| 1003 |
|
|
| 1004 |
|
return; |
| 1005 |
|
} |
| 1006 |
– |
|
| 1007 |
– |
void Electrostatic::calcSkipCorrection(InteractionData &idat) { |
| 1008 |
– |
|
| 1009 |
– |
if (!initialized_) initialize(); |
| 1010 |
– |
|
| 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 |
– |
} |
| 1006 |
|
|
| 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 |
– |
|
| 1007 |
|
void Electrostatic::calcSelfCorrection(SelfData &sdat) { |
| 1008 |
|
RealType mu1, preVal, chg1, self; |
| 1009 |
|
|