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. |
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 |
|
/** |
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(); |
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) { |
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();; |
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 |
< |
|
121 |
> |
|
122 |
|
void VelocityVerletIntegrator::doIntegrate() { |
123 |
|
|
124 |
|
|
131 |
|
integrateStep(); |
132 |
|
|
133 |
|
postStep(); |
134 |
< |
|
134 |
> |
|
135 |
|
} |
136 |
|
|
137 |
|
finalize(); |
140 |
|
|
141 |
|
|
142 |
|
void VelocityVerletIntegrator::preStep() { |
143 |
< |
double difference = currentSnapshot_->getTime() + dt - currStatus; |
143 |
> |
RealType difference = currentSnapshot_->getTime() + dt - currStatus; |
144 |
|
|
145 |
< |
if (difference > 0 || fabs(difference) < oopse::epsilon) { |
145 |
> |
if (difference > 0 || fabs(difference) < OpenMD::epsilon) { |
146 |
|
needPotential = true; |
147 |
|
needStress = true; |
148 |
|
} |
144 |
– |
|
149 |
|
} |
150 |
|
|
151 |
|
void VelocityVerletIntegrator::postStep() { |
152 |
< |
|
152 |
> |
|
153 |
|
//save snapshot |
154 |
|
info_->getSnapshotManager()->advance(); |
155 |
|
|
156 |
|
//increase time |
157 |
|
currentSnapshot_->increaseTime(dt); |
158 |
< |
|
158 |
> |
|
159 |
|
if (needVelocityScaling) { |
160 |
|
if (currentSnapshot_->getTime() >= currThermal) { |
161 |
|
velocitizer_->velocitize(targetScalingTemp); |
162 |
|
currThermal += thermalTime; |
163 |
|
} |
164 |
|
} |
165 |
< |
|
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 |
< |
|
165 |
< |
if (simParams->getUseSolidThermInt()) |
166 |
< |
restWriter->writeZangle(); |
167 |
< |
|
175 |
> |
|
176 |
|
currSample += sampleTime; |
177 |
|
} |
178 |
< |
|
178 |
> |
|
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 |
< |
|
189 |
> |
|
190 |
> |
progressBar->setStatus(currentSnapshot_->getTime(), runTime); |
191 |
> |
progressBar->update(); |
192 |
> |
|
193 |
|
needPotential = false; |
194 |
|
needStress = false; |
195 |
|
currStatus += statusTime; |
196 |
|
} |
197 |
< |
|
198 |
< |
if (needReset && currentSnapshot_->getTime() >= currReset) { |
199 |
< |
resetIntegrator(); |
200 |
< |
currReset += resetTime; |
201 |
< |
} |
186 |
< |
|
197 |
> |
|
198 |
> |
if (needReset && currentSnapshot_->getTime() >= currReset) { |
199 |
> |
resetIntegrator(); |
200 |
> |
currReset += resetTime; |
201 |
> |
} |
202 |
|
} |
203 |
|
|
204 |
|
|
205 |
|
void VelocityVerletIntegrator::finalize() { |
206 |
|
dumpWriter->writeEor(); |
207 |
|
|
193 |
– |
if (simParams->getUseSolidThermInt()) { |
194 |
– |
restWriter->writeZangle(); |
195 |
– |
delete restWriter; |
196 |
– |
restWriter = NULL; |
197 |
– |
} |
198 |
– |
|
208 |
|
delete dumpWriter; |
209 |
|
delete statWriter; |
210 |
|
|
216 |
|
void VelocityVerletIntegrator::integrateStep() { |
217 |
|
|
218 |
|
moveA(); |
219 |
< |
calcForce(needPotential, needStress); |
219 |
> |
calcForce(); |
220 |
|
moveB(); |
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
< |
void VelocityVerletIntegrator::calcForce(bool needPotential, |
225 |
< |
bool needStress) { |
217 |
< |
forceMan_->calcForces(needPotential, needStress); |
224 |
> |
void VelocityVerletIntegrator::calcForce() { |
225 |
> |
forceMan_->calcForces(); |
226 |
|
} |
227 |
|
|
228 |
|
DumpWriter* VelocityVerletIntegrator::createDumpWriter() { |
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); |
234 |
< |
mask.set(Stats::VOLUME); |
235 |
< |
mask.set(Stats::CONSERVED_QUANTITY); |
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); |
238 |
– |
return new StatWriter(info_->getStatFileName(), mask); |
248 |
|
} |
249 |
|
|
250 |
< |
if (simParams->havePrintPressureTensor() && simParams->getPrintPressureTensor()){ |
251 |
< |
StatsBitSet mask; |
252 |
< |
mask.set(Stats::TIME); |
253 |
< |
mask.set(Stats::TOTAL_ENERGY); |
254 |
< |
mask.set(Stats::POTENTIAL_ENERGY); |
255 |
< |
mask.set(Stats::KINETIC_ENERGY); |
256 |
< |
mask.set(Stats::TEMPERATURE); |
257 |
< |
mask.set(Stats::PRESSURE); |
258 |
< |
mask.set(Stats::VOLUME); |
259 |
< |
mask.set(Stats::CONSERVED_QUANTITY); |
260 |
< |
mask.set(Stats::PRESSURE_TENSOR_X); |
252 |
< |
mask.set(Stats::PRESSURE_TENSOR_Y); |
253 |
< |
mask.set(Stats::PRESSURE_TENSOR_Z); |
254 |
< |
return new StatWriter(info_->getStatFileName(), mask); |
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 |
< |
return new StatWriter(info_->getStatFileName()); |
264 |
< |
} |
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 |
< |
RestWriter* VelocityVerletIntegrator::createRestWriter(){ |
276 |
< |
return new RestWriter(info_); |
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 oopse |
284 |
> |
} //end namespace OpenMD |