From 57616478940b8cd7b77eef5cfcdd730779923ed6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Jul 2022 05:15:50 -0400 Subject: [PATCH 001/100] plug memory leak --- src/GRANULAR/compute_contact_atom.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/GRANULAR/compute_contact_atom.cpp b/src/GRANULAR/compute_contact_atom.cpp index 91511f57ec..b090fb8631 100644 --- a/src/GRANULAR/compute_contact_atom.cpp +++ b/src/GRANULAR/compute_contact_atom.cpp @@ -32,17 +32,16 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeContactAtom::ComputeContactAtom(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - contact(nullptr) + Compute(lmp, narg, arg), group2(nullptr), contact(nullptr) { - if (narg != 3 && narg != 4) error->all(FLERR,"Illegal compute contact/atom command"); + if ((narg != 3) && (narg != 4)) error->all(FLERR, "Illegal compute contact/atom command"); jgroup = group->find("all"); jgroupbit = group->bitmask[jgroup]; if (narg == 4) { group2 = utils::strdup(arg[3]); jgroup = group->find(group2); - if (jgroup == -1) error->all(FLERR, "Compute contact/atom group2 ID does not exist"); + if (jgroup == -1) error->all(FLERR, "Compute contact/atom group2 ID {} does not exist", group2); jgroupbit = group->bitmask[jgroup]; } @@ -54,8 +53,7 @@ ComputeContactAtom::ComputeContactAtom(LAMMPS *lmp, int narg, char **arg) : // error checks - if (!atom->sphere_flag) - error->all(FLERR,"Compute contact/atom requires atom style sphere"); + if (!atom->sphere_flag) error->all(FLERR, "Compute contact/atom requires atom style sphere"); } /* ---------------------------------------------------------------------- */ @@ -63,6 +61,7 @@ ComputeContactAtom::ComputeContactAtom(LAMMPS *lmp, int narg, char **arg) : ComputeContactAtom::~ComputeContactAtom() { memory->destroy(contact); + delete[] group2; } /* ---------------------------------------------------------------------- */ From c9c9139fd6fc2058b4b7ef78bfa528b0b111396f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Jul 2022 05:21:13 -0400 Subject: [PATCH 002/100] fix off-by-one error and resulting out-of-bounds write access. --- src/REACTION/fix_bond_react.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index 0405971bdd..f487b8303f 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -1725,7 +1725,7 @@ void FixBondReact::inner_crosscheck_loop() int num_choices = 0; for (int i = 0; i < nfirst_neighs; i++) { if (type[(int)atom->map(xspecial[atom->map(glove[pion][1])][i])] == onemol->type[(int)onemol_xspecial[pion][neigh]-1]) { - if (num_choices > 5) { // here failed because too many identical first neighbors. but really no limit if situation arises + if (num_choices == 5) { // here failed because too many identical first neighbors. but really no limit if situation arises status = GUESSFAIL; return; } From 48ad917d9e27156c426ad9f542ff4ac4fa208a4a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Jul 2022 05:33:12 -0400 Subject: [PATCH 003/100] initialized pointers to null --- src/CG-SPICA/angle_spica.cpp | 17 +++++++++++------ src/CG-SPICA/pair_lj_spica.cpp | 16 +++++++++------- src/CG-SPICA/pair_lj_spica_coul_long.cpp | 9 ++++++--- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/CG-SPICA/angle_spica.cpp b/src/CG-SPICA/angle_spica.cpp index d25779d60c..ff19f29b75 100644 --- a/src/CG-SPICA/angle_spica.cpp +++ b/src/CG-SPICA/angle_spica.cpp @@ -21,17 +21,17 @@ #include "angle_spica.h" -#include #include "atom.h" -#include "neighbor.h" -#include "pair.h" -#include "domain.h" #include "comm.h" +#include "domain.h" +#include "error.h" #include "force.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neighbor.h" +#include "pair.h" +#include #include "lj_spica_common.h" @@ -43,7 +43,12 @@ using namespace LJSPICAParms; /* ---------------------------------------------------------------------- */ -AngleSPICA::AngleSPICA(LAMMPS *lmp) : Angle(lmp) { repflag = 0;} +AngleSPICA::AngleSPICA(LAMMPS *lmp) : + Angle(lmp), k(nullptr), theta0(nullptr), lj_type(nullptr), lj1(nullptr), lj2(nullptr), + lj3(nullptr), lj4(nullptr), rminsq(nullptr), emin(nullptr) +{ + repflag = 0; +} /* ---------------------------------------------------------------------- */ diff --git a/src/CG-SPICA/pair_lj_spica.cpp b/src/CG-SPICA/pair_lj_spica.cpp index 6a14d12146..32af30cd2b 100644 --- a/src/CG-SPICA/pair_lj_spica.cpp +++ b/src/CG-SPICA/pair_lj_spica.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -19,15 +18,15 @@ #include "pair_lj_spica.h" -#include -#include #include "atom.h" #include "comm.h" -#include "force.h" -#include "neigh_list.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neigh_list.h" +#include +#include #define LMP_NEED_SPICA_FIND_LJ_TYPE 1 #include "lj_spica_common.h" @@ -37,7 +36,9 @@ using namespace LJSPICAParms; /* ---------------------------------------------------------------------- */ -PairLJSPICA::PairLJSPICA(LAMMPS *lmp) : Pair(lmp) +PairLJSPICA::PairLJSPICA(LAMMPS *lmp) : + Pair(lmp), lj_type(nullptr), cut(nullptr), epsilon(nullptr), sigma(nullptr), lj1(nullptr), + lj2(nullptr), lj3(nullptr), lj4(nullptr), offset(nullptr), rminsq(nullptr), emin(nullptr) { respa_enable = 0; single_enable = 1; @@ -71,6 +72,7 @@ PairLJSPICA::~PairLJSPICA() } } +// clang-format off /* ---------------------------------------------------------------------- */ void PairLJSPICA::compute(int eflag, int vflag) diff --git a/src/CG-SPICA/pair_lj_spica_coul_long.cpp b/src/CG-SPICA/pair_lj_spica_coul_long.cpp index 416561c3a1..9b32f8eafb 100644 --- a/src/CG-SPICA/pair_lj_spica_coul_long.cpp +++ b/src/CG-SPICA/pair_lj_spica_coul_long.cpp @@ -46,7 +46,10 @@ using namespace LJSPICAParms; /* ---------------------------------------------------------------------- */ -PairLJSPICACoulLong::PairLJSPICACoulLong(LAMMPS *lmp) : Pair(lmp) +PairLJSPICACoulLong::PairLJSPICACoulLong(LAMMPS *lmp) : + Pair(lmp), lj_type(nullptr), cut_lj(nullptr), cut_ljsq(nullptr), + epsilon(nullptr), sigma(nullptr), lj1(nullptr), lj2(nullptr), lj3(nullptr), + lj4(nullptr), offset(nullptr), rminsq(nullptr), emin(nullptr) { ewaldflag = pppmflag = 1; respa_enable = 0; @@ -550,8 +553,8 @@ void PairLJSPICACoulLong::write_data_all(FILE *fp) /* ---------------------------------------------------------------------- */ -double PairLJSPICACoulLong::single(int i, int j, int itype, int jtype, double rsq, double factor_coul, - double factor_lj, double &fforce) +double PairLJSPICACoulLong::single(int i, int j, int itype, int jtype, double rsq, + double factor_coul, double factor_lj, double &fforce) { double r2inv, r, grij, expm2, t, erfc, prefactor; double fraction, table, forcecoul, forcelj, phicoul, philj; From 40920ac6e14e29477e779666f065e14c38c5bb4d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 22 Jul 2022 12:41:43 -0400 Subject: [PATCH 004/100] improved error messages for duplicate or missing entries in manybody potential files --- src/INTERLAYER/pair_drip.cpp | 8 ++++++-- src/INTERLAYER/pair_ilp_graphene_hbn.cpp | 8 ++++---- src/INTERLAYER/pair_kolmogorov_crespi_full.cpp | 8 ++++++-- src/INTERLAYER/pair_kolmogorov_crespi_z.cpp | 8 ++++++-- src/INTERLAYER/pair_lebedeva_z.cpp | 6 ++++-- src/KSPACE/pair_coul_streitz.cpp | 4 ++-- src/MANYBODY/pair_comb.cpp | 6 ++++-- src/MANYBODY/pair_comb3.cpp | 6 ++++-- src/MANYBODY/pair_edip.cpp | 8 ++++++-- src/MANYBODY/pair_edip_multi.cpp | 6 ++++-- src/MANYBODY/pair_extep.cpp | 6 ++++-- src/MANYBODY/pair_gw.cpp | 6 ++++-- src/MANYBODY/pair_nb3b_harmonic.cpp | 8 ++++++-- src/MANYBODY/pair_sw.cpp | 6 ++++-- src/MANYBODY/pair_tersoff.cpp | 6 ++++-- src/MANYBODY/pair_tersoff_mod.cpp | 6 ++++-- src/MANYBODY/pair_tersoff_table.cpp | 6 ++++-- src/MANYBODY/pair_threebody_table.cpp | 8 ++++++-- src/MANYBODY/pair_vashishta.cpp | 6 ++++-- src/MISC/pair_agni.cpp | 4 ++-- 20 files changed, 88 insertions(+), 42 deletions(-) diff --git a/src/INTERLAYER/pair_drip.cpp b/src/INTERLAYER/pair_drip.cpp index 2bd6a16e8c..e7b340c516 100644 --- a/src/INTERLAYER/pair_drip.cpp +++ b/src/INTERLAYER/pair_drip.cpp @@ -256,11 +256,15 @@ void PairDRIP::read_file(char *filename) int n = -1; for (int m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement) { - if (n >= 0) error->all(FLERR, "DRIP potential file has duplicate entry"); + if (n >= 0) + error->all(FLERR, "DRIP potential file has a duplicate entry for: {} {}", elements[i], + elements[j]); n = m; } } - if (n < 0) error->all(FLERR, "Potential file is missing an entry"); + if (n < 0) + error->all(FLERR, "Potential file is missing an entry for: {} {}", elements[i], + elements[j]); elem2param[i][j] = n; } } diff --git a/src/INTERLAYER/pair_ilp_graphene_hbn.cpp b/src/INTERLAYER/pair_ilp_graphene_hbn.cpp index 8e502a9f1f..49b2adbd33 100644 --- a/src/INTERLAYER/pair_ilp_graphene_hbn.cpp +++ b/src/INTERLAYER/pair_ilp_graphene_hbn.cpp @@ -313,14 +313,14 @@ void PairILPGrapheneHBN::read_file(char *filename) for (int m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement) { if (n >= 0) - error->all(FLERR, "{} potential file {} has a duplicate entry", variant_map[variant], - filename); + error->all(FLERR, "{} potential file {} has a duplicate entry for: {} {}", + variant_map[variant], filename, elements[i], elements[j]); n = m; } } if (n < 0) - error->all(FLERR, "{} potential file {} is missing an entry", variant_map[variant], - filename); + error->all(FLERR, "{} potential file {} is missing an entry for: {} {}", + variant_map[variant], filename, elements[i], elements[j]); elem2param[i][j] = n; cutILPsq[i][j] = params[n].rcut * params[n].rcut; } diff --git a/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp b/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp index 0c005d53a2..116018f18a 100644 --- a/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp +++ b/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp @@ -289,11 +289,15 @@ void PairKolmogorovCrespiFull::read_file(char *filename) int n = -1; for (int m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement) { - if (n >= 0) error->all(FLERR, "KC potential file has duplicate entry"); + if (n >= 0) + error->all(FLERR, "KC potential file has a duplicate entry for: {} {}", elements[i], + elements[j]); n = m; } } - if (n < 0) error->all(FLERR, "Potential file is missing an entry"); + if (n < 0) + error->all(FLERR, "Potential file is missing an entry for: {} {}", elements[i], + elements[j]); elem2param[i][j] = n; cutKCsq[i][j] = params[n].rcut * params[n].rcut; } diff --git a/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp b/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp index 144e09cb50..a2abdc9a1c 100644 --- a/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp +++ b/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp @@ -379,11 +379,15 @@ void PairKolmogorovCrespiZ::read_file(char *filename) int n = -1; for (int m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement) { - if (n >= 0) error->all(FLERR, "Potential file has duplicate entry"); + if (n >= 0) + error->all(FLERR, "Potential file has a duplicate entry for: {} {}", elements[i], + elements[j]); n = m; } } - if (n < 0) error->all(FLERR, "Potential file is missing an entry"); + if (n < 0) + error->all(FLERR, "Potential file is missing an entry for: {} {}", elements[i], + elements[j]); elem2param[i][j] = n; } } diff --git a/src/INTERLAYER/pair_lebedeva_z.cpp b/src/INTERLAYER/pair_lebedeva_z.cpp index 95e23d3348..0c2c285504 100644 --- a/src/INTERLAYER/pair_lebedeva_z.cpp +++ b/src/INTERLAYER/pair_lebedeva_z.cpp @@ -376,11 +376,13 @@ void PairLebedevaZ::read_file(char *filename) int n = -1; for (int m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {}", + elements[i], elements[j]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {}", + elements[i], elements[j]); elem2param[i][j] = n; } } diff --git a/src/KSPACE/pair_coul_streitz.cpp b/src/KSPACE/pair_coul_streitz.cpp index f388f4cc88..d0ad285f31 100644 --- a/src/KSPACE/pair_coul_streitz.cpp +++ b/src/KSPACE/pair_coul_streitz.cpp @@ -253,11 +253,11 @@ void PairCoulStreitz::setup_params() n = -1; for (m = 0; m < nparams; m++) { if (i == params[m].ielement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has duplicate entry for: {}", elements[i]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {}", elements[i]); elem1param[i] = n; } diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 90e2d72512..ddaf378445 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -687,11 +687,13 @@ void PairComb::setup_params() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index 7c126bf8ab..e5ea235363 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -642,11 +642,13 @@ void PairComb3::setup_params() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_edip.cpp b/src/MANYBODY/pair_edip.cpp index 8becba670b..87ccf9b18a 100644 --- a/src/MANYBODY/pair_edip.cpp +++ b/src/MANYBODY/pair_edip.cpp @@ -871,11 +871,15 @@ void PairEDIP::setup_params() n = -1; for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR, "Potential file has duplicate entry"); + if (n >= 0) + error->all(FLERR, "Potential file has a duplicate entry for: {} {} {}", elements[i], + elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR, "Potential file is missing an entry"); + if (n < 0) + error->all(FLERR, "Potential file is missing an entry for: {} {} {}", elements[i], + elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_edip_multi.cpp b/src/MANYBODY/pair_edip_multi.cpp index 4710dcce0a..cb50426033 100644 --- a/src/MANYBODY/pair_edip_multi.cpp +++ b/src/MANYBODY/pair_edip_multi.cpp @@ -687,11 +687,13 @@ void PairEDIPMulti::setup() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_extep.cpp b/src/MANYBODY/pair_extep.cpp index 7f6d266050..f8446e16eb 100644 --- a/src/MANYBODY/pair_extep.cpp +++ b/src/MANYBODY/pair_extep.cpp @@ -696,11 +696,13 @@ void PairExTeP::setup() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 3e948880ca..ba315bdf70 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -427,11 +427,13 @@ void PairGW::setup_params() if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { if (n >= 0) - error->all(FLERR,"Potential file has duplicate entry"); + error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index d74c504aea..3b25ac00a3 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -314,11 +314,15 @@ void PairNb3bHarmonic::setup_params() n = -1; for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR, "Potential file has duplicate entry"); + if (n >= 0) + error->all(FLERR, "Potential file has a duplicate entry for: {} {} {}", elements[i], + elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR, "Potential file is missing an entry"); + if (n < 0) + error->all(FLERR, "Potential file is missing an entry for: {} {} {}", elements[i], + elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index de2a7ac8d6..ce1f8193fd 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -438,11 +438,13 @@ void PairSW::setup_params() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index 37ea0bfebf..8b4a51ae95 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -543,11 +543,13 @@ void PairTersoff::setup_params() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index bc34edfb75..f2edf81ba5 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -177,11 +177,13 @@ void PairTersoffMOD::setup_params() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_tersoff_table.cpp b/src/MANYBODY/pair_tersoff_table.cpp index dee1fd3237..421d2c1e14 100644 --- a/src/MANYBODY/pair_tersoff_table.cpp +++ b/src/MANYBODY/pair_tersoff_table.cpp @@ -896,11 +896,13 @@ void PairTersoffTable::setup_params() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_threebody_table.cpp b/src/MANYBODY/pair_threebody_table.cpp index 2f4bc83f5a..044f69a8da 100644 --- a/src/MANYBODY/pair_threebody_table.cpp +++ b/src/MANYBODY/pair_threebody_table.cpp @@ -403,11 +403,15 @@ void PairThreebodyTable::setup_params() n = -1; for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR, "Potential file has duplicate entry"); + if (n >= 0) + error->all(FLERR, "Potential file has a duplicate entry for: {} {} {}", elements[i], + elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR, "Potential file is missing an entry"); + if (n < 0) + error->all(FLERR, "Potential file is missing an entry for: {} {} {}", elements[i], + elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 6ce6c6f59a..30855fa6da 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -410,11 +410,13 @@ void PairVashishta::setup_params() for (m = 0; m < nparams; m++) { if (i == params[m].ielement && j == params[m].jelement && k == params[m].kelement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {} {} {}", + elements[i], elements[j], elements[k]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {} {} {}", + elements[i], elements[j], elements[k]); elem3param[i][j][k] = n; } diff --git a/src/MISC/pair_agni.cpp b/src/MISC/pair_agni.cpp index 46cc630f2d..ee744173fc 100644 --- a/src/MISC/pair_agni.cpp +++ b/src/MISC/pair_agni.cpp @@ -406,11 +406,11 @@ void PairAGNI::setup_params() n = -1; for (m = 0; m < nparams; m++) { if (i == params[m].ielement) { - if (n >= 0) error->all(FLERR,"Potential file has duplicate entry"); + if (n >= 0) error->all(FLERR,"Potential file has a duplicate entry for: {}", elements[i]); n = m; } } - if (n < 0) error->all(FLERR,"Potential file is missing an entry"); + if (n < 0) error->all(FLERR,"Potential file is missing an entry for: {}", elements[i]); elem1param[i] = n; } From 87d1aef54360c2a2cea44dbfcbff818a0f0f6b1a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 24 Jul 2022 18:12:04 -0400 Subject: [PATCH 005/100] clarify whom to contact with questions about pre-built binaries. update ubuntu info --- doc/src/Install.rst | 18 ++++-- doc/src/Install_conda.rst | 7 ++ doc/src/Install_linux.rst | 130 ++++++++++++++++---------------------- 3 files changed, 76 insertions(+), 79 deletions(-) diff --git a/doc/src/Install.rst b/doc/src/Install.rst index 157bd32208..04e5333fea 100644 --- a/doc/src/Install.rst +++ b/doc/src/Install.rst @@ -3,10 +3,20 @@ Install LAMMPS You can download LAMMPS as an executable or as source code. -With source code, you also have to :doc:`build LAMMPS `. But you -have more flexibility as to what features to include or exclude in the -build. If you plan to :doc:`modify or extend LAMMPS `, then you -need the source code. +When downloading the LAMMPS source code, you also have to :doc:`build +LAMMPS `. But you have more flexibility as to what features to +include or exclude in the build. When you download and install +pre-compiled LAMMPS executables, you are limited to install which +version of LAMMPS is available and which features are included of these +builds. If you plan to :doc:`modify or extend LAMMPS `, then +you **must** build LAMMPS from the source code. + +.. note:: + + If you have questions about the pre-compiled LAMMPS executables, you + need to contact the people preparing those executables. The LAMMPS + developers have no control over their choices of how they configure + and build their packages and when they update them. .. toctree:: :maxdepth: 1 diff --git a/doc/src/Install_conda.rst b/doc/src/Install_conda.rst index 972c09d7d3..efb7b6146a 100644 --- a/doc/src/Install_conda.rst +++ b/doc/src/Install_conda.rst @@ -38,3 +38,10 @@ up the Conda capability. .. _openkim: https://openkim.org .. _conda: https://docs.conda.io/en/latest/index.html .. _mini_conda_install: https://docs.conda.io/en/latest/miniconda.html + +.. note:: + + If you have questions about these pre-compiled LAMMPS executables, + you need to contact the people preparing those packages. The LAMMPS + developers have no control over their choices of how they configure + and build their packages and when they update them. diff --git a/doc/src/Install_linux.rst b/doc/src/Install_linux.rst index bc44fe3b07..15a244f117 100644 --- a/doc/src/Install_linux.rst +++ b/doc/src/Install_linux.rst @@ -3,13 +3,19 @@ Download an executable for Linux Binaries are available for different versions of Linux: -| :ref:`Pre-built Ubuntu Linux executables ` -| :ref:`Pre-built Fedora Linux executables ` -| :ref:`Pre-built EPEL Linux executables (RHEL, CentOS) ` -| :ref:`Pre-built OpenSuse Linux executables ` -| :ref:`Gentoo Linux executable ` -| :ref:`Arch Linux build-script ` -| +- :ref:`Pre-built Ubuntu Linux executables ` +- :ref:`Pre-built Fedora Linux executables ` +- :ref:`Pre-built EPEL Linux executables (RHEL, CentOS) ` +- :ref:`Pre-built OpenSuse Linux executables ` +- :ref:`Gentoo Linux executable ` +- :ref:`Arch Linux build-script ` + +.. note:: + + If you have questions about these pre-compiled LAMMPS executables, + you need to contact the people preparing those packages. The LAMMPS + developers have no control over their choices of how they configure + and build their packages and when they update them. ---------- @@ -18,41 +24,28 @@ Binaries are available for different versions of Linux: Pre-built Ubuntu Linux executables ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A pre-built LAMMPS executable suitable for running on the latest -Ubuntu Linux versions, can be downloaded as a Debian package. This -allows you to install LAMMPS with a single command, and stay -up-to-date with the current stable version of LAMMPS by simply updating -your operating system. Please note, that the repository below offers -two LAMMPS packages, ``lammps-daily`` and ``lammps-stable``. The -LAMMPS developers recommend to use the ``lammps-stable`` package for -any production simulations. The ``lammps-daily`` package is built -from the LAMMPS development sources, and those versions may have known -issues and bugs when new features are added and the software has not -undergone full release testing. - -To install the appropriate personal-package archives (PPAs), do the -following once: - -.. code-block:: bash - - $ sudo add-apt-repository ppa:gladky-anton/lammps - $ sudo add-apt-repository ppa:openkim/latest - $ sudo apt-get update +A pre-built LAMMPS executable suitable for running on the latest Ubuntu +Linux versions, can be downloaded as a Debian package. This allows you +to install LAMMPS with a single command, and stay (mostly) up-to-date +with the current stable version of LAMMPS by simply updating your +operating system. To install LAMMPS do the following once: .. code-block:: bash - $ sudo apt-get install lammps-stable + $ sudo apt-get install lammps -This downloads an executable named ``lmp_stable`` to your box, which -can then be used in the usual way to run input scripts: +This downloads an executable named ``lmp`` to your box and multiple +packages with supporting data, examples and libraries as well as any +missing dependencies. This executable can then be used in the usual way +to run input scripts: .. code-block:: bash - $ lmp_stable -in in.lj + $ lmp -in in.lj -To update LAMMPS to the most current stable version, do the following: +To update LAMMPS to the latest packaged version, do the following: .. code-block:: bash @@ -60,44 +53,24 @@ To update LAMMPS to the most current stable version, do the following: which will also update other packages on your system. -To get a copy of the current documentation and examples: - -.. code-block:: bash - - $ sudo apt-get install lammps-stable-doc - -which will download the doc files in -``/usr/share/doc/lammps-stable-doc/doc`` and example problems in -``/usr/share/doc/lammps-doc/examples``. - -To get a copy of the current potentials files: - -.. code-block:: bash - - $ sudo apt-get install lammps-stable-data - -which will download the potentials files to -``/usr/share/lammps-stable/potentials``. The ``lmp_stable`` binary is -hard-coded to look for potential files in this directory (it does not -use the ``LAMMPS_POTENTIALS`` environment variable, as described -in :doc:`pair_coeff ` command). - -The ``lmp_stable`` binary is built with the :ref:`KIM package ` which -results in the above command also installing the ``kim-api`` binaries when LAMMPS -is installed. In order to use potentials from `openkim.org `_, you -can install the ``openkim-models`` package +The ``lmp`` binary is built with the :ref:`KIM package ` included, +which results in the above command also installing the ``kim-api`` +binaries when LAMMPS is installed. In order to use potentials from +`openkim.org `_, you can also install the ``openkim-models`` +package .. code-block:: bash $ sudo apt-get install openkim-models +Or use the KIM-API commands to download and install individual models. To un-install LAMMPS, do the following: .. code-block:: bash - $ sudo apt-get remove lammps-stable + $ sudo apt-get remove lammps -Please use ``lmp_stable -help`` to see which compilation options, packages, +Please use ``lmp -help`` to see which compilation options, packages, and styles are included in the binary. Thanks to Anton Gladky (gladky.anton at gmail.com) for setting up this @@ -110,21 +83,21 @@ Ubuntu package capability. Pre-built Fedora Linux executables ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Pre-built LAMMPS packages for stable releases are available -in the Fedora Linux distribution as of version 28. The packages -can be installed via the dnf package manager. There are 3 basic -varieties (lammps = no MPI, lammps-mpich = MPICH MPI library, -lammps-openmpi = OpenMPI MPI library) and for each support for -linking to the C library interface (lammps-devel, lammps-mpich-devel, -lammps-openmpi-devel), the header for compiling programs using -the C library interface (lammps-headers), and the LAMMPS python -module for Python 3. All packages can be installed at the same -time and the name of the LAMMPS executable is ``lmp`` and ``lmp_openmpi`` -or ``lmp_mpich`` respectively. By default, ``lmp`` will refer to the -serial executable, unless one of the MPI environment modules is loaded -(``module load mpi/mpich-x86_64`` or ``module load mpi/openmpi-x86_64``). -Then the corresponding parallel LAMMPS executable can be used. -The same mechanism applies when loading the LAMMPS python module. +Pre-built LAMMPS packages for stable releases are available in the +Fedora Linux distribution as of Fedora version 28. The packages can be +installed via the dnf package manager. There are 3 basic varieties +(lammps = no MPI, lammps-mpich = MPICH MPI library, lammps-openmpi = +OpenMPI MPI library) and for each support for linking to the C library +interface (lammps-devel, lammps-mpich-devel, lammps-openmpi-devel), the +header for compiling programs using the C library interface +(lammps-headers), and the LAMMPS python module for Python 3. All +packages can be installed at the same time and the name of the LAMMPS +executable is ``lmp`` and ``lmp_openmpi`` or ``lmp_mpich`` respectively. +By default, ``lmp`` will refer to the serial executable, unless one of +the MPI environment modules is loaded (``module load mpi/mpich-x86_64`` +or ``module load mpi/openmpi-x86_64``). Then the corresponding parallel +LAMMPS executable can be used. The same mechanism applies when loading +the LAMMPS python module. To install LAMMPS with OpenMPI and run an input ``in.lj`` with 2 CPUs do: @@ -273,3 +246,10 @@ Alternatively, you may use an AUR helper to install these packages. Note that the AUR provides build-scripts that download the source and the build the package on your machine. + +.. note:: + + It looks like the Arch Linux AUR repository build scripts for LAMMPS + have not been updated since the 29 October 2020 version. You may want + to consider installing a more current version of LAMMPS from source + directly. From 762e79c49dcd4309629fe5a97b5f4cdc1d0b4ade Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Jul 2022 08:56:51 -0400 Subject: [PATCH 006/100] initialize possibly uninitialized variabled --- src/AMOEBA/amoeba_polar.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/AMOEBA/amoeba_polar.cpp b/src/AMOEBA/amoeba_polar.cpp index f0670ea8c6..b8020cb513 100644 --- a/src/AMOEBA/amoeba_polar.cpp +++ b/src/AMOEBA/amoeba_polar.cpp @@ -499,6 +499,18 @@ void PairAmoeba::polar_real() urc3[k] = rc3[k] * factor_uscale; urc5[k] = rc5[k] * factor_uscale; } + } else { + // avoid uninitialized data access when damp == 0.0 + psc3 = psc5 = psc7 = dsc3 = dsc5 = dsc7 = usc3 = usc5 = 0.0; + psr3 = psr5 = psr7 = dsr3 = dsr5 = dsr7 = usr5 = 0.0; + prc3[0] = prc3[1] = prc3[2] = 0.0; + drc3[0] = drc3[1] = drc3[2] = 0.0; + prc5[0] = prc5[1] = prc5[2] = 0.0; + drc5[0] = drc5[1] = drc5[2] = 0.0; + prc7[0] = prc7[1] = prc7[2] = 0.0; + drc7[0] = drc7[1] = drc7[2] = 0.0; + urc3[0] = urc3[1] = urc3[2] = 0.0; + urc5[0] = urc5[1] = urc5[2] = 0.0; } // apply charge penetration damping to scale factors From bcc49aca844343a838fbc8bf801b759f5a7251a3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Jul 2022 09:01:26 -0400 Subject: [PATCH 007/100] fix logic issue --- src/AMOEBA/amoeba_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AMOEBA/amoeba_utils.cpp b/src/AMOEBA/amoeba_utils.cpp index b01b9f11b6..332b62708e 100644 --- a/src/AMOEBA/amoeba_utils.cpp +++ b/src/AMOEBA/amoeba_utils.cpp @@ -84,9 +84,9 @@ void PairAmoeba::kmpole() if (bondneigh[j] < smallest) { smallest = bondneigh[j]; k = j; + bondneigh[k] = bondneigh[m]; + bondneigh[m] = smallest; } - bondneigh[k] = bondneigh[m]; - bondneigh[m] = smallest; } } From e99494d838c8fa3034e919222c0367c0a33affd0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Jul 2022 09:02:54 -0400 Subject: [PATCH 008/100] fix copy-n-paste error --- src/AMOEBA/amoeba_kspace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AMOEBA/amoeba_kspace.cpp b/src/AMOEBA/amoeba_kspace.cpp index 22b83c1b59..5e12deae1c 100644 --- a/src/AMOEBA/amoeba_kspace.cpp +++ b/src/AMOEBA/amoeba_kspace.cpp @@ -1137,7 +1137,7 @@ void PairAmoeba::kewald() // NOTE: also worry about satisfying Tinker minfft ? while (!factorable(ndfft1)) ndfft1++; - while (!factorable(ndfft2)) ndfft3++; + while (!factorable(ndfft2)) ndfft2++; while (!factorable(ndfft3)) ndfft3++; } From 6dc966408704ed604b209539aec4c4d087f55392 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Jul 2022 09:06:09 -0400 Subject: [PATCH 009/100] avoid uninitialized data access --- src/AMOEBA/angle_amoeba.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AMOEBA/angle_amoeba.cpp b/src/AMOEBA/angle_amoeba.cpp index 4b9342f058..33b89a29f5 100644 --- a/src/AMOEBA/angle_amoeba.cpp +++ b/src/AMOEBA/angle_amoeba.cpp @@ -53,6 +53,9 @@ AngleAmoeba::AngleAmoeba(LAMMPS *lmp) : Angle(lmp) ub_k = nullptr; ub_r0 = nullptr; + + setflag_a = setflag_ba = setflag_ub = nullptr; + enable_angle = enable_urey = 0; } /* ---------------------------------------------------------------------- */ From f736248efb484b1f199eceb75c4d5969262fcc7e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Jul 2022 09:17:37 -0400 Subject: [PATCH 010/100] replace calls to pow() with faster functions for integer powers --- src/AMOEBA/amoeba_hal.cpp | 13 +++++++++---- src/AMOEBA/amoeba_induce.cpp | 9 ++++++--- src/AMOEBA/amoeba_kspace.cpp | 11 +++++++---- src/AMOEBA/amoeba_multipole.cpp | 5 ++++- src/AMOEBA/amoeba_polar.cpp | 10 +++++++--- src/AMOEBA/amoeba_repulsion.cpp | 2 +- src/AMOEBA/pair_amoeba.cpp | 7 +++++-- 7 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/AMOEBA/amoeba_hal.cpp b/src/AMOEBA/amoeba_hal.cpp index 21bb7ad099..896595945e 100644 --- a/src/AMOEBA/amoeba_hal.cpp +++ b/src/AMOEBA/amoeba_hal.cpp @@ -16,12 +16,17 @@ #include "atom.h" #include "error.h" +#include "math_special.h" #include "neigh_list.h" #include using namespace LAMMPS_NS; +using MathSpecial::square; +using MathSpecial::cube; +using MathSpecial::powint; + enum{VDWL,REPULSE,QFER,DISP,MPOLE,POLAR,USOLV,DISP_LONG,MPOLE_LONG,POLAR_LONG}; /* ---------------------------------------------------------------------- @@ -114,14 +119,14 @@ void PairAmoeba::hal() } eps *= factor_hal; - rv7 = pow(rv,7.0); - rik6 = pow(rik2,3.0); + rv7 = powint(rv,7); + rik6 = cube(rik2); rik7 = rik6 * rik; rho = rik7 + ghal*rv7; tau = (dhal+1.0) / (rik + dhal*rv); - tau7 = pow(tau,7.0); + tau7 = powint(tau,7); dtau = tau / (dhal+1.0); - gtau = eps*tau7*rik6*(ghal+1.0)*pow(rv7/rho,2.0); + gtau = eps*tau7*rik6*(ghal+1.0)*square(rv7/rho); e = eps*tau7*rv7*((ghal+1.0)*rv7/rho-2.0); de = -7.0 * (dtau*e+gtau); diff --git a/src/AMOEBA/amoeba_induce.cpp b/src/AMOEBA/amoeba_induce.cpp index 3d9d7809cc..43688cef94 100644 --- a/src/AMOEBA/amoeba_induce.cpp +++ b/src/AMOEBA/amoeba_induce.cpp @@ -22,6 +22,7 @@ #include "fft3d_wrap.h" #include "fix_store.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "my_page.h" #include "neigh_list.h" @@ -32,6 +33,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +using MathSpecial::cube; + enum{INDUCE,RSD,SETUP_AMOEBA,SETUP_HIPPO,KMPOLE,AMGROUP}; // forward comm enum{FIELD,ZRSD,TORQUE,UFLD}; // reverse comm enum{VDWL,REPULSE,QFER,DISP,MPOLE,POLAR,USOLV,DISP_LONG,MPOLE_LONG,POLAR_LONG}; @@ -732,7 +735,7 @@ void PairAmoeba::uscale0b(int mode, double **rsd, double **rsdp, damp = pdi * pdamp[jtype]; if (damp != 0.0) { pgamma = MIN(pti,thole[jtype]); - damp = -pgamma * pow((r/damp),3.0); + damp = -pgamma * cube(r/damp); if (damp > -50.0) { expdamp = exp(damp); scale3 *= 1.0 - expdamp; @@ -1332,7 +1335,7 @@ void PairAmoeba::udirect2b(double **field, double **fieldp) } } else { pgamma = MIN(pti,thole[jtype]); - damp = pgamma * pow(r/damp,3.0); + damp = pgamma * cube(r/damp); if (damp < 50.0) { expdamp = exp(-damp); scale3 = 1.0 - expdamp; @@ -1384,7 +1387,7 @@ void PairAmoeba::udirect2b(double **field, double **fieldp) damp = pdi * pdamp[jtype]; if (damp != 0.0) { pgamma = MIN(pti,thole[jtype]); - damp = pgamma * pow(r/damp,3.0); + damp = pgamma * cube(r/damp); if (damp < 50.0) { expdamp = exp(-damp); scale3 = 1.0 - expdamp; diff --git a/src/AMOEBA/amoeba_kspace.cpp b/src/AMOEBA/amoeba_kspace.cpp index 5e12deae1c..51b206b6d8 100644 --- a/src/AMOEBA/amoeba_kspace.cpp +++ b/src/AMOEBA/amoeba_kspace.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "domain.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include @@ -24,6 +25,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +using MathSpecial::powint; + #define ANINT(x) ((x)>0 ? floor((x)+0.5) : ceil((x)-0.5)) /* ---------------------------------------------------------------------- @@ -173,13 +176,13 @@ void PairAmoeba::dftmod(double *bsmod, double *bsarray, int nfft, int order) factor = MY_PI * k / nfft; for (j = 1; j <= jcut; j++) { arg = factor / (factor + MY_PI*j); - sum1 += pow(arg,order); - sum2 += pow(arg,order2); + sum1 += powint(arg,order); + sum2 += powint(arg,order2); } for (j = 1; j <= jcut; j++) { arg = factor / (factor - MY_PI*j); - sum1 += pow(arg,order); - sum2 += pow(arg,order2); + sum1 += powint(arg,order); + sum2 += powint(arg,order2); } zeta = sum2 / sum1; } diff --git a/src/AMOEBA/amoeba_multipole.cpp b/src/AMOEBA/amoeba_multipole.cpp index 5d11bde1ab..8466a8fe1d 100644 --- a/src/AMOEBA/amoeba_multipole.cpp +++ b/src/AMOEBA/amoeba_multipole.cpp @@ -20,6 +20,7 @@ #include "domain.h" #include "fft3d_wrap.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "neigh_list.h" @@ -29,6 +30,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +using MathSpecial::square; + enum{FIELD,ZRSD,TORQUE,UFLD}; // reverse comm enum{VDWL,REPULSE,QFER,DISP,MPOLE,POLAR,USOLV,DISP_LONG,MPOLE_LONG,POLAR_LONG}; @@ -670,7 +673,7 @@ void PairAmoeba::multipole_kspace() nzlo = m_kspace->nzlo_fft; nzhi = m_kspace->nzhi_fft; - pterm = pow((MY_PI/aewald),2.0); + pterm = square(MY_PI/aewald); volterm = MY_PI * volbox; n = 0; diff --git a/src/AMOEBA/amoeba_polar.cpp b/src/AMOEBA/amoeba_polar.cpp index b8020cb513..ad6b585f25 100644 --- a/src/AMOEBA/amoeba_polar.cpp +++ b/src/AMOEBA/amoeba_polar.cpp @@ -20,6 +20,7 @@ #include "domain.h" #include "fft3d_wrap.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "neigh_list.h" @@ -29,6 +30,9 @@ using namespace LAMMPS_NS; using namespace MathConst; +using MathSpecial::square; +using MathSpecial::cube; + enum{FIELD,ZRSD,TORQUE,UFLD}; // reverse comm enum{MUTUAL,OPT,TCG,DIRECT}; enum{VDWL,REPULSE,QFER,DISP,MPOLE,POLAR,USOLV,DISP_LONG,MPOLE_LONG,POLAR_LONG}; @@ -82,7 +86,7 @@ void PairAmoeba::polar() // compute the Ewald self-energy torque and virial terms - term = (4.0/3.0) * felec * pow(aewald,3.0) / MY_PIS; + term = (4.0/3.0) * felec * cube(aewald) / MY_PIS; for (i = 0; i < nlocal; i++) { dix = rpole[i][1]; @@ -454,7 +458,7 @@ void PairAmoeba::polar_real() damp = pdi * pdamp[jtype]; if (damp != 0.0) { pgamma = MIN(pti,thole[jtype]); - damp = pgamma * pow(r/damp,3.0); + damp = pgamma * cube(r/damp); if (damp < 50.0) { expdamp = exp(-damp); sc3 = 1.0 - expdamp; @@ -1272,7 +1276,7 @@ void PairAmoeba::polar_kspace() int nlocal = atom->nlocal; double volbox = domain->prd[0] * domain->prd[1] * domain->prd[2]; - pterm = pow((MY_PI/aewald),2.0); + pterm = square(MY_PI/aewald); volterm = MY_PI * volbox; // initialize variables required for the scalar summation diff --git a/src/AMOEBA/amoeba_repulsion.cpp b/src/AMOEBA/amoeba_repulsion.cpp index 0784a32d0b..041d74e54d 100644 --- a/src/AMOEBA/amoeba_repulsion.cpp +++ b/src/AMOEBA/amoeba_repulsion.cpp @@ -504,7 +504,7 @@ void PairAmoeba::damprep(double r, double r2, double rr1, double rr3, dmpk24 = dmpk23 * dmpk2; dmpk25 = dmpk24 * dmpk2; term = dmpi22 - dmpk22; - pre = 8192.0 * dmpi23 * dmpk23 / pow(term,4.0); + pre = 8192.0 * dmpi23 * dmpk23 / (term*term*term*term); tmp = 4.0 * dmpi2 * dmpk2 / term; s = (dampi-tmp)*expk + (dampk+tmp)*expi; diff --git a/src/AMOEBA/pair_amoeba.cpp b/src/AMOEBA/pair_amoeba.cpp index be5f9c73df..e8b7b71753 100644 --- a/src/AMOEBA/pair_amoeba.cpp +++ b/src/AMOEBA/pair_amoeba.cpp @@ -25,6 +25,7 @@ #include "force.h" #include "gridcomm.h" #include "group.h" +#include "math_special.h" #include "memory.h" #include "modify.h" #include "my_page.h" @@ -40,6 +41,8 @@ using namespace LAMMPS_NS; +using MathSpecial::powint; + enum{INDUCE,RSD,SETUP_AMOEBA,SETUP_HIPPO,KMPOLE,AMGROUP,PVAL}; // forward comm enum{FIELD,ZRSD,TORQUE,UFLD}; // reverse comm enum{ARITHMETIC,GEOMETRIC,CUBIC_MEAN,R_MIN,SIGMA,DIAMETER,HARMONIC,HHG,W_H}; @@ -1956,7 +1959,7 @@ void PairAmoeba::choose(int which) // taper coeffs - double denom = pow(off-cut,5.0); + double denom = powint(off-cut,5); c0 = off*off2 * (off2 - 5.0*off*cut + 10.0*cut2) / denom; c1 = -30.0 * off2*cut2 / denom; c2 = 30.0 * (off2*cut+off*cut2) / denom; @@ -2026,7 +2029,7 @@ void PairAmoeba::mix() } else if (epsilon_rule == HHG) { eij = 4.0 * (ei*ej) / ((sei+sej)*(sei+sej)); } else if (epsilon_rule == W_H) { - eij = 2.0 * (sei*sej) * pow(ri*rj,3.0) / (pow(ri,6.0) + pow(rj,6.0)); + eij = 2.0 * (sei*sej) * powint(ri*rj,3) / (powint(ri,6) + powint(rj,6)); } else { eij = sei * sej; } From 7b54b974d3dbc1f29f6eaa68fea2adf034f47447 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Jul 2022 11:48:21 -0400 Subject: [PATCH 011/100] remove dead code --- src/dump_custom.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/dump_custom.h b/src/dump_custom.h index b27a9950cd..dd653d5e98 100644 --- a/src/dump_custom.h +++ b/src/dump_custom.h @@ -127,11 +127,6 @@ class DumpCustom : public Dump { void header_item(bigint); void header_item_triclinic(bigint); - typedef int (DumpCustom::*FnPtrConvert)(int, double *); - FnPtrConvert convert_choice; // ptr to convert data functions - int convert_image(int, double *); - int convert_noimage(int, double *); - typedef void (DumpCustom::*FnPtrWrite)(int, double *); FnPtrWrite write_choice; // ptr to write data functions void write_binary(int, double *); From 5f6785017138f173bfa14e7552f3537fd97e3674 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 25 Jul 2022 22:32:59 -0400 Subject: [PATCH 012/100] correct typos --- doc/src/Intro_citing.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/Intro_citing.rst b/doc/src/Intro_citing.rst index e10b1857f1..aaf62028ae 100644 --- a/doc/src/Intro_citing.rst +++ b/doc/src/Intro_citing.rst @@ -33,9 +33,9 @@ initial versions of LAMMPS is: DOI for the LAMMPS source code ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LAMMPS developers use the `Zenodo service at CERN `_ -to create digital object identifies (DOI) for stable releases of the -LAMMPS source code. There are two types of DOIs for the LAMMPS source code. +The LAMMPS developers use the `Zenodo service at CERN `_ +to create digital object identifiers (DOI) for stable releases of the +LAMMPS source code. There are two types of DOIs for the LAMMPS source code. The canonical DOI for **all** versions of LAMMPS, which will always point to the **latest** stable release version is: From d347a27a396dde34254739e17f5876e9fa32d0f1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 26 Jul 2022 09:18:21 -0400 Subject: [PATCH 013/100] add reference --- doc/src/label.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/label.rst b/doc/src/label.rst index 710a1b1b40..430587135f 100644 --- a/doc/src/label.rst +++ b/doc/src/label.rst @@ -38,7 +38,7 @@ Restrictions Related commands """""""""""""""" -none +:doc:`jump `, :doc:`next ` Default From 4f8a1ca52685f65965aab558641b7ce58b39c86e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 26 Jul 2022 12:32:42 -0400 Subject: [PATCH 014/100] correct formatting --- doc/lammps.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lammps.1 b/doc/lammps.1 index 5f1c25867e..586627258e 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -161,7 +161,7 @@ list references for specific cite-able features used during a run. .TP \fB\-pk