| 49 |
|
|
| 50 |
|
using namespace std; |
| 51 |
|
namespace OpenMD { |
| 52 |
< |
|
| 53 |
< |
|
| 52 |
> |
|
| 53 |
|
SHAPES::SHAPES() { |
| 54 |
|
initialized_ = false; |
| 55 |
|
lMax_ = 64; |
| 70 |
|
for (at = atomTypes->beginType(i); at != NULL; |
| 71 |
|
at = atomTypes->nextType(i)) { |
| 72 |
|
|
| 73 |
< |
if (at->isShape() || at->isLennardJones()) |
| 74 |
< |
addType(at); |
| 73 |
> |
if (at->isShape()) |
| 74 |
> |
addShape(dynamic_cast<ShapeAtomType*>(at)); |
| 75 |
> |
|
| 76 |
> |
if (at->isLennardJones()) |
| 77 |
> |
addLJ(at); |
| 78 |
> |
|
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
initialized_ = true; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
< |
void SHAPES::addType(AtomType* atomType){ |
| 84 |
> |
void SHAPES::addShape(ShapeAtomType* atomType){ |
| 85 |
|
// add it to the map: |
| 86 |
|
AtomTypeProperties atp = atomType->getATP(); |
| 87 |
< |
|
| 88 |
< |
pair<map<int,AtomType*>::iterator,bool> ret; |
| 89 |
< |
ret = ShapesMap.insert( pair<int, AtomType*>(atp.ident, atomType) ); |
| 87 |
> |
|
| 88 |
> |
pair<map<int,ShapeAtomType*>::iterator, bool> ret; |
| 89 |
> |
ret = shapesMap.insert( pair<int, ShapeAtomType*>(atp.ident, atomType)); |
| 90 |
|
if (ret.second == false) { |
| 91 |
< |
sprintf( painCave.errMsg, |
| 91 |
> |
sprintf( painCave.errmsg, |
| 92 |
|
"SHAPES already had a previous entry with ident %d\n", |
| 93 |
|
atp.ident); |
| 94 |
|
painCave.severity = OPENMD_INFO; |
| 96 |
|
simError(); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
< |
if (atomType->isShape()) { |
| 100 |
< |
ShapeAtomType* sAtomType = dynamic_cast<ShapeAtomType*>(atomType); |
| 101 |
< |
if (sAtomType == NULL) { |
| 99 |
< |
sprintf(painCave.errMsg, |
| 100 |
< |
"SHAPES:: Can't cast to ShapeAtomType"); |
| 101 |
< |
painCave.severity = OPENMD_ERROR; |
| 102 |
< |
painCave.isFatal = 1; |
| 103 |
< |
simError(); |
| 104 |
< |
} |
| 105 |
< |
ShapesMap.insert( pair<int, ShapeAtomType*>(atp.ident, sAtomType) ); |
| 106 |
< |
|
| 107 |
< |
} else if (atomType->isLennardJones()) { |
| 99 |
> |
ShapesMap.insert( pair<int, ShapeAtomType*>(atp.ident, sAtomType) ); |
| 100 |
> |
|
| 101 |
> |
} else if (atomType->isLennardJones()) { |
| 102 |
|
d1 = getLJSigma(atomType) / sqrt(2.0); |
| 103 |
|
e1 = getLJEpsilon(atomType); |
| 104 |
|
} else { |
| 109 |
|
painCave.severity = OPENMD_ERROR; |
| 110 |
|
painCave.isFatal = 1; |
| 111 |
|
simError(); |
| 112 |
< |
} |
| 119 |
< |
|
| 120 |
< |
|
| 121 |
< |
// Now, iterate over all known types and add to the mixing map: |
| 122 |
< |
|
| 123 |
< |
map<int, AtomType*>::iterator it; |
| 124 |
< |
for( it = ShapesMap.begin(); it != SHAPESMap.end(); ++it) { |
| 125 |
< |
|
| 126 |
< |
AtomType* atype2 = (*it).second; |
| 127 |
< |
|
| 128 |
< |
RealType d2, l2, e2, er2, dw2; |
| 129 |
< |
|
| 130 |
< |
if (atype2->isGayBerne()) { |
| 131 |
< |
GayBerneParam gb2 = getGayBerneParam(atype2); |
| 132 |
< |
d2 = gb2.SHAPES_d; |
| 133 |
< |
l2 = gb2.SHAPES_l; |
| 134 |
< |
e2 = gb2.SHAPES_eps; |
| 135 |
< |
er2 = gb2.SHAPES_eps_ratio; |
| 136 |
< |
dw2 = gb2.SHAPES_dw; |
| 137 |
< |
} else if (atype2->isLennardJones()) { |
| 138 |
< |
d2 = getLJSigma(atype2) / sqrt(2.0); |
| 139 |
< |
e2 = getLJEpsilon(atype2); |
| 140 |
< |
l2 = d2; |
| 141 |
< |
er2 = 1.0; |
| 142 |
< |
dw2 = 1.0; |
| 143 |
< |
} |
| 144 |
< |
|
| 145 |
< |
SHAPESInteractionData mixer; |
| 146 |
< |
|
| 147 |
< |
// Cleaver paper uses sqrt of squares to get sigma0 for |
| 148 |
< |
// mixed interactions. |
| 149 |
< |
|
| 150 |
< |
mixer.sigma0 = sqrt(d1*d1 + d2*d2); |
| 151 |
< |
mixer.xa2 = (l1*l1 - d1*d1)/(l1*l1 + d2*d2); |
| 152 |
< |
mixer.xai2 = (l2*l2 - d2*d2)/(l2*l2 + d1*d1); |
| 153 |
< |
mixer.x2 = (l1*l1 - d1*d1) * (l2*l2 - d2*d2) / |
| 154 |
< |
((l2*l2 + d1*d1) * (l1*l1 + d2*d2)); |
| 155 |
< |
|
| 156 |
< |
// assumed LB mixing rules for now: |
| 157 |
< |
|
| 158 |
< |
mixer.dw = 0.5 * (dw1 + dw2); |
| 159 |
< |
mixer.eps0 = sqrt(e1 * e2); |
| 160 |
< |
|
| 161 |
< |
RealType er = sqrt(er1 * er2); |
| 162 |
< |
RealType ermu = pow(er,(1.0 / mu_)); |
| 163 |
< |
RealType xp = (1.0 - ermu) / (1.0 + ermu); |
| 164 |
< |
RealType ap2 = 1.0 / (1.0 + ermu); |
| 165 |
< |
|
| 166 |
< |
mixer.xp2 = xp * xp; |
| 167 |
< |
mixer.xpap2 = xp * ap2; |
| 168 |
< |
mixer.xpapi2 = xp / ap2; |
| 169 |
< |
|
| 170 |
< |
// only add this pairing if at least one of the atoms is a Gay-Berne atom |
| 171 |
< |
|
| 172 |
< |
if (atomType->isGayBerne() || atype2->isGayBerne()) { |
| 173 |
< |
|
| 174 |
< |
pair<AtomType*, AtomType*> key1, key2; |
| 175 |
< |
key1 = make_pair(atomType, atype2); |
| 176 |
< |
key2 = make_pair(atype2, atomType); |
| 177 |
< |
|
| 178 |
< |
MixingMap[key1] = mixer; |
| 179 |
< |
if (key2 != key1) { |
| 180 |
< |
MixingMap[key2] = mixer; |
| 181 |
< |
} |
| 182 |
< |
} |
| 183 |
< |
} |
| 112 |
> |
} |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
|