10 |
|
#include "Integrator.hpp" |
11 |
|
#include "simError.h" |
12 |
|
|
13 |
+ |
|
14 |
|
// Basic non-isotropic thermostating and barostating via the Melchionna |
15 |
|
// modification of the Hoover algorithm: |
16 |
|
// |
29 |
|
{ |
30 |
|
int i, j; |
31 |
|
chi = 0.0; |
32 |
< |
|
32 |
> |
integralOfChidt = 0.0; |
33 |
> |
|
34 |
|
for(i = 0; i < 3; i++) |
35 |
|
for (j = 0; j < 3; j++) |
36 |
|
eta[i][j] = 0.0; |
330 |
|
} |
331 |
|
} |
332 |
|
|
333 |
+ |
template<typename T> void NPTfm<T>::resetIntegrator() { |
334 |
+ |
int i,j; |
335 |
+ |
|
336 |
+ |
chi = 0.0; |
337 |
+ |
|
338 |
+ |
for(i = 0; i < 3; i++) |
339 |
+ |
for (j = 0; j < 3; j++) |
340 |
+ |
eta[i][j] = 0.0; |
341 |
+ |
} |
342 |
+ |
|
343 |
|
template<typename T> int NPTfm<T>::readyCheck() { |
344 |
|
|
345 |
|
//check parent's readyCheck() first |
396 |
|
NkBT = (double)info->ndf * kB * targetTemp; |
397 |
|
|
398 |
|
return 1; |
399 |
+ |
} |
400 |
+ |
|
401 |
+ |
template<typename T> double NPTfm<T>::getConservedQuantity(void){ |
402 |
+ |
|
403 |
+ |
double conservedQuantity; |
404 |
+ |
double tb2; |
405 |
+ |
double trEta; |
406 |
+ |
|
407 |
+ |
//HNVE |
408 |
+ |
conservedQuantity = tStats->getTotalE(); |
409 |
+ |
|
410 |
+ |
//HNVT |
411 |
+ |
conservedQuantity += (info->getNDF() * kB * targetTemp * |
412 |
+ |
(integralOfChidt + tauThermostat * tauThermostat * chi * chi / 2.0)) / eConvert ; |
413 |
+ |
|
414 |
+ |
//HNPT |
415 |
+ |
tb2 = tauBarostat *tauBarostat; |
416 |
+ |
|
417 |
+ |
trEta = info->matTrace3(eta); |
418 |
+ |
|
419 |
+ |
conservedQuantity += (targetPressure * tStats->getVolume() / p_convert + |
420 |
+ |
3*NkBT/2 * tb2 * trEta * trEta) / eConvert; |
421 |
+ |
|
422 |
+ |
return conservedQuantity; |
423 |
|
} |