52 |
|
thermo(info), |
53 |
|
currentSnapshot_(info->getSnapshotManager()->getCurrentSnapshot()) { |
54 |
|
|
55 |
+ |
|
56 |
|
if (info_->usesFluctuatingCharges()) { |
57 |
|
if (info_->getNFluctuatingCharges() > 0) { |
58 |
|
|
59 |
|
hasFlucQ_ = true; |
60 |
|
Globals* simParams = info_->getSimParams(); |
61 |
+ |
FluctuatingChargeParameters* fqParams = simParams->getFluctuatingChargeParameters(); |
62 |
|
|
63 |
|
if (simParams->haveDt()) { |
64 |
|
dt_ = simParams->getDt(); |
75 |
|
currentSnapshot_->setIntegralOfChiElectronicDt(0.0); |
76 |
|
} |
77 |
|
|
78 |
< |
if (!simParams->haveFlucQTargetTemp()) { |
78 |
> |
if (!fqParams->haveTargetTemp()) { |
79 |
|
sprintf(painCave.errMsg, "You can't use the FluctuatingChargeNVT " |
80 |
|
"propagator without a flucQ.targetTemp!\n"); |
81 |
|
painCave.isFatal = 1; |
82 |
|
painCave.severity = OPENMD_ERROR; |
83 |
|
simError(); |
84 |
|
} else { |
85 |
< |
targetTemp_ = simParams->getFlucQTargetTemp(); |
85 |
> |
targetTemp_ = fqParams->getTargetTemp(); |
86 |
|
} |
87 |
|
|
88 |
|
// We must set tauThermostat. |
89 |
|
|
90 |
< |
if (!simParams->haveFlucQtauThermostat()) { |
90 |
> |
if (!fqParams->haveTauThermostat()) { |
91 |
|
sprintf(painCave.errMsg, "If you use the FluctuatingChargeNVT\n" |
92 |
|
"\tpropagator, you must set flucQ.tauThermostat .\n"); |
93 |
|
|
95 |
|
painCave.isFatal = 1; |
96 |
|
simError(); |
97 |
|
} else { |
98 |
< |
tauThermostat_ = simParams->getFlucQtauThermostat(); |
98 |
> |
tauThermostat_ = fqParams->getTauThermostat(); |
99 |
|
} |
100 |
|
updateSizes(); |
101 |
|
} |
137 |
|
RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt(); |
138 |
|
RealType instTemp = thermo.getElectronicTemperature(); |
139 |
|
|
138 |
– |
cerr << "why are we here?\n"; |
140 |
|
|
141 |
|
for (mol = info_->beginMolecule(i); mol != NULL; |
142 |
|
mol = info_->nextMolecule(i)) { |
148 |
|
cfrc = atom->getFlucQFrc(); |
149 |
|
cmass = atom->getChargeMass(); |
150 |
|
|
151 |
< |
// velocity half step |
152 |
< |
cvel += dt2_ *PhysicalConstants::energyConvert/cmass*cfrc - dt2_*chi*cvel; |
151 |
> |
cerr << atom->getType() << "\n"; |
152 |
> |
cerr << "Before\n"; |
153 |
> |
cerr << "cvel: " << cvel << "\tcpos: " << cpos << "\tcfrc: " << cfrc << "\tcmass: " << cmass << "\n"; |
154 |
> |
|
155 |
> |
// velocity half step |
156 |
> |
cvel += dt2_ * cfrc / cmass - dt2_*chi*cvel; |
157 |
|
// position whole step |
158 |
|
cpos += dt_ * cvel; |
159 |
< |
|
159 |
> |
|
160 |
> |
cerr << "After\n"; |
161 |
> |
cerr << "cvel: " << cvel << "\tcpos: " << cpos << "\n\n"; |
162 |
> |
|
163 |
|
atom->setFlucQVel(cvel); |
164 |
|
atom->setFlucQPos(cpos); |
165 |
|
} |
169 |
|
(tauThermostat_ * tauThermostat_); |
170 |
|
|
171 |
|
integralOfChidt += chi * dt2_; |
172 |
+ |
cerr << "Move A instTemp: " << instTemp << "\n"; |
173 |
|
currentSnapshot_->setChiElectronic(chi); |
174 |
|
currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt); |
175 |
|
|
210 |
|
for(int k = 0; k < maxIterNum_; k++) { |
211 |
|
index = 0; |
212 |
|
instTemp = thermo.getElectronicTemperature(); |
213 |
< |
|
213 |
> |
cerr << "MoveB instTemp: " << instTemp << "\n"; |
214 |
|
// evolve chi another half step using the temperature at t + dt/2 |
215 |
|
prevChi = chi; |
216 |
|
chi = oldChi + dt2_ * (instTemp / targetTemp_ - 1.0) / |
226 |
|
cmass = atom->getChargeMass(); |
227 |
|
|
228 |
|
// velocity half step |
229 |
< |
cvel = oldVel_[index] + dt2_/cmass*PhysicalConstants::energyConvert * cfrc - dt2_*chi*oldVel_[index]; |
229 |
> |
cvel = oldVel_[index] + dt2_ * cfrc / cmass - dt2_*chi*oldVel_[index]; |
230 |
|
|
231 |
|
atom->setFlucQVel(cvel); |
232 |
|
++index; |