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 #ifdef PAIR_CLASS
15 // clang-format off
16 PairStyle(tersoff,PairTersoff);
17 // clang-format on
18 #else
19 
20 #ifndef LMP_PAIR_TERSOFF_H
21 #define LMP_PAIR_TERSOFF_H
22 
23 #include "pair.h"
24 
25 namespace LAMMPS_NS {
26 
27 class PairTersoff : public Pair {
28  public:
29   PairTersoff(class LAMMPS *);
30   virtual ~PairTersoff();
31   virtual void compute(int, int);
32   void settings(int, char **);
33   void coeff(int, char **);
34   virtual void init_style();
35   double init_one(int, int);
36 
37   template <int SHIFT_FLAG, int EVFLAG, int EFLAG, int VFLAG_ATOM> void eval();
38 
39   static constexpr int NPARAMS_PER_LINE = 17;
40 
41  protected:
42   struct Param {
43     double lam1, lam2, lam3;
44     double c, d, h;
45     double gamma, powerm;
46     double powern, beta;
47     double biga, bigb, bigd, bigr;
48     double cut, cutsq;
49     double c1, c2, c3, c4;
50     int ielement, jelement, kelement;
51     int powermint;
52     double Z_i, Z_j;    // added for TersoffZBL
53     double ZBLcut, ZBLexpscale;
54     double c5, ca1, ca4;    // added for TersoffMOD
55     double powern_del;
56     double c0;    // added for TersoffMODC
57   };
58 
59   Param *params;      // parameter set for an I-J-K interaction
60   double cutmax;      // max cutoff for all elements
61   int maxshort;       // size of short neighbor list array
62   int *neighshort;    // short neighbor list array
63 
64   int shift_flag;    // flag to turn on/off shift
65   double shift;      // negative change in equilibrium bond length
66 
67   virtual void allocate();
68   virtual void read_file(char *);
69   virtual void setup_params();
70   virtual void repulsive(Param *, double, double &, int, double &);
71   virtual double zeta(Param *, double, double, double *, double *);
72   virtual void force_zeta(Param *, double, double, double &, double &, int, double &);
73   void attractive(Param *, double, double, double, double *, double *, double *, double *,
74                   double *);
75 
76   virtual double ters_fc(double, Param *);
77   virtual double ters_fc_d(double, Param *);
78   virtual double ters_fa(double, Param *);
79   virtual double ters_fa_d(double, Param *);
80   virtual double ters_bij(double, Param *);
81   virtual double ters_bij_d(double, Param *);
82 
83   virtual void ters_zetaterm_d(double, double *, double, double, double *, double, double, double *,
84                                double *, double *, Param *);
85   void costheta_d(double *, double, double *, double, double *, double *, double *);
86 
87   // inlined functions for efficiency
88 
ters_gijk(const double costheta,const Param * const param)89   inline double ters_gijk(const double costheta, const Param *const param) const
90   {
91     const double ters_c = param->c * param->c;
92     const double ters_d = param->d * param->d;
93     const double hcth = param->h - costheta;
94 
95     return param->gamma * (1.0 + ters_c / ters_d - ters_c / (ters_d + hcth * hcth));
96   }
97 
ters_gijk_d(const double costheta,const Param * const param)98   inline double ters_gijk_d(const double costheta, const Param *const param) const
99   {
100     const double ters_c = param->c * param->c;
101     const double ters_d = param->d * param->d;
102     const double hcth = param->h - costheta;
103     const double numerator = -2.0 * ters_c * hcth;
104     const double denominator = 1.0 / (ters_d + hcth * hcth);
105     return param->gamma * numerator * denominator * denominator;
106   }
107 };
108 
109 }    // namespace LAMMPS_NS
110 
111 #endif
112 #endif
113 
114 /* ERROR/WARNING messages:
115 
116 E: Illegal ... command
117 
118 Self-explanatory.  Check the input script syntax and compare to the
119 documentation for the command.  You can use -echo screen as a
120 command-line option when running LAMMPS to see the offending line.
121 
122 E: Incorrect args for pair coefficients
123 
124 Self-explanatory.  Check the input script or data file.
125 
126 E: Pair style Tersoff requires atom IDs
127 
128 This is a requirement to use the Tersoff potential.
129 
130 E: Pair style Tersoff requires newton pair on
131 
132 See the newton command.  This is a restriction to use the Tersoff
133 potential.
134 
135 E: All pair coeffs are not set
136 
137 All pair coefficients must be set in the data file or by the
138 pair_coeff command before running a simulation.
139 
140 E: Cannot open Tersoff potential file %s
141 
142 The specified potential file cannot be opened.  Check that the path
143 and name are correct.
144 
145 E: Incorrect format in Tersoff potential file
146 
147 Incorrect number of words per line in the potential file.
148 
149 E: Illegal Tersoff parameter
150 
151 One or more of the coefficients defined in the potential file is
152 invalid.
153 
154 E: Potential file has duplicate entry
155 
156 The potential file has more than one entry for the same element.
157 
158 E: Potential file is missing an entry
159 
160 The potential file does not have a needed entry.
161 
162 */
163