47 |
|
|
48 |
|
namespace OpenMD { |
49 |
|
|
50 |
< |
FluctuatingChargeNVT::FluctuatingChargeNVT(SimInfo* info) : |
51 |
< |
FluctuatingChargePropagator(info), chiTolerance_ (1e-6), maxIterNum_(4), |
52 |
< |
thermo(info), |
50 |
> |
FluctuatingChargeNVT::FluctuatingChargeNVT(SimInfo* info, ForceManager* fm) : |
51 |
> |
FluctuatingChargePropagator(info, fm), chiTolerance_ (1e-6), |
52 |
> |
maxIterNum_(4), 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(); |
65 |
< |
dt2_ = dt_ * 0.5; |
66 |
< |
} else { |
67 |
< |
sprintf(painCave.errMsg, |
68 |
< |
"FluctuatingChargeNVT Error: dt is not set\n"); |
69 |
< |
painCave.isFatal = 1; |
70 |
< |
simError(); |
71 |
< |
} |
54 |
> |
|
55 |
> |
if (hasFlucQ_) { |
56 |
> |
if (info_->getSimParams()->haveDt()) { |
57 |
> |
dt_ = info_->getSimParams()->getDt(); |
58 |
> |
dt2_ = dt_ * 0.5; |
59 |
> |
} else { |
60 |
> |
sprintf(painCave.errMsg, |
61 |
> |
"FluctuatingChargeNVT Error: dt is not set\n"); |
62 |
> |
painCave.isFatal = 1; |
63 |
> |
simError(); |
64 |
> |
} |
65 |
> |
|
66 |
> |
if (!info_->getSimParams()->getUseIntialExtendedSystemState()) { |
67 |
> |
currentSnapshot_->setChiElectronic(0.0); |
68 |
> |
currentSnapshot_->setIntegralOfChiElectronicDt(0.0); |
69 |
> |
} |
70 |
> |
|
71 |
> |
if (!fqParams_->haveTargetTemp()) { |
72 |
> |
sprintf(painCave.errMsg, "You can't use the FluctuatingChargeNVT " |
73 |
> |
"propagator without a flucQ.targetTemp!\n"); |
74 |
> |
painCave.isFatal = 1; |
75 |
> |
painCave.severity = OPENMD_ERROR; |
76 |
> |
simError(); |
77 |
> |
} else { |
78 |
> |
targetTemp_ = fqParams_->getTargetTemp(); |
79 |
> |
} |
80 |
> |
|
81 |
> |
// We must set tauThermostat. |
82 |
> |
|
83 |
> |
if (!fqParams_->haveTauThermostat()) { |
84 |
> |
sprintf(painCave.errMsg, "If you use the FluctuatingChargeNVT\n" |
85 |
> |
"\tpropagator, you must set flucQ.tauThermostat .\n"); |
86 |
|
|
87 |
< |
if (!simParams->getUseIntialExtendedSystemState()) { |
88 |
< |
currentSnapshot_->setChiElectronic(0.0); |
89 |
< |
currentSnapshot_->setIntegralOfChiElectronicDt(0.0); |
90 |
< |
} |
91 |
< |
|
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_ = fqParams->getTargetTemp(); |
86 |
< |
} |
87 |
< |
|
88 |
< |
// We must set tauThermostat. |
89 |
< |
|
90 |
< |
if (!fqParams->haveTauThermostat()) { |
91 |
< |
sprintf(painCave.errMsg, "If you use the FluctuatingChargeNVT\n" |
92 |
< |
"\tpropagator, you must set flucQ.tauThermostat .\n"); |
93 |
< |
|
94 |
< |
painCave.severity = OPENMD_ERROR; |
95 |
< |
painCave.isFatal = 1; |
96 |
< |
simError(); |
97 |
< |
} else { |
98 |
< |
tauThermostat_ = fqParams->getTauThermostat(); |
99 |
< |
} |
100 |
< |
updateSizes(); |
87 |
> |
painCave.severity = OPENMD_ERROR; |
88 |
> |
painCave.isFatal = 1; |
89 |
> |
simError(); |
90 |
> |
} else { |
91 |
> |
tauThermostat_ = fqParams_->getTauThermostat(); |
92 |
|
} |
93 |
< |
} |
93 |
> |
updateSizes(); |
94 |
> |
} |
95 |
|
} |
96 |
|
|
97 |
|
void FluctuatingChargeNVT::initialize() { |
98 |
< |
|
107 |
< |
if (!hasFlucQ_) return; |
108 |
< |
|
109 |
< |
SimInfo::MoleculeIterator i; |
110 |
< |
Molecule::FluctuatingChargeIterator j; |
111 |
< |
Molecule* mol; |
112 |
< |
Atom* atom; |
113 |
< |
|
114 |
< |
for (mol = info_->beginMolecule(i); mol != NULL; |
115 |
< |
mol = info_->nextMolecule(i)) { |
116 |
< |
for (atom = mol->beginFluctuatingCharge(j); atom != NULL; |
117 |
< |
atom = mol->nextFluctuatingCharge(j)) { |
118 |
< |
atom->setFlucQPos(0.0); |
119 |
< |
atom->setFlucQVel(0.0); |
120 |
< |
} |
121 |
< |
} |
122 |
< |
|
123 |
< |
cerr << "Yeah, you should probably implement this\n"; |
98 |
> |
FluctuatingChargePropagator::initialize(); |
99 |
|
} |
100 |
|
|
101 |
+ |
|
102 |
|
void FluctuatingChargeNVT::moveA() { |
103 |
|
|
104 |
|
if (!hasFlucQ_) return; |