56 |
|
namespace OpenMD { |
57 |
|
|
58 |
|
FluctuatingChargePropagator::FluctuatingChargePropagator(SimInfo* info) : |
59 |
< |
info_(info), hasFlucQ_(false), forceMan_(NULL) { |
59 |
> |
info_(info), hasFlucQ_(false), forceMan_(NULL), initialized_(false) { |
60 |
|
|
61 |
|
Globals* simParams = info_->getSimParams(); |
62 |
|
fqParams_ = simParams->getFluctuatingChargeParameters(); |
73 |
|
} |
74 |
|
|
75 |
|
void FluctuatingChargePropagator::initialize() { |
76 |
– |
|
76 |
|
if (info_->usesFluctuatingCharges()) { |
77 |
|
if (info_->getNFluctuatingCharges() > 0) { |
78 |
|
hasFlucQ_ = true; |
79 |
|
} |
80 |
|
} |
81 |
+ |
|
82 |
+ |
if (!hasFlucQ_) { |
83 |
+ |
initialized_ = true; |
84 |
+ |
return; |
85 |
+ |
} |
86 |
|
|
83 |
– |
if (!hasFlucQ_) return; |
84 |
– |
|
87 |
|
SimInfo::MoleculeIterator i; |
88 |
|
Molecule::FluctuatingChargeIterator j; |
89 |
|
Molecule* mol; |
111 |
|
|
112 |
|
DumpStatusFunction dsf(info_); // we want a dump file written |
113 |
|
// every iteration |
112 |
– |
|
114 |
|
minim->minimize(problem, endCriteria); |
115 |
+ |
initialized_ = true; |
116 |
|
} |
117 |
|
|
118 |
|
void FluctuatingChargePropagator::applyConstraints() { |
119 |
+ |
if (!initialized_) initialize(); |
120 |
|
if (!hasFlucQ_) return; |
121 |
|
fqConstraints_->applyConstraints(); |
122 |
|
} |