1 |
gezelter |
1502 |
/* |
2 |
|
|
* Copyright (c) 2009 The University of Notre Dame. All Rights Reserved. |
3 |
|
|
* |
4 |
|
|
* The University of Notre Dame grants you ("Licensee") a |
5 |
|
|
* non-exclusive, royalty free, license to use, modify and |
6 |
|
|
* redistribute this software in source and binary code form, provided |
7 |
|
|
* that the following conditions are met: |
8 |
|
|
* |
9 |
|
|
* 1. Redistributions of source code must retain the above copyright |
10 |
|
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
|
* |
12 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
|
* documentation and/or other materials provided with the |
15 |
|
|
* distribution. |
16 |
|
|
* |
17 |
|
|
* This software is provided "AS IS," without a warranty of any |
18 |
|
|
* kind. All express or implied conditions, representations and |
19 |
|
|
* warranties, including any implied warranty of merchantability, |
20 |
|
|
* fitness for a particular purpose or non-infringement, are hereby |
21 |
|
|
* excluded. The University of Notre Dame and its licensors shall not |
22 |
|
|
* be liable for any damages suffered by licensee as a result of |
23 |
|
|
* using, modifying or distributing the software or its |
24 |
|
|
* derivatives. In no event will the University of Notre Dame or its |
25 |
|
|
* licensors be liable for any lost revenue, profit or data, or for |
26 |
|
|
* direct, indirect, special, consequential, incidental or punitive |
27 |
|
|
* damages, however caused and regardless of the theory of liability, |
28 |
|
|
* arising out of the use of or inability to use software, even if the |
29 |
|
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
|
* such damages. |
31 |
|
|
* |
32 |
|
|
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
|
|
* research, please cite the appropriate papers when you publish your |
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). |
38 |
gezelter |
1879 |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
39 |
gezelter |
1665 |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
|
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
gezelter |
1502 |
*/ |
42 |
|
|
|
43 |
|
|
#ifndef NONBONDED_ELECTROSTATIC_HPP |
44 |
|
|
#define NONBONDED_ELECTROSTATIC_HPP |
45 |
|
|
|
46 |
|
|
#include "nonbonded/NonBondedInteraction.hpp" |
47 |
|
|
#include "types/AtomType.hpp" |
48 |
gezelter |
1725 |
#include "brains/ForceField.hpp" |
49 |
gezelter |
1502 |
#include "math/SquareMatrix3.hpp" |
50 |
|
|
#include "math/CubicSpline.hpp" |
51 |
gezelter |
1584 |
#include "brains/SimInfo.hpp" |
52 |
gezelter |
1969 |
#include "flucq/FluctuatingChargeForces.hpp" |
53 |
gezelter |
1502 |
|
54 |
|
|
namespace OpenMD { |
55 |
|
|
|
56 |
|
|
struct ElectrostaticAtomData { |
57 |
|
|
bool is_Charge; |
58 |
|
|
bool is_Dipole; |
59 |
|
|
bool is_Quadrupole; |
60 |
gezelter |
1718 |
bool is_Fluctuating; |
61 |
gezelter |
1969 |
bool has_MultipleMinima; |
62 |
gezelter |
1718 |
RealType fixedCharge; |
63 |
|
|
RealType hardness; |
64 |
|
|
RealType electronegativity; |
65 |
gezelter |
1767 |
int slaterN; |
66 |
gezelter |
1718 |
RealType slaterZeta; |
67 |
gezelter |
1969 |
RealType curvature; |
68 |
|
|
RealType coupling; |
69 |
|
|
vector<pair<int, RealType> > diabats; |
70 |
gezelter |
1879 |
Vector3d dipole; |
71 |
|
|
Mat3x3d quadrupole; |
72 |
gezelter |
1502 |
}; |
73 |
gezelter |
1718 |
|
74 |
gezelter |
1502 |
enum ElectrostaticSummationMethod{ |
75 |
gezelter |
1528 |
esm_HARD, |
76 |
|
|
esm_SWITCHING_FUNCTION, |
77 |
|
|
esm_SHIFTED_POTENTIAL, |
78 |
|
|
esm_SHIFTED_FORCE, |
79 |
gezelter |
1879 |
esm_TAYLOR_SHIFTED, |
80 |
gezelter |
1528 |
esm_REACTION_FIELD, |
81 |
gezelter |
1915 |
esm_EWALD_FULL, |
82 |
|
|
esm_EWALD_PME, /**< PME Ewald methods aren't supported yet */ |
83 |
|
|
esm_EWALD_SPME /**< SPME Ewald methods aren't supported yet */ |
84 |
gezelter |
1502 |
}; |
85 |
|
|
|
86 |
|
|
enum ElectrostaticScreeningMethod{ |
87 |
|
|
UNDAMPED, |
88 |
|
|
DAMPED |
89 |
|
|
}; |
90 |
|
|
|
91 |
|
|
class Electrostatic : public ElectrostaticInteraction { |
92 |
|
|
|
93 |
|
|
public: |
94 |
|
|
Electrostatic(); |
95 |
gezelter |
1969 |
void setForceField(ForceField *ff); |
96 |
|
|
void setSimulatedAtomTypes(set<AtomType*> &simtypes); |
97 |
gezelter |
1584 |
void setSimInfo(SimInfo* info) {info_ = info;}; |
98 |
gezelter |
1502 |
void addType(AtomType* atomType); |
99 |
gezelter |
1536 |
virtual void calcForce(InteractionData &idat); |
100 |
gezelter |
1545 |
virtual void calcSelfCorrection(SelfData &sdat); |
101 |
gezelter |
1502 |
virtual string getName() {return name_;} |
102 |
gezelter |
1545 |
virtual RealType getSuggestedCutoffRadius(pair<AtomType*, AtomType*> atypes); |
103 |
gezelter |
1584 |
void setCutoffRadius( RealType rCut ); |
104 |
gezelter |
1502 |
void setElectrostaticSummationMethod( ElectrostaticSummationMethod esm ); |
105 |
|
|
void setElectrostaticScreeningMethod( ElectrostaticScreeningMethod sm ); |
106 |
|
|
void setDampingAlpha( RealType alpha ); |
107 |
|
|
void setReactionFieldDielectric( RealType dielectric ); |
108 |
gezelter |
1925 |
void ReciprocalSpaceSum(RealType &pot); |
109 |
gezelter |
1502 |
|
110 |
|
|
private: |
111 |
|
|
void initialize(); |
112 |
|
|
string name_; |
113 |
|
|
bool initialized_; |
114 |
gezelter |
1528 |
bool haveCutoffRadius_; |
115 |
gezelter |
1502 |
bool haveDampingAlpha_; |
116 |
|
|
bool haveDielectric_; |
117 |
gezelter |
1879 |
bool haveElectroSplines_; |
118 |
gezelter |
1895 |
|
119 |
|
|
int nElectro_; |
120 |
|
|
int nFlucq_; |
121 |
|
|
|
122 |
|
|
set<int> Etypes; /**< The set of AtomType idents that are Electrostatic types */ |
123 |
|
|
vector<int> Etids; /**< The mapping from AtomType ident -> Electrostatic ident */ |
124 |
|
|
set<int> FQtypes; /**< The set of AtomType idents that are fluctuating types */ |
125 |
|
|
vector<int> FQtids; /**< The mapping from AtomType ident -> fluctuating ident */ |
126 |
|
|
vector<ElectrostaticAtomData> ElectrostaticMap; /**< data about Electrostatic types */ |
127 |
|
|
vector<vector<CubicSpline*> > Jij; /**< Coulomb integral for two fq types */ |
128 |
|
|
|
129 |
|
|
|
130 |
gezelter |
1584 |
SimInfo* info_; |
131 |
gezelter |
1502 |
ForceField* forceField_; |
132 |
gezelter |
1969 |
FluctuatingChargeForces* flucQ_; |
133 |
gezelter |
1895 |
set<AtomType*> simTypes_; |
134 |
gezelter |
1528 |
RealType cutoffRadius_; |
135 |
gezelter |
1502 |
RealType pre11_; |
136 |
|
|
RealType pre12_; |
137 |
|
|
RealType pre22_; |
138 |
|
|
RealType pre14_; |
139 |
gezelter |
1879 |
RealType pre24_; |
140 |
|
|
RealType pre44_; |
141 |
|
|
RealType v01, v11, v21, v22, v31, v32, v41, v42, v43; |
142 |
|
|
RealType dv01, dv11, dv21, dv22, dv31, dv32, dv41, dv42, dv43; |
143 |
|
|
RealType v01or, v11or, v21or, v22or, v31or, v32or, v41or, v42or, v43or; |
144 |
gezelter |
1502 |
RealType chargeToC_; |
145 |
|
|
RealType angstromToM_; |
146 |
|
|
RealType debyeToCm_; |
147 |
|
|
int np_; |
148 |
|
|
ElectrostaticSummationMethod summationMethod_; |
149 |
|
|
ElectrostaticScreeningMethod screeningMethod_; |
150 |
gezelter |
1528 |
map<string, ElectrostaticSummationMethod> summationMap_; |
151 |
|
|
map<string, ElectrostaticScreeningMethod> screeningMap_; |
152 |
gezelter |
1502 |
RealType dampingAlpha_; |
153 |
|
|
RealType dielectric_; |
154 |
|
|
RealType preRF_; |
155 |
gezelter |
1900 |
RealType selfMult1_; |
156 |
|
|
RealType selfMult2_; |
157 |
|
|
RealType selfMult4_; |
158 |
gezelter |
1879 |
|
159 |
|
|
CubicSpline* v01s; |
160 |
|
|
CubicSpline* v11s; |
161 |
|
|
CubicSpline* v21s; |
162 |
|
|
CubicSpline* v22s; |
163 |
|
|
CubicSpline* v31s; |
164 |
|
|
CubicSpline* v32s; |
165 |
|
|
CubicSpline* v41s; |
166 |
|
|
CubicSpline* v42s; |
167 |
|
|
CubicSpline* v43s; |
168 |
|
|
|
169 |
gezelter |
1893 |
ElectrostaticAtomData data1; |
170 |
|
|
ElectrostaticAtomData data2; |
171 |
|
|
RealType C_a, C_b; // Charges |
172 |
|
|
Vector3d D_a, D_b; // Dipoles (space-fixed) |
173 |
|
|
Mat3x3d Q_a, Q_b; // Quadrupoles (space-fixed) |
174 |
|
|
|
175 |
|
|
RealType ri; // Distance utility scalar |
176 |
|
|
RealType rdDa, rdDb; // Dipole utility scalars |
177 |
|
|
Vector3d rxDa, rxDb; // Dipole utility vectors |
178 |
|
|
RealType rdQar, rdQbr, trQa, trQb; // Quadrupole utility scalars |
179 |
|
|
Vector3d Qar, Qbr, rQa, rQb, rxQar, rxQbr; // Quadrupole utility vectors |
180 |
|
|
RealType pref; |
181 |
|
|
|
182 |
|
|
RealType DadDb, trQaQb, DadQbr, DbdQar; // Cross-interaction scalars |
183 |
|
|
RealType rQaQbr; |
184 |
|
|
Vector3d DaxDb, DadQb, DbdQa, DaxQbr, DbxQar; // Cross-interaction vectors |
185 |
|
|
Vector3d rQaQb, QaQbr, QaxQb, rQaxQbr; |
186 |
|
|
Mat3x3d QaQb; // Cross-interaction matrices |
187 |
|
|
|
188 |
|
|
RealType U; // Potential |
189 |
|
|
Vector3d F; // Force |
190 |
|
|
Vector3d Ta; // Torque on site a |
191 |
|
|
Vector3d Tb; // Torque on site b |
192 |
|
|
Vector3d Ea; // Electric field at site a |
193 |
|
|
Vector3d Eb; // Electric field at site b |
194 |
gezelter |
1993 |
RealType Pa; // Site potential at site a |
195 |
|
|
RealType Pb; // Site potential at site b |
196 |
gezelter |
1893 |
RealType dUdCa; // fluctuating charge force at site a |
197 |
|
|
RealType dUdCb; // fluctuating charge force at site a |
198 |
|
|
|
199 |
|
|
// Indirect interactions mediated by the reaction field. |
200 |
|
|
RealType indirect_Pot; // Potential |
201 |
|
|
Vector3d indirect_F; // Force |
202 |
|
|
Vector3d indirect_Ta; // Torque on site a |
203 |
|
|
Vector3d indirect_Tb; // Torque on site b |
204 |
|
|
|
205 |
|
|
// Excluded potential that is still computed for fluctuating charges |
206 |
|
|
RealType excluded_Pot; |
207 |
|
|
|
208 |
gezelter |
1932 |
RealType rfContrib, coulInt, dJdr; |
209 |
gezelter |
1893 |
|
210 |
|
|
// spline for coulomb integral |
211 |
|
|
CubicSpline* J; |
212 |
|
|
Vector3d rhat; |
213 |
|
|
|
214 |
|
|
// logicals |
215 |
|
|
|
216 |
|
|
bool a_is_Charge; |
217 |
|
|
bool a_is_Dipole; |
218 |
|
|
bool a_is_Quadrupole; |
219 |
|
|
bool a_is_Fluctuating; |
220 |
|
|
|
221 |
|
|
bool b_is_Charge; |
222 |
|
|
bool b_is_Dipole; |
223 |
|
|
bool b_is_Quadrupole; |
224 |
|
|
bool b_is_Fluctuating; |
225 |
|
|
|
226 |
|
|
|
227 |
gezelter |
1879 |
/* |
228 |
|
|
CubicSpline* dv01s; |
229 |
|
|
CubicSpline* dv11s; |
230 |
|
|
CubicSpline* dv21s; |
231 |
|
|
CubicSpline* dv22s; |
232 |
|
|
CubicSpline* dv31s; |
233 |
|
|
CubicSpline* dv32s; |
234 |
|
|
CubicSpline* dv41s; |
235 |
|
|
CubicSpline* dv42s; |
236 |
|
|
CubicSpline* dv43s; |
237 |
|
|
*/ |
238 |
gezelter |
1502 |
}; |
239 |
|
|
} |
240 |
|
|
|
241 |
|
|
|
242 |
|
|
#endif |