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 1629 by gezelter, Wed Sep 14 21:15:17 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines