67 |
|
|
68 |
|
forceMan_->init(); |
69 |
|
|
70 |
< |
// remove center of mass drift velocity (in case we passed in a configuration |
71 |
< |
// that was drifting |
70 |
> |
// remove center of mass drift velocity (in case we passed in a |
71 |
> |
// configuration that was drifting) |
72 |
|
velocitizer_->removeComDrift(); |
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 |
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 |
82 |
> |
rattle->constraintB(); |
83 |
> |
//copy the current snapshot to previous snapshot |
84 |
> |
info_->getSnapshotManager()->advance(); |
85 |
|
} |
86 |
|
|
87 |
|
if (needVelocityScaling) { |
91 |
|
dumpWriter = createDumpWriter(); |
92 |
|
|
93 |
|
statWriter = createStatWriter(); |
94 |
< |
|
93 |
< |
if (simParams->getUseSolidThermInt()) { |
94 |
< |
restWriter = createRestWriter(); |
95 |
< |
restWriter->writeZangle(); |
96 |
< |
} |
97 |
< |
|
94 |
> |
|
95 |
|
dumpWriter->writeDumpAndEor(); |
96 |
< |
|
100 |
< |
|
96 |
> |
|
97 |
|
//save statistics, before writeStat, we must save statistics |
98 |
|
thermo.saveStat(); |
99 |
|
saveConservedQuantity(); |
100 |
+ |
if (simParams->getUseRNEMD()) |
101 |
+ |
rnemd_->getStatus(); |
102 |
+ |
|
103 |
|
statWriter->writeStat(currentSnapshot_->statData); |
104 |
|
|
105 |
|
currSample = sampleTime + currentSnapshot_->getTime(); |
106 |
< |
currStatus = statusTime + currentSnapshot_->getTime();; |
107 |
< |
currThermal = thermalTime + + currentSnapshot_->getTime(); |
106 |
> |
currStatus = statusTime + currentSnapshot_->getTime(); |
107 |
> |
currThermal = thermalTime + currentSnapshot_->getTime(); |
108 |
> |
if (needReset) { |
109 |
> |
currReset = resetTime + currentSnapshot_->getTime(); |
110 |
> |
} |
111 |
> |
if (simParams->getUseRNEMD()){ |
112 |
> |
currRNEMD = RNEMD_swapTime + currentSnapshot_->getTime(); |
113 |
> |
} |
114 |
|
needPotential = false; |
115 |
|
needStress = false; |
116 |
|
|
137 |
|
|
138 |
|
|
139 |
|
void VelocityVerletIntegrator::preStep() { |
140 |
< |
double difference = currentSnapshot_->getTime() + dt - currStatus; |
140 |
> |
RealType difference = currentSnapshot_->getTime() + dt - currStatus; |
141 |
|
|
142 |
|
if (difference > 0 || fabs(difference) < oopse::epsilon) { |
143 |
|
needPotential = true; |
144 |
|
needStress = true; |
145 |
|
} |
141 |
– |
|
146 |
|
} |
147 |
|
|
148 |
|
void VelocityVerletIntegrator::postStep() { |
149 |
< |
|
149 |
> |
|
150 |
|
//save snapshot |
151 |
|
info_->getSnapshotManager()->advance(); |
152 |
|
|
153 |
|
//increase time |
154 |
|
currentSnapshot_->increaseTime(dt); |
155 |
< |
|
155 |
> |
|
156 |
|
if (needVelocityScaling) { |
157 |
|
if (currentSnapshot_->getTime() >= currThermal) { |
158 |
|
velocitizer_->velocitize(targetScalingTemp); |
159 |
|
currThermal += thermalTime; |
160 |
|
} |
161 |
|
} |
162 |
< |
|
162 |
> |
if (useRNEMD) { |
163 |
> |
if (currentSnapshot_->getTime() >= currRNEMD) { |
164 |
> |
rnemd_->doSwap(); |
165 |
> |
currRNEMD += RNEMD_swapTime; |
166 |
> |
} |
167 |
> |
} |
168 |
> |
|
169 |
|
if (currentSnapshot_->getTime() >= currSample) { |
170 |
|
dumpWriter->writeDumpAndEor(); |
171 |
< |
|
162 |
< |
if (simParams->getUseSolidThermInt()) |
163 |
< |
restWriter->writeZangle(); |
164 |
< |
|
171 |
> |
|
172 |
|
currSample += sampleTime; |
173 |
|
} |
174 |
< |
|
174 |
> |
|
175 |
|
if (currentSnapshot_->getTime() >= currStatus) { |
176 |
|
//save statistics, before writeStat, we must save statistics |
177 |
|
thermo.saveStat(); |
178 |
|
saveConservedQuantity(); |
179 |
+ |
|
180 |
+ |
if (simParams->getUseRNEMD()) |
181 |
+ |
rnemd_->getStatus(); |
182 |
+ |
|
183 |
|
statWriter->writeStat(currentSnapshot_->statData); |
184 |
< |
|
184 |
> |
|
185 |
|
needPotential = false; |
186 |
|
needStress = false; |
187 |
|
currStatus += statusTime; |
188 |
|
} |
189 |
< |
|
190 |
< |
|
189 |
> |
|
190 |
> |
if (needReset && currentSnapshot_->getTime() >= currReset) { |
191 |
> |
resetIntegrator(); |
192 |
> |
currReset += resetTime; |
193 |
> |
} |
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
|
void VelocityVerletIntegrator::finalize() { |
198 |
|
dumpWriter->writeEor(); |
185 |
– |
|
186 |
– |
if (simParams->getUseSolidThermInt()) { |
187 |
– |
restWriter->writeZangle(); |
188 |
– |
delete restWriter; |
189 |
– |
restWriter = NULL; |
190 |
– |
} |
199 |
|
|
200 |
|
delete dumpWriter; |
201 |
|
delete statWriter; |
223 |
|
} |
224 |
|
|
225 |
|
StatWriter* VelocityVerletIntegrator::createStatWriter() { |
226 |
< |
// if solidThermInt is true, add extra information to the statfile |
227 |
< |
if (simParams->getUseSolidThermInt()){ |
228 |
< |
StatsBitSet mask; |
229 |
< |
mask.set(Stats::TIME); |
230 |
< |
mask.set(Stats::TOTAL_ENERGY); |
231 |
< |
mask.set(Stats::POTENTIAL_ENERGY); |
232 |
< |
mask.set(Stats::KINETIC_ENERGY); |
233 |
< |
mask.set(Stats::TEMPERATURE); |
234 |
< |
mask.set(Stats::PRESSURE); |
227 |
< |
mask.set(Stats::VOLUME); |
228 |
< |
mask.set(Stats::CONSERVED_QUANTITY); |
226 |
> |
|
227 |
> |
std::string statFileFormatString = simParams->getStatFileFormat(); |
228 |
> |
StatsBitSet mask = parseStatFileFormat(statFileFormatString); |
229 |
> |
|
230 |
> |
// if we're doing a thermodynamic integration, we'll want the raw |
231 |
> |
// potential as well as the full potential: |
232 |
> |
|
233 |
> |
|
234 |
> |
if (simParams->getUseThermodynamicIntegration()) |
235 |
|
mask.set(Stats::VRAW); |
236 |
+ |
|
237 |
+ |
// if we've got restraints turned on, we'll also want a report of the |
238 |
+ |
// total harmonic restraints |
239 |
+ |
if (simParams->getUseRestraints()){ |
240 |
|
mask.set(Stats::VHARM); |
231 |
– |
return new StatWriter(info_->getStatFileName(), mask); |
241 |
|
} |
242 |
|
|
243 |
< |
if (simParams->havePrintPresureTensor() && simParams->getPrintPressureTensor()){ |
244 |
< |
mask.set(Stats::TIME); |
245 |
< |
mask.set(Stats::TOTAL_ENERGY); |
246 |
< |
mask.set(Stats::POTENTIAL_ENERGY); |
247 |
< |
mask.set(Stats::KINETIC_ENERGY); |
248 |
< |
mask.set(Stats::TEMPERATURE); |
249 |
< |
mask.set(Stats::PRESSURE); |
250 |
< |
mask.set(Stats::VOLUME); |
251 |
< |
mask.set(Stats::CONSERVED_QUANTITY); |
252 |
< |
mask.set(Stats::PRESSURE_TENSOR_X); |
253 |
< |
mask.set(Stats::PRESSURE_TENSOR_Y); |
245 |
< |
mask.set(Stats::PRESSURE_TENSOR_Z); |
246 |
< |
return new StatWriter(info_->getStatFileName(), mask); |
243 |
> |
if (simParams->havePrintPressureTensor() && |
244 |
> |
simParams->getPrintPressureTensor()){ |
245 |
> |
mask.set(Stats::PRESSURE_TENSOR_XX); |
246 |
> |
mask.set(Stats::PRESSURE_TENSOR_XY); |
247 |
> |
mask.set(Stats::PRESSURE_TENSOR_XZ); |
248 |
> |
mask.set(Stats::PRESSURE_TENSOR_YX); |
249 |
> |
mask.set(Stats::PRESSURE_TENSOR_YY); |
250 |
> |
mask.set(Stats::PRESSURE_TENSOR_YZ); |
251 |
> |
mask.set(Stats::PRESSURE_TENSOR_ZX); |
252 |
> |
mask.set(Stats::PRESSURE_TENSOR_ZY); |
253 |
> |
mask.set(Stats::PRESSURE_TENSOR_ZZ); |
254 |
|
} |
255 |
|
|
256 |
< |
return new StatWriter(info_->getStatFileName()); |
257 |
< |
} |
256 |
> |
if (simParams->getAccumulateBoxDipole()) { |
257 |
> |
mask.set(Stats::BOX_DIPOLE_X); |
258 |
> |
mask.set(Stats::BOX_DIPOLE_Y); |
259 |
> |
mask.set(Stats::BOX_DIPOLE_Z); |
260 |
> |
} |
261 |
> |
|
262 |
> |
if (simParams->haveTaggedAtomPair() && simParams->havePrintTaggedPairDistance()) { |
263 |
> |
if (simParams->getPrintTaggedPairDistance()) { |
264 |
> |
mask.set(Stats::TAGGED_PAIR_DISTANCE); |
265 |
> |
} |
266 |
> |
} |
267 |
|
|
268 |
< |
RestWriter* VelocityVerletIntegrator::createRestWriter(){ |
269 |
< |
return new RestWriter(info_); |
268 |
> |
if (simParams->getUseRNEMD()) { |
269 |
> |
mask.set(Stats::RNEMD_SWAP_TOTAL); |
270 |
> |
} |
271 |
> |
|
272 |
> |
|
273 |
> |
return new StatWriter(info_->getStatFileName(), mask); |
274 |
|
} |
275 |
|
|
276 |
|
|