| 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 |  | /** | 
| 52 |  | #include "UseTheForce/ForceField.hpp" | 
| 53 |  | #include "utils/simError.h" | 
| 54 |  | #include "utils/Tuple.hpp" | 
| 54 | – | #include "UseTheForce/DarkSide/atype_interface.h" | 
| 55 | – | #include "UseTheForce/DarkSide/fForceOptions_interface.h" | 
| 56 | – | #include "UseTheForce/DarkSide/switcheroo_interface.h" | 
| 55 |  | namespace OpenMD { | 
| 56 |  |  | 
| 57 |  | ForceField::ForceField() { | 
| 58 | + |  | 
| 59 |  | char* tempPath; | 
| 60 |  | tempPath = getenv("FORCE_PARAM_PATH"); | 
| 61 | < |  | 
| 61 | > |  | 
| 62 |  | if (tempPath == NULL) { | 
| 63 | < | ffPath_ = "ORNULL(FRC_PATH)"; | 
| 63 | > | //convert a macro from compiler to a string in c++ | 
| 64 | > | STR_DEFINE(ffPath_, FRC_PATH ); | 
| 65 |  | } else { | 
| 66 |  | ffPath_ = tempPath; | 
| 67 |  | } | 
| 68 |  | } | 
| 69 |  |  | 
| 70 | < |  | 
| 71 | < | ForceField::~ForceField() { | 
| 72 | < | deleteAtypes(); | 
| 73 | < | deleteSwitch(); | 
| 74 | < | } | 
| 75 | < |  | 
| 70 | > | /** | 
| 71 | > | * getAtomType by string | 
| 72 | > | * | 
| 73 | > | * finds the requested atom type in this force field using the string | 
| 74 | > | * name of the atom type. | 
| 75 | > | */ | 
| 76 |  | AtomType* ForceField::getAtomType(const std::string &at) { | 
| 77 |  | std::vector<std::string> keys; | 
| 78 |  | keys.push_back(at); | 
| 79 |  | return atomTypeCont_.find(keys); | 
| 80 |  | } | 
| 81 |  |  | 
| 82 | + | /** | 
| 83 | + | * getAtomType by ident | 
| 84 | + | * | 
| 85 | + | * finds the requested atom type in this force field using the | 
| 86 | + | * integer ident instead of the string name of the atom type. | 
| 87 | + | */ | 
| 88 | + | AtomType* ForceField::getAtomType(int ident) { | 
| 89 | + | std::string at = atypeIdentToName.find(ident)->second; | 
| 90 | + | return getAtomType(at); | 
| 91 | + | } | 
| 92 | + |  | 
| 93 |  | BondType* ForceField::getBondType(const std::string &at1, | 
| 94 |  | const std::string &at2) { | 
| 95 |  | std::vector<std::string> keys; | 
| 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); | 
| 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, | 
| 571 |  | bool ForceField::addAtomType(const std::string &at, AtomType* atomType) { | 
| 572 |  | std::vector<std::string> keys; | 
| 573 |  | keys.push_back(at); | 
| 574 | + | atypeIdentToName[atomType->getIdent()] = at; | 
| 575 |  | return atomTypeCont_.add(keys, atomType); | 
| 576 |  | } | 
| 577 |  |  | 
| 578 |  | bool ForceField::replaceAtomType(const std::string &at, AtomType* atomType) { | 
| 579 |  | std::vector<std::string> keys; | 
| 580 |  | keys.push_back(at); | 
| 581 | + | atypeIdentToName[atomType->getIdent()] = at; | 
| 582 |  | return atomTypeCont_.replace(keys, atomType); | 
| 583 |  | } | 
| 584 |  |  | 
| 697 |  | return ffStream; | 
| 698 |  | } | 
| 699 |  |  | 
| 632 | – | void ForceField::setFortranForceOptions(){ | 
| 633 | – | ForceOptions theseFortranOptions; | 
| 634 | – | forceFieldOptions_.makeFortranOptions(theseFortranOptions); | 
| 635 | – | setfForceOptions(&theseFortranOptions); | 
| 636 | – | } | 
| 700 |  | } //end namespace OpenMD |