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 1528 by gezelter, Fri Dec 17 20:11:05 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_;
# Line 56 | Line 58 | namespace OpenMD {
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 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 279 | Line 301 | namespace OpenMD {
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      
# 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 432 | Line 454 | namespace OpenMD {
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 442 | 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) {
# Line 458 | Line 493 | extern "C" {
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,
463 <                     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,
471 <                                                          vdwMult, electroMult,
504 >                                                          r2, rcut, sw, topoDist,
505                                                            pot, vpair, f1,
506                                                            eFrame1, eFrame2,
507                                                            A1, A2, t1, t2, rho1,
# Line 505 | Line 538 | extern "C" {
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