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

Comparing branches/development/src/UseTheForce/ForceField.cpp (file contents):
Revision 1535 by gezelter, Fri Dec 31 18:31:56 2010 UTC vs.
Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 36 | Line 36
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).                        
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   /**
# Line 448 | Line 449 | namespace OpenMD {
449    }
450    
451    NonBondedInteractionType* ForceField::getNonBondedInteractionType(const std::string &at1, const std::string &at2) {
452 +    
453      std::vector<std::string> keys;
454      keys.push_back(at1);
455      keys.push_back(at2);    
456 <  
456 >    
457      //try exact match first
458      NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(keys);
459      if (nbiType) {
460        return nbiType;
461      } else {
462 <      //if no exact match found, try wild card match
463 <      return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_);  
464 <    }    
462 >      AtomType* atype1;
463 >      AtomType* atype2;
464 >      std::vector<std::string> at1key;
465 >      at1key.push_back(at1);
466 >      atype1 = atomTypeCont_.find(at1key);
467 >      
468 >      std::vector<std::string> at2key;
469 >      at2key.push_back(at2);
470 >      atype2 = atomTypeCont_.find(at2key);
471 >      
472 >      // query atom types for their chains of responsibility
473 >      std::vector<AtomType*> at1Chain = atype1->allYourBase();
474 >      std::vector<AtomType*> at2Chain = atype2->allYourBase();
475 >      
476 >      std::vector<AtomType*>::iterator i;
477 >      std::vector<AtomType*>::iterator j;
478 >      
479 >      int ii = 0;
480 >      int jj = 0;
481 >      int nbiTypeScore;
482 >      
483 >      std::vector<std::pair<int, std::vector<std::string> > > foundNBI;
484 >      
485 >      for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
486 >        jj = 0;
487 >        for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
488 >          
489 >          nbiTypeScore = ii + jj;
490 >          
491 >          std::vector<std::string> myKeys;
492 >          myKeys.push_back((*i)->getName());
493 >          myKeys.push_back((*j)->getName());
494 >          
495 >          NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(myKeys);
496 >          if (nbiType) {
497 >            foundNBI.push_back(std::make_pair(nbiTypeScore, myKeys));
498 >          }
499 >          jj++;
500 >        }
501 >        ii++;
502 >      }
503 >      
504 >      
505 >      if (foundNBI.size() > 0) {
506 >        // sort the foundNBI by the score:
507 >        std::sort(foundNBI.begin(), foundNBI.end());
508 >        
509 >        int bestScore = foundNBI[0].first;
510 >        std::vector<std::string> theKeys = foundNBI[0].second;
511 >        
512 >        NonBondedInteractionType* bestType = nonBondedInteractionTypeCont_.find(theKeys);        
513 >        return bestType;
514 >      } else {
515 >        //if no exact match found, try wild card match
516 >        return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_);
517 >      }
518 >    }
519    }
520    
521    BondType* ForceField::getExactBondType(const std::string &at1,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines