| 13 |
|
#include "mpiSimulation.hpp" |
| 14 |
|
#endif |
| 15 |
|
|
| 16 |
– |
|
| 16 |
|
// Basic isotropic thermostating and barostating via the Melchionna |
| 17 |
|
// modification of the Hoover algorithm: |
| 18 |
|
// |
| 87 |
|
mass = atoms[i]->getMass(); |
| 88 |
|
|
| 89 |
|
for (j=0; j < 3; j++) { |
| 90 |
< |
// velocity half step (use chi from previous step here): |
| 90 |
> |
// velocity half step |
| 91 |
|
vel[j] += dt2 * ((frc[j] / mass ) * eConvert - vel[j]*(chi + eta)); |
| 93 |
– |
|
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
atoms[i]->setVel( vel ); |
| 140 |
|
} |
| 141 |
|
} |
| 142 |
|
|
| 143 |
< |
// evolve chi and eta half step |
| 143 |
> |
// advance chi half step |
| 144 |
|
|
| 145 |
|
chi += dt2 * ( instaTemp / targetTemp - 1.0) / tt2; |
| 148 |
– |
eta += dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2)); |
| 146 |
|
|
| 147 |
< |
//calculate the integral of chidt |
| 147 |
> |
// calculate the integral of chidt |
| 148 |
> |
|
| 149 |
|
integralOfChidt += dt2*chi; |
| 150 |
|
|
| 151 |
+ |
// advance eta half step |
| 152 |
+ |
|
| 153 |
+ |
eta += dt2 * ( instaVol * (instaPress - targetPressure) / (p_convert*NkBT*tb2)); |
| 154 |
+ |
|
| 155 |
|
//save the old positions |
| 156 |
|
for(i = 0; i < nAtoms; i++){ |
| 157 |
|
atoms[i]->getPos(pos); |
| 210 |
|
double vel[3], frc[3]; |
| 211 |
|
double mass; |
| 212 |
|
|
| 213 |
< |
double instTemp, instPress, instVol; |
| 213 |
> |
double instaTemp, instaPress, instaVol; |
| 214 |
|
double tt2, tb2; |
| 215 |
|
double oldChi, prevChi; |
| 216 |
< |
double oldEta, preEta; |
| 216 |
> |
double oldEta, prevEta; |
| 217 |
|
|
| 218 |
|
tt2 = tauThermostat * tauThermostat; |
| 219 |
|
tb2 = tauBarostat * tauBarostat; |
| 244 |
|
|
| 245 |
|
// do the iteration: |
| 246 |
|
|
| 247 |
< |
instVol = tStats->getVolume(); |
| 247 |
> |
instaVol = tStats->getVolume(); |
| 248 |
|
|
| 249 |
|
for (k=0; k < 4; k++) { |
| 250 |
|
|
| 251 |
< |
instTemp = tStats->getTemperature(); |
| 252 |
< |
instPress = tStats->getPressure(); |
| 251 |
> |
instaTemp = tStats->getTemperature(); |
| 252 |
> |
instaPress = tStats->getPressure(); |
| 253 |
|
|
| 254 |
|
// evolve chi another half step using the temperature at t + dt/2 |
| 255 |
|
|
| 256 |
|
prevChi = chi; |
| 257 |
< |
chi = oldChi + dt2 * ( instTemp / targetTemp - 1.0) / |
| 256 |
< |
(tauThermostat*tauThermostat); |
| 257 |
> |
chi = oldChi + dt2 * ( instaTemp / targetTemp - 1.0) / tt2; |
| 258 |
|
|
| 259 |
< |
preEta = eta; |
| 260 |
< |
eta = oldEta + dt2 * ( instVol * (instPress - targetPressure) / |
| 259 |
> |
prevEta = eta; |
| 260 |
> |
|
| 261 |
> |
// advance eta half step and calculate scale factor for velocity |
| 262 |
> |
|
| 263 |
> |
eta = oldEta + dt2 * ( instaVol * (instaPress - targetPressure) / |
| 264 |
|
(p_convert*NkBT*tb2)); |
| 265 |
|
|
| 266 |
|
|
| 298 |
|
} |
| 299 |
|
|
| 300 |
|
if (fabs(prevChi - chi) <= |
| 301 |
< |
chiTolerance && fabs(preEta -eta) <= etaTolerance) |
| 301 |
> |
chiTolerance && fabs(prevEta -eta) <= etaTolerance) |
| 302 |
|
break; |
| 303 |
|
} |
| 304 |
|
|
| 305 |
< |
//calculate integral of chida |
| 305 |
> |
//calculate integral of chidt |
| 306 |
|
integralOfChidt += dt2*chi; |
| 307 |
|
|
| 304 |
– |
|
| 308 |
|
} |
| 309 |
|
|
| 310 |
|
template<typename T> void NPTi<T>::resetIntegrator() { |