--- branches/new_design/OOPSE-4/src/integrators/NVT.cpp 2004/12/03 17:59:45 1841 +++ branches/new_design/OOPSE-4/src/integrators/NVT.cpp 2004/12/09 16:22:42 1871 @@ -43,7 +43,7 @@ void NVT::update() { update(); } -void NVT::update() { +void NVT::doUpdate() { oldVel_.resize(info_->getNIntegrableObjects()); oldJi_.resize(info_->getNIntegrableObjects()); } @@ -59,9 +59,8 @@ void NVT::moveA() { Vector3d pos; Vector3d frc; - Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); - double chi = currSnapshot->getChi(); - double integralOfChidt = currSnapshot->getIntegralOfChiDt(); + double chi = currentSnapshot_->getChi(); + double integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); // We need the temperature at time = t for the chi update below: @@ -79,7 +78,7 @@ void NVT::moveA() { // velocity half step (use chi from previous step here): //vel[j] += dt2 * ((frc[j] / mass ) * OOPSEConstant::energyConvert - vel[j]*chi); - vel = dt2 *OOPSEConstant::energyConvert/mass*frc - dt2*chi*vel; + vel += dt2 *OOPSEConstant::energyConvert/mass*frc - dt2*chi*vel; // position whole step //pos[j] += dt * vel[j]; @@ -90,11 +89,9 @@ void NVT::moveA() { if (integrableObject->isDirectional()) { - // get and convert the torque to body frame + //convert the torque to body frame + Tb = integrableObject->lab2Body(integrableObject->getTrq()); - Tb = integrableObject->getTrq(); - integrableObject->lab2Body(Tb); - // get the angular momentum, and propagate a half step ji = integrableObject->getJ(); @@ -118,8 +115,8 @@ void NVT::moveA() { chi += dt2 * (instTemp / targetTemp_ - 1.0) / (tauThermostat_ * tauThermostat_); integralOfChidt += chi * dt2; - currSnapshot->setChi(chi); - currSnapshot->setIntegralOfChiDt(integralOfChidt); + currentSnapshot_->setChi(chi); + currentSnapshot_->setIntegralOfChiDt(integralOfChidt); } void NVT::moveB() { @@ -137,11 +134,10 @@ void NVT::moveB() { int index; // Set things up for the iteration: - Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); - double chi = currSnapshot->getChi(); + double chi = currentSnapshot_->getChi(); double oldChi = chi; double prevChi; - double integralOfChidt = currSnapshot->getIntegralOfChiDt(); + double integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); index = 0; for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) { @@ -149,8 +145,10 @@ void NVT::moveB() { integrableObject = mol->nextIntegrableObject(j)) { oldVel_[index] = integrableObject->getVel(); oldJi_[index] = integrableObject->getJ(); + + ++index; } - ++index; + } // do the iteration: @@ -184,15 +182,17 @@ void NVT::moveB() { // get and convert the torque to body frame - Tb = integrableObject->getTrq(); - integrableObject->lab2Body(Tb); + Tb = integrableObject->lab2Body(integrableObject->getTrq()); //for(j = 0; j < 3; j++) // ji[j] = oldJi_[3*i + j] + dt2 * (Tb[j] * OOPSEConstant::energyConvert - oldJi_[3*i+j]*chi); - ji += dt2*OOPSEConstant::energyConvert*Tb - dt2*chi *oldJi_[index]; + ji = oldJi_[index] + dt2*OOPSEConstant::energyConvert*Tb - dt2*chi *oldJi_[index]; integrableObject->setJ(ji); } + + + ++index; } } @@ -202,20 +202,19 @@ void NVT::moveB() { if (fabs(prevChi - chi) <= chiTolerance_) break; - ++index; } integralOfChidt += dt2 * chi; - currSnapshot->setChi(chi); - currSnapshot->setIntegralOfChiDt(integralOfChidt); + currentSnapshot_->setChi(chi); + currentSnapshot_->setIntegralOfChiDt(integralOfChidt); } double NVT::calcConservedQuantity() { - Snapshot* currSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); - double chi = currSnapshot->getChi(); - double integralOfChidt = currSnapshot->getIntegralOfChiDt(); + + double chi = currentSnapshot_->getChi(); + double integralOfChidt = currentSnapshot_->getIntegralOfChiDt(); double conservedQuantity; double fkBT; double Energy;