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 276 by tim, Wed Jan 26 15:26:47 2005 UTC vs.
branches/development/src/integrators/VelocityVerletIntegrator.cpp (file contents), Revision 1808 by gezelter, Mon Oct 22 20:42:10 2012 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]  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();
92 <    eorWriter = createEorWriter();
92 >    
93      statWriter = createStatWriter();
94 +
95 +    dumpWriter->writeDumpAndEor();
96  
97 <    dumpWriter->writeDump();
98 <    eorWriter->writeDump();
95 <    
97 >    progressBar = new ProgressBar();
98 >
99      //save statistics, before writeStat,  we must save statistics
97    thermo.saveStat();
100      saveConservedQuantity();
101 <    statWriter->writeStat(currentSnapshot_->statData);
101 >    stats->collectStats();
102  
103 <    currSample = sampleTime + currentSnapshot_->getTime();
104 <    currStatus =  statusTime + currentSnapshot_->getTime();;
105 <    currThermal = thermalTime +  + currentSnapshot_->getTime();
103 >    if (simParams->getRNEMDParameters()->getUseRNEMD())
104 >      rnemd_->getStarted();
105 >
106 >    statWriter->writeStat();
107 >    
108 >    currSample = sampleTime + snap->getTime();
109 >    currStatus =  statusTime + snap->getTime();
110 >    currThermal = thermalTime + snap->getTime();
111 >    if (needReset) {
112 >      currReset = resetTime + snap->getTime();
113 >    }
114 >    if (simParams->getRNEMDParameters()->getUseRNEMD()){
115 >      currRNEMD = RNEMD_exchangeTime + snap->getTime();
116 >    }
117      needPotential = false;
118      needStress = false;      
119 <  
120 < }
121 <        
122 < void VelocityVerletIntegrator::doIntegrate() {
123 <
111 <
119 >    
120 >  }
121 >
122 >  void VelocityVerletIntegrator::doIntegrate() {
123 >  
124      initialize();
125 +  
126 +    while (snap->getTime() < runTime) {    
127 +      preStep();    
128 +      integrateStep();    
129 +      postStep();      
130 +    }  
131 +    finalize();
132 +  }
133  
114    while (currentSnapshot_->getTime() < runTime) {
115        
116        preStep();
134  
135 <        integrateStep();
136 <        
137 <        postStep();
138 <
135 >  void VelocityVerletIntegrator::preStep() {
136 >    RealType difference = snap->getTime() + dt - currStatus;
137 >  
138 >    if (difference > 0 || fabs(difference) < OpenMD::epsilon) {
139 >      needPotential = true;
140 >      needStress = true;  
141      }
142 +  }
143  
144 <    finalize();
144 >  void VelocityVerletIntegrator::postStep() {
145 >
146 >    //save snapshot
147 >    info_->getSnapshotManager()->advance();
148 >  
149 >    //increase time
150 >    snap->increaseTime(dt);        
151 >  
152 >    if (needVelocityScaling) {
153 >      if (snap->getTime() >= currThermal) {
154 >        velocitizer_->velocitize(targetScalingTemp);
155 >        currThermal += thermalTime;
156 >      }
157 >    }
158 >    if (useRNEMD) {
159 >      if (snap->getTime() >= currRNEMD) {
160 >        rnemd_->doRNEMD();
161 >        currRNEMD += RNEMD_exchangeTime;
162 >      }
163 >      rnemd_->collectData();
164 >    }
165      
166 < }
166 >    if (snap->getTime() >= currSample) {
167 >      dumpWriter->writeDumpAndEor();
168 >      
169 >      currSample += sampleTime;
170 >    }
171 >    
172 >    if (snap->getTime() >= currStatus) {
173 >      //save statistics, before writeStat,  we must save statistics
174 >      stats->collectStats();
175 >      saveConservedQuantity();
176  
177 +      if (simParams->getRNEMDParameters()->getUseRNEMD()) {
178 +        rnemd_->writeOutputFile();
179 +      }
180  
181 < void VelocityVerletIntegrator::preStep() {
130 <        double difference = currentSnapshot_->getTime() + dt - currStatus;
181 >      statWriter->writeStat();
182  
183 <        if (difference > 0 || fabs(difference) < oopse::epsilon) {
184 <            needPotential = true;
134 <            needStress = true;  
135 <        }
183 >      progressBar->setStatus(snap->getTime(), runTime);
184 >      progressBar->update();
185  
186 < }
186 >      needPotential = false;
187 >      needStress = false;
188 >      currStatus += statusTime;
189 >    }
190 >    
191 >    if (needReset && snap->getTime() >= currReset) {    
192 >      resetIntegrator();
193 >      currReset += resetTime;
194 >    }        
195 >  }
196  
139 void VelocityVerletIntegrator::postStep() {
197  
198 <        //save snapshot
199 <        info_->getSnapshotManager()->advance();
200 <
201 <        //increase time
202 <        currentSnapshot_->increaseTime(dt);        
203 <        
147 <        if (needVelocityScaling) {
148 <            if (currentSnapshot_->getTime() >= currThermal) {
149 <                velocitizer_->velocitize(targetScalingTemp);
150 <                currThermal += thermalTime;
151 <            }
152 <        }
153 <
154 <        if (currentSnapshot_->getTime() >= currSample) {
155 <            dumpWriter->writeDump();
156 <            eorWriter->writeDump();
157 <            currSample += sampleTime;
158 <        }
159 <
160 <        if (currentSnapshot_->getTime() >= currStatus) {
161 <            //save statistics, before writeStat,  we must save statistics
162 <            thermo.saveStat();
163 <            saveConservedQuantity();
164 <            statWriter->writeStat(currentSnapshot_->statData);
165 <
166 <            needPotential = false;
167 <            needStress = false;
168 <            currStatus += statusTime;
169 <        }
170 <
171 <        
172 < }
173 <
174 <
175 < void VelocityVerletIntegrator::finalize() {
176 <
177 <    dumpWriter->writeDump();
178 <    eorWriter->writeDump();
179 <
198 >  void VelocityVerletIntegrator::finalize() {
199 >    dumpWriter->writeEor();
200 >    if (simParams->getRNEMDParameters()->getUseRNEMD()) {
201 >      rnemd_->writeOutputFile();
202 >    }
203 >
204      delete dumpWriter;
181    delete eorWriter;
205      delete statWriter;
206 <
206 >  
207      dumpWriter = NULL;
185    eorWriter = NULL;
208      statWriter = NULL;
209 <    
188 < }
209 >  }
210  
211 < void VelocityVerletIntegrator::integrateStep() {
212 <
211 >  void VelocityVerletIntegrator::integrateStep() {
212 >  
213      moveA();
214 <    calcForce(needPotential, needStress);
214 >    calcForce();
215      moveB();
216 < }
216 >  }
217  
218  
219 < void VelocityVerletIntegrator::calcForce(bool needPotential,
220 <                                         bool needStress) {
221 <    forceMan_->calcForces(needPotential, needStress);
222 < }
219 >  void VelocityVerletIntegrator::calcForce() {
220 >    forceMan_->calcForces();
221 >    flucQ_->applyConstraints();
222 >  }
223  
224 < DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
225 <    return new DumpWriter(info_, info_->getDumpFileName());
226 < }
224 >  DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
225 >    return new DumpWriter(info_);
226 >  }
227  
228 < DumpWriter* VelocityVerletIntegrator::createEorWriter() {
229 <    return new DumpWriter(info_, getPrefix(info_->getDumpFileName()) + ".eor");
230 < }
228 >  StatWriter* VelocityVerletIntegrator::createStatWriter() {
229 >    
230 >    stats = new Stats(info_);
231 >    statWriter = new StatWriter(info_->getStatFileName(), stats);
232 >    
233 >    return statWriter;
234 >  }
235  
236 < StatWriter* VelocityVerletIntegrator::createStatWriter() {
212 <    return new StatWriter(info_->getStatFileName());
213 < }
214 <
215 <
216 < } //end namespace oopse
236 > } //end namespace OpenMD

Comparing:
trunk/src/integrators/VelocityVerletIntegrator.cpp (property svn:keywords), Revision 276 by tim, Wed Jan 26 15:26:47 2005 UTC vs.
branches/development/src/integrators/VelocityVerletIntegrator.cpp (property svn:keywords), Revision 1808 by gezelter, Mon Oct 22 20:42:10 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines