--- branches/development/src/flucq/FluctuatingChargeObjectiveFunction.cpp 2012/06/18 18:23:20 1756 +++ branches/development/src/flucq/FluctuatingChargeObjectiveFunction.cpp 2012/07/06 22:01:58 1767 @@ -52,18 +52,21 @@ 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) { - int shakeStatus; setCoor(x); forceMan_->calcForces(); fqConstraints_->applyConstraints(); - + getGrad(grad); } @@ -78,7 +81,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 +120,6 @@ namespace OpenMD{ atom = mol->nextFluctuatingCharge(j)) { grad[index++] = -atom->getFlucQFrc(); - } } }