| 36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124 234104 (2006). |
| 38 |
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
| 39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
| 39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
| 40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
| 41 |
|
*/ |
| 42 |
|
|
| 43 |
|
#include <stdio.h> |
| 65 |
|
Globals* simParams_ = info_->getSimParams(); |
| 66 |
|
|
| 67 |
|
summationMap_["HARD"] = esm_HARD; |
| 68 |
+ |
summationMap_["NONE"] = esm_HARD; |
| 69 |
|
summationMap_["SWITCHING_FUNCTION"] = esm_SWITCHING_FUNCTION; |
| 70 |
|
summationMap_["SHIFTED_POTENTIAL"] = esm_SHIFTED_POTENTIAL; |
| 71 |
|
summationMap_["SHIFTED_FORCE"] = esm_SHIFTED_FORCE; |
| 118 |
|
sprintf( painCave.errMsg, |
| 119 |
|
"Electrostatic::initialize: Unknown electrostaticSummationMethod.\n" |
| 120 |
|
"\t(Input file specified %s .)\n" |
| 121 |
< |
"\telectrostaticSummationMethod must be one of: \"none\",\n" |
| 121 |
> |
"\telectrostaticSummationMethod must be one of: \"hard\",\n" |
| 122 |
|
"\t\"shifted_potential\", \"shifted_force\", or \n" |
| 123 |
|
"\t\"reaction_field\".\n", myMethod.c_str() ); |
| 124 |
|
painCave.isFatal = 1; |
| 251 |
|
preRF2_ = 2.0 * preRF_; |
| 252 |
|
} |
| 253 |
|
|
| 254 |
< |
RealType dx = cutoffRadius_ / RealType(np_ - 1); |
| 254 |
> |
// Add a 2 angstrom safety window to deal with cutoffGroups that |
| 255 |
> |
// have charged atoms longer than the cutoffRadius away from each |
| 256 |
> |
// other. Splining may not be the best choice here. Direct calls |
| 257 |
> |
// to erfc might be preferrable. |
| 258 |
> |
|
| 259 |
> |
RealType dx = (cutoffRadius_ + 2.0) / RealType(np_ - 1); |
| 260 |
|
RealType rval; |
| 261 |
|
vector<RealType> rvals; |
| 262 |
|
vector<RealType> yvals; |
| 585 |
|
if (j_is_Charge) { |
| 586 |
|
if (screeningMethod_ == DAMPED) { |
| 587 |
|
// assemble the damping variables |
| 588 |
< |
res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 589 |
< |
erfcVal = res.first; |
| 590 |
< |
derfcVal = res.second; |
| 588 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 589 |
> |
//erfcVal = res.first; |
| 590 |
> |
//derfcVal = res.second; |
| 591 |
> |
|
| 592 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
| 593 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
| 594 |
> |
|
| 595 |
|
c1 = erfcVal * riji; |
| 596 |
|
c2 = (-derfcVal + c1) * riji; |
| 597 |
|
} else { |
| 678 |
|
|
| 679 |
|
if (screeningMethod_ == DAMPED) { |
| 680 |
|
// assemble the damping variables |
| 681 |
< |
res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 682 |
< |
erfcVal = res.first; |
| 683 |
< |
derfcVal = res.second; |
| 681 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 682 |
> |
//erfcVal = res.first; |
| 683 |
> |
//derfcVal = res.second; |
| 684 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
| 685 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
| 686 |
|
c1 = erfcVal * ri; |
| 687 |
|
c2 = (-derfcVal + c1) * ri; |
| 688 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri; |
| 717 |
|
|
| 718 |
|
if (screeningMethod_ == DAMPED) { |
| 719 |
|
// assemble the damping variables |
| 720 |
< |
res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 721 |
< |
erfcVal = res.first; |
| 722 |
< |
derfcVal = res.second; |
| 720 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 721 |
> |
//erfcVal = res.first; |
| 722 |
> |
//derfcVal = res.second; |
| 723 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
| 724 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
| 725 |
|
c1 = erfcVal * riji; |
| 726 |
|
c2 = (-derfcVal + c1) * riji; |
| 727 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * riji; |
| 808 |
|
|
| 809 |
|
if (screeningMethod_ == DAMPED) { |
| 810 |
|
// assemble the damping variables |
| 811 |
< |
res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 812 |
< |
erfcVal = res.first; |
| 813 |
< |
derfcVal = res.second; |
| 811 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 812 |
> |
//erfcVal = res.first; |
| 813 |
> |
//derfcVal = res.second; |
| 814 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
| 815 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
| 816 |
|
c1 = erfcVal * ri; |
| 817 |
|
c2 = (-derfcVal + c1) * ri; |
| 818 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri; |
| 889 |
|
} |
| 890 |
|
if (screeningMethod_ == DAMPED) { |
| 891 |
|
// assemble damping variables |
| 892 |
< |
res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 893 |
< |
erfcVal = res.first; |
| 894 |
< |
derfcVal = res.second; |
| 892 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 893 |
> |
//erfcVal = res.first; |
| 894 |
> |
//derfcVal = res.second; |
| 895 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
| 896 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
| 897 |
|
c1 = erfcVal * ri; |
| 898 |
|
c2 = (-derfcVal + c1) * ri; |
| 899 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri; |
| 942 |
|
|
| 943 |
|
if (screeningMethod_ == DAMPED) { |
| 944 |
|
// assemble the damping variables |
| 945 |
< |
res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 946 |
< |
erfcVal = res.first; |
| 947 |
< |
derfcVal = res.second; |
| 945 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
| 946 |
> |
//erfcVal = res.first; |
| 947 |
> |
//derfcVal = res.second; |
| 948 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
| 949 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
| 950 |
|
c1 = erfcVal * riji; |
| 951 |
|
c2 = (-derfcVal + c1) * riji; |
| 952 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * riji; |
| 1011 |
|
|
| 1012 |
|
// only accumulate the forces and torques resulting from the |
| 1013 |
|
// indirect reaction field terms. |
| 1014 |
+ |
|
| 1015 |
|
*(idat.vpair) += indirect_vpair; |
| 1016 |
|
(*(idat.pot))[ELECTROSTATIC_FAMILY] += indirect_Pot; |
| 1017 |
|
*(idat.f1) += indirect_dVdr; |
| 1025 |
|
|
| 1026 |
|
return; |
| 1027 |
|
} |
| 1006 |
– |
|
| 1007 |
– |
void Electrostatic::calcSkipCorrection(InteractionData &idat) { |
| 1008 |
– |
|
| 1009 |
– |
if (!initialized_) initialize(); |
| 1028 |
|
|
| 1011 |
– |
ElectrostaticAtomData data1 = ElectrostaticMap[idat.atypes.first]; |
| 1012 |
– |
ElectrostaticAtomData data2 = ElectrostaticMap[idat.atypes.second]; |
| 1013 |
– |
|
| 1014 |
– |
// logicals |
| 1015 |
– |
|
| 1016 |
– |
bool i_is_Charge = data1.is_Charge; |
| 1017 |
– |
bool i_is_Dipole = data1.is_Dipole; |
| 1018 |
– |
|
| 1019 |
– |
bool j_is_Charge = data2.is_Charge; |
| 1020 |
– |
bool j_is_Dipole = data2.is_Dipole; |
| 1021 |
– |
|
| 1022 |
– |
RealType q_i, q_j; |
| 1023 |
– |
|
| 1024 |
– |
// The skippedCharge computation is needed by the real-space |
| 1025 |
– |
// cutoff methods (i.e. shifted force and shifted potential) |
| 1026 |
– |
|
| 1027 |
– |
if (i_is_Charge) { |
| 1028 |
– |
q_i = data1.charge; |
| 1029 |
– |
*(idat.skippedCharge2) += q_i; |
| 1030 |
– |
} |
| 1031 |
– |
|
| 1032 |
– |
if (j_is_Charge) { |
| 1033 |
– |
q_j = data2.charge; |
| 1034 |
– |
*(idat.skippedCharge1) += q_j; |
| 1035 |
– |
} |
| 1036 |
– |
|
| 1037 |
– |
// the rest of this function should only be necessary for reaction field. |
| 1038 |
– |
|
| 1039 |
– |
if (summationMethod_ == esm_REACTION_FIELD) { |
| 1040 |
– |
RealType riji, ri2, ri3; |
| 1041 |
– |
RealType mu_i, ct_i; |
| 1042 |
– |
RealType mu_j, ct_j; |
| 1043 |
– |
RealType preVal, rfVal, vterm, dudr, pref, myPot(0.0); |
| 1044 |
– |
Vector3d dVdr, uz_i, uz_j, duduz_i, duduz_j, rhat; |
| 1045 |
– |
|
| 1046 |
– |
// some variables we'll need independent of electrostatic type: |
| 1047 |
– |
|
| 1048 |
– |
riji = 1.0 / *(idat.rij) ; |
| 1049 |
– |
rhat = *(idat.d) * riji; |
| 1050 |
– |
|
| 1051 |
– |
if (i_is_Dipole) { |
| 1052 |
– |
mu_i = data1.dipole_moment; |
| 1053 |
– |
uz_i = idat.eFrame1->getColumn(2); |
| 1054 |
– |
ct_i = dot(uz_i, rhat); |
| 1055 |
– |
duduz_i = V3Zero; |
| 1056 |
– |
} |
| 1057 |
– |
|
| 1058 |
– |
if (j_is_Dipole) { |
| 1059 |
– |
mu_j = data2.dipole_moment; |
| 1060 |
– |
uz_j = idat.eFrame2->getColumn(2); |
| 1061 |
– |
ct_j = dot(uz_j, rhat); |
| 1062 |
– |
duduz_j = V3Zero; |
| 1063 |
– |
} |
| 1064 |
– |
|
| 1065 |
– |
if (i_is_Charge) { |
| 1066 |
– |
if (j_is_Charge) { |
| 1067 |
– |
preVal = *(idat.electroMult) * pre11_ * q_i * q_j; |
| 1068 |
– |
rfVal = preRF_ * *(idat.rij) * *(idat.rij) ; |
| 1069 |
– |
vterm = preVal * rfVal; |
| 1070 |
– |
myPot += *(idat.sw) * vterm; |
| 1071 |
– |
dudr = *(idat.sw) * preVal * 2.0 * rfVal * riji; |
| 1072 |
– |
dVdr += dudr * rhat; |
| 1073 |
– |
} |
| 1074 |
– |
|
| 1075 |
– |
if (j_is_Dipole) { |
| 1076 |
– |
ri2 = riji * riji; |
| 1077 |
– |
ri3 = ri2 * riji; |
| 1078 |
– |
pref = *(idat.electroMult) * pre12_ * q_i * mu_j; |
| 1079 |
– |
vterm = - pref * ct_j * ( ri2 - preRF2_ * *(idat.rij) ); |
| 1080 |
– |
myPot += *(idat.sw) * vterm; |
| 1081 |
– |
dVdr += - *(idat.sw) * pref * ( ri3 * ( uz_j - 3.0 * ct_j * rhat) - preRF2_ * uz_j); |
| 1082 |
– |
duduz_j += - *(idat.sw) * pref * rhat * (ri2 - preRF2_ * *(idat.rij) ); |
| 1083 |
– |
} |
| 1084 |
– |
} |
| 1085 |
– |
if (i_is_Dipole) { |
| 1086 |
– |
if (j_is_Charge) { |
| 1087 |
– |
ri2 = riji * riji; |
| 1088 |
– |
ri3 = ri2 * riji; |
| 1089 |
– |
pref = *(idat.electroMult) * pre12_ * q_j * mu_i; |
| 1090 |
– |
vterm = - pref * ct_i * ( ri2 - preRF2_ * *(idat.rij) ); |
| 1091 |
– |
myPot += *(idat.sw) * vterm; |
| 1092 |
– |
dVdr += *(idat.sw) * pref * ( ri3 * ( uz_i - 3.0 * ct_i * rhat) - preRF2_ * uz_i); |
| 1093 |
– |
duduz_i += *(idat.sw) * pref * rhat * (ri2 - preRF2_ * *(idat.rij)); |
| 1094 |
– |
} |
| 1095 |
– |
} |
| 1096 |
– |
|
| 1097 |
– |
// accumulate the forces and torques resulting from the self term |
| 1098 |
– |
(*(idat.pot))[ELECTROSTATIC_FAMILY] += myPot; |
| 1099 |
– |
*(idat.f1) += dVdr; |
| 1100 |
– |
|
| 1101 |
– |
if (i_is_Dipole) |
| 1102 |
– |
*(idat.t1) -= cross(uz_i, duduz_i); |
| 1103 |
– |
if (j_is_Dipole) |
| 1104 |
– |
*(idat.t2) -= cross(uz_j, duduz_j); |
| 1105 |
– |
} |
| 1106 |
– |
} |
| 1107 |
– |
|
| 1029 |
|
void Electrostatic::calcSelfCorrection(SelfData &sdat) { |
| 1030 |
|
RealType mu1, preVal, chg1, self; |
| 1031 |
|
|