34 |
|
* work. Good starting points are: |
35 |
|
* |
36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
< |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
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> |
47 |
|
#include "nonbonded/Electrostatic.hpp" |
48 |
|
#include "utils/simError.h" |
49 |
|
#include "types/NonBondedInteractionType.hpp" |
50 |
< |
#include "types/DirectionalAtomType.hpp" |
50 |
> |
#include "types/FixedChargeAdapter.hpp" |
51 |
> |
#include "types/FluctuatingChargeAdapter.hpp" |
52 |
> |
#include "types/MultipoleAdapter.hpp" |
53 |
> |
#include "io/Globals.hpp" |
54 |
> |
#include "nonbonded/SlaterIntegrals.hpp" |
55 |
> |
#include "utils/PhysicalConstants.hpp" |
56 |
|
|
57 |
|
|
58 |
|
namespace OpenMD { |
59 |
|
|
60 |
|
Electrostatic::Electrostatic(): name_("Electrostatic"), initialized_(false), |
61 |
< |
forceField_(NULL) {} |
61 |
> |
forceField_(NULL), info_(NULL), |
62 |
> |
haveCutoffRadius_(false), |
63 |
> |
haveDampingAlpha_(false), |
64 |
> |
haveDielectric_(false), |
65 |
> |
haveElectroSpline_(false) |
66 |
> |
{} |
67 |
|
|
68 |
|
void Electrostatic::initialize() { |
69 |
+ |
|
70 |
+ |
Globals* simParams_ = info_->getSimParams(); |
71 |
+ |
|
72 |
+ |
summationMap_["HARD"] = esm_HARD; |
73 |
+ |
summationMap_["NONE"] = esm_HARD; |
74 |
+ |
summationMap_["SWITCHING_FUNCTION"] = esm_SWITCHING_FUNCTION; |
75 |
+ |
summationMap_["SHIFTED_POTENTIAL"] = esm_SHIFTED_POTENTIAL; |
76 |
+ |
summationMap_["SHIFTED_FORCE"] = esm_SHIFTED_FORCE; |
77 |
+ |
summationMap_["REACTION_FIELD"] = esm_REACTION_FIELD; |
78 |
+ |
summationMap_["EWALD_FULL"] = esm_EWALD_FULL; |
79 |
+ |
summationMap_["EWALD_PME"] = esm_EWALD_PME; |
80 |
+ |
summationMap_["EWALD_SPME"] = esm_EWALD_SPME; |
81 |
+ |
screeningMap_["DAMPED"] = DAMPED; |
82 |
+ |
screeningMap_["UNDAMPED"] = UNDAMPED; |
83 |
+ |
|
84 |
|
// these prefactors convert the multipole interactions into kcal / mol |
85 |
|
// all were computed assuming distances are measured in angstroms |
86 |
|
// Charge-Charge, assuming charges are measured in electrons |
105 |
|
|
106 |
|
// variables to handle different summation methods for long-range |
107 |
|
// electrostatics: |
108 |
< |
summationMethod_ = NONE; |
108 |
> |
summationMethod_ = esm_HARD; |
109 |
|
screeningMethod_ = UNDAMPED; |
110 |
|
dielectric_ = 1.0; |
111 |
|
one_third_ = 1.0 / 3.0; |
86 |
– |
haveDefaultCutoff_ = false; |
87 |
– |
haveDampingAlpha_ = false; |
88 |
– |
haveDielectric_ = false; |
89 |
– |
haveElectroSpline_ = false; |
112 |
|
|
113 |
+ |
// check the summation method: |
114 |
+ |
if (simParams_->haveElectrostaticSummationMethod()) { |
115 |
+ |
string myMethod = simParams_->getElectrostaticSummationMethod(); |
116 |
+ |
toUpper(myMethod); |
117 |
+ |
map<string, ElectrostaticSummationMethod>::iterator i; |
118 |
+ |
i = summationMap_.find(myMethod); |
119 |
+ |
if ( i != summationMap_.end() ) { |
120 |
+ |
summationMethod_ = (*i).second; |
121 |
+ |
} else { |
122 |
+ |
// throw error |
123 |
+ |
sprintf( painCave.errMsg, |
124 |
+ |
"Electrostatic::initialize: Unknown electrostaticSummationMethod.\n" |
125 |
+ |
"\t(Input file specified %s .)\n" |
126 |
+ |
"\telectrostaticSummationMethod must be one of: \"hard\",\n" |
127 |
+ |
"\t\"shifted_potential\", \"shifted_force\", or \n" |
128 |
+ |
"\t\"reaction_field\".\n", myMethod.c_str() ); |
129 |
+ |
painCave.isFatal = 1; |
130 |
+ |
simError(); |
131 |
+ |
} |
132 |
+ |
} else { |
133 |
+ |
// set ElectrostaticSummationMethod to the cutoffMethod: |
134 |
+ |
if (simParams_->haveCutoffMethod()){ |
135 |
+ |
string myMethod = simParams_->getCutoffMethod(); |
136 |
+ |
toUpper(myMethod); |
137 |
+ |
map<string, ElectrostaticSummationMethod>::iterator i; |
138 |
+ |
i = summationMap_.find(myMethod); |
139 |
+ |
if ( i != summationMap_.end() ) { |
140 |
+ |
summationMethod_ = (*i).second; |
141 |
+ |
} |
142 |
+ |
} |
143 |
+ |
} |
144 |
+ |
|
145 |
+ |
if (summationMethod_ == esm_REACTION_FIELD) { |
146 |
+ |
if (!simParams_->haveDielectric()) { |
147 |
+ |
// throw warning |
148 |
+ |
sprintf( painCave.errMsg, |
149 |
+ |
"SimInfo warning: dielectric was not specified in the input file\n\tfor the reaction field correction method.\n" |
150 |
+ |
"\tA default value of %f will be used for the dielectric.\n", dielectric_); |
151 |
+ |
painCave.isFatal = 0; |
152 |
+ |
painCave.severity = OPENMD_INFO; |
153 |
+ |
simError(); |
154 |
+ |
} else { |
155 |
+ |
dielectric_ = simParams_->getDielectric(); |
156 |
+ |
} |
157 |
+ |
haveDielectric_ = true; |
158 |
+ |
} |
159 |
+ |
|
160 |
+ |
if (simParams_->haveElectrostaticScreeningMethod()) { |
161 |
+ |
string myScreen = simParams_->getElectrostaticScreeningMethod(); |
162 |
+ |
toUpper(myScreen); |
163 |
+ |
map<string, ElectrostaticScreeningMethod>::iterator i; |
164 |
+ |
i = screeningMap_.find(myScreen); |
165 |
+ |
if ( i != screeningMap_.end()) { |
166 |
+ |
screeningMethod_ = (*i).second; |
167 |
+ |
} else { |
168 |
+ |
sprintf( painCave.errMsg, |
169 |
+ |
"SimInfo error: Unknown electrostaticScreeningMethod.\n" |
170 |
+ |
"\t(Input file specified %s .)\n" |
171 |
+ |
"\telectrostaticScreeningMethod must be one of: \"undamped\"\n" |
172 |
+ |
"or \"damped\".\n", myScreen.c_str() ); |
173 |
+ |
painCave.isFatal = 1; |
174 |
+ |
simError(); |
175 |
+ |
} |
176 |
+ |
} |
177 |
+ |
|
178 |
+ |
// check to make sure a cutoff value has been set: |
179 |
+ |
if (!haveCutoffRadius_) { |
180 |
+ |
sprintf( painCave.errMsg, "Electrostatic::initialize has no Default " |
181 |
+ |
"Cutoff value!\n"); |
182 |
+ |
painCave.severity = OPENMD_ERROR; |
183 |
+ |
painCave.isFatal = 1; |
184 |
+ |
simError(); |
185 |
+ |
} |
186 |
+ |
|
187 |
+ |
if (screeningMethod_ == DAMPED) { |
188 |
+ |
if (!simParams_->haveDampingAlpha()) { |
189 |
+ |
// first set a cutoff dependent alpha value |
190 |
+ |
// we assume alpha depends linearly with rcut from 0 to 20.5 ang |
191 |
+ |
dampingAlpha_ = 0.425 - cutoffRadius_* 0.02; |
192 |
+ |
if (dampingAlpha_ < 0.0) dampingAlpha_ = 0.0; |
193 |
+ |
|
194 |
+ |
// throw warning |
195 |
+ |
sprintf( painCave.errMsg, |
196 |
+ |
"Electrostatic::initialize: dampingAlpha was not specified in the\n" |
197 |
+ |
"\tinput file. A default value of %f (1/ang) will be used for the\n" |
198 |
+ |
"\tcutoff of %f (ang).\n", |
199 |
+ |
dampingAlpha_, cutoffRadius_); |
200 |
+ |
painCave.severity = OPENMD_INFO; |
201 |
+ |
painCave.isFatal = 0; |
202 |
+ |
simError(); |
203 |
+ |
} else { |
204 |
+ |
dampingAlpha_ = simParams_->getDampingAlpha(); |
205 |
+ |
} |
206 |
+ |
haveDampingAlpha_ = true; |
207 |
+ |
} |
208 |
+ |
|
209 |
|
// find all of the Electrostatic atom Types: |
210 |
|
ForceField::AtomTypeContainer* atomTypes = forceField_->getAtomTypes(); |
211 |
|
ForceField::AtomTypeContainer::MapTypeIterator i; |
212 |
|
AtomType* at; |
213 |
< |
|
213 |
> |
|
214 |
|
for (at = atomTypes->beginType(i); at != NULL; |
215 |
|
at = atomTypes->nextType(i)) { |
216 |
|
|
218 |
|
addType(at); |
219 |
|
} |
220 |
|
|
221 |
< |
// check to make sure a cutoff value has been set: |
222 |
< |
if (!haveDefaultCutoff_) { |
105 |
< |
sprintf( painCave.errMsg, "Electrostatic::initialize has no Default " |
106 |
< |
"Cutoff value!\n"); |
107 |
< |
painCave.severity = OPENMD_ERROR; |
108 |
< |
painCave.isFatal = 1; |
109 |
< |
simError(); |
110 |
< |
} |
111 |
< |
|
112 |
< |
defaultCutoff2_ = defaultCutoff_ * defaultCutoff_; |
113 |
< |
rcuti_ = 1.0 / defaultCutoff_; |
221 |
> |
cutoffRadius2_ = cutoffRadius_ * cutoffRadius_; |
222 |
> |
rcuti_ = 1.0 / cutoffRadius_; |
223 |
|
rcuti2_ = rcuti_ * rcuti_; |
224 |
|
rcuti3_ = rcuti2_ * rcuti_; |
225 |
|
rcuti4_ = rcuti2_ * rcuti2_; |
226 |
|
|
227 |
|
if (screeningMethod_ == DAMPED) { |
228 |
< |
if (!haveDampingAlpha_) { |
120 |
< |
sprintf( painCave.errMsg, "Electrostatic::initialize has no " |
121 |
< |
"DampingAlpha value!\n"); |
122 |
< |
painCave.severity = OPENMD_ERROR; |
123 |
< |
painCave.isFatal = 1; |
124 |
< |
simError(); |
125 |
< |
} |
126 |
< |
|
228 |
> |
|
229 |
|
alpha2_ = dampingAlpha_ * dampingAlpha_; |
230 |
|
alpha4_ = alpha2_ * alpha2_; |
231 |
|
alpha6_ = alpha4_ * alpha2_; |
232 |
|
alpha8_ = alpha4_ * alpha4_; |
233 |
|
|
234 |
< |
constEXP_ = exp(-alpha2_ * defaultCutoff2_); |
234 |
> |
constEXP_ = exp(-alpha2_ * cutoffRadius2_); |
235 |
|
invRootPi_ = 0.56418958354775628695; |
236 |
|
alphaPi_ = 2.0 * dampingAlpha_ * invRootPi_; |
237 |
|
|
238 |
< |
c1c_ = erfc(dampingAlpha_ * defaultCutoff_) * rcuti_; |
238 |
> |
c1c_ = erfc(dampingAlpha_ * cutoffRadius_) * rcuti_; |
239 |
|
c2c_ = alphaPi_ * constEXP_ * rcuti_ + c1c_ * rcuti_; |
240 |
|
c3c_ = 2.0 * alphaPi_ * alpha2_ + 3.0 * c2c_ * rcuti_; |
241 |
|
c4c_ = 4.0 * alphaPi_ * alpha4_ + 5.0 * c3c_ * rcuti2_; |
250 |
|
c6c_ = 9.0 * c5c_ * rcuti2_; |
251 |
|
} |
252 |
|
|
253 |
< |
if (summationMethod_ == REACTION_FIELD) { |
254 |
< |
if (haveDielectric_) { |
255 |
< |
preRF_ = (dielectric_ - 1.0) / |
256 |
< |
((2.0 * dielectric_ + 1.0) * defaultCutoff2_ * defaultCutoff_); |
155 |
< |
preRF2_ = 2.0 * preRF_; |
156 |
< |
} else { |
157 |
< |
sprintf( painCave.errMsg, "Electrostatic::initialize has no Dielectric" |
158 |
< |
" value!\n"); |
159 |
< |
painCave.severity = OPENMD_ERROR; |
160 |
< |
painCave.isFatal = 1; |
161 |
< |
simError(); |
162 |
< |
} |
253 |
> |
if (summationMethod_ == esm_REACTION_FIELD) { |
254 |
> |
preRF_ = (dielectric_ - 1.0) / |
255 |
> |
((2.0 * dielectric_ + 1.0) * cutoffRadius2_ * cutoffRadius_); |
256 |
> |
preRF2_ = 2.0 * preRF_; |
257 |
|
} |
258 |
< |
|
259 |
< |
RealType dx = defaultCutoff_ / RealType(np_ - 1); |
258 |
> |
|
259 |
> |
// Add a 2 angstrom safety window to deal with cutoffGroups that |
260 |
> |
// have charged atoms longer than the cutoffRadius away from each |
261 |
> |
// other. Splining may not be the best choice here. Direct calls |
262 |
> |
// to erfc might be preferrable. |
263 |
> |
|
264 |
> |
RealType dx = (cutoffRadius_ + 2.0) / RealType(np_ - 1); |
265 |
|
RealType rval; |
266 |
|
vector<RealType> rvals; |
267 |
|
vector<RealType> yvals; |
284 |
|
electrostaticAtomData.is_Dipole = false; |
285 |
|
electrostaticAtomData.is_SplitDipole = false; |
286 |
|
electrostaticAtomData.is_Quadrupole = false; |
287 |
+ |
electrostaticAtomData.is_Fluctuating = false; |
288 |
|
|
289 |
< |
if (atomType->isCharge()) { |
190 |
< |
GenericData* data = atomType->getPropertyByName("Charge"); |
289 |
> |
FixedChargeAdapter fca = FixedChargeAdapter(atomType); |
290 |
|
|
291 |
< |
if (data == NULL) { |
193 |
< |
sprintf( painCave.errMsg, "Electrostatic::addType could not find " |
194 |
< |
"Charge\n" |
195 |
< |
"\tparameters for atomType %s.\n", |
196 |
< |
atomType->getName().c_str()); |
197 |
< |
painCave.severity = OPENMD_ERROR; |
198 |
< |
painCave.isFatal = 1; |
199 |
< |
simError(); |
200 |
< |
} |
201 |
< |
|
202 |
< |
DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data); |
203 |
< |
if (doubleData == NULL) { |
204 |
< |
sprintf( painCave.errMsg, |
205 |
< |
"Electrostatic::addType could not convert GenericData to " |
206 |
< |
"Charge for\n" |
207 |
< |
"\tatom type %s\n", atomType->getName().c_str()); |
208 |
< |
painCave.severity = OPENMD_ERROR; |
209 |
< |
painCave.isFatal = 1; |
210 |
< |
simError(); |
211 |
< |
} |
291 |
> |
if (fca.isFixedCharge()) { |
292 |
|
electrostaticAtomData.is_Charge = true; |
293 |
< |
electrostaticAtomData.charge = doubleData->getData(); |
293 |
> |
electrostaticAtomData.fixedCharge = fca.getCharge(); |
294 |
|
} |
295 |
|
|
296 |
< |
if (atomType->isDirectional()) { |
297 |
< |
DirectionalAtomType* daType = dynamic_cast<DirectionalAtomType*>(atomType); |
298 |
< |
|
219 |
< |
if (daType->isDipole()) { |
220 |
< |
GenericData* data = daType->getPropertyByName("Dipole"); |
221 |
< |
|
222 |
< |
if (data == NULL) { |
223 |
< |
sprintf( painCave.errMsg, |
224 |
< |
"Electrostatic::addType could not find Dipole\n" |
225 |
< |
"\tparameters for atomType %s.\n", |
226 |
< |
daType->getName().c_str()); |
227 |
< |
painCave.severity = OPENMD_ERROR; |
228 |
< |
painCave.isFatal = 1; |
229 |
< |
simError(); |
230 |
< |
} |
231 |
< |
|
232 |
< |
DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data); |
233 |
< |
if (doubleData == NULL) { |
234 |
< |
sprintf( painCave.errMsg, |
235 |
< |
"Electrostatic::addType could not convert GenericData to " |
236 |
< |
"Dipole Moment\n" |
237 |
< |
"\tfor atom type %s\n", daType->getName().c_str()); |
238 |
< |
painCave.severity = OPENMD_ERROR; |
239 |
< |
painCave.isFatal = 1; |
240 |
< |
simError(); |
241 |
< |
} |
296 |
> |
MultipoleAdapter ma = MultipoleAdapter(atomType); |
297 |
> |
if (ma.isMultipole()) { |
298 |
> |
if (ma.isDipole()) { |
299 |
|
electrostaticAtomData.is_Dipole = true; |
300 |
< |
electrostaticAtomData.dipole_moment = doubleData->getData(); |
300 |
> |
electrostaticAtomData.dipole_moment = ma.getDipoleMoment(); |
301 |
|
} |
302 |
< |
|
246 |
< |
if (daType->isSplitDipole()) { |
247 |
< |
GenericData* data = daType->getPropertyByName("SplitDipoleDistance"); |
248 |
< |
|
249 |
< |
if (data == NULL) { |
250 |
< |
sprintf(painCave.errMsg, |
251 |
< |
"Electrostatic::addType could not find SplitDipoleDistance\n" |
252 |
< |
"\tparameter for atomType %s.\n", |
253 |
< |
daType->getName().c_str()); |
254 |
< |
painCave.severity = OPENMD_ERROR; |
255 |
< |
painCave.isFatal = 1; |
256 |
< |
simError(); |
257 |
< |
} |
258 |
< |
|
259 |
< |
DoubleGenericData* doubleData = dynamic_cast<DoubleGenericData*>(data); |
260 |
< |
if (doubleData == NULL) { |
261 |
< |
sprintf( painCave.errMsg, |
262 |
< |
"Electrostatic::addType could not convert GenericData to " |
263 |
< |
"SplitDipoleDistance for\n" |
264 |
< |
"\tatom type %s\n", daType->getName().c_str()); |
265 |
< |
painCave.severity = OPENMD_ERROR; |
266 |
< |
painCave.isFatal = 1; |
267 |
< |
simError(); |
268 |
< |
} |
302 |
> |
if (ma.isSplitDipole()) { |
303 |
|
electrostaticAtomData.is_SplitDipole = true; |
304 |
< |
electrostaticAtomData.split_dipole_distance = doubleData->getData(); |
304 |
> |
electrostaticAtomData.split_dipole_distance = ma.getSplitDipoleDistance(); |
305 |
|
} |
306 |
< |
|
273 |
< |
if (daType->isQuadrupole()) { |
274 |
< |
GenericData* data = daType->getPropertyByName("QuadrupoleMoments"); |
275 |
< |
|
276 |
< |
if (data == NULL) { |
277 |
< |
sprintf( painCave.errMsg, |
278 |
< |
"Electrostatic::addType could not find QuadrupoleMoments\n" |
279 |
< |
"\tparameter for atomType %s.\n", |
280 |
< |
daType->getName().c_str()); |
281 |
< |
painCave.severity = OPENMD_ERROR; |
282 |
< |
painCave.isFatal = 1; |
283 |
< |
simError(); |
284 |
< |
} |
285 |
< |
|
306 |
> |
if (ma.isQuadrupole()) { |
307 |
|
// Quadrupoles in OpenMD are set as the diagonal elements |
308 |
|
// of the diagonalized traceless quadrupole moment tensor. |
309 |
|
// The column vectors of the unitary matrix that diagonalizes |
310 |
|
// the quadrupole moment tensor become the eFrame (or the |
311 |
|
// electrostatic version of the body-fixed frame. |
291 |
– |
|
292 |
– |
Vector3dGenericData* v3dData = dynamic_cast<Vector3dGenericData*>(data); |
293 |
– |
if (v3dData == NULL) { |
294 |
– |
sprintf( painCave.errMsg, |
295 |
– |
"Electrostatic::addType could not convert GenericData to " |
296 |
– |
"Quadrupole Moments for\n" |
297 |
– |
"\tatom type %s\n", daType->getName().c_str()); |
298 |
– |
painCave.severity = OPENMD_ERROR; |
299 |
– |
painCave.isFatal = 1; |
300 |
– |
simError(); |
301 |
– |
} |
312 |
|
electrostaticAtomData.is_Quadrupole = true; |
313 |
< |
electrostaticAtomData.quadrupole_moments = v3dData->getData(); |
313 |
> |
electrostaticAtomData.quadrupole_moments = ma.getQuadrupoleMoments(); |
314 |
|
} |
315 |
|
} |
316 |
|
|
317 |
< |
AtomTypeProperties atp = atomType->getATP(); |
317 |
> |
FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atomType); |
318 |
|
|
319 |
+ |
if (fqa.isFluctuatingCharge()) { |
320 |
+ |
electrostaticAtomData.is_Fluctuating = true; |
321 |
+ |
electrostaticAtomData.electronegativity = fqa.getElectronegativity(); |
322 |
+ |
electrostaticAtomData.hardness = fqa.getHardness(); |
323 |
+ |
electrostaticAtomData.slaterN = fqa.getSlaterN(); |
324 |
+ |
electrostaticAtomData.slaterZeta = fqa.getSlaterZeta(); |
325 |
+ |
} |
326 |
+ |
|
327 |
|
pair<map<int,AtomType*>::iterator,bool> ret; |
328 |
< |
ret = ElectrostaticList.insert( pair<int,AtomType*>(atp.ident, atomType) ); |
328 |
> |
ret = ElectrostaticList.insert( pair<int,AtomType*>(atomType->getIdent(), |
329 |
> |
atomType) ); |
330 |
|
if (ret.second == false) { |
331 |
|
sprintf( painCave.errMsg, |
332 |
|
"Electrostatic already had a previous entry with ident %d\n", |
333 |
< |
atp.ident); |
333 |
> |
atomType->getIdent() ); |
334 |
|
painCave.severity = OPENMD_INFO; |
335 |
|
painCave.isFatal = 0; |
336 |
|
simError(); |
337 |
|
} |
338 |
|
|
339 |
< |
ElectrostaticMap[atomType] = electrostaticAtomData; |
339 |
> |
ElectrostaticMap[atomType] = electrostaticAtomData; |
340 |
> |
|
341 |
> |
// Now, iterate over all known types and add to the mixing map: |
342 |
> |
|
343 |
> |
map<AtomType*, ElectrostaticAtomData>::iterator it; |
344 |
> |
for( it = ElectrostaticMap.begin(); it != ElectrostaticMap.end(); ++it) { |
345 |
> |
AtomType* atype2 = (*it).first; |
346 |
> |
ElectrostaticAtomData eaData2 = (*it).second; |
347 |
> |
if (eaData2.is_Fluctuating && electrostaticAtomData.is_Fluctuating) { |
348 |
> |
|
349 |
> |
RealType a = electrostaticAtomData.slaterZeta; |
350 |
> |
RealType b = eaData2.slaterZeta; |
351 |
> |
int m = electrostaticAtomData.slaterN; |
352 |
> |
int n = eaData2.slaterN; |
353 |
> |
|
354 |
> |
// Create the spline of the coulombic integral for s-type |
355 |
> |
// Slater orbitals. Add a 2 angstrom safety window to deal |
356 |
> |
// with cutoffGroups that have charged atoms longer than the |
357 |
> |
// cutoffRadius away from each other. |
358 |
> |
|
359 |
> |
RealType rval; |
360 |
> |
RealType dr = (cutoffRadius_ + 2.0) / RealType(np_ - 1); |
361 |
> |
vector<RealType> rvals; |
362 |
> |
vector<RealType> J1vals; |
363 |
> |
vector<RealType> J2vals; |
364 |
> |
for (int i = 0; i < np_; i++) { |
365 |
> |
rval = RealType(i) * dr; |
366 |
> |
rvals.push_back(rval); |
367 |
> |
J1vals.push_back(electrostaticAtomData.hardness * sSTOCoulInt( a, b, m, n, rval * PhysicalConstants::angstromsToBohr ) ); |
368 |
> |
// may not be necessary if Slater coulomb integral is symmetric |
369 |
> |
J2vals.push_back(eaData2.hardness * sSTOCoulInt( b, a, n, m, rval * PhysicalConstants::angstromsToBohr ) ); |
370 |
> |
} |
371 |
> |
|
372 |
> |
CubicSpline* J1 = new CubicSpline(); |
373 |
> |
J1->addPoints(rvals, J1vals); |
374 |
> |
CubicSpline* J2 = new CubicSpline(); |
375 |
> |
J2->addPoints(rvals, J2vals); |
376 |
> |
|
377 |
> |
pair<AtomType*, AtomType*> key1, key2; |
378 |
> |
key1 = make_pair(atomType, atype2); |
379 |
> |
key2 = make_pair(atype2, atomType); |
380 |
> |
|
381 |
> |
Jij[key1] = J1; |
382 |
> |
Jij[key2] = J2; |
383 |
> |
} |
384 |
> |
} |
385 |
> |
|
386 |
|
return; |
387 |
|
} |
388 |
|
|
389 |
< |
void Electrostatic::setElectrostaticCutoffRadius( RealType theECR, |
390 |
< |
RealType theRSW ) { |
391 |
< |
defaultCutoff_ = theECR; |
392 |
< |
rrf_ = defaultCutoff_; |
328 |
< |
rt_ = theRSW; |
329 |
< |
haveDefaultCutoff_ = true; |
389 |
> |
void Electrostatic::setCutoffRadius( RealType rCut ) { |
390 |
> |
cutoffRadius_ = rCut; |
391 |
> |
rrf_ = cutoffRadius_; |
392 |
> |
haveCutoffRadius_ = true; |
393 |
|
} |
394 |
+ |
|
395 |
+ |
void Electrostatic::setSwitchingRadius( RealType rSwitch ) { |
396 |
+ |
rt_ = rSwitch; |
397 |
+ |
} |
398 |
|
void Electrostatic::setElectrostaticSummationMethod( ElectrostaticSummationMethod esm ) { |
399 |
|
summationMethod_ = esm; |
400 |
|
} |
410 |
|
haveDielectric_ = true; |
411 |
|
} |
412 |
|
|
413 |
< |
void Electrostatic::calcForce(InteractionData idat) { |
413 |
> |
void Electrostatic::calcForce(InteractionData &idat) { |
414 |
|
|
415 |
|
// utility variables. Should clean these up and use the Vector3d and |
416 |
|
// Mat3x3d to replace as many as we can in future versions: |
424 |
|
RealType ct_i, ct_j, ct_ij, a1; |
425 |
|
RealType riji, ri, ri2, ri3, ri4; |
426 |
|
RealType pref, vterm, epot, dudr; |
427 |
+ |
RealType vpair(0.0); |
428 |
|
RealType scale, sc2; |
429 |
|
RealType pot_term, preVal, rfVal; |
430 |
|
RealType c2ri, c3ri, c4rij, cti3, ctj3, ctidotj; |
431 |
|
RealType preSw, preSwSc; |
432 |
|
RealType c1, c2, c3, c4; |
433 |
< |
RealType erfcVal, derfcVal; |
433 |
> |
RealType erfcVal(1.0), derfcVal(0.0); |
434 |
|
RealType BigR; |
435 |
+ |
RealType two(2.0), three(3.0); |
436 |
|
|
437 |
|
Vector3d Q_i, Q_j; |
438 |
|
Vector3d ux_i, uy_i, uz_i; |
442 |
|
Vector3d rhatdot2, rhatc4; |
443 |
|
Vector3d dVdr; |
444 |
|
|
445 |
+ |
// variables for indirect (reaction field) interactions for excluded pairs: |
446 |
+ |
RealType indirect_Pot(0.0); |
447 |
+ |
RealType indirect_vpair(0.0); |
448 |
+ |
Vector3d indirect_dVdr(V3Zero); |
449 |
+ |
Vector3d indirect_duduz_i(V3Zero), indirect_duduz_j(V3Zero); |
450 |
+ |
|
451 |
+ |
RealType coulInt, vFluc1(0.0), vFluc2(0.0); |
452 |
|
pair<RealType, RealType> res; |
453 |
|
|
454 |
+ |
// splines for coulomb integrals |
455 |
+ |
CubicSpline* J1; |
456 |
+ |
CubicSpline* J2; |
457 |
+ |
|
458 |
|
if (!initialized_) initialize(); |
459 |
|
|
460 |
< |
ElectrostaticAtomData data1 = ElectrostaticMap[idat.atype1]; |
461 |
< |
ElectrostaticAtomData data2 = ElectrostaticMap[idat.atype2]; |
460 |
> |
ElectrostaticAtomData data1 = ElectrostaticMap[idat.atypes.first]; |
461 |
> |
ElectrostaticAtomData data2 = ElectrostaticMap[idat.atypes.second]; |
462 |
|
|
463 |
|
// some variables we'll need independent of electrostatic type: |
464 |
|
|
465 |
< |
riji = 1.0 / idat.rij; |
466 |
< |
Vector3d rhat = idat.d * riji; |
465 |
> |
riji = 1.0 / *(idat.rij) ; |
466 |
> |
Vector3d rhat = *(idat.d) * riji; |
467 |
|
|
468 |
|
// logicals |
469 |
|
|
471 |
|
bool i_is_Dipole = data1.is_Dipole; |
472 |
|
bool i_is_SplitDipole = data1.is_SplitDipole; |
473 |
|
bool i_is_Quadrupole = data1.is_Quadrupole; |
474 |
+ |
bool i_is_Fluctuating = data1.is_Fluctuating; |
475 |
|
|
476 |
|
bool j_is_Charge = data2.is_Charge; |
477 |
|
bool j_is_Dipole = data2.is_Dipole; |
478 |
|
bool j_is_SplitDipole = data2.is_SplitDipole; |
479 |
|
bool j_is_Quadrupole = data2.is_Quadrupole; |
480 |
+ |
bool j_is_Fluctuating = data2.is_Fluctuating; |
481 |
|
|
482 |
< |
if (i_is_Charge) |
483 |
< |
q_i = data1.charge; |
482 |
> |
if (i_is_Charge) { |
483 |
> |
q_i = data1.fixedCharge; |
484 |
|
|
485 |
+ |
if (i_is_Fluctuating) { |
486 |
+ |
q_i += *(idat.flucQ1); |
487 |
+ |
} |
488 |
+ |
|
489 |
+ |
if (idat.excluded) { |
490 |
+ |
*(idat.skippedCharge2) += q_i; |
491 |
+ |
} |
492 |
+ |
} |
493 |
+ |
|
494 |
|
if (i_is_Dipole) { |
495 |
|
mu_i = data1.dipole_moment; |
496 |
< |
uz_i = idat.eFrame1.getColumn(2); |
496 |
> |
uz_i = idat.eFrame1->getColumn(2); |
497 |
|
|
498 |
|
ct_i = dot(uz_i, rhat); |
499 |
|
|
509 |
|
qyy_i = Q_i.y(); |
510 |
|
qzz_i = Q_i.z(); |
511 |
|
|
512 |
< |
ux_i = idat.eFrame1.getColumn(0); |
513 |
< |
uy_i = idat.eFrame1.getColumn(1); |
514 |
< |
uz_i = idat.eFrame1.getColumn(2); |
512 |
> |
ux_i = idat.eFrame1->getColumn(0); |
513 |
> |
uy_i = idat.eFrame1->getColumn(1); |
514 |
> |
uz_i = idat.eFrame1->getColumn(2); |
515 |
|
|
516 |
|
cx_i = dot(ux_i, rhat); |
517 |
|
cy_i = dot(uy_i, rhat); |
522 |
|
duduz_i = V3Zero; |
523 |
|
} |
524 |
|
|
525 |
< |
if (j_is_Charge) |
526 |
< |
q_j = data2.charge; |
525 |
> |
if (j_is_Charge) { |
526 |
> |
q_j = data2.fixedCharge; |
527 |
|
|
528 |
+ |
if (j_is_Fluctuating) |
529 |
+ |
q_j += *(idat.flucQ2); |
530 |
+ |
|
531 |
+ |
if (idat.excluded) { |
532 |
+ |
*(idat.skippedCharge1) += q_j; |
533 |
+ |
} |
534 |
+ |
} |
535 |
+ |
|
536 |
+ |
|
537 |
|
if (j_is_Dipole) { |
538 |
|
mu_j = data2.dipole_moment; |
539 |
< |
uz_j = idat.eFrame2.getColumn(2); |
539 |
> |
uz_j = idat.eFrame2->getColumn(2); |
540 |
|
|
541 |
|
ct_j = dot(uz_j, rhat); |
542 |
|
|
552 |
|
qyy_j = Q_j.y(); |
553 |
|
qzz_j = Q_j.z(); |
554 |
|
|
555 |
< |
ux_j = idat.eFrame2.getColumn(0); |
556 |
< |
uy_j = idat.eFrame2.getColumn(1); |
557 |
< |
uz_j = idat.eFrame2.getColumn(2); |
555 |
> |
ux_j = idat.eFrame2->getColumn(0); |
556 |
> |
uy_j = idat.eFrame2->getColumn(1); |
557 |
> |
uz_j = idat.eFrame2->getColumn(2); |
558 |
|
|
559 |
|
cx_j = dot(ux_j, rhat); |
560 |
|
cy_j = dot(uy_j, rhat); |
565 |
|
duduz_j = V3Zero; |
566 |
|
} |
567 |
|
|
568 |
+ |
if (i_is_Fluctuating && j_is_Fluctuating) { |
569 |
+ |
J1 = Jij[idat.atypes]; |
570 |
+ |
J2 = Jij[make_pair(idat.atypes.second, idat.atypes.first)]; |
571 |
+ |
} |
572 |
+ |
|
573 |
|
epot = 0.0; |
574 |
|
dVdr = V3Zero; |
575 |
|
|
578 |
|
if (j_is_Charge) { |
579 |
|
if (screeningMethod_ == DAMPED) { |
580 |
|
// assemble the damping variables |
581 |
< |
res = erfcSpline_->getValueAndDerivativeAt(idat.rij); |
582 |
< |
erfcVal = res.first; |
583 |
< |
derfcVal = res.second; |
581 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
582 |
> |
//erfcVal = res.first; |
583 |
> |
//derfcVal = res.second; |
584 |
> |
|
585 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
586 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
587 |
> |
|
588 |
|
c1 = erfcVal * riji; |
589 |
|
c2 = (-derfcVal + c1) * riji; |
590 |
|
} else { |
592 |
|
c2 = c1 * riji; |
593 |
|
} |
594 |
|
|
595 |
< |
preVal = idat.electroMult * pre11_ * q_i * q_j; |
595 |
> |
preVal = *(idat.electroMult) * pre11_; |
596 |
|
|
597 |
< |
if (summationMethod_ == SHIFTED_POTENTIAL) { |
597 |
> |
if (summationMethod_ == esm_SHIFTED_POTENTIAL) { |
598 |
|
vterm = preVal * (c1 - c1c_); |
599 |
< |
dudr = -idat.sw * preVal * c2; |
599 |
> |
dudr = - *(idat.sw) * preVal * c2; |
600 |
|
|
601 |
< |
} else if (summationMethod_ == SHIFTED_FORCE) { |
602 |
< |
vterm = preVal * ( c1 - c1c_ + c2c_*(idat.rij - defaultCutoff_) ); |
603 |
< |
dudr = idat.sw * preVal * (c2c_ - c2); |
495 |
< |
|
496 |
< |
} else if (summationMethod_ == REACTION_FIELD) { |
497 |
< |
rfVal = idat.electroMult * preRF_ * idat.rij * idat.rij; |
498 |
< |
vterm = preVal * ( riji + rfVal ); |
499 |
< |
dudr = idat.sw * preVal * ( 2.0 * rfVal - riji ) * riji; |
601 |
> |
} else if (summationMethod_ == esm_SHIFTED_FORCE) { |
602 |
> |
vterm = preVal * ( c1 - c1c_ + c2c_*( *(idat.rij) - cutoffRadius_) ); |
603 |
> |
dudr = *(idat.sw) * preVal * (c2c_ - c2); |
604 |
|
|
605 |
+ |
} else if (summationMethod_ == esm_REACTION_FIELD) { |
606 |
+ |
rfVal = preRF_ * *(idat.rij) * *(idat.rij); |
607 |
+ |
|
608 |
+ |
vterm = preVal * ( riji + rfVal ); |
609 |
+ |
dudr = *(idat.sw) * preVal * ( 2.0 * rfVal - riji ) * riji; |
610 |
+ |
|
611 |
+ |
// if this is an excluded pair, there are still indirect |
612 |
+ |
// interactions via the reaction field we must worry about: |
613 |
+ |
|
614 |
+ |
if (idat.excluded) { |
615 |
+ |
indirect_vpair += preVal * rfVal; |
616 |
+ |
indirect_Pot += *(idat.sw) * preVal * rfVal; |
617 |
+ |
indirect_dVdr += *(idat.sw) * preVal * two * rfVal * riji * rhat; |
618 |
+ |
} |
619 |
+ |
|
620 |
|
} else { |
502 |
– |
vterm = preVal * riji * erfcVal; |
621 |
|
|
622 |
< |
dudr = - idat.sw * preVal * c2; |
622 |
> |
vterm = preVal * riji * erfcVal; |
623 |
> |
dudr = - *(idat.sw) * preVal * c2; |
624 |
> |
|
625 |
> |
} |
626 |
> |
|
627 |
> |
vpair += vterm * q_i * q_j; |
628 |
> |
epot += *(idat.sw) * vterm * q_i * q_j; |
629 |
> |
dVdr += dudr * rhat * q_i * q_j; |
630 |
|
|
631 |
+ |
if (i_is_Fluctuating) { |
632 |
+ |
if (idat.excluded) { |
633 |
+ |
// vFluc1 is the difference between the direct coulomb integral |
634 |
+ |
// and the normal 1/r-like interaction between point charges. |
635 |
+ |
coulInt = J1->getValueAt( *(idat.rij) ); |
636 |
+ |
vFluc1 = coulInt - (*(idat.sw) * vterm); |
637 |
+ |
} else { |
638 |
+ |
vFluc1 = 0.0; |
639 |
+ |
} |
640 |
+ |
*(idat.dVdFQ1) += ( *(idat.sw) * vterm + vFluc1 ) * q_j; |
641 |
|
} |
507 |
– |
|
508 |
– |
idat.vpair += vterm; |
509 |
– |
epot += idat.sw * vterm; |
642 |
|
|
643 |
< |
dVdr += dudr * rhat; |
643 |
> |
if (j_is_Fluctuating) { |
644 |
> |
if (idat.excluded) { |
645 |
> |
// vFluc2 is the difference between the direct coulomb integral |
646 |
> |
// and the normal 1/r-like interaction between point charges. |
647 |
> |
coulInt = J2->getValueAt( *(idat.rij) ); |
648 |
> |
vFluc2 = coulInt - (*(idat.sw) * vterm); |
649 |
> |
} else { |
650 |
> |
vFluc2 = 0.0; |
651 |
> |
} |
652 |
> |
*(idat.dVdFQ2) += ( *(idat.sw) * vterm + vFluc2 ) * q_i; |
653 |
> |
} |
654 |
> |
|
655 |
> |
|
656 |
|
} |
657 |
|
|
658 |
|
if (j_is_Dipole) { |
659 |
|
// pref is used by all the possible methods |
660 |
< |
pref = idat.electroMult * pre12_ * q_i * mu_j; |
661 |
< |
preSw = idat.sw * pref; |
660 |
> |
pref = *(idat.electroMult) * pre12_ * q_i * mu_j; |
661 |
> |
preSw = *(idat.sw) * pref; |
662 |
|
|
663 |
< |
if (summationMethod_ == REACTION_FIELD) { |
663 |
> |
if (summationMethod_ == esm_REACTION_FIELD) { |
664 |
|
ri2 = riji * riji; |
665 |
|
ri3 = ri2 * riji; |
666 |
|
|
667 |
< |
vterm = - pref * ct_j * ( ri2 - preRF2_ * idat.rij ); |
668 |
< |
idat.vpair += vterm; |
669 |
< |
epot += idat.sw * vterm; |
667 |
> |
vterm = - pref * ct_j * ( ri2 - preRF2_ * *(idat.rij) ); |
668 |
> |
vpair += vterm; |
669 |
> |
epot += *(idat.sw) * vterm; |
670 |
|
|
671 |
< |
dVdr += -preSw * (ri3 * (uz_j - 3.0 * ct_j * rhat) - preRF2_*uz_j); |
672 |
< |
duduz_j += -preSw * rhat * (ri2 - preRF2_ * idat.rij); |
671 |
> |
dVdr += -preSw * (ri3 * (uz_j - three * ct_j * rhat) - preRF2_*uz_j); |
672 |
> |
duduz_j += -preSw * rhat * (ri2 - preRF2_ * *(idat.rij) ); |
673 |
|
|
674 |
+ |
// Even if we excluded this pair from direct interactions, |
675 |
+ |
// we still have the reaction-field-mediated charge-dipole |
676 |
+ |
// interaction: |
677 |
+ |
|
678 |
+ |
if (idat.excluded) { |
679 |
+ |
indirect_vpair += pref * ct_j * preRF2_ * *(idat.rij); |
680 |
+ |
indirect_Pot += preSw * ct_j * preRF2_ * *(idat.rij); |
681 |
+ |
indirect_dVdr += preSw * preRF2_ * uz_j; |
682 |
+ |
indirect_duduz_j += preSw * rhat * preRF2_ * *(idat.rij); |
683 |
+ |
} |
684 |
+ |
|
685 |
|
} else { |
686 |
|
// determine the inverse r used if we have split dipoles |
687 |
|
if (j_is_SplitDipole) { |
688 |
< |
BigR = sqrt(idat.r2 + 0.25 * d_j * d_j); |
688 |
> |
BigR = sqrt( *(idat.r2) + 0.25 * d_j * d_j); |
689 |
|
ri = 1.0 / BigR; |
690 |
< |
scale = idat.rij * ri; |
690 |
> |
scale = *(idat.rij) * ri; |
691 |
|
} else { |
692 |
|
ri = riji; |
693 |
|
scale = 1.0; |
697 |
|
|
698 |
|
if (screeningMethod_ == DAMPED) { |
699 |
|
// assemble the damping variables |
700 |
< |
res = erfcSpline_->getValueAndDerivativeAt(idat.rij); |
701 |
< |
erfcVal = res.first; |
702 |
< |
derfcVal = res.second; |
700 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
701 |
> |
//erfcVal = res.first; |
702 |
> |
//derfcVal = res.second; |
703 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
704 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
705 |
|
c1 = erfcVal * ri; |
706 |
|
c2 = (-derfcVal + c1) * ri; |
707 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri; |
716 |
|
// calculate the potential |
717 |
|
pot_term = scale * c2; |
718 |
|
vterm = -pref * ct_j * pot_term; |
719 |
< |
idat.vpair += vterm; |
720 |
< |
epot += idat.sw * vterm; |
719 |
> |
vpair += vterm; |
720 |
> |
epot += *(idat.sw) * vterm; |
721 |
|
|
722 |
|
// calculate derivatives for forces and torques |
723 |
|
|
725 |
|
duduz_j += -preSw * pot_term * rhat; |
726 |
|
|
727 |
|
} |
728 |
+ |
if (i_is_Fluctuating) { |
729 |
+ |
*(idat.dVdFQ1) += ( *(idat.sw) * vterm ) / q_i; |
730 |
+ |
} |
731 |
|
} |
732 |
|
|
733 |
|
if (j_is_Quadrupole) { |
735 |
|
cx2 = cx_j * cx_j; |
736 |
|
cy2 = cy_j * cy_j; |
737 |
|
cz2 = cz_j * cz_j; |
738 |
< |
pref = idat.electroMult * pre14_ * q_i * one_third_; |
738 |
> |
pref = *(idat.electroMult) * pre14_ * q_i * one_third_; |
739 |
|
|
740 |
|
if (screeningMethod_ == DAMPED) { |
741 |
|
// assemble the damping variables |
742 |
< |
res = erfcSpline_->getValueAndDerivativeAt(idat.rij); |
743 |
< |
erfcVal = res.first; |
744 |
< |
derfcVal = res.second; |
742 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
743 |
> |
//erfcVal = res.first; |
744 |
> |
//derfcVal = res.second; |
745 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
746 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
747 |
|
c1 = erfcVal * riji; |
748 |
|
c2 = (-derfcVal + c1) * riji; |
749 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * riji; |
756 |
|
} |
757 |
|
|
758 |
|
// precompute variables for convenience |
759 |
< |
preSw = idat.sw * pref; |
759 |
> |
preSw = *(idat.sw) * pref; |
760 |
|
c2ri = c2 * riji; |
761 |
|
c3ri = c3 * riji; |
762 |
< |
c4rij = c4 * idat.rij; |
763 |
< |
rhatdot2 = 2.0 * rhat * c3; |
762 |
> |
c4rij = c4 * *(idat.rij) ; |
763 |
> |
rhatdot2 = two * rhat * c3; |
764 |
|
rhatc4 = rhat * c4rij; |
765 |
|
|
766 |
|
// calculate the potential |
768 |
|
qyy_j * (cy2*c3 - c2ri) + |
769 |
|
qzz_j * (cz2*c3 - c2ri) ); |
770 |
|
vterm = pref * pot_term; |
771 |
< |
idat.vpair += vterm; |
772 |
< |
epot += idat.sw * vterm; |
771 |
> |
vpair += vterm; |
772 |
> |
epot += *(idat.sw) * vterm; |
773 |
|
|
774 |
|
// calculate derivatives for the forces and torques |
775 |
|
|
776 |
< |
dVdr += -preSw * ( qxx_j* (cx2*rhatc4 - (2.0*cx_j*ux_j + rhat)*c3ri) + |
777 |
< |
qyy_j* (cy2*rhatc4 - (2.0*cy_j*uy_j + rhat)*c3ri) + |
778 |
< |
qzz_j* (cz2*rhatc4 - (2.0*cz_j*uz_j + rhat)*c3ri)); |
776 |
> |
dVdr += -preSw * ( qxx_j* (cx2*rhatc4 - (two*cx_j*ux_j + rhat)*c3ri) + |
777 |
> |
qyy_j* (cy2*rhatc4 - (two*cy_j*uy_j + rhat)*c3ri) + |
778 |
> |
qzz_j* (cz2*rhatc4 - (two*cz_j*uz_j + rhat)*c3ri)); |
779 |
|
|
780 |
|
dudux_j += preSw * qxx_j * cx_j * rhatdot2; |
781 |
|
duduy_j += preSw * qyy_j * cy_j * rhatdot2; |
782 |
|
duduz_j += preSw * qzz_j * cz_j * rhatdot2; |
783 |
+ |
if (i_is_Fluctuating) { |
784 |
+ |
*(idat.dVdFQ1) += ( *(idat.sw) * vterm ) / q_i; |
785 |
+ |
} |
786 |
+ |
|
787 |
|
} |
788 |
|
} |
789 |
|
|
791 |
|
|
792 |
|
if (j_is_Charge) { |
793 |
|
// variables used by all the methods |
794 |
< |
pref = idat.electroMult * pre12_ * q_j * mu_i; |
795 |
< |
preSw = idat.sw * pref; |
794 |
> |
pref = *(idat.electroMult) * pre12_ * q_j * mu_i; |
795 |
> |
preSw = *(idat.sw) * pref; |
796 |
|
|
797 |
< |
if (summationMethod_ == REACTION_FIELD) { |
797 |
> |
if (summationMethod_ == esm_REACTION_FIELD) { |
798 |
|
|
799 |
|
ri2 = riji * riji; |
800 |
|
ri3 = ri2 * riji; |
801 |
|
|
802 |
< |
vterm = pref * ct_i * ( ri2 - preRF2_ * idat.rij ); |
803 |
< |
idat.vpair += vterm; |
804 |
< |
epot += idat.sw * vterm; |
802 |
> |
vterm = pref * ct_i * ( ri2 - preRF2_ * *(idat.rij) ); |
803 |
> |
vpair += vterm; |
804 |
> |
epot += *(idat.sw) * vterm; |
805 |
|
|
806 |
< |
dVdr += preSw * (ri3 * (uz_i - 3.0 * ct_i * rhat) - preRF2_ * uz_i); |
806 |
> |
dVdr += preSw * (ri3 * (uz_i - three * ct_i * rhat) - preRF2_ * uz_i); |
807 |
|
|
808 |
< |
duduz_i += preSw * rhat * (ri2 - preRF2_ * idat.rij); |
808 |
> |
duduz_i += preSw * rhat * (ri2 - preRF2_ * *(idat.rij) ); |
809 |
> |
|
810 |
> |
// Even if we excluded this pair from direct interactions, |
811 |
> |
// we still have the reaction-field-mediated charge-dipole |
812 |
> |
// interaction: |
813 |
> |
|
814 |
> |
if (idat.excluded) { |
815 |
> |
indirect_vpair += -pref * ct_i * preRF2_ * *(idat.rij); |
816 |
> |
indirect_Pot += -preSw * ct_i * preRF2_ * *(idat.rij); |
817 |
> |
indirect_dVdr += -preSw * preRF2_ * uz_i; |
818 |
> |
indirect_duduz_i += -preSw * rhat * preRF2_ * *(idat.rij); |
819 |
> |
} |
820 |
|
|
821 |
|
} else { |
822 |
|
|
823 |
|
// determine inverse r if we are using split dipoles |
824 |
|
if (i_is_SplitDipole) { |
825 |
< |
BigR = sqrt(idat.r2 + 0.25 * d_i * d_i); |
825 |
> |
BigR = sqrt( *(idat.r2) + 0.25 * d_i * d_i); |
826 |
|
ri = 1.0 / BigR; |
827 |
< |
scale = idat.rij * ri; |
827 |
> |
scale = *(idat.rij) * ri; |
828 |
|
} else { |
829 |
|
ri = riji; |
830 |
|
scale = 1.0; |
834 |
|
|
835 |
|
if (screeningMethod_ == DAMPED) { |
836 |
|
// assemble the damping variables |
837 |
< |
res = erfcSpline_->getValueAndDerivativeAt(idat.rij); |
838 |
< |
erfcVal = res.first; |
839 |
< |
derfcVal = res.second; |
837 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
838 |
> |
//erfcVal = res.first; |
839 |
> |
//derfcVal = res.second; |
840 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
841 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
842 |
|
c1 = erfcVal * ri; |
843 |
|
c2 = (-derfcVal + c1) * ri; |
844 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri; |
853 |
|
// calculate the potential |
854 |
|
pot_term = c2 * scale; |
855 |
|
vterm = pref * ct_i * pot_term; |
856 |
< |
idat.vpair += vterm; |
857 |
< |
epot += idat.sw * vterm; |
856 |
> |
vpair += vterm; |
857 |
> |
epot += *(idat.sw) * vterm; |
858 |
|
|
859 |
|
// calculate derivatives for the forces and torques |
860 |
|
dVdr += preSw * (uz_i * c2ri - ct_i * rhat * sc2 * c3); |
861 |
|
duduz_i += preSw * pot_term * rhat; |
862 |
|
} |
863 |
+ |
|
864 |
+ |
if (j_is_Fluctuating) { |
865 |
+ |
*(idat.dVdFQ2) += ( *(idat.sw) * vterm ) / q_j; |
866 |
+ |
} |
867 |
+ |
|
868 |
|
} |
869 |
|
|
870 |
|
if (j_is_Dipole) { |
871 |
|
// variables used by all methods |
872 |
|
ct_ij = dot(uz_i, uz_j); |
873 |
|
|
874 |
< |
pref = idat.electroMult * pre22_ * mu_i * mu_j; |
875 |
< |
preSw = idat.sw * pref; |
874 |
> |
pref = *(idat.electroMult) * pre22_ * mu_i * mu_j; |
875 |
> |
preSw = *(idat.sw) * pref; |
876 |
|
|
877 |
< |
if (summationMethod_ == REACTION_FIELD) { |
877 |
> |
if (summationMethod_ == esm_REACTION_FIELD) { |
878 |
|
ri2 = riji * riji; |
879 |
|
ri3 = ri2 * riji; |
880 |
|
ri4 = ri2 * ri2; |
881 |
|
|
882 |
|
vterm = pref * ( ri3 * (ct_ij - 3.0 * ct_i * ct_j) - |
883 |
|
preRF2_ * ct_ij ); |
884 |
< |
idat.vpair += vterm; |
885 |
< |
epot += idat.sw * vterm; |
884 |
> |
vpair += vterm; |
885 |
> |
epot += *(idat.sw) * vterm; |
886 |
|
|
887 |
|
a1 = 5.0 * ct_i * ct_j - ct_ij; |
888 |
|
|
889 |
< |
dVdr += preSw * 3.0 * ri4 * (a1 * rhat - ct_i * uz_j - ct_j * uz_i); |
889 |
> |
dVdr += preSw * three * ri4 * (a1 * rhat - ct_i * uz_j - ct_j * uz_i); |
890 |
|
|
891 |
< |
duduz_i += preSw * (ri3 * (uz_j - 3.0 * ct_j * rhat) - preRF2_*uz_j); |
892 |
< |
duduz_j += preSw * (ri3 * (uz_i - 3.0 * ct_i * rhat) - preRF2_*uz_i); |
891 |
> |
duduz_i += preSw * (ri3 * (uz_j - three * ct_j * rhat) - preRF2_*uz_j); |
892 |
> |
duduz_j += preSw * (ri3 * (uz_i - three * ct_i * rhat) - preRF2_*uz_i); |
893 |
|
|
894 |
+ |
if (idat.excluded) { |
895 |
+ |
indirect_vpair += - pref * preRF2_ * ct_ij; |
896 |
+ |
indirect_Pot += - preSw * preRF2_ * ct_ij; |
897 |
+ |
indirect_duduz_i += -preSw * preRF2_ * uz_j; |
898 |
+ |
indirect_duduz_j += -preSw * preRF2_ * uz_i; |
899 |
+ |
} |
900 |
+ |
|
901 |
|
} else { |
902 |
|
|
903 |
|
if (i_is_SplitDipole) { |
904 |
|
if (j_is_SplitDipole) { |
905 |
< |
BigR = sqrt(idat.r2 + 0.25 * d_i * d_i + 0.25 * d_j * d_j); |
905 |
> |
BigR = sqrt( *(idat.r2) + 0.25 * d_i * d_i + 0.25 * d_j * d_j); |
906 |
|
} else { |
907 |
< |
BigR = sqrt(idat.r2 + 0.25 * d_i * d_i); |
907 |
> |
BigR = sqrt( *(idat.r2) + 0.25 * d_i * d_i); |
908 |
|
} |
909 |
|
ri = 1.0 / BigR; |
910 |
< |
scale = idat.rij * ri; |
910 |
> |
scale = *(idat.rij) * ri; |
911 |
|
} else { |
912 |
|
if (j_is_SplitDipole) { |
913 |
< |
BigR = sqrt(idat.r2 + 0.25 * d_j * d_j); |
913 |
> |
BigR = sqrt( *(idat.r2) + 0.25 * d_j * d_j); |
914 |
|
ri = 1.0 / BigR; |
915 |
< |
scale = idat.rij * ri; |
915 |
> |
scale = *(idat.rij) * ri; |
916 |
|
} else { |
917 |
|
ri = riji; |
918 |
|
scale = 1.0; |
920 |
|
} |
921 |
|
if (screeningMethod_ == DAMPED) { |
922 |
|
// assemble damping variables |
923 |
< |
res = erfcSpline_->getValueAndDerivativeAt(idat.rij); |
924 |
< |
erfcVal = res.first; |
925 |
< |
derfcVal = res.second; |
923 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
924 |
> |
//erfcVal = res.first; |
925 |
> |
//derfcVal = res.second; |
926 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
927 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
928 |
|
c1 = erfcVal * ri; |
929 |
|
c2 = (-derfcVal + c1) * ri; |
930 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * ri; |
944 |
|
preSwSc = preSw * scale; |
945 |
|
c2ri = c2 * ri; |
946 |
|
c3ri = c3 * ri; |
947 |
< |
c4rij = c4 * idat.rij; |
947 |
> |
c4rij = c4 * *(idat.rij) ; |
948 |
|
|
949 |
|
// calculate the potential |
950 |
|
pot_term = (ct_ij * c2ri - ctidotj * c3); |
951 |
|
vterm = pref * pot_term; |
952 |
< |
idat.vpair += vterm; |
953 |
< |
epot += idat.sw * vterm; |
952 |
> |
vpair += vterm; |
953 |
> |
epot += *(idat.sw) * vterm; |
954 |
|
|
955 |
|
// calculate derivatives for the forces and torques |
956 |
|
dVdr += preSwSc * ( ctidotj * rhat * c4rij - |
969 |
|
cy2 = cy_i * cy_i; |
970 |
|
cz2 = cz_i * cz_i; |
971 |
|
|
972 |
< |
pref = idat.electroMult * pre14_ * q_j * one_third_; |
972 |
> |
pref = *(idat.electroMult) * pre14_ * q_j * one_third_; |
973 |
|
|
974 |
|
if (screeningMethod_ == DAMPED) { |
975 |
|
// assemble the damping variables |
976 |
< |
res = erfcSpline_->getValueAndDerivativeAt(idat.rij); |
977 |
< |
erfcVal = res.first; |
978 |
< |
derfcVal = res.second; |
976 |
> |
//res = erfcSpline_->getValueAndDerivativeAt( *(idat.rij) ); |
977 |
> |
//erfcVal = res.first; |
978 |
> |
//derfcVal = res.second; |
979 |
> |
erfcVal = erfc(dampingAlpha_ * *(idat.rij)); |
980 |
> |
derfcVal = - alphaPi_ * exp(-alpha2_ * *(idat.r2)); |
981 |
|
c1 = erfcVal * riji; |
982 |
|
c2 = (-derfcVal + c1) * riji; |
983 |
|
c3 = -2.0 * derfcVal * alpha2_ + 3.0 * c2 * riji; |
990 |
|
} |
991 |
|
|
992 |
|
// precompute some variables for convenience |
993 |
< |
preSw = idat.sw * pref; |
993 |
> |
preSw = *(idat.sw) * pref; |
994 |
|
c2ri = c2 * riji; |
995 |
|
c3ri = c3 * riji; |
996 |
< |
c4rij = c4 * idat.rij; |
997 |
< |
rhatdot2 = 2.0 * rhat * c3; |
996 |
> |
c4rij = c4 * *(idat.rij) ; |
997 |
> |
rhatdot2 = two * rhat * c3; |
998 |
|
rhatc4 = rhat * c4rij; |
999 |
|
|
1000 |
|
// calculate the potential |
1003 |
|
qzz_i * (cz2 * c3 - c2ri) ); |
1004 |
|
|
1005 |
|
vterm = pref * pot_term; |
1006 |
< |
idat.vpair += vterm; |
1007 |
< |
epot += idat.sw * vterm; |
1006 |
> |
vpair += vterm; |
1007 |
> |
epot += *(idat.sw) * vterm; |
1008 |
|
|
1009 |
|
// calculate the derivatives for the forces and torques |
1010 |
|
|
1011 |
< |
dVdr += -preSw * (qxx_i* (cx2*rhatc4 - (2.0*cx_i*ux_i + rhat)*c3ri) + |
1012 |
< |
qyy_i* (cy2*rhatc4 - (2.0*cy_i*uy_i + rhat)*c3ri) + |
1013 |
< |
qzz_i* (cz2*rhatc4 - (2.0*cz_i*uz_i + rhat)*c3ri)); |
1011 |
> |
dVdr += -preSw * (qxx_i* (cx2*rhatc4 - (two*cx_i*ux_i + rhat)*c3ri) + |
1012 |
> |
qyy_i* (cy2*rhatc4 - (two*cy_i*uy_i + rhat)*c3ri) + |
1013 |
> |
qzz_i* (cz2*rhatc4 - (two*cz_i*uz_i + rhat)*c3ri)); |
1014 |
|
|
1015 |
|
dudux_i += preSw * qxx_i * cx_i * rhatdot2; |
1016 |
|
duduy_i += preSw * qyy_i * cy_i * rhatdot2; |
1017 |
|
duduz_i += preSw * qzz_i * cz_i * rhatdot2; |
823 |
– |
} |
824 |
– |
} |
1018 |
|
|
1019 |
< |
idat.pot += epot; |
1020 |
< |
idat.f1 += dVdr; |
1019 |
> |
if (j_is_Fluctuating) { |
1020 |
> |
*(idat.dVdFQ2) += ( *(idat.sw) * vterm ) / q_j; |
1021 |
> |
} |
1022 |
|
|
1023 |
< |
if (i_is_Dipole || i_is_Quadrupole) |
830 |
< |
idat.t1 -= cross(uz_i, duduz_i); |
831 |
< |
if (i_is_Quadrupole) { |
832 |
< |
idat.t1 -= cross(ux_i, dudux_i); |
833 |
< |
idat.t1 -= cross(uy_i, duduy_i); |
1023 |
> |
} |
1024 |
|
} |
1025 |
|
|
836 |
– |
if (j_is_Dipole || j_is_Quadrupole) |
837 |
– |
idat.t2 -= cross(uz_j, duduz_j); |
838 |
– |
if (j_is_Quadrupole) { |
839 |
– |
idat.t2 -= cross(uz_j, dudux_j); |
840 |
– |
idat.t2 -= cross(uz_j, duduy_j); |
841 |
– |
} |
1026 |
|
|
1027 |
< |
return; |
1028 |
< |
} |
1027 |
> |
if (!idat.excluded) { |
1028 |
> |
*(idat.vpair) += vpair; |
1029 |
> |
(*(idat.pot))[ELECTROSTATIC_FAMILY] += epot; |
1030 |
> |
*(idat.f1) += dVdr; |
1031 |
> |
|
1032 |
> |
if (i_is_Dipole || i_is_Quadrupole) |
1033 |
> |
*(idat.t1) -= cross(uz_i, duduz_i); |
1034 |
> |
if (i_is_Quadrupole) { |
1035 |
> |
*(idat.t1) -= cross(ux_i, dudux_i); |
1036 |
> |
*(idat.t1) -= cross(uy_i, duduy_i); |
1037 |
> |
} |
1038 |
> |
|
1039 |
> |
if (j_is_Dipole || j_is_Quadrupole) |
1040 |
> |
*(idat.t2) -= cross(uz_j, duduz_j); |
1041 |
> |
if (j_is_Quadrupole) { |
1042 |
> |
*(idat.t2) -= cross(uz_j, dudux_j); |
1043 |
> |
*(idat.t2) -= cross(uz_j, duduy_j); |
1044 |
> |
} |
1045 |
|
|
1046 |
< |
void Electrostatic::calcSkipCorrection(SkipCorrectionData skdat) { |
1046 |
> |
} else { |
1047 |
|
|
1048 |
< |
if (!initialized_) initialize(); |
1049 |
< |
|
850 |
< |
ElectrostaticAtomData data1 = ElectrostaticMap[skdat.atype1]; |
851 |
< |
ElectrostaticAtomData data2 = ElectrostaticMap[skdat.atype2]; |
852 |
< |
|
853 |
< |
// logicals |
1048 |
> |
// only accumulate the forces and torques resulting from the |
1049 |
> |
// indirect reaction field terms. |
1050 |
|
|
1051 |
< |
bool i_is_Charge = data1.is_Charge; |
1052 |
< |
bool i_is_Dipole = data1.is_Dipole; |
1053 |
< |
|
858 |
< |
bool j_is_Charge = data2.is_Charge; |
859 |
< |
bool j_is_Dipole = data2.is_Dipole; |
860 |
< |
|
861 |
< |
RealType q_i, q_j; |
862 |
< |
|
863 |
< |
// The skippedCharge computation is needed by the real-space cutoff methods |
864 |
< |
// (i.e. shifted force and shifted potential) |
865 |
< |
|
866 |
< |
if (i_is_Charge) { |
867 |
< |
q_i = data1.charge; |
868 |
< |
skdat.skippedCharge2 += q_i; |
869 |
< |
} |
870 |
< |
|
871 |
< |
if (j_is_Charge) { |
872 |
< |
q_j = data2.charge; |
873 |
< |
skdat.skippedCharge1 += q_j; |
874 |
< |
} |
875 |
< |
|
876 |
< |
// the rest of this function should only be necessary for reaction field. |
877 |
< |
|
878 |
< |
if (summationMethod_ == REACTION_FIELD) { |
879 |
< |
RealType riji, ri2, ri3; |
880 |
< |
RealType q_i, mu_i, ct_i; |
881 |
< |
RealType q_j, mu_j, ct_j; |
882 |
< |
RealType preVal, rfVal, vterm, dudr, pref, myPot; |
883 |
< |
Vector3d dVdr, uz_i, uz_j, duduz_i, duduz_j, rhat; |
884 |
< |
|
885 |
< |
// some variables we'll need independent of electrostatic type: |
1051 |
> |
*(idat.vpair) += indirect_vpair; |
1052 |
> |
(*(idat.pot))[ELECTROSTATIC_FAMILY] += indirect_Pot; |
1053 |
> |
*(idat.f1) += indirect_dVdr; |
1054 |
|
|
887 |
– |
riji = 1.0 / skdat.rij; |
888 |
– |
rhat = skdat.d * riji; |
889 |
– |
|
890 |
– |
if (i_is_Dipole) { |
891 |
– |
mu_i = data1.dipole_moment; |
892 |
– |
uz_i = skdat.eFrame1.getColumn(2); |
893 |
– |
ct_i = dot(uz_i, rhat); |
894 |
– |
duduz_i = V3Zero; |
895 |
– |
} |
896 |
– |
|
897 |
– |
if (j_is_Dipole) { |
898 |
– |
mu_j = data2.dipole_moment; |
899 |
– |
uz_j = skdat.eFrame2.getColumn(2); |
900 |
– |
ct_j = dot(uz_j, rhat); |
901 |
– |
duduz_j = V3Zero; |
902 |
– |
} |
903 |
– |
|
904 |
– |
if (i_is_Charge) { |
905 |
– |
if (j_is_Charge) { |
906 |
– |
preVal = skdat.electroMult * pre11_ * q_i * q_j; |
907 |
– |
rfVal = preRF_ * skdat.rij * skdat.rij; |
908 |
– |
vterm = preVal * rfVal; |
909 |
– |
myPot += skdat.sw * vterm; |
910 |
– |
dudr = skdat.sw * preVal * 2.0 * rfVal * riji; |
911 |
– |
dVdr += dudr * rhat; |
912 |
– |
} |
913 |
– |
|
914 |
– |
if (j_is_Dipole) { |
915 |
– |
ri2 = riji * riji; |
916 |
– |
ri3 = ri2 * riji; |
917 |
– |
pref = skdat.electroMult * pre12_ * q_i * mu_j; |
918 |
– |
vterm = - pref * ct_j * ( ri2 - preRF2_ * skdat.rij ); |
919 |
– |
myPot += skdat.sw * vterm; |
920 |
– |
dVdr += -skdat.sw * pref * ( ri3 * ( uz_j - 3.0 * ct_j * rhat) - preRF2_ * uz_j); |
921 |
– |
duduz_j += -skdat.sw * pref * rhat * (ri2 - preRF2_ * skdat.rij); |
922 |
– |
} |
923 |
– |
} |
924 |
– |
if (i_is_Dipole) { |
925 |
– |
if (j_is_Charge) { |
926 |
– |
ri2 = riji * riji; |
927 |
– |
ri3 = ri2 * riji; |
928 |
– |
pref = skdat.electroMult * pre12_ * q_j * mu_i; |
929 |
– |
vterm = - pref * ct_i * ( ri2 - preRF2_ * skdat.rij ); |
930 |
– |
myPot += skdat.sw * vterm; |
931 |
– |
dVdr += skdat.sw * pref * ( ri3 * ( uz_i - 3.0 * ct_i * rhat) - preRF2_ * uz_i); |
932 |
– |
duduz_i += skdat.sw * pref * rhat * (ri2 - preRF2_ * skdat.rij); |
933 |
– |
} |
934 |
– |
} |
935 |
– |
|
936 |
– |
// accumulate the forces and torques resulting from the self term |
937 |
– |
skdat.pot += myPot; |
938 |
– |
skdat.f1 += dVdr; |
939 |
– |
|
1055 |
|
if (i_is_Dipole) |
1056 |
< |
skdat.t1 -= cross(uz_i, duduz_i); |
1056 |
> |
*(idat.t1) -= cross(uz_i, indirect_duduz_i); |
1057 |
|
if (j_is_Dipole) |
1058 |
< |
skdat.t2 -= cross(uz_j, duduz_j); |
1058 |
> |
*(idat.t2) -= cross(uz_j, indirect_duduz_j); |
1059 |
|
} |
1060 |
< |
} |
1060 |
> |
|
1061 |
> |
return; |
1062 |
> |
} |
1063 |
|
|
1064 |
< |
void Electrostatic::calcSelfCorrection(SelfCorrectionData scdat) { |
1065 |
< |
RealType mu1, preVal, chg1, self; |
949 |
< |
|
1064 |
> |
void Electrostatic::calcSelfCorrection(SelfData &sdat) { |
1065 |
> |
RealType mu1, preVal, self; |
1066 |
|
if (!initialized_) initialize(); |
1067 |
< |
|
1068 |
< |
ElectrostaticAtomData data = ElectrostaticMap[scdat.atype]; |
1067 |
> |
|
1068 |
> |
ElectrostaticAtomData data = ElectrostaticMap[sdat.atype]; |
1069 |
|
|
1070 |
|
// logicals |
955 |
– |
|
1071 |
|
bool i_is_Charge = data.is_Charge; |
1072 |
|
bool i_is_Dipole = data.is_Dipole; |
1073 |
+ |
bool i_is_Fluctuating = data.is_Fluctuating; |
1074 |
+ |
RealType chg1 = data.fixedCharge; |
1075 |
+ |
|
1076 |
+ |
if (i_is_Fluctuating) { |
1077 |
+ |
chg1 += *(sdat.flucQ); |
1078 |
+ |
// dVdFQ is really a force, so this is negative the derivative |
1079 |
+ |
*(sdat.dVdFQ) -= *(sdat.flucQ) * data.hardness + data.electronegativity; |
1080 |
+ |
} |
1081 |
|
|
1082 |
< |
if (summationMethod_ == REACTION_FIELD) { |
1082 |
> |
if (summationMethod_ == esm_REACTION_FIELD) { |
1083 |
|
if (i_is_Dipole) { |
1084 |
|
mu1 = data.dipole_moment; |
1085 |
|
preVal = pre22_ * preRF2_ * mu1 * mu1; |
1086 |
< |
scdat.pot -= 0.5 * preVal; |
1086 |
> |
(*(sdat.pot))[ELECTROSTATIC_FAMILY] -= 0.5 * preVal; |
1087 |
|
|
1088 |
|
// The self-correction term adds into the reaction field vector |
1089 |
< |
Vector3d uz_i = scdat.eFrame.getColumn(2); |
1089 |
> |
Vector3d uz_i = sdat.eFrame->getColumn(2); |
1090 |
|
Vector3d ei = preVal * uz_i; |
1091 |
|
|
1092 |
|
// This looks very wrong. A vector crossed with itself is zero. |
1093 |
< |
scdat.t -= cross(uz_i, ei); |
1093 |
> |
*(sdat.t) -= cross(uz_i, ei); |
1094 |
|
} |
1095 |
< |
} else if (summationMethod_ == SHIFTED_FORCE || summationMethod_ == SHIFTED_POTENTIAL) { |
1095 |
> |
} else if (summationMethod_ == esm_SHIFTED_FORCE || summationMethod_ == esm_SHIFTED_POTENTIAL) { |
1096 |
|
if (i_is_Charge) { |
974 |
– |
chg1 = data.charge; |
1097 |
|
if (screeningMethod_ == DAMPED) { |
1098 |
< |
self = - 0.5 * (c1c_ + alphaPi_) * chg1 * (chg1 + scdat.skippedCharge) * pre11_; |
1098 |
> |
self = - 0.5 * (c1c_ + alphaPi_) * chg1 * (chg1 + *(sdat.skippedCharge)) * pre11_; |
1099 |
|
} else { |
1100 |
< |
self = - 0.5 * rcuti_ * chg1 * (chg1 + scdat.skippedCharge) * pre11_; |
1100 |
> |
self = - 0.5 * rcuti_ * chg1 * (chg1 + *(sdat.skippedCharge)) * pre11_; |
1101 |
|
} |
1102 |
< |
scdat.pot += self; |
1102 |
> |
(*(sdat.pot))[ELECTROSTATIC_FAMILY] += self; |
1103 |
|
} |
1104 |
|
} |
1105 |
|
} |
1106 |
|
|
1107 |
< |
RealType Electrostatic::getSuggestedCutoffRadius(AtomType* at1, AtomType* at2) { |
1107 |
> |
RealType Electrostatic::getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes) { |
1108 |
|
// This seems to work moderately well as a default. There's no |
1109 |
|
// inherent scale for 1/r interactions that we can standardize. |
1110 |
|
// 12 angstroms seems to be a reasonably good guess for most |