51 |
|
FluctuatingChargeNVT::FluctuatingChargeNVT(SimInfo* info) : |
52 |
|
FluctuatingChargePropagator(info), chiTolerance_ (1e-6), |
53 |
|
maxIterNum_(4), thermo(info), |
54 |
< |
currentSnapshot_(info->getSnapshotManager()->getCurrentSnapshot()) { |
54 |
> |
snap(info->getSnapshotManager()->getCurrentSnapshot()) { |
55 |
|
} |
56 |
|
|
57 |
|
void FluctuatingChargeNVT::initialize() { |
68 |
|
} |
69 |
|
|
70 |
|
if (!info_->getSimParams()->getUseIntialExtendedSystemState()) { |
71 |
< |
currentSnapshot_->setChiElectronic(0.0); |
72 |
< |
currentSnapshot_->setIntegralOfChiElectronicDt(0.0); |
71 |
> |
snap->setElectronicThermostat(make_pair(0.0, 0.0)); |
72 |
|
} |
73 |
|
|
74 |
|
if (!fqParams_->haveTargetTemp()) { |
108 |
|
Atom* atom; |
109 |
|
RealType cvel, cpos, cfrc, cmass; |
110 |
|
|
111 |
< |
RealType chi = currentSnapshot_->getChiElectronic(); |
112 |
< |
RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt(); |
111 |
> |
pair<RealType, RealType> thermostat = snap->getElectronicThermostat(); |
112 |
> |
RealType chi = thermostat.first; |
113 |
> |
RealType integralOfChidt = thermostat.second; |
114 |
|
RealType instTemp = thermo.getElectronicTemperature(); |
115 |
|
|
116 |
|
for (mol = info_->beginMolecule(i); mol != NULL; |
137 |
|
(tauThermostat_ * tauThermostat_); |
138 |
|
|
139 |
|
integralOfChidt += chi * dt2_; |
140 |
< |
currentSnapshot_->setChiElectronic(chi); |
141 |
< |
currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt); |
142 |
< |
|
140 |
> |
snap->setElectronicThermostat(make_pair(chi, integralOfChidt)); |
141 |
|
} |
142 |
|
|
143 |
|
void FluctuatingChargeNVT::updateSizes() { |
151 |
|
Molecule* mol; |
152 |
|
Atom* atom; |
153 |
|
RealType instTemp; |
154 |
< |
RealType chi = currentSnapshot_->getChiElectronic(); |
154 |
> |
pair<RealType, RealType> thermostat = snap->getElectronicThermostat(); |
155 |
> |
RealType chi = thermostat.first; |
156 |
|
RealType oldChi = chi; |
157 |
|
RealType prevChi; |
158 |
< |
RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt(); |
158 |
> |
RealType integralOfChidt = thermostat.second; |
159 |
|
int index; |
160 |
|
RealType cfrc, cvel, cmass; |
161 |
|
|
199 |
|
break; |
200 |
|
} |
201 |
|
integralOfChidt += dt2_ * chi; |
202 |
< |
currentSnapshot_->setChiElectronic(chi); |
204 |
< |
currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt); |
202 |
> |
snap->setElectronicThermostat(make_pair(chi, integralOfChidt)); |
203 |
|
} |
204 |
|
|
205 |
|
void FluctuatingChargeNVT::resetPropagator() { |
206 |
|
if (!hasFlucQ_) return; |
207 |
< |
currentSnapshot_->setChiElectronic(0.0); |
210 |
< |
currentSnapshot_->setIntegralOfChiElectronicDt(0.0); |
207 |
> |
snap->setElectronicThermostat(make_pair(0.0, 0.0)); |
208 |
|
} |
209 |
|
|
210 |
|
RealType FluctuatingChargeNVT::calcConservedQuantity() { |
211 |
|
if (!hasFlucQ_) return 0.0; |
212 |
< |
RealType chi = currentSnapshot_->getChiElectronic(); |
213 |
< |
RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt(); |
212 |
> |
pair<RealType, RealType> thermostat = snap->getElectronicThermostat(); |
213 |
> |
RealType chi = thermostat.first; |
214 |
> |
RealType integralOfChidt = thermostat.second; |
215 |
|
RealType fkBT = info_->getNFluctuatingCharges() * |
216 |
|
PhysicalConstants::kB *targetTemp_; |
217 |
|
|