ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/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.
Revision 2074 by gezelter, Sun Mar 8 00:02:29 2015 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, 234107 (2008).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   /**
44   * @file VelocityVerletIntegrator.cpp
45   * @author tlin
46   * @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   #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) {
57      dt2 = 0.5 * dt;
58 <    rotAlgo = new DLM();
59 <    rattle = new Rattle(info);
60 < }
61 <
62 < VelocityVerletIntegrator::~VelocityVerletIntegrator() {
63 <    delete rotAlgo;
64 <    delete rattle;
65 < }
66 <
67 < void VelocityVerletIntegrator::initialize(){
68 <
68 <    forceMan_->init();
69 <
70 <    // remove center of mass drift velocity (in case we passed in a configuration
71 <    // that was drifting
58 >  }
59 >  
60 >  VelocityVerletIntegrator::~VelocityVerletIntegrator() {
61 >  }
62 >  
63 >  void VelocityVerletIntegrator::initialize(){
64 >    
65 >    forceMan_->initialize();
66 >    
67 >    // remove center of mass drift velocity (in case we passed in a
68 >    // configuration that was drifting)
69      velocitizer_->removeComDrift();
70  
71 +    // find the initial fluctuating charges.
72 +    flucQ_->initialize();
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  
75 >    calcForce();
76 >    
77 >    // execute the constraint algorithm to make sure that the system is
78 >    // constrained at the very beginning  
79      if (info_->getNGlobalConstraints() > 0) {
80 <        rattle->constraintA();
81 <        calcForce(true, true);
82 <        rattle->constraintB();        
83 <        info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
80 >      rattle_->constraintA();
81 >      calcForce();
82 >      rattle_->constraintB();      
83 >      //copy the current snapshot to previous snapshot
84 >      info_->getSnapshotManager()->advance();
85      }
86 <
86 >    
87      if (needVelocityScaling) {
88 <        velocitizer_->velocitize(targetScalingTemp);
88 >      velocitizer_->velocitize(targetScalingTemp);
89      }
90      
91 <    dumpWriter = createDumpWriter();
91 >    dumpWriter = createDumpWriter();    
92 >    statWriter = createStatWriter();
93 >    dumpWriter->writeDumpAndEor();
94  
95 <    statWriter = createStatWriter();
95 >    progressBar = new ProgressBar();
96  
93    dumpWriter->writeDumpAndEor();
94    
97      //save statistics, before writeStat,  we must save statistics
96    thermo.saveStat();
98      saveConservedQuantity();
99 <    statWriter->writeStat(currentSnapshot_->statData);
99 >    stats->collectStats();
100  
101 <    currSample = sampleTime + currentSnapshot_->getTime();
102 <    currStatus =  statusTime + currentSnapshot_->getTime();;
103 <    currThermal = thermalTime +  + currentSnapshot_->getTime();
101 >    if (simParams->getRNEMDParameters()->getUseRNEMD())
102 >      rnemd_->getStarted();
103 >
104 >    statWriter->writeStat();
105 >    
106 >    currSample = sampleTime + snap->getTime();
107 >    currStatus =  statusTime + snap->getTime();
108 >    currThermal = thermalTime + snap->getTime();
109 >    if (needReset) {
110 >      currReset = resetTime + snap->getTime();
111 >    }
112 >    if (simParams->getRNEMDParameters()->getUseRNEMD()){
113 >      currRNEMD = RNEMD_exchangeTime + snap->getTime();
114 >    }
115      needPotential = false;
116      needStress = false;      
117 <  
118 < }
119 <        
120 < void VelocityVerletIntegrator::doIntegrate() {
121 <
110 <
117 >    
118 >  }
119 >
120 >  void VelocityVerletIntegrator::doIntegrate() {
121 >  
122      initialize();
123 +  
124 +    while (snap->getTime() < runTime) {
125 +      preStep();    
126 +      integrateStep();    
127 +      postStep();      
128 +    }  
129 +    finalize();
130 +  }
131  
113    while (currentSnapshot_->getTime() < runTime) {
114        
115        preStep();
132  
133 <        integrateStep();
134 <        
135 <        postStep();
136 <
133 >  void VelocityVerletIntegrator::preStep() {
134 >    RealType difference = snap->getTime() + dt - currStatus;
135 >  
136 >    if (difference > 0 || fabs(difference) < OpenMD::epsilon) {
137 >      needPotential = true;
138 >      needStress = true;  
139      }
140 +  }
141  
142 <    finalize();
142 >  void VelocityVerletIntegrator::postStep() {
143 >
144 >  
145 >    if (needVelocityScaling) {
146 >      if (snap->getTime() >= currThermal) {
147 >        velocitizer_->velocitize(targetScalingTemp);
148 >        currThermal += thermalTime;
149 >      }
150 >    }
151 >    if (useRNEMD) {
152 >      if (snap->getTime() >= currRNEMD) {
153 >        rnemd_->doRNEMD();
154 >        currRNEMD += RNEMD_exchangeTime;
155 >      }
156 >      rnemd_->collectData();
157 >    }
158      
159 < }
159 >    if (snap->getTime() >= currSample) {
160 >      dumpWriter->writeDumpAndEor();
161 >      
162 >      currSample += sampleTime;
163 >    }
164 >    
165 >    if (snap->getTime() >= currStatus) {
166 >      //save statistics, before writeStat,  we must save statistics
167 >      saveConservedQuantity();
168 >      stats->collectStats();
169  
170 +      if (simParams->getRNEMDParameters()->getUseRNEMD()) {
171 +        rnemd_->writeOutputFile();
172 +      }
173  
174 < void VelocityVerletIntegrator::preStep() {
129 <        double difference = currentSnapshot_->getTime() + dt - currStatus;
174 >      statWriter->writeStat();
175  
176 <        if (difference > 0 || fabs(difference) < oopse::epsilon) {
177 <            needPotential = true;
133 <            needStress = true;  
134 <        }
176 >      progressBar->setStatus(snap->getTime(), runTime);
177 >      progressBar->update();
178  
179 < }
179 >      needPotential = false;
180 >      needStress = false;
181 >      currStatus += statusTime;
182 >    }
183 >    
184 >    if (needReset && snap->getTime() >= currReset) {    
185 >      resetIntegrator();
186 >      currReset += resetTime;
187 >    }        
188 >    //save snapshot
189 >    info_->getSnapshotManager()->advance();
190 >  
191 >    //increase time
192 >    snap->increaseTime(dt);        
193  
194 < void VelocityVerletIntegrator::postStep() {
194 >  }
195  
140        //save snapshot
141        info_->getSnapshotManager()->advance();
196  
197 <        //increase time
198 <        currentSnapshot_->increaseTime(dt);        
199 <        
200 <        if (needVelocityScaling) {
201 <            if (currentSnapshot_->getTime() >= currThermal) {
202 <                velocitizer_->velocitize(targetScalingTemp);
203 <                currThermal += thermalTime;
204 <            }
151 <        }
152 <
153 <        if (currentSnapshot_->getTime() >= currSample) {
154 <            dumpWriter->writeDumpAndEor();
155 <            currSample += sampleTime;
156 <        }
157 <
158 <        if (currentSnapshot_->getTime() >= currStatus) {
159 <            //save statistics, before writeStat,  we must save statistics
160 <            thermo.saveStat();
161 <            saveConservedQuantity();
162 <            statWriter->writeStat(currentSnapshot_->statData);
163 <
164 <            needPotential = false;
165 <            needStress = false;
166 <            currStatus += statusTime;
167 <        }
168 <
169 <        
170 < }
171 <
172 <
173 < void VelocityVerletIntegrator::finalize() {
174 <     dumpWriter->writeEor();
175 <
197 >  void VelocityVerletIntegrator::finalize() {
198 >    dumpWriter->writeEor();
199 >    if (simParams->getRNEMDParameters()->getUseRNEMD()) {
200 >      rnemd_->writeOutputFile();
201 >    }
202 >    progressBar->setStatus(runTime, runTime);
203 >    progressBar->update();
204 >
205      delete dumpWriter;
206      delete statWriter;
207 <
207 >  
208      dumpWriter = NULL;
209      statWriter = NULL;
210 <    
182 < }
210 >  }
211  
212 < void VelocityVerletIntegrator::integrateStep() {
213 <
212 >  void VelocityVerletIntegrator::integrateStep() {
213 >  
214      moveA();
215 <    calcForce(needPotential, needStress);
215 >    calcForce();
216      moveB();
217 < }
217 >  }
218  
219  
220 < void VelocityVerletIntegrator::calcForce(bool needPotential,
221 <                                         bool needStress) {
222 <    forceMan_->calcForces(needPotential, needStress);
223 < }
220 >  void VelocityVerletIntegrator::calcForce() {
221 >    forceMan_->calcForces();
222 >    flucQ_->applyConstraints();
223 >  }
224  
225 < DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
225 >  DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
226      return new DumpWriter(info_);
227 < }
227 >  }
228  
229 < StatWriter* VelocityVerletIntegrator::createStatWriter() {
230 <    return new StatWriter(info_->getStatFileName());
231 < }
229 >  StatWriter* VelocityVerletIntegrator::createStatWriter() {
230 >    
231 >    stats = new Stats(info_);
232 >    statWriter = new StatWriter(info_->getStatFileName(), stats);
233 >    
234 >    return statWriter;
235 >  }
236  
237 <
206 < } //end namespace oopse
237 > } //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.
Revision 2074 by gezelter, Sun Mar 8 00:02:29 2015 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines