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 |
> |
|
60 |
> |
return pot[ELECTROSTATIC_FAMILY] + exPot[ELECTROSTATIC_FAMILY]; |
61 |
|
} |
62 |
|
|
63 |
|
void FluctuatingChargeObjectiveFunction::gradient(DynamicVector<RealType>& grad, const DynamicVector<RealType>& x) { |
67 |
|
|
68 |
|
forceMan_->calcForces(); |
69 |
|
fqConstraints_->applyConstraints(); |
70 |
< |
|
70 |
> |
|
71 |
|
getGrad(grad); |
72 |
|
} |
73 |
|
|
82 |
|
getGrad(grad); |
83 |
|
|
84 |
|
Snapshot* curSnapshot = info_->getSnapshotManager()->getCurrentSnapshot(); |
85 |
< |
return curSnapshot->statData[Stats::ELECTROSTATIC_POTENTIAL]; |
85 |
> |
potVec pot = curSnapshot->getLongRangePotentials(); |
86 |
> |
potVec exPot = curSnapshot->getExcludedPotentials(); |
87 |
> |
|
88 |
> |
return pot[ELECTROSTATIC_FAMILY] + exPot[ELECTROSTATIC_FAMILY]; |
89 |
|
} |
90 |
|
|
91 |
|
void FluctuatingChargeObjectiveFunction::setCoor(const DynamicVector<RealType> &x) const { |
100 |
|
|
101 |
|
for (atom = mol->beginFluctuatingCharge(j); atom != NULL; |
102 |
|
atom = mol->nextFluctuatingCharge(j)) { |
103 |
< |
|
103 |
> |
|
104 |
|
atom->setFlucQPos(x[index++]); |
105 |
|
} |
106 |
|
} |
119 |
|
|
120 |
|
for (atom = mol->beginFluctuatingCharge(j); atom != NULL; |
121 |
|
atom = mol->nextFluctuatingCharge(j)) { |
122 |
< |
|
122 |
> |
|
123 |
|
grad[index++] = -atom->getFlucQFrc(); |
124 |
|
} |
125 |
|
} |