--- branches/development/src/optimization/PotentialEnergyObjectiveFunction.cpp 2012/06/05 18:02:44 1741 +++ branches/development/src/optimization/PotentialEnergyObjectiveFunction.cpp 2012/06/07 12:53:46 1750 @@ -45,29 +45,35 @@ namespace OpenMD{ namespace OpenMD{ PotentialEnergyObjectiveFunction::PotentialEnergyObjectiveFunction(SimInfo* info, ForceManager* forceMan) - : info_(info), forceMan_(forceMan), thermo(info) { + : info_(info), forceMan_(forceMan), thermo(info) { + shake_ = new Shake(info_); } RealType PotentialEnergyObjectiveFunction::value(const DynamicVector& x) { setCoor(x); + shake_->constraintR(); forceMan_->calcForces(); + shake_->constraintF(); return thermo.getPotential(); } void PotentialEnergyObjectiveFunction::gradient(DynamicVector& grad, const DynamicVector& x) { - setCoor(x); - forceMan_->calcForces(); - getGrad(grad); + setCoor(x); + shake_->constraintR(); + forceMan_->calcForces(); + shake_->constraintF(); + getGrad(grad); } RealType PotentialEnergyObjectiveFunction::valueAndGradient(DynamicVector& grad, const DynamicVector& x) { - - setCoor(x); - forceMan_->calcForces(); + setCoor(x); + shake_->constraintR(); + forceMan_->calcForces(); + shake_->constraintF(); getGrad(grad); return thermo.getPotential(); } @@ -99,7 +105,12 @@ namespace OpenMD{ eulerAngle[2] = x[index++]; integrableObject->setEuler(eulerAngle); - } + + if (integrableObject->isRigidBody()) { + RigidBody* rb = static_cast(integrableObject); + rb->updateAtoms(); + } + } } } } @@ -119,7 +130,8 @@ namespace OpenMD{ integrableObject != NULL; integrableObject = mol->nextIntegrableObject(j)) { myGrad = integrableObject->getGrad(); - for (size_t k = 0; k < myGrad.size(); ++k) { + + for (size_t k = 0; k < myGrad.size(); ++k) { grad[index++] = myGrad[k]; } }