| 44 |
|
namespace OpenMD { |
| 45 |
|
|
| 46 |
|
bool InteractionManager::initialized_ = false; |
| 47 |
+ |
RealType InteractionManager::rCut_ = -1.0; |
| 48 |
+ |
RealType InteractionManager::rSwitch_ = -1.0; |
| 49 |
|
ForceField* InteractionManager::forceField_ = NULL; |
| 50 |
|
InteractionManager* InteractionManager::_instance = NULL; |
| 51 |
|
map<int, AtomType*> InteractionManager::typeMap_; |
| 52 |
|
map<pair<AtomType*, AtomType*>, set<NonBondedInteraction*> > InteractionManager::interactions_; |
| 53 |
+ |
|
| 54 |
+ |
LJ* InteractionManager::lj_ = new LJ(); |
| 55 |
+ |
GB* InteractionManager::gb_ = new GB(); |
| 56 |
+ |
Sticky* InteractionManager::sticky_ = new Sticky(); |
| 57 |
+ |
Morse* InteractionManager::morse_ = new Morse(); |
| 58 |
+ |
EAM* InteractionManager::eam_ = new EAM(); |
| 59 |
+ |
SC* InteractionManager::sc_ = new SC(); |
| 60 |
+ |
Electrostatic* InteractionManager::electrostatic_ = new Electrostatic(); |
| 61 |
+ |
MAW* InteractionManager::maw_ = new MAW(); |
| 62 |
+ |
SwitchingFunction* InteractionManager::switcher_ = new SwitchingFunction(); |
| 63 |
|
|
| 64 |
|
InteractionManager* InteractionManager::Instance() { |
| 65 |
|
if (!_instance) { |
| 70 |
|
|
| 71 |
|
void InteractionManager::initialize() { |
| 72 |
|
|
| 61 |
– |
lj_ = new LJ(); |
| 62 |
– |
gb_ = new GB(); |
| 63 |
– |
sticky_ = new Sticky(); |
| 64 |
– |
eam_ = new EAM(); |
| 65 |
– |
sc_ = new SC(); |
| 66 |
– |
morse_ = new Morse(); |
| 67 |
– |
electrostatic_ = new Electrostatic(); |
| 68 |
– |
|
| 73 |
|
lj_->setForceField(forceField_); |
| 74 |
|
gb_->setForceField(forceField_); |
| 75 |
|
sticky_->setForceField(forceField_); |
| 77 |
|
sc_->setForceField(forceField_); |
| 78 |
|
morse_->setForceField(forceField_); |
| 79 |
|
electrostatic_->setForceField(forceField_); |
| 80 |
+ |
maw_->setForceField(forceField_); |
| 81 |
|
|
| 82 |
+ |
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
| 83 |
+ |
// Force fields can set options on how to scale van der Waals and electrostatic |
| 84 |
+ |
// interactions for atoms connected via bonds, bends and torsions |
| 85 |
+ |
// in this case the topological distance between atoms is: |
| 86 |
+ |
// 0 = the atom itself |
| 87 |
+ |
// 1 = bonded together |
| 88 |
+ |
// 2 = connected via a bend |
| 89 |
+ |
// 3 = connected via a torsion |
| 90 |
+ |
|
| 91 |
+ |
vdwScale_[0] = 0.0; |
| 92 |
+ |
vdwScale_[1] = fopts.getvdw12scale(); |
| 93 |
+ |
vdwScale_[2] = fopts.getvdw13scale(); |
| 94 |
+ |
vdwScale_[3] = fopts.getvdw14scale(); |
| 95 |
+ |
|
| 96 |
+ |
electrostaticScale_[0] = 0.0; |
| 97 |
+ |
electrostaticScale_[1] = fopts.getelectrostatic12scale(); |
| 98 |
+ |
electrostaticScale_[2] = fopts.getelectrostatic13scale(); |
| 99 |
+ |
electrostaticScale_[3] = fopts.getelectrostatic14scale(); |
| 100 |
+ |
|
| 101 |
|
ForceField::AtomTypeContainer* atomTypes = forceField_->getAtomTypes(); |
| 102 |
|
ForceField::AtomTypeContainer::MapTypeIterator i1, i2; |
| 103 |
|
AtomType* atype1; |
| 233 |
|
interactions_[key].insert(sc_); |
| 234 |
|
metExplicit = true; |
| 235 |
|
} |
| 236 |
+ |
|
| 237 |
+ |
if (nbiType->isMAW()) { |
| 238 |
+ |
if (vdwExplicit) { |
| 239 |
+ |
sprintf( painCave.errMsg, |
| 240 |
+ |
"InteractionManager::initialize found more than one explicit\n" |
| 241 |
+ |
"\tvan der Waals interaction for atom types %s - %s\n", |
| 242 |
+ |
atype1->getName().c_str(), atype2->getName().c_str()); |
| 243 |
+ |
painCave.severity = OPENMD_ERROR; |
| 244 |
+ |
painCave.isFatal = 1; |
| 245 |
+ |
simError(); |
| 246 |
+ |
} |
| 247 |
+ |
// We found an explicit MAW interaction. |
| 248 |
+ |
// override all other vdw entries for this pair of atom types: |
| 249 |
+ |
set<NonBondedInteraction*>::iterator it; |
| 250 |
+ |
for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it) { |
| 251 |
+ |
InteractionFamily ifam = (*it)->getFamily(); |
| 252 |
+ |
if (ifam == VANDERWAALS_FAMILY) interactions_[key].erase(*it); |
| 253 |
+ |
} |
| 254 |
+ |
interactions_[key].insert(maw_); |
| 255 |
+ |
vdwExplicit = true; |
| 256 |
+ |
} |
| 257 |
|
} |
| 258 |
|
} |
| 259 |
|
|
| 324 |
|
return; |
| 325 |
|
} |
| 326 |
|
|
| 327 |
< |
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){ |
| 327 |
> |
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){ |
| 328 |
|
|
| 329 |
|
if (!initialized_) initialize(); |
| 330 |
|
|
| 337 |
|
idat.r2 = *r2; |
| 338 |
|
idat.rcut = *rcut; |
| 339 |
|
idat.sw = *sw; |
| 340 |
< |
idat.vdwMult = *vdwMult; |
| 341 |
< |
idat.electroMult = *electroMult; |
| 340 |
> |
idat.vdwMult = vdwScale_[*topoDist]; |
| 341 |
> |
idat.electroMult = electrostaticScale_[*topoDist]; |
| 342 |
|
idat.pot = *pot; |
| 343 |
|
idat.vpair = *vpair; |
| 344 |
|
idat.f1 = Vector3d(f1); |
| 463 |
|
for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it) |
| 464 |
|
cutoff = max(cutoff, (*it)->getSuggestedCutoffRadius(atype, atype)); |
| 465 |
|
return cutoff; |
| 466 |
+ |
} |
| 467 |
+ |
|
| 468 |
+ |
RealType InteractionManager::getSuggestedCutoffRadius(AtomType* atype) { |
| 469 |
+ |
if (!initialized_) initialize(); |
| 470 |
+ |
|
| 471 |
+ |
pair<AtomType*, AtomType*> key = make_pair(atype, atype); |
| 472 |
+ |
set<NonBondedInteraction*>::iterator it; |
| 473 |
+ |
RealType cutoff = 0.0; |
| 474 |
+ |
|
| 475 |
+ |
for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it) |
| 476 |
+ |
cutoff = max(cutoff, (*it)->getSuggestedCutoffRadius(atype, atype)); |
| 477 |
+ |
return cutoff; |
| 478 |
+ |
} |
| 479 |
+ |
|
| 480 |
+ |
|
| 481 |
+ |
void InteractionManager::setSwitch(RealType *rIn, RealType *rOut) { |
| 482 |
+ |
switcher_->setSwitch(*rIn, *rOut); |
| 483 |
+ |
} |
| 484 |
+ |
|
| 485 |
+ |
void InteractionManager::getSwitch(RealType *r2, RealType *sw, RealType *dswdr, RealType *r, |
| 486 |
+ |
int *in_switching_region) { |
| 487 |
+ |
bool isr = switcher_->getSwitch(*r2, *sw, *dswdr, *r); |
| 488 |
+ |
*in_switching_region = (int)isr; |
| 489 |
|
} |
| 490 |
|
|
| 491 |
|
} //end namespace OpenMD |
| 498 |
|
#define fortranDoSkipCorrection FC_FUNC(do_skip_correction, DO_SKIP_CORRECTION) |
| 499 |
|
#define fortranDoSelfCorrection FC_FUNC(do_self_correction, DO_SELF_CORRECTION) |
| 500 |
|
#define fortranGetCutoff FC_FUNC(get_cutoff, GET_CUTOFF) |
| 501 |
+ |
#define fortranSetSwitch FC_FUNC(set_switch, SET_SWITCH) |
| 502 |
+ |
#define fortranGetSwitch FC_FUNC(get_switch, GET_SWITCH) |
| 503 |
|
|
| 504 |
|
void fortranDoPrePair(int *atid1, int *atid2, RealType *rij, |
| 505 |
|
RealType *rho_i_at_j, RealType *rho_j_at_i) { |
| 508 |
|
rho_i_at_j, |
| 509 |
|
rho_j_at_i); |
| 510 |
|
} |
| 511 |
< |
void fortranDoPreforce(int *atid, RealType *rho, RealType *frho, |
| 511 |
> |
void fortranDoPreForce(int *atid, RealType *rho, RealType *frho, |
| 512 |
|
RealType *dfrhodrho) { |
| 513 |
|
|
| 514 |
|
return OpenMD::InteractionManager::Instance()->doPreForce(atid, rho, frho, |
| 516 |
|
} |
| 517 |
|
|
| 518 |
|
void fortranDoPair(int *atid1, int *atid2, RealType *d, RealType *r, |
| 519 |
< |
RealType *r2, RealType *rcut, RealType *sw, |
| 520 |
< |
RealType *vdwMult, RealType *electroMult, RealType *pot, |
| 451 |
< |
RealType *vpair, RealType *f1, RealType *eFrame1, |
| 519 |
> |
RealType *r2, RealType *rcut, RealType *sw, int *topoDist, |
| 520 |
> |
RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, |
| 521 |
|
RealType *eFrame2, RealType *A1, RealType *A2, |
| 522 |
|
RealType *t1, RealType *t2, RealType *rho1, RealType *rho2, |
| 523 |
|
RealType *dfrho1, RealType *dfrho2, RealType *fshift1, |
| 524 |
|
RealType *fshift2){ |
| 525 |
|
|
| 526 |
|
return OpenMD::InteractionManager::Instance()->doPair(atid1, atid2, d, r, |
| 527 |
< |
r2, rcut, sw, |
| 459 |
< |
vdwMult, electroMult, |
| 527 |
> |
r2, rcut, sw, topoDist, |
| 528 |
|
pot, vpair, f1, |
| 529 |
|
eFrame1, eFrame2, |
| 530 |
|
A1, A2, t1, t2, rho1, |
| 561 |
|
RealType fortranGetCutoff(int *atid) { |
| 562 |
|
return OpenMD::InteractionManager::Instance()->getSuggestedCutoffRadius(atid); |
| 563 |
|
} |
| 564 |
+ |
|
| 565 |
+ |
void fortranGetSwitch(RealType *r2, RealType *sw, RealType *dswdr, RealType *r, |
| 566 |
+ |
int *in_switching_region) { |
| 567 |
+ |
|
| 568 |
+ |
return OpenMD::InteractionManager::Instance()->getSwitch(r2, sw, dswdr, r, |
| 569 |
+ |
in_switching_region); |
| 570 |
+ |
} |
| 571 |
+ |
|
| 572 |
+ |
void fortranSetSwitch(RealType *rIn, RealType *rOut) { |
| 573 |
+ |
return OpenMD::InteractionManager::Instance()->setSwitch(rIn, rOut); |
| 574 |
+ |
} |
| 575 |
+ |
|
| 576 |
|
} |