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

Comparing trunk/src/UseTheForce/ForceField.cpp (file contents):
Revision 1460 by gezelter, Wed Jul 7 15:04:32 2010 UTC vs.
Revision 1555 by gezelter, Tue May 10 20:54:47 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines