--- trunk/OOPSE/libmdtools/Integrator.cpp 2003/08/26 20:37:30 726 +++ trunk/OOPSE/libmdtools/Integrator.cpp 2003/09/24 19:34:39 784 @@ -25,8 +25,7 @@ template Integrator::Integrator(SimInfo if (info->the_integrator != NULL){ delete info->the_integrator; } - info->the_integrator = this; - + nAtoms = info->n_atoms; // check for constraints @@ -153,11 +152,14 @@ template void Integrator::integrate(voi double sampleTime = info->sampleTime; double statusTime = info->statusTime; double thermalTime = info->thermalTime; + double resetTime = info->resetTime; + double currSample; double currThermal; double currStatus; - + double currReset; + int calcPot, calcStress; int isError; @@ -171,32 +173,35 @@ template void Integrator::integrate(voi dt = info->dt; dt2 = 0.5 * dt; + readyCheck(); + // initialize the forces before the first step calcForce(1, 1); - // myFF->doForces(1,1); + if (nConstrained){ + preMove(); + constrainA(); + calcForce(1, 1); + constrainB(); + } + if (info->setTemp){ thermalize(); } - calcPot = 0; - calcStress = 0; - currSample = sampleTime; - currThermal = thermalTime; - currStatus = statusTime; - calcPot = 0; calcStress = 0; currSample = sampleTime + info->getTime(); currThermal = thermalTime+ info->getTime(); currStatus = statusTime + info->getTime(); + currReset = resetTime + info->getTime(); dumpOut->writeDump(info->getTime()); statOut->writeStat(info->getTime()); - readyCheck(); + #ifdef IS_MPI strcpy(checkPointMsg, "The integrator is ready to go."); MPIcheckPoint(); @@ -231,6 +236,13 @@ template void Integrator::integrate(voi currStatus += statusTime; } + if (info->resetIntegrator){ + if (info->getTime() >= currReset){ + this->resetIntegrator(); + currReset += resetTime; + } + } + #ifdef IS_MPI strcpy(checkPointMsg, "successfully took a time step."); MPIcheckPoint(); @@ -250,11 +262,9 @@ template void Integrator::integrateStep moveA(); - if (nConstrained){ - constrainA(); - } + #ifdef IS_MPI strcpy(checkPointMsg, "Succesful moveA\n"); MPIcheckPoint(); @@ -275,10 +285,8 @@ template void Integrator::integrateStep moveB(); - if (nConstrained){ - constrainB(); - } + #ifdef IS_MPI strcpy(checkPointMsg, "Succesful moveB\n"); MPIcheckPoint(); @@ -290,8 +298,6 @@ template void Integrator::moveA(void){ int i, j; DirectionalAtom* dAtom; double Tb[3], ji[3]; - double A[3][3], I[3][3]; - double angle; double vel[3], pos[3], frc[3]; double mass; @@ -327,36 +333,14 @@ template void Integrator::moveA(void){ for (j = 0; j < 3; j++) ji[j] += (dt2 * Tb[j]) * eConvert; - // use the angular velocities to propagate the rotation matrix a - // full time step + this->rotationPropagation( dAtom, ji ); - dAtom->getA(A); - dAtom->getI(I); - - // rotate about the x-axis - angle = dt2 * ji[0] / I[0][0]; - this->rotate(1, 2, angle, ji, A); - - // rotate about the y-axis - angle = dt2 * ji[1] / I[1][1]; - this->rotate(2, 0, angle, ji, A); - - // rotate about the z-axis - angle = dt * ji[2] / I[2][2]; - this->rotate(0, 1, angle, ji, A); - - // rotate about the y-axis - angle = dt2 * ji[1] / I[1][1]; - this->rotate(2, 0, angle, ji, A); - - // rotate about the x-axis - angle = dt2 * ji[0] / I[0][0]; - this->rotate(1, 2, angle, ji, A); - - - dAtom->setJ(ji); - dAtom->setA(A); + dAtom->setJ(ji); } + } + + if (nConstrained){ + constrainA(); } } @@ -399,6 +383,10 @@ template void Integrator::moveB(void){ dAtom->setJ(ji); } } + + if (nConstrained){ + constrainB(); + } } template void Integrator::preMove(void){ @@ -557,6 +545,7 @@ template void Integrator::constrainA(){ painCave.isFatal = 1; simError(); } + } template void Integrator::constrainB(void){ @@ -658,6 +647,41 @@ template void Integrator::constrainB(vo painCave.isFatal = 1; simError(); } +} + +template void Integrator::rotationPropagation +( DirectionalAtom* dAtom, double ji[3] ){ + + double angle; + double A[3][3], I[3][3]; + + // use the angular velocities to propagate the rotation matrix a + // full time step + + dAtom->getA(A); + dAtom->getI(I); + + // rotate about the x-axis + angle = dt2 * ji[0] / I[0][0]; + this->rotate( 1, 2, angle, ji, A ); + + // rotate about the y-axis + angle = dt2 * ji[1] / I[1][1]; + this->rotate( 2, 0, angle, ji, A ); + + // rotate about the z-axis + angle = dt * ji[2] / I[2][2]; + this->rotate( 0, 1, angle, ji, A); + + // rotate about the y-axis + angle = dt2 * ji[1] / I[1][1]; + this->rotate( 2, 0, angle, ji, A ); + + // rotate about the x-axis + angle = dt2 * ji[0] / I[0][0]; + this->rotate( 1, 2, angle, ji, A ); + + dAtom->setA( A ); } template void Integrator::rotate(int axes1, int axes2, @@ -750,3 +774,7 @@ template void Integrator::thermalize(){ template void Integrator::thermalize(){ tStats->velocitize(); } + +template double Integrator::getConservedQuantity(void){ + return tStats->getTotalE(); +}