35 |
|
* |
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). |
38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
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 "nonbonded/InteractionManager.hpp" |
52 |
|
gb_ = new GB(); |
53 |
|
sticky_ = new Sticky(); |
54 |
|
morse_ = new Morse(); |
55 |
+ |
repulsivePower_ = new RepulsivePower(); |
56 |
|
eam_ = new EAM(); |
57 |
|
sc_ = new SC(); |
58 |
|
electrostatic_ = new Electrostatic(); |
59 |
|
maw_ = new MAW(); |
60 |
|
} |
61 |
|
|
62 |
+ |
InteractionManager::~InteractionManager() { |
63 |
+ |
delete lj_; |
64 |
+ |
delete gb_; |
65 |
+ |
delete sticky_; |
66 |
+ |
delete morse_; |
67 |
+ |
delete repulsivePower_; |
68 |
+ |
delete eam_; |
69 |
+ |
delete sc_; |
70 |
+ |
delete electrostatic_; |
71 |
+ |
delete maw_; |
72 |
+ |
} |
73 |
+ |
|
74 |
|
void InteractionManager::initialize() { |
75 |
< |
|
75 |
> |
|
76 |
> |
if (initialized_) return; |
77 |
> |
|
78 |
|
ForceField* forceField_ = info_->getForceField(); |
79 |
|
|
80 |
|
lj_->setForceField(forceField_); |
86 |
|
electrostatic_->setSimInfo(info_); |
87 |
|
electrostatic_->setForceField(forceField_); |
88 |
|
maw_->setForceField(forceField_); |
89 |
+ |
repulsivePower_->setForceField(forceField_); |
90 |
|
|
91 |
|
ForceField::AtomTypeContainer* atomTypes = forceField_->getAtomTypes(); |
92 |
|
ForceField::AtomTypeContainer::MapTypeIterator i1, i2; |
93 |
|
AtomType* atype1; |
94 |
|
AtomType* atype2; |
95 |
|
pair<AtomType*, AtomType*> key; |
79 |
– |
pair<set<NonBondedInteraction*>::iterator, bool> ret; |
96 |
|
|
97 |
|
for (atype1 = atomTypes->beginType(i1); atype1 != NULL; |
98 |
|
atype1 = atomTypes->nextType(i1)) { |
99 |
|
|
100 |
|
// add it to the map: |
85 |
– |
AtomTypeProperties atp = atype1->getATP(); |
101 |
|
|
102 |
|
pair<map<int,AtomType*>::iterator,bool> ret; |
103 |
< |
ret = typeMap_.insert( pair<int, AtomType*>(atp.ident, atype1) ); |
103 |
> |
ret = typeMap_.insert( pair<int, AtomType*>(atype1->getIdent(), atype1) ); |
104 |
|
if (ret.second == false) { |
105 |
|
sprintf( painCave.errMsg, |
106 |
|
"InteractionManager already had a previous entry with ident %d\n", |
107 |
< |
atp.ident); |
107 |
> |
atype1->getIdent()); |
108 |
|
painCave.severity = OPENMD_INFO; |
109 |
|
painCave.isFatal = 0; |
110 |
|
simError(); |
119 |
|
|
120 |
|
for( it2 = typeMap_.begin(); it2 != typeMap_.end(); ++it2) { |
121 |
|
atype2 = (*it2).second; |
122 |
< |
|
108 |
< |
bool vdwExplicit = false; |
109 |
< |
bool metExplicit = false; |
110 |
< |
bool hbExplicit = false; |
111 |
< |
|
122 |
> |
|
123 |
|
key = make_pair(atype1, atype2); |
124 |
|
|
125 |
|
if (atype1->isLennardJones() && atype2->isLennardJones()) { |
154 |
|
|
155 |
|
if (nbiType != NULL) { |
156 |
|
|
157 |
+ |
bool vdwExplicit = false; |
158 |
+ |
bool metExplicit = false; |
159 |
+ |
// bool hbExplicit = false; |
160 |
+ |
|
161 |
|
if (nbiType->isLennardJones()) { |
162 |
|
// We found an explicit Lennard-Jones interaction. |
163 |
|
// override all other vdw entries for this pair of atom types: |
191 |
|
if (ifam == VANDERWAALS_FAMILY) interactions_[key].erase(*it); |
192 |
|
} |
193 |
|
interactions_[key].insert(morse_); |
194 |
+ |
vdwExplicit = true; |
195 |
+ |
} |
196 |
+ |
|
197 |
+ |
if (nbiType->isRepulsivePower()) { |
198 |
+ |
if (vdwExplicit) { |
199 |
+ |
sprintf( painCave.errMsg, |
200 |
+ |
"InteractionManager::initialize found more than one " |
201 |
+ |
"explicit \n" |
202 |
+ |
"\tvan der Waals interaction for atom types %s - %s\n", |
203 |
+ |
atype1->getName().c_str(), atype2->getName().c_str()); |
204 |
+ |
painCave.severity = OPENMD_ERROR; |
205 |
+ |
painCave.isFatal = 1; |
206 |
+ |
simError(); |
207 |
+ |
} |
208 |
+ |
// We found an explicit RepulsivePower interaction. |
209 |
+ |
// override all other vdw entries for this pair of atom types: |
210 |
+ |
set<NonBondedInteraction*>::iterator it; |
211 |
+ |
for (it = interactions_[key].begin(); |
212 |
+ |
it != interactions_[key].end(); ++it) { |
213 |
+ |
InteractionFamily ifam = (*it)->getFamily(); |
214 |
+ |
if (ifam == VANDERWAALS_FAMILY) interactions_[key].erase(*it); |
215 |
+ |
} |
216 |
+ |
interactions_[key].insert(repulsivePower_); |
217 |
|
vdwExplicit = true; |
218 |
|
} |
219 |
|
|
220 |
+ |
|
221 |
|
if (nbiType->isEAM()) { |
222 |
|
// We found an explicit EAM interaction. |
223 |
|
// override all other metallic entries for this pair of atom types: |
310 |
|
} |
311 |
|
|
312 |
|
void InteractionManager::setCutoffRadius(RealType rcut) { |
313 |
+ |
|
314 |
|
electrostatic_->setCutoffRadius(rcut); |
315 |
|
eam_->setCutoffRadius(rcut); |
316 |
|
} |
317 |
|
|
278 |
– |
void InteractionManager::setSwitchingRadius(RealType rswitch) { |
279 |
– |
electrostatic_->setSwitchingRadius(rswitch); |
280 |
– |
} |
281 |
– |
|
318 |
|
void InteractionManager::doPrePair(InteractionData idat){ |
319 |
|
|
320 |
|
if (!initialized_) initialize(); |
321 |
|
|
322 |
+ |
// excluded interaction, so just return |
323 |
+ |
if (idat.excluded) return; |
324 |
+ |
|
325 |
|
set<NonBondedInteraction*>::iterator it; |
326 |
|
|
327 |
|
for (it = interactions_[ idat.atypes ].begin(); |
353 |
|
void InteractionManager::doPair(InteractionData idat){ |
354 |
|
|
355 |
|
if (!initialized_) initialize(); |
356 |
< |
|
356 |
> |
|
357 |
|
set<NonBondedInteraction*>::iterator it; |
358 |
|
|
359 |
|
for (it = interactions_[ idat.atypes ].begin(); |
360 |
< |
it != interactions_[ idat.atypes ].end(); ++it) |
322 |
< |
(*it)->calcForce(idat); |
323 |
< |
|
324 |
< |
return; |
325 |
< |
} |
360 |
> |
it != interactions_[ idat.atypes ].end(); ++it) { |
361 |
|
|
362 |
< |
void InteractionManager::doSkipCorrection(InteractionData idat){ |
362 |
> |
// electrostatics still has to worry about indirect |
363 |
> |
// contributions from excluded pairs of atoms: |
364 |
|
|
365 |
< |
if (!initialized_) initialize(); |
366 |
< |
|
331 |
< |
set<NonBondedInteraction*>::iterator it; |
332 |
< |
|
333 |
< |
for (it = interactions_[ idat.atypes ].begin(); |
334 |
< |
it != interactions_[ idat.atypes ].end(); ++it){ |
335 |
< |
if ((*it)->getFamily() == ELECTROSTATIC_FAMILY) { |
336 |
< |
dynamic_cast<ElectrostaticInteraction*>(*it)->calcSkipCorrection(idat); |
365 |
> |
if (!idat.excluded || (*it)->getFamily() == ELECTROSTATIC_FAMILY) { |
366 |
> |
(*it)->calcForce(idat); |
367 |
|
} |
368 |
|
} |
369 |
|
|
388 |
|
|
389 |
|
RealType InteractionManager::getSuggestedCutoffRadius(int *atid) { |
390 |
|
if (!initialized_) initialize(); |
391 |
< |
|
391 |
> |
|
392 |
|
AtomType* atype = typeMap_[*atid]; |
393 |
|
|
394 |
|
pair<AtomType*, AtomType*> key = make_pair(atype, atype); |