--- branches/development/src/flucq/FluctuatingChargeObjectiveFunction.cpp 2012/06/05 18:01:50 1740 +++ 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 { @@ -93,7 +100,7 @@ namespace OpenMD{ for (atom = mol->beginFluctuatingCharge(j); atom != NULL; atom = mol->nextFluctuatingCharge(j)) { - + atom->setFlucQPos(x[index++]); } } @@ -112,7 +119,7 @@ namespace OpenMD{ for (atom = mol->beginFluctuatingCharge(j); atom != NULL; atom = mol->nextFluctuatingCharge(j)) { - + grad[index++] = -atom->getFlucQFrc(); } }