50 |
|
using namespace std; |
51 |
|
namespace OpenMD { |
52 |
|
|
53 |
– |
bool SHAPES::initialized_ = false; |
54 |
– |
int SHAPES::lMax_ = 64; |
55 |
– |
int SHAPES::mMax_ = 64; |
56 |
– |
ForceField* SHAPES::forceField_ = NULL; |
57 |
– |
map<int, AtomType*> SHAPES::ShapesMap; |
58 |
– |
map<pair<AtomType*, AtomType*>, SHAPESInteractionData> SHAPES::MixingMap; |
59 |
– |
|
60 |
– |
SHAPES* SHAPES::_instance = NULL; |
53 |
|
|
54 |
< |
SHAPES* SHAPES::Instance() { |
55 |
< |
if (!_instance) { |
56 |
< |
_instance = new SHAPES(); |
57 |
< |
} |
58 |
< |
return _instance; |
54 |
> |
SHAPES::SHAPES() { |
55 |
> |
initialized_ = false; |
56 |
> |
lMax_ = 64; |
57 |
> |
mMax_ = 64; |
58 |
> |
forceField_ = NULL; |
59 |
|
} |
60 |
< |
|
60 |
> |
|
61 |
|
void SHAPES::initialize() { |
62 |
|
|
63 |
|
ForceFieldOptions& fopts = forceField_->getForceFieldOptions(); |
67 |
|
|
68 |
|
// SHAPES handles all of the SHAPES-SHAPES interactions as well as |
69 |
|
// SHAPES-LJ cross interactions: |
70 |
< |
|
70 |
> |
|
71 |
|
for (at = atomTypes->beginType(i); at != NULL; |
72 |
|
at = atomTypes->nextType(i)) { |
73 |
|
|
74 |
|
if (at->isShape() || at->isLennardJones()) |
75 |
|
addType(at); |
76 |
|
} |
77 |
< |
|
77 |
> |
|
78 |
|
initialized_ = true; |
79 |
|
} |
80 |
< |
|
80 |
> |
|
81 |
|
void SHAPES::addType(AtomType* atomType){ |
82 |
|
// add it to the map: |
83 |
|
AtomTypeProperties atp = atomType->getATP(); |
84 |
< |
|
84 |
> |
|
85 |
|
pair<map<int,AtomType*>::iterator,bool> ret; |
86 |
|
ret = ShapesMap.insert( pair<int, AtomType*>(atp.ident, atomType) ); |
87 |
|
if (ret.second == false) { |
103 |
|
simError(); |
104 |
|
} |
105 |
|
ShapesMap.insert( pair<int, ShapeAtomType*>(atp.ident, sAtomType) ); |
106 |
< |
|
106 |
> |
|
107 |
|
} else if (atomType->isLennardJones()) { |
108 |
< |
d1 = LJ::Instance()->getSigma(atomType) / sqrt(2.0); |
109 |
< |
e1 = LJ::Instance()->getEpsilon(atomType); |
108 |
> |
d1 = getLJSigma(atomType) / sqrt(2.0); |
109 |
> |
e1 = getLJEpsilon(atomType); |
110 |
|
} else { |
111 |
|
sprintf( painCave.errMsg, |
112 |
|
"SHAPES::addType was passed an atomType (%s) that does not\n" |
113 |
< |
"\tappear to be a Gay-Berne or Lennard-Jones atom.\n", |
113 |
> |
"\tappear to be a SHAPES or Lennard-Jones atom.\n", |
114 |
|
atomType->getName().c_str()); |
115 |
|
painCave.severity = OPENMD_ERROR; |
116 |
|
painCave.isFatal = 1; |
117 |
|
simError(); |
118 |
|
} |
119 |
< |
|
119 |
> |
|
120 |
|
|
121 |
|
// Now, iterate over all known types and add to the mixing map: |
122 |
|
|
135 |
|
er2 = gb2.SHAPES_eps_ratio; |
136 |
|
dw2 = gb2.SHAPES_dw; |
137 |
|
} else if (atype2->isLennardJones()) { |
138 |
< |
d2 = LJ::Instance()->getSigma(atype2) / sqrt(2.0); |
139 |
< |
e2 = LJ::Instance()->getEpsilon(atype2); |
138 |
> |
d2 = getLJSigma(atype2) / sqrt(2.0); |
139 |
> |
e2 = getLJEpsilon(atype2); |
140 |
|
l2 = d2; |
141 |
|
er2 = 1.0; |
142 |
|
dw2 = 1.0; |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
+ |
LJParam SHAPES::getLJParam(AtomType* atomType) { |
188 |
+ |
|
189 |
+ |
// Do sanity checking on the AtomType we were passed before |
190 |
+ |
// building any data structures: |
191 |
+ |
if (!atomType->isLennardJones()) { |
192 |
+ |
sprintf( painCave.errMsg, |
193 |
+ |
"SHAPES::getLJParam was passed an atomType (%s) that does not\n" |
194 |
+ |
"\tappear to be a Lennard-Jones atom.\n", |
195 |
+ |
atomType->getName().c_str()); |
196 |
+ |
painCave.severity = OPENMD_ERROR; |
197 |
+ |
painCave.isFatal = 1; |
198 |
+ |
simError(); |
199 |
+ |
} |
200 |
+ |
|
201 |
+ |
GenericData* data = atomType->getPropertyByName("LennardJones"); |
202 |
+ |
if (data == NULL) { |
203 |
+ |
sprintf( painCave.errMsg, "SHAPES::getLJParam could not find Lennard-Jones\n" |
204 |
+ |
"\tparameters for atomType %s.\n", atomType->getName().c_str()); |
205 |
+ |
painCave.severity = OPENMD_ERROR; |
206 |
+ |
painCave.isFatal = 1; |
207 |
+ |
simError(); |
208 |
+ |
} |
209 |
+ |
|
210 |
+ |
LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data); |
211 |
+ |
if (ljData == NULL) { |
212 |
+ |
sprintf( painCave.errMsg, |
213 |
+ |
"SHAPES::getLJParam could not convert GenericData to LJParam for\n" |
214 |
+ |
"\tatom type %s\n", atomType->getName().c_str()); |
215 |
+ |
painCave.severity = OPENMD_ERROR; |
216 |
+ |
painCave.isFatal = 1; |
217 |
+ |
simError(); |
218 |
+ |
} |
219 |
+ |
|
220 |
+ |
return ljData->getData(); |
221 |
+ |
} |
222 |
+ |
|
223 |
+ |
RealType SHAPES::getLJEpsilon(AtomType* atomType) { |
224 |
+ |
LJParam ljParam = getLJParam(atomType); |
225 |
+ |
return ljParam.epsilon; |
226 |
+ |
} |
227 |
+ |
RealType SHAPES::getLJSigma(AtomType* atomType) { |
228 |
+ |
LJParam ljParam = getLJParam(atomType); |
229 |
+ |
return ljParam.sigma; |
230 |
+ |
} |
231 |
+ |
|
232 |
|
RealType SHAPES::getGayBerneCut(int atid) { |
233 |
|
if (!initialized_) initialize(); |
234 |
|
std::map<int, AtomType*> :: const_iterator it; |