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). |
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 |
|
/** |
54 |
|
#include "utils/ProgressBar.hpp" |
55 |
|
|
56 |
|
namespace OpenMD { |
57 |
< |
VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) { |
57 |
> |
VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info) { |
58 |
|
dt2 = 0.5 * dt; |
58 |
– |
rotAlgo = new DLM(); |
59 |
– |
rattle = new Rattle(info); |
59 |
|
} |
60 |
|
|
61 |
|
VelocityVerletIntegrator::~VelocityVerletIntegrator() { |
63 |
– |
delete rotAlgo; |
64 |
– |
delete rattle; |
62 |
|
} |
63 |
|
|
64 |
|
void VelocityVerletIntegrator::initialize(){ |
65 |
|
|
66 |
< |
forceMan_->init(); |
66 |
> |
forceMan_->initialize(); |
67 |
|
|
68 |
|
// remove center of mass drift velocity (in case we passed in a |
69 |
|
// configuration that was drifting) |
70 |
|
velocitizer_->removeComDrift(); |
71 |
+ |
|
72 |
+ |
// find the initial fluctuating charges. |
73 |
+ |
flucQ_->initialize(); |
74 |
|
|
75 |
|
// initialize the forces before the first step |
76 |
|
calcForce(); |
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(); |
81 |
> |
rattle_->constraintA(); |
82 |
|
calcForce(); |
83 |
< |
rattle->constraintB(); |
83 |
> |
rattle_->constraintB(); |
84 |
|
//copy the current snapshot to previous snapshot |
85 |
|
info_->getSnapshotManager()->advance(); |
86 |
|
} |
98 |
|
progressBar = new ProgressBar(); |
99 |
|
|
100 |
|
//save statistics, before writeStat, we must save statistics |
101 |
– |
thermo.saveStat(); |
101 |
|
saveConservedQuantity(); |
102 |
< |
if (simParams->getUseRNEMD()) |
102 |
> |
stats->collectStats(); |
103 |
> |
|
104 |
> |
if (simParams->getRNEMDParameters()->getUseRNEMD()) |
105 |
|
rnemd_->getStarted(); |
106 |
|
|
107 |
< |
statWriter->writeStat(currentSnapshot_->statData); |
107 |
> |
statWriter->writeStat(); |
108 |
|
|
109 |
< |
currSample = sampleTime + currentSnapshot_->getTime(); |
110 |
< |
currStatus = statusTime + currentSnapshot_->getTime(); |
111 |
< |
currThermal = thermalTime + currentSnapshot_->getTime(); |
109 |
> |
currSample = sampleTime + snap->getTime(); |
110 |
> |
currStatus = statusTime + snap->getTime(); |
111 |
> |
currThermal = thermalTime + snap->getTime(); |
112 |
|
if (needReset) { |
113 |
< |
currReset = resetTime + currentSnapshot_->getTime(); |
113 |
> |
currReset = resetTime + snap->getTime(); |
114 |
|
} |
115 |
< |
if (simParams->getUseRNEMD()){ |
116 |
< |
currRNEMD = RNEMD_exchangeTime + currentSnapshot_->getTime(); |
115 |
> |
if (simParams->getRNEMDParameters()->getUseRNEMD()){ |
116 |
> |
currRNEMD = RNEMD_exchangeTime + snap->getTime(); |
117 |
|
} |
118 |
|
needPotential = false; |
119 |
|
needStress = false; |
122 |
|
|
123 |
|
void VelocityVerletIntegrator::doIntegrate() { |
124 |
|
|
124 |
– |
|
125 |
|
initialize(); |
126 |
|
|
127 |
< |
while (currentSnapshot_->getTime() < runTime) { |
128 |
< |
|
129 |
< |
preStep(); |
130 |
< |
|
131 |
< |
integrateStep(); |
132 |
< |
|
133 |
< |
postStep(); |
134 |
< |
|
135 |
< |
} |
136 |
< |
|
127 |
> |
while (snap->getTime() < runTime) { |
128 |
> |
preStep(); |
129 |
> |
integrateStep(); |
130 |
> |
postStep(); |
131 |
> |
} |
132 |
|
finalize(); |
138 |
– |
|
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
void VelocityVerletIntegrator::preStep() { |
137 |
< |
RealType difference = currentSnapshot_->getTime() + dt - currStatus; |
137 |
> |
RealType difference = snap->getTime() + dt - currStatus; |
138 |
|
|
139 |
|
if (difference > 0 || fabs(difference) < OpenMD::epsilon) { |
140 |
|
needPotential = true; |
148 |
|
info_->getSnapshotManager()->advance(); |
149 |
|
|
150 |
|
//increase time |
151 |
< |
currentSnapshot_->increaseTime(dt); |
151 |
> |
snap->increaseTime(dt); |
152 |
|
|
153 |
|
if (needVelocityScaling) { |
154 |
< |
if (currentSnapshot_->getTime() >= currThermal) { |
154 |
> |
if (snap->getTime() >= currThermal) { |
155 |
|
velocitizer_->velocitize(targetScalingTemp); |
156 |
|
currThermal += thermalTime; |
157 |
|
} |
158 |
|
} |
159 |
|
if (useRNEMD) { |
160 |
< |
if (currentSnapshot_->getTime() >= currRNEMD) { |
160 |
> |
if (snap->getTime() >= currRNEMD) { |
161 |
|
rnemd_->doRNEMD(); |
162 |
|
currRNEMD += RNEMD_exchangeTime; |
163 |
|
} |
164 |
|
rnemd_->collectData(); |
165 |
|
} |
166 |
|
|
167 |
< |
if (currentSnapshot_->getTime() >= currSample) { |
167 |
> |
if (snap->getTime() >= currSample) { |
168 |
|
dumpWriter->writeDumpAndEor(); |
169 |
|
|
170 |
|
currSample += sampleTime; |
171 |
|
} |
172 |
|
|
173 |
< |
if (currentSnapshot_->getTime() >= currStatus) { |
173 |
> |
if (snap->getTime() >= currStatus) { |
174 |
|
//save statistics, before writeStat, we must save statistics |
175 |
< |
thermo.saveStat(); |
175 |
> |
stats->collectStats(); |
176 |
|
saveConservedQuantity(); |
177 |
|
|
178 |
< |
if (simParams->getUseRNEMD()) { |
179 |
< |
rnemd_->getStatus(); |
178 |
> |
if (simParams->getRNEMDParameters()->getUseRNEMD()) { |
179 |
> |
rnemd_->writeOutputFile(); |
180 |
|
} |
181 |
|
|
182 |
< |
statWriter->writeStat(currentSnapshot_->statData); |
182 |
> |
statWriter->writeStat(); |
183 |
|
|
184 |
< |
progressBar->setStatus(currentSnapshot_->getTime(), runTime); |
184 |
> |
progressBar->setStatus(snap->getTime(), runTime); |
185 |
|
progressBar->update(); |
186 |
|
|
187 |
|
needPotential = false; |
189 |
|
currStatus += statusTime; |
190 |
|
} |
191 |
|
|
192 |
< |
if (needReset && currentSnapshot_->getTime() >= currReset) { |
192 |
> |
if (needReset && snap->getTime() >= currReset) { |
193 |
|
resetIntegrator(); |
194 |
|
currReset += resetTime; |
195 |
|
} |
198 |
|
|
199 |
|
void VelocityVerletIntegrator::finalize() { |
200 |
|
dumpWriter->writeEor(); |
201 |
+ |
rnemd_->writeOutputFile(); |
202 |
|
|
203 |
|
delete dumpWriter; |
204 |
|
delete statWriter; |
205 |
|
|
206 |
|
dumpWriter = NULL; |
207 |
|
statWriter = NULL; |
213 |
– |
|
208 |
|
} |
209 |
|
|
210 |
|
void VelocityVerletIntegrator::integrateStep() { |
217 |
|
|
218 |
|
void VelocityVerletIntegrator::calcForce() { |
219 |
|
forceMan_->calcForces(); |
220 |
+ |
flucQ_->applyConstraints(); |
221 |
|
} |
222 |
|
|
223 |
|
DumpWriter* VelocityVerletIntegrator::createDumpWriter() { |
225 |
|
} |
226 |
|
|
227 |
|
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 |
– |
} |
228 |
|
|
229 |
< |
if (simParams->getAccumulateBoxDipole()) { |
230 |
< |
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 |
< |
} |
229 |
> |
stats = new Stats(info_); |
230 |
> |
statWriter = new StatWriter(info_->getStatFileName(), stats); |
231 |
|
|
232 |
< |
|
280 |
< |
return new StatWriter(info_->getStatFileName(), mask); |
232 |
> |
return statWriter; |
233 |
|
} |
234 |
|
|
283 |
– |
|
235 |
|
} //end namespace OpenMD |