25 |
|
if (info->the_integrator != NULL){ |
26 |
|
delete info->the_integrator; |
27 |
|
} |
28 |
< |
info->the_integrator = this; |
29 |
< |
|
28 |
> |
|
29 |
|
nAtoms = info->n_atoms; |
30 |
|
|
31 |
|
// check for constraints |
152 |
|
double sampleTime = info->sampleTime; |
153 |
|
double statusTime = info->statusTime; |
154 |
|
double thermalTime = info->thermalTime; |
155 |
+ |
double resetTime = info->resetTime; |
156 |
|
|
157 |
+ |
|
158 |
|
double currSample; |
159 |
|
double currThermal; |
160 |
|
double currStatus; |
161 |
< |
|
161 |
> |
double currReset; |
162 |
> |
|
163 |
|
int calcPot, calcStress; |
164 |
|
int isError; |
165 |
|
|
176 |
|
// initialize the forces before the first step |
177 |
|
|
178 |
|
calcForce(1, 1); |
177 |
– |
// myFF->doForces(1,1); |
179 |
|
|
180 |
+ |
if (nConstrained){ |
181 |
+ |
preMove(); |
182 |
+ |
constrainA(); |
183 |
+ |
calcForce(1, 1); |
184 |
+ |
constrainB(); |
185 |
+ |
} |
186 |
+ |
|
187 |
|
if (info->setTemp){ |
188 |
|
thermalize(); |
189 |
|
} |
190 |
|
|
183 |
– |
calcPot = 0; |
184 |
– |
calcStress = 0; |
185 |
– |
currSample = sampleTime; |
186 |
– |
currThermal = thermalTime; |
187 |
– |
currStatus = statusTime; |
188 |
– |
|
191 |
|
calcPot = 0; |
192 |
|
calcStress = 0; |
193 |
|
currSample = sampleTime + info->getTime(); |
194 |
|
currThermal = thermalTime+ info->getTime(); |
195 |
|
currStatus = statusTime + info->getTime(); |
196 |
+ |
currReset = resetTime + info->getTime(); |
197 |
|
|
198 |
|
dumpOut->writeDump(info->getTime()); |
199 |
|
statOut->writeStat(info->getTime()); |
234 |
|
currStatus += statusTime; |
235 |
|
} |
236 |
|
|
237 |
+ |
if (info->resetIntegrator){ |
238 |
+ |
if (info->getTime() >= currReset){ |
239 |
+ |
this->resetIntegrator(); |
240 |
+ |
currReset += resetTime; |
241 |
+ |
} |
242 |
+ |
} |
243 |
+ |
|
244 |
|
#ifdef IS_MPI |
245 |
|
strcpy(checkPointMsg, "successfully took a time step."); |
246 |
|
MPIcheckPoint(); |
260 |
|
|
261 |
|
moveA(); |
262 |
|
|
253 |
– |
if (nConstrained){ |
254 |
– |
constrainA(); |
255 |
– |
} |
263 |
|
|
264 |
|
|
265 |
+ |
|
266 |
|
#ifdef IS_MPI |
267 |
|
strcpy(checkPointMsg, "Succesful moveA\n"); |
268 |
|
MPIcheckPoint(); |
283 |
|
|
284 |
|
moveB(); |
285 |
|
|
278 |
– |
if (nConstrained){ |
279 |
– |
constrainB(); |
280 |
– |
} |
286 |
|
|
287 |
+ |
|
288 |
|
#ifdef IS_MPI |
289 |
|
strcpy(checkPointMsg, "Succesful moveB\n"); |
290 |
|
MPIcheckPoint(); |
296 |
|
int i, j; |
297 |
|
DirectionalAtom* dAtom; |
298 |
|
double Tb[3], ji[3]; |
293 |
– |
double A[3][3], I[3][3]; |
294 |
– |
double angle; |
299 |
|
double vel[3], pos[3], frc[3]; |
300 |
|
double mass; |
301 |
|
|
331 |
|
for (j = 0; j < 3; j++) |
332 |
|
ji[j] += (dt2 * Tb[j]) * eConvert; |
333 |
|
|
334 |
< |
// use the angular velocities to propagate the rotation matrix a |
331 |
< |
// full time step |
334 |
> |
this->rotationPropagation( dAtom, ji ); |
335 |
|
|
336 |
< |
dAtom->getA(A); |
337 |
< |
dAtom->getI(I); |
338 |
< |
|
336 |
< |
// rotate about the x-axis |
337 |
< |
angle = dt2 * ji[0] / I[0][0]; |
338 |
< |
this->rotate(1, 2, angle, ji, A); |
339 |
< |
|
340 |
< |
// rotate about the y-axis |
341 |
< |
angle = dt2 * ji[1] / I[1][1]; |
342 |
< |
this->rotate(2, 0, angle, ji, A); |
343 |
< |
|
344 |
< |
// rotate about the z-axis |
345 |
< |
angle = dt * ji[2] / I[2][2]; |
346 |
< |
this->rotate(0, 1, angle, ji, A); |
336 |
> |
dAtom->setJ(ji); |
337 |
> |
} |
338 |
> |
} |
339 |
|
|
340 |
< |
// rotate about the y-axis |
341 |
< |
angle = dt2 * ji[1] / I[1][1]; |
350 |
< |
this->rotate(2, 0, angle, ji, A); |
351 |
< |
|
352 |
< |
// rotate about the x-axis |
353 |
< |
angle = dt2 * ji[0] / I[0][0]; |
354 |
< |
this->rotate(1, 2, angle, ji, A); |
355 |
< |
|
356 |
< |
|
357 |
< |
dAtom->setJ(ji); |
358 |
< |
dAtom->setA(A); |
359 |
< |
} |
340 |
> |
if (nConstrained){ |
341 |
> |
constrainA(); |
342 |
|
} |
343 |
|
} |
344 |
|
|
381 |
|
dAtom->setJ(ji); |
382 |
|
} |
383 |
|
} |
384 |
+ |
|
385 |
+ |
if (nConstrained){ |
386 |
+ |
constrainB(); |
387 |
+ |
} |
388 |
|
} |
389 |
|
|
390 |
|
template<typename T> void Integrator<T>::preMove(void){ |
543 |
|
painCave.isFatal = 1; |
544 |
|
simError(); |
545 |
|
} |
546 |
+ |
|
547 |
|
} |
548 |
|
|
549 |
|
template<typename T> void Integrator<T>::constrainB(void){ |
645 |
|
painCave.isFatal = 1; |
646 |
|
simError(); |
647 |
|
} |
648 |
+ |
} |
649 |
+ |
|
650 |
+ |
template<typename T> void Integrator<T>::rotationPropagation |
651 |
+ |
( DirectionalAtom* dAtom, double ji[3] ){ |
652 |
+ |
|
653 |
+ |
double angle; |
654 |
+ |
double A[3][3], I[3][3]; |
655 |
+ |
|
656 |
+ |
// use the angular velocities to propagate the rotation matrix a |
657 |
+ |
// full time step |
658 |
+ |
|
659 |
+ |
dAtom->getA(A); |
660 |
+ |
dAtom->getI(I); |
661 |
+ |
|
662 |
+ |
// rotate about the x-axis |
663 |
+ |
angle = dt2 * ji[0] / I[0][0]; |
664 |
+ |
this->rotate( 1, 2, angle, ji, A ); |
665 |
+ |
|
666 |
+ |
// rotate about the y-axis |
667 |
+ |
angle = dt2 * ji[1] / I[1][1]; |
668 |
+ |
this->rotate( 2, 0, angle, ji, A ); |
669 |
+ |
|
670 |
+ |
// rotate about the z-axis |
671 |
+ |
angle = dt * ji[2] / I[2][2]; |
672 |
+ |
this->rotate( 0, 1, angle, ji, A); |
673 |
+ |
|
674 |
+ |
// rotate about the y-axis |
675 |
+ |
angle = dt2 * ji[1] / I[1][1]; |
676 |
+ |
this->rotate( 2, 0, angle, ji, A ); |
677 |
+ |
|
678 |
+ |
// rotate about the x-axis |
679 |
+ |
angle = dt2 * ji[0] / I[0][0]; |
680 |
+ |
this->rotate( 1, 2, angle, ji, A ); |
681 |
+ |
|
682 |
+ |
dAtom->setA( A ); |
683 |
|
} |
684 |
|
|
685 |
|
template<typename T> void Integrator<T>::rotate(int axes1, int axes2, |
772 |
|
template<typename T> void Integrator<T>::thermalize(){ |
773 |
|
tStats->velocitize(); |
774 |
|
} |
775 |
+ |
|
776 |
+ |
template<typename T> double Integrator<T>::getConservedQuantity(void){ |
777 |
+ |
return tStats->getTotalE(); |
778 |
+ |
} |