| 46 |
|
#include <cmath> |
| 47 |
|
#include "nonbonded/Sticky.hpp" |
| 48 |
|
#include "nonbonded/LJ.hpp" |
| 49 |
+ |
#include "types/StickyAdapter.hpp" |
| 50 |
|
#include "utils/simError.h" |
| 51 |
|
|
| 52 |
|
using namespace std; |
| 53 |
|
namespace OpenMD { |
| 54 |
|
|
| 55 |
|
Sticky::Sticky() : name_("Sticky"), initialized_(false), forceField_(NULL) {} |
| 55 |
– |
|
| 56 |
– |
StickyParam Sticky::getStickyParam(AtomType* atomType) { |
| 57 |
– |
|
| 58 |
– |
// Do sanity checking on the AtomType we were passed before |
| 59 |
– |
// building any data structures: |
| 60 |
– |
if (!atomType->isSticky() && !atomType->isStickyPower()) { |
| 61 |
– |
sprintf( painCave.errMsg, |
| 62 |
– |
"Sticky::getStickyParam was passed an atomType (%s) that does\n" |
| 63 |
– |
"\tnot appear to be a Sticky atom.\n", |
| 64 |
– |
atomType->getName().c_str()); |
| 65 |
– |
painCave.severity = OPENMD_ERROR; |
| 66 |
– |
painCave.isFatal = 1; |
| 67 |
– |
simError(); |
| 68 |
– |
} |
| 69 |
– |
|
| 70 |
– |
DirectionalAtomType* daType = dynamic_cast<DirectionalAtomType*>(atomType); |
| 71 |
– |
GenericData* data = daType->getPropertyByName("Sticky"); |
| 72 |
– |
if (data == NULL) { |
| 73 |
– |
sprintf( painCave.errMsg, "Sticky::getStickyParam could not find\n" |
| 74 |
– |
"\tSticky parameters for atomType %s.\n", |
| 75 |
– |
daType->getName().c_str()); |
| 76 |
– |
painCave.severity = OPENMD_ERROR; |
| 77 |
– |
painCave.isFatal = 1; |
| 78 |
– |
simError(); |
| 79 |
– |
} |
| 80 |
– |
|
| 81 |
– |
StickyParamGenericData* stickyData = dynamic_cast<StickyParamGenericData*>(data); |
| 82 |
– |
if (stickyData == NULL) { |
| 83 |
– |
sprintf( painCave.errMsg, |
| 84 |
– |
"Sticky::getStickyParam could not convert GenericData to\n" |
| 85 |
– |
"\tStickyParamGenericData for atom type %s\n", |
| 86 |
– |
daType->getName().c_str()); |
| 87 |
– |
painCave.severity = OPENMD_ERROR; |
| 88 |
– |
painCave.isFatal = 1; |
| 89 |
– |
simError(); |
| 90 |
– |
} |
| 56 |
|
|
| 92 |
– |
return stickyData->getData(); |
| 93 |
– |
} |
| 94 |
– |
|
| 57 |
|
void Sticky::initialize() { |
| 58 |
|
|
| 59 |
|
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
| 66 |
|
for (at = atomTypes->beginType(i); at != NULL; |
| 67 |
|
at = atomTypes->nextType(i)) { |
| 68 |
|
|
| 69 |
< |
if (at->isSticky() || at->isStickyPower()) |
| 70 |
< |
addType(at); |
| 69 |
> |
StickyAdapter sa = StickyAdapter(at); |
| 70 |
> |
if (sa.isSticky()) addType(at); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
initialized_ = true; |
| 75 |
|
|
| 76 |
|
void Sticky::addType(AtomType* atomType){ |
| 77 |
|
// add it to the map: |
| 116 |
– |
AtomTypeProperties atp = atomType->getATP(); |
| 78 |
|
|
| 79 |
|
pair<map<int,AtomType*>::iterator,bool> ret; |
| 80 |
< |
ret = StickyMap.insert( pair<int, AtomType*>(atp.ident, atomType) ); |
| 80 |
> |
ret = StickyMap.insert( pair<int, AtomType*>(atomType->getIdent(), |
| 81 |
> |
atomType) ); |
| 82 |
|
if (ret.second == false) { |
| 83 |
|
sprintf( painCave.errMsg, |
| 84 |
|
"Sticky already had a previous entry with ident %d\n", |
| 85 |
< |
atp.ident); |
| 85 |
> |
atomType->getIdent() ); |
| 86 |
|
painCave.severity = OPENMD_INFO; |
| 87 |
|
painCave.isFatal = 0; |
| 88 |
|
simError(); |
| 90 |
|
|
| 91 |
|
RealType w0i, v0i, v0pi, rli, rui, rlpi, rupi; |
| 92 |
|
|
| 93 |
< |
StickyParam sticky1 = getStickyParam(atomType); |
| 93 |
> |
StickyAdapter sticky1 = StickyAdapter(atomType); |
| 94 |
|
|
| 95 |
|
// Now, iterate over all known types and add to the mixing map: |
| 96 |
|
|
| 98 |
|
for( it = StickyMap.begin(); it != StickyMap.end(); ++it) { |
| 99 |
|
|
| 100 |
|
AtomType* atype2 = (*it).second; |
| 101 |
< |
|
| 102 |
< |
StickyParam sticky2 = getStickyParam(atype2); |
| 101 |
> |
|
| 102 |
> |
StickyAdapter sticky2 = StickyAdapter(atype2); |
| 103 |
|
|
| 104 |
|
StickyInteractionData mixer; |
| 105 |
|
|
| 108 |
|
// Lorentz- Berthelot mixing rules (which happen to do the right thing |
| 109 |
|
// when atomType and atype2 happen to be the same. |
| 110 |
|
|
| 111 |
< |
mixer.rl = 0.5 * ( sticky1.rl + sticky2.rl ); |
| 112 |
< |
mixer.ru = 0.5 * ( sticky1.ru + sticky2.ru ); |
| 113 |
< |
mixer.rlp = 0.5 * ( sticky1.rlp + sticky2.rlp ); |
| 114 |
< |
mixer.rup = 0.5 * ( sticky1.rup + sticky2.rup ); |
| 111 |
> |
mixer.rl = 0.5 * ( sticky1.getRl() + sticky2.getRl() ); |
| 112 |
> |
mixer.ru = 0.5 * ( sticky1.getRu() + sticky2.getRu() ); |
| 113 |
> |
mixer.rlp = 0.5 * ( sticky1.getRlp() + sticky2.getRlp() ); |
| 114 |
> |
mixer.rup = 0.5 * ( sticky1.getRup() + sticky2.getRup() ); |
| 115 |
|
mixer.rbig = max(mixer.ru, mixer.rup); |
| 116 |
< |
mixer.w0 = sqrt( sticky1.w0 * sticky2.w0 ); |
| 117 |
< |
mixer.v0 = sqrt( sticky1.v0 * sticky2.v0 ); |
| 118 |
< |
mixer.v0p = sqrt( sticky1.v0p * sticky2.v0p ); |
| 119 |
< |
mixer.isPower = atomType->isStickyPower() && atype2->isStickyPower(); |
| 116 |
> |
mixer.w0 = sqrt( sticky1.getW0() * sticky2.getW0() ); |
| 117 |
> |
mixer.v0 = sqrt( sticky1.getW0() * sticky2.getV0() ); |
| 118 |
> |
mixer.v0p = sqrt( sticky1.getV0p() * sticky2.getV0p() ); |
| 119 |
> |
mixer.isPower = sticky1.isStickyPower() && sticky2.isStickyPower(); |
| 120 |
|
|
| 121 |
|
CubicSpline* s = new CubicSpline(); |
| 122 |
|
s->addPoint(mixer.rl, 1.0); |