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 |
+ |
SwitchingFunction* InteractionManager::switcher_ = new SwitchingFunction(); |
62 |
|
|
63 |
|
InteractionManager* InteractionManager::Instance() { |
64 |
|
if (!_instance) { |
69 |
|
|
70 |
|
void InteractionManager::initialize() { |
71 |
|
|
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 |
– |
|
72 |
|
lj_->setForceField(forceField_); |
73 |
|
gb_->setForceField(forceField_); |
74 |
|
sticky_->setForceField(forceField_); |
77 |
|
morse_->setForceField(forceField_); |
78 |
|
electrostatic_->setForceField(forceField_); |
79 |
|
|
80 |
+ |
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
81 |
+ |
// Force fields can set options on how to scale van der Waals and electrostatic |
82 |
+ |
// interactions for atoms connected via bonds, bends and torsions |
83 |
+ |
// in this case the topological distance between atoms is: |
84 |
+ |
// 0 = the atom itself |
85 |
+ |
// 1 = bonded together |
86 |
+ |
// 2 = connected via a bend |
87 |
+ |
// 3 = connected via a torsion |
88 |
+ |
|
89 |
+ |
vdwScale_[0] = 0.0; |
90 |
+ |
vdwScale_[1] = fopts.getvdw12scale(); |
91 |
+ |
vdwScale_[2] = fopts.getvdw13scale(); |
92 |
+ |
vdwScale_[3] = fopts.getvdw14scale(); |
93 |
+ |
|
94 |
+ |
electrostaticScale_[0] = 0.0; |
95 |
+ |
electrostaticScale_[1] = fopts.getelectrostatic12scale(); |
96 |
+ |
electrostaticScale_[2] = fopts.getelectrostatic13scale(); |
97 |
+ |
electrostaticScale_[3] = fopts.getelectrostatic14scale(); |
98 |
+ |
|
99 |
|
ForceField::AtomTypeContainer* atomTypes = forceField_->getAtomTypes(); |
100 |
|
ForceField::AtomTypeContainer::MapTypeIterator i1, i2; |
101 |
|
AtomType* atype1; |
301 |
|
return; |
302 |
|
} |
303 |
|
|
304 |
< |
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){ |
304 |
> |
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){ |
305 |
|
|
306 |
|
if (!initialized_) initialize(); |
307 |
|
|
314 |
|
idat.r2 = *r2; |
315 |
|
idat.rcut = *rcut; |
316 |
|
idat.sw = *sw; |
317 |
< |
idat.vdwMult = *vdwMult; |
318 |
< |
idat.electroMult = *electroMult; |
317 |
> |
idat.vdwMult = vdwScale_[*topoDist]; |
318 |
> |
idat.electroMult = electrostaticScale_[*topoDist]; |
319 |
|
idat.pot = *pot; |
320 |
|
idat.vpair = *vpair; |
321 |
|
idat.f1 = Vector3d(f1); |
442 |
|
return cutoff; |
443 |
|
} |
444 |
|
|
445 |
+ |
RealType InteractionManager::getSuggestedCutoffRadius(AtomType* atype) { |
446 |
+ |
if (!initialized_) initialize(); |
447 |
+ |
|
448 |
+ |
pair<AtomType*, AtomType*> key = make_pair(atype, atype); |
449 |
+ |
set<NonBondedInteraction*>::iterator it; |
450 |
+ |
RealType cutoff = 0.0; |
451 |
+ |
|
452 |
+ |
for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it) |
453 |
+ |
cutoff = max(cutoff, (*it)->getSuggestedCutoffRadius(atype, atype)); |
454 |
+ |
return cutoff; |
455 |
+ |
} |
456 |
+ |
|
457 |
+ |
|
458 |
+ |
void InteractionManager::setSwitch(RealType *rIn, RealType *rOut) { |
459 |
+ |
switcher_->setSwitch(*rIn, *rOut); |
460 |
+ |
} |
461 |
+ |
|
462 |
+ |
void InteractionManager::getSwitch(RealType *r2, RealType *sw, RealType *dswdr, RealType *r, |
463 |
+ |
int *in_switching_region) { |
464 |
+ |
bool isr = switcher_->getSwitch(*r2, *sw, *dswdr, *r); |
465 |
+ |
*in_switching_region = (int)isr; |
466 |
+ |
} |
467 |
+ |
|
468 |
|
} //end namespace OpenMD |
469 |
|
|
470 |
|
extern "C" { |
475 |
|
#define fortranDoSkipCorrection FC_FUNC(do_skip_correction, DO_SKIP_CORRECTION) |
476 |
|
#define fortranDoSelfCorrection FC_FUNC(do_self_correction, DO_SELF_CORRECTION) |
477 |
|
#define fortranGetCutoff FC_FUNC(get_cutoff, GET_CUTOFF) |
478 |
+ |
#define fortranSetSwitch FC_FUNC(set_switch, SET_SWITCH) |
479 |
+ |
#define fortranGetSwitch FC_FUNC(get_switch, GET_SWITCH) |
480 |
|
|
481 |
|
void fortranDoPrePair(int *atid1, int *atid2, RealType *rij, |
482 |
|
RealType *rho_i_at_j, RealType *rho_j_at_i) { |
485 |
|
rho_i_at_j, |
486 |
|
rho_j_at_i); |
487 |
|
} |
488 |
< |
void fortranDoPreforce(int *atid, RealType *rho, RealType *frho, |
488 |
> |
void fortranDoPreForce(int *atid, RealType *rho, RealType *frho, |
489 |
|
RealType *dfrhodrho) { |
490 |
|
|
491 |
|
return OpenMD::InteractionManager::Instance()->doPreForce(atid, rho, frho, |
493 |
|
} |
494 |
|
|
495 |
|
void fortranDoPair(int *atid1, int *atid2, RealType *d, RealType *r, |
496 |
< |
RealType *r2, RealType *rcut, RealType *sw, |
497 |
< |
RealType *vdwMult, RealType *electroMult, RealType *pot, |
451 |
< |
RealType *vpair, RealType *f1, RealType *eFrame1, |
496 |
> |
RealType *r2, RealType *rcut, RealType *sw, int *topoDist, |
497 |
> |
RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, |
498 |
|
RealType *eFrame2, RealType *A1, RealType *A2, |
499 |
|
RealType *t1, RealType *t2, RealType *rho1, RealType *rho2, |
500 |
|
RealType *dfrho1, RealType *dfrho2, RealType *fshift1, |
501 |
|
RealType *fshift2){ |
502 |
|
|
503 |
|
return OpenMD::InteractionManager::Instance()->doPair(atid1, atid2, d, r, |
504 |
< |
r2, rcut, sw, |
459 |
< |
vdwMult, electroMult, |
504 |
> |
r2, rcut, sw, topoDist, |
505 |
|
pot, vpair, f1, |
506 |
|
eFrame1, eFrame2, |
507 |
|
A1, A2, t1, t2, rho1, |
538 |
|
RealType fortranGetCutoff(int *atid) { |
539 |
|
return OpenMD::InteractionManager::Instance()->getSuggestedCutoffRadius(atid); |
540 |
|
} |
541 |
+ |
|
542 |
+ |
void fortranGetSwitch(RealType *r2, RealType *sw, RealType *dswdr, RealType *r, |
543 |
+ |
int *in_switching_region) { |
544 |
+ |
|
545 |
+ |
return OpenMD::InteractionManager::Instance()->getSwitch(r2, sw, dswdr, r, |
546 |
+ |
in_switching_region); |
547 |
+ |
} |
548 |
+ |
|
549 |
+ |
void fortranSetSwitch(RealType *rIn, RealType *rOut) { |
550 |
+ |
return OpenMD::InteractionManager::Instance()->setSwitch(rIn, rOut); |
551 |
+ |
} |
552 |
+ |
|
553 |
|
} |