--- trunk/src/flucq/FluctuatingChargePropagator.cpp 2013/07/24 20:00:51 1913 +++ trunk/src/flucq/FluctuatingChargePropagator.cpp 2014/04/14 18:32:51 1981 @@ -60,12 +60,9 @@ namespace OpenMD { Globals* simParams = info_->getSimParams(); fqParams_ = simParams->getFluctuatingChargeParameters(); - fqConstraints_ = new FluctuatingChargeConstraints(info_); - fqConstraints_->setConstrainRegions( fqParams_->getConstrainRegions() ); } FluctuatingChargePropagator::~FluctuatingChargePropagator() { - if (fqConstraints_ != NULL) delete fqConstraints_; } void FluctuatingChargePropagator::setForceManager(ForceManager* forceMan) { @@ -76,6 +73,8 @@ namespace OpenMD { if (info_->usesFluctuatingCharges()) { if (info_->getNFluctuatingCharges() > 0) { hasFlucQ_ = true; + fqConstraints_ = new FluctuatingChargeConstraints(info_); + fqConstraints_->setConstrainRegions(fqParams_->getConstrainRegions()); } } @@ -89,14 +88,17 @@ namespace OpenMD { Molecule* mol; Atom* atom; - for (mol = info_->beginMolecule(i); mol != NULL; - mol = info_->nextMolecule(i)) { - for (atom = mol->beginFluctuatingCharge(j); atom != NULL; - atom = mol->nextFluctuatingCharge(j)) { - atom->setFlucQPos(0.0); - atom->setFlucQVel(0.0); - } - } + // For single-minima flucq, this ensures a net neutral system, but + // for multiple minima, this is no longer the right thing to do: + // + // for (mol = info_->beginMolecule(i); mol != NULL; + // mol = info_->nextMolecule(i)) { + // for (atom = mol->beginFluctuatingCharge(j); atom != NULL; + // atom = mol->nextFluctuatingCharge(j)) { + // atom->setFlucQPos(0.0); + // atom->setFlucQVel(0.0); + // } + // } FluctuatingChargeObjectiveFunction flucQobjf(info_, forceMan_, fqConstraints_); @@ -112,6 +114,7 @@ namespace OpenMD { DumpStatusFunction dsf(info_); // we want a dump file written // every iteration minim->minimize(problem, endCriteria); + cerr << "back from minim\n"; initialized_ = true; }