1 /* -*- c++ -*- ----------------------------------------------------------
2    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
3    https://www.lammps.org/, Sandia National Laboratories
4    Steve Plimpton, sjplimp@sandia.gov
5 
6    Copyright (2003) Sandia Corporation.  Under the terms of Contract
7    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
8    certain rights in this software.  This software is distributed under
9    the GNU General Public License.
10 
11    See the README file in the top-level LAMMPS directory.
12 ------------------------------------------------------------------------- */
13 
14 #ifndef LMP_FORCE_H
15 #define LMP_FORCE_H
16 
17 #include "pointers.h"
18 
19 #include <map>
20 
21 namespace LAMMPS_NS {
22 class Angle;
23 class Bond;
24 class Dihedral;
25 class Improper;
26 class KSpace;
27 class Pair;
28 
29 enum { ENERGY_NONE = 0x00, ENERGY_GLOBAL = 0x01, ENERGY_ATOM = 0x02 };
30 
31 // clang-format off
32 enum {
33   VIRIAL_NONE     = 0x00,
34   VIRIAL_PAIR     = 0x01,
35   VIRIAL_FDOTR    = 0x02,
36   VIRIAL_ATOM     = 0x04,
37   VIRIAL_CENTROID = 0x08
38 };
39 // clang-format on
40 
41 enum { CENTROID_SAME = 0, CENTROID_AVAIL = 1, CENTROID_NOTAVAIL = 2 };
42 
43 class Force : protected Pointers {
44  public:
45   double boltz;          // Boltzmann constant (eng/degree-K)
46   double hplanck;        // Planck's constant (energy-time)
47   double mvv2e;          // conversion of mv^2 to energy
48   double ftm2v;          // conversion of ft/m to velocity
49   double mv2d;           // conversion of mass/volume to density
50   double nktv2p;         // conversion of NkT/V to pressure
51   double qqr2e;          // conversion of q^2/r to energy
52   double qe2f;           // conversion of qE to force
53   double vxmu2f;         // conversion of vx dynamic-visc to force
54   double xxt2kmu;        // conversion of xx/t to kinematic-visc
55   double dielectric;     // dielectric constant
56   double qqrd2e;         // q^2/r to energy w/ dielectric constant
57   double e_mass;         // electron mass
58   double hhmrr2e;        // conversion of (hbar)^2/(mr^2) to energy
59   double mvh2r;          // conversion of mv/hbar to distance
60                          // hbar = h/(2*pi)
61   double angstrom;       // 1 angstrom in native units
62   double femtosecond;    // 1 femtosecond in native units
63   double qelectron;      // 1 electron charge abs() in native units
64 
65   double qqr2e_lammps_real;    // different versions of this constant
66   double qqr2e_charmm_real;    // used by new CHARMM pair styles
67 
68   int newton, newton_pair, newton_bond;    // Newton's 3rd law settings
69 
70   Pair *pair;
71   char *pair_style;
72   char *pair_restart;
73 
74   Bond *bond;
75   char *bond_style;
76 
77   Angle *angle;
78   char *angle_style;
79 
80   Dihedral *dihedral;
81   char *dihedral_style;
82 
83   Improper *improper;
84   char *improper_style;
85 
86   KSpace *kspace;
87   char *kspace_style;
88 
89   typedef Pair *(*PairCreator)(LAMMPS *);
90   typedef Bond *(*BondCreator)(LAMMPS *);
91   typedef Angle *(*AngleCreator)(LAMMPS *);
92   typedef Dihedral *(*DihedralCreator)(LAMMPS *);
93   typedef Improper *(*ImproperCreator)(LAMMPS *);
94   typedef KSpace *(*KSpaceCreator)(LAMMPS *);
95 
96   typedef std::map<std::string, PairCreator> PairCreatorMap;
97   typedef std::map<std::string, BondCreator> BondCreatorMap;
98   typedef std::map<std::string, AngleCreator> AngleCreatorMap;
99   typedef std::map<std::string, DihedralCreator> DihedralCreatorMap;
100   typedef std::map<std::string, ImproperCreator> ImproperCreatorMap;
101   typedef std::map<std::string, KSpaceCreator> KSpaceCreatorMap;
102 
103   PairCreatorMap *pair_map;
104   BondCreatorMap *bond_map;
105   AngleCreatorMap *angle_map;
106   DihedralCreatorMap *dihedral_map;
107   ImproperCreatorMap *improper_map;
108   KSpaceCreatorMap *kspace_map;
109 
110   // index [0] is not used in these arrays
111   double special_lj[4];      // 1-2, 1-3, 1-4 prefactors for LJ
112   double special_coul[4];    // 1-2, 1-3, 1-4 prefactors for Coulombics
113   int special_angle;         // 0 if defined angles are ignored
114                              // 1 if only weight 1,3 atoms if in an angle
115   int special_dihedral;      // 0 if defined dihedrals are ignored
116                              // 1 if only weight 1,4 atoms if in a dihedral
117   int special_extra;         // extra space for added bonds
118 
119   Force(class LAMMPS *);
120   ~Force();
121   void init();
122   void setup();
123 
124   void create_pair(const std::string &, int);
125   Pair *new_pair(const std::string &, int, int &);
126   Pair *pair_match(const std::string &, int, int nsub = 0);
127   char *pair_match_ptr(Pair *);
128 
129   void create_bond(const std::string &, int);
130   Bond *new_bond(const std::string &, int, int &);
131   Bond *bond_match(const std::string &);
132 
133   void create_angle(const std::string &, int);
134   Angle *new_angle(const std::string &, int, int &);
135   Angle *angle_match(const std::string &);
136 
137   void create_dihedral(const std::string &, int);
138   Dihedral *new_dihedral(const std::string &, int, int &);
139   Dihedral *dihedral_match(const std::string &);
140 
141   void create_improper(const std::string &, int);
142   Improper *new_improper(const std::string &, int, int &);
143   Improper *improper_match(const std::string &);
144 
145   void create_kspace(const std::string &, int);
146   KSpace *new_kspace(const std::string &, int, int &);
147   KSpace *kspace_match(const std::string &, int);
148 
149   void store_style(char *&, const std::string &, int);
150   void set_special(int, char **);
151 
152   double memory_usage();
153 
154  private:
155   void create_factories();
156   template <typename T> static Pair *pair_creator(LAMMPS *);
157   template <typename T> static Bond *bond_creator(LAMMPS *);
158   template <typename T> static Angle *angle_creator(LAMMPS *);
159   template <typename T> static Dihedral *dihedral_creator(LAMMPS *);
160   template <typename T> static Improper *improper_creator(LAMMPS *);
161   template <typename T> static KSpace *kspace_creator(LAMMPS *);
162 };
163 
164 }    // namespace LAMMPS_NS
165 
166 #endif
167 
168 /* ERROR/WARNING messages:
169 
170 E: Must re-specify non-restarted pair style (%s) after read_restart
171 
172 For pair styles, that do not store their settings in a restart file,
173 it must be defined with a new 'pair_style' command after read_restart.
174 
175 E: Unrecognized pair style %s
176 
177 The choice of pair style is unknown.
178 
179 E: Unrecognized bond style %s
180 
181 The choice of bond style is unknown.
182 
183 E: Unrecognized angle style %s
184 
185 The choice of angle style is unknown.
186 
187 E: Unrecognized dihedral style %s
188 
189 The choice of dihedral style is unknown.
190 
191 E: Unrecognized improper style %s
192 
193 The choice of improper style is unknown.
194 
195 E: Cannot yet use KSpace solver with grid with comm style tiled
196 
197 This is current restriction in LAMMPS.
198 
199 E: Unrecognized kspace style %s
200 
201 The choice of kspace style is unknown.
202 
203 E: Illegal ... command
204 
205 Self-explanatory.  Check the input script syntax and compare to the
206 documentation for the command.  You can use -echo screen as a
207 command-line option when running LAMMPS to see the offending line.
208 
209 U: Unknown pair style
210 
211 The choice of pair style is unknown.
212 
213 U: Unknown bond style
214 
215 The choice of bond style is unknown.
216 
217 U: Unknown angle style
218 
219 The choice of angle style is unknown.
220 
221 U: Unknown dihedral style
222 
223 The choice of dihedral style is unknown.
224 
225 U: Unknown improper style
226 
227 The choice of improper style is unknown.
228 
229 U: Unknown kspace style
230 
231 The choice of kspace style is unknown.
232 
233 U: Numeric index is out of bounds
234 
235 A command with an argument that specifies an integer or range of
236 integers is using a value that is less than 1 or greater than the
237 maximum allowed limit.
238 
239 W: Bonds are defined but no bond style is set
240 
241 The topology contains bonds, but there are no bond forces computed
242 since there was no bond_style command.
243 
244 W: Angles are defined but no angle style is set
245 
246 The topology contains angles, but there are no angle forces computed
247 since there was no angle_style command.
248 
249 W: Dihedrals are defined but no dihedral style is set
250 
251 The topology contains dihedrals, but there are no dihedral forces computed
252 since there was no dihedral_style command.
253 
254 W: Impropers are defined but no improper style is set
255 
256 The topology contains impropers, but there are no improper forces computed
257 since there was no improper_style command.
258 
259 W: Likewise 1-2 special neighbor interactions != 1.0
260 
261 The topology contains bonds, but there is no bond style defined
262 and a 1-2 special neighbor scaling factor was not 1.0. This
263 means that pair style interactions may have scaled or missing
264 pairs in the neighbor list in expectation of interactions for
265 those pairs being computed from the bond style.
266 
267 W: Likewise 1-3 special neighbor interactions != 1.0
268 
269 The topology contains angles, but there is no angle style defined
270 and a 1-3 special neighbor scaling factor was not 1.0. This
271 means that pair style interactions may have scaled or missing
272 pairs in the neighbor list in expectation of interactions for
273 those pairs being computed from the angle style.
274 
275 W: Likewise 1-4 special neighbor interactions != 1.0
276 
277 The topology contains dihedrals, but there is no dihedral style defined
278 and a 1-4 special neighbor scaling factor was not 1.0. This
279 means that pair style interactions may have scaled or missing
280 pairs in the neighbor list in expectation of interactions for
281 those pairs being computed from the dihedral style.
282 
283 */
284