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 1847 by gezelter, Thu Jan 31 17:57:07 2013 UTC vs.
Revision 1866 by gezelter, Thu Apr 25 14:32:56 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 71 | Line 71 | namespace OpenMD {
71      forceField_ = info_->getForceField();
72      interactionMan_ = new InteractionManager();
73      fDecomp_ = new ForceMatrixDecomposition(info_, interactionMan_);
74 +    thermo = new Thermo(info_);
75    }
76  
77    /**
# Line 117 | Line 118 | namespace OpenMD {
118      else
119        mdFileVersion = 0;
120    
121 +    // We need the list of simulated atom types to figure out cutoffs
122 +    // as well as long range corrections.
123 +
124 +    set<AtomType*>::iterator i;
125 +    set<AtomType*> atomTypes_;
126 +    atomTypes_ = info_->getSimulatedAtomTypes();
127 +
128      if (simParams_->haveCutoffRadius()) {
129        rCut_ = simParams_->getCutoffRadius();
130      } else {      
# Line 131 | Line 139 | namespace OpenMD {
139          rCut_ = 12.0;
140        } else {
141          RealType thisCut;
142 <        set<AtomType*>::iterator i;
135 <        set<AtomType*> atomTypes;
136 <        atomTypes = info_->getSimulatedAtomTypes();        
137 <        for (i = atomTypes.begin(); i != atomTypes.end(); ++i) {
142 >        for (i = atomTypes_.begin(); i != atomTypes_.end(); ++i) {
143            thisCut = interactionMan_->getSuggestedCutoffRadius((*i));
144            rCut_ = max(thisCut, rCut_);
145          }
# Line 429 | Line 434 | namespace OpenMD {
434        perturbations_.push_back(eField);
435      }
436  
437 <    fDecomp_->distributeInitialData();
438 <
437 >    usePeriodicBoundaryConditions_ = info_->getSimParams()->getUsePeriodicBoundaryConditions();
438 >    
439 >    fDecomp_->distributeInitialData();
440 >    
441      initialized_ = true;
442 <
442 >    
443    }
444 <
444 >  
445    void ForceManager::calcForces() {
446      
447      if (!initialized_) initialize();
448 <
448 >    
449      preCalculation();  
450      shortRangeInteractions();
451      longRangeInteractions();
# Line 722 | Line 729 | namespace OpenMD {
729      
730        if (iLoop == loopStart) {
731          bool update_nlist = fDecomp_->checkNeighborList();
732 <        if (update_nlist)
732 >        if (update_nlist) {
733 >          if (!usePeriodicBoundaryConditions_)
734 >            Mat3x3d bbox = thermo->getBoundingBox();
735            neighborList = fDecomp_->buildNeighborList();
736 <      }            
736 >        }
737 >      }
738  
739        for (vector<pair<int, int> >::iterator it = neighborList.begin();
740               it != neighborList.end(); ++it) {
# Line 904 | Line 914 | namespace OpenMD {
914          interactionMan_->doSelfCorrection(sdat);
915        }
916      }
907
908    // collects single-atom information
909    fDecomp_->collectSelfData();
910
911    longRangePotential = *(fDecomp_->getEmbeddingPotential()) +
912      *(fDecomp_->getPairwisePotential());
913
914    curSnapshot->setLongRangePotential(longRangePotential);
917  
918      // collects single-atom information
919      fDecomp_->collectSelfData();
# Line 957 | Line 959 | namespace OpenMD {
959   #endif
960      curSnapshot->setStressTensor(stressTensor);
961      
962 +    if (info_->getSimParams()->getUseLongRangeCorrections()) {
963 +      /*
964 +      RealType vol = curSnapshot->getVolume();
965 +      RealType Elrc(0.0);
966 +      RealType Wlrc(0.0);
967 +
968 +      set<AtomType*>::iterator i;
969 +      set<AtomType*>::iterator j;
970 +    
971 +      RealType n_i, n_j;
972 +      RealType rho_i, rho_j;
973 +      pair<RealType, RealType> LRI;
974 +      
975 +      for (i = atomTypes_.begin(); i != atomTypes_.end(); ++i) {
976 +        n_i = RealType(info_->getGlobalCountOfType(*i));
977 +        rho_i = n_i /  vol;
978 +        for (j = atomTypes_.begin(); j != atomTypes_.end(); ++j) {
979 +          n_j = RealType(info_->getGlobalCountOfType(*j));
980 +          rho_j = n_j / vol;
981 +          
982 +          LRI = interactionMan_->getLongRangeIntegrals( (*i), (*j) );
983 +
984 +          Elrc += n_i   * rho_j * LRI.first;
985 +          Wlrc -= rho_i * rho_j * LRI.second;
986 +        }
987 +      }
988 +      Elrc *= 2.0 * NumericConstant::PI;
989 +      Wlrc *= 2.0 * NumericConstant::PI;
990 +
991 +      RealType lrp = curSnapshot->getLongRangePotential();
992 +      curSnapshot->setLongRangePotential(lrp + Elrc);
993 +      stressTensor += Wlrc * SquareMatrix3<RealType>::identity();
994 +      curSnapshot->setStressTensor(stressTensor);
995 +      */
996 +    
997 +    }
998    }
999 < } //end namespace OpenMD
999 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines