20 |
|
// |
21 |
|
// Hoover, W. G., 1986, Phys. Rev. A, 34, 2499. |
22 |
|
|
23 |
< |
NPTf::NPTf ( SimInfo *theInfo, ForceFields* the_ff): |
24 |
< |
Integrator( theInfo, the_ff ) |
23 |
> |
template<typename T> NPTf<T>::NPTf ( SimInfo *theInfo, ForceFields* the_ff): |
24 |
> |
T( theInfo, the_ff ) |
25 |
|
{ |
26 |
|
int i, j; |
27 |
|
chi = 0.0; |
28 |
+ |
integralOfChidt = 0.0; |
29 |
|
|
30 |
|
for(i = 0; i < 3; i++) |
31 |
|
for (j = 0; j < 3; j++) |
37 |
|
have_target_pressure = 0; |
38 |
|
} |
39 |
|
|
40 |
< |
void NPTf::moveA() { |
40 |
> |
template<typename T> void NPTf<T>::moveA() { |
41 |
|
|
42 |
|
int i, j, k; |
43 |
|
DirectionalAtom* dAtom; |
73 |
|
(press[i][j] - targetPressure/p_convert) / (NkBT*tb2); |
74 |
|
|
75 |
|
vScale[i][j] = eta[i][j] + chi; |
76 |
< |
|
76 |
> |
|
77 |
|
} else { |
78 |
|
|
79 |
|
eta[i][j] += dt2 * instaVol * press[i][j] / (NkBT*tb2); |
190 |
|
if (i != j) |
191 |
|
if (fabs(scaleMat[i][j]) > offDiagMax) |
192 |
|
offDiagMax = fabs(scaleMat[i][j]); |
192 |
– |
|
193 |
|
} |
194 |
|
|
195 |
|
if (scaleMat[i][i] > bigScale) bigScale = scaleMat[i][i]; |
228 |
|
|
229 |
|
} |
230 |
|
|
231 |
< |
void NPTf::moveB( void ){ |
231 |
> |
template<typename T> void NPTf<T>::moveB( void ){ |
232 |
|
|
233 |
|
int i, j; |
234 |
|
DirectionalAtom* dAtom; |
310 |
|
} |
311 |
|
} |
312 |
|
|
313 |
< |
int NPTf::readyCheck() { |
313 |
> |
template<typename T> void NPTf<T>::resetIntegrator() { |
314 |
> |
int i,j; |
315 |
> |
|
316 |
> |
chi = 0.0; |
317 |
> |
|
318 |
> |
for(i = 0; i < 3; i++) |
319 |
> |
for (j = 0; j < 3; j++) |
320 |
> |
eta[i][j] = 0.0; |
321 |
> |
|
322 |
> |
} |
323 |
> |
|
324 |
> |
template<typename T> int NPTf<T>::readyCheck() { |
325 |
> |
|
326 |
> |
//check parent's readyCheck() first |
327 |
> |
if (T::readyCheck() == -1) |
328 |
> |
return -1; |
329 |
|
|
330 |
|
// First check to see if we have a target temperature. |
331 |
|
// Not having one is fatal. |
378 |
|
|
379 |
|
return 1; |
380 |
|
} |
381 |
+ |
|
382 |
+ |
template<typename T> double NPTf<T>::getConservedQuantity(void){ |
383 |
+ |
|
384 |
+ |
double conservedQuantity; |
385 |
+ |
double tb2; |
386 |
+ |
double eta2[3][3]; |
387 |
+ |
double trEta; |
388 |
+ |
|
389 |
+ |
//HNVE |
390 |
+ |
conservedQuantity = tStats->getTotalE(); |
391 |
+ |
|
392 |
+ |
//HNVT |
393 |
+ |
conservedQuantity += (info->getNDF() * kB * targetTemp * |
394 |
+ |
(integralOfChidt + tauThermostat * tauThermostat * chi * chi /2)) / eConvert; |
395 |
+ |
|
396 |
+ |
//HNPT |
397 |
+ |
tb2 = tauBarostat *tauBarostat; |
398 |
+ |
|
399 |
+ |
trEta = info->matTrace3(eta); |
400 |
+ |
|
401 |
+ |
conservedQuantity += (targetPressure * tStats->getVolume() / p_convert + |
402 |
+ |
3*NkBT/2 * tb2 * trEta * trEta) / eConvert; |
403 |
+ |
|
404 |
+ |
return conservedQuantity; |
405 |
+ |
} |