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 |
|
|
62 |
|
InteractionManager* InteractionManager::Instance() { |
63 |
|
if (!_instance) { |
68 |
|
|
69 |
|
void InteractionManager::initialize() { |
70 |
|
|
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 |
– |
|
71 |
|
lj_->setForceField(forceField_); |
72 |
|
gb_->setForceField(forceField_); |
73 |
|
sticky_->setForceField(forceField_); |
234 |
|
} |
235 |
|
} |
236 |
|
|
237 |
< |
void InteractionManager::do_prepair(int *atid1, int *atid2, RealType *rij, RealType *rho_i_at_j, RealType *rho_j_at_i){ |
237 |
> |
void InteractionManager::doPrePair(int *atid1, int *atid2, RealType *rij, RealType *rho_i_at_j, RealType *rho_j_at_i){ |
238 |
|
|
239 |
|
if (!initialized_) initialize(); |
240 |
|
|
258 |
|
return; |
259 |
|
} |
260 |
|
|
261 |
< |
void InteractionManager::do_preforce(int *atid, RealType *rho, RealType *frho, RealType *dfrhodrho){ |
261 |
> |
void InteractionManager::doPreForce(int *atid, RealType *rho, RealType *frho, RealType *dfrhodrho){ |
262 |
|
|
263 |
|
if (!initialized_) initialize(); |
264 |
|
|
281 |
|
return; |
282 |
|
} |
283 |
|
|
284 |
< |
void InteractionManager::do_pair(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){ |
284 |
> |
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){ |
285 |
|
|
286 |
|
if (!initialized_) initialize(); |
287 |
|
|
333 |
|
return; |
334 |
|
} |
335 |
|
|
336 |
< |
void InteractionManager::do_skip_correction(int *atid1, int *atid2, RealType *d, RealType *r, RealType *skippedCharge1, RealType *skippedCharge2, RealType *sw, RealType *electroMult, RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *t1, RealType *t2){ |
336 |
> |
void InteractionManager::doSkipCorrection(int *atid1, int *atid2, RealType *d, RealType *r, RealType *skippedCharge1, RealType *skippedCharge2, RealType *sw, RealType *electroMult, RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1, RealType *eFrame2, RealType *t1, RealType *t2){ |
337 |
|
|
338 |
|
if (!initialized_) initialize(); |
339 |
|
|
379 |
|
return; |
380 |
|
} |
381 |
|
|
382 |
< |
void InteractionManager::do_self_correction(int *atid, RealType *eFrame, RealType *skippedCharge, RealType *pot, RealType *t){ |
382 |
> |
void InteractionManager::doSelfCorrection(int *atid, RealType *eFrame, RealType *skippedCharge, RealType *pot, RealType *t){ |
383 |
|
|
384 |
|
if (!initialized_) initialize(); |
385 |
|
|
407 |
|
return; |
408 |
|
} |
409 |
|
|
410 |
+ |
|
411 |
+ |
RealType InteractionManager::getSuggestedCutoffRadius(int *atid) { |
412 |
+ |
if (!initialized_) initialize(); |
413 |
+ |
|
414 |
+ |
AtomType* atype = typeMap_[*atid]; |
415 |
+ |
|
416 |
+ |
pair<AtomType*, AtomType*> key = make_pair(atype, atype); |
417 |
+ |
set<NonBondedInteraction*>::iterator it; |
418 |
+ |
RealType cutoff = 0.0; |
419 |
+ |
|
420 |
+ |
for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it) |
421 |
+ |
cutoff = max(cutoff, (*it)->getSuggestedCutoffRadius(atype, atype)); |
422 |
+ |
return cutoff; |
423 |
+ |
} |
424 |
+ |
|
425 |
+ |
RealType InteractionManager::getSuggestedCutoffRadius(AtomType* atype) { |
426 |
+ |
if (!initialized_) initialize(); |
427 |
+ |
|
428 |
+ |
pair<AtomType*, AtomType*> key = make_pair(atype, atype); |
429 |
+ |
set<NonBondedInteraction*>::iterator it; |
430 |
+ |
RealType cutoff = 0.0; |
431 |
+ |
|
432 |
+ |
for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it) |
433 |
+ |
cutoff = max(cutoff, (*it)->getSuggestedCutoffRadius(atype, atype)); |
434 |
+ |
return cutoff; |
435 |
+ |
} |
436 |
+ |
|
437 |
|
} //end namespace OpenMD |
438 |
|
|
439 |
|
extern "C" { |
448 |
|
void fortranDoPrePair(int *atid1, int *atid2, RealType *rij, |
449 |
|
RealType *rho_i_at_j, RealType *rho_j_at_i) { |
450 |
|
|
451 |
< |
return OpenMD::InteractionManager::Instance()->do_prepair(atid1, atid2, rij, |
452 |
< |
rho_i_at_j, |
453 |
< |
rho_j_at_i); |
451 |
> |
return OpenMD::InteractionManager::Instance()->doPrePair(atid1, atid2, rij, |
452 |
> |
rho_i_at_j, |
453 |
> |
rho_j_at_i); |
454 |
|
} |
455 |
< |
void fortranDoPreforce(int *atid, RealType *rho, RealType *frho, |
455 |
> |
void fortranDoPreForce(int *atid, RealType *rho, RealType *frho, |
456 |
|
RealType *dfrhodrho) { |
457 |
|
|
458 |
< |
return OpenMD::InteractionManager::Instance()->do_preforce(atid, rho, frho, |
459 |
< |
dfrhodrho); |
458 |
> |
return OpenMD::InteractionManager::Instance()->doPreForce(atid, rho, frho, |
459 |
> |
dfrhodrho); |
460 |
|
} |
461 |
|
|
462 |
|
void fortranDoPair(int *atid1, int *atid2, RealType *d, RealType *r, |
468 |
|
RealType *dfrho1, RealType *dfrho2, RealType *fshift1, |
469 |
|
RealType *fshift2){ |
470 |
|
|
471 |
< |
return OpenMD::InteractionManager::Instance()->do_pair(atid1, atid2, d, r, r2, rcut, |
472 |
< |
sw, vdwMult, electroMult, pot, |
473 |
< |
vpair, f1, eFrame1, eFrame2, |
474 |
< |
A1, A2, t1, t2, rho1, rho2, |
475 |
< |
dfrho1, dfrho2, fshift1, fshift2); |
471 |
> |
return OpenMD::InteractionManager::Instance()->doPair(atid1, atid2, d, r, |
472 |
> |
r2, rcut, sw, |
473 |
> |
vdwMult, electroMult, |
474 |
> |
pot, vpair, f1, |
475 |
> |
eFrame1, eFrame2, |
476 |
> |
A1, A2, t1, t2, rho1, |
477 |
> |
rho2, dfrho1, dfrho2, |
478 |
> |
fshift1, fshift2); |
479 |
|
} |
480 |
< |
|
481 |
< |
void fortranDoSkipCorrection(int *atid1, int *atid2, RealType *d, RealType *r, |
482 |
< |
RealType *skippedCharge1, RealType *skippedCharge2, |
483 |
< |
RealType *sw, RealType *electroMult, RealType *pot, |
480 |
> |
|
481 |
> |
void fortranDoSkipCorrection(int *atid1, int *atid2, RealType *d, |
482 |
> |
RealType *r, RealType *skippedCharge1, |
483 |
> |
RealType *skippedCharge2, RealType *sw, |
484 |
> |
RealType *electroMult, RealType *pot, |
485 |
|
RealType *vpair, RealType *f1, |
486 |
|
RealType *eFrame1, RealType *eFrame2, |
487 |
|
RealType *t1, RealType *t2){ |
488 |
|
|
489 |
< |
return OpenMD::InteractionManager::Instance()->do_skip_correction(atid1, atid2, d, r, |
490 |
< |
skippedCharge1, |
491 |
< |
skippedCharge2, |
492 |
< |
sw, electroMult, pot, |
493 |
< |
vpair, f1, eFrame1, |
494 |
< |
eFrame2, t1, t2); |
489 |
> |
return OpenMD::InteractionManager::Instance()->doSkipCorrection(atid1, |
490 |
> |
atid2, d, |
491 |
> |
r, |
492 |
> |
skippedCharge1, |
493 |
> |
skippedCharge2, |
494 |
> |
sw, electroMult, pot, |
495 |
> |
vpair, f1, eFrame1, |
496 |
> |
eFrame2, t1, t2); |
497 |
|
} |
498 |
< |
|
498 |
> |
|
499 |
|
void fortranDoSelfCorrection(int *atid, RealType *eFrame, RealType *skippedCharge, |
500 |
|
RealType *pot, RealType *t) { |
501 |
|
|
502 |
< |
return OpenMD::InteractionManager::Instance()->do_self_correction(atid, eFrame, |
503 |
< |
skippedCharge, |
504 |
< |
pot, t); |
502 |
> |
return OpenMD::InteractionManager::Instance()->doSelfCorrection(atid, |
503 |
> |
eFrame, |
504 |
> |
skippedCharge, |
505 |
> |
pot, t); |
506 |
|
} |
507 |
< |
RealType fortranGetCutoff() { |
508 |
< |
return OpenMD::InteractionManager::Instance()->getCutoff(); |
507 |
> |
RealType fortranGetCutoff(int *atid) { |
508 |
> |
return OpenMD::InteractionManager::Instance()->getSuggestedCutoffRadius(atid); |
509 |
|
} |
510 |
|
} |