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

Comparing branches/development/src/brains/ForceManager.cpp (file contents):
Revision 1808 by gezelter, Mon Oct 22 20:42:10 2012 UTC vs.
Revision 1874 by gezelter, Wed May 15 15:09:35 2013 UTC

# Line 35 | Line 35
35   *                                                                      
36   * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37   * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 < * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39   * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40   * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
# Line 67 | Line 67 | namespace OpenMD {
67   using namespace std;
68   namespace OpenMD {
69    
70 <  ForceManager::ForceManager(SimInfo * info) : info_(info) {
70 >  ForceManager::ForceManager(SimInfo * info) : info_(info), switcher_(NULL),
71 >                                               initialized_(false) {
72      forceField_ = info_->getForceField();
73      interactionMan_ = new InteractionManager();
74      fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_);
75 +    thermo = new Thermo(info_);
76    }
77  
78 +  ForceManager::~ForceManager() {
79 +    perturbations_.clear();
80 +    
81 +    delete switcher_;
82 +    delete interactionMan_;
83 +    delete fDecomp_;
84 +    delete thermo;
85 +  }
86 +  
87    /**
88     * setupCutoffs
89     *
# Line 117 | Line 128 | namespace OpenMD {
128      else
129        mdFileVersion = 0;
130    
131 +    // We need the list of simulated atom types to figure out cutoffs
132 +    // as well as long range corrections.
133 +
134 +    set<AtomType*>::iterator i;
135 +    set<AtomType*> atomTypes_;
136 +    atomTypes_ = info_->getSimulatedAtomTypes();
137 +
138      if (simParams_->haveCutoffRadius()) {
139        rCut_ = simParams_->getCutoffRadius();
140      } else {      
# Line 131 | Line 149 | namespace OpenMD {
149          rCut_ = 12.0;
150        } else {
151          RealType thisCut;
152 <        set<AtomType*>::iterator i;
135 <        set<AtomType*> atomTypes;
136 <        atomTypes = info_->getSimulatedAtomTypes();        
137 <        for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
152 >        for (i = atomTypes_.begin(); i != atomTypes_.end(); ++i) {
153            thisCut = interactionMan_->getSuggestedCutoffRadius((*i));
154            rCut_ = max(thisCut, rCut_);
155          }
# Line 429 | Line 444 | namespace OpenMD {
444        perturbations_.push_back(eField);
445      }
446  
447 <    fDecomp_->distributeInitialData();
448 <
447 >    usePeriodicBoundaryConditions_ = info_->getSimParams()->getUsePeriodicBoundaryConditions();
448 >    
449 >    fDecomp_->distributeInitialData();
450 >    
451      initialized_ = true;
452 <
452 >    
453    }
454 <
454 >  
455    void ForceManager::calcForces() {
456      
457      if (!initialized_) initialize();
458 <
458 >    
459      preCalculation();  
460      shortRangeInteractions();
461      longRangeInteractions();
# Line 677 | Line 694 | namespace OpenMD {
694      RealType rCutSq;
695      bool in_switching_region;
696      RealType sw, dswdr, swderiv;
697 <    vector<int> atomListColumn, atomListRow, atomListLocal;
697 >    vector<int> atomListColumn, atomListRow;
698      InteractionData idat;
699      SelfData sdat;
700      RealType mf;
# Line 722 | Line 739 | namespace OpenMD {
739      
740        if (iLoop == loopStart) {
741          bool update_nlist = fDecomp_->checkNeighborList();
742 <        if (update_nlist)
742 >        if (update_nlist) {
743 >          if (!usePeriodicBoundaryConditions_)
744 >            Mat3x3d bbox = thermo->getBoundingBox();
745            neighborList = fDecomp_->buildNeighborList();
746 <      }            
746 >        }
747 >      }
748  
749        for (vector<pair<int, int> >::iterator it = neighborList.begin();
750               it != neighborList.end(); ++it) {
# Line 745 | Line 765 | namespace OpenMD {
765            if (iLoop == PAIR_LOOP) {
766              vij = 0.0;
767              fij = V3Zero;
768 +            eField1 = V3Zero;
769 +            eField2 = V3Zero;
770            }
771            
772            in_switching_region = switcher_->getSwitch(rgrpsq, sw, dswdr,
# Line 819 | Line 841 | namespace OpenMD {
841                fij += fg;
842  
843                if (atomListRow.size() == 1 && atomListColumn.size() == 1) {
844 <                stressTensor -= outProduct( *(idat.d), fg);
845 <                if (doHeatFlux_)
846 <                  fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2));
847 <                
844 >                if (!fDecomp_->skipAtomPair(atomListRow[0],
845 >                                            atomListColumn[0],
846 >                                            cg1, cg2)) {
847 >                  stressTensor -= outProduct( *(idat.d), fg);
848 >                  if (doHeatFlux_)
849 >                    fDecomp_->addToHeatFlux(*(idat.d) * dot(fg, vel2));
850 >                }                
851                }
852            
853                for (ia = atomListRow.begin();
# Line 907 | Line 932 | namespace OpenMD {
932        *(fDecomp_->getPairwisePotential());
933  
934      curSnapshot->setLongRangePotential(longRangePotential);
910
911    // collects single-atom information
912    fDecomp_->collectSelfData();
913
914    longRangePotential = *(fDecomp_->getEmbeddingPotential()) +
915      *(fDecomp_->getPairwisePotential());
916
917    curSnapshot->setLongRangePotential(longRangePotential);
935      
936      curSnapshot->setExcludedPotentials(*(fDecomp_->getExcludedSelfPotential()) +
937                                           *(fDecomp_->getExcludedPotential()));
# Line 952 | Line 969 | namespace OpenMD {
969   #endif
970      curSnapshot->setStressTensor(stressTensor);
971      
972 +    if (info_->getSimParams()->getUseLongRangeCorrections()) {
973 +      /*
974 +      RealType vol = curSnapshot->getVolume();
975 +      RealType Elrc(0.0);
976 +      RealType Wlrc(0.0);
977 +
978 +      set<AtomType*>::iterator i;
979 +      set<AtomType*>::iterator j;
980 +    
981 +      RealType n_i, n_j;
982 +      RealType rho_i, rho_j;
983 +      pair<RealType, RealType> LRI;
984 +      
985 +      for (i = atomTypes_.begin(); i != atomTypes_.end(); ++i) {
986 +        n_i = RealType(info_->getGlobalCountOfType(*i));
987 +        rho_i = n_i /  vol;
988 +        for (j = atomTypes_.begin(); j != atomTypes_.end(); ++j) {
989 +          n_j = RealType(info_->getGlobalCountOfType(*j));
990 +          rho_j = n_j / vol;
991 +          
992 +          LRI = interactionMan_->getLongRangeIntegrals( (*i), (*j) );
993 +
994 +          Elrc += n_i   * rho_j * LRI.first;
995 +          Wlrc -= rho_i * rho_j * LRI.second;
996 +        }
997 +      }
998 +      Elrc *= 2.0 * NumericConstant::PI;
999 +      Wlrc *= 2.0 * NumericConstant::PI;
1000 +
1001 +      RealType lrp = curSnapshot->getLongRangePotential();
1002 +      curSnapshot->setLongRangePotential(lrp + Elrc);
1003 +      stressTensor += Wlrc * SquareMatrix3<RealType>::identity();
1004 +      curSnapshot->setStressTensor(stressTensor);
1005 +      */
1006 +    
1007 +    }
1008    }
1009 < } //end namespace OpenMD
1009 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines