107 |
|
} |
108 |
|
|
109 |
|
RealType LJ::getSigma(int atid) { |
110 |
+ |
if (!initialized_) initialize(); |
111 |
|
std::map<int, AtomType*> :: const_iterator it; |
112 |
|
it = LJMap.find(atid); |
113 |
|
if (it == LJMap.end()) { |
143 |
|
} |
144 |
|
|
145 |
|
RealType LJ::getEpsilon(int atid) { |
146 |
+ |
if (!initialized_) initialize(); |
147 |
|
std::map<int, AtomType*> :: const_iterator it; |
148 |
|
it = LJMap.find(atid); |
149 |
|
if (it == LJMap.end()) { |
230 |
|
|
231 |
|
// add it to the map: |
232 |
|
AtomTypeProperties atp = atomType->getATP(); |
233 |
< |
std::pair<std::map<int,AtomType*>::iterator,bool> ret; |
233 |
> |
|
234 |
> |
std::pair<std::map<int,AtomType*>::iterator,bool> ret; |
235 |
|
ret = LJMap.insert( std::pair<int, AtomType*>(atp.ident, atomType) ); |
236 |
|
if (ret.second == false) { |
237 |
|
sprintf( painCave.errMsg, |
288 |
|
} |
289 |
|
} |
290 |
|
|
291 |
< |
void LJ::calcForce(AtomType* at1, AtomType* at2, Vector3d d, RealType rij, |
292 |
< |
RealType r2, RealType rcut, RealType sw, RealType vdwMult, |
293 |
< |
RealType vpair, RealType pot, Vector3d f1) { |
291 |
> |
void LJ::calcForce(AtomType* at1, AtomType* at2, Vector3d d, |
292 |
> |
RealType rij, RealType r2, RealType rcut, RealType sw, |
293 |
> |
RealType vdwMult, RealType &vpair, RealType &pot, |
294 |
> |
Vector3d &f1) { |
295 |
|
|
296 |
|
if (!initialized_) initialize(); |
297 |
|
|
308 |
|
RealType sigmai = mixer.sigmai; |
309 |
|
RealType epsilon = mixer.epsilon; |
310 |
|
|
311 |
+ |
|
312 |
|
ros = rij * sigmai; |
313 |
|
|
314 |
|
getLJfunc(ros, myPot, myDeriv); |
335 |
|
f1 = d * dudr / rij; |
336 |
|
|
337 |
|
return; |
338 |
+ |
|
339 |
+ |
|
340 |
+ |
|
341 |
|
} |
342 |
|
|
343 |
|
void LJ::do_lj_pair(int *atid1, int *atid2, RealType *d, RealType *rij, |
355 |
|
|
356 |
|
calcForce(atype1, atype2, disp, *rij, *r2, *rcut, *sw, *vdwMult, *vpair, |
357 |
|
*pot, frc); |
358 |
+ |
|
359 |
+ |
f1[0] = frc.x(); |
360 |
+ |
f1[1] = frc.y(); |
361 |
+ |
f1[2] = frc.z(); |
362 |
+ |
|
363 |
|
return; |
364 |
|
} |
365 |
|
|
366 |
< |
void LJ::getLJfunc(const RealType r, RealType pot, RealType deriv) { |
366 |
> |
void LJ::getLJfunc(RealType r, RealType &pot, RealType &deriv) { |
367 |
> |
|
368 |
|
RealType ri = 1.0 / r; |
369 |
|
RealType ri2 = ri * ri; |
370 |
|
RealType ri6 = ri2 * ri2 * ri2; |
371 |
|
RealType ri7 = ri6 * ri; |
372 |
|
RealType ri12 = ri6 * ri6; |
373 |
|
RealType ri13 = ri12 * ri; |
374 |
< |
|
374 |
> |
|
375 |
|
pot = 4.0 * (ri12 - ri6); |
376 |
|
deriv = 24.0 * (ri7 - 2.0 * ri13); |
377 |
+ |
|
378 |
|
return; |
379 |
|
} |
380 |
+ |
|
381 |
|
|
366 |
– |
|
382 |
|
void LJ::setLJDefaultCutoff(RealType *thisRcut, int *sP, int *sF) { |
383 |
|
shiftedPot_ = (bool)(*sP); |
384 |
|
shiftedFrc_ = (bool)(*sF); |