--- branches/development/src/nonbonded/MAW.cpp 2011/05/27 16:45:44 1571 +++ trunk/src/nonbonded/MAW.cpp 2013/06/16 15:15:42 1879 @@ -35,8 +35,9 @@ * * [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). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ #include @@ -50,53 +51,43 @@ namespace OpenMD { namespace OpenMD { - MAW::MAW() : name_("MAW"), initialized_(false), forceField_(NULL), - shiftedPot_(false), shiftedFrc_(false) {} + MAW::MAW() : name_("MAW"), initialized_(false), forceField_(NULL) {} void MAW::initialize() { ForceField::NonBondedInteractionTypeContainer* nbiTypes = forceField_->getNonBondedInteractionTypes(); ForceField::NonBondedInteractionTypeContainer::MapTypeIterator j; NonBondedInteractionType* nbt; + ForceField::NonBondedInteractionTypeContainer::KeyType keys; for (nbt = nbiTypes->beginType(j); nbt != NULL; nbt = nbiTypes->nextType(j)) { if (nbt->isMAW()) { - pair atypes = nbt->getAtomTypes(); - - GenericData* data = nbt->getPropertyByName("MAW"); - if (data == NULL) { - sprintf( painCave.errMsg, "MAW::initialize could not find\n" - "\tMAW parameters for %s - %s interaction.\n", - atypes.first->getName().c_str(), - atypes.second->getName().c_str()); - painCave.severity = OPENMD_ERROR; - painCave.isFatal = 1; - simError(); - } - - MAWData* mawData = dynamic_cast(data); - if (mawData == NULL) { + keys = nbiTypes->getKeys(j); + AtomType* at1 = forceField_->getAtomType(keys[0]); + AtomType* at2 = forceField_->getAtomType(keys[1]); + + MAWInteractionType* mit = dynamic_cast(nbt); + + if (mit == NULL) { sprintf( painCave.errMsg, - "MAW::initialize could not convert GenericData to\n" - "\tMAWData for %s - %s interaction.\n", - atypes.first->getName().c_str(), - atypes.second->getName().c_str()); + "MAW::initialize could not convert NonBondedInteractionType\n" + "\tto MAWInteractionType for %s - %s interaction.\n", + at1->getName().c_str(), + at2->getName().c_str()); painCave.severity = OPENMD_ERROR; painCave.isFatal = 1; simError(); } - MAWParam mawParam = mawData->getData(); - - RealType De = mawParam.De; - RealType beta = mawParam.beta; - RealType Re = mawParam.Re; - RealType ca1 = mawParam.ca1; - RealType cb1 = mawParam.cb1; + RealType De = mit->getD(); + RealType beta = mit->getBeta(); + RealType Re = mit->getR(); + RealType ca1 = mit->getCA1(); + RealType cb1 = mit->getCB1(); - addExplicitInteraction(atypes.first, atypes.second, + addExplicitInteraction(at1, at2, De, beta, Re, ca1, cb1); } } @@ -172,18 +163,18 @@ namespace OpenMD { myPot = D_e * (expfnc2 - 2.0 * expfnc); myDeriv = 2.0 * D_e * beta * (expfnc - expfnc2); - if (MAW::shiftedPot_ || MAW::shiftedFrc_) { + if (idat.shiftedPot || idat.shiftedForce) { exptC = -beta*( *(idat.rcut) - R_e); expfncC = exp(exptC); expfnc2C = expfncC*expfncC; } - if (MAW::shiftedPot_) { + if (idat.shiftedPot) { myPotC = D_e * (expfnc2C - 2.0 * expfncC); myDerivC = 0.0; - } else if (MAW::shiftedFrc_) { + } else if (idat.shiftedForce) { myPotC = D_e * (expfnc2C - 2.0 * expfncC); - myDerivC = 2.0 * D_e * beta * (expfnc2C - expfnc2C); + myDerivC = 2.0 * D_e * beta * (expfncC - expfnc2C); myPotC += myDerivC * ( *(idat.rij) - *(idat.rcut) ); } else { myPotC = 0.0; @@ -194,7 +185,6 @@ namespace OpenMD { RealType y = r.y(); RealType z = r.z(); RealType x2 = x * x; - RealType y2 = y * y; RealType z2 = z * z; RealType r3 = *(idat.r2) * *(idat.rij) ; @@ -221,7 +211,7 @@ namespace OpenMD { RealType pot_temp = *(idat.vdwMult) * Vmorse * Vang; *(idat.vpair) += pot_temp; - idat.pot[VANDERWAALS_FAMILY] += *(idat.sw) * pot_temp; + (*(idat.pot))[VANDERWAALS_FAMILY] += *(idat.sw) * pot_temp; Vector3d dVmorsedr = (myDeriv - myDerivC) * Vector3d(x, y, z) / *(idat.rij) ;