--- branches/development/src/nonbonded/InteractionManager.cpp 2010/12/17 20:11:05 1528 +++ branches/development/src/nonbonded/InteractionManager.cpp 2010/12/29 19:59:21 1532 @@ -44,6 +44,8 @@ namespace OpenMD { namespace OpenMD { bool InteractionManager::initialized_ = false; + RealType InteractionManager::rCut_ = -1.0; + RealType InteractionManager::rSwitch_ = -1.0; ForceField* InteractionManager::forceField_ = NULL; InteractionManager* InteractionManager::_instance = NULL; map InteractionManager::typeMap_; @@ -56,6 +58,8 @@ namespace OpenMD { EAM* InteractionManager::eam_ = new EAM(); SC* InteractionManager::sc_ = new SC(); Electrostatic* InteractionManager::electrostatic_ = new Electrostatic(); + MAW* InteractionManager::maw_ = new MAW(); + SwitchingFunction* InteractionManager::switcher_ = new SwitchingFunction(); InteractionManager* InteractionManager::Instance() { if (!_instance) { @@ -73,7 +77,27 @@ namespace OpenMD { sc_->setForceField(forceField_); morse_->setForceField(forceField_); electrostatic_->setForceField(forceField_); + maw_->setForceField(forceField_); + ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); + // Force fields can set options on how to scale van der Waals and electrostatic + // interactions for atoms connected via bonds, bends and torsions + // in this case the topological distance between atoms is: + // 0 = the atom itself + // 1 = bonded together + // 2 = connected via a bend + // 3 = connected via a torsion + + vdwScale_[0] = 0.0; + vdwScale_[1] = fopts.getvdw12scale(); + vdwScale_[2] = fopts.getvdw13scale(); + vdwScale_[3] = fopts.getvdw14scale(); + + electrostaticScale_[0] = 0.0; + electrostaticScale_[1] = fopts.getelectrostatic12scale(); + electrostaticScale_[2] = fopts.getelectrostatic13scale(); + electrostaticScale_[3] = fopts.getelectrostatic14scale(); + ForceField::AtomTypeContainer* atomTypes = forceField_->getAtomTypes(); ForceField::AtomTypeContainer::MapTypeIterator i1, i2; AtomType* atype1; @@ -209,6 +233,27 @@ namespace OpenMD { interactions_[key].insert(sc_); metExplicit = true; } + + if (nbiType->isMAW()) { + 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 MAW 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(maw_); + vdwExplicit = true; + } } } @@ -279,7 +324,7 @@ namespace OpenMD { return; } - void InteractionManager::doPair(int *atid1, int *atid2, RealType *d, RealType *r, RealType *r2, RealType *rcut, RealType *sw, RealType *vdwMult,RealType *electroMult, RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *A1, RealType *A2, RealType *t1, RealType *t2, RealType *rho1, RealType *rho2, RealType *dfrho1, RealType *dfrho2, RealType *fshift1, RealType *fshift2){ + void InteractionManager::doPair(int *atid1, int *atid2, RealType *d, RealType *r, RealType *r2, RealType *rcut, RealType *sw, int *topoDist, RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *A1, RealType *A2, RealType *t1, RealType *t2, RealType *rho1, RealType *rho2, RealType *dfrho1, RealType *dfrho2, RealType *fshift1, RealType *fshift2){ if (!initialized_) initialize(); @@ -292,8 +337,8 @@ namespace OpenMD { idat.r2 = *r2; idat.rcut = *rcut; idat.sw = *sw; - idat.vdwMult = *vdwMult; - idat.electroMult = *electroMult; + idat.vdwMult = vdwScale_[*topoDist]; + idat.electroMult = electrostaticScale_[*topoDist]; idat.pot = *pot; idat.vpair = *vpair; idat.f1 = Vector3d(f1); @@ -432,6 +477,17 @@ namespace OpenMD { return cutoff; } + + void InteractionManager::setSwitch(RealType *rIn, RealType *rOut) { + switcher_->setSwitch(*rIn, *rOut); + } + + void InteractionManager::getSwitch(RealType *r2, RealType *sw, RealType *dswdr, RealType *r, + int *in_switching_region) { + bool isr = switcher_->getSwitch(*r2, *sw, *dswdr, *r); + *in_switching_region = (int)isr; + } + } //end namespace OpenMD extern "C" { @@ -442,6 +498,8 @@ extern "C" { #define fortranDoSkipCorrection FC_FUNC(do_skip_correction, DO_SKIP_CORRECTION) #define fortranDoSelfCorrection FC_FUNC(do_self_correction, DO_SELF_CORRECTION) #define fortranGetCutoff FC_FUNC(get_cutoff, GET_CUTOFF) +#define fortranSetSwitch FC_FUNC(set_switch, SET_SWITCH) +#define fortranGetSwitch FC_FUNC(get_switch, GET_SWITCH) void fortranDoPrePair(int *atid1, int *atid2, RealType *rij, RealType *rho_i_at_j, RealType *rho_j_at_i) { @@ -458,17 +516,15 @@ extern "C" { } void fortranDoPair(int *atid1, int *atid2, RealType *d, RealType *r, - RealType *r2, RealType *rcut, RealType *sw, - RealType *vdwMult, RealType *electroMult, RealType *pot, - RealType *vpair, RealType *f1, RealType *eFrame1, + RealType *r2, RealType *rcut, RealType *sw, int *topoDist, + RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *A1, RealType *A2, RealType *t1, RealType *t2, RealType *rho1, RealType *rho2, RealType *dfrho1, RealType *dfrho2, RealType *fshift1, RealType *fshift2){ return OpenMD::InteractionManager::Instance()->doPair(atid1, atid2, d, r, - r2, rcut, sw, - vdwMult, electroMult, + r2, rcut, sw, topoDist, pot, vpair, f1, eFrame1, eFrame2, A1, A2, t1, t2, rho1, @@ -505,4 +561,16 @@ extern "C" { RealType fortranGetCutoff(int *atid) { return OpenMD::InteractionManager::Instance()->getSuggestedCutoffRadius(atid); } + + void fortranGetSwitch(RealType *r2, RealType *sw, RealType *dswdr, RealType *r, + int *in_switching_region) { + + return OpenMD::InteractionManager::Instance()->getSwitch(r2, sw, dswdr, r, + in_switching_region); + } + + void fortranSetSwitch(RealType *rIn, RealType *rOut) { + return OpenMD::InteractionManager::Instance()->setSwitch(rIn, rOut); + } + }