diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index 59501b4a56..91d6b6290f 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -200,6 +200,7 @@ OPT. * :doc:`mdpd ` * :doc:`mdpd/rhosum ` * :doc:`meam (k) ` + * :doc:`meam/ms (k) ` * :doc:`meam/spline (o) ` * :doc:`meam/sw/spline ` * :doc:`mesocnt ` diff --git a/doc/src/pair_meam.rst b/doc/src/pair_meam.rst index 194afeb1ff..1963332e8a 100644 --- a/doc/src/pair_meam.rst +++ b/doc/src/pair_meam.rst @@ -1,19 +1,26 @@ .. index:: pair_style meam .. index:: pair_style meam/kk +.. index:: pair_style meam/ms +.. index:: pair_style meam/ms/kk pair_style meam command ========================= Accelerator Variants: *meam/kk* +pair_style meam/ms command +========================== + +Accelerator Variants: *meam/ms/kk* + Syntax """""" .. code-block:: LAMMPS - pair_style meam [ms] + pair_style style -* ms = use multi-state MEAM (optional) +* style = *meam* or *meam/ms* Examples """""""" @@ -24,6 +31,9 @@ Examples pair_coeff * * ../potentials/library.meam Si ../potentials/si.meam Si pair_coeff * * ../potentials/library.meam Ni Al NULL Ni Al Ni Ni + pair_style meam/ms + pair_coeff * * ../potentials/library.msmeam H Ga ../potentials/HGa.meam H Ga + Description """"""""""" @@ -33,16 +43,23 @@ Description as of November 2010; see description below of the mixture_ref_t parameter -Pair style *meam* computes non-bonded interactions for a variety of materials -using the modified embedded-atom method (MEAM) -:ref:`(Baskes) `. Conceptually, it is an extension to the original -:doc:`EAM method ` which adds angular forces. It is -thus suitable for modeling metals and alloys with fcc, bcc, hcp and -diamond cubic structures, as well as materials with covalent interactions -like silicon and carbon. This *meam* pair style is a translation of the -original Fortran version to C++. It is functionally equivalent but more -efficient and has additional features. The Fortran version of the *meam* -pair style has been removed from LAMMPS after the 12 December 2018 release. +Pair style *meam* computes non-bonded interactions for a variety of +materials using the modified embedded-atom method (MEAM) :ref:`(Baskes) +`. Conceptually, it is an extension to the original :doc:`EAM +method ` which adds angular forces. It is thus suitable for +modeling metals and alloys with fcc, bcc, hcp and diamond cubic +structures, as well as materials with covalent interactions like silicon +and carbon. + +The *meam* pair style is a translation of the original Fortran version +to C++. It is functionally equivalent but more efficient and has +additional features. The Fortran version of the *meam* pair style has +been removed from LAMMPS after the 12 December 2018 release. + +Pair style *meam/ms* uses the multi-state MEAM (MS-MEAM) method +according to :ref:`(Baskes2) `, which is an extension to MEAM. +This pair style is mostly equivalent to *meam* and is use differs only +where noted in the documentation below. In the MEAM formulation, the total energy E of a system of atoms is given by: @@ -353,13 +370,15 @@ Most published MEAM parameter sets use the default values *attrac* = *repulse* = Setting *repuls* = *attrac* = *delta* corresponds to the form used in several recent published MEAM parameter sets, such as :ref:`(Valone) ` -The optional *ms* flag activates multi-state MEAM (MS-MEAM) according to :ref:`(Baskes2) `. -This requires 6 extra parameters in the MEAM library file, resulting in 25 parameters ordered like: +Then using *meam/ms* pair style the multi-state MEAM (MS-MEAM) method is +activated. This requires 6 extra parameters in the MEAM library file, +resulting in 25 parameters ordered that are ordered like this: elt, lat, z, ielement, atwt, alpha, b0, b1, b2, b3, b1m, b2m, b3m, alat, esub, asub, t0, t1, t2, t3, t1m, t2m, t3m, rozero, ibar The 6 extra MS-MEAM parameters are *b1m, b2m, b3m, t1m, t2m, t3m*. +In the LAMMPS ``potentials`` folder, compatible files have an ".msmeam" extension. ---------- @@ -403,16 +422,15 @@ This pair style can only be used via the *pair* keyword of the Restrictions """""""""""" -The *meam* style is provided in the MEAM package. It is -only enabled if LAMMPS was built with that package. +The *meam* and *meam/ms* pair styles are provided in the MEAM +package. They are only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. -The maximum number of elements, that can be read from the MEAM -library file, is determined at compile time. The default is 5. -If you need support for more elements, you have to change the -define for the constant 'maxelt' at the beginning of the file -src/MEAM/meam.h and update/recompile LAMMPS. There is no -limit on the number of atoms types. +The maximum number of elements, that can be read from the MEAM library +file, is determined at compile time. The default is 5. If you need +support for more elements, you have to change the the constant 'maxelt' +at the beginning of the file ``src/MEAM/meam.h`` and update/recompile +LAMMPS. There is no limit on the number of atoms types. Related commands """""""""""""""" diff --git a/doc/src/pair_style.rst b/doc/src/pair_style.rst index 3f91bfc0b4..cc471ecf6d 100644 --- a/doc/src/pair_style.rst +++ b/doc/src/pair_style.rst @@ -277,7 +277,8 @@ accelerated styles exist. * :doc:`lubricateU/poly ` - hydrodynamic lubrication forces for Fast Lubrication with polydispersity * :doc:`mdpd ` - mDPD particle interactions * :doc:`mdpd/rhosum ` - mDPD particle interactions for mass density -* :doc:`meam ` - modified embedded atom method (MEAM) in C +* :doc:`meam ` - modified embedded atom method (MEAM) +* :doc:`meam/ms ` - multi-state modified embedded atom method (MS-MEAM) * :doc:`meam/spline ` - splined version of MEAM * :doc:`meam/sw/spline ` - splined version of MEAM with a Stillinger-Weber term * :doc:`mesocnt ` - mesoscopic vdW potential for (carbon) nanotubes diff --git a/src/KOKKOS/pair_meam_kokkos.cpp b/src/KOKKOS/pair_meam_kokkos.cpp index 7f88645f1d..c2b03c2054 100644 --- a/src/KOKKOS/pair_meam_kokkos.cpp +++ b/src/KOKKOS/pair_meam_kokkos.cpp @@ -51,6 +51,7 @@ PairMEAMKokkos::PairMEAMKokkos(LAMMPS *lmp) : PairMEAM(lmp) delete meam_inst; meam_inst_kk = new MEAMKokkos(memory); meam_inst = meam_inst_kk; + myname = "meam/kk"; } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_meam_kokkos.h b/src/KOKKOS/pair_meam_kokkos.h index f052826b59..0d0d7667f3 100644 --- a/src/KOKKOS/pair_meam_kokkos.h +++ b/src/KOKKOS/pair_meam_kokkos.h @@ -13,12 +13,12 @@ #ifdef PAIR_CLASS // clang-format off -PairStyle(meam/c/kk,PairMEAMKokkos) -PairStyle(meam/c/kk/device,PairMEAMKokkos) -PairStyle(meam/c/kk/host,PairMEAMKokkos) -PairStyle(meam/kk,PairMEAMKokkos) -PairStyle(meam/kk/device,PairMEAMKokkos) -PairStyle(meam/kk/host,PairMEAMKokkos) +PairStyle(meam/c/kk,PairMEAMKokkos); +PairStyle(meam/c/kk/device,PairMEAMKokkos); +PairStyle(meam/c/kk/host,PairMEAMKokkos); +PairStyle(meam/kk,PairMEAMKokkos); +PairStyle(meam/kk/device,PairMEAMKokkos); +PairStyle(meam/kk/host,PairMEAMKokkos); // clang-format on #else diff --git a/src/KOKKOS/pair_meam_ms_kokkos.cpp b/src/KOKKOS/pair_meam_ms_kokkos.cpp new file mode 100644 index 0000000000..491fc0273c --- /dev/null +++ b/src/KOKKOS/pair_meam_ms_kokkos.cpp @@ -0,0 +1,32 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "pair_meam_ms_kokkos.h" +#include "meam.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ +template +PairMEAMMSKokkos::PairMEAMMSKokkos(LAMMPS *lmp) : PairMEAMKokkos(lmp) +{ + this->meam_inst->msmeamflag = this->msmeamflag = 1; + this->myname = "meam/ms/kk"; +} + +namespace LAMMPS_NS { +template class PairMEAMMSKokkos; +#ifdef KOKKOS_ENABLE_CUDA +template class PairMEAMMSKokkos; +#endif +} diff --git a/src/KOKKOS/pair_meam_ms_kokkos.h b/src/KOKKOS/pair_meam_ms_kokkos.h new file mode 100644 index 0000000000..a2cefc2c16 --- /dev/null +++ b/src/KOKKOS/pair_meam_ms_kokkos.h @@ -0,0 +1,36 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS +// clang-format off +PairStyle(meam/ms/kk,PairMEAMMSKokkos); +PairStyle(meam/ms/kk/device,PairMEAMMSKokkos); +PairStyle(meam/ms/kk/host,PairMEAMMSKokkos); +// clang-format on +#else + +#ifndef LMP_PAIR_MEAM_MS_KOKKOS_H +#define LMP_PAIR_MEAM_MS_KOKKOS_H + +#include "pair_meam_kokkos.h" + +namespace LAMMPS_NS { + +template +class PairMEAMMSKokkos : public PairMEAMKokkos { + public: + PairMEAMMSKokkos(class LAMMPS *); +}; +} // namespace LAMMPS_NS +#endif +#endif diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index c5d6afbea5..5a131bdc34 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -17,7 +17,7 @@ #include #include -#define maxelt 5 +constexpr int maxelt = 5; namespace LAMMPS_NS { class Memory; diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 911b8930df..de1188349c 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -836,9 +836,9 @@ void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, dou *rho21 = *rho21 / denom * *rho01; } else *rho21 = 8. / 3. * (rhoa21 - rhoa22) * (rhoa21 - rhoa22); - if (this->msmeamflag) { - *rho2m1 = 8. / 3. * (rhoa2m1 - rhoa2m2) * (rhoa2m1 - rhoa2m2); - } + if (this->msmeamflag) { + *rho2m1 = 8. / 3. * (rhoa2m1 - rhoa2m2) * (rhoa2m1 - rhoa2m2); + } break; case B2: *rho01 = 8.0 * rhoa02; diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 62c0278da3..c4a4cfa1d7 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -54,12 +54,15 @@ PairMEAM::PairMEAM(LAMMPS *lmp) : Pair(lmp) one_coeff = 1; manybody_flag = 1; centroidstressflag = CENTROID_NOTAVAIL; - msmeamflag = 0; allocated = 0; nlibelements = 0; + meam_inst = new MEAM(memory); + meam_inst->msmeamflag = msmeamflag = 0; + myname = "meam"; + scale = nullptr; } @@ -181,18 +184,9 @@ void PairMEAM::allocate() global settings ------------------------------------------------------------------------- */ -void PairMEAM::settings(int narg, char **arg) +void PairMEAM::settings(int narg, char ** /*arg*/) { - if (narg > 1) error->all(FLERR,"Illegal pair_style meam command"); - - meam_inst->msmeamflag = 0; - - if (narg == 1) { - if (strcmp("ms", arg[0]) == 0) { - msmeamflag = meam_inst->msmeamflag = 1; - } else - error->all(FLERR, "Unknown pair style meam option {}", arg[0]); - } + if (narg != 0) error->all(FLERR,"Illegal pair_style {} command", myname); // set comm size needed by this Pair @@ -215,12 +209,7 @@ void PairMEAM::coeff(int narg, char **arg) if (!allocated) allocate(); - if (narg < 6) error->all(FLERR,"Incorrect args for pair coefficients"); - - // insure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg < 6) error->all(FLERR,"Incorrect args for pair style {} coefficients", myname); // check for presence of first meam file @@ -248,7 +237,7 @@ void PairMEAM::coeff(int narg, char **arg) } if (paridx < 0) error->all(FLERR,"No MEAM parameter file in pair coefficients"); if ((narg - paridx - 1) != atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); + error->all(FLERR,"Incorrect args for pair style {} coefficients", myname); // MEAM element names between 2 filenames // nlibelements = # of MEAM elements @@ -291,7 +280,7 @@ void PairMEAM::coeff(int narg, char **arg) if (libelements[j] == arg[i]) break; if (j < nlibelements) map[m] = j; else if (strcmp(arg[i],"NULL") == 0) map[m] = -1; - else error->all(FLERR,"Incorrect args for pair coefficients"); + else error->all(FLERR,"Incorrect args for pair style {} coefficients", myname); } // clear setflag since coeff() called once with I,J = * * @@ -316,7 +305,7 @@ void PairMEAM::coeff(int narg, char **arg) } } - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + if (count == 0) error->all(FLERR,"Incorrect args for pair style {} coefficients", myname); } /* ---------------------------------------------------------------------- @@ -326,7 +315,7 @@ void PairMEAM::coeff(int narg, char **arg) void PairMEAM::init_style() { if (force->newton_pair == 0) - error->all(FLERR,"Pair style MEAM requires newton pair on"); + error->all(FLERR,"Pair style {} requires newton pair on", myname); // need a full and a half neighbor list @@ -436,8 +425,7 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) std::string lattice_type = values.next_string(); if (!MEAM::str_to_lat(lattice_type, true, lat[index])) - error->one(FLERR,"Unrecognized lattice type in MEAM " - "library file: {}", lattice_type); + error->one(FLERR,"Unrecognized lattice type in MEAM library file: {}", lattice_type); // store parameters @@ -470,11 +458,11 @@ void PairMEAM::read_global_meam_file(const std::string &globalfile) ibar[index] = values.next_int(); if (!isone(t0[index])) - error->one(FLERR,"Unsupported parameter in MEAM library file: t0!=1"); + error->one(FLERR,"Unsupported parameter in MEAM library file: t0 != 1"); // z given is ignored: if this is mismatched, we definitely won't do what the user said -> fatal error if (z[index] != MEAM::get_Zij(lat[index])) - error->one(FLERR,"Mismatched parameter in MEAM library file: z!=lat"); + error->one(FLERR,"Mismatched parameter in MEAM library file: z != lat"); nset++; } catch (TokenizerException &e) { diff --git a/src/MEAM/pair_meam.h b/src/MEAM/pair_meam.h index 0db599e74d..a89714bfa9 100644 --- a/src/MEAM/pair_meam.h +++ b/src/MEAM/pair_meam.h @@ -48,6 +48,7 @@ class PairMEAM : public Pair { double cutmax; // max cutoff for all elements int nlibelements; // # of library elements int msmeamflag; // 0 (default) for normal MEAM, 1 for MS-MEAM + std::string myname; // name of the pair style std::vector libelements; // names of library elements std::vector mass; // mass of library element diff --git a/src/MEAM/pair_meam_ms.cpp b/src/MEAM/pair_meam_ms.cpp new file mode 100644 index 0000000000..982a54f546 --- /dev/null +++ b/src/MEAM/pair_meam_ms.cpp @@ -0,0 +1,25 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "pair_meam_ms.h" +#include "meam.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +PairMEAMMS::PairMEAMMS(LAMMPS *lmp) : PairMEAM(lmp) +{ + meam_inst->msmeamflag = msmeamflag = 1; + myname = "meam/ms"; +} diff --git a/src/MEAM/pair_meam_ms.h b/src/MEAM/pair_meam_ms.h new file mode 100644 index 0000000000..25878203ed --- /dev/null +++ b/src/MEAM/pair_meam_ms.h @@ -0,0 +1,33 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/ Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS +// clang-format off +PairStyle(meam/ms,PairMEAMMS); +// clang-format on +#else + +#ifndef LMP_PAIR_MEAM_MS_H +#define LMP_PAIR_MEAM_MS_H + +#include "pair_meam.h" + +namespace LAMMPS_NS { + +class PairMEAMMS : public PairMEAM { + public: + PairMEAMMS(class LAMMPS *); +}; +} // namespace LAMMPS_NS +#endif +#endif