| 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) { |
| 69 |
|
|
| 70 |
|
forceMan_->calcForces(); |
| 71 |
|
fqConstraints_->applyConstraints(); |
| 72 |
< |
|
| 72 |
> |
cerr << "grad\n"; |
| 73 |
|
getGrad(grad); |
| 74 |
|
} |
| 75 |
|
|
| 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 { |
| 106 |
|
atom = mol->nextFluctuatingCharge(j)) { |
| 107 |
|
|
| 108 |
|
atom->setFlucQPos(x[index++]); |
| 109 |
+ |
cerr << "setting charge = " << x[index -1] << "\n"; |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
} |
| 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 |
|
} |