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

Comparing branches/development/src/nonbonded/GB.cpp (file contents):
Revision 1505 by gezelter, Sun Oct 3 22:18:59 2010 UTC vs.
Revision 1554 by gezelter, Sat Apr 30 02:54:02 2011 UTC

# Line 263 | Line 263 | namespace OpenMD {
263      }      
264    }
265    
266 <  void GB::calcForce(InteractionData idat) {
266 >  void GB::calcForce(InteractionData &idat) {
267  
268      if (!initialized_) initialize();
269      
270 <    pair<AtomType*, AtomType*> key = make_pair(idat.atype1, idat.atype2);
271 <    GBInteractionData mixer = MixingMap[key];
270 >    GBInteractionData mixer = MixingMap[*(idat.atypes)];
271  
272      RealType sigma0 = mixer.sigma0;
273      RealType dw     = mixer.dw;
# Line 280 | Line 279 | namespace OpenMD {
279      RealType xpap2  = mixer.xpap2;
280      RealType xpapi2 = mixer.xpapi2;
281  
282 <    Vector3d ul1 = idat.A1.getRow(2);
283 <    Vector3d ul2 = idat.A2.getRow(2);
282 >    Vector3d ul1 = idat.A1->getRow(2);
283 >    Vector3d ul2 = idat.A2->getRow(2);
284  
285      RealType a, b, g;
286  
287 <    bool i_is_LJ = idat.atype1->isLennardJones();
288 <    bool j_is_LJ = idat.atype2->isLennardJones();
289 <
287 >    bool i_is_LJ = idat.atypes->first->isLennardJones();
288 >    bool j_is_LJ = idat.atypes->second->isLennardJones();
289 >    
290      if (i_is_LJ) {
291        a = 0.0;
292        ul1 = V3Zero;
293      } else {
294 <      a = dot(idat.d, ul1);
294 >      a = dot(*(idat.d), ul1);
295      }
296  
297      if (j_is_LJ) {
298        b = 0.0;
299        ul2 = V3Zero;
300      } else {
301 <      b = dot(idat.d, ul2);
301 >      b = dot(*(idat.d), ul2);
302      }
303  
304      if (i_is_LJ || j_is_LJ)
# Line 307 | Line 306 | namespace OpenMD {
306      else
307        g = dot(ul1, ul2);
308  
309 <    RealType au = a / idat.rij;
310 <    RealType bu = b / idat.rij;
309 >    RealType au = a / *(idat.rij);
310 >    RealType bu = b / *(idat.rij);
311      
312      RealType au2 = au * au;
313      RealType bu2 = bu * bu;
# Line 321 | Line 320 | namespace OpenMD {
320      RealType e1 = 1.0 / sqrt(1.0 - x2*g2);
321      RealType e2 = 1.0 - Hp;
322      RealType eps = eps0 * pow(e1,nu_) * pow(e2,mu_);
323 <    RealType BigR = dw*sigma0 / (idat.rij - sigma + dw*sigma0);
323 >    RealType BigR = dw*sigma0 / (*(idat.rij) - sigma + dw*sigma0);
324      
325      RealType R3 = BigR*BigR*BigR;
326      RealType R6 = R3*R3;
# Line 329 | Line 328 | namespace OpenMD {
328      RealType R12 = R6*R6;
329      RealType R13 = R6*R7;
330  
331 <    RealType U = idat.vdwMult * 4.0 * eps * (R12 - R6);
331 >    RealType U = *(idat.vdwMult) * 4.0 * eps * (R12 - R6);
332  
333      RealType s3 = sigma*sigma*sigma;
334      RealType s03 = sigma0*sigma0*sigma0;
335  
336 <    RealType pref1 = - idat.vdwMult * 8.0 * eps * mu_ * (R12 - R6) / (e2 * idat.rij);
336 >    RealType pref1 = - *(idat.vdwMult) * 8.0 * eps * mu_ * (R12 - R6) /
337 >      (e2 * *(idat.rij));
338  
339 <    RealType pref2 = idat.vdwMult * 8.0 * eps * s3 * (6.0*R13 - 3.0*R7) /(dw*idat.rij*s03);
339 >    RealType pref2 = *(idat.vdwMult) * 8.0 * eps * s3 * (6.0*R13 - 3.0*R7) /
340 >      (dw*  *(idat.rij) * s03);
341  
342 <    RealType dUdr = - (pref1 * Hp + pref2 * (sigma0*sigma0*idat.rij/s3 + H));
342 >    RealType dUdr = - (pref1 * Hp + pref2 * (sigma0 * sigma0 *  
343 >                                             *(idat.rij) / s3 + H));
344      
345      RealType dUda = pref1 * (xpap2*au - xp2*bu*g) / (1.0 - xp2 * g2)
346        + pref2 * (xa2 * au - x2 *bu*g) / (1.0 - x2 * g2);
# Line 352 | Line 354 | namespace OpenMD {
354        (x2 * au * bu - H * x2 * g) / (1.0 - x2 * g2) / (dw * s03);
355      
356  
357 <    Vector3d rhat = idat.d / idat.rij;  
358 <    Vector3d rxu1 = cross(idat.d, ul1);
359 <    Vector3d rxu2 = cross(idat.d, ul2);
357 >    Vector3d rhat = *(idat.d) / *(idat.rij);  
358 >    Vector3d rxu1 = cross(*(idat.d), ul1);
359 >    Vector3d rxu2 = cross(*(idat.d), ul2);
360      Vector3d uxu = cross(ul1, ul2);
361      
362 <    idat.pot += U*idat.sw;
363 <    idat.f1 += dUdr * rhat + dUda * ul1 + dUdb * ul2;    
364 <    idat.t1 += dUda * rxu1 - dUdg * uxu;
365 <    idat.t2 += dUdb * rxu2 - dUdg * uxu;
366 <    idat.vpair += U*idat.sw;
362 >    idat.pot[VANDERWAALS_FAMILY] += U *  *(idat.sw);
363 >    *(idat.f1) += dUdr * rhat + dUda * ul1 + dUdb * ul2;    
364 >    *(idat.t1) += dUda * rxu1 - dUdg * uxu;
365 >    *(idat.t2) += dUdb * rxu2 - dUdg * uxu;
366 >    *(idat.vpair) += U * *(idat.sw);
367  
368      return;
369  
370    }
371  
372 <  RealType GB::getSuggestedCutoffRadius(AtomType* at1, AtomType* at2) {
372 >  RealType GB::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) {
373      if (!initialized_) initialize();  
374  
375      RealType cut = 0.0;
376  
377 <    if (at1->isGayBerne()) {
378 <      GayBerneParam gb1 = getGayBerneParam(at1);
377 >    if (atypes.first->isGayBerne()) {
378 >      GayBerneParam gb1 = getGayBerneParam(atypes.first);
379        RealType d1 = gb1.GB_d;
380        RealType l1 = gb1.GB_l;
381        // sigma is actually sqrt(2)*l  for prolate ellipsoids
382        cut = max(cut, 2.5 * sqrt(2.0) * max(d1, l1));
383 <    } else if (at1->isLennardJones()) {
384 <      cut = max(cut, 2.5 * getLJSigma(at1));
383 >    } else if (atypes.first->isLennardJones()) {
384 >      cut = max(cut, 2.5 * getLJSigma(atypes.first));
385      }
386  
387 <    if (at2->isGayBerne()) {
388 <      GayBerneParam gb2 = getGayBerneParam(at2);
387 >    if (atypes.second->isGayBerne()) {
388 >      GayBerneParam gb2 = getGayBerneParam(atypes.second);
389        RealType d2 = gb2.GB_d;
390        RealType l2 = gb2.GB_l;
391        cut = max(cut, 2.5 * sqrt(2.0) * max(d2, l2));
392 <    } else if (at1->isLennardJones()) {
393 <      cut = max(cut, 2.5 * getLJSigma(at2));
392 >    } else if (atypes.second->isLennardJones()) {
393 >      cut = max(cut, 2.5 * getLJSigma(atypes.second));
394      }
395    
396      return cut;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines