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 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/heatflux/src/UseTheForce/ForceField.cpp (file contents), Revision 1670 by chuckv, Fri Jan 27 19:07:19 2012 UTC

# Line 57 | Line 57 | namespace OpenMD {
57   namespace OpenMD {
58  
59    ForceField::ForceField() {
60 +
61      char* tempPath;
62      tempPath = getenv("FORCE_PARAM_PATH");
63 <
63 >    
64      if (tempPath == NULL) {
65        //convert a macro from compiler to a string in c++
66        STR_DEFINE(ffPath_, FRC_PATH );
# Line 439 | Line 440 | namespace OpenMD {
440    }
441    
442    NonBondedInteractionType* ForceField::getNonBondedInteractionType(const std::string &at1, const std::string &at2) {
443 +
444      std::vector<std::string> keys;
445      keys.push_back(at1);
446      keys.push_back(at2);    
# Line 448 | Line 450 | namespace OpenMD {
450      if (nbiType) {
451        return nbiType;
452      } else {
453 <      //if no exact match found, try wild card match
454 <      return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_);
455 <    }    
453 >      AtomType* atype1;
454 >      AtomType* atype2;
455 >      std::vector<std::string> at1key;
456 >      at1key.push_back(at1);
457 >      atype1 = atomTypeCont_.find(at1key);
458 >  
459 >      std::vector<std::string> at2key;
460 >      at2key.push_back(at2);
461 >      atype2 = atomTypeCont_.find(at2key);
462 >
463 >      // query atom types for their chains of responsibility
464 >      std::vector<AtomType*> at1Chain = atype1->allYourBase();
465 >      std::vector<AtomType*> at2Chain = atype2->allYourBase();
466 >
467 >      std::vector<AtomType*>::iterator i;
468 >      std::vector<AtomType*>::iterator j;
469 >
470 >      int ii = 0;
471 >      int jj = 0;
472 >      int nbiTypeScore;
473 >
474 >      std::vector<std::pair<int, std::vector<std::string> > > foundNBI;
475 >
476 >      for (i = at1Chain.begin(); i != at1Chain.end(); i++) {
477 >        jj = 0;
478 >        for (j = at2Chain.begin(); j != at2Chain.end(); j++) {
479 >
480 >          nbiTypeScore = ii + jj;
481 >
482 >          std::vector<std::string> myKeys;
483 >          myKeys.push_back((*i)->getName());
484 >          myKeys.push_back((*j)->getName());
485 >
486 >          NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(myKeys);
487 >          if (nbiType) {
488 >            foundNBI.push_back(std::make_pair(nbiTypeScore, myKeys));
489 >          }
490 >          jj++;
491 >        }
492 >        ii++;
493 >      }
494 >
495 >
496 >      if (foundNBI.size() > 0) {
497 >        // sort the foundNBI by the score:
498 >        std::sort(foundNBI.begin(), foundNBI.end());
499 >    
500 >        int bestScore = foundNBI[0].first;
501 >        std::vector<std::string> theKeys = foundNBI[0].second;
502 >        
503 >        NonBondedInteractionType* bestType = nonBondedInteractionTypeCont_.find(theKeys);        
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,

Comparing:
trunk/src/UseTheForce/ForceField.cpp (property svn:keywords), Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC vs.
branches/heatflux/src/UseTheForce/ForceField.cpp (property svn:keywords), Revision 1670 by chuckv, Fri Jan 27 19:07:19 2012 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines