--- branches/development/src/nonbonded/GB.cpp 2012/01/06 19:03:05 1668 +++ branches/development/src/nonbonded/GB.cpp 2012/03/14 17:56:01 1688 @@ -50,6 +50,42 @@ namespace OpenMD { using namespace std; namespace OpenMD { + /* GB is the Gay-Berne interaction for ellipsoidal particles. The original + * paper (for identical uniaxial particles) is: + * J. G. Gay and B. J. Berne, J. Chem. Phys., 74, 3316-3319 (1981). + * A more-general GB potential for dissimilar uniaxial particles: + * D. J. Cleaver, C. M. Care, M. P. Allen and M. P. Neal, Phys. Rev. E, + * 54, 559-567 (1996). + * Further parameterizations can be found in: + * A. P. J. Emerson, G. R. Luckhurst and S. G. Whatling, Mol. Phys., + * 82, 113-124 (1994). + * And a nice force expression: + * G. R. Luckhurst and R. A. Stephens, Liq. Cryst. 8, 451-464 (1990). + * Even clearer force and torque expressions: + * P. A. Golubkov and P. Y. Ren, J. Chem. Phys., 125, 64103 (2006). + * New expressions for cross interactions of strength parameters: + * J. Wu, X. Zhen, H. Shen, G. Li, and P. Ren, J. Chem. Phys., + * 135, 155104 (2011). + * + * In this version of the GB interaction, each uniaxial ellipsoidal type + * is described using a set of 6 parameters: + * d: range parameter for side-by-side (S) and cross (X) configurations + * l: range parameter for end-to-end (E) configuration + * epsilon_X: well-depth parameter for cross (X) configuration + * epsilon_S: well-depth parameter for side-by-side (S) configuration + * epsilon_E: well depth parameter for end-to-end (E) configuration + * dw: "softness" of the potential + * + * Additionally, there are two "universal" paramters to govern the overall + * importance of the purely orientational (nu) and the mixed + * orientational / translational (mu) parts of strength of the interactions. + * These parameters have default or "canonical" values, but may be changed + * as a force field option: + * nu_: purely orientational part : defaults to 1 + * mu_: mixed orientational / translational part : defaults to 2 + */ + + GB::GB() : name_("GB"), initialized_(false), mu_(2.0), nu_(1.0), forceField_(NULL) {} GayBerneParam GB::getGayBerneParam(AtomType* atomType) { @@ -173,20 +209,22 @@ namespace OpenMD { simError(); } - RealType d1, l1, e1, er1, dw1; + RealType d1, l1, eX1, eS1, eE1, dw1; if (atomType->isGayBerne()) { GayBerneParam gb1 = getGayBerneParam(atomType); d1 = gb1.GB_d; l1 = gb1.GB_l; - e1 = gb1.GB_eps; - er1 = gb1.GB_eps_ratio; + eX1 = gb1.GB_eps_X; + eS1 = gb1.GB_eps_S; + eE1 = gb1.GB_eps_E; dw1 = gb1.GB_dw; } else if (atomType->isLennardJones()) { d1 = getLJSigma(atomType) / sqrt(2.0); - e1 = getLJEpsilon(atomType); l1 = d1; - er1 = 1.0; + eX1 = getLJEpsilon(atomType); + eS1 = eX1; + eE1 = eX1; dw1 = 1.0; } else { sprintf( painCave.errMsg, @@ -206,50 +244,64 @@ namespace OpenMD { AtomType* atype2 = (*it).second; - RealType d2, l2, e2, er2, dw2; + RealType d2, l2, eX2, eS2, eE2, dw2; if (atype2->isGayBerne()) { GayBerneParam gb2 = getGayBerneParam(atype2); d2 = gb2.GB_d; l2 = gb2.GB_l; - e2 = gb2.GB_eps; - er2 = gb2.GB_eps_ratio; + eX2 = gb2.GB_eps_X; + eS2 = gb2.GB_eps_S; + eE2 = gb2.GB_eps_E; dw2 = gb2.GB_dw; } else if (atype2->isLennardJones()) { d2 = getLJSigma(atype2) / sqrt(2.0); - e2 = getLJEpsilon(atype2); l2 = d2; - er2 = 1.0; + eX2 = getLJEpsilon(atype2); + eS2 = eX2; + eE2 = eX2; dw2 = 1.0; } - GBInteractionData mixer; + GBInteractionData mixer1, mixer2; // Cleaver paper uses sqrt of squares to get sigma0 for // mixed interactions. - mixer.sigma0 = sqrt(d1*d1 + d2*d2); - mixer.xa2 = (l1*l1 - d1*d1)/(l1*l1 + d2*d2); - mixer.xai2 = (l2*l2 - d2*d2)/(l2*l2 + d1*d1); - mixer.x2 = (l1*l1 - d1*d1) * (l2*l2 - d2*d2) / + mixer1.sigma0 = sqrt(d1*d1 + d2*d2); + mixer1.xa2 = (l1*l1 - d1*d1)/(l1*l1 + d2*d2); + mixer1.xai2 = (l2*l2 - d2*d2)/(l2*l2 + d1*d1); + mixer1.x2 = (l1*l1 - d1*d1) * (l2*l2 - d2*d2) / ((l2*l2 + d1*d1) * (l1*l1 + d2*d2)); + + mixer2.sigma0 = mixer1.sigma0; + // xa2 and xai2 for j-i pairs are reversed from the same i-j pairing. + // Swapping the particles reverses the anisotropy parameters: + mixer2.xa2 = mixer1.xai2; + mixer2.xai2 = mixer1.xa2; + mixer2.x2 = mixer1.x2; // assumed LB mixing rules for now: - mixer.dw = 0.5 * (dw1 + dw2); - mixer.eps0 = sqrt(e1 * e2); - - RealType er = sqrt(er1 * er2); - RealType ermu = pow(er, (RealType(1.0) / mu_)); - RealType xp = (1.0 - ermu) / (1.0 + ermu); - RealType ap2 = 1.0 / (1.0 + ermu); - - mixer.xp2 = xp * xp; - mixer.xpap2 = xp * ap2; - mixer.xpapi2 = xp / ap2; + mixer1.dw = 0.5 * (dw1 + dw2); + mixer1.eps0 = sqrt(eX1 * eX2); + + mixer2.dw = mixer1.dw; + mixer2.eps0 = mixer1.eps0; - cerr << "mixer" << er1 << " " << er2 << " " << mu_ << " " << ermu << " " << xp <<" " << ap2 << "\n"; + RealType mi = RealType(1.0)/mu_; + + mixer1.xpap2 = (pow(eS1, mi) - pow(eE1, mi)) / (pow(eS1, mi) + pow(eE2, mi)); + mixer1.xpapi2 = (pow(eS2, mi) - pow(eE2, mi)) / (pow(eS2, mi) + pow(eE1, mi)); + mixer1.xp2 = (pow(eS1, mi) - pow(eE1, mi)) * (pow(eS2, mi) - pow(eE2, mi)) / + (pow(eS2, mi) + pow(eE1, mi)) / (pow(eS1, mi) + pow(eE2, mi)) ; + // xpap2 and xpapi2 for j-i pairs are reversed from the same i-j pairing. + // Swapping the particles reverses the anisotropy parameters: + mixer2.xpap2 = mixer1.xpapi2; + mixer2.xpapi2 = mixer1.xpap2; + mixer2.xp2 = mixer1.xp2; + // only add this pairing if at least one of the atoms is a Gay-Berne atom if (atomType->isGayBerne() || atype2->isGayBerne()) { @@ -258,9 +310,9 @@ namespace OpenMD { key1 = make_pair(atomType, atype2); key2 = make_pair(atype2, atomType); - MixingMap[key1] = mixer; + MixingMap[key1] = mixer1; if (key2 != key1) { - MixingMap[key2] = mixer; + MixingMap[key2] = mixer2; } } } @@ -282,9 +334,23 @@ namespace OpenMD { RealType xpap2 = mixer.xpap2; RealType xpapi2 = mixer.xpapi2; + // cerr << "atypes = " << idat.atypes.first->getName() << " " << idat.atypes.second->getName() << "\n"; + // cerr << "sigma0 = " <getRow(2); Vector3d ul2 = idat.A2->getRow(2); + // cerr << "ul1 = " <isLennardJones(); @@ -309,27 +375,26 @@ namespace OpenMD { else g = dot(ul1, ul2); - cerr << "in GB, d = " << *(idat.d) << "\n"; - cerr << "abg = " << a << " " << b << " " << g <<"\n"; - RealType au = a / *(idat.rij); RealType bu = b / *(idat.rij); RealType au2 = au * au; RealType bu2 = bu * bu; RealType g2 = g * g; - + RealType H = (xa2 * au2 + xai2 * bu2 - 2.0*x2*au*bu*g) / (1.0 - x2*g2); RealType Hp = (xpap2*au2 + xpapi2*bu2 - 2.0*xp2*au*bu*g) / (1.0 - xp2*g2); - cerr << "xa2, xai2 " << xa2 << " " << xai2 << "\n"; - cerr << "xpap2, xpapi2 " << xpap2 << " " << xpapi2 << "\n"; - cerr << "H Hp = " << H << " " << Hp << "\n"; + // cerr << "au2 = " << au2 << "\n"; + // cerr << "bu2 = " << bu2 << "\n"; + // cerr << "g2 = " << g2 << "\n"; + // cerr << "H = " << H << "\n"; + // cerr << "Hp = " << Hp << "\n"; + RealType sigma = sigma0 / sqrt(1.0 - H); RealType e1 = 1.0 / sqrt(1.0 - x2*g2); RealType e2 = 1.0 - Hp; RealType eps = eps0 * pow(e1,nu_) * pow(e2,mu_); - cerr << "eps = " << eps0 << " " << e1 << " " << nu_ << " " << e2 << " " << mu_ << "\n"; RealType BigR = dw*sigma0 / (*(idat.rij) - sigma + dw*sigma0); RealType R3 = BigR*BigR*BigR; @@ -340,11 +405,22 @@ namespace OpenMD { RealType U = *(idat.vdwMult) * 4.0 * eps * (R12 - R6); - cerr << "R12, R6, eps = " << R12 << " " << R6 << " " << eps << " " << *(idat.vdwMult) << "\n"; - RealType s3 = sigma*sigma*sigma; RealType s03 = sigma0*sigma0*sigma0; + // cerr << "vdwMult = " << *(idat.vdwMult) << "\n"; + // cerr << "eps = " << eps <<"\n"; + // cerr << "mu = " << mu_ << "\n"; + // cerr << "R12 = " << R12 << "\n"; + // cerr << "R6 = " << R6 << "\n"; + // cerr << "R13 = " << R13 << "\n"; + // cerr << "R7 = " << R7 << "\n"; + // cerr << "e2 = " << e2 << "\n"; + // cerr << "rij = " << *(idat.rij) << "\n"; + // cerr << "s3 = " << s3 << "\n"; + // cerr << "s03 = " << s03 << "\n"; + // cerr << "dw = " << dw << "\n"; + RealType pref1 = - *(idat.vdwMult) * 8.0 * eps * mu_ * (R12 - R6) / (e2 * *(idat.rij)); @@ -365,25 +441,25 @@ namespace OpenMD { (1.0 - xp2 * g2) / e2 + 8.0 * eps * s3 * (3.0 * R7 - 6.0 * R13) * (x2 * au * bu - H * x2 * g) / (1.0 - x2 * g2) / (dw * s03); - cerr << pref1 << " " << pref2 << " " << dUdr <<" " << dUda << " " << dUdb << dUdg << "\n"; + // cerr << "pref = " << pref1 << " " << pref2 << "\n"; + // cerr << "dU = " << dUdr << " " << dUda <<" " << dUdb << " " << dUdg << "\n"; Vector3d rhat = *(idat.d) / *(idat.rij); Vector3d rxu1 = cross(*(idat.d), ul1); Vector3d rxu2 = cross(*(idat.d), ul2); Vector3d uxu = cross(ul1, ul2); - cerr << "U = " << U << "\n"; - cerr << "f1 = " << dUdr * rhat + dUda * ul1 + dUdb * ul2 << "\n"; - cerr << "t1 = " << dUda * rxu1 - dUdg * uxu << "\n"; - cerr << "t2 = " << dUdb * rxu2 - dUdg * uxu << "\n"; - - (*(idat.pot))[VANDERWAALS_FAMILY] += U * *(idat.sw); - *(idat.f1) += dUdr * rhat + dUda * ul1 + dUdb * ul2; - *(idat.t1) += dUda * rxu1 - dUdg * uxu; - *(idat.t2) += dUdb * rxu2 - dUdg * uxu; - *(idat.vpair) += U * *(idat.sw); + *(idat.f1) += (dUdr * rhat + dUda * ul1 + dUdb * ul2) * *(idat.sw); + *(idat.t1) += (dUda * rxu1 - dUdg * uxu) * *(idat.sw); + *(idat.t2) += (dUdb * rxu2 + dUdg * uxu) * *(idat.sw); + *(idat.vpair) += U; + // cerr << "f1 term = " << (dUdr * rhat + dUda * ul1 + dUdb * ul2) * *(idat.sw) << "\n"; + // cerr << "t1 term = " << (dUda * rxu1 - dUdg * uxu) * *(idat.sw) << "\n"; + // cerr << "t2 term = " << (dUdb * rxu2 + dUdg * uxu) * *(idat.sw) << "\n"; + // cerr << "vp term = " << U << "\n"; + return; }