--- branches/development/src/flucq/FluctuatingChargeObjectiveFunction.cpp 2012/06/18 18:23:20 1756 +++ branches/development/src/flucq/FluctuatingChargeObjectiveFunction.cpp 2012/06/22 20:01:37 1761 @@ -52,8 +52,12 @@ namespace OpenMD{ RealType FluctuatingChargeObjectiveFunction::value(const DynamicVector& x) { setCoor(x); forceMan_->calcForces(); + Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); - return curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL]; + potVec pot = curSnapshot->getLongRangePotentials(); + potVec exPot = curSnapshot->getExcludedPotentials(); + + return pot[ELECTROSTATIC_FAMILY] + exPot[ELECTROSTATIC_FAMILY]; } void FluctuatingChargeObjectiveFunction::gradient(DynamicVector& grad, const DynamicVector& x) { @@ -63,7 +67,7 @@ namespace OpenMD{ forceMan_->calcForces(); fqConstraints_->applyConstraints(); - + getGrad(grad); } @@ -78,7 +82,10 @@ namespace OpenMD{ getGrad(grad); Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); - return curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL]; + potVec pot = curSnapshot->getLongRangePotentials(); + potVec exPot = curSnapshot->getExcludedPotentials(); + + return pot[ELECTROSTATIC_FAMILY] + exPot[ELECTROSTATIC_FAMILY]; } void FluctuatingChargeObjectiveFunction::setCoor(const DynamicVector &x) const { @@ -114,7 +121,6 @@ namespace OpenMD{ atom = mol->nextFluctuatingCharge(j)) { grad[index++] = -atom->getFlucQFrc(); - } } }