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> |
49 |
|
|
50 |
|
namespace OpenMD { |
51 |
|
|
52 |
< |
LJ::LJ() : name_("LJ"), initialized_(false), shiftedPot_(false), |
52 |
< |
shiftedFrc_(false), forceField_(NULL) {} |
52 |
> |
LJ::LJ() : name_("LJ"), initialized_(false), forceField_(NULL) {} |
53 |
|
|
54 |
|
LJParam LJ::getLJParam(AtomType* atomType) { |
55 |
|
|
240 |
|
} |
241 |
|
} |
242 |
|
|
243 |
< |
void LJ::calcForce(InteractionData idat) { |
243 |
> |
void LJ::calcForce(InteractionData &idat) { |
244 |
|
|
245 |
|
if (!initialized_) initialize(); |
246 |
– |
|
247 |
– |
RealType ros; |
248 |
– |
RealType rcos; |
249 |
– |
RealType myPot = 0.0; |
250 |
– |
RealType myPotC = 0.0; |
251 |
– |
RealType myDeriv = 0.0; |
252 |
– |
RealType myDerivC = 0.0; |
246 |
|
|
247 |
< |
std::pair<AtomType*, AtomType*> key = std::make_pair(idat.atype1, |
248 |
< |
idat.atype2); |
256 |
< |
LJInteractionData mixer = MixingMap[key]; |
257 |
< |
|
258 |
< |
RealType sigmai = mixer.sigmai; |
259 |
< |
RealType epsilon = mixer.epsilon; |
247 |
> |
map<pair<AtomType*, AtomType*>, LJInteractionData>::iterator it; |
248 |
> |
it = MixingMap.find( idat.atypes ); |
249 |
|
|
250 |
< |
|
251 |
< |
ros = idat.rij * sigmai; |
252 |
< |
|
253 |
< |
getLJfunc(ros, myPot, myDeriv); |
250 |
> |
if (it != MixingMap.end()) { |
251 |
> |
|
252 |
> |
LJInteractionData mixer = (*it).second; |
253 |
> |
|
254 |
> |
RealType sigmai = mixer.sigmai; |
255 |
> |
RealType epsilon = mixer.epsilon; |
256 |
> |
|
257 |
> |
RealType ros; |
258 |
> |
RealType rcos; |
259 |
> |
RealType myPot = 0.0; |
260 |
> |
RealType myPotC = 0.0; |
261 |
> |
RealType myDeriv = 0.0; |
262 |
> |
RealType myDerivC = 0.0; |
263 |
> |
|
264 |
> |
ros = *(idat.rij) * sigmai; |
265 |
> |
|
266 |
> |
getLJfunc(ros, myPot, myDeriv); |
267 |
> |
|
268 |
> |
if (idat.shiftedPot) { |
269 |
> |
rcos = *(idat.rcut) * sigmai; |
270 |
> |
getLJfunc(rcos, myPotC, myDerivC); |
271 |
> |
myDerivC = 0.0; |
272 |
> |
} else if (idat.shiftedForce) { |
273 |
> |
rcos = *(idat.rcut) * sigmai; |
274 |
> |
getLJfunc(rcos, myPotC, myDerivC); |
275 |
> |
myPotC = myPotC + myDerivC * (*(idat.rij) - *(idat.rcut)) * sigmai; |
276 |
> |
} else { |
277 |
> |
myPotC = 0.0; |
278 |
> |
myDerivC = 0.0; |
279 |
> |
} |
280 |
|
|
281 |
< |
if (shiftedPot_) { |
282 |
< |
rcos = idat.rcut * sigmai; |
283 |
< |
getLJfunc(rcos, myPotC, myDerivC); |
284 |
< |
myDerivC = 0.0; |
285 |
< |
} else if (LJ::shiftedFrc_) { |
271 |
< |
rcos = idat.rcut * sigmai; |
272 |
< |
getLJfunc(rcos, myPotC, myDerivC); |
273 |
< |
myPotC = myPotC + myDerivC * (idat.rij - idat.rcut) * sigmai; |
274 |
< |
} else { |
275 |
< |
myPotC = 0.0; |
276 |
< |
myDerivC = 0.0; |
277 |
< |
} |
281 |
> |
RealType pot_temp = *(idat.vdwMult) * epsilon * (myPot - myPotC); |
282 |
> |
*(idat.vpair) += pot_temp; |
283 |
> |
|
284 |
> |
RealType dudr = *(idat.sw) * *(idat.vdwMult) * epsilon * (myDeriv - |
285 |
> |
myDerivC)*sigmai; |
286 |
|
|
287 |
< |
RealType pot_temp = idat.vdwMult * epsilon * (myPot - myPotC); |
288 |
< |
idat.vpair += pot_temp; |
289 |
< |
|
282 |
< |
RealType dudr = idat.sw * idat.vdwMult * epsilon * (myDeriv - |
283 |
< |
myDerivC)*sigmai; |
284 |
< |
|
285 |
< |
idat.pot += idat.sw * pot_temp; |
286 |
< |
idat.f1 = idat.d * dudr / idat.rij; |
287 |
< |
|
287 |
> |
(*(idat.pot))[VANDERWAALS_FAMILY] += *(idat.sw) * pot_temp; |
288 |
> |
*(idat.f1) += *(idat.d) * dudr / *(idat.rij); |
289 |
> |
} |
290 |
|
return; |
289 |
– |
|
291 |
|
} |
292 |
|
|
293 |
|
void LJ::getLJfunc(RealType r, RealType &pot, RealType &deriv) { |
305 |
|
return; |
306 |
|
} |
307 |
|
|
308 |
+ |
RealType LJ::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) { |
309 |
+ |
if (!initialized_) initialize(); |
310 |
+ |
map<pair<AtomType*, AtomType*>, LJInteractionData>::iterator it; |
311 |
+ |
it = MixingMap.find(atypes); |
312 |
+ |
if (it == MixingMap.end()) |
313 |
+ |
return 0.0; |
314 |
+ |
else { |
315 |
+ |
LJInteractionData mixer = (*it).second; |
316 |
+ |
return 2.5 * mixer.sigma; |
317 |
+ |
} |
318 |
+ |
} |
319 |
|
|
320 |
|
} |