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" |
55 |
< |
#include "UseTheForce/DarkSide/atype_interface.h" |
56 |
< |
#include "UseTheForce/DarkSide/fForceOptions_interface.h" |
56 |
< |
#include "UseTheForce/DarkSide/switcheroo_interface.h" |
55 |
> |
#include "types/LennardJonesAdapter.hpp" |
56 |
> |
|
57 |
|
namespace OpenMD { |
58 |
|
|
59 |
|
ForceField::ForceField() { |
69 |
|
} |
70 |
|
} |
71 |
|
|
72 |
< |
|
73 |
< |
ForceField::~ForceField() { |
74 |
< |
deleteAtypes(); |
75 |
< |
deleteSwitch(); |
76 |
< |
} |
77 |
< |
|
72 |
> |
/** |
73 |
> |
* getAtomType by string |
74 |
> |
* |
75 |
> |
* finds the requested atom type in this force field using the string |
76 |
> |
* name of the atom type. |
77 |
> |
*/ |
78 |
|
AtomType* ForceField::getAtomType(const std::string &at) { |
79 |
|
std::vector<std::string> keys; |
80 |
|
keys.push_back(at); |
81 |
|
return atomTypeCont_.find(keys); |
82 |
|
} |
83 |
|
|
84 |
+ |
/** |
85 |
+ |
* getAtomType by ident |
86 |
+ |
* |
87 |
+ |
* finds the requested atom type in this force field using the |
88 |
+ |
* integer ident instead of the string name of the atom type. |
89 |
+ |
*/ |
90 |
+ |
AtomType* ForceField::getAtomType(int ident) { |
91 |
+ |
std::string at = atypeIdentToName.find(ident)->second; |
92 |
+ |
return getAtomType(at); |
93 |
+ |
} |
94 |
+ |
|
95 |
|
BondType* ForceField::getBondType(const std::string &at1, |
96 |
|
const std::string &at2) { |
97 |
|
std::vector<std::string> keys; |
451 |
|
} |
452 |
|
|
453 |
|
NonBondedInteractionType* ForceField::getNonBondedInteractionType(const std::string &at1, const std::string &at2) { |
454 |
+ |
|
455 |
|
std::vector<std::string> keys; |
456 |
|
keys.push_back(at1); |
457 |
|
keys.push_back(at2); |
461 |
|
if (nbiType) { |
462 |
|
return nbiType; |
463 |
|
} else { |
464 |
< |
//if no exact match found, try wild card match |
465 |
< |
return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_); |
466 |
< |
} |
464 |
> |
AtomType* atype1; |
465 |
> |
AtomType* atype2; |
466 |
> |
std::vector<std::string> at1key; |
467 |
> |
at1key.push_back(at1); |
468 |
> |
atype1 = atomTypeCont_.find(at1key); |
469 |
> |
|
470 |
> |
std::vector<std::string> at2key; |
471 |
> |
at2key.push_back(at2); |
472 |
> |
atype2 = atomTypeCont_.find(at2key); |
473 |
> |
|
474 |
> |
// query atom types for their chains of responsibility |
475 |
> |
std::vector<AtomType*> at1Chain = atype1->allYourBase(); |
476 |
> |
std::vector<AtomType*> at2Chain = atype2->allYourBase(); |
477 |
> |
|
478 |
> |
std::vector<AtomType*>::iterator i; |
479 |
> |
std::vector<AtomType*>::iterator j; |
480 |
> |
|
481 |
> |
int ii = 0; |
482 |
> |
int jj = 0; |
483 |
> |
int nbiTypeScore; |
484 |
> |
|
485 |
> |
std::vector<std::pair<int, std::vector<std::string> > > foundNBI; |
486 |
> |
|
487 |
> |
for (i = at1Chain.begin(); i != at1Chain.end(); i++) { |
488 |
> |
jj = 0; |
489 |
> |
for (j = at2Chain.begin(); j != at2Chain.end(); j++) { |
490 |
> |
|
491 |
> |
nbiTypeScore = ii + jj; |
492 |
> |
|
493 |
> |
std::vector<std::string> myKeys; |
494 |
> |
myKeys.push_back((*i)->getName()); |
495 |
> |
myKeys.push_back((*j)->getName()); |
496 |
> |
|
497 |
> |
NonBondedInteractionType* nbiType = nonBondedInteractionTypeCont_.find(myKeys); |
498 |
> |
if (nbiType) { |
499 |
> |
foundNBI.push_back(std::make_pair(nbiTypeScore, myKeys)); |
500 |
> |
} |
501 |
> |
jj++; |
502 |
> |
} |
503 |
> |
ii++; |
504 |
> |
} |
505 |
> |
|
506 |
> |
|
507 |
> |
if (foundNBI.size() > 0) { |
508 |
> |
// sort the foundNBI by the score: |
509 |
> |
std::sort(foundNBI.begin(), foundNBI.end()); |
510 |
> |
|
511 |
> |
int bestScore = foundNBI[0].first; |
512 |
> |
std::vector<std::string> theKeys = foundNBI[0].second; |
513 |
> |
|
514 |
> |
NonBondedInteractionType* bestType = nonBondedInteractionTypeCont_.find(theKeys); |
515 |
> |
return bestType; |
516 |
> |
} else { |
517 |
> |
//if no exact match found, try wild card match |
518 |
> |
return nonBondedInteractionTypeCont_.find(keys, wildCardAtomTypeName_); |
519 |
> |
} |
520 |
> |
} |
521 |
|
} |
522 |
|
|
523 |
|
BondType* ForceField::getExactBondType(const std::string &at1, |
573 |
|
bool ForceField::addAtomType(const std::string &at, AtomType* atomType) { |
574 |
|
std::vector<std::string> keys; |
575 |
|
keys.push_back(at); |
576 |
+ |
atypeIdentToName[atomType->getIdent()] = at; |
577 |
|
return atomTypeCont_.add(keys, atomType); |
578 |
|
} |
579 |
|
|
580 |
|
bool ForceField::replaceAtomType(const std::string &at, AtomType* atomType) { |
581 |
|
std::vector<std::string> keys; |
582 |
|
keys.push_back(at); |
583 |
+ |
atypeIdentToName[atomType->getIdent()] = at; |
584 |
|
return atomTypeCont_.replace(keys, atomType); |
585 |
|
} |
586 |
|
|
637 |
|
} |
638 |
|
|
639 |
|
RealType ForceField::getRcutFromAtomType(AtomType* at) { |
572 |
– |
/**@todo */ |
573 |
– |
GenericData* data; |
640 |
|
RealType rcut = 0.0; |
641 |
|
|
642 |
< |
if (at->isLennardJones()) { |
643 |
< |
data = at->getPropertyByName("LennardJones"); |
644 |
< |
if (data != NULL) { |
579 |
< |
LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data); |
580 |
< |
|
581 |
< |
if (ljData != NULL) { |
582 |
< |
LJParam ljParam = ljData->getData(); |
583 |
< |
|
584 |
< |
//by default use 2.5*sigma as cutoff radius |
585 |
< |
rcut = 2.5 * ljParam.sigma; |
586 |
< |
|
587 |
< |
} else { |
588 |
< |
sprintf( painCave.errMsg, |
589 |
< |
"Can not cast GenericData to LJParam\n"); |
590 |
< |
painCave.severity = OPENMD_ERROR; |
591 |
< |
painCave.isFatal = 1; |
592 |
< |
simError(); |
593 |
< |
} |
594 |
< |
} else { |
595 |
< |
sprintf( painCave.errMsg, "Can not find Parameters for LennardJones\n"); |
596 |
< |
painCave.severity = OPENMD_ERROR; |
597 |
< |
painCave.isFatal = 1; |
598 |
< |
simError(); |
599 |
< |
} |
642 |
> |
LennardJonesAdapter lja = LennardJonesAdapter(at); |
643 |
> |
if (lja.isLennardJones()) { |
644 |
> |
rcut = 2.5 * lja.getSigma(); |
645 |
|
} |
646 |
|
return rcut; |
647 |
|
} |
676 |
|
return ffStream; |
677 |
|
} |
678 |
|
|
634 |
– |
void ForceField::setFortranForceOptions(){ |
635 |
– |
ForceOptions theseFortranOptions; |
636 |
– |
forceFieldOptions_.makeFortranOptions(theseFortranOptions); |
637 |
– |
setfForceOptions(&theseFortranOptions); |
638 |
– |
} |
679 |
|
} //end namespace OpenMD |