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 417 by chrisfen, Thu Mar 10 15:10:24 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 {
55 > namespace OpenMD {
56    VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
57      dt2 = 0.5 * dt;
58      rotAlgo = new DLM();
# Line 67 | Line 68 | namespace oopse {
68      
69      forceMan_->init();
70      
71 <    // remove center of mass drift velocity (in case we passed in a configuration
72 <    // that was drifting
71 >    // remove center of mass drift velocity (in case we passed in a
72 >    // configuration that was drifting)
73      velocitizer_->removeComDrift();
74      
75      // initialize the forces before the first step
76 <    calcForce(true, true);
76 >    calcForce();
77      
78 <    //execute constraint algorithm to make sure at the very beginning the system is constrained  
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
82 >      calcForce();
83 >      rattle->constraintB();      
84 >      //copy the current snapshot to previous snapshot
85 >      info_->getSnapshotManager()->advance();
86      }
87      
88      if (needVelocityScaling) {
# Line 89 | Line 92 | namespace oopse {
92      dumpWriter = createDumpWriter();
93      
94      statWriter = createStatWriter();
95 <    
93 <    if (simParams->getUseSolidThermInt()) {
94 <      restWriter = createRestWriter();
95 <      restWriter->writeZangle();
96 <    }
97 <    
95 >
96      dumpWriter->writeDumpAndEor();
97 <    
98 <    
97 >
98 >    progressBar = new ProgressBar();
99 >
100      //save statistics, before writeStat,  we must save statistics
101      thermo.saveStat();
102      saveConservedQuantity();
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() {
120 >  }
121 >
122 >  void VelocityVerletIntegrator::doIntegrate() {
123    
124    
125 <  initialize();
125 >    initialize();
126    
127 <  while (currentSnapshot_->getTime() < runTime) {
127 >    while (currentSnapshot_->getTime() < runTime) {
128      
129 <    preStep();
129 >      preStep();
130      
131 <    integrateStep();
131 >      integrateStep();
132      
133 <    postStep();
134 <    
135 <  }
133 >      postStep();
134 >      
135 >    }
136    
137 <  finalize();
137 >    finalize();
138    
139 < }
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) < oopse::epsilon) {
146 <    needPotential = true;
147 <    needStress = true;  
145 >    if (difference > 0 || fabs(difference) < OpenMD::epsilon) {
146 >      needPotential = true;
147 >      needStress = true;  
148 >    }
149    }
141  
142 }
150  
151 < void VelocityVerletIntegrator::postStep() {
151 >  void VelocityVerletIntegrator::postStep() {
152 >
153 >    //save snapshot
154 >    info_->getSnapshotManager()->advance();
155    
156 <  //save snapshot
157 <  info_->getSnapshotManager()->advance();
158 <  
159 <  //increase time
160 <  currentSnapshot_->increaseTime(dt);        
161 <  
162 <  if (needVelocityScaling) {
163 <    if (currentSnapshot_->getTime() >= currThermal) {
154 <      velocitizer_->velocitize(targetScalingTemp);
155 <      currThermal += thermalTime;
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 <  }
166 <  
167 <  if (currentSnapshot_->getTime() >= currSample) {
168 <    dumpWriter->writeDumpAndEor();
165 >    if (useRNEMD) {
166 >      if (currentSnapshot_->getTime() >= currRNEMD) {
167 >        rnemd_->doRNEMD();
168 >        currRNEMD += RNEMD_exchangeTime;
169 >      }
170 >      rnemd_->collectData();
171 >    }
172      
173 <    if (simParams->getUseSolidThermInt())
174 <      restWriter->writeZangle();
173 >    if (currentSnapshot_->getTime() >= currSample) {
174 >      dumpWriter->writeDumpAndEor();
175 >      
176 >      currSample += sampleTime;
177 >    }
178      
179 <    currSample += sampleTime;
180 <  }
181 <  
182 <  if (currentSnapshot_->getTime() >= currStatus) {
183 <    //save statistics, before writeStat,  we must save statistics
184 <    thermo.saveStat();
185 <    saveConservedQuantity();
186 <    statWriter->writeStat(currentSnapshot_->statData);
179 >    if (currentSnapshot_->getTime() >= currStatus) {
180 >      //save statistics, before writeStat,  we must save statistics
181 >      thermo.saveStat();
182 >      saveConservedQuantity();
183 >
184 >      if (simParams->getUseRNEMD()) {
185 >        rnemd_->getStatus();
186 >      }
187 >
188 >      statWriter->writeStat(currentSnapshot_->statData);
189 >
190 >      progressBar->setStatus(currentSnapshot_->getTime(), runTime);
191 >      progressBar->update();
192 >
193 >      needPotential = false;
194 >      needStress = false;
195 >      currStatus += statusTime;
196 >    }
197      
198 <    needPotential = false;
199 <    needStress = false;
200 <    currStatus += statusTime;
198 >    if (needReset && currentSnapshot_->getTime() >= currReset) {    
199 >      resetIntegrator();
200 >      currReset += resetTime;
201 >    }        
202    }
178  
179  
180 }
203  
204  
205 < void VelocityVerletIntegrator::finalize() {
206 <  dumpWriter->writeEor();
205 >  void VelocityVerletIntegrator::finalize() {
206 >    dumpWriter->writeEor();
207    
208 <  if (simParams->getUseSolidThermInt()) {
209 <    restWriter->writeZangle();
188 <    delete restWriter;
189 <    restWriter = NULL;
190 <  }
208 >    delete dumpWriter;
209 >    delete statWriter;
210    
211 <  delete dumpWriter;
212 <  delete statWriter;
211 >    dumpWriter = NULL;
212 >    statWriter = NULL;
213    
214 <  dumpWriter = NULL;
196 <  statWriter = NULL;
197 <  
198 < }
214 >  }
215  
216 < void VelocityVerletIntegrator::integrateStep() {
216 >  void VelocityVerletIntegrator::integrateStep() {
217    
218 <  moveA();
219 <  calcForce(needPotential, needStress);
220 <  moveB();
221 < }
218 >    moveA();
219 >    calcForce();
220 >    moveB();
221 >  }
222  
223  
224 < void VelocityVerletIntegrator::calcForce(bool needPotential,
225 <                                         bool needStress) {
226 <  forceMan_->calcForces(needPotential, needStress);
211 < }
224 >  void VelocityVerletIntegrator::calcForce() {
225 >    forceMan_->calcForces();
226 >  }
227  
228 < DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
229 <  return new DumpWriter(info_);
230 < }
228 >  DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
229 >    return new DumpWriter(info_);
230 >  }
231  
232 < StatWriter* VelocityVerletIntegrator::createStatWriter() {
233 <  // if solidThermInt is true, add extra information to the statfile
234 <  if (simParams->getUseSolidThermInt()){
235 <    StatsBitSet mask;
236 <    mask.set(Stats::TIME);
237 <    mask.set(Stats::TOTAL_ENERGY);
238 <    mask.set(Stats::POTENTIAL_ENERGY);
239 <    mask.set(Stats::KINETIC_ENERGY);
240 <    mask.set(Stats::TEMPERATURE);
241 <    mask.set(Stats::PRESSURE);
242 <    mask.set(Stats::CONSERVED_QUANTITY);
243 <    mask.set(Stats::VRAW);
244 <    mask.set(Stats::VHARM);
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 >
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    }
232  
233  return new StatWriter(info_->getStatFileName());
234 }
282  
236 RestWriter* VelocityVerletIntegrator::createRestWriter(){
237  return new RestWriter(info_);
238 }
283  
284 <
241 < } //end namespace oopse
284 > } //end namespace OpenMD

Comparing:
trunk/src/integrators/VelocityVerletIntegrator.cpp (property svn:keywords), Revision 417 by chrisfen, Thu Mar 10 15:10:24 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