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 1576 by gezelter, Wed Jun 8 16:05:07 2011 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).          
39 < * [4]  Vardeman & Gezelter, in progress (2009).                        
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   */
42  
43   #include "nonbonded/InteractionManager.hpp"
# Line 51 | Line 52 | namespace OpenMD {
52      gb_ = new GB();
53      sticky_ = new Sticky();
54      morse_ = new Morse();
55 +    repulsivePower_ = new RepulsivePower();
56      eam_ = new EAM();
57      sc_ = new SC();
58      electrostatic_ = new Electrostatic();
59      maw_ = new MAW();
60    }
61  
62 +  InteractionManager::~InteractionManager() {
63 +    delete lj_;
64 +    delete gb_;
65 +    delete sticky_;
66 +    delete morse_;
67 +    delete repulsivePower_;
68 +    delete eam_;
69 +    delete sc_;
70 +    delete electrostatic_;
71 +    delete maw_;
72 +  }
73 +
74    void InteractionManager::initialize() {
75 <    
75 >
76 >    if (initialized_) return;
77 >
78      ForceField* forceField_ = info_->getForceField();
79      
80      lj_->setForceField(forceField_);
# Line 67 | Line 83 | namespace OpenMD {
83      eam_->setForceField(forceField_);
84      sc_->setForceField(forceField_);
85      morse_->setForceField(forceField_);
86 +    electrostatic_->setSimInfo(info_);
87      electrostatic_->setForceField(forceField_);
88      maw_->setForceField(forceField_);
89 +    repulsivePower_->setForceField(forceField_);
90  
91      ForceField::AtomTypeContainer* atomTypes = forceField_->getAtomTypes();
92      ForceField::AtomTypeContainer::MapTypeIterator i1, i2;
93      AtomType* atype1;
94      AtomType* atype2;
95      pair<AtomType*, AtomType*> key;
78    pair<set<NonBondedInteraction*>::iterator, bool> ret;
96      
97      for (atype1 = atomTypes->beginType(i1); atype1 != NULL;
98           atype1 = atomTypes->nextType(i1)) {
99        
100        // add it to the map:
84      AtomTypeProperties atp = atype1->getATP();    
101        
102        pair<map<int,AtomType*>::iterator,bool> ret;    
103 <      ret = typeMap_.insert( pair<int, AtomType*>(atp.ident, atype1) );
103 >      ret = typeMap_.insert( pair<int, AtomType*>(atype1->getIdent(), atype1) );
104        if (ret.second == false) {
105          sprintf( painCave.errMsg,
106                   "InteractionManager already had a previous entry with ident %d\n",
107 <                 atp.ident);
107 >                 atype1->getIdent());
108          painCave.severity = OPENMD_INFO;
109          painCave.isFatal = 0;
110          simError();                
# Line 103 | Line 119 | namespace OpenMD {
119  
120        for( it2 = typeMap_.begin(); it2 != typeMap_.end(); ++it2) {        
121          atype2 = (*it2).second;
122 <        
107 <        bool vdwExplicit = false;
108 <        bool metExplicit = false;
109 <        bool hbExplicit = false;
110 <                      
122 >                              
123          key = make_pair(atype1, atype2);
124          
125          if (atype1->isLennardJones() && atype2->isLennardJones()) {
# Line 142 | Line 154 | namespace OpenMD {
154          
155          if (nbiType != NULL) {
156  
157 +          bool vdwExplicit = false;
158 +          bool metExplicit = false;
159 +          // bool hbExplicit = false;
160 +
161            if (nbiType->isLennardJones()) {
162              // We found an explicit Lennard-Jones interaction.  
163              // override all other vdw entries for this pair of atom types:
# Line 175 | Line 191 | namespace OpenMD {
191                if (ifam == VANDERWAALS_FAMILY) interactions_[key].erase(*it);
192              }
193              interactions_[key].insert(morse_);
194 +            vdwExplicit = true;
195 +          }
196 +
197 +          if (nbiType->isRepulsivePower()) {
198 +            if (vdwExplicit) {
199 +              sprintf( painCave.errMsg,
200 +                       "InteractionManager::initialize found more than one "
201 +                       "explicit \n"
202 +                       "\tvan der Waals interaction for atom types %s - %s\n",
203 +                       atype1->getName().c_str(), atype2->getName().c_str());
204 +              painCave.severity = OPENMD_ERROR;
205 +              painCave.isFatal = 1;
206 +              simError();
207 +            }
208 +            // We found an explicit RepulsivePower interaction.  
209 +            // override all other vdw entries for this pair of atom types:
210 +            set<NonBondedInteraction*>::iterator it;
211 +            for (it = interactions_[key].begin();
212 +                 it != interactions_[key].end(); ++it) {
213 +              InteractionFamily ifam = (*it)->getFamily();
214 +              if (ifam == VANDERWAALS_FAMILY) interactions_[key].erase(*it);
215 +            }
216 +            interactions_[key].insert(repulsivePower_);
217              vdwExplicit = true;
218            }
219            
220 +          
221            if (nbiType->isEAM()) {
222              // We found an explicit EAM interaction.  
223              // override all other metallic entries for this pair of atom types:
# Line 241 | Line 281 | namespace OpenMD {
281      }
282      
283      
284 <    // make sure every pair of atom types in this simulation has a
285 <    // non-bonded interaction:
284 >    // Make sure every pair of atom types in this simulation has a
285 >    // non-bonded interaction.  If not, just inform the user.
286  
287      set<AtomType*> simTypes = info_->getSimulatedAtomTypes();
288      set<AtomType*>::iterator it, jt;
289 +
290      for (it = simTypes.begin(); it != simTypes.end(); ++it) {
291        atype1 = (*it);
292 <      for (jt = simTypes.begin(); jt != simTypes.end(); ++jt) {
292 >      for (jt = it; jt != simTypes.end(); ++jt) {
293          atype2 = (*jt);
294          key = make_pair(atype1, atype2);
295          
296          if (interactions_[key].size() == 0) {
297            sprintf( painCave.errMsg,
298 <                   "InteractionManager unable to find an appropriate non-bonded\n"
299 <                   "\tinteraction for atom types %s - %s\n",
298 >                   "InteractionManager could not find a matching non-bonded\n"
299 >                   "\tinteraction for atom types %s - %s\n"
300 >                   "\tProceeding without this interaction.\n",
301                     atype1->getName().c_str(), atype2->getName().c_str());
302            painCave.severity = OPENMD_INFO;
303 <          painCave.isFatal = 1;
303 >          painCave.isFatal = 0;
304            simError();
305          }
306        }
# Line 266 | Line 308 | namespace OpenMD {
308  
309      initialized_ = true;
310    }
311 <  
311 >
312 >  void InteractionManager::setCutoffRadius(RealType rcut) {
313 >    
314 >    electrostatic_->setCutoffRadius(rcut);
315 >    eam_->setCutoffRadius(rcut);
316 >  }
317 >
318    void InteractionManager::doPrePair(InteractionData idat){
319      
320      if (!initialized_) initialize();
321          
322 +    // excluded interaction, so just return
323 +    if (idat.excluded) return;
324 +
325      set<NonBondedInteraction*>::iterator it;
326  
327      for (it = interactions_[ idat.atypes ].begin();
# Line 302 | Line 353 | namespace OpenMD {
353    void InteractionManager::doPair(InteractionData idat){
354      
355      if (!initialized_) initialize();
356 <  
356 >
357      set<NonBondedInteraction*>::iterator it;
358  
359      for (it = interactions_[ idat.atypes ].begin();
360 <         it != interactions_[ idat.atypes ].end(); ++it)
310 <      (*it)->calcForce(idat);
311 <    
312 <    return;    
313 <  }
360 >         it != interactions_[ idat.atypes ].end(); ++it) {
361  
362 <  void InteractionManager::doSkipCorrection(InteractionData idat){
362 >      // electrostatics still has to worry about indirect
363 >      // contributions from excluded pairs of atoms:
364  
365 <    if (!initialized_) initialize();  
366 <    
319 <    set<NonBondedInteraction*>::iterator it;
320 <
321 <    for (it = interactions_[ idat.atypes ].begin();
322 <         it != interactions_[ idat.atypes ].end(); ++it){
323 <      if ((*it)->getFamily() == ELECTROSTATIC_FAMILY) {
324 <        dynamic_cast<ElectrostaticInteraction*>(*it)->calcSkipCorrection(idat);
365 >      if (!idat.excluded || (*it)->getFamily() == ELECTROSTATIC_FAMILY) {
366 >        (*it)->calcForce(idat);
367        }
368      }
369      
# Line 346 | Line 388 | namespace OpenMD {
388  
389    RealType InteractionManager::getSuggestedCutoffRadius(int *atid) {
390      if (!initialized_) initialize();
391 <    
391 >
392      AtomType* atype = typeMap_[*atid];
393  
394      pair<AtomType*, AtomType*> key = make_pair(atype, atype);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines