34 |
|
int i, j; |
35 |
|
DirectionalAtom* dAtom; |
36 |
|
double Tb[3], ji[3]; |
37 |
< |
double A[3][3], I[3][3]; |
38 |
< |
double angle, mass; |
37 |
> |
double mass; |
38 |
|
double vel[3], pos[3], frc[3]; |
39 |
|
|
40 |
|
double instTemp; |
77 |
|
for (j=0; j < 3; j++) |
78 |
|
ji[j] += dt2 * (Tb[j] * eConvert - ji[j]*chi); |
79 |
|
|
80 |
< |
// use the angular velocities to propagate the rotation matrix a |
82 |
< |
// full time step |
83 |
< |
|
84 |
< |
dAtom->getA(A); |
85 |
< |
dAtom->getI(I); |
86 |
< |
|
87 |
< |
// rotate about the x-axis |
88 |
< |
angle = dt2 * ji[0] / I[0][0]; |
89 |
< |
this->rotate( 1, 2, angle, ji, A ); |
90 |
< |
|
91 |
< |
// rotate about the y-axis |
92 |
< |
angle = dt2 * ji[1] / I[1][1]; |
93 |
< |
this->rotate( 2, 0, angle, ji, A ); |
80 |
> |
this->rotationPropagation( dAtom, ji ); |
81 |
|
|
95 |
– |
// rotate about the z-axis |
96 |
– |
angle = dt * ji[2] / I[2][2]; |
97 |
– |
this->rotate( 0, 1, angle, ji, A); |
98 |
– |
|
99 |
– |
// rotate about the y-axis |
100 |
– |
angle = dt2 * ji[1] / I[1][1]; |
101 |
– |
this->rotate( 2, 0, angle, ji, A ); |
102 |
– |
|
103 |
– |
// rotate about the x-axis |
104 |
– |
angle = dt2 * ji[0] / I[0][0]; |
105 |
– |
this->rotate( 1, 2, angle, ji, A ); |
106 |
– |
|
82 |
|
dAtom->setJ( ji ); |
108 |
– |
dAtom->setA( A ); |
83 |
|
} |
84 |
+ |
} |
85 |
+ |
|
86 |
+ |
if (nConstrained){ |
87 |
+ |
constrainA(); |
88 |
|
} |
89 |
|
|
90 |
|
// Finally, evolve chi a half step (just like a velocity) using |
168 |
|
} |
169 |
|
} |
170 |
|
|
171 |
+ |
if (nConstrained){ |
172 |
+ |
constrainB(); |
173 |
+ |
} |
174 |
+ |
|
175 |
|
if (fabs(prevChi - chi) <= chiTolerance) break; |
176 |
|
} |
177 |
|
|
229 |
|
template<typename T> double NVT<T>::getConservedQuantity(void){ |
230 |
|
|
231 |
|
double conservedQuantity; |
232 |
< |
double E_NVT; |
232 |
> |
double fkBT; |
233 |
> |
double Energy; |
234 |
> |
double thermostat_kinetic; |
235 |
> |
double thermostat_potential; |
236 |
|
|
237 |
< |
//HNVE |
238 |
< |
conservedQuantity = tStats->getTotalE(); |
239 |
< |
//HNVE |
255 |
< |
|
256 |
< |
E_NVT = (info->getNDF() * kB * targetTemp * |
257 |
< |
(integralOfChidt + tauThermostat * tauThermostat * chi * chi / 2.0 )) / eConvert; |
237 |
> |
fkBT = (double)(info->getNDF() ) * kB * targetTemp; |
238 |
> |
|
239 |
> |
Energy = tStats->getTotalE(); |
240 |
|
|
241 |
< |
conservedQuantity += E_NVT; |
241 |
> |
thermostat_kinetic = fkBT* tauThermostat * tauThermostat * chi * chi / |
242 |
> |
(2.0 * eConvert); |
243 |
|
|
244 |
< |
//cerr << info->getTime() << "\t" << chi << "\t" << integralOfChidt << "\t" << E_NVT << endl; |
244 |
> |
thermostat_potential = fkBT * integralOfChidt / eConvert; |
245 |
|
|
246 |
+ |
conservedQuantity = Energy + thermostat_kinetic + thermostat_potential; |
247 |
+ |
|
248 |
+ |
cerr << info->getTime() << "\t" << Energy << "\t" << thermostat_kinetic << |
249 |
+ |
"\t" << thermostat_potential << "\t" << conservedQuantity << endl; |
250 |
+ |
|
251 |
|
return conservedQuantity; |
252 |
|
} |