173 |
|
pos[j] = oldPos[i*3 + j] + dt*(vel[j] + eta*rj[j]); |
174 |
|
|
175 |
|
atoms[i]->setPos( pos ); |
176 |
– |
|
176 |
|
} |
177 |
< |
|
177 |
> |
|
178 |
> |
if (nConstrained){ |
179 |
> |
constrainA(); |
180 |
> |
} |
181 |
|
} |
182 |
|
|
183 |
|
|
289 |
|
dAtom->setJ( ji ); |
290 |
|
} |
291 |
|
} |
292 |
< |
|
293 |
< |
if (fabs(prevChi - chi) <= chiTolerance && fabs(preEta -eta) <= etaTolerance) |
292 |
> |
|
293 |
> |
if (nConstrained){ |
294 |
> |
constrainB(); |
295 |
> |
} |
296 |
> |
|
297 |
> |
if (fabs(prevChi - chi) <= |
298 |
> |
chiTolerance && fabs(preEta -eta) <= etaTolerance) |
299 |
|
break; |
300 |
|
} |
301 |
|
|
389 |
|
template<typename T> double NPTi<T>::getConservedQuantity(void){ |
390 |
|
|
391 |
|
double conservedQuantity; |
392 |
+ |
double LkBT; |
393 |
+ |
double fkBT; |
394 |
+ |
double f1kBT; |
395 |
+ |
double f2kBT; |
396 |
+ |
double NkBT; |
397 |
+ |
double Energy; |
398 |
+ |
double thermostat_kinetic; |
399 |
+ |
double thermostat_potential; |
400 |
+ |
double barostat_kinetic; |
401 |
+ |
double barostat_potential; |
402 |
|
double tb2; |
403 |
|
double eta2; |
387 |
– |
double E_NPT; |
388 |
– |
double U; |
389 |
– |
double TS; |
390 |
– |
double PV; |
391 |
– |
double extra; |
404 |
|
|
405 |
< |
U = tStats->getTotalE(); |
405 |
> |
LkBT = (double)(info->getNDF() + 4) * kB * targetTemp; // 3N + 1 |
406 |
> |
fkBT = (double)(info->getNDF() ) * kB * targetTemp; // 3N - 3 |
407 |
> |
f1kBT = (double)(info->getNDF()+ 1) * kB * targetTemp; // 3N - 3 + 1 |
408 |
> |
NkBT = (double)(info->getNDF() + 3) * kB * targetTemp; // 3N |
409 |
> |
f2kBT = (double)(info->getNDF()+ 2) * kB * targetTemp; // 3N - 3 + 1 |
410 |
|
|
411 |
< |
TS = fkBT * |
396 |
< |
(integralOfChidt + tauThermostat * tauThermostat * chi * chi / 2.0) / eConvert; |
411 |
> |
Energy = tStats->getTotalE(); |
412 |
|
|
413 |
< |
PV = (targetPressure * tStats->getVolume() / p_convert) / eConvert; |
413 |
> |
thermostat_kinetic = fkBT* tauThermostat * tauThermostat * chi * chi / |
414 |
> |
(2.0 * eConvert); |
415 |
|
|
416 |
< |
tb2 = tauBarostat * tauBarostat; |
401 |
< |
eta2 = eta * eta; |
416 |
> |
thermostat_potential = fkBT* integralOfChidt / eConvert; |
417 |
|
|
418 |
|
|
419 |
< |
extra = ((double)info->ndfTrans * kB * targetTemp * tb2 * eta2 / 2.0) / eConvert; |
419 |
> |
barostat_kinetic = fkBT * tauBarostat * tauBarostat * eta * eta / |
420 |
> |
(2.0 * eConvert); |
421 |
> |
|
422 |
> |
barostat_potential = (targetPressure * tStats->getVolume() / p_convert) / |
423 |
> |
eConvert; |
424 |
|
|
425 |
+ |
conservedQuantity = Energy + thermostat_kinetic + thermostat_potential + |
426 |
+ |
barostat_kinetic + barostat_potential; |
427 |
+ |
|
428 |
|
cout.width(8); |
429 |
|
cout.precision(8); |
430 |
|
|
431 |
< |
|
432 |
< |
cout << info->getTime() << "\t" |
433 |
< |
<< chi << "\t" |
412 |
< |
<< eta << "\t" |
413 |
< |
<< U << "\t" |
414 |
< |
<< TS << "\t" |
415 |
< |
<< PV << "\t" |
416 |
< |
<< extra << "\t" |
417 |
< |
<< U+TS+PV+extra << endl; |
431 |
> |
cerr << info->getTime() << "\t" << Energy << "\t" << thermostat_kinetic << |
432 |
> |
"\t" << thermostat_potential << "\t" << barostat_kinetic << |
433 |
> |
"\t" << barostat_potential << "\t" << conservedQuantity << endl; |
434 |
|
|
419 |
– |
conservedQuantity = U+TS+PV+extra; |
435 |
|
return conservedQuantity; |
436 |
|
} |