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 1579 by gezelter, Thu Jun 9 20:26:29 2011 UTC

# Line 240 | Line 240 | namespace OpenMD {
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;
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 >    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 >      cerr << "ros = " << ros << "\n";
267 >      
268 >      getLJfunc(ros, myPot, myDeriv);
269 >      
270 >      if (shiftedPot_) {
271 >        rcos = *(idat.rcut) * sigmai;
272 >        getLJfunc(rcos, myPotC, myDerivC);
273 >        myDerivC = 0.0;
274 >      } else if (LJ::shiftedFrc_) {
275 >        rcos = *(idat.rcut) * sigmai;
276 >        getLJfunc(rcos, myPotC, myDerivC);
277 >        myPotC = myPotC + myDerivC * (*(idat.rij) - *(idat.rcut)) * sigmai;
278 >      } else {
279 >        myPotC = 0.0;
280 >        myDerivC = 0.0;        
281 >      }
282  
283 <    if (shiftedPot_) {
284 <      rcos = idat.rcut * sigmai;
285 <      getLJfunc(rcos, myPotC, myDerivC);
286 <      myDerivC = 0.0;
287 <    } else if (LJ::shiftedFrc_) {
288 <      rcos = idat.rcut * sigmai;
289 <      getLJfunc(rcos, myPotC, myDerivC);
290 <      myPotC = myPotC + myDerivC * (idat.rij - idat.rcut) * sigmai;
291 <    } else {
292 <      myPotC = 0.0;
293 <      myDerivC = 0.0;
283 >      cerr << "myPot =  " << myPot << "\n";
284 >      cerr << "myPotC =  " << myPotC << "\n";
285 >      cerr << "epsilon =  " << epsilon << "\n";
286 >      cerr << "vdwm =  " << *(idat.vdwMult) << "\n";
287 >      RealType pot_temp = *(idat.vdwMult) * epsilon * (myPot - myPotC);
288 >      *(idat.vpair) += pot_temp;
289 >      
290 >      RealType dudr = *(idat.sw) * *(idat.vdwMult) * epsilon * (myDeriv -
291 >                                                             myDerivC)*sigmai;
292 >      
293 >      (idat.pot)[VANDERWAALS_FAMILY] += *(idat.sw) * pot_temp;
294 >      *(idat.f1) = *(idat.d) * dudr / *(idat.rij);
295      }
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
296      return;
289
297    }
298    
299    void LJ::getLJfunc(RealType r, RealType &pot, RealType &deriv) {
# Line 304 | Line 311 | namespace OpenMD {
311      return;
312    }
313    
314 +  RealType LJ::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) {
315 +    if (!initialized_) initialize();  
316 +    map<pair<AtomType*, AtomType*>, LJInteractionData>::iterator it;
317 +    it = MixingMap.find(atypes);
318 +    if (it == MixingMap.end())
319 +      return 0.0;
320 +    else  {
321 +      LJInteractionData mixer = (*it).second;
322 +      return 2.5 * mixer.sigma;
323 +    }
324 +  }
325  
326   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines