OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
Electrostatic.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the following paper when you publish your work:
33 *
34 * [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35 *
36 * Good starting points for code and simulation methodology are:
37 *
38 * [2] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
39 * [3] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
40 * [4] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
41 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
42 * [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
43 * [7] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
44 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
45 * [9] Drisko & Gezelter, J. Chem. Theory Comput. 20, 4986-4997 (2024).
46 */
47
48#ifndef NONBONDED_ELECTROSTATIC_HPP
49#define NONBONDED_ELECTROSTATIC_HPP
50
51#include "brains/ForceField.hpp"
52#include "brains/SimInfo.hpp"
53#include "flucq/FluctuatingChargeForces.hpp"
54#include "math/CubicSpline.hpp"
56#include "nonbonded/NonBondedInteraction.hpp"
57#include "primitives/Atom.hpp"
58#include "types/AtomType.hpp"
59
60namespace OpenMD {
61
63 bool is_Charge;
64 bool is_Dipole;
65 bool is_Quadrupole;
66 bool is_Fluctuating;
67 bool uses_SlaterIntramolecular;
68 RealType fixedCharge;
69 RealType hardness;
70 RealType electronegativity;
71 int slaterN;
72 RealType slaterZeta;
73 Vector3d dipole;
74 Mat3x3d quadrupole;
75 };
76
78 esm_HARD,
79 esm_SWITCHING_FUNCTION,
80 esm_SHIFTED_POTENTIAL,
81 esm_SHIFTED_FORCE,
82 esm_TAYLOR_SHIFTED,
83 esm_REACTION_FIELD,
84 esm_EWALD_FULL,
85 esm_EWALD_PME, /**< PME Ewald methods aren't supported yet */
86 esm_EWALD_SPME /**< SPME Ewald methods aren't supported yet */
87 };
88
89 enum ElectrostaticScreeningMethod { UNDAMPED, DAMPED };
90
91 class Electrostatic : public ElectrostaticInteraction {
92 public:
93 Electrostatic();
94 ~Electrostatic();
95 void setForceField(ForceField* ff);
96 void setSimulatedAtomTypes(AtomTypeSet& simtypes);
97 void setSimInfo(SimInfo* info) { info_ = info; };
98 void addType(AtomType* atomType);
99 virtual void calcForce(InteractionData& idat);
100 virtual void calcSelfCorrection(SelfData& sdat);
101 virtual string getName() { return name_; }
102 virtual RealType getSuggestedCutoffRadius(
103 pair<AtomType*, AtomType*> atypes);
104 void setCutoffRadius(RealType rCut);
105 void setElectrostaticSummationMethod(ElectrostaticSummationMethod esm);
106 void setElectrostaticScreeningMethod(ElectrostaticScreeningMethod sm);
107 void setDampingAlpha(RealType alpha);
108 void setReactionFieldDielectric(RealType dielectric);
109 void calcSurfaceTerm(bool slabGeometry, int axis, RealType& pot);
110 void ReciprocalSpaceSum(RealType& pot);
111
112 // Used by EAM to compute local fields:
113 RealType getFieldFunction(RealType r);
114
115 // Utility routine
116 void getSitePotentials(Atom* a1, Atom* a2, bool excluded, RealType& spot1,
117 RealType& spot2);
118
119 private:
120 void initialize();
121 string name_;
122 bool initialized_;
123 bool haveCutoffRadius_;
124 bool haveDampingAlpha_;
125 bool haveDielectric_;
126 bool haveElectroSplines_;
127
128 int nElectro_;
129 int nFlucq_;
130
131 set<int>
132 Etypes; /**< The set of AtomType idents that are Electrostatic types */
133 vector<int>
134 Etids; /**< The mapping from AtomType ident -> Electrostatic ident */
135 set<int>
136 FQtypes; /**< The set of AtomType idents that are fluctuating types */
137 vector<int>
138 FQtids; /**< The mapping from AtomType ident -> fluctuating ident */
139 vector<ElectrostaticAtomData>
140 ElectrostaticMap; /**< data about Electrostatic types */
141 vector<vector<CubicSplinePtr>>
142 Jij; /**< Coulomb integral for two fq types */
143
144 SimInfo* info_ {nullptr};
145 ForceField* forceField_;
147 AtomTypeSet simTypes_;
148 RealType cutoffRadius_;
149 RealType pre11_;
150 RealType pre12_;
151 RealType pre22_;
152 RealType pre14_;
153 RealType pre24_;
154 RealType pre44_;
155 RealType v01, v11, v21, v22, v31, v32, v41, v42, v43;
156 RealType dv01, dv11, dv21, dv22, dv31, dv32, dv41, dv42, dv43;
157 RealType v11or, v22or, v31or, v32or, v42or, v43or;
158 RealType chargeToC_;
159 RealType angstromToM_;
160 RealType debyeToCm_;
161 int np_;
162 ElectrostaticSummationMethod summationMethod_;
163 ElectrostaticScreeningMethod screeningMethod_;
164 map<string, ElectrostaticSummationMethod> summationMap_;
165 map<string, ElectrostaticScreeningMethod> screeningMap_;
166 RealType dampingAlpha_;
167 RealType dielectric_;
168 RealType preRF_;
169 RealType selfMult1_;
170 RealType selfMult2_;
171 RealType selfMult4_;
172
173 CubicSplinePtr v01s;
174 CubicSplinePtr v11s;
175 CubicSplinePtr v21s;
176 CubicSplinePtr v22s;
177 CubicSplinePtr v31s;
178 CubicSplinePtr v32s;
179 CubicSplinePtr v41s;
180 CubicSplinePtr v42s;
181 CubicSplinePtr v43s;
182
185 RealType C_a, C_b; // Charges
186 Vector3d D_a, D_b; // Dipoles (space-fixed)
187 Mat3x3d Q_a, Q_b; // Quadrupoles (space-fixed)
188
189 RealType ri; // Distance utility scalar
190 RealType rdDa, rdDb; // Dipole utility scalars
191 Vector3d rxDa, rxDb; // Dipole utility vectors
192 RealType rdQar, rdQbr, trQa, trQb; // Quadrupole utility scalars
193 Vector3d Qar, Qbr, rQa, rQb, rxQar, rxQbr; // Quadrupole utility vectors
194 RealType pref;
195
196 RealType DadDb, trQaQb, DadQbr, DbdQar; // Cross-interaction scalars
197 RealType rQaQbr;
198 Vector3d DaxDb, DadQb, DbdQa, DaxQbr, DbxQar; // Cross-interaction vectors
199 Vector3d rQaQb, QaQbr, QaxQb, rQaxQbr;
200 Mat3x3d QaQb; // Cross-interaction matrices
201
202 RealType U; // Potential
203 Vector3d F; // Force
204 Vector3d Ta; // Torque on site a
205 Vector3d Tb; // Torque on site b
206 Vector3d Ea; // Electric field at site a
207 Vector3d Eb; // Electric field at site b
208 RealType Pa; // Site potential at site a
209 RealType Pb; // Site potential at site b
210 RealType dUdCa; // fluctuating charge force at site a
211 RealType dUdCb; // fluctuating charge force at site a
212
213 // Indirect interactions mediated by the reaction field.
214 RealType indirect_Pot; // Potential
215 Vector3d indirect_F; // Force
216 Vector3d indirect_Ta; // Torque on site a
217 Vector3d indirect_Tb; // Torque on site b
218
219 // Excluded potential that is still computed for fluctuating charges
220 RealType excluded_Pot;
221
222 RealType rfContrib, coulInt;
223
224 // spline for coulomb integral
225 CubicSplinePtr J;
226 Vector3d rhat;
227
228 // logicals
229
230 bool a_is_Charge;
231 bool a_is_Dipole;
232 bool a_is_Quadrupole;
233 bool a_is_Fluctuating;
234 bool a_uses_SlaterIntra;
235
236 bool b_is_Charge;
237 bool b_is_Dipole;
238 bool b_is_Quadrupole;
239 bool b_is_Fluctuating;
240 bool b_uses_SlaterIntra;
241 };
242} // namespace OpenMD
243
244#endif
AtomType is what OpenMD looks to for unchanging data about an atom.
Definition AtomType.hpp:69
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Definition SimInfo.hpp:96
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
ElectrostaticSummationMethod
@ esm_EWALD_SPME
SPME Ewald methods aren't supported yet.
@ esm_EWALD_PME
PME Ewald methods aren't supported yet.
The InteractionData struct.
The SelfData struct.