| 10 |
|
// get what information we need from the SimInfo object |
| 11 |
|
|
| 12 |
|
entry_plug = the_entry_plug; |
| 13 |
– |
nAtoms = entry_plug->n_atoms; |
| 14 |
– |
atoms = entry_plug->atoms; |
| 15 |
– |
nMols = entry_plug->n_mol; |
| 16 |
– |
molecules = entry_plug->molecules; |
| 17 |
– |
nOriented = entry_plug->n_oriented; |
| 18 |
– |
ndf = entry_plug->ndf; |
| 13 |
|
zeta = 0.0; |
| 14 |
|
epsilonDot = 0.0; |
| 21 |
– |
|
| 15 |
|
} |
| 16 |
|
|
| 17 |
|
void ExtendedSystem::NoseHooverNVT( double dt, double ke ){ |
| 25 |
|
const double e_convert = 4.184e-4; // to convert ke from kcal/mol to |
| 26 |
|
// amu*Ang^2*fs^-2/K |
| 27 |
|
DirectionalAtom* dAtom; |
| 28 |
+ |
atoms = entry_plug->atoms; |
| 29 |
|
|
| 36 |
– |
|
| 30 |
|
ke_temp = ke * e_convert; |
| 31 |
< |
NkBT = (double)ndf * kB * targetTemp; |
| 31 |
> |
NkBT = (double)entry_plug->ndf * kB * targetTemp; |
| 32 |
|
|
| 33 |
|
// advance the zeta term to zeta(t + dt) - zeta is 0.0d0 on config. readin |
| 34 |
|
// qmass is set in the parameter file |
| 35 |
|
|
| 36 |
|
zeta += dt * ( (ke_temp*2.0 - NkBT) / qmass ); |
| 37 |
+ |
|
| 38 |
|
zetaScale = zeta * dt; |
| 39 |
+ |
|
| 40 |
+ |
std::cerr << "zetaScale = " << zetaScale << "\n"; |
| 41 |
|
|
| 42 |
|
// perform thermostat scaling on linear velocities and angular momentum |
| 43 |
< |
for(i = 0; i < nAtoms; i++){ |
| 43 |
> |
for(i = 0; i < entry_plug->n_atoms; i++){ |
| 44 |
|
|
| 45 |
|
vx = atoms[i]->get_vx(); |
| 46 |
|
vy = atoms[i]->get_vy(); |
| 47 |
|
vz = atoms[i]->get_vz(); |
| 48 |
< |
|
| 48 |
> |
|
| 49 |
|
atoms[i]->set_vx(vx * (1.0 - zetaScale)); |
| 50 |
|
atoms[i]->set_vy(vy * (1.0 - zetaScale)); |
| 51 |
|
atoms[i]->set_vz(vz * (1.0 - zetaScale)); |
| 52 |
|
} |
| 53 |
< |
if( nOriented ){ |
| 53 |
> |
if( entry_plug->n_oriented ){ |
| 54 |
|
|
| 55 |
< |
for( i=0; i < nAtoms; i++ ){ |
| 55 |
> |
for( i=0; i < entry_plug->n_atoms; i++ ){ |
| 56 |
|
|
| 57 |
|
if( atoms[i]->isDirectional() ){ |
| 58 |
|
|
| 85 |
|
const double e_convert = 4.184e-4; // to convert ke from kcal/mol to |
| 86 |
|
// amu*Ang^2*fs^-2/K |
| 87 |
|
|
| 88 |
+ |
int i; |
| 89 |
|
double p_ext, zetaScale, epsilonScale, scale, NkBT, ke_temp; |
| 90 |
|
double volume, p_mol; |
| 91 |
|
double vx, vy, vz, jx, jy, jz; |
| 92 |
|
DirectionalAtom* dAtom; |
| 93 |
< |
int i; |
| 93 |
> |
atoms = entry_plug->atoms; |
| 94 |
|
|
| 95 |
|
p_ext = targetPressure * p_units; |
| 96 |
|
p_mol = p_int * p_units; |
| 97 |
|
|
| 98 |
|
entry_plug->getBox(oldBox); |
| 102 |
– |
|
| 99 |
|
volume = oldBox[0]*oldBox[1]*oldBox[2]; |
| 100 |
|
|
| 101 |
|
ke_temp = ke * e_convert; |
| 102 |
< |
NkBT = (double)ndf * kB * targetTemp; |
| 102 |
> |
NkBT = (double)entry_plug->ndf * kB * targetTemp; |
| 103 |
|
|
| 104 |
|
// propogate the strain rate |
| 105 |
|
|
| 126 |
|
|
| 127 |
|
zeta += dt * ( (ke_temp*2.0 - NkBT) / qmass ); |
| 128 |
|
zetaScale = zeta * dt; |
| 129 |
+ |
|
| 130 |
+ |
std::cerr << "zetaScale = " << zetaScale << " epsilonScale = " << epsilonScale << "\n"; |
| 131 |
|
|
| 132 |
|
// apply barostating and thermostating to velocities and angular momenta |
| 133 |
< |
for(i = 0; i < nAtoms; i++){ |
| 133 |
> |
for(i = 0; i < entry_plug->n_atoms; i++){ |
| 134 |
|
|
| 135 |
|
vx = atoms[i]->get_vx(); |
| 136 |
|
vy = atoms[i]->get_vy(); |
| 140 |
|
atoms[i]->set_vy(vy * (1.0 - zetaScale - epsilonScale)); |
| 141 |
|
atoms[i]->set_vz(vz * (1.0 - zetaScale - epsilonScale)); |
| 142 |
|
} |
| 143 |
< |
if( nOriented ){ |
| 143 |
> |
if( entry_plug->n_oriented ){ |
| 144 |
|
|
| 145 |
< |
for( i=0; i < nAtoms; i++ ){ |
| 145 |
> |
for( i=0; i < entry_plug->n_atoms; i++ ){ |
| 146 |
|
|
| 147 |
|
if( atoms[i]->isDirectional() ){ |
| 148 |
|
|
| 166 |
|
double r[3]; |
| 167 |
|
double boxNum[3]; |
| 168 |
|
double percentScale[3]; |
| 169 |
+ |
double delta[3]; |
| 170 |
|
double rxi, ryi, rzi; |
| 171 |
+ |
|
| 172 |
+ |
molecules = entry_plug->molecules; |
| 173 |
|
|
| 174 |
|
// first determine the scaling factor from the box size change |
| 175 |
|
percentScale[0] = (newBox[0] - oldBox[0]) / oldBox[0]; |
| 176 |
|
percentScale[1] = (newBox[1] - oldBox[1]) / oldBox[1]; |
| 177 |
|
percentScale[2] = (newBox[2] - oldBox[2]) / oldBox[2]; |
| 178 |
|
|
| 179 |
< |
for (i=0; i < nMols; i++) { |
| 179 |
> |
for (i=0; i < entry_plug->n_mol; i++) { |
| 180 |
|
|
| 181 |
|
molecules[i].getCOM(r); |
| 182 |
< |
|
| 182 |
> |
|
| 183 |
|
// find the minimum image coordinates of the molecular centers of mass: |
| 184 |
|
|
| 185 |
|
boxNum[0] = oldBox[0] * copysign(1.0,r[0]) * |
| 200 |
|
ryi += ryi*percentScale[1]; |
| 201 |
|
rzi += rzi*percentScale[2]; |
| 202 |
|
|
| 203 |
< |
r[0] = rxi + boxNum[0]; |
| 204 |
< |
r[1] = ryi + boxNum[1]; |
| 205 |
< |
r[2] = rzi + boxNum[2]; |
| 203 |
> |
delta[0] = r[0] - (rxi + boxNum[0]); |
| 204 |
> |
delta[1] = r[1] - (ryi + boxNum[1]); |
| 205 |
> |
delta[2] = r[2] - (rzi + boxNum[2]); |
| 206 |
|
|
| 207 |
< |
molecules[i].moveCOM(r); |
| 207 |
> |
molecules[i].moveCOM(delta); |
| 208 |
|
} |
| 209 |
|
} |