# | Line 25 | Line 25 | template<typename T> Integrator<T>::Integrator(SimInfo | |
---|---|---|
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 | |
# | Line 177 | Line 176 | template<typename T> void Integrator<T>::integrate(voi | |
176 | // initialize the forces before the first step | |
177 | ||
178 | calcForce(1, 1); | |
179 | + | |
180 | + | if (nConstrained){ |
181 | + | preMove(); |
182 | + | constrainA(); |
183 | + | calcForce(1, 1); |
184 | + | constrainB(); |
185 | + | } |
186 | ||
187 | if (info->setTemp){ | |
188 | thermalize(); | |
# | Line 254 | Line 260 | template<typename T> void Integrator<T>::integrateStep | |
260 | ||
261 | moveA(); | |
262 | ||
263 | < | if (nConstrained){ |
258 | < | constrainA(); |
259 | < | } |
263 | > | |
264 | ||
265 | ||
266 | #ifdef IS_MPI | |
# | Line 279 | Line 283 | template<typename T> void Integrator<T>::integrateStep | |
283 | ||
284 | moveB(); | |
285 | ||
282 | – | if (nConstrained){ |
283 | – | constrainB(); |
284 | – | } |
286 | ||
287 | + | |
288 | #ifdef IS_MPI | |
289 | strcpy(checkPointMsg, "Succesful moveB\n"); | |
290 | MPIcheckPoint(); | |
# | Line 294 | Line 296 | template<typename T> void Integrator<T>::moveA(void){ | |
296 | int i, j; | |
297 | DirectionalAtom* dAtom; | |
298 | double Tb[3], ji[3]; | |
297 | – | double A[3][3], I[3][3]; |
298 | – | double angle; |
299 | double vel[3], pos[3], frc[3]; | |
300 | double mass; | |
301 | ||
# | Line 331 | Line 331 | template<typename T> void Integrator<T>::moveA(void){ | |
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 |
335 | < | // full time step |
336 | < | |
337 | < | dAtom->getA(A); |
338 | < | dAtom->getI(I); |
334 | > | this->rotationPropagation( dAtom, ji ); |
335 | ||
340 | – | // rotate about the x-axis |
341 | – | angle = dt2 * ji[0] / I[0][0]; |
342 | – | this->rotate(1, 2, angle, ji, A); |
343 | – | |
344 | – | // rotate about the y-axis |
345 | – | angle = dt2 * ji[1] / I[1][1]; |
346 | – | this->rotate(2, 0, angle, ji, A); |
347 | – | |
348 | – | // rotate about the z-axis |
349 | – | angle = dt * ji[2] / I[2][2]; |
350 | – | this->rotate(0, 1, angle, ji, A); |
351 | – | |
352 | – | // rotate about the y-axis |
353 | – | angle = dt2 * ji[1] / I[1][1]; |
354 | – | this->rotate(2, 0, angle, ji, A); |
355 | – | |
356 | – | // rotate about the x-axis |
357 | – | angle = dt2 * ji[0] / I[0][0]; |
358 | – | this->rotate(1, 2, angle, ji, A); |
359 | – | |
360 | – | |
336 | dAtom->setJ(ji); | |
362 | – | dAtom->setA(A); |
337 | } | |
338 | } | |
339 | + | |
340 | + | if (nConstrained){ |
341 | + | constrainA(); |
342 | + | } |
343 | } | |
344 | ||
345 | ||
# | Line 402 | Line 380 | template<typename T> void Integrator<T>::moveB(void){ | |
380 | ||
381 | dAtom->setJ(ji); | |
382 | } | |
383 | + | } |
384 | + | |
385 | + | if (nConstrained){ |
386 | + | constrainB(); |
387 | } | |
388 | } | |
389 | ||
# | Line 561 | Line 543 | template<typename T> void Integrator<T>::constrainA(){ | |
543 | painCave.isFatal = 1; | |
544 | simError(); | |
545 | } | |
546 | + | |
547 | } | |
548 | ||
549 | template<typename T> void Integrator<T>::constrainB(void){ | |
# | Line 662 | Line 645 | template<typename T> void Integrator<T>::constrainB(vo | |
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, | |
# | Line 754 | Line 772 | template<typename T> void Integrator<T>::thermalize(){ | |
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 | + | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |