| 45 |  | namespace OpenMD{ | 
| 46 |  |  | 
| 47 |  | PotentialEnergyObjectiveFunction::PotentialEnergyObjectiveFunction(SimInfo* info, ForceManager* forceMan) | 
| 48 | < | : info_(info), forceMan_(forceMan), thermo(info) { | 
| 48 | > | : info_(info), forceMan_(forceMan), thermo(info) { | 
| 49 | > | shake_ = new Shake(info_); | 
| 50 |  | } | 
| 51 |  |  | 
| 52 |  |  | 
| 53 |  |  | 
| 54 |  | RealType PotentialEnergyObjectiveFunction::value(const DynamicVector<RealType>& x) { | 
| 55 |  | setCoor(x); | 
| 56 | + | shake_->constraintR(); | 
| 57 |  | forceMan_->calcForces(); | 
| 58 | + | shake_->constraintF(); | 
| 59 |  | return thermo.getPotential(); | 
| 60 |  | } | 
| 61 |  |  | 
| 62 |  | void PotentialEnergyObjectiveFunction::gradient(DynamicVector<RealType>& grad, const DynamicVector<RealType>& x) { | 
| 63 |  |  | 
| 64 | < | setCoor(x); | 
| 65 | < | forceMan_->calcForces(); | 
| 66 | < | getGrad(grad); | 
| 64 | > | setCoor(x); | 
| 65 | > | shake_->constraintR(); | 
| 66 | > | forceMan_->calcForces(); | 
| 67 | > | shake_->constraintF(); | 
| 68 | > | getGrad(grad); | 
| 69 |  | } | 
| 70 |  |  | 
| 71 |  | RealType PotentialEnergyObjectiveFunction::valueAndGradient(DynamicVector<RealType>& grad, | 
| 72 |  | const DynamicVector<RealType>& x) { | 
| 73 |  |  | 
| 74 | < | setCoor(x); | 
| 75 | < | forceMan_->calcForces(); | 
| 74 | > | setCoor(x); | 
| 75 | > | shake_->constraintR(); | 
| 76 | > | forceMan_->calcForces(); | 
| 77 | > | shake_->constraintF(); | 
| 78 |  | getGrad(grad); | 
| 79 |  | return thermo.getPotential(); | 
| 80 |  | } | 
| 106 |  | eulerAngle[2] = x[index++]; | 
| 107 |  |  | 
| 108 |  | integrableObject->setEuler(eulerAngle); | 
| 109 | < | } | 
| 109 | > |  | 
| 110 | > | if (integrableObject->isRigidBody()) { | 
| 111 | > | RigidBody* rb = static_cast<RigidBody*>(integrableObject); | 
| 112 | > | rb->updateAtoms(); | 
| 113 | > | } | 
| 114 | > | } | 
| 115 |  | } | 
| 116 |  | } | 
| 117 |  | } |