--- branches/development/src/nonbonded/InteractionManager.cpp 2011/06/08 16:05:07 1576 +++ branches/development/src/nonbonded/InteractionManager.cpp 2012/05/18 21:44:02 1710 @@ -36,7 +36,8 @@ * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). - * [4] Vardeman & Gezelter, in progress (2009). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ #include "nonbonded/InteractionManager.hpp" @@ -51,6 +52,7 @@ namespace OpenMD { gb_ = new GB(); sticky_ = new Sticky(); morse_ = new Morse(); + repulsivePower_ = new RepulsivePower(); eam_ = new EAM(); sc_ = new SC(); electrostatic_ = new Electrostatic(); @@ -67,8 +69,10 @@ namespace OpenMD { eam_->setForceField(forceField_); sc_->setForceField(forceField_); morse_->setForceField(forceField_); + electrostatic_->setSimInfo(info_); electrostatic_->setForceField(forceField_); maw_->setForceField(forceField_); + repulsivePower_->setForceField(forceField_); ForceField::AtomTypeContainer* atomTypes = forceField_->getAtomTypes(); ForceField::AtomTypeContainer::MapTypeIterator i1, i2; @@ -81,14 +85,13 @@ namespace OpenMD { atype1 = atomTypes->nextType(i1)) { // add it to the map: - AtomTypeProperties atp = atype1->getATP(); pair::iterator,bool> ret; - ret = typeMap_.insert( pair(atp.ident, atype1) ); + ret = typeMap_.insert( pair(atype1->getIdent(), atype1) ); if (ret.second == false) { sprintf( painCave.errMsg, "InteractionManager already had a previous entry with ident %d\n", - atp.ident); + atype1->getIdent()); painCave.severity = OPENMD_INFO; painCave.isFatal = 0; simError(); @@ -175,9 +178,33 @@ namespace OpenMD { if (ifam == VANDERWAALS_FAMILY) interactions_[key].erase(*it); } interactions_[key].insert(morse_); + vdwExplicit = true; + } + + if (nbiType->isRepulsivePower()) { + if (vdwExplicit) { + sprintf( painCave.errMsg, + "InteractionManager::initialize found more than one " + "explicit \n" + "\tvan der Waals interaction for atom types %s - %s\n", + atype1->getName().c_str(), atype2->getName().c_str()); + painCave.severity = OPENMD_ERROR; + painCave.isFatal = 1; + simError(); + } + // We found an explicit RepulsivePower interaction. + // override all other vdw entries for this pair of atom types: + set::iterator it; + for (it = interactions_[key].begin(); + it != interactions_[key].end(); ++it) { + InteractionFamily ifam = (*it)->getFamily(); + if (ifam == VANDERWAALS_FAMILY) interactions_[key].erase(*it); + } + interactions_[key].insert(repulsivePower_); vdwExplicit = true; } + if (nbiType->isEAM()) { // We found an explicit EAM interaction. // override all other metallic entries for this pair of atom types: @@ -241,24 +268,26 @@ namespace OpenMD { } - // make sure every pair of atom types in this simulation has a - // non-bonded interaction: + // Make sure every pair of atom types in this simulation has a + // non-bonded interaction. If not, just inform the user. set simTypes = info_->getSimulatedAtomTypes(); set::iterator it, jt; + for (it = simTypes.begin(); it != simTypes.end(); ++it) { atype1 = (*it); - for (jt = simTypes.begin(); jt != simTypes.end(); ++jt) { + for (jt = it; jt != simTypes.end(); ++jt) { atype2 = (*jt); key = make_pair(atype1, atype2); if (interactions_[key].size() == 0) { sprintf( painCave.errMsg, - "InteractionManager unable to find an appropriate non-bonded\n" - "\tinteraction for atom types %s - %s\n", + "InteractionManager could not find a matching non-bonded\n" + "\tinteraction for atom types %s - %s\n" + "\tProceeding without this interaction.\n", atype1->getName().c_str(), atype2->getName().c_str()); painCave.severity = OPENMD_INFO; - painCave.isFatal = 1; + painCave.isFatal = 0; simError(); } } @@ -266,11 +295,24 @@ namespace OpenMD { initialized_ = true; } + + void InteractionManager::setCutoffRadius(RealType rcut) { + + electrostatic_->setCutoffRadius(rcut); + eam_->setCutoffRadius(rcut); + } + + void InteractionManager::setSwitchingRadius(RealType rswitch) { + electrostatic_->setSwitchingRadius(rswitch); + } void InteractionManager::doPrePair(InteractionData idat){ if (!initialized_) initialize(); + // excluded interaction, so just return + if (idat.excluded) return; + set::iterator it; for (it = interactions_[ idat.atypes ].begin(); @@ -302,26 +344,17 @@ namespace OpenMD { void InteractionManager::doPair(InteractionData idat){ if (!initialized_) initialize(); - + set::iterator it; for (it = interactions_[ idat.atypes ].begin(); - it != interactions_[ idat.atypes ].end(); ++it) - (*it)->calcForce(idat); - - return; - } + it != interactions_[ idat.atypes ].end(); ++it) { - void InteractionManager::doSkipCorrection(InteractionData idat){ + // electrostatics still has to worry about indirect + // contributions from excluded pairs of atoms: - if (!initialized_) initialize(); - - set::iterator it; - - for (it = interactions_[ idat.atypes ].begin(); - it != interactions_[ idat.atypes ].end(); ++it){ - if ((*it)->getFamily() == ELECTROSTATIC_FAMILY) { - dynamic_cast(*it)->calcSkipCorrection(idat); + if (!idat.excluded || (*it)->getFamily() == ELECTROSTATIC_FAMILY) { + (*it)->calcForce(idat); } }