OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
NonBondedInteraction.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_NONBONDEDINTERACTION_HPP
49#define NONBONDED_NONBONDEDINTERACTION_HPP
50
51#include <memory>
52
54#include "types/AtomType.hpp"
55
56using namespace std;
57namespace OpenMD {
58 /**
59 * The InteractionFamily enum.
60 *
61 * This is used to sort different types of non-bonded interaction
62 * and to prevent multiple interactions in the same family from
63 * being applied to any given pair of atom types.
64 */
66 NO_FAMILY = 0, /**< No family defined */
68 1, /**< Long-range dispersion and short-range pauli repulsion */
69 ELECTROSTATIC_FAMILY = 2, /**< Coulombic and point-multipole interactions */
71 3, /**< Transition metal interactions involving electron density */
73 4, /**< Transition metal interactions involving pair potentials */
74 HYDROGENBONDING_FAMILY = 5, /**< Short-range directional interactions */
75 BONDED_FAMILY = 6, /**< directly bonded 1-2, 1-3, or 1-4 interactions */
76 N_INTERACTION_FAMILIES = 7
77 };
78
79 /**
80 * Boolean flags for the iHash_ and sHash_ data structures. These
81 * are used to greatly increase the speed of looking up the
82 * low-level interaction for any given pair:
83 */
84 const static int ELECTROSTATIC_INTERACTION = (1 << 0);
85 const static int LJ_INTERACTION = (1 << 1);
86 const static int EAM_INTERACTION = (1 << 2);
87 const static int SC_INTERACTION = (1 << 3);
88 const static int STICKY_INTERACTION = (1 << 4);
89 const static int GB_INTERACTION = (1 << 5);
90 const static int MORSE_INTERACTION = (1 << 6);
91 const static int REPULSIVEPOWER_INTERACTION = (1 << 7);
92 const static int MAW_INTERACTION = (1 << 8);
93 const static int MIE_INTERACTION = (1 << 9);
94 const static int BUCKINGHAM_INTERACTION = (1 << 10);
95 const static int INVERSEPOWERSERIES_INTERACTION = (1 << 11);
96
98
99 /**
100 * The InteractionData struct.
101 *
102 * This is used to pass data and references to data to specific non-bonded
103 * interactions for force calculations. Not all of the struct
104 * members are utilized by any given interaction.
105 */
107 int atid1 = -1; /**< atomType ident for atom 1 */
108 int atid2 = -1; /**< atomType ident for atom 2 */
109 Vector3d d {}; /**< interatomic vector (already wrapped into box) */
110 RealType rij {}; /**< interatomic separation */
111 RealType r2 {}; /**< square of rij */
112 RealType rcut {}; /**< cutoff radius for this interaction */
113 bool shiftedPot {false}; /**< shift the potential up inside the cutoff? */
115 false}; /**< shifted forces smoothly inside the cutoff? */
116 RealType sw {}; /**< switching function value at rij */
117 int topoDist {}; /**< topological distance between atoms */
118 bool excluded {
119 false}; /**< is this excluded from direct pairwise interactions? (some
120 indirect interactions may still apply) */
122 false}; /**< are these atoms specified to be in the same region? */
123 RealType vdwMult {}; /**< multiplier for van der Waals interactions */
124 RealType electroMult {}; /**< multiplier for electrostatic interactions */
125 potVec pot {}; /**< total potential */
126 potVec excludedPot {}; /**< potential energy excluded from the overall
127 calculation */
128 RealType vpair {}; /**< pair potential */
129 bool doParticlePot {false}; /**< should we bother with the particle pot? */
131 false}; /**< should we bother with the electric field? */
133 false}; /**< should we bother with electrostatic site potential */
134 bool isSelected {false}; /**< one of the particles has been selected for
135 selection potential */
136 potVec selePot {}; /**< potential energies of the selected sites */
137 RealType particlePot1 {}; /**< particle potential for atom1 */
138 RealType particlePot2 {}; /**< particle potential for atom2 */
139 Vector3d f1 {}; /**< force between the two atoms */
140 RotMat3x3d A1 {}; /**< rotation matrix of first atom */
141 RotMat3x3d A2 {}; /**< rotation matrix of second atom */
142 Vector3d D_1 {}; /**< dipole vector of first atom */
143 Vector3d D_2 {}; /**< dipole vector of first atom */
144 Mat3x3d Q_1 {}; /**< quadrupole tensor of first atom */
145 Mat3x3d Q_2 {}; /**< quadrupole tensor of first atom */
146 Vector3d t1 {}; /**< torque on first atom */
147 Vector3d t2 {}; /**< torque on second atom */
148 RealType rho1 {}; /**< total electron density at first atom */
149 RealType rho2 {}; /**< total electron density at second atom */
150 RealType frho1 {}; /**< density functional at first atom */
151 RealType frho2 {}; /**< density functional at second atom */
152 RealType dfrho1 {}; /**< derivative of functional for atom 1 */
153 RealType dfrho2 {}; /**< derivative of functional for atom 2 */
154 RealType flucQ1 {}; /**< fluctuating charge on atom1 */
155 RealType flucQ2 {}; /**< fluctuating charge on atom2 */
156 RealType dVdFQ1 {}; /**< fluctuating charge force on atom1 */
157 RealType dVdFQ2 {}; /**< fluctuating charge force on atom2 */
158 Vector3d eField1 {}; /**< electric field on first atom */
159 Vector3d eField2 {}; /**< electric field on second atom */
160 RealType skippedCharge1 {}; /**< charge skipped on atom1 in pairwise
161 interaction loop with atom2 */
162 RealType skippedCharge2 {}; /**< charge skipped on atom2 in pairwise
163 interaction loop with atom1 */
164 RealType sPot1 {}; /**< site potential on first atom */
165 RealType sPot2 {}; /**< site potential on second atom */
166 };
167
168 /**
169 * The SelfData struct.
170 *
171 * This is used to pass data for the self-interaction or
172 * derived information on a single atom after a pass through all
173 * other interactions. This is used by electrostatic methods that
174 * have long-range corrections involving interactions with a medium
175 * or a boundary and also by specific metal interactions for
176 * electron density functional calculations. Not all of the struct
177 * members are utilized by any given self interaction.
178 */
179 struct SelfData {
180 int atid {}; /**< atomType ident for the atom */
181 RealType
182 skippedCharge {}; /**< charge skipped in pairwise interaction loop */
183 potVec selfPot {}; /**< total potential (including embedding energy) */
184 bool doParticlePot {false}; /**< should we bother with the particle pot? */
185 RealType
186 particlePot {}; /**< contribution to potential from this particle */
187 RealType rho {}; /**< electron density */
188 RealType frho {}; /**< value of density functional for atom */
189 RealType dfrhodrho {}; /**< derivative of density functional for atom */
190 RealType flucQ {}; /**< current value of atom's fluctuating charge */
191 RealType flucQfrc {}; /**< fluctuating charge derivative */
193 false}; /**< this site has been selected for selection potential */
194 potVec selePot {}; /**< potential energy of the selected site */
195 };
196
197 /**
198 * The basic interface for non-bonded interactions.
199 */
200 class NonBondedInteraction {
201 public:
202 NonBondedInteraction() {}
203 virtual ~NonBondedInteraction() {}
204 virtual void calcForce(InteractionData& idat) = 0;
205 virtual InteractionFamily getFamily() = 0;
206 virtual int getHash() = 0;
207 virtual RealType getSuggestedCutoffRadius(
208 pair<AtomType*, AtomType*> atypes) = 0;
209 virtual string getName() = 0;
210 };
211
212 using NonBondedInteractionPtr = std::shared_ptr<NonBondedInteraction>;
213
214 /**
215 * The basic interface for van der Waals interactions.
216 */
217 class VanDerWaalsInteraction : public NonBondedInteraction {
218 public:
219 VanDerWaalsInteraction() : NonBondedInteraction() {}
220 virtual ~VanDerWaalsInteraction() {}
221 virtual InteractionFamily getFamily() { return VANDERWAALS_FAMILY; }
222 };
223
224 /**
225 * The basic interface for electrostatic interactions.
226 */
227 class ElectrostaticInteraction : public NonBondedInteraction {
228 public:
229 ElectrostaticInteraction() : NonBondedInteraction() {}
230 virtual ~ElectrostaticInteraction() {}
231 virtual void calcSelfCorrection(SelfData& sdat) = 0;
232 virtual InteractionFamily getFamily() { return ELECTROSTATIC_FAMILY; }
233 virtual int getHash() { return ELECTROSTATIC_INTERACTION; }
234 };
235
236 /**
237 * The basic interface for metallic interactions.
238 */
239 class MetallicInteraction : public NonBondedInteraction {
240 public:
241 MetallicInteraction() : NonBondedInteraction() {}
242 virtual ~MetallicInteraction() {}
243 virtual void calcDensity(InteractionData& idat) = 0;
244 virtual void calcFunctional(SelfData& sdat) = 0;
245 virtual InteractionFamily getFamily() { return METALLIC_EMBEDDING_FAMILY; }
246 };
247
248 /**
249 * The basic interface for hydrogen bonding interactions.
250 */
251 class HydrogenBondingInteraction : public NonBondedInteraction {
252 public:
253 HydrogenBondingInteraction() : NonBondedInteraction() {}
254 virtual ~HydrogenBondingInteraction() {}
255 virtual InteractionFamily getFamily() { return HYDROGENBONDING_FAMILY; }
256 };
257} // namespace OpenMD
258
259#endif
Fix length vector class.
Definition Vector.hpp:81
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
static const int ELECTROSTATIC_INTERACTION
Boolean flags for the iHash_ and sHash_ data structures.
InteractionFamily
The InteractionFamily enum.
@ HYDROGENBONDING_FAMILY
Short-range directional interactions.
@ VANDERWAALS_FAMILY
Long-range dispersion and short-range pauli repulsion.
@ NO_FAMILY
No family defined.
@ METALLIC_EMBEDDING_FAMILY
Transition metal interactions involving electron density.
@ BONDED_FAMILY
directly bonded 1-2, 1-3, or 1-4 interactions
@ METALLIC_PAIR_FAMILY
Transition metal interactions involving pair potentials.
@ ELECTROSTATIC_FAMILY
Coulombic and point-multipole interactions.
The InteractionData struct.
bool shiftedPot
shift the potential up inside the cutoff?
Vector3d d
interatomic vector (already wrapped into box)
RealType sPot2
site potential on second atom
Vector3d D_1
dipole vector of first atom
RealType skippedCharge1
charge skipped on atom1 in pairwise interaction loop with atom2
RealType dVdFQ1
fluctuating charge force on atom1
RealType dVdFQ2
fluctuating charge force on atom2
RealType particlePot2
particle potential for atom2
RealType electroMult
multiplier for electrostatic interactions
int atid1
atomType ident for atom 1
potVec selePot
potential energies of the selected sites
RealType flucQ2
fluctuating charge on atom2
bool sameRegion
are these atoms specified to be in the same region?
bool excluded
is this excluded from direct pairwise interactions?
RealType rho2
total electron density at second atom
RealType sw
switching function value at rij
Vector3d eField1
electric field on first atom
RotMat3x3d A2
rotation matrix of second atom
bool isSelected
one of the particles has been selected for selection potential
RotMat3x3d A1
rotation matrix of first atom
bool doElectricField
should we bother with the electric field?
RealType flucQ1
fluctuating charge on atom1
Mat3x3d Q_2
quadrupole tensor of first atom
Vector3d eField2
electric field on second atom
Vector3d t1
torque on first atom
Vector3d t2
torque on second atom
RealType vpair
pair potential
RealType sPot1
site potential on first atom
int atid2
atomType ident for atom 2
bool doSitePotential
should we bother with electrostatic site potential
bool shiftedForce
shifted forces smoothly inside the cutoff?
int topoDist
topological distance between atoms
RealType rcut
cutoff radius for this interaction
Vector3d D_2
dipole vector of first atom
RealType skippedCharge2
charge skipped on atom2 in pairwise interaction loop with atom1
RealType dfrho2
derivative of functional for atom 2
potVec excludedPot
potential energy excluded from the overall calculation
RealType vdwMult
multiplier for van der Waals interactions
RealType frho2
density functional at second atom
bool doParticlePot
should we bother with the particle pot?
RealType dfrho1
derivative of functional for atom 1
Mat3x3d Q_1
quadrupole tensor of first atom
RealType frho1
density functional at first atom
Vector3d f1
force between the two atoms
RealType rij
interatomic separation
RealType particlePot1
particle potential for atom1
RealType rho1
total electron density at first atom
The SelfData struct.
potVec selePot
potential energy of the selected site
RealType flucQfrc
fluctuating charge derivative
RealType frho
value of density functional for atom
RealType dfrhodrho
derivative of density functional for atom
potVec selfPot
total potential (including embedding energy)
RealType particlePot
contribution to potential from this particle
RealType rho
electron density
bool isSelected
this site has been selected for selection potential
RealType flucQ
current value of atom's fluctuating charge
RealType skippedCharge
charge skipped in pairwise interaction loop
bool doParticlePot
should we bother with the particle pot?
int atid
atomType ident for the atom