ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/nonbonded/LJ.cpp
(Generate patch)

Comparing branches/development/src/nonbonded/LJ.cpp (file contents):
Revision 1502 by gezelter, Sat Oct 2 19:53:32 2010 UTC vs.
Revision 1505 by gezelter, Sun Oct 3 22:18:59 2010 UTC

# Line 244 | Line 244 | namespace OpenMD {
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;
253 <
254 <    std::pair<AtomType*, AtomType*> key = std::make_pair(idat.atype1,
255 <                                                         idat.atype2);
256 <    LJInteractionData mixer = MixingMap[key];
257 <
258 <    RealType sigmai = mixer.sigmai;
259 <    RealType epsilon = mixer.epsilon;
247 >    pair<AtomType*, AtomType*> key = make_pair(idat.atype1, idat.atype2);
248 >    map<pair<AtomType*, AtomType*>, LJInteractionData>::iterator it;
249 >    it = MixingMap.find(key);
250      
251 <
252 <    ros = idat.rij * sigmai;
253 <
254 <    getLJfunc(ros, myPot, myDeriv);
251 >    if (it != MixingMap.end())  {
252 >      
253 >      LJInteractionData mixer = (*it).second;
254 >      
255 >      RealType sigmai = mixer.sigmai;
256 >      RealType epsilon = mixer.epsilon;
257 >      
258 >      RealType ros;
259 >      RealType rcos;
260 >      RealType myPot = 0.0;
261 >      RealType myPotC = 0.0;
262 >      RealType myDeriv = 0.0;
263 >      RealType myDerivC = 0.0;
264 >    
265 >      ros = idat.rij * sigmai;
266 >      
267 >      getLJfunc(ros, myPot, myDeriv);
268 >      
269 >      if (shiftedPot_) {
270 >        rcos = idat.rcut * sigmai;
271 >        getLJfunc(rcos, myPotC, myDerivC);
272 >        myDerivC = 0.0;
273 >      } else if (LJ::shiftedFrc_) {
274 >        rcos = idat.rcut * sigmai;
275 >        getLJfunc(rcos, myPotC, myDerivC);
276 >        myPotC = myPotC + myDerivC * (idat.rij - idat.rcut) * sigmai;
277 >      } else {
278 >        myPotC = 0.0;
279 >        myDerivC = 0.0;        
280 >      }
281  
282 <    if (shiftedPot_) {
283 <      rcos = idat.rcut * sigmai;
284 <      getLJfunc(rcos, myPotC, myDerivC);
285 <      myDerivC = 0.0;
286 <    } else if (LJ::shiftedFrc_) {
287 <      rcos = idat.rcut * sigmai;
288 <      getLJfunc(rcos, myPotC, myDerivC);
289 <      myPotC = myPotC + myDerivC * (idat.rij - idat.rcut) * sigmai;
290 <    } else {
275 <      myPotC = 0.0;
276 <      myDerivC = 0.0;
282 >      RealType pot_temp = idat.vdwMult * epsilon * (myPot - myPotC);
283 >      idat.vpair += pot_temp;
284 >      
285 >      RealType dudr = idat.sw * idat.vdwMult * epsilon * (myDeriv -
286 >                                                          myDerivC)*sigmai;
287 >      
288 >      idat.pot += idat.sw * pot_temp;
289 >      idat.f1 = idat.d * dudr / idat.rij;
290 >      
291      }
278
279    RealType pot_temp = idat.vdwMult * epsilon * (myPot - myPotC);
280    idat.vpair += pot_temp;
281
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
292      return;
289
293    }
294    
295    void LJ::getLJfunc(RealType r, RealType &pot, RealType &deriv) {
# Line 304 | Line 307 | namespace OpenMD {
307      return;
308    }
309    
310 +  RealType LJ::getSuggestedCutoffRadius(AtomType* at1, AtomType* at2) {
311 +    if (!initialized_) initialize();  
312 +    pair<AtomType*, AtomType*> key = make_pair(at1, at2);
313 +    map<pair<AtomType*, AtomType*>, LJInteractionData>::iterator it;
314 +    it = MixingMap.find(key);
315 +    if (it == MixingMap.end())
316 +      return 0.0;
317 +    else  {
318 +      LJInteractionData mixer = (*it).second;
319 +      return 2.5 * mixer.sigma;
320 +    }
321 +  }
322  
323   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines