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 1535 by gezelter, Fri Dec 31 18:31:56 2010 UTC vs.
Revision 1536 by gezelter, Wed Jan 5 14:49:05 2011 UTC

# Line 54 | Line 54 | namespace OpenMD {
54    RealType InteractionManager::listRadius_ = 0.0;
55    CutoffMethod InteractionManager::cutoffMethod_ = SHIFTED_FORCE;
56    SwitchingFunctionType InteractionManager::sft_ = cubic;
57 <  RealType InteractionManager::vdwScale_[4] = {0.0, 0.0, 0.0, 0.0};
58 <  RealType InteractionManager::electrostaticScale_[4] = {0.0, 0.0, 0.0, 0.0};
57 >  RealType InteractionManager::vdwScale_[4] = {1.0, 0.0, 0.0, 0.0};
58 >  RealType InteractionManager::electrostaticScale_[4] = {1.0, 0.0, 0.0, 0.0};
59  
60    map<int, AtomType*> InteractionManager::typeMap_;
61    map<pair<AtomType*, AtomType*>, set<NonBondedInteraction*> > InteractionManager::interactions_;
# Line 95 | Line 95 | namespace OpenMD {
95      // Force fields can set options on how to scale van der Waals and electrostatic
96      // interactions for atoms connected via bonds, bends and torsions
97      // in this case the topological distance between atoms is:
98 <    // 0 = the atom itself
98 >    // 0 = topologically unconnected
99      // 1 = bonded together
100      // 2 = connected via a bend
101      // 3 = connected via a torsion
102  
103 <    vdwScale_[0] = 0.0;
103 >    vdwScale_[0] = 1.0;
104      vdwScale_[1] = fopts.getvdw12scale();
105      vdwScale_[2] = fopts.getvdw13scale();
106      vdwScale_[3] = fopts.getvdw14scale();
107  
108 <    electrostaticScale_[0] = 0.0;
108 >    electrostaticScale_[0] = 1.0;
109      electrostaticScale_[1] = fopts.getelectrostatic12scale();
110      electrostaticScale_[2] = fopts.getelectrostatic13scale();
111      electrostaticScale_[3] = fopts.getelectrostatic14scale();    
# Line 307 | Line 307 | namespace OpenMD {
307      setupCutoffs();
308      setupSwitching();
309      setupNeighborlists();
310    notifyFortranSkinThickness(&skinThickness_);
310  
311      int ljsp = cutoffMethod_ == SHIFTED_POTENTIAL ? 1 : 0;
312      int ljsf = cutoffMethod_ == SHIFTED_FORCE ? 1 : 0;
313      notifyFortranCutoffs(&rCut_, &rSwitch_, &ljsp, &ljsf);
314 <
316 <    int isError;
317 <    initFortranFF(&isError);
314 >    notifyFortranSkinThickness(&skinThickness_);
315  
316      initialized_ = true;
317    }
# Line 457 | Line 454 | namespace OpenMD {
454          }          
455        }
456      }
457 +
458 +    switcher_->setSwitchType(sft_);
459 +    switcher_->setSwitch(rSwitch_, rCut_);
460    }
461  
462    /**
# Line 483 | Line 483 | namespace OpenMD {
483      }            
484  
485      listRadius_ = rCut_ + skinThickness_;
486
486    }
487  
488  
# Line 534 | Line 533 | namespace OpenMD {
533      return;    
534    }
535  
536 <  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){
536 >  void InteractionManager::doPair(int *atid1, int *atid2, RealType *d, RealType *r, RealType *r2, RealType *sw, int *topoDist, RealType *A1, RealType *A2, RealType *eFrame1, RealType *eFrame2, RealType *vpair, RealType *pot, RealType  *f1, RealType *t1, RealType *t2, RealType *rho1, RealType *rho2, RealType *dfrho1, RealType *dfrho2, RealType *fshift1, RealType *fshift2){
537      
538      if (!initialized_) initialize();
539      
# Line 545 | Line 544 | namespace OpenMD {
544      idat.d = Vector3d(d);
545      idat.rij = *r;
546      idat.r2 = *r2;
548    idat.rcut = *rcut;
547      idat.sw = *sw;
548      idat.vdwMult = vdwScale_[*topoDist];
549      idat.electroMult = electrostaticScale_[*topoDist];
550 <    idat.pot = *pot;
551 <    idat.vpair = *vpair;
552 <    idat.f1 = Vector3d(f1);
550 >    for (int i = 0; i < 4; i++) {
551 >      idat.vpair[i] = vpair[i];
552 >      idat.pot[i] = pot[i];
553 >    }
554 >    idat.f1 = Vector3d(f1[0], f1[1], f1[2]);
555      idat.eFrame1 = Mat3x3d(eFrame1);
556      idat.eFrame2 = Mat3x3d(eFrame2);
557      idat.A1 = RotMat3x3d(A1);
# Line 571 | Line 571 | namespace OpenMD {
571      for (it = interactions_[key].begin(); it != interactions_[key].end(); ++it)
572        (*it)->calcForce(idat);
573      
574 <    f1[0] = idat.f1.x();
575 <    f1[1] = idat.f1.y();
576 <    f1[2] = idat.f1.z();
577 <    
578 <    t1[0] = idat.t1.x();
579 <    t1[1] = idat.t1.y();
580 <    t1[2] = idat.t1.z();
581 <    
582 <    t2[0] = idat.t2.x();
583 <    t2[1] = idat.t2.y();
584 <    t2[2] = idat.t2.z();
574 >    for (int i = 0; i < 4; i++) {
575 >      vpair[i] = idat.vpair[i];
576 >      pot[i] = idat.pot[i];
577 >    }
578  
579 +    for (int i = 0; i < 3; i++) {
580 +      f1[i] = idat.f1[i];
581 +      t1[i] = idat.t1[i];
582 +      t2[i] = idat.t2[i];
583 +    }
584 +
585      return;    
586    }
587  
# Line 600 | Line 599 | namespace OpenMD {
599      skdat.skippedCharge2 = *skippedCharge2;
600      skdat.sw = *sw;
601      skdat.electroMult = *electroMult;
602 <    skdat.pot = *pot;
603 <    skdat.vpair = *vpair;
602 >    for (int i = 0; i < 4; i++) {
603 >      skdat.vpair[i] = vpair[i];
604 >      skdat.pot[i] = pot[i];
605 >    }
606      skdat.f1 = Vector3d(f1);
607      skdat.eFrame1 = Mat3x3d(eFrame1);
608      skdat.eFrame2 = Mat3x3d(eFrame2);
# Line 617 | Line 618 | namespace OpenMD {
618        }
619      }
620      
621 <    f1[0] = skdat.f1.x();
622 <    f1[1] = skdat.f1.y();
623 <    f1[2] = skdat.f1.z();
624 <    
624 <    t1[0] = skdat.t1.x();
625 <    t1[1] = skdat.t1.y();
626 <    t1[2] = skdat.t1.z();
627 <    
628 <    t2[0] = skdat.t2.x();
629 <    t2[1] = skdat.t2.y();
630 <    t2[2] = skdat.t2.z();
621 >    for (int i = 0; i < 4; i++) {
622 >      vpair[i] = skdat.vpair[i];
623 >      pot[i] = skdat.pot[i];
624 >    }
625  
626 +    for (int i = 0; i < 3; i++) {
627 +      f1[i] = skdat.f1[i];
628 +      t1[i] = skdat.t1[i];
629 +      t2[i] = skdat.t2[i];
630 +    }
631 +
632      return;    
633    }
634  
# Line 641 | Line 641 | namespace OpenMD {
641      scdat.atype = typeMap_[*atid];
642      scdat.eFrame = Mat3x3d(eFrame);
643      scdat.skippedCharge = *skippedCharge;
644 <    scdat.pot = *pot;
644 >    for (int i = 0; i < 4; i++){
645 >      scdat.pot[i] = pot[i];
646 >    }    
647      scdat.t = Vector3d(t);
648  
649      pair<AtomType*, AtomType*> key = make_pair(scdat.atype, scdat.atype);
# Line 652 | Line 654 | namespace OpenMD {
654          dynamic_cast<ElectrostaticInteraction*>(*it)->calcSelfCorrection(scdat);
655        }
656      }
657 <        
657 >      
658      t[0] = scdat.t.x();
659      t[1] = scdat.t.y();
660      t[2] = scdat.t.z();
# Line 687 | Line 689 | namespace OpenMD {
689      return cutoff;    
690    }
691  
690
691  void InteractionManager::setSwitch(RealType *rIn, RealType *rOut) {
692    switcher_->setSwitch(*rIn, *rOut);    
693  }
694
692    void InteractionManager::getSwitch(RealType *r2, RealType *sw, RealType *dswdr, RealType *r,
693                                       int *in_switching_region) {
694 <    bool isr = switcher_->getSwitch(*r2, *sw, *dswdr, *r);    
694 >    bool isr = switcher_->getSwitch( *r2 , *sw, *dswdr, *r);    
695      *in_switching_region = (int)isr;
696    }
697  
# Line 708 | Line 705 | extern "C" {
705   #define fortranDoSkipCorrection FC_FUNC(do_skip_correction, DO_SKIP_CORRECTION)
706   #define fortranDoSelfCorrection FC_FUNC(do_self_correction, DO_SELF_CORRECTION)
707   #define fortranGetCutoff FC_FUNC(get_cutoff, GET_CUTOFF)
711 #define fortranSetSwitch FC_FUNC(set_switch, SET_SWITCH)
708   #define fortranGetSwitch FC_FUNC(get_switch, GET_SWITCH)
709  
710    void fortranDoPrePair(int *atid1, int *atid2, RealType *rij,
# Line 725 | Line 721 | extern "C" {
721                                                                dfrhodrho);    
722    }
723    
724 <  void fortranDoPair(int *atid1, int *atid2, RealType *d, RealType *r,
725 <                     RealType *r2, RealType *rcut, RealType *sw, int *topoDist,
726 <                     RealType *pot, RealType *vpair, RealType *f1, RealType *eFrame1,
727 <                     RealType *eFrame2, RealType *A1, RealType *A2,
728 <                     RealType *t1, RealType *t2, RealType *rho1, RealType *rho2,
729 <                     RealType *dfrho1, RealType *dfrho2, RealType *fshift1,
730 <                     RealType *fshift2){
724 >  void fortranDoPair(int *atid1, int *atid2, RealType *d, RealType *r, RealType *r2,
725 >                     RealType *sw, int *topoDist, RealType *A1, RealType *A2,
726 >                     RealType *eFrame1, RealType *eFrame2,
727 >                     RealType *vpair, RealType *pot,
728 >                     RealType *f1, RealType *t1, RealType *t2,
729 >                     RealType *rho1, RealType *rho2, RealType *dfrho1, RealType *dfrho2,
730 >                     RealType *fshift1, RealType *fshift2){
731      
732 <    return OpenMD::InteractionManager::Instance()->doPair(atid1, atid2, d, r,
733 <                                                          r2, rcut, sw, topoDist,
738 <                                                          pot, vpair, f1,
732 >    return OpenMD::InteractionManager::Instance()->doPair(atid1, atid2, d, r, r2,
733 >                                                          sw, topoDist, A1, A2,
734                                                            eFrame1, eFrame2,
735 <                                                          A1, A2, t1, t2, rho1,
736 <                                                          rho2, dfrho1, dfrho2,
735 >                                                          vpair, pot,
736 >                                                          f1, t1, t2,
737 >                                                          rho1, rho2,
738 >                                                          dfrho1, dfrho2,
739                                                            fshift1, fshift2);
740    }
741    
# Line 773 | Line 770 | extern "C" {
770    }
771  
772    void fortranGetSwitch(RealType *r2, RealType *sw, RealType *dswdr, RealType *r,
773 <                        int *in_switching_region) {
777 <    
773 >                        int *in_switching_region) {    
774      return OpenMD::InteractionManager::Instance()->getSwitch(r2, sw, dswdr, r,
775                                                               in_switching_region);
776 <  }
781 <
782 <  void fortranSetSwitch(RealType *rIn, RealType *rOut) {    
783 <    return OpenMD::InteractionManager::Instance()->setSwitch(rIn, rOut);
784 <  }
785 <  
776 >  }  
777   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines