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

Comparing branches/development/src/flucq/FluctuatingChargeObjectiveFunction.cpp (file contents):
Revision 1759 by gezelter, Mon Jun 18 18:23:20 2012 UTC vs.
Revision 1760 by gezelter, Thu Jun 21 19:26:46 2012 UTC

# Line 52 | Line 52 | namespace OpenMD{
52    RealType FluctuatingChargeObjectiveFunction::value(const DynamicVector<RealType>& x) {
53      setCoor(x);
54      forceMan_->calcForces();
55 +
56      Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
57 <    return curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL];
57 >    potVec pot = curSnapshot->getLongRangePotentials();
58 >    potVec exPot = curSnapshot->getExcludedPotentials();  
59 >    cerr << "val p= " <<   pot[ELECTROSTATIC_FAMILY] << "\n";
60 >    cerr << "val e= " << exPot[ELECTROSTATIC_FAMILY] << "\n";
61 >  
62 >    return pot[ELECTROSTATIC_FAMILY] + exPot[ELECTROSTATIC_FAMILY];
63    }
64    
65    void FluctuatingChargeObjectiveFunction::gradient(DynamicVector<RealType>& grad, const DynamicVector<RealType>& x) {
# Line 63 | Line 69 | namespace OpenMD{
69      
70      forceMan_->calcForces();
71      fqConstraints_->applyConstraints();
72 <    
72 >    cerr << "grad\n";
73      getGrad(grad);      
74    }
75    
# Line 78 | Line 84 | namespace OpenMD{
84      getGrad(grad);
85  
86      Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot();
87 <    return curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL];
87 >    potVec pot = curSnapshot->getLongRangePotentials();
88 >    potVec exPot = curSnapshot->getExcludedPotentials();    
89 >    cerr << "vang p= " <<   pot[ELECTROSTATIC_FAMILY] << "\n";
90 >    cerr << "vang e= " << exPot[ELECTROSTATIC_FAMILY] << "\n";
91 >
92 >    return pot[ELECTROSTATIC_FAMILY] + exPot[ELECTROSTATIC_FAMILY];
93    }
94    
95    void FluctuatingChargeObjectiveFunction::setCoor(const DynamicVector<RealType> &x) const {
# Line 95 | Line 106 | namespace OpenMD{
106             atom = mol->nextFluctuatingCharge(j)) {
107        
108          atom->setFlucQPos(x[index++]);
109 +        cerr << "setting charge = " << x[index -1] << "\n";
110        }
111      }    
112    }
# Line 113 | Line 125 | namespace OpenMD{
125        for (atom = mol->beginFluctuatingCharge(j); atom != NULL;
126             atom = mol->nextFluctuatingCharge(j)) {
127  
128 <        grad[index++] = -atom->getFlucQFrc();
129 <
128 >        grad[index++] = atom->getFlucQFrc();
129 >        cerr << "getting grad = " << grad[index -1] << "\n";
130        }
131      }
132    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines