ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/integrators/VelocityVerletIntegrator.cpp
Revision: 2019
Committed: Mon Feb 14 18:12:43 2005 UTC (19 years, 4 months ago) by tim
File size: 6103 byte(s)
Log Message:
fix a bug in VelocityVerletIntegrator : last frame is written twice

File Contents

# User Rev Content
1 gezelter 1930 /*
2     * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3     *
4     * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
6     * redistribute this software in source and binary code form, provided
7     * that the following conditions are met:
8     *
9     * 1. Acknowledgement of the program authors must be made in any
10     * publication of scientific results based in part on use of the
11     * program. An acceptable form of acknowledgement is citation of
12     * the article in which the program was described (Matthew
13     * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15     * Parallel Simulation Engine for Molecular Dynamics,"
16     * J. Comput. Chem. 26, pp. 252-271 (2005))
17     *
18     * 2. Redistributions of source code must retain the above copyright
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
41    
42     /**
43     * @file VelocityVerletIntegrator.cpp
44     * @author tlin
45     * @date 11/09/2004
46     * @time 16:16am
47     * @version 1.0
48     */
49    
50     #include "integrators/VelocityVerletIntegrator.hpp"
51     #include "integrators/DLM.hpp"
52 tim 1960 #include "utils/StringUtils.hpp"
53 gezelter 1930
54     namespace oopse {
55     VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
56     dt2 = 0.5 * dt;
57     rotAlgo = new DLM();
58     rattle = new Rattle(info);
59     }
60    
61     VelocityVerletIntegrator::~VelocityVerletIntegrator() {
62     delete rotAlgo;
63     delete rattle;
64     }
65    
66     void VelocityVerletIntegrator::initialize(){
67    
68     forceMan_->init();
69    
70     // remove center of mass drift velocity (in case we passed in a configuration
71     // that was drifting
72     velocitizer_->removeComDrift();
73    
74     // initialize the forces before the first step
75     calcForce(true, true);
76    
77     //execute constraint algorithm to make sure at the very beginning the system is constrained
78     if (info_->getNGlobalConstraints() > 0) {
79     rattle->constraintA();
80     calcForce(true, true);
81     rattle->constraintB();
82     info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
83     }
84    
85     if (needVelocityScaling) {
86     velocitizer_->velocitize(targetScalingTemp);
87     }
88    
89     dumpWriter = createDumpWriter();
90 tim 2008
91 gezelter 1930 statWriter = createStatWriter();
92    
93     dumpWriter->writeDump();
94 tim 1960
95 gezelter 1930 //save statistics, before writeStat, we must save statistics
96     thermo.saveStat();
97     saveConservedQuantity();
98     statWriter->writeStat(currentSnapshot_->statData);
99    
100     currSample = sampleTime + currentSnapshot_->getTime();
101     currStatus = statusTime + currentSnapshot_->getTime();;
102     currThermal = thermalTime + + currentSnapshot_->getTime();
103     needPotential = false;
104     needStress = false;
105    
106     }
107    
108     void VelocityVerletIntegrator::doIntegrate() {
109    
110    
111     initialize();
112    
113     while (currentSnapshot_->getTime() < runTime) {
114    
115     preStep();
116    
117     integrateStep();
118    
119     postStep();
120    
121     }
122    
123     finalize();
124    
125     }
126    
127    
128     void VelocityVerletIntegrator::preStep() {
129     double difference = currentSnapshot_->getTime() + dt - currStatus;
130    
131     if (difference > 0 || fabs(difference) < oopse::epsilon) {
132     needPotential = true;
133     needStress = true;
134     }
135    
136     }
137    
138     void VelocityVerletIntegrator::postStep() {
139    
140     //save snapshot
141     info_->getSnapshotManager()->advance();
142    
143     //increase time
144     currentSnapshot_->increaseTime(dt);
145    
146     if (needVelocityScaling) {
147     if (currentSnapshot_->getTime() >= currThermal) {
148     velocitizer_->velocitize(targetScalingTemp);
149     currThermal += thermalTime;
150     }
151     }
152    
153     if (currentSnapshot_->getTime() >= currSample) {
154     dumpWriter->writeDump();
155 tim 2008 //eorWriter->writeDump();
156 gezelter 1930 currSample += sampleTime;
157     }
158    
159     if (currentSnapshot_->getTime() >= currStatus) {
160     //save statistics, before writeStat, we must save statistics
161     thermo.saveStat();
162     saveConservedQuantity();
163     statWriter->writeStat(currentSnapshot_->statData);
164    
165     needPotential = false;
166     needStress = false;
167     currStatus += statusTime;
168     }
169    
170    
171     }
172    
173    
174     void VelocityVerletIntegrator::finalize() {
175    
176     delete dumpWriter;
177     delete statWriter;
178    
179     dumpWriter = NULL;
180     statWriter = NULL;
181    
182     }
183    
184     void VelocityVerletIntegrator::integrateStep() {
185    
186     moveA();
187     calcForce(needPotential, needStress);
188     moveB();
189     }
190    
191    
192     void VelocityVerletIntegrator::calcForce(bool needPotential,
193     bool needStress) {
194     forceMan_->calcForces(needPotential, needStress);
195     }
196    
197     DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
198     return new DumpWriter(info_, info_->getDumpFileName());
199     }
200    
201     StatWriter* VelocityVerletIntegrator::createStatWriter() {
202     return new StatWriter(info_->getStatFileName());
203     }
204    
205    
206     } //end namespace oopse

Properties

Name Value
svn:executable *