ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/optimization/PotentialEnergyObjectiveFunction.cpp
(Generate patch)

Comparing branches/development/src/optimization/PotentialEnergyObjectiveFunction.cpp (file contents):
Revision 1747 by gezelter, Tue Jun 5 18:02:44 2012 UTC vs.
Revision 1748 by gezelter, Wed Jun 6 19:54:09 2012 UTC

# Line 45 | Line 45 | namespace OpenMD{
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    }
# Line 99 | Line 106 | namespace OpenMD{
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    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines