From 39a00e2901019e37d8bb3d50ffdbeedc9ed224f6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 11 Apr 2021 06:03:46 -0400 Subject: [PATCH 01/24] reformat --- doc/src/fix_qeq.rst | 125 ++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 58 deletions(-) diff --git a/doc/src/fix_qeq.rst b/doc/src/fix_qeq.rst index 56fde059e8..c655076ce8 100644 --- a/doc/src/fix_qeq.rst +++ b/doc/src/fix_qeq.rst @@ -56,27 +56,28 @@ Examples Description """"""""""" -Perform the charge equilibration (QEq) method as described in :ref:`(Rappe and Goddard) ` and formulated in :ref:`(Nakano) ` (also known -as the matrix inversion method) and in :ref:`(Rick and Stuart) ` (also -known as the extended Lagrangian method) based on the -electronegativity equilization principle. +Perform the charge equilibration (QEq) method as described in +:ref:`(Rappe and Goddard) ` and formulated in :ref:`(Nakano) +` (also known as the matrix inversion method) and in +:ref:`(Rick and Stuart) ` (also known as the extended Lagrangian +method) based on the electronegativity equilization principle. These fixes can be used with any :doc:`pair style ` in LAMMPS, so long as per-atom charges are defined. The most typical use-case is in conjunction with a :doc:`pair style ` that performs charge equilibration periodically (e.g. every timestep), such -as the ReaxFF or Streitz-Mintmire potential. -But these fixes can also be used with -potentials that normally assume per-atom charges are fixed, e.g. a -:doc:`Buckingham ` or :doc:`LJ/Coulombic ` potential. +as the ReaxFF or Streitz-Mintmire potential. But these fixes can also +be used with potentials that normally assume per-atom charges are fixed, +e.g. a :doc:`Buckingham ` or :doc:`LJ/Coulombic ` +potential. -Because the charge equilibration calculation is effectively -independent of the pair style, these fixes can also be used to perform -a one-time assignment of charges to atoms. For example, you could -define the QEq fix, perform a zero-timestep run via the :doc:`run ` -command without any pair style defined which would set per-atom -charges (based on the current atom configuration), then remove the fix -via the :doc:`unfix ` command before performing further dynamics. +Because the charge equilibration calculation is effectively independent +of the pair style, these fixes can also be used to perform a one-time +assignment of charges to atoms. For example, you could define the QEq +fix, perform a zero-timestep run via the :doc:`run ` command +without any pair style defined which would set per-atom charges (based +on the current atom configuration), then remove the fix via the +:doc:`unfix ` command before performing further dynamics. .. note:: @@ -87,11 +88,14 @@ via the :doc:`unfix ` command before performing further dynamics. .. note:: - The :doc:`fix qeq/comb ` command must still be used - to perform charge equilibration with the :doc:`COMB potential `. The :doc:`fix qeq/reax ` - command can be used to perform charge equilibration with the :doc:`ReaxFF force field `, although fix qeq/shielded yields the - same results as fix qeq/reax if *Nevery*\ , *cutoff*\ , and *tolerance* - are the same. Eventually the fix qeq/reax command will be deprecated. + The :doc:`fix qeq/comb ` command must still be used to + perform charge equilibration with the :doc:`COMB potential + `. The :doc:`fix qeq/reax ` command can be + used to perform charge equilibration with the :doc:`ReaxFF force + field `, although fix qeq/shielded yields the same + results as fix qeq/reax if *Nevery*\ , *cutoff*\ , and *tolerance* + are the same. Eventually the fix qeq/reax command will be + deprecated. The QEq method minimizes the electrostatic energy of the system (or equalizes the derivative of energy with respect to charge of all the @@ -134,55 +138,57 @@ usually a good number. The *qeq/shielded* style describes partial charges on atoms also as point charges, but uses a shielded Coulomb potential to describe the interaction between a pair of charged particles. Interaction through -the shielded Coulomb is given by equation (13) of the :ref:`ReaxFF force field ` paper. The shielding accounts for charge overlap +the shielded Coulomb is given by equation (13) of the :ref:`ReaxFF force +field ` paper. The shielding accounts for charge overlap between charged particles at small separation. This style is the same -as :doc:`fix qeq/reax `, and can be used with :doc:`pair_style reax/c `. Only the *chi*\ , *eta*\ , and *gamma* -parameters from the *qfile* file are used. When using the string -*reax/c* as filename, these parameters are extracted directly from -an active *reax/c* pair style. This style solves partial -charges on atoms via the matrix inversion method. A tolerance of -1.0e-6 is usually a good number. +as :doc:`fix qeq/reax `, and can be used with +:doc:`pair_style reax/c `. Only the *chi*\ , *eta*\ , and +*gamma* parameters from the *qfile* file are used. When using the string +*reax/c* as filename, these parameters are extracted directly from an +active *reax/c* pair style. This style solves partial charges on atoms +via the matrix inversion method. A tolerance of 1.0e-6 is usually a +good number. The *qeq/slater* style describes partial charges on atoms as spherical charge densities centered around atoms via the Slater 1\ *s* orbital, so -that the interaction between a pair of charged particles is the -product of two Slater 1\ *s* orbitals. The expression for the Slater -1\ *s* orbital is given under equation (6) of the -:ref:`Streitz-Mintmire ` paper. Only the *chi*\ , *eta*\ , *zeta*\ , and -*qcore* parameters from the *qfile* file are used. When using the string +that the interaction between a pair of charged particles is the product +of two Slater 1\ *s* orbitals. The expression for the Slater 1\ *s* +orbital is given under equation (6) of the :ref:`Streitz-Mintmire +` paper. Only the *chi*\ , *eta*\ , *zeta*\ , and *qcore* +parameters from the *qfile* file are used. When using the string *coul/streitz* as filename, these parameters are extracted directly from -an active *coul/streitz* pair style. This style solves -partial charges on atoms via the matrix inversion method. A tolerance -of 1.0e-6 is usually a good number. Keyword *alpha* can be used to -change the Slater type orbital exponent. +an active *coul/streitz* pair style. This style solves partial charges +on atoms via the matrix inversion method. A tolerance of 1.0e-6 is +usually a good number. Keyword *alpha* can be used to change the Slater +type orbital exponent. The *qeq/dynamic* style describes partial charges on atoms as point -charges that interact through 1/r, but the extended Lagrangian method -is used to solve partial charges on atoms. Only the *chi* and *eta* +charges that interact through 1/r, but the extended Lagrangian method is +used to solve partial charges on atoms. Only the *chi* and *eta* parameters from the *qfile* file are used. Note that Coulomb -catastrophe can occur if repulsion between the pair of charged -particles is too weak. A tolerance of 1.0e-3 is usually a good -number. Keyword *qdamp* can be used to change the damping factor, while -keyword *qstep* can be used to change the time step size. +catastrophe can occur if repulsion between the pair of charged particles +is too weak. A tolerance of 1.0e-3 is usually a good number. Keyword +*qdamp* can be used to change the damping factor, while keyword *qstep* +can be used to change the time step size. -The :ref:`\ *qeq/fire*\ ` style describes the same charge model and charge -solver as the *qeq/dynamic* style, but employs a FIRE minimization -algorithm to solve for equilibrium charges. -Keyword *qdamp* can be used to change the damping factor, while -keyword *qstep* can be used to change the time step size. +The :ref:`\ *qeq/fire*\ ` style describes the same charge model +and charge solver as the *qeq/dynamic* style, but employs a FIRE +minimization algorithm to solve for equilibrium charges. Keyword +*qdamp* can be used to change the damping factor, while keyword *qstep* +can be used to change the time step size. Note that *qeq/point*\ , *qeq/shielded*\ , and *qeq/slater* describe different charge models, whereas the matrix inversion method and the extended Lagrangian method (\ *qeq/dynamic* and *qeq/fire*\ ) are different solvers. -Note that *qeq/point*\ , *qeq/dynamic* and *qeq/fire* styles all describe -charges as point charges that interact through 1/r relationship, but -solve partial charges on atoms using different solvers. These three -styles should yield comparable results if -the QEq parameters and *Nevery*\ , *cutoff*\ , and *tolerance* are the -same. Style *qeq/point* is typically faster, *qeq/dynamic* scales -better on larger sizes, and *qeq/fire* is faster than *qeq/dynamic*\ . +Note that *qeq/point*\ , *qeq/dynamic* and *qeq/fire* styles all +describe charges as point charges that interact through 1/r +relationship, but solve partial charges on atoms using different +solvers. These three styles should yield comparable results if the QEq +parameters and *Nevery*\ , *cutoff*\ , and *tolerance* are the same. +Style *qeq/point* is typically faster, *qeq/dynamic* scales better on +larger sizes, and *qeq/fire* is faster than *qeq/dynamic*\ . .. note:: @@ -200,9 +206,11 @@ better on larger sizes, and *qeq/fire* is faster than *qeq/dynamic*\ . Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about these fixes is written to :doc:`binary restart files `. No global scalar or vector or per-atom -quantities are stored by these fixes for access by various :doc:`output commands `. No parameter of these fixes can be used -with the *start/stop* keywords of the :doc:`run ` command. +No information about these fixes is written to :doc:`binary restart +files `. No global scalar or vector or per-atom quantities are +stored by these fixes for access by various :doc:`output commands +`. No parameter of these fixes can be used with the +*start/stop* keywords of the :doc:`run ` command. Thexe fixes are invoked during :doc:`energy minimization `. @@ -210,7 +218,8 @@ Restrictions """""""""""" These fixes are part of the QEQ package. They are only enabled if -LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. +LAMMPS was built with that package. See the :doc:`Build package +` doc page for more info. Related commands """""""""""""""" From e1418a341a6cc0f196ae958807160e250229b5c9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 11 Apr 2021 06:05:41 -0400 Subject: [PATCH 02/24] ensure that only one of comb/comb3 is matched and called --- src/MANYBODY/fix_qeq_comb.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/MANYBODY/fix_qeq_comb.cpp b/src/MANYBODY/fix_qeq_comb.cpp index 910db90822..7c23e6c218 100644 --- a/src/MANYBODY/fix_qeq_comb.cpp +++ b/src/MANYBODY/fix_qeq_comb.cpp @@ -17,21 +17,21 @@ #include "fix_qeq_comb.h" -#include -#include -#include "pair_comb.h" -#include "pair_comb3.h" -#include "neigh_list.h" #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "group.h" +#include "memory.h" +#include "neigh_list.h" #include "respa.h" #include "update.h" -#include "memory.h" -#include "error.h" +#include +#include +#include "pair_comb.h" +#include "pair_comb3.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -85,9 +85,6 @@ FixQEQComb::FixQEQComb(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) qf[i] = 0.0; - comb = nullptr; - comb3 = nullptr; - comm_forward = 1; } @@ -119,8 +116,9 @@ void FixQEQComb::init() if (!atom->q_flag) error->all(FLERR,"Fix qeq/comb requires atom attribute q"); - comb = (PairComb *) force->pair_match("^comb",0); comb3 = (PairComb3 *) force->pair_match("^comb3",0); + if (!comb3) comb = (PairComb *) force->pair_match("^comb",0); + if (comb == nullptr && comb3 == nullptr) error->all(FLERR,"Must use pair_style comb or comb3 with fix qeq/comb"); @@ -204,14 +202,17 @@ void FixQEQComb::post_force(int /*vflag*/) double *q = atom->q; int *mask = atom->mask; - if (comb) { + if (comb) { inum = comb->list->inum; ilist = comb->list->ilist; - } - if (comb3) { + } else if (comb3) { inum = comb3->list->inum; ilist = comb3->list->ilist; + } else { + inum = 0; + ilist = nullptr; } + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; q1[i] = q2[i] = qf[i] = 0.0; @@ -227,8 +228,9 @@ void FixQEQComb::post_force(int /*vflag*/) } comm->forward_comm_fix(this); + enegtot = 0.0; if (comb) enegtot = comb->yasu_char(qf,igroup); - if (comb3) enegtot = comb3->combqeq(qf,igroup); + else if (comb3) enegtot = comb3->combqeq(qf,igroup); enegtot /= ngroup; enegchk = enegmax = 0.0; From bb0be962a91702abcd57b24651c898f60724555e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 11 Apr 2021 16:44:46 -0400 Subject: [PATCH 03/24] eliminate use of s(n)printf() in QEQ package --- src/QEQ/fix_qeq.cpp | 30 ++++++++++++--------------- src/QEQ/fix_qeq_dynamic.cpp | 27 ++++++++++--------------- src/QEQ/fix_qeq_fire.cpp | 39 ++++++++++++++---------------------- src/QEQ/fix_qeq_point.cpp | 28 ++++++++++++-------------- src/QEQ/fix_qeq_shielded.cpp | 32 ++++++++++++++--------------- src/QEQ/fix_qeq_slater.cpp | 30 ++++++++++++--------------- 6 files changed, 80 insertions(+), 106 deletions(-) diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index a63e008b36..e592ed2af4 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -18,16 +18,16 @@ #include "fix_qeq.h" -#include -#include #include "atom.h" #include "comm.h" -#include "neigh_list.h" -#include "update.h" +#include "error.h" #include "force.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "update.h" +#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -386,13 +386,11 @@ int FixQEq::CG( double *b, double *x ) vector_sum( d, 1., p, beta, d, inum ); } - if (loop >= maxiter && comm->me == 0) { - char str[128]; - sprintf(str,"Fix qeq CG convergence failed (%g) after %d iterations " - "at " BIGINT_FORMAT " step",sqrt(sig_new)/b_norm,loop,update->ntimestep); - error->warning(FLERR,str); - } - + if ((comm->me == 0) && (loop >= maxiter)) + error->warning(FLERR,fmt::format("Fix qeq CG convergence failed ({}) " + "after {} iterations at step {}", + sqrt(sig_new)/b_norm,loop, + update->ntimestep)); return loop; } @@ -708,11 +706,9 @@ void FixQEq::read_file(char *file) FILE *fp; if (comm->me == 0) { fp = utils::open_potential(file,lmp,nullptr); - if (fp == nullptr) { - char str[128]; - snprintf(str,128,"Cannot open fix qeq parameter file %s",file); - error->one(FLERR,str); - } + if (fp == nullptr) + error->one(FLERR,fmt::format("Cannot open fix qeq parameter file {}: {}", + file,utils::getsyserror())); } // read each line out of file, skipping blank lines or leading '#' diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index b06bde223b..397393b786 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -17,20 +17,20 @@ #include "fix_qeq_dynamic.h" -#include - -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" #include "kspace.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" #include "respa.h" -#include "error.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; @@ -154,14 +154,9 @@ void FixQEqDynamic::pre_force(int /*vflag*/) } } - if (comm->me == 0) { - if (iloop == maxiter) { - char str[128]; - sprintf(str,"Charges did not converge at step " BIGINT_FORMAT - ": %lg",update->ntimestep,enegchk); - error->warning(FLERR,str); - } - } + if ((comm->me == 0) && (iloop >= maxiter)) + error->warning(FLERR,fmt::format("Charges did not converge at step " + "{}: {}",update->ntimestep,enegchk)); if (force->kspace) force->kspace->qsum_qsq(); } diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index b33a7745e0..0bdf65dc18 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -17,22 +17,22 @@ #include "fix_qeq_fire.h" -#include - -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" +#include "kspace.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" #include "pair_comb.h" #include "pair_comb3.h" -#include "kspace.h" #include "respa.h" -#include "error.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -47,7 +47,7 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixQEqFire::FixQEqFire(LAMMPS *lmp, int narg, char **arg) : - FixQEq(lmp, narg, arg) + FixQEq(lmp, narg, arg), comb(nullptr), comb3(nullptr) { qdamp = 0.20; qstep = 0.20; @@ -65,9 +65,6 @@ FixQEqFire::FixQEqFire(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else error->all(FLERR,"Illegal fix qeq/fire command"); } - - comb = nullptr; - comb3 = nullptr; } /* ---------------------------------------------------------------------- */ @@ -94,9 +91,8 @@ void FixQEqFire::init() if (utils::strmatch(update->integrate_style,"^respa")) nlevels_respa = ((Respa *) update->integrate)->nlevels; - comb = (PairComb *) force->pair_match("comb",1); - comb3 = (PairComb3 *) force->pair_match("comb3",1); - + comb3 = (PairComb3 *) force->pair_match("^comb3",0); + if (!comb3) comb = (PairComb *) force->pair_match("^comb",0); } /* ---------------------------------------------------------------------- */ @@ -218,14 +214,9 @@ void FixQEqFire::pre_force(int /*vflag*/) if (enegchk < tolerance) break; } - if (comm->me == 0) { - if (iloop == maxiter) { - char str[128]; - sprintf(str,"Charges did not converge at step " BIGINT_FORMAT - ": %lg",update->ntimestep,enegchk); - error->warning(FLERR,str); - } - } + if ((comm->me == 0) && (iloop >= maxiter)) + error->warning(FLERR,fmt::format("Charges did not converge at step " + "{}: {}",update->ntimestep,enegchk)); if (force->kspace) force->kspace->qsum_qsq(); } diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index 3d71135ae1..ac31f906e0 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -16,20 +16,22 @@ ------------------------------------------------------------------------- */ #include "fix_qeq_point.h" -#include -#include + #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" #include "kspace.h" -#include "respa.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "respa.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; @@ -158,13 +160,9 @@ void FixQEqPoint::compute_H() } } - if (m_fill >= H.m) { - char str[128]; - sprintf(str,"H matrix size has been exceeded: m_fill=%d H.m=%d\n", - m_fill, H.m ); - error->warning(FLERR,str); - error->all(FLERR,"Fix qeq/point has insufficient QEq matrix size"); - } + if (m_fill >= H.m) + error->all(FLERR,fmt::format("Fix qeq/point has insufficient H matrix " + "size: m_fill={} H.m={}\n",m_fill, H.m)); } /* ---------------------------------------------------------------------- */ diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index 356a747ed3..ad6202abd8 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -16,21 +16,23 @@ ------------------------------------------------------------------------- */ #include "fix_qeq_shielded.h" -#include -#include + #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" -#include "pair.h" #include "kspace.h" -#include "respa.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "respa.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; @@ -223,13 +225,9 @@ void FixQEqShielded::compute_H() } } - if (m_fill >= H.m) { - char str[128]; - sprintf(str,"H matrix size has been exceeded: m_fill=%d H.m=%d\n", - m_fill, H.m ); - error->warning(FLERR,str); - error->all(FLERR,"Fix qeq/shielded has insufficient QEq matrix size"); - } + if (m_fill >= H.m) + error->all(FLERR,fmt::format("Fix qeq/shielded has insufficient H matrix " + "size: m_fill={} H.m={}\n",m_fill,H.m)); } /* ---------------------------------------------------------------------- */ @@ -247,7 +245,7 @@ double FixQEqShielded::calculate_H( double r, double gamma ) Taper = Taper * r + Tap[0]; denom = r * r * r + gamma; - denom = pow(denom,0.3333333333333); + denom = pow(denom,1.0/3.0); return Taper * EV_TO_KCAL_PER_MOL / denom; } diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 9b90f78d7a..326d71c93b 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -16,22 +16,23 @@ ------------------------------------------------------------------------- */ #include "fix_qeq_slater.h" -#include -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" +#include "error.h" #include "force.h" #include "group.h" -#include "pair.h" #include "kspace.h" -#include "respa.h" #include "math_const.h" -#include "error.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "respa.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace MathConst; @@ -207,14 +208,9 @@ void FixQEqSlater::compute_H() chizj[i] = zjtmp; } - if (m_fill >= H.m) { - char str[128]; - sprintf(str,"H matrix size has been exceeded: m_fill=%d H.m=%d\n", - m_fill, H.m ); - error->warning(FLERR,str); - error->all(FLERR,"Fix qeq/slater has insufficient QEq matrix size"); - } - + if (m_fill >= H.m) + error->all(FLERR,fmt::format(FLERR,"Fix qeq/slater has insufficient H " + "matrix size:m_fill={} H.m={}\n",m_fill,H.m)); } /* ---------------------------------------------------------------------- */ From 38d5798223a6946e688749b2d3dabe13810f659b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 11 Apr 2021 21:36:18 -0400 Subject: [PATCH 04/24] must not look for package metadata when using python module from source tree --- python/lammps/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index e6ffd779a9..93c46819c0 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -13,10 +13,16 @@ from .core import * from .data import * from .pylammps import * -# convert module string version to numeric version +# convert installed module string version to numeric version def get_version_number(): import time + from os.path import join from sys import version_info + + # must report 0 when inside LAMMPS source tree + if __file__.find(join('python', 'lammps', '__init__.py')) > 0: + return 0 + vstring = None if version_info.major == 3 and version_info.minor >= 8: from importlib.metadata import version From c324d754a0644f2a50c5b376ca3318b8fc1a3396 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 12 Apr 2021 10:51:44 -0400 Subject: [PATCH 05/24] when installing the LAMMPS python package create a valid version id --- python/install.py | 8 +++++--- python/lammps/__init__.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/install.py b/python/install.py index 6e4c509f07..fbff02a1b5 100644 --- a/python/install.py +++ b/python/install.py @@ -10,7 +10,7 @@ build target in the conventional and CMake based build systems # copy LAMMPS shared library and lammps package to system dirs from __future__ import print_function -import sys,os,shutil +import sys,os,shutil,time from argparse import ArgumentParser parser = ArgumentParser(prog='install.py', @@ -80,13 +80,15 @@ if args.dir: sys.exit() -# extract version string from header +# extract LAMMPS version string from header +# and convert to python packaging compatible version def get_lammps_version(header): with open(header, 'r') as f: line = f.readline() start_pos = line.find('"')+1 end_pos = line.find('"', start_pos) - return "".join(line[start_pos:end_pos].split()) + t = time.strptime("".join(line[start_pos:end_pos].split()), "%d%b%Y") + return "{}.{}.{}".format(t.tm_year,t.tm_mon,t.tm_mday) verstr = get_lammps_version(args.version) diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index 93c46819c0..2c0e7a6fe3 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -38,7 +38,7 @@ def get_version_number(): if not vstring: return 0 - t = time.strptime(vstring, "%d%b%Y") + t = time.strptime(vstring, "%Y.%m.%d") return t.tm_year*10000 + t.tm_mon*100 + t.tm_mday __version__ = get_version_number() From d08d59acb3cd4e271cc8d106ead2865636d3128c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 12 Apr 2021 15:00:21 -0400 Subject: [PATCH 06/24] whitespace fix --- src/pair_coul_cut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pair_coul_cut.cpp b/src/pair_coul_cut.cpp index 428c12c2e0..629d39a9c5 100644 --- a/src/pair_coul_cut.cpp +++ b/src/pair_coul_cut.cpp @@ -260,7 +260,7 @@ void PairCoulCut::read_restart(FILE *fp) MPI_Bcast(&scale[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); if (setflag[i][j]) { - if (me == 0) + if (me == 0) utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error); MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); } From e49e505b9f096bb1e954e99e51544353eff4ceb8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 12 Apr 2021 23:16:02 -0400 Subject: [PATCH 07/24] make utility function private --- src/USER-COLVARS/ndx_group.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/USER-COLVARS/ndx_group.h b/src/USER-COLVARS/ndx_group.h index ceca1f9570..944638017d 100644 --- a/src/USER-COLVARS/ndx_group.h +++ b/src/USER-COLVARS/ndx_group.h @@ -31,6 +31,7 @@ class Ndx2Group : protected Pointers { public: Ndx2Group(class LAMMPS *lmp) : Pointers(lmp) {}; void command(int, char **); + private: void create(const std::string &, const std::vector &); }; From d8c68dec6f9f38e162cf428a231c70c44bc866ae Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 12 Apr 2021 23:32:26 -0400 Subject: [PATCH 08/24] whitespace fixes --- doc/src/Build_extras.rst | 8 ++++---- src/COMPRESS/gz_file_writer.cpp | 2 +- src/MC/fix_charge_regulation.cpp | 2 +- src/USER-PACE/README | 20 ++++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 12bb33f264..d375d33e56 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -1253,8 +1253,8 @@ be built for the most part with all major versions of the C++ language. USER-PACE package ----------------------------- -This package requires a library that can be downloaded and built -in lib/pace or somewhere else, which must be done before building +This package requires a library that can be downloaded and built +in lib/pace or somewhere else, which must be done before building LAMMPS with this package. The code for the library can be found at: `https://github.com/ICAMS/lammps-user-pace/ `_ @@ -1276,8 +1276,8 @@ at: `https://github.com/ICAMS/lammps-user-pace/ triclinic; + triclinic = domain->triclinic; int ipe = modify->find_compute("thermo_pe"); c_pe = modify->compute[ipe]; diff --git a/src/USER-PACE/README b/src/USER-PACE/README index 3d85c806e9..c701a615f7 100644 --- a/src/USER-PACE/README +++ b/src/USER-PACE/README @@ -1,23 +1,23 @@ -The USER-PACE package provides the pace pair style, -an efficient implementation of the Atomic Cluster Expansion +The USER-PACE package provides the pace pair style, +an efficient implementation of the Atomic Cluster Expansion potential (ACE). -ACE is a methodology for deriving a highly accurate classical -potential fit to a large archive of quantum mechanical (DFT) data. +ACE is a methodology for deriving a highly accurate classical +potential fit to a large archive of quantum mechanical (DFT) data. This package was written by Yury Lysogorskiy and others -at ICAMS, the Interdisciplinary Centre for Advanced Materials Simulation, +at ICAMS, the Interdisciplinary Centre for Advanced Materials Simulation, Ruhr University Bochum, Germany (http://www.icams.de). -This package requires a library that can be downloaded and built -in lib/pace or somewhere else, which must be done before building -LAMMPS with this package. Details of the download, build, and -install process for this package using traditional make (not CMake) +This package requires a library that can be downloaded and built +in lib/pace or somewhere else, which must be done before building +LAMMPS with this package. Details of the download, build, and +install process for this package using traditional make (not CMake) are given in the lib/pace/README file, and scripts are provided to help automate the process. Also see the LAMMPS manual for general information on building LAMMPS with external libraries using either traditional make or CMake. -More information about the USER-PACE implementation of ACE +More information about the USER-PACE implementation of ACE is available here: https://github.com/ICAMS/lammps-user-pace From 02612047c34aac6dd90082b7c90c85df001cdf9e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 12 Apr 2021 23:57:30 -0400 Subject: [PATCH 09/24] must set CMAKE_EXPORT_COMPILE_COMMANDS ON for using iwyu --- cmake/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f567a15d25..a11c7575d2 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -269,6 +269,7 @@ endif() set(ENABLE_IWYU OFF CACHE BOOL "Add 'iwyu' build target to call the include-what-you-use tool") mark_as_advanced(ENABLE_IWYU) if(ENABLE_IWYU) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_program(IWYU_EXE NAMES include-what-you-use iwyu) find_program(IWYU_TOOL NAMES iwyu_tool iwyu-tool iwyu_tool.py) if (IWYU_EXE AND IWYU_TOOL) From fab571cf6bc1a1ba3aaa5b261f0244fda49a46b7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 00:32:11 -0400 Subject: [PATCH 10/24] IWYU reported header updates --- src/body.cpp | 1 - src/compute.cpp | 1 - src/compute_chunk_spread_atom.cpp | 2 ++ src/compute_reduce.cpp | 2 ++ src/compute_temp_region.cpp | 9 ++++----- src/fix.cpp | 1 - src/fix_controller.cpp | 2 -- src/fix_enforce2d.cpp | 7 +++---- src/fix_lineforce.cpp | 1 - src/fix_nph_sphere.cpp | 2 -- src/fix_npt_sphere.cpp | 2 -- src/fix_nve_limit.cpp | 11 +++++------ src/fix_nve_noforce.cpp | 6 +++--- src/fix_planeforce.cpp | 1 - src/fix_store_force.cpp | 8 ++++---- src/fix_vector.cpp | 2 -- src/group.cpp | 1 - src/imbalance_store.cpp | 2 -- src/imbalance_var.cpp | 2 -- src/info.cpp | 1 - src/library.cpp | 1 - src/math_eigen.cpp | 4 +++- src/math_special.cpp | 2 -- src/my_pool_chunk.cpp | 1 - src/npair_full_bin_atomonly.cpp | 6 +++--- src/npair_half_bin_atomonly_newton.cpp | 6 +++--- src/npair_half_size_bin_newtoff.cpp | 6 +++--- src/npair_half_size_bin_newton.cpp | 6 +++--- src/npair_half_size_bin_newton_tri.cpp | 6 +++--- src/npair_half_size_multi_newtoff.cpp | 6 +++--- src/npair_half_size_multi_newton.cpp | 6 +++--- src/npair_half_size_multi_newton_tri.cpp | 6 +++--- src/npair_half_size_nsq_newtoff.cpp | 6 +++--- src/npair_half_size_nsq_newton.cpp | 6 +++--- src/npair_halffull_newtoff.cpp | 6 +++--- src/npair_halffull_newton.cpp | 6 +++--- src/npair_skip.cpp | 6 +++--- src/npair_skip_respa.cpp | 6 +++--- src/npair_skip_size.cpp | 6 +++--- src/npair_skip_size_off2on.cpp | 6 +++--- src/npair_skip_size_off2on_oneside.cpp | 6 +++--- src/output.cpp | 3 --- src/pair_lj96_cut.cpp | 15 +++++++-------- src/pair_lj_relres.cpp | 1 - src/reader.cpp | 2 -- src/region_sphere.cpp | 1 - src/tokenizer.cpp | 1 - src/universe.cpp | 2 -- src/variable.cpp | 1 - src/write_coeff.cpp | 1 - src/write_data.cpp | 1 - src/write_restart.cpp | 1 - 52 files changed, 84 insertions(+), 119 deletions(-) diff --git a/src/body.cpp b/src/body.cpp index 89bb2fc1d9..2c4121b0cc 100644 --- a/src/body.cpp +++ b/src/body.cpp @@ -12,7 +12,6 @@ ------------------------------------------------------------------------- */ #include "body.h" -#include using namespace LAMMPS_NS; diff --git a/src/compute.cpp b/src/compute.cpp index 81e317076c..46bd0d0fc8 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -22,7 +22,6 @@ #include "modify.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index d817141064..f552454e72 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -23,6 +23,8 @@ #include "modify.h" #include "update.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index 30b4fcb98a..6e961df47a 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -25,6 +25,8 @@ #include "update.h" #include "variable.h" +#include + using namespace LAMMPS_NS; #define BIG 1.0e20 diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp index 036f118a30..535a0166c5 100644 --- a/src/compute_temp_region.cpp +++ b/src/compute_temp_region.cpp @@ -13,15 +13,14 @@ #include "compute_temp_region.h" -#include #include "atom.h" -#include "update.h" -#include "force.h" #include "domain.h" -#include "region.h" +#include "error.h" +#include "force.h" #include "group.h" #include "memory.h" -#include "error.h" +#include "region.h" +#include "update.h" using namespace LAMMPS_NS; diff --git a/src/fix.cpp b/src/fix.cpp index 32a76cc125..14c04bf4b5 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -21,7 +21,6 @@ #include "memory.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_controller.cpp b/src/fix_controller.cpp index 21d1ccf751..c611dee271 100644 --- a/src/fix_controller.cpp +++ b/src/fix_controller.cpp @@ -21,8 +21,6 @@ #include "update.h" #include "variable.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_enforce2d.cpp b/src/fix_enforce2d.cpp index 1284a9b78c..11e041fcf4 100644 --- a/src/fix_enforce2d.cpp +++ b/src/fix_enforce2d.cpp @@ -12,14 +12,13 @@ ------------------------------------------------------------------------- */ #include "fix_enforce2d.h" -#include + #include "atom.h" -#include "update.h" #include "domain.h" +#include "error.h" #include "modify.h" #include "respa.h" -#include "error.h" - +#include "update.h" using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_lineforce.cpp b/src/fix_lineforce.cpp index 6a77442ea4..d95aacfd93 100644 --- a/src/fix_lineforce.cpp +++ b/src/fix_lineforce.cpp @@ -19,7 +19,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_nph_sphere.cpp b/src/fix_nph_sphere.cpp index 20e072d5b5..1266cb2b9d 100644 --- a/src/fix_nph_sphere.cpp +++ b/src/fix_nph_sphere.cpp @@ -16,8 +16,6 @@ #include "error.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_npt_sphere.cpp b/src/fix_npt_sphere.cpp index a6dfeba425..8bbd43d4cf 100644 --- a/src/fix_npt_sphere.cpp +++ b/src/fix_npt_sphere.cpp @@ -16,8 +16,6 @@ #include "error.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_nve_limit.cpp b/src/fix_nve_limit.cpp index 58db5e25d9..58dc023991 100644 --- a/src/fix_nve_limit.cpp +++ b/src/fix_nve_limit.cpp @@ -13,16 +13,15 @@ #include "fix_nve_limit.h" -#include -#include #include "atom.h" -#include "force.h" -#include "update.h" -#include "respa.h" -#include "modify.h" #include "comm.h" #include "error.h" +#include "force.h" +#include "modify.h" +#include "respa.h" +#include "update.h" +#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_nve_noforce.cpp b/src/fix_nve_noforce.cpp index 61528a0024..e6bca3b608 100644 --- a/src/fix_nve_noforce.cpp +++ b/src/fix_nve_noforce.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "fix_nve_noforce.h" -#include + #include "atom.h" -#include "update.h" -#include "respa.h" #include "error.h" +#include "respa.h" +#include "update.h" using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_planeforce.cpp b/src/fix_planeforce.cpp index 783d26ac9e..fe6f3d6500 100644 --- a/src/fix_planeforce.cpp +++ b/src/fix_planeforce.cpp @@ -19,7 +19,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_store_force.cpp b/src/fix_store_force.cpp index 1541294f6c..7ebd4db75a 100644 --- a/src/fix_store_force.cpp +++ b/src/fix_store_force.cpp @@ -12,12 +12,12 @@ ------------------------------------------------------------------------- */ #include "fix_store_force.h" -#include + #include "atom.h" -#include "update.h" -#include "respa.h" -#include "memory.h" #include "error.h" +#include "memory.h" +#include "respa.h" +#include "update.h" using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_vector.cpp b/src/fix_vector.cpp index afd3778841..71a8bb3d3c 100644 --- a/src/fix_vector.cpp +++ b/src/fix_vector.cpp @@ -22,8 +22,6 @@ #include "update.h" #include "variable.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/group.cpp b/src/group.cpp index ebab78dd0f..0143008a72 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -35,7 +35,6 @@ #include #include #include -#include using namespace LAMMPS_NS; diff --git a/src/imbalance_store.cpp b/src/imbalance_store.cpp index 879b434bfd..e72ef4d50b 100644 --- a/src/imbalance_store.cpp +++ b/src/imbalance_store.cpp @@ -16,8 +16,6 @@ #include "atom.h" #include "error.h" -#include - using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ diff --git a/src/imbalance_var.cpp b/src/imbalance_var.cpp index d2a4f0d691..64f98a6a26 100644 --- a/src/imbalance_var.cpp +++ b/src/imbalance_var.cpp @@ -20,8 +20,6 @@ #include "memory.h" #include "variable.h" -#include - using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ diff --git a/src/info.cpp b/src/info.cpp index 948073bb10..f1ee327191 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -39,7 +39,6 @@ #include "pair.h" #include "pair_hybrid.h" #include "region.h" -#include "universe.h" #include "update.h" #include "variable.h" diff --git a/src/library.cpp b/src/library.cpp index 300aafc293..c51006f8d8 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -31,7 +31,6 @@ #include "group.h" #include "info.h" #include "input.h" -#include "integrate.h" #include "memory.h" #include "modify.h" #include "molecule.h" diff --git a/src/math_eigen.cpp b/src/math_eigen.cpp index ab00e42ae0..10caccd0e5 100644 --- a/src/math_eigen.cpp +++ b/src/math_eigen.cpp @@ -18,7 +18,9 @@ #include "math_eigen.h" #include "math_eigen_impl.h" -#include +#include +#include +#include using std::vector; using std::array; diff --git a/src/math_special.cpp b/src/math_special.cpp index 243d5a05f3..8d48158e72 100644 --- a/src/math_special.cpp +++ b/src/math_special.cpp @@ -4,8 +4,6 @@ #include // IWYU pragma: keep #include -#include "error.h" - using namespace LAMMPS_NS; static constexpr int nmaxfactorial = 167; diff --git a/src/my_pool_chunk.cpp b/src/my_pool_chunk.cpp index d866804adc..d824b0557b 100644 --- a/src/my_pool_chunk.cpp +++ b/src/my_pool_chunk.cpp @@ -14,7 +14,6 @@ #include "my_pool_chunk.h" #include -#include #if defined(LMP_USER_INTEL) && !defined(LAMMPS_MEMALIGN) && !defined(_WIN32) #define LAMMPS_MEMALIGN 64 diff --git a/src/npair_full_bin_atomonly.cpp b/src/npair_full_bin_atomonly.cpp index 4e05c2c17a..8ace197e30 100644 --- a/src/npair_full_bin_atomonly.cpp +++ b/src/npair_full_bin_atomonly.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_full_bin_atomonly.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_bin_atomonly_newton.cpp b/src/npair_half_bin_atomonly_newton.cpp index 2dd0bd0b96..2007bda728 100644 --- a/src/npair_half_bin_atomonly_newton.cpp +++ b/src/npair_half_bin_atomonly_newton.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_bin_atomonly_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_bin_newtoff.cpp b/src/npair_half_size_bin_newtoff.cpp index 2d406d533c..5b9eee3672 100644 --- a/src/npair_half_size_bin_newtoff.cpp +++ b/src/npair_half_size_bin_newtoff.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_bin_newtoff.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_bin_newton.cpp b/src/npair_half_size_bin_newton.cpp index 820b293414..9cf4e744ab 100644 --- a/src/npair_half_size_bin_newton.cpp +++ b/src/npair_half_size_bin_newton.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_bin_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_bin_newton_tri.cpp b/src/npair_half_size_bin_newton_tri.cpp index ea878ef440..83f903c864 100644 --- a/src/npair_half_size_bin_newton_tri.cpp +++ b/src/npair_half_size_bin_newton_tri.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_bin_newton_tri.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp index d57542f562..f1bc93de38 100644 --- a/src/npair_half_size_multi_newtoff.cpp +++ b/src/npair_half_size_multi_newtoff.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_multi_newtoff.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_multi_newton.cpp b/src/npair_half_size_multi_newton.cpp index 01065876af..22a02899ca 100644 --- a/src/npair_half_size_multi_newton.cpp +++ b/src/npair_half_size_multi_newton.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_multi_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp index 361c0ba260..268ca81f3d 100644 --- a/src/npair_half_size_multi_newton_tri.cpp +++ b/src/npair_half_size_multi_newton_tri.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_multi_newton_tri.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_nsq_newtoff.cpp b/src/npair_half_size_nsq_newtoff.cpp index 38594ebcb1..79302042a6 100644 --- a/src/npair_half_size_nsq_newtoff.cpp +++ b/src/npair_half_size_nsq_newtoff.cpp @@ -12,12 +12,12 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_nsq_newtoff.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" +#include "error.h" #include "group.h" #include "my_page.h" -#include "error.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_half_size_nsq_newton.cpp b/src/npair_half_size_nsq_newton.cpp index 9010ca9a86..1ac6223afa 100644 --- a/src/npair_half_size_nsq_newton.cpp +++ b/src/npair_half_size_nsq_newton.cpp @@ -12,12 +12,12 @@ ------------------------------------------------------------------------- */ #include "npair_half_size_nsq_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" +#include "error.h" #include "group.h" #include "my_page.h" -#include "error.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_halffull_newtoff.cpp b/src/npair_halffull_newtoff.cpp index e2965b4a46..52f981e843 100644 --- a/src/npair_halffull_newtoff.cpp +++ b/src/npair_halffull_newtoff.cpp @@ -12,10 +12,10 @@ ------------------------------------------------------------------------- */ #include "npair_halffull_newtoff.h" -#include "neigh_list.h" -#include "atom_vec.h" -#include "my_page.h" + #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_halffull_newton.cpp b/src/npair_halffull_newton.cpp index 99b5493f3e..cf15af8f18 100644 --- a/src/npair_halffull_newton.cpp +++ b/src/npair_halffull_newton.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_halffull_newton.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip.cpp b/src/npair_skip.cpp index 45540ab2fa..6046464ecf 100644 --- a/src/npair_skip.cpp +++ b/src/npair_skip.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_skip.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip_respa.cpp b/src/npair_skip_respa.cpp index 3479a5d8ce..d24a30794e 100644 --- a/src/npair_skip_respa.cpp +++ b/src/npair_skip_respa.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_skip_respa.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip_size.cpp b/src/npair_skip_size.cpp index d3810e6acc..40b70aed21 100644 --- a/src/npair_skip_size.cpp +++ b/src/npair_skip_size.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_skip_size.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip_size_off2on.cpp b/src/npair_skip_size_off2on.cpp index 0d7630aaa9..994910852b 100644 --- a/src/npair_skip_size_off2on.cpp +++ b/src/npair_skip_size_off2on.cpp @@ -12,11 +12,11 @@ ------------------------------------------------------------------------- */ #include "npair_skip_size_off2on.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/npair_skip_size_off2on_oneside.cpp b/src/npair_skip_size_off2on_oneside.cpp index eab98de035..30ee2ff6ba 100644 --- a/src/npair_skip_size_off2on_oneside.cpp +++ b/src/npair_skip_size_off2on_oneside.cpp @@ -12,12 +12,12 @@ ------------------------------------------------------------------------- */ #include "npair_skip_size_off2on_oneside.h" -#include "neigh_list.h" + #include "atom.h" -#include "atom_vec.h" #include "domain.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" using namespace LAMMPS_NS; diff --git a/src/output.cpp b/src/output.cpp index 988ef04409..d7be9b8cd6 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -14,18 +14,15 @@ #include "output.h" #include "style_dump.h" // IWYU pragma: keep -#include "atom.h" #include "comm.h" #include "domain.h" #include "dump.h" #include "error.h" -#include "force.h" #include "group.h" #include "info.h" #include "input.h" #include "memory.h" #include "modify.h" -#include "neighbor.h" #include "thermo.h" #include "update.h" #include "variable.h" diff --git a/src/pair_lj96_cut.cpp b/src/pair_lj96_cut.cpp index 65f2d40e00..92cbb47440 100644 --- a/src/pair_lj96_cut.cpp +++ b/src/pair_lj96_cut.cpp @@ -17,20 +17,19 @@ #include "pair_lj96_cut.h" -#include -#include #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" -#include "respa.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "respa.h" +#include "update.h" +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/pair_lj_relres.cpp b/src/pair_lj_relres.cpp index 1f40d03aa9..306b68684e 100644 --- a/src/pair_lj_relres.cpp +++ b/src/pair_lj_relres.cpp @@ -26,7 +26,6 @@ #include "memory.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/reader.cpp b/src/reader.cpp index c22a9f7e5d..ba172f58ee 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -15,8 +15,6 @@ #include "error.h" -#include - using namespace LAMMPS_NS; // only proc 0 calls methods of this class, except for constructor/destructor diff --git a/src/region_sphere.cpp b/src/region_sphere.cpp index 8921cbd456..3a5a51834b 100644 --- a/src/region_sphere.cpp +++ b/src/region_sphere.cpp @@ -19,7 +19,6 @@ #include "variable.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index d26a5199f9..ea8ff2ce43 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -19,7 +19,6 @@ #include "utils.h" #include "fmt/format.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/universe.cpp b/src/universe.cpp index a7fa8fc2e2..79de6948df 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -15,9 +15,7 @@ #include "error.h" #include "memory.h" -#include "version.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/variable.cpp b/src/variable.cpp index d903490219..f66b99d6e5 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -40,7 +40,6 @@ #include #include #include -#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/write_coeff.cpp b/src/write_coeff.cpp index 485bc3b29b..79a99502a6 100644 --- a/src/write_coeff.cpp +++ b/src/write_coeff.cpp @@ -22,7 +22,6 @@ #include "force.h" #include "improper.h" #include "pair.h" -#include "universe.h" #include #include diff --git a/src/write_data.cpp b/src/write_data.cpp index 6d10359e8b..8ec24bb4cf 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -29,7 +29,6 @@ #include "output.h" #include "pair.h" #include "thermo.h" -#include "universe.h" #include "update.h" #include diff --git a/src/write_restart.cpp b/src/write_restart.cpp index afe1d2d528..795e93b05e 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -32,7 +32,6 @@ #include "output.h" #include "pair.h" #include "thermo.h" -#include "universe.h" #include "update.h" #include From b9cb63ae56832ae2c10e102280032bee7f71cbea Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 00:47:58 -0400 Subject: [PATCH 11/24] remove redundant check --- src/pair_hybrid_scaled.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pair_hybrid_scaled.cpp b/src/pair_hybrid_scaled.cpp index 7a30c9a3ee..cdbccbf7c7 100644 --- a/src/pair_hybrid_scaled.cpp +++ b/src/pair_hybrid_scaled.cpp @@ -457,8 +457,6 @@ void PairHybridScaled::coeff(int narg, char **arg) if (multiple[m]) { multflag = 1; if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients"); - if (!isdigit(arg[3][0])) - error->all(FLERR,"Incorrect args for pair coefficients"); int index = utils::inumeric(FLERR,arg[3],false,lmp); if (index == multiple[m]) break; else continue; From bddc6d58201b3ef4618de87732118341a8a34a05 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 09:58:19 -0400 Subject: [PATCH 12/24] make installation procedure consistent with install.py --- python/setup.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/setup.py b/python/setup.py index aff0b14671..2f2b67b6f1 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,7 +1,8 @@ # this only installs the LAMMPS python package # it assumes the LAMMPS shared library is already installed from distutils.core import setup -import os +from sys import version_info +import os,time LAMMPS_PYTHON_DIR = os.path.dirname(os.path.realpath(__file__)) LAMMPS_DIR = os.path.dirname(LAMMPS_PYTHON_DIR) @@ -12,7 +13,13 @@ def get_lammps_version(): line = f.readline() start_pos = line.find('"')+1 end_pos = line.find('"', start_pos) - return "".join(line[start_pos:end_pos].split()) + t = time.strptime("".join(line[start_pos:end_pos].split()), "%d%b%Y") + return "{}.{}.{}".format(t.tm_year,t.tm_mon,t.tm_mday) + +if version_info.major >= 3: + pkgs = ['lammps', 'lammps.mliap'] +else: + pkgs = ['lammps'] setup( name = "lammps", @@ -22,5 +29,5 @@ setup( url = "https://lammps.sandia.gov", description = "LAMMPS Molecular Dynamics Python package", license = "GPL", - packages=["lammps","lammps.mliap"], + packages=pkgs, ) From 82337c8cc574bc454a5ceb4618151fdaf04e24b9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 09:58:41 -0400 Subject: [PATCH 13/24] silence compiler warnings when compiling with python 2 --- src/PYTHON/fix_python_invoke.cpp | 6 ++++-- src/PYTHON/fix_python_move.cpp | 14 +++++++------- src/PYTHON/pair_python.cpp | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/PYTHON/fix_python_invoke.cpp b/src/PYTHON/fix_python_invoke.cpp index 6483e21f91..7d981a749e 100644 --- a/src/PYTHON/fix_python_invoke.cpp +++ b/src/PYTHON/fix_python_invoke.cpp @@ -92,8 +92,9 @@ int FixPythonInvoke::setmask() void FixPythonInvoke::end_of_step() { PyUtils::GIL lock; + char fmt[] = "O"; - PyObject * result = PyObject_CallFunction((PyObject*)pFunc, "O", (PyObject*)lmpPtr); + PyObject * result = PyObject_CallFunction((PyObject*)pFunc, fmt, (PyObject*)lmpPtr); if (!result) { PyUtils::Print_Errors(); @@ -110,8 +111,9 @@ void FixPythonInvoke::post_force(int vflag) if (update->ntimestep % nevery != 0) return; PyUtils::GIL lock; + char fmt[] = "Oi"; - PyObject * result = PyObject_CallFunction((PyObject*)pFunc, "Oi", (PyObject*)lmpPtr, vflag); + PyObject * result = PyObject_CallFunction((PyObject*)pFunc, fmt, (PyObject*)lmpPtr, vflag); if (!result) { PyUtils::Print_Errors(); diff --git a/src/PYTHON/fix_python_move.cpp b/src/PYTHON/fix_python_move.cpp index e04a32afe4..8ec2e1b74d 100644 --- a/src/PYTHON/fix_python_move.cpp +++ b/src/PYTHON/fix_python_move.cpp @@ -75,7 +75,7 @@ FixPythonMove::FixPythonMove(LAMMPS *lmp, int narg, char **arg) : } PyObject *ptr = PY_VOID_POINTER(lmp); - PyObject *py_move_obj = PyObject_CallFunction(py_move_type, "O", ptr); + PyObject *py_move_obj = PyObject_CallFunction(py_move_type, (char *)"O", ptr); Py_CLEAR(ptr); if (!py_move_obj) { @@ -112,7 +112,7 @@ int FixPythonMove::setmask() void FixPythonMove::init() { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject *)py_move, "init", nullptr); + PyObject * result = PyObject_CallMethod((PyObject *)py_move, (char *)"init", nullptr); if (!result) { PyUtils::Print_Errors(); @@ -126,7 +126,7 @@ void FixPythonMove::init() void FixPythonMove::initial_integrate(int vflag) { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "initial_integrate", "i", vflag); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"initial_integrate", (char *)"i", vflag); if (!result) { PyUtils::Print_Errors(); @@ -140,7 +140,7 @@ void FixPythonMove::initial_integrate(int vflag) void FixPythonMove::final_integrate() { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "final_integrate", nullptr); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"final_integrate", nullptr); if (!result) { PyUtils::Print_Errors(); @@ -154,7 +154,7 @@ void FixPythonMove::final_integrate() void FixPythonMove::initial_integrate_respa(int vflag, int ilevel, int iloop) { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "initial_integrate_respa", "iii", vflag, ilevel, iloop); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"initial_integrate_respa", (char *)"iii", vflag, ilevel, iloop); if (!result) { PyUtils::Print_Errors(); @@ -168,7 +168,7 @@ void FixPythonMove::initial_integrate_respa(int vflag, int ilevel, int iloop) void FixPythonMove::final_integrate_respa(int ilevel, int iloop) { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "final_integrate_respa", "ii", ilevel, iloop); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"final_integrate_respa", (char *)"ii", ilevel, iloop); if (!result) { PyUtils::Print_Errors(); @@ -182,7 +182,7 @@ void FixPythonMove::final_integrate_respa(int ilevel, int iloop) void FixPythonMove::reset_dt() { PyUtils::GIL lock; - PyObject * result = PyObject_CallMethod((PyObject*)py_move, "reset_dt", nullptr); + PyObject * result = PyObject_CallMethod((PyObject*)py_move, (char *)"reset_dt", nullptr); if (!result) { PyUtils::Print_Errors(); diff --git a/src/PYTHON/pair_python.cpp b/src/PYTHON/pair_python.cpp index b147c9cb79..5020119e0d 100644 --- a/src/PYTHON/pair_python.cpp +++ b/src/PYTHON/pair_python.cpp @@ -288,7 +288,7 @@ void PairPython::coeff(int narg, char **arg) py_potential = (void *) py_pair_instance; - PyObject *py_value = PyObject_CallMethod(py_pair_instance, "check_units", "s", update->unit_style); + PyObject *py_value = PyObject_CallMethod(py_pair_instance, (char *)"check_units", (char *)"s", update->unit_style); if (!py_value) { PyUtils::Print_Errors(); error->all(FLERR,"Calling 'check_units' function failed"); @@ -306,7 +306,7 @@ void PairPython::coeff(int narg, char **arg) } else skip_types[i] = 0; const int type = i; const char * name = arg[2+i]; - py_value = PyObject_CallMethod(py_pair_instance, "map_coeff", "si", name, type); + py_value = PyObject_CallMethod(py_pair_instance, (char *)"map_coeff", (char *)"si", name, type); if (!py_value) { PyUtils::Print_Errors(); error->all(FLERR,"Calling 'map_coeff' function failed"); From 208d9f1fce3b8cb7c2f3bca4dc93d746c38982ef Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 09:59:15 -0400 Subject: [PATCH 14/24] use safe fread function to silence compiler warnings --- src/pair_lj_relres.cpp | 30 +++++++++++++++--------------- src/pair_morse.cpp | 11 ++++++----- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/pair_lj_relres.cpp b/src/pair_lj_relres.cpp index 306b68684e..2131907f3a 100644 --- a/src/pair_lj_relres.cpp +++ b/src/pair_lj_relres.cpp @@ -607,18 +607,18 @@ void PairLJRelRes::read_restart(FILE *fp) int me = comm->me; for (i = 1; i <= atom->ntypes; i++) for (j = i; j <= atom->ntypes; j++) { - if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,nullptr,error); MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); if (setflag[i][j]) { if (me == 0) { - fread(&epsilonf[i][j],sizeof(double),1,fp); - fread(&sigmaf[i][j],sizeof(double),1,fp); - fread(&epsilon[i][j],sizeof(double),1,fp); - fread(&sigma[i][j],sizeof(double),1,fp); - fread(&cutf_inner[i][j],sizeof(double),1,fp); - fread(&cutf[i][j],sizeof(double),1,fp); - fread(&cut_inner[i][j],sizeof(double),1,fp); - fread(&cut[i][j],sizeof(double),1,fp); + utils::sfread(FLERR,&epsilonf[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&sigmaf[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&epsilon[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&sigma[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cutf_inner[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cutf[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cut_inner[i][j],sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error); } MPI_Bcast(&epsilonf[i][j],1,MPI_DOUBLE,0,world); MPI_Bcast(&sigmaf[i][j],1,MPI_DOUBLE,0,world); @@ -654,12 +654,12 @@ void PairLJRelRes::read_restart_settings(FILE *fp) { int me = comm->me; if (me == 0) { - fread(&cutf_inner_global,sizeof(double),1,fp); - fread(&cutf_global,sizeof(double),1,fp); - fread(&cut_inner_global,sizeof(double),1,fp); - fread(&cut_global,sizeof(double),1,fp); - fread(&offset_flag,sizeof(int),1,fp); - fread(&mix_flag,sizeof(int),1,fp); + utils::sfread(FLERR,&cutf_inner_global,sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cutf_global,sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cut_inner_global,sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error); + utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,nullptr,error); + utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,nullptr,error); } MPI_Bcast(&cutf_inner_global,1,MPI_DOUBLE,0,world); MPI_Bcast(&cutf_global,1,MPI_DOUBLE,0,world); diff --git a/src/pair_morse.cpp b/src/pair_morse.cpp index 6c67a8ef55..e6d924dab6 100644 --- a/src/pair_morse.cpp +++ b/src/pair_morse.cpp @@ -13,14 +13,15 @@ #include "pair_morse.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 using namespace LAMMPS_NS; From 3b2c0871ccc766a4e66174880f4524c86079d435 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 14:53:03 -0400 Subject: [PATCH 15/24] add and use Neighbor::modify_params() convenience function --- src/MC/fix_charge_regulation.cpp | 9 +-------- src/MC/fix_gcmc.cpp | 9 +-------- src/MC/fix_widom.cpp | 9 +-------- src/USER-MISC/fix_srp.cpp | 12 +----------- src/neighbor.cpp | 16 ++++++++++++++++ src/neighbor.h | 1 + 6 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/MC/fix_charge_regulation.cpp b/src/MC/fix_charge_regulation.cpp index 6775b4e4ca..17d3af3e34 100644 --- a/src/MC/fix_charge_regulation.cpp +++ b/src/MC/fix_charge_regulation.cpp @@ -187,14 +187,7 @@ void FixChargeRegulation::init() { // neighbor list exclusion setup // turn off interactions between group all and the exclusion group - int narg = 4; - char **arg = new char*[narg];; - arg[0] = (char *) "exclude"; - arg[1] = (char *) "group"; - arg[2] = (char *) group_id.c_str(); - arg[3] = (char *) "all"; - neighbor->modify_params(narg,arg); - delete [] arg; + neighbor->modify_params(fmt::format("exclude group {} all",group_id)); } // check that no deletable atoms are in atom->firstgroup diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index b946615b04..ff894d976b 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -580,14 +580,7 @@ void FixGCMC::init() // neighbor list exclusion setup // turn off interactions between group all and the exclusion group - int narg = 4; - char **arg = new char*[narg];; - arg[0] = (char *) "exclude"; - arg[1] = (char *) "group"; - arg[2] = (char *) group_id.c_str(); - arg[3] = (char *) "all"; - neighbor->modify_params(narg,arg); - delete [] arg; + neighbor->modify_params(fmt::format("exclude group {} all",group_id); } // create a new group for temporary use with selected molecules diff --git a/src/MC/fix_widom.cpp b/src/MC/fix_widom.cpp index e898196e14..65f00811c1 100644 --- a/src/MC/fix_widom.cpp +++ b/src/MC/fix_widom.cpp @@ -342,14 +342,7 @@ void FixWidom::init() // neighbor list exclusion setup // turn off interactions between group all and the exclusion group - int narg = 4; - char **arg = new char*[narg];; - arg[0] = (char *) "exclude"; - arg[1] = (char *) "group"; - arg[2] = (char *) group_id.c_str(); - arg[3] = (char *) "all"; - neighbor->modify_params(narg,arg); - delete [] arg; + neighbor->modify_params(fmt::format("exclude group {} all",group_id)); } // create a new group for temporary use with selected molecules diff --git a/src/USER-MISC/fix_srp.cpp b/src/USER-MISC/fix_srp.cpp index eb57da30e9..51047dfaa6 100644 --- a/src/USER-MISC/fix_srp.cpp +++ b/src/USER-MISC/fix_srp.cpp @@ -128,20 +128,10 @@ void FixSRP::init() // bond particles do not interact with other types // type bptype only interacts with itself - char* arg1[4]; - arg1[0] = (char *) "exclude"; - arg1[1] = (char *) "type"; - char c0[20]; - char c1[20]; - for (int z = 1; z < atom->ntypes; z++) { if (z == bptype) continue; - sprintf(c0, "%d", z); - arg1[2] = c0; - sprintf(c1, "%d", bptype); - arg1[3] = c1; - neighbor->modify_params(4, arg1); + neighbor->modify_params(fmt::format("exclude type {} {}",z,bptype)); } } diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 704d94c77c..ee4226f43e 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -2356,6 +2356,22 @@ void Neighbor::modify_params(int narg, char **arg) } } +/* ---------------------------------------------------------------------- + convenience function to allow modifying parameters from a single string +------------------------------------------------------------------------- */ + +void Neighbor::modify_params(const std::string &modcmd) +{ + auto args = utils::split_words(modcmd); + char **newarg = new char*[args.size()]; + int i=0; + for (const auto &arg : args) { + newarg[i++] = (char *)arg.c_str(); + } + modify_params(args.size(),newarg); + delete[] newarg; +} + /* ---------------------------------------------------------------------- remove the first group-group exclusion matching group1, group2 ------------------------------------------------------------------------- */ diff --git a/src/neighbor.h b/src/neighbor.h index b9b40bcf1a..0babfae9ef 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -118,6 +118,7 @@ class Neighbor : protected Pointers { void set(int, char **); // set neighbor style and skin distance void reset_timestep(bigint); // reset of timestep counter void modify_params(int, char**); // modify params that control builds + void modify_params(const std::string &); // convenience overload void exclusion_group_group_delete(int, int); // rm a group-group exclusion int exclude_setting(); // return exclude value to accelerator pkg From 533739b1287e04e431ddca4966a6d547763b80e8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 14:53:51 -0400 Subject: [PATCH 16/24] avoid NULL pointer dereference / slience warnings issued by static code analysis --- src/MC/fix_charge_regulation.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/MC/fix_charge_regulation.cpp b/src/MC/fix_charge_regulation.cpp index 17d3af3e34..4e7e5ab5a0 100644 --- a/src/MC/fix_charge_regulation.cpp +++ b/src/MC/fix_charge_regulation.cpp @@ -349,7 +349,7 @@ void FixChargeRegulation::forward_acid() { double energy_before = energy_stored; double factor; - double *dummyp = nullptr; + double dummyp[3]; double pos[3]; pos[0] = 0; pos[1] = 0; @@ -408,7 +408,7 @@ void FixChargeRegulation::backward_acid() { double energy_before = energy_stored; double factor; int mask_tmp; - double *dummyp = nullptr; + double dummyp[3]; double pos[3]; pos[0] = 0; pos[1] = 0; @@ -481,7 +481,7 @@ void FixChargeRegulation::forward_base() { double energy_before = energy_stored; double factor; - double *dummyp = nullptr; + double dummyp[3]; double pos[3]; pos[0] = 0; pos[1] = 0; @@ -539,7 +539,7 @@ void FixChargeRegulation::backward_base() { double energy_before = energy_stored; double factor; - double *dummyp = nullptr; + double dummyp[3]; int mask_tmp; double pos[3]; pos[0] = 0; @@ -612,7 +612,7 @@ void FixChargeRegulation::forward_ions() { double energy_before = energy_stored; double factor; - double *dummyp = nullptr; + double dummyp[3]; int m1 = -1, m2 = -1; factor = volume_rx * volume_rx * c10pI_plus * c10pI_minus / ((1 + ncation) * (1 + nanion)); @@ -647,7 +647,7 @@ void FixChargeRegulation::backward_ions() { double energy_before = energy_stored; double factor; int mask1_tmp = 0, mask2_tmp = 0; - double *dummyp = nullptr; + double dummyp[3]; int m1 = -1, m2 = -1; m1 = get_random_particle(cation_type, +1, 0, dummyp); @@ -726,7 +726,7 @@ void FixChargeRegulation::forward_ions_multival() { double energy_before = energy_stored; double factor = 1; - double *dummyp = nullptr; + double dummyp[3]; int mm[salt_charge_ratio + 1];// particle ID array for all ions to be inserted if (salt_charge[0] <= -salt_charge[1]) { @@ -780,7 +780,7 @@ void FixChargeRegulation::backward_ions_multival() { double energy_before = energy_stored; double factor = 1; - double *dummyp = nullptr; // dummy pointer + double dummyp[3]; // dummy particle int mm[salt_charge_ratio + 1]; // particle ID array for all deleted ions double qq[salt_charge_ratio + 1]; // charge array for all deleted ions int mask_tmp[salt_charge_ratio + 1]; // temporary mask array From 680e6a389dac748000bf9a8e53a20b4e14cae26a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 14:54:04 -0400 Subject: [PATCH 17/24] use type cast consistently --- src/PYTHON/fix_python_invoke.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PYTHON/fix_python_invoke.cpp b/src/PYTHON/fix_python_invoke.cpp index 7d981a749e..82baef909b 100644 --- a/src/PYTHON/fix_python_invoke.cpp +++ b/src/PYTHON/fix_python_invoke.cpp @@ -92,9 +92,8 @@ int FixPythonInvoke::setmask() void FixPythonInvoke::end_of_step() { PyUtils::GIL lock; - char fmt[] = "O"; - PyObject * result = PyObject_CallFunction((PyObject*)pFunc, fmt, (PyObject*)lmpPtr); + PyObject * result = PyObject_CallFunction((PyObject*)pFunc, (char *)"O", (PyObject*)lmpPtr); if (!result) { PyUtils::Print_Errors(); From 9dbdb4386b6e74f020c594218fa4a175e056dd54 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 14:54:47 -0400 Subject: [PATCH 18/24] fix typo --- src/MC/fix_gcmc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index ff894d976b..3ab6327404 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -580,7 +580,7 @@ void FixGCMC::init() // neighbor list exclusion setup // turn off interactions between group all and the exclusion group - neighbor->modify_params(fmt::format("exclude group {} all",group_id); + neighbor->modify_params(fmt::format("exclude group {} all",group_id)); } // create a new group for temporary use with selected molecules From 8aed7e55b37752e574116e40d7210d63a99b4d32 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Apr 2021 14:59:37 -0400 Subject: [PATCH 19/24] add error check when updating variables in ::single() function --- src/pair_hybrid_scaled.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pair_hybrid_scaled.cpp b/src/pair_hybrid_scaled.cpp index cdbccbf7c7..de8801fe24 100644 --- a/src/pair_hybrid_scaled.cpp +++ b/src/pair_hybrid_scaled.cpp @@ -396,6 +396,9 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, double *vals = new double[nvars]; for (i = 0; i < nvars; ++i) { j = input->variable->find(scalevars[i].c_str()); + if (j < 0) + error->all(FLERR,fmt::format("Variable '{}' not found when updating " + "scale factors",scalevars[i])); vals[i] = input->variable->compute_equal(j); } for (i = 0; i < nstyles; ++i) { From d5661e06ae266dee138e432f732922ab91b1b37e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 14 Apr 2021 20:00:38 -0400 Subject: [PATCH 20/24] Detect linux distribution and version --- cmake/Modules/LAMMPSUtils.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index acaef19498..41dcfc5b2f 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -104,3 +104,13 @@ function(FetchPotentials pkgfolder potfolder) endforeach() endif() endfunction(FetchPotentials) + +# set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux +if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (EXISTS /etc/os-release)) + file(STRINGS /etc/os-release distro REGEX "^NAME=") + string(REGEX REPLACE "NAME=\"?([^\"]*)\"?" "\\1" distro "${distro}") + file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=") + string(REGEX REPLACE "VERSION_ID=\"?([^\"]*)\"?" "\\1" disversion "${disversion}") + set(CMAKE_LINUX_DISTRO ${distro}) + set(CMAKE_DISTRO_VERSION ${disversion}) +endif() From 2a81411029c6410d4e979c9f3ac5b27d6f795d70 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 14 Apr 2021 20:01:46 -0400 Subject: [PATCH 21/24] use linux distro and version info to decide when to look for faster linkers --- cmake/CMakeLists.txt | 2 +- cmake/Modules/Testing.cmake | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index a11c7575d2..263b5a566d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -731,7 +731,7 @@ get_target_property(DEFINES lammps COMPILE_DEFINITIONS) include(FeatureSummary) feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND) message(STATUS "<<< Build configuration >>> - Operating System: ${CMAKE_SYSTEM_NAME} + Operating System: ${CMAKE_SYSTEM_NAME} ${CMAKE_LINUX_DISTRO} ${CMAKE_DISTRO_VERSION} Build type: ${CMAKE_BUILD_TYPE} Install path: ${CMAKE_INSTALL_PREFIX} Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}") diff --git a/cmake/Modules/Testing.cmake b/cmake/Modules/Testing.cmake index 6d2f39b0f3..7fbd8212de 100644 --- a/cmake/Modules/Testing.cmake +++ b/cmake/Modules/Testing.cmake @@ -16,11 +16,14 @@ if(ENABLE_TESTING) set(MEMORYCHECK_COMMAND "${VALGRIND_BINARY}" CACHE FILEPATH "Memory Check Command") set(MEMORYCHECK_COMMAND_OPTIONS "${VALGRIND_DEFAULT_OPTIONS}" CACHE STRING "Memory Check Command Options") - # check if a faster linker is available. - # only verified with GNU and Clang compilers and new CMake - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) - if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) + # we need to build and link a LOT of tester executables, so it is worth checking if + # a faster linker is available. requires GNU or Clang compiler, newer CMake. + # also only verified with Fedora Linux > 30 and Ubuntu <= 18.04 (Ubuntu 20.04 fails) + if((CMAKE_SYSTEM_NAME STREQUAL Linux) AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + AND ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))) + if (((CMAKE_LINUX_DISTRO STREQUAL Ubuntu) AND (CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04)) + OR ((CMAKE_LINUX_DISTRO STREQUAL Fedora) AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30))) include(CheckCXXCompilerFlag) set(CMAKE_CUSTOM_LINKER_DEFAULT default) check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG) From 6e739c04e43951596a6a13a4b8db374e03026e96 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 14 Apr 2021 20:02:05 -0400 Subject: [PATCH 22/24] use safe fread() call --- src/read_restart.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 9e8fbce91c..d3fecd9d80 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -1195,7 +1195,7 @@ void ReadRestart::check_eof_magic() if (me == 0) { long curpos = ftell(fp); fseek(fp,(long)-n,SEEK_END); - fread(str,sizeof(char),n,fp); + utils::sfread(FLERR,str,sizeof(char),n,fp,nullptr,error); fseek(fp,curpos,SEEK_SET); } From 0870a560939079644892c9ff2e650e2a45339243 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 15 Apr 2021 11:57:48 -0400 Subject: [PATCH 23/24] expand exception message to include cause of file open failure --- src/potential_file_reader.cpp | 3 ++- src/text_file_reader.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/potential_file_reader.cpp b/src/potential_file_reader.cpp index 2730a3d109..bddfca9bce 100644 --- a/src/potential_file_reader.cpp +++ b/src/potential_file_reader.cpp @@ -62,7 +62,8 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp, try { reader = open_potential(filename); if (!reader) { - error->one(FLERR, fmt::format("cannot open {} potential file {}", potential_name, filename)); + error->one(FLERR, fmt::format("cannot open {} potential file {}: {}", + potential_name, filename, utils::getsyserror())); } } catch (FileReaderException &e) { error->one(FLERR, e.what()); diff --git a/src/text_file_reader.cpp b/src/text_file_reader.cpp index af27bfb16d..7a6e914639 100644 --- a/src/text_file_reader.cpp +++ b/src/text_file_reader.cpp @@ -46,7 +46,8 @@ TextFileReader::TextFileReader(const std::string &filename, const std::string &f fp = fopen(filename.c_str(), "r"); if (fp == nullptr) { - throw FileReaderException(fmt::format("cannot open {} file {}", filetype, filename)); + throw FileReaderException(fmt::format("cannot open {} file {}: {}", + filetype, filename, utils::getsyserror())); } } From 7a97331e510aa53635a5b469deceb445e785c99a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 16 Apr 2021 12:38:00 -0400 Subject: [PATCH 24/24] add support for Plumed2 version 2.5.7, 2.6.3, 2.7.1 --- cmake/Modules/Packages/USER-PLUMED.cmake | 5 +++-- lib/plumed/Install.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/USER-PLUMED.cmake index 8719e8179d..e71542cfc5 100644 --- a/cmake/Modules/Packages/USER-PLUMED.cmake +++ b/cmake/Modules/Packages/USER-PLUMED.cmake @@ -54,8 +54,9 @@ if(DOWNLOAD_PLUMED) set(PLUMED_BUILD_BYPRODUCTS "/lib/libplumedWrapper.a") endif() - set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.7.0/plumed-src-2.7.0.tgz" CACHE STRING "URL for PLUMED tarball") - set(PLUMED_MD5 "95f29dd0c067577f11972ff90dfc7d12" CACHE STRING "MD5 checksum of PLUMED tarball") + set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.7.1/plumed-src-2.7.1.tgz" CACHE STRING "URL for PLUMED tarball") + set(PLUMED_MD5 "4eac6a462ec84dfe0cec96c82421b8e8" CACHE STRING "MD5 checksum of PLUMED tarball") + mark_as_advanced(PLUMED_URL) mark_as_advanced(PLUMED_MD5) diff --git a/lib/plumed/Install.py b/lib/plumed/Install.py index c11d5bfee9..e3858b39d3 100644 --- a/lib/plumed/Install.py +++ b/lib/plumed/Install.py @@ -17,7 +17,7 @@ parser = ArgumentParser(prog='Install.py', # settings -version = "2.7.0" +version = "2.7.1" mode = "static" # help message @@ -47,9 +47,12 @@ checksums = { \ '2.5.2' : 'bd2f18346c788eb54e1e52f4f6acf41a', \ '2.5.3' : 'de30d6e7c2dcc0973298e24a6da24286', \ '2.5.4' : 'f31b7d16a4be2e30aa7d5c19c3d37853', \ + '2.5.7' : '1ca36226fdb8110b1009aa61d615d4e5', \ '2.6.0' : '204d2edae58d9b10ba3ad460cad64191', \ '2.6.1' : '89a9a450fc6025299fe16af235957163', \ + '2.6.3' : 'a9f8028fd74528c2024781ea1fdefeee', \ '2.7.0' : '95f29dd0c067577f11972ff90dfc7d12', \ + '2.7.1' : '4eac6a462ec84dfe0cec96c82421b8e8', \ } # parse and process arguments