--- branches/development/src/integrators/FluctuatingChargeNVT.cpp 2012/05/23 01:26:15 1716 +++ branches/development/src/flucq/FluctuatingChargeNVT.cpp 2012/06/05 17:50:53 1735 @@ -52,11 +52,13 @@ namespace OpenMD { thermo(info), currentSnapshot_(info->getSnapshotManager()->getCurrentSnapshot()) { + if (info_->usesFluctuatingCharges()) { if (info_->getNFluctuatingCharges() > 0) { hasFlucQ_ = true; Globals* simParams = info_->getSimParams(); + FluctuatingChargeParameters* fqParams = simParams->getFluctuatingChargeParameters(); if (simParams->haveDt()) { dt_ = simParams->getDt(); @@ -73,19 +75,19 @@ namespace OpenMD { currentSnapshot_->setIntegralOfChiElectronicDt(0.0); } - if (!simParams->haveFlucQTargetTemp()) { + if (!fqParams->haveTargetTemp()) { sprintf(painCave.errMsg, "You can't use the FluctuatingChargeNVT " "propagator without a flucQ.targetTemp!\n"); painCave.isFatal = 1; painCave.severity = OPENMD_ERROR; simError(); } else { - targetTemp_ = simParams->getFlucQTargetTemp(); + targetTemp_ = fqParams->getTargetTemp(); } // We must set tauThermostat. - if (!simParams->haveFlucQtauThermostat()) { + if (!fqParams->haveTauThermostat()) { sprintf(painCave.errMsg, "If you use the FluctuatingChargeNVT\n" "\tpropagator, you must set flucQ.tauThermostat .\n"); @@ -93,7 +95,7 @@ namespace OpenMD { painCave.isFatal = 1; simError(); } else { - tauThermostat_ = simParams->getFlucQtauThermostat(); + tauThermostat_ = fqParams->getTauThermostat(); } updateSizes(); } @@ -135,7 +137,6 @@ namespace OpenMD { RealType integralOfChidt = currentSnapshot_->getIntegralOfChiElectronicDt(); RealType instTemp = thermo.getElectronicTemperature(); - cerr << "why are we here?\n"; for (mol = info_->beginMolecule(i); mol != NULL; mol = info_->nextMolecule(i)) { @@ -147,11 +148,18 @@ namespace OpenMD { cfrc = atom->getFlucQFrc(); cmass = atom->getChargeMass(); - // velocity half step - cvel += dt2_ *PhysicalConstants::energyConvert/cmass*cfrc - dt2_*chi*cvel; + cerr << atom->getType() << "\n"; + cerr << "Before\n"; + cerr << "cvel: " << cvel << "\tcpos: " << cpos << "\tcfrc: " << cfrc << "\tcmass: " << cmass << "\n"; + + // velocity half step + cvel += dt2_ * cfrc / cmass - dt2_*chi*cvel; // position whole step cpos += dt_ * cvel; - + + cerr << "After\n"; + cerr << "cvel: " << cvel << "\tcpos: " << cpos << "\n\n"; + atom->setFlucQVel(cvel); atom->setFlucQPos(cpos); } @@ -161,6 +169,7 @@ namespace OpenMD { (tauThermostat_ * tauThermostat_); integralOfChidt += chi * dt2_; + cerr << "Move A instTemp: " << instTemp << "\n"; currentSnapshot_->setChiElectronic(chi); currentSnapshot_->setIntegralOfChiElectronicDt(integralOfChidt); @@ -201,7 +210,7 @@ namespace OpenMD { for(int k = 0; k < maxIterNum_; k++) { index = 0; instTemp = thermo.getElectronicTemperature(); - + cerr << "MoveB instTemp: " << instTemp << "\n"; // evolve chi another half step using the temperature at t + dt/2 prevChi = chi; chi = oldChi + dt2_ * (instTemp / targetTemp_ - 1.0) / @@ -217,7 +226,7 @@ namespace OpenMD { cmass = atom->getChargeMass(); // velocity half step - cvel = oldVel_[index] + dt2_/cmass*PhysicalConstants::energyConvert * cfrc - dt2_*chi*oldVel_[index]; + cvel = oldVel_[index] + dt2_ * cfrc / cmass - dt2_*chi*oldVel_[index]; atom->setFlucQVel(cvel); ++index;