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 // Common definition of taper function and its derivative for interlayer potentials 15 16 #ifndef LMP_INTERLAYER_TAPER_H 17 #define LMP_INTERLAYER_TAPER_H 18 19 namespace LAMMPS_NS { 20 namespace InterLayer { 21 22 static constexpr double Tap_coeff[8] = {1.0, 0.0, 0.0, 0.0, -35.0, 84.0, -70.0, 20.0}; 23 24 /* ----Calculate the long-range cutoff term */ calc_Tap(double r_ij,double Rcut)25 static inline double calc_Tap(double r_ij, double Rcut) 26 { 27 double Tap, r; 28 29 r = r_ij / Rcut; 30 if (r >= 1.0) { 31 Tap = 0.0; 32 } else { 33 Tap = Tap_coeff[7] * r + Tap_coeff[6]; 34 Tap = Tap * r + Tap_coeff[5]; 35 Tap = Tap * r + Tap_coeff[4]; 36 Tap = Tap * r + Tap_coeff[3]; 37 Tap = Tap * r + Tap_coeff[2]; 38 Tap = Tap * r + Tap_coeff[1]; 39 Tap = Tap * r + Tap_coeff[0]; 40 } 41 42 return (Tap); 43 } 44 45 /* ----Calculate the derivatives of long-range cutoff term */ calc_dTap(double r_ij,double Rcut)46 static inline double calc_dTap(double r_ij, double Rcut) 47 { 48 double dTap, r; 49 50 r = r_ij / Rcut; 51 if (r >= 1.0) { 52 dTap = 0.0; 53 } else { 54 dTap = 7.0 * Tap_coeff[7] * r + 6.0 * Tap_coeff[6]; 55 dTap = dTap * r + 5.0 * Tap_coeff[5]; 56 dTap = dTap * r + 4.0 * Tap_coeff[4]; 57 dTap = dTap * r + 3.0 * Tap_coeff[3]; 58 dTap = dTap * r + 2.0 * Tap_coeff[2]; 59 dTap = dTap * r + Tap_coeff[1]; 60 dTap = dTap / Rcut; 61 } 62 63 return (dTap); 64 } 65 } // namespace InterLayer 66 } // namespace LAMMPS_NS 67 #endif 68