--- branches/development/src/flucq/FluctuatingChargeObjectiveFunction.cpp 2012/06/05 18:01:50 1740 +++ branches/development/src/flucq/FluctuatingChargeObjectiveFunction.cpp 2013/02/20 15:39:39 1850 @@ -35,7 +35,7 @@ * * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). - * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ @@ -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 { @@ -93,7 +99,7 @@ namespace OpenMD{ for (atom = mol->beginFluctuatingCharge(j); atom != NULL; atom = mol->nextFluctuatingCharge(j)) { - + atom->setFlucQPos(x[index++]); } } @@ -112,7 +118,7 @@ namespace OpenMD{ for (atom = mol->beginFluctuatingCharge(j); atom != NULL; atom = mol->nextFluctuatingCharge(j)) { - + grad[index++] = -atom->getFlucQFrc(); } }