ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/nonbonded/InteractionManager.cpp
(Generate patch)

Comparing branches/development/src/nonbonded/InteractionManager.cpp (file contents):
Revision 1504 by gezelter, Sat Oct 2 20:41:53 2010 UTC vs.
Revision 1530 by gezelter, Tue Dec 28 21:47:55 2010 UTC

# Line 44 | Line 44 | namespace OpenMD {
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) {
# Line 58 | Line 69 | namespace OpenMD {
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_);
# Line 73 | Line 76 | namespace OpenMD {
76      sc_->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;
# Line 232 | Line 254 | namespace OpenMD {
254      }
255    }
256    
257 <  void InteractionManager::do_prepair(int *atid1, int *atid2, RealType *rij, RealType *rho_i_at_j, RealType *rho_j_at_i){
257 >  void InteractionManager::doPrePair(int *atid1, int *atid2, RealType *rij, RealType *rho_i_at_j, RealType *rho_j_at_i){
258      
259      if (!initialized_) initialize();
260            
# Line 256 | Line 278 | namespace OpenMD {
278      return;    
279    }
280    
281 <  void InteractionManager::do_preforce(int *atid, RealType *rho, RealType *frho, RealType *dfrhodrho){
281 >  void InteractionManager::doPreForce(int *atid, RealType *rho, RealType *frho, RealType *dfrhodrho){
282  
283      if (!initialized_) initialize();
284            
# Line 279 | Line 301 | namespace OpenMD {
301      return;    
302    }
303  
304 <  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){
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      
# Line 292 | Line 314 | namespace OpenMD {
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);
# Line 331 | Line 353 | namespace OpenMD {
353      return;    
354    }
355  
356 <  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){
356 >  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){
357  
358      if (!initialized_) initialize();
359      
# Line 377 | Line 399 | namespace OpenMD {
399      return;    
400    }
401  
402 <  void InteractionManager::do_self_correction(int *atid, RealType *eFrame, RealType *skippedCharge, RealType *pot, RealType *t){
402 >  void InteractionManager::doSelfCorrection(int *atid, RealType *eFrame, RealType *skippedCharge, RealType *pot, RealType *t){
403  
404      if (!initialized_) initialize();
405      
# Line 405 | Line 427 | namespace OpenMD {
427      return;    
428    }
429  
430 +
431 +  RealType InteractionManager::getSuggestedCutoffRadius(int *atid) {
432 +    if (!initialized_) initialize();
433 +    
434 +    AtomType* atype = typeMap_[*atid];
435 +
436 +    pair<AtomType*, AtomType*> key = make_pair(atype, atype);
437 +    set<NonBondedInteraction*>::iterator it;
438 +    RealType cutoff = 0.0;
439 +    
440 +    for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it)
441 +      cutoff = max(cutoff, (*it)->getSuggestedCutoffRadius(atype, atype));  
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" {
# Line 415 | Line 475 | 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) {
483              
484 <    return OpenMD::InteractionManager::Instance()->do_prepair(atid1, atid2, rij,
485 <                                                              rho_i_at_j,  
486 <                                                              rho_j_at_i);
484 >    return OpenMD::InteractionManager::Instance()->doPrePair(atid1, atid2, rij,
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()->do_preforce(atid, rho, frho,
492 <                                                               dfrhodrho);    
491 >    return OpenMD::InteractionManager::Instance()->doPreForce(atid, rho, frho,
492 >                                                              dfrhodrho);    
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,
436 <                     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()->do_pair(atid1, atid2, d, r, r2, rcut,
504 <                                                           sw, vdwMult, electroMult, pot,
505 <                                                           vpair, f1, eFrame1, eFrame2,
506 <                                                           A1, A2, t1, t2, rho1, rho2,
507 <                                                           dfrho1, dfrho2, fshift1, fshift2);
503 >    return OpenMD::InteractionManager::Instance()->doPair(atid1, atid2, d, r,
504 >                                                          r2, rcut, sw, topoDist,
505 >                                                          pot, vpair, f1,
506 >                                                          eFrame1, eFrame2,
507 >                                                          A1, A2, t1, t2, rho1,
508 >                                                          rho2, dfrho1, dfrho2,
509 >                                                          fshift1, fshift2);
510    }
511 <
512 <  void fortranDoSkipCorrection(int *atid1, int *atid2, RealType *d, RealType *r,
513 <                               RealType *skippedCharge1, RealType *skippedCharge2,
514 <                               RealType *sw, RealType *electroMult, RealType *pot,
511 >  
512 >  void fortranDoSkipCorrection(int *atid1, int *atid2, RealType *d,
513 >                               RealType *r, RealType *skippedCharge1,
514 >                               RealType *skippedCharge2, RealType *sw,
515 >                               RealType *electroMult, RealType *pot,
516                                 RealType *vpair, RealType *f1,
517                                 RealType *eFrame1, RealType *eFrame2,
518                                 RealType *t1, RealType *t2){
519      
520 <    return OpenMD::InteractionManager::Instance()->do_skip_correction(atid1, atid2, d, r,
521 <                                                                      skippedCharge1,
522 <                                                                      skippedCharge2,
523 <                                                                      sw, electroMult, pot,
524 <                                                                      vpair, f1, eFrame1,
525 <                                                                      eFrame2, t1, t2);
520 >    return OpenMD::InteractionManager::Instance()->doSkipCorrection(atid1,
521 >                                                                    atid2, d,
522 >                                                                    r,
523 >                                                                    skippedCharge1,
524 >                                                                    skippedCharge2,
525 >                                                                    sw, electroMult, pot,
526 >                                                                    vpair, f1, eFrame1,
527 >                                                                    eFrame2, t1, t2);
528    }
529 <
529 >  
530    void fortranDoSelfCorrection(int *atid, RealType *eFrame, RealType *skippedCharge,
531                                 RealType *pot, RealType *t) {
532      
533 <    return OpenMD::InteractionManager::Instance()->do_self_correction(atid, eFrame,
534 <                                                                      skippedCharge,
535 <                                                                      pot, t);
533 >    return OpenMD::InteractionManager::Instance()->doSelfCorrection(atid,
534 >                                                                    eFrame,
535 >                                                                    skippedCharge,
536 >                                                                    pot, t);
537    }
538 <  RealType fortranGetCutoff() {
539 <    return OpenMD::InteractionManager::Instance()->getCutoff();
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines