ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/integrators/VelocityVerletIntegrator.cpp
(Generate patch)

Comparing:
trunk/src/integrators/VelocityVerletIntegrator.cpp (file contents), Revision 376 by tim, Thu Feb 24 20:55:07 2005 UTC vs.
branches/development/src/integrators/VelocityVerletIntegrator.cpp (file contents), Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# Line 6 | Line 6
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
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 + * [4]  Vardeman & Gezelter, in progress (2009).                        
40   */
41  
42   /**
# Line 50 | Line 50
50   #include "integrators/VelocityVerletIntegrator.hpp"
51   #include "integrators/DLM.hpp"
52   #include "utils/StringUtils.hpp"
53 + #include "utils/ProgressBar.hpp"
54  
55 < namespace oopse {
56 < VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
55 > namespace OpenMD {
56 >  VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
57      dt2 = 0.5 * dt;
58      rotAlgo = new DLM();
59      rattle = new Rattle(info);
60 < }
61 <
62 < VelocityVerletIntegrator::~VelocityVerletIntegrator() {
60 >  }
61 >  
62 >  VelocityVerletIntegrator::~VelocityVerletIntegrator() {
63      delete rotAlgo;
64      delete rattle;
65 < }
66 <
67 < void VelocityVerletIntegrator::initialize(){
68 <
65 >  }
66 >  
67 >  void VelocityVerletIntegrator::initialize(){
68 >    
69      forceMan_->init();
70 <
71 <    // remove center of mass drift velocity (in case we passed in a configuration
72 <    // that was drifting
70 >    
71 >    // remove center of mass drift velocity (in case we passed in a
72 >    // configuration that was drifting)
73      velocitizer_->removeComDrift();
74 <
74 >    
75      // initialize the forces before the first step
76 <    calcForce(true, true);
77 <
78 <    //execute constraint algorithm to make sure at the very beginning the system is constrained  
76 >    calcForce();
77 >    
78 >    // execute the constraint algorithm to make sure that the system is
79 >    // constrained at the very beginning  
80      if (info_->getNGlobalConstraints() > 0) {
81 <        rattle->constraintA();
82 <        calcForce(true, true);
83 <        rattle->constraintB();        
84 <        info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
81 >      rattle->constraintA();
82 >      calcForce();
83 >      rattle->constraintB();      
84 >      //copy the current snapshot to previous snapshot
85 >      info_->getSnapshotManager()->advance();
86      }
87 <
87 >    
88      if (needVelocityScaling) {
89 <        velocitizer_->velocitize(targetScalingTemp);
89 >      velocitizer_->velocitize(targetScalingTemp);
90      }
91      
92      dumpWriter = createDumpWriter();
93 <
93 >    
94      statWriter = createStatWriter();
95 <
95 >
96      dumpWriter->writeDumpAndEor();
97 <    
97 >
98 >    progressBar = new ProgressBar();
99 >
100      //save statistics, before writeStat,  we must save statistics
101      thermo.saveStat();
102      saveConservedQuantity();
103 <    statWriter->writeStat(currentSnapshot_->statData);
103 >    if (simParams->getUseRNEMD())
104 >      rnemd_->getStarted();
105  
106 +    statWriter->writeStat(currentSnapshot_->statData);
107 +    
108      currSample = sampleTime + currentSnapshot_->getTime();
109 <    currStatus =  statusTime + currentSnapshot_->getTime();;
110 <    currThermal = thermalTime +  + currentSnapshot_->getTime();
109 >    currStatus =  statusTime + currentSnapshot_->getTime();
110 >    currThermal = thermalTime + currentSnapshot_->getTime();
111 >    if (needReset) {
112 >      currReset = resetTime + currentSnapshot_->getTime();
113 >    }
114 >    if (simParams->getUseRNEMD()){
115 >      currRNEMD = RNEMD_exchangeTime + currentSnapshot_->getTime();
116 >    }
117      needPotential = false;
118      needStress = false;      
119 <  
120 < }
121 <        
122 < void VelocityVerletIntegrator::doIntegrate() {
123 <
124 <
119 >    
120 >  }
121 >
122 >  void VelocityVerletIntegrator::doIntegrate() {
123 >  
124 >  
125      initialize();
126 <
126 >  
127      while (currentSnapshot_->getTime() < runTime) {
128 <        
129 <        preStep();
130 <
131 <        integrateStep();
132 <        
133 <        postStep();
134 <
128 >    
129 >      preStep();
130 >    
131 >      integrateStep();
132 >    
133 >      postStep();
134 >      
135      }
136 <
136 >  
137      finalize();
138 <    
139 < }
138 >  
139 >  }
140  
141  
142 < void VelocityVerletIntegrator::preStep() {
143 <        double difference = currentSnapshot_->getTime() + dt - currStatus;
142 >  void VelocityVerletIntegrator::preStep() {
143 >    RealType difference = currentSnapshot_->getTime() + dt - currStatus;
144 >  
145 >    if (difference > 0 || fabs(difference) < OpenMD::epsilon) {
146 >      needPotential = true;
147 >      needStress = true;  
148 >    }
149 >  }
150  
151 <        if (difference > 0 || fabs(difference) < oopse::epsilon) {
132 <            needPotential = true;
133 <            needStress = true;  
134 <        }
151 >  void VelocityVerletIntegrator::postStep() {
152  
153 < }
153 >    //save snapshot
154 >    info_->getSnapshotManager()->advance();
155 >  
156 >    //increase time
157 >    currentSnapshot_->increaseTime(dt);        
158 >  
159 >    if (needVelocityScaling) {
160 >      if (currentSnapshot_->getTime() >= currThermal) {
161 >        velocitizer_->velocitize(targetScalingTemp);
162 >        currThermal += thermalTime;
163 >      }
164 >    }
165 >    if (useRNEMD) {
166 >      if (currentSnapshot_->getTime() >= currRNEMD) {
167 >        rnemd_->doRNEMD();
168 >        currRNEMD += RNEMD_exchangeTime;
169 >      }
170 >      rnemd_->collectData();
171 >    }
172 >    
173 >    if (currentSnapshot_->getTime() >= currSample) {
174 >      dumpWriter->writeDumpAndEor();
175 >      
176 >      currSample += sampleTime;
177 >    }
178 >    
179 >    if (currentSnapshot_->getTime() >= currStatus) {
180 >      //save statistics, before writeStat,  we must save statistics
181 >      thermo.saveStat();
182 >      saveConservedQuantity();
183  
184 < void VelocityVerletIntegrator::postStep() {
184 >      if (simParams->getUseRNEMD()) {
185 >        rnemd_->getStatus();
186 >      }
187  
188 <        //save snapshot
141 <        info_->getSnapshotManager()->advance();
188 >      statWriter->writeStat(currentSnapshot_->statData);
189  
190 <        //increase time
191 <        currentSnapshot_->increaseTime(dt);        
145 <        
146 <        if (needVelocityScaling) {
147 <            if (currentSnapshot_->getTime() >= currThermal) {
148 <                velocitizer_->velocitize(targetScalingTemp);
149 <                currThermal += thermalTime;
150 <            }
151 <        }
190 >      progressBar->setStatus(currentSnapshot_->getTime(), runTime);
191 >      progressBar->update();
192  
193 <        if (currentSnapshot_->getTime() >= currSample) {
194 <            dumpWriter->writeDumpAndEor();
195 <            currSample += sampleTime;
196 <        }
193 >      needPotential = false;
194 >      needStress = false;
195 >      currStatus += statusTime;
196 >    }
197 >    
198 >    if (needReset && currentSnapshot_->getTime() >= currReset) {    
199 >      resetIntegrator();
200 >      currReset += resetTime;
201 >    }        
202 >  }
203  
158        if (currentSnapshot_->getTime() >= currStatus) {
159            //save statistics, before writeStat,  we must save statistics
160            thermo.saveStat();
161            saveConservedQuantity();
162            statWriter->writeStat(currentSnapshot_->statData);
204  
205 <            needPotential = false;
206 <            needStress = false;
207 <            currStatus += statusTime;
167 <        }
168 <
169 <        
170 < }
171 <
172 <
173 < void VelocityVerletIntegrator::finalize() {
174 <     dumpWriter->writeEor();
175 <
205 >  void VelocityVerletIntegrator::finalize() {
206 >    dumpWriter->writeEor();
207 >  
208      delete dumpWriter;
209      delete statWriter;
210 <
210 >  
211      dumpWriter = NULL;
212      statWriter = NULL;
213 <    
214 < }
213 >  
214 >  }
215  
216 < void VelocityVerletIntegrator::integrateStep() {
217 <
216 >  void VelocityVerletIntegrator::integrateStep() {
217 >  
218      moveA();
219 <    calcForce(needPotential, needStress);
219 >    calcForce();
220      moveB();
221 < }
221 >  }
222  
223  
224 < void VelocityVerletIntegrator::calcForce(bool needPotential,
225 <                                         bool needStress) {
226 <    forceMan_->calcForces(needPotential, needStress);
195 < }
224 >  void VelocityVerletIntegrator::calcForce() {
225 >    forceMan_->calcForces();
226 >  }
227  
228 < DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
228 >  DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
229      return new DumpWriter(info_);
230 < }
230 >  }
231  
232 < StatWriter* VelocityVerletIntegrator::createStatWriter() {
202 <    return new StatWriter(info_->getStatFileName());
203 < }
232 >  StatWriter* VelocityVerletIntegrator::createStatWriter() {
233  
234 +    std::string statFileFormatString = simParams->getStatFileFormat();
235 +    StatsBitSet mask = parseStatFileFormat(statFileFormatString);
236 +  
237 +    // if we're doing a thermodynamic integration, we'll want the raw
238 +    // potential as well as the full potential:
239  
240 < } //end namespace oopse
240 >
241 >    if (simParams->getUseThermodynamicIntegration())
242 >      mask.set(Stats::VRAW);
243 >
244 >    // if we've got restraints turned on, we'll also want a report of the
245 >    // total harmonic restraints
246 >    if (simParams->getUseRestraints()){
247 >      mask.set(Stats::VHARM);
248 >    }
249 >
250 >    if (simParams->havePrintPressureTensor() &&
251 >        simParams->getPrintPressureTensor()){
252 >      mask.set(Stats::PRESSURE_TENSOR_XX);
253 >      mask.set(Stats::PRESSURE_TENSOR_XY);
254 >      mask.set(Stats::PRESSURE_TENSOR_XZ);
255 >      mask.set(Stats::PRESSURE_TENSOR_YX);
256 >      mask.set(Stats::PRESSURE_TENSOR_YY);
257 >      mask.set(Stats::PRESSURE_TENSOR_YZ);
258 >      mask.set(Stats::PRESSURE_TENSOR_ZX);
259 >      mask.set(Stats::PRESSURE_TENSOR_ZY);
260 >      mask.set(Stats::PRESSURE_TENSOR_ZZ);
261 >    }
262 >    
263 >    if (simParams->getAccumulateBoxDipole()) {
264 >      mask.set(Stats::BOX_DIPOLE_X);
265 >      mask.set(Stats::BOX_DIPOLE_Y);
266 >      mask.set(Stats::BOX_DIPOLE_Z);
267 >    }
268 >  
269 >    if (simParams->haveTaggedAtomPair() && simParams->havePrintTaggedPairDistance()) {
270 >      if (simParams->getPrintTaggedPairDistance()) {
271 >        mask.set(Stats::TAGGED_PAIR_DISTANCE);
272 >      }
273 >    }
274 >
275 >    if (simParams->getUseRNEMD()) {
276 >      mask.set(Stats::RNEMD_EXCHANGE_TOTAL);
277 >    }
278 >    
279 >
280 >    return new StatWriter(info_->getStatFileName(), mask);
281 >  }
282 >
283 >
284 > } //end namespace OpenMD

Comparing:
trunk/src/integrators/VelocityVerletIntegrator.cpp (property svn:keywords), Revision 376 by tim, Thu Feb 24 20:55:07 2005 UTC vs.
branches/development/src/integrators/VelocityVerletIntegrator.cpp (property svn:keywords), Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines