| 20 |
|
// |
| 21 |
|
// Hoover, W. G., 1986, Phys. Rev. A, 34, 2499. |
| 22 |
|
|
| 23 |
< |
NPTi::NPTi ( SimInfo *theInfo, ForceFields* the_ff): |
| 24 |
< |
Integrator( theInfo, the_ff ) |
| 23 |
> |
template<typename T> NPTi<T>::NPTi ( SimInfo *theInfo, ForceFields* the_ff): |
| 24 |
> |
T( theInfo, the_ff ) |
| 25 |
|
{ |
| 26 |
|
chi = 0.0; |
| 27 |
|
eta = 0.0; |
| 31 |
|
have_target_pressure = 0; |
| 32 |
|
} |
| 33 |
|
|
| 34 |
< |
void NPTi::moveA() { |
| 34 |
> |
template<typename T> void NPTi<T>::moveA() { |
| 35 |
|
|
| 36 |
|
int i, j; |
| 37 |
|
DirectionalAtom* dAtom; |
| 42 |
|
|
| 43 |
|
double rj[3]; |
| 44 |
|
double instaTemp, instaPress, instaVol; |
| 45 |
< |
double tt2, tb2; |
| 45 |
> |
double tt2, tb2, scaleFactor; |
| 46 |
|
|
| 47 |
|
tt2 = tauThermostat * tauThermostat; |
| 48 |
|
tb2 = tauBarostat * tauBarostat; |
| 76 |
|
for (j = 0; j < 3; j++) |
| 77 |
|
pos[j] += dt * (vel[j] + eta*rj[j]); |
| 78 |
|
|
| 79 |
– |
|
| 79 |
|
atoms[i]->setPos( pos ); |
| 80 |
|
|
| 82 |
– |
|
| 81 |
|
if( atoms[i]->isDirectional() ){ |
| 82 |
|
|
| 83 |
|
dAtom = (DirectionalAtom *)atoms[i]; |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
} |
| 128 |
+ |
|
| 129 |
|
// Scale the box after all the positions have been moved: |
| 130 |
|
|
| 131 |
< |
cerr << "eta = " << eta |
| 132 |
< |
<< "; exp(dt*eta) = " << exp(eta*dt) << "\n"; |
| 133 |
< |
|
| 134 |
< |
info->scaleBox(exp(dt*eta)); |
| 131 |
> |
scaleFactor = exp(dt*eta); |
| 132 |
> |
|
| 133 |
> |
if ((scaleFactor > 1.1) || (scaleFactor < 0.9)) { |
| 134 |
> |
sprintf( painCave.errMsg, |
| 135 |
> |
"NPTi error: Attempting a Box scaling of more than 10 percent" |
| 136 |
> |
" check your tauBarostat, as it is probably too small!\n" |
| 137 |
> |
" eta = %lf, scaleFactor = %lf\n", eta, scaleFactor |
| 138 |
> |
); |
| 139 |
> |
painCave.isFatal = 1; |
| 140 |
> |
simError(); |
| 141 |
> |
} else { |
| 142 |
> |
info->scaleBox(exp(dt*eta)); |
| 143 |
> |
} |
| 144 |
> |
|
| 145 |
|
} |
| 146 |
|
|
| 147 |
< |
void NPTi::moveB( void ){ |
| 147 |
> |
template<typename T> void NPTi<T>::moveB( void ){ |
| 148 |
|
|
| 149 |
|
int i, j; |
| 150 |
|
DirectionalAtom* dAtom; |
| 200 |
|
} |
| 201 |
|
} |
| 202 |
|
|
| 203 |
< |
int NPTi::readyCheck() { |
| 203 |
> |
template<typename T> void NPTi<T>::resetIntegrator() { |
| 204 |
> |
chi = 0.0; |
| 205 |
> |
eta = 0.0; |
| 206 |
> |
} |
| 207 |
> |
|
| 208 |
> |
template<typename T> int NPTi<T>::readyCheck() { |
| 209 |
> |
|
| 210 |
> |
//check parent's readyCheck() first |
| 211 |
> |
if (T::readyCheck() == -1) |
| 212 |
> |
return -1; |
| 213 |
|
|
| 214 |
|
// First check to see if we have a target temperature. |
| 215 |
|
// Not having one is fatal. |