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 1587 by gezelter, Fri Jul 8 20:25:32 2011 UTC

# Line 239 | Line 239 | namespace OpenMD {
239        mixer.eps0 = sqrt(e1 * e2);
240        
241        RealType er = sqrt(er1 * er2);
242 <      RealType ermu = pow(er,(1.0 / mu_));
242 >      RealType ermu = pow(er, (1.0 / mu_));
243        RealType xp = (1.0 - ermu) / (1.0 + ermu);
244        RealType ap2 = 1.0 / (1.0 + ermu);
245        
246        mixer.xp2 = xp * xp;
247        mixer.xpap2 = xp * ap2;
248        mixer.xpapi2 = xp / ap2;
249 +
250 +      cerr << "mixer" << er1 << " " << er2 << " " << mu_ << " " << ermu << " " << xp <<" " << ap2 << "\n";
251  
252        // only add this pairing if at least one of the atoms is a Gay-Berne atom
253  
# Line 263 | Line 265 | namespace OpenMD {
265      }      
266    }
267    
268 <  void GB::calcForce(InteractionData idat) {
268 >  void GB::calcForce(InteractionData &idat) {
269  
270      if (!initialized_) initialize();
271      
272 <    pair<AtomType*, AtomType*> key = make_pair(idat.atype1, idat.atype2);
271 <    GBInteractionData mixer = MixingMap[key];
272 >    GBInteractionData mixer = MixingMap[idat.atypes];
273  
274      RealType sigma0 = mixer.sigma0;
275      RealType dw     = mixer.dw;
# Line 280 | Line 281 | namespace OpenMD {
281      RealType xpap2  = mixer.xpap2;
282      RealType xpapi2 = mixer.xpapi2;
283  
284 <    Vector3d ul1 = idat.A1.getRow(2);
285 <    Vector3d ul2 = idat.A2.getRow(2);
284 >    Vector3d ul1 = idat.A1->getRow(2);
285 >    Vector3d ul2 = idat.A2->getRow(2);
286  
287      RealType a, b, g;
288  
289 <    bool i_is_LJ = idat.atype1->isLennardJones();
290 <    bool j_is_LJ = idat.atype2->isLennardJones();
291 <
289 >    bool i_is_LJ = idat.atypes.first->isLennardJones();
290 >    bool j_is_LJ = idat.atypes.second->isLennardJones();
291 >    
292      if (i_is_LJ) {
293        a = 0.0;
294        ul1 = V3Zero;
295      } else {
296 <      a = dot(idat.d, ul1);
296 >      a = dot(*(idat.d), ul1);
297      }
298  
299      if (j_is_LJ) {
300        b = 0.0;
301        ul2 = V3Zero;
302      } else {
303 <      b = dot(idat.d, ul2);
303 >      b = dot(*(idat.d), ul2);
304      }
305  
306      if (i_is_LJ || j_is_LJ)
# Line 307 | Line 308 | namespace OpenMD {
308      else
309        g = dot(ul1, ul2);
310  
311 <    RealType au = a / idat.rij;
312 <    RealType bu = b / idat.rij;
311 >    cerr << "in GB, d = " << *(idat.d) << "\n";
312 >    cerr << "abg = " << a << " " << b << " " << g <<"\n";
313 >
314 >    RealType au = a / *(idat.rij);
315 >    RealType bu = b / *(idat.rij);
316      
317      RealType au2 = au * au;
318      RealType bu2 = bu * bu;
# Line 316 | Line 320 | namespace OpenMD {
320      
321      RealType H  = (xa2 * au2 + xai2 * bu2 - 2.0*x2*au*bu*g)  / (1.0 - x2*g2);
322      RealType Hp = (xpap2*au2 + xpapi2*bu2 - 2.0*xp2*au*bu*g) / (1.0 - xp2*g2);
323 +    cerr << "xa2, xai2 " << xa2 << " " << xai2 << "\n";
324 +    cerr << "xpap2, xpapi2 " << xpap2 << " " << xpapi2 << "\n";
325 +    cerr << "H Hp = " << H <<  " " << Hp << "\n";
326  
327      RealType sigma = sigma0 / sqrt(1.0 - H);
328      RealType e1 = 1.0 / sqrt(1.0 - x2*g2);
329      RealType e2 = 1.0 - Hp;
330      RealType eps = eps0 * pow(e1,nu_) * pow(e2,mu_);
331 <    RealType BigR = dw*sigma0 / (idat.rij - sigma + dw*sigma0);
331 >    cerr << "eps = " << eps0 << " " << e1 << " " << nu_ << " " << e2 << " " << mu_ << "\n";
332 >    RealType BigR = dw*sigma0 / (*(idat.rij) - sigma + dw*sigma0);
333      
334      RealType R3 = BigR*BigR*BigR;
335      RealType R6 = R3*R3;
# Line 329 | Line 337 | namespace OpenMD {
337      RealType R12 = R6*R6;
338      RealType R13 = R6*R7;
339  
340 <    RealType U = idat.vdwMult * 4.0 * eps * (R12 - R6);
340 >    RealType U = *(idat.vdwMult) * 4.0 * eps * (R12 - R6);
341  
342 +    cerr << "R12, R6, eps = " << R12 << " " << R6 << " " << eps << " " <<  *(idat.vdwMult) << "\n";
343 +
344      RealType s3 = sigma*sigma*sigma;
345      RealType s03 = sigma0*sigma0*sigma0;
346  
347 <    RealType pref1 = - idat.vdwMult * 8.0 * eps * mu_ * (R12 - R6) / (e2 * idat.rij);
347 >    RealType pref1 = - *(idat.vdwMult) * 8.0 * eps * mu_ * (R12 - R6) /
348 >      (e2 * *(idat.rij));
349  
350 <    RealType pref2 = idat.vdwMult * 8.0 * eps * s3 * (6.0*R13 - 3.0*R7) /(dw*idat.rij*s03);
350 >    RealType pref2 = *(idat.vdwMult) * 8.0 * eps * s3 * (6.0*R13 - 3.0*R7) /
351 >      (dw*  *(idat.rij) * s03);
352  
353 <    RealType dUdr = - (pref1 * Hp + pref2 * (sigma0*sigma0*idat.rij/s3 + H));
353 >    RealType dUdr = - (pref1 * Hp + pref2 * (sigma0 * sigma0 *  
354 >                                             *(idat.rij) / s3 + H));
355      
356      RealType dUda = pref1 * (xpap2*au - xp2*bu*g) / (1.0 - xp2 * g2)
357        + pref2 * (xa2 * au - x2 *bu*g) / (1.0 - x2 * g2);
# Line 350 | Line 363 | namespace OpenMD {
363        + 8.0 * eps * mu_ * (R12 - R6) * (xp2*au*bu - Hp*xp2*g) /
364        (1.0 - xp2 * g2) / e2 + 8.0 * eps * s3 * (3.0 * R7 - 6.0 * R13) *
365        (x2 * au * bu - H * x2 * g) / (1.0 - x2 * g2) / (dw * s03);
353    
366  
367 <    Vector3d rhat = idat.d / idat.rij;  
368 <    Vector3d rxu1 = cross(idat.d, ul1);
369 <    Vector3d rxu2 = cross(idat.d, ul2);
367 >    cerr << pref1 << " " << pref2 << " " << dUdr <<" " << dUda << " " << dUdb << dUdg << "\n";
368 >
369 >    Vector3d rhat = *(idat.d) / *(idat.rij);  
370 >    Vector3d rxu1 = cross(*(idat.d), ul1);
371 >    Vector3d rxu2 = cross(*(idat.d), ul2);
372      Vector3d uxu = cross(ul1, ul2);
373 +
374 +    cerr << "U = " << U << "\n";
375 +    cerr << "f1 = " << dUdr * rhat + dUda * ul1 + dUdb * ul2 << "\n";
376 +    cerr << "t1 = " << dUda * rxu1 - dUdg * uxu << "\n";
377 +    cerr << "t2 = " << dUdb * rxu2 - dUdg * uxu << "\n";
378 +
379      
380 <    idat.pot += U*idat.sw;
381 <    idat.f1 += dUdr * rhat + dUda * ul1 + dUdb * ul2;    
382 <    idat.t1 += dUda * rxu1 - dUdg * uxu;
383 <    idat.t2 += dUdb * rxu2 - dUdg * uxu;
384 <    idat.vpair += U*idat.sw;
380 >    (*(idat.pot))[VANDERWAALS_FAMILY] += U *  *(idat.sw);
381 >    *(idat.f1) += dUdr * rhat + dUda * ul1 + dUdb * ul2;    
382 >    *(idat.t1) += dUda * rxu1 - dUdg * uxu;
383 >    *(idat.t2) += dUdb * rxu2 - dUdg * uxu;
384 >    *(idat.vpair) += U * *(idat.sw);
385  
386      return;
387  
388    }
389  
390 <  RealType GB::getSuggestedCutoffRadius(AtomType* at1, AtomType* at2) {
390 >  RealType GB::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) {
391      if (!initialized_) initialize();  
392  
393      RealType cut = 0.0;
394  
395 <    if (at1->isGayBerne()) {
396 <      GayBerneParam gb1 = getGayBerneParam(at1);
395 >    if (atypes.first->isGayBerne()) {
396 >      GayBerneParam gb1 = getGayBerneParam(atypes.first);
397        RealType d1 = gb1.GB_d;
398        RealType l1 = gb1.GB_l;
399        // sigma is actually sqrt(2)*l  for prolate ellipsoids
400        cut = max(cut, 2.5 * sqrt(2.0) * max(d1, l1));
401 <    } else if (at1->isLennardJones()) {
402 <      cut = max(cut, 2.5 * getLJSigma(at1));
401 >    } else if (atypes.first->isLennardJones()) {
402 >      cut = max(cut, 2.5 * getLJSigma(atypes.first));
403      }
404  
405 <    if (at2->isGayBerne()) {
406 <      GayBerneParam gb2 = getGayBerneParam(at2);
405 >    if (atypes.second->isGayBerne()) {
406 >      GayBerneParam gb2 = getGayBerneParam(atypes.second);
407        RealType d2 = gb2.GB_d;
408        RealType l2 = gb2.GB_l;
409        cut = max(cut, 2.5 * sqrt(2.0) * max(d2, l2));
410 <    } else if (at1->isLennardJones()) {
411 <      cut = max(cut, 2.5 * getLJSigma(at2));
410 >    } else if (atypes.second->isLennardJones()) {
411 >      cut = max(cut, 2.5 * getLJSigma(atypes.second));
412      }
413    
414      return cut;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines