| 24 |
|
// The NPTim variant scales the molecular center-of-mass coordinates |
| 25 |
|
// instead of the atomic coordinates |
| 26 |
|
|
| 27 |
< |
NPTim::NPTim ( SimInfo *theInfo, ForceFields* the_ff): |
| 28 |
< |
Integrator( theInfo, the_ff ) |
| 27 |
> |
template<typename T> NPTim<T>::NPTim ( SimInfo *theInfo, ForceFields* the_ff): |
| 28 |
> |
T( theInfo, the_ff ) |
| 29 |
|
{ |
| 30 |
|
chi = 0.0; |
| 31 |
|
eta = 0.0; |
| 35 |
|
have_target_pressure = 0; |
| 36 |
|
} |
| 37 |
|
|
| 38 |
< |
void NPTim::moveA() { |
| 38 |
> |
template<typename T> void NPTim<T>::moveA() { |
| 39 |
|
|
| 40 |
< |
int i, j; |
| 40 |
> |
int i, j, k; |
| 41 |
|
DirectionalAtom* dAtom; |
| 42 |
|
double Tb[3], ji[3]; |
| 43 |
|
double A[3][3], I[3][3]; |
| 46 |
|
|
| 47 |
|
double rj[3]; |
| 48 |
|
double instaTemp, instaPress, instaVol; |
| 49 |
< |
double tt2, tb2; |
| 49 |
> |
double tt2, tb2, scaleFactor; |
| 50 |
|
|
| 51 |
|
int nInMol; |
| 52 |
|
double rc[3]; |
| 82 |
|
|
| 83 |
|
if(myAtoms[j] != NULL) { |
| 84 |
|
|
| 85 |
< |
myAtoms[i]->getVel( vel ); |
| 86 |
< |
myAtoms[i]->getPos( pos ); |
| 87 |
< |
myAtoms[i]->getFrc( frc ); |
| 85 |
> |
myAtoms[j]->getVel( vel ); |
| 86 |
> |
myAtoms[j]->getPos( pos ); |
| 87 |
> |
myAtoms[j]->getFrc( frc ); |
| 88 |
|
|
| 89 |
< |
mass = myAtoms[i]->getMass(); |
| 89 |
> |
mass = myAtoms[j]->getMass(); |
| 90 |
|
|
| 91 |
< |
for (j=0; j < 3; j++) |
| 92 |
< |
vel[j] += dt2 * ((frc[j] / mass ) * eConvert - vel[j]*(chi+eta)); |
| 91 |
> |
for (k=0; k < 3; k++) |
| 92 |
> |
vel[k] += dt2 * ((frc[k] / mass ) * eConvert - vel[k]*(chi+eta)); |
| 93 |
|
|
| 94 |
< |
myAtoms[i]->setVel( vel ); |
| 94 |
> |
myAtoms[j]->setVel( vel ); |
| 95 |
|
|
| 96 |
< |
for (j = 0; j < 3; j++) |
| 97 |
< |
pos[j] += dt * (vel[j] + eta*rc[j]); |
| 96 |
> |
for (k = 0; k < 3; k++) |
| 97 |
> |
pos[k] += dt * (vel[k] + eta*rc[k]); |
| 98 |
|
|
| 99 |
< |
atoms[i]->setPos( pos ); |
| 99 |
> |
myAtoms[j]->setPos( pos ); |
| 100 |
|
|
| 101 |
|
if( myAtoms[j]->isDirectional() ){ |
| 102 |
|
|
| 111 |
|
|
| 112 |
|
dAtom->getJ( ji ); |
| 113 |
|
|
| 114 |
< |
for (j=0; j < 3; j++) |
| 115 |
< |
ji[j] += dt2 * (Tb[j] * eConvert - ji[j]*chi); |
| 114 |
> |
for (k=0; k < 3; k++) |
| 115 |
> |
ji[k] += dt2 * (Tb[k] * eConvert - ji[k]*chi); |
| 116 |
|
|
| 117 |
|
// use the angular velocities to propagate the rotation matrix a |
| 118 |
|
// full time step |
| 146 |
|
} |
| 147 |
|
} |
| 148 |
|
} |
| 149 |
+ |
|
| 150 |
|
// Scale the box after all the positions have been moved: |
| 151 |
|
|
| 152 |
< |
cerr << "eta = " << eta |
| 153 |
< |
<< "; exp(dt*eta) = " << exp(eta*dt) << "\n"; |
| 154 |
< |
|
| 155 |
< |
info->scaleBox(exp(dt*eta)); |
| 152 |
> |
scaleFactor = exp(dt*eta); |
| 153 |
> |
|
| 154 |
> |
if (scaleFactor > 1.1 || scaleFactor < 0.9) { |
| 155 |
> |
sprintf( painCave.errMsg, |
| 156 |
> |
"NPTi error: Attempting a Box scaling of more than 10 percent" |
| 157 |
> |
" check your tauBarostat, as it is probably too small!\n" |
| 158 |
> |
" eta = %lf, scaleFactor = %lf\n", eta, scaleFactor |
| 159 |
> |
); |
| 160 |
> |
painCave.isFatal = 1; |
| 161 |
> |
simError(); |
| 162 |
> |
} else { |
| 163 |
> |
info->scaleBox(exp(dt*eta)); |
| 164 |
> |
} |
| 165 |
|
} |
| 166 |
|
|
| 167 |
< |
void NPTim::moveB( void ){ |
| 167 |
> |
template<typename T> void NPTim<T>::moveB( void ){ |
| 168 |
|
int i, j; |
| 169 |
|
DirectionalAtom* dAtom; |
| 170 |
|
double Tb[3], ji[3]; |
| 219 |
|
} |
| 220 |
|
} |
| 221 |
|
|
| 222 |
< |
int NPTim::readyCheck() { |
| 222 |
> |
template<typename T> int NPTim<T>::readyCheck() { |
| 223 |
|
|
| 224 |
|
// First check to see if we have a target temperature. |
| 225 |
|
// Not having one is fatal. |