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 |
|
#include <stdio.h> |
46 |
|
#include <cmath> |
47 |
|
#include "nonbonded/LJ.hpp" |
48 |
|
#include "utils/simError.h" |
49 |
+ |
#include "types/LennardJonesInteractionType.hpp" |
50 |
|
|
51 |
|
namespace OpenMD { |
52 |
|
|
125 |
|
|
126 |
|
for (at = atomTypes->beginType(i); at != NULL; |
127 |
|
at = atomTypes->nextType(i)) { |
128 |
< |
|
129 |
< |
if (at->isLennardJones()) |
130 |
< |
addType(at); |
128 |
> |
if (at->isLennardJones()){ |
129 |
> |
addType(at); |
130 |
> |
} |
131 |
|
} |
130 |
– |
|
132 |
|
ForceField::NonBondedInteractionTypeContainer* nbiTypes = forceField_->getNonBondedInteractionTypes(); |
133 |
|
ForceField::NonBondedInteractionTypeContainer::MapTypeIterator j; |
134 |
|
NonBondedInteractionType* nbt; |
135 |
+ |
ForceField::NonBondedInteractionTypeContainer::KeyType keys; |
136 |
|
|
137 |
+ |
|
138 |
|
for (nbt = nbiTypes->beginType(j); nbt != NULL; |
139 |
|
nbt = nbiTypes->nextType(j)) { |
140 |
< |
|
140 |
> |
|
141 |
|
if (nbt->isLennardJones()) { |
142 |
< |
|
143 |
< |
pair<AtomType*, AtomType*> atypes = nbt->getAtomTypes(); |
144 |
< |
|
145 |
< |
GenericData* data = nbt->getPropertyByName("LennardJones"); |
146 |
< |
if (data == NULL) { |
147 |
< |
sprintf( painCave.errMsg, "LJ::rebuildMixingMap could not find\n" |
148 |
< |
"\tLennard-Jones parameters for %s - %s interaction.\n", |
146 |
< |
atypes.first->getName().c_str(), |
147 |
< |
atypes.second->getName().c_str()); |
148 |
< |
painCave.severity = OPENMD_ERROR; |
149 |
< |
painCave.isFatal = 1; |
150 |
< |
simError(); |
151 |
< |
} |
152 |
< |
|
153 |
< |
LJParamGenericData* ljData = dynamic_cast<LJParamGenericData*>(data); |
154 |
< |
if (ljData == NULL) { |
142 |
> |
keys = nbiTypes->getKeys(j); |
143 |
> |
AtomType* at1 = forceField_->getAtomType(keys[0]); |
144 |
> |
AtomType* at2 = forceField_->getAtomType(keys[1]); |
145 |
> |
|
146 |
> |
LennardJonesInteractionType* ljit = dynamic_cast<LennardJonesInteractionType*>(nbt); |
147 |
> |
|
148 |
> |
if (ljit == NULL) { |
149 |
|
sprintf( painCave.errMsg, |
150 |
< |
"LJ::rebuildMixingMap could not convert GenericData to\n" |
151 |
< |
"\tLJParam for %s - %s interaction.\n", |
152 |
< |
atypes.first->getName().c_str(), |
153 |
< |
atypes.second->getName().c_str()); |
150 |
> |
"LJ::initialize could not convert NonBondedInteractionType\n" |
151 |
> |
"\tto LennardJonesInteractionType for %s - %s interaction.\n", |
152 |
> |
at1->getName().c_str(), |
153 |
> |
at2->getName().c_str()); |
154 |
|
painCave.severity = OPENMD_ERROR; |
155 |
|
painCave.isFatal = 1; |
156 |
|
simError(); |
157 |
|
} |
164 |
– |
|
165 |
– |
LJParam ljParam = ljData->getData(); |
158 |
|
|
159 |
< |
RealType sigma = ljParam.sigma; |
160 |
< |
RealType epsilon = ljParam.epsilon; |
161 |
< |
|
170 |
< |
addExplicitInteraction(atypes.first, atypes.second, sigma, epsilon); |
159 |
> |
RealType sigma = ljit->getSigma(); |
160 |
> |
RealType epsilon = ljit->getEpsilon(); |
161 |
> |
addExplicitInteraction(at1, at2, sigma, epsilon); |
162 |
|
} |
163 |
|
} |
164 |
|
initialized_ = true; |
210 |
|
|
211 |
|
void LJ::addExplicitInteraction(AtomType* atype1, AtomType* atype2, RealType sigma, RealType epsilon){ |
212 |
|
|
222 |
– |
// in case these weren't already in the map |
223 |
– |
addType(atype1); |
224 |
– |
addType(atype2); |
225 |
– |
|
213 |
|
LJInteractionData mixer; |
214 |
|
mixer.sigma = sigma; |
215 |
|
mixer.epsilon = epsilon; |
227 |
|
} |
228 |
|
|
229 |
|
void LJ::calcForce(InteractionData &idat) { |
243 |
– |
|
230 |
|
if (!initialized_) initialize(); |
245 |
– |
|
231 |
|
map<pair<AtomType*, AtomType*>, LJInteractionData>::iterator it; |
232 |
|
it = MixingMap.find( idat.atypes ); |
233 |
|
|