57 |
|
using namespace QuantLib; |
58 |
|
namespace OpenMD { |
59 |
|
|
60 |
< |
FluctuatingChargePropagator::FluctuatingChargePropagator(SimInfo* info, |
61 |
< |
ForceManager* fm) : |
62 |
< |
info_(info), forceMan_(fm), hasFlucQ_(false) { |
60 |
> |
FluctuatingChargePropagator::FluctuatingChargePropagator(SimInfo* info) : |
61 |
> |
info_(info), hasFlucQ_(false), forceMan_(NULL) { |
62 |
|
|
63 |
+ |
Globals* simParams = info_->getSimParams(); |
64 |
+ |
fqParams_ = simParams->getFluctuatingChargeParameters(); |
65 |
+ |
|
66 |
+ |
} |
67 |
+ |
|
68 |
+ |
void FluctuatingChargePropagator::setForceManager(ForceManager* forceMan) { |
69 |
+ |
forceMan_ = forceMan; |
70 |
+ |
} |
71 |
+ |
|
72 |
+ |
void FluctuatingChargePropagator::initialize() { |
73 |
+ |
|
74 |
|
if (info_->usesFluctuatingCharges()) { |
75 |
|
if (info_->getNFluctuatingCharges() > 0) { |
66 |
– |
|
76 |
|
hasFlucQ_ = true; |
77 |
< |
Globals* simParams = info_->getSimParams(); |
69 |
< |
fqParams_ = simParams->getFluctuatingChargeParameters(); |
70 |
< |
fqConstraints_ = new FluctuatingChargeConstraints(info_); |
71 |
< |
|
77 |
> |
fqConstraints_ = new FluctuatingChargeConstraints(info_); |
78 |
|
} |
79 |
|
} |
74 |
– |
} |
80 |
|
|
76 |
– |
void FluctuatingChargePropagator::initialize() { |
77 |
– |
|
81 |
|
if (!hasFlucQ_) return; |
82 |
|
|
83 |
|
SimInfo::MoleculeIterator i; |
93 |
|
atom->setFlucQVel(0.0); |
94 |
|
} |
95 |
|
} |
93 |
– |
|
94 |
– |
std::cerr << "doing a minimization\n"; |
96 |
|
|
97 |
|
fqConstraints_ = new FluctuatingChargeConstraints(info_); |
98 |
|
FluctuatingChargeObjectiveFunction flucQobjf(info_, forceMan_, fqConstraints_); |
101 |
|
EndCriteria endCriteria(1000, 100, 1e-5, 1e-5, 1e-5); |
102 |
|
OptimizationMethod* minim = OptimizationFactory::getInstance()->createOptimization("SD", info_); |
103 |
|
|
104 |
< |
DumpStatusFunction dsf(info_); // we want a dump file written every iteration |
104 |
> |
DumpStatusFunction dsf(info_); // we want a dump file written every iteration |
105 |
|
|
106 |
|
minim->minimize(problem, endCriteria); |
106 |
– |
cerr << "Finished minimization\n"; |
107 |
– |
for (mol = info_->beginMolecule(i); mol != NULL; |
108 |
– |
mol = info_->nextMolecule(i)) { |
109 |
– |
for (atom = mol->beginFluctuatingCharge(j); atom != NULL; |
110 |
– |
atom = mol->nextFluctuatingCharge(j)) { |
111 |
– |
cerr << atom->getType() << "\tQ Pos: " << atom->getFlucQPos() << "\n"; |
112 |
– |
} |
113 |
– |
} |
114 |
– |
// std::cerr << "after minim\n"; |
115 |
– |
// for (mol = info_->beginMolecule(i); mol != NULL; |
116 |
– |
// mol = info_->nextMolecule(i)) { |
117 |
– |
// for (atom = mol->beginFluctuatingCharge(j); atom != NULL; |
118 |
– |
// atom = mol->nextFluctuatingCharge(j)) { |
119 |
– |
// cerr << "q = " << atom->getFlucQPos(0.0) << "\n"; |
120 |
– |
// } |
121 |
– |
// } |
107 |
|
|
123 |
– |
|
108 |
|
} |
109 |
|
|
126 |
– |
|
110 |
|
void FluctuatingChargePropagator::applyConstraints() { |
111 |
|
if (!hasFlucQ_) return; |
112 |
|
|