From a986f035d6042f319db97767e3bd127b51e044a7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Nov 2022 16:10:12 -0500 Subject: [PATCH 01/19] update list of functions and add list of flags for pair styles --- doc/src/Modify_pair.rst | 132 +++++++++++++++++++++++++++++++++------- 1 file changed, 109 insertions(+), 23 deletions(-) diff --git a/doc/src/Modify_pair.rst b/doc/src/Modify_pair.rst index 6913204504..38f5ade567 100644 --- a/doc/src/Modify_pair.rst +++ b/doc/src/Modify_pair.rst @@ -1,35 +1,121 @@ Pair styles =========== -Classes that compute pairwise interactions are derived from the Pair -class. In LAMMPS, pairwise calculation include many-body potentials -such as EAM or Tersoff where particles interact without a static bond -topology. New styles can be created to add new pair potentials to -LAMMPS. +Classes that compute pairwise non-bonded interactions are derived from +the Pair class. In LAMMPS, pairwise calculation include many-body +potentials such as EAM, Tersoff, or ReaxFF where particles interact +without an explicit bond topology but include interactions beyond +pairwise non-bonded contributions. New styles can be created to add +support for additional pair potentials to LAMMPS. When the +modifications are small, sometimes it is more effective to derive from +an existing pair style class. This latter approach is also used by +:doc:`Accelerator packages ` where the accelerated style +names differ from their base classes by an appended suffix. -Pair_lj_cut.cpp is a simple example of a Pair class, though it -includes some optional methods to enable its use with rRESPA. +The file ``src/pair_lj_cut.cpp`` is an example of a Pair class with a +very simple potential function. It includes several optional methods to +enable its use with :doc:`run_style respa ` and :doc:`compute +group/group `. -Here is a brief description of the class methods in pair.h: +Here is a brief list of some the class methods in the Pair class that +*must* be or *may* be overridden in a derived class. +---------------------------------+---------------------------------------------------------------------+ +| Required | "pure" methods that *must* be overridden in a derived class | ++=================================+=====================================================================+ | compute | workhorse routine that computes pairwise interactions | +---------------------------------+---------------------------------------------------------------------+ -| settings | reads the input script line with arguments you define | +| settings | processes the arguments to the pair_style command | +---------------------------------+---------------------------------------------------------------------+ -| coeff | set coefficients for one i,j type pair | -+---------------------------------+---------------------------------------------------------------------+ -| init_one | perform initialization for one i,j type pair | -+---------------------------------+---------------------------------------------------------------------+ -| init_style | initialization specific to this pair style | -+---------------------------------+---------------------------------------------------------------------+ -| write & read_restart | write/read i,j pair coeffs to restart files | -+---------------------------------+---------------------------------------------------------------------+ -| write & read_restart_settings | write/read global settings to restart files | -+---------------------------------+---------------------------------------------------------------------+ -| single | force/r and energy of a single pairwise interaction between 2 atoms | -+---------------------------------+---------------------------------------------------------------------+ -| compute_inner/middle/outer | versions of compute used by rRESPA | +| coeff | set coefficients for one i,j type pair, called from pair_coeff | +---------------------------------+---------------------------------------------------------------------+ -The inner/middle/outer routines are optional. ++---------------------------------+----------------------------------------------------------------------+ +| Optional | methods that have a default or dummy implementation | ++=================================+======================================================================+ +| init_one | perform initialization for one i,j type pair | ++---------------------------------+----------------------------------------------------------------------+ +| init_style | style initialization: request neighbor list(s), error checks | ++---------------------------------+----------------------------------------------------------------------+ +| init_list | Neighbor class callback function to pass neighbor list to pair style | ++---------------------------------+----------------------------------------------------------------------+ +| single | force/r and energy of a single pairwise interaction between 2 atoms | ++---------------------------------+----------------------------------------------------------------------+ +| compute_inner/middle/outer | versions of compute used by rRESPA | ++---------------------------------+----------------------------------------------------------------------+ +| memory_usage | return estimated amount of memory used by the pair style | ++---------------------------------+----------------------------------------------------------------------+ +| modify_params | process arguments to pair_modify command | ++---------------------------------+----------------------------------------------------------------------+ +| extract | provide access to internal scalar or per-type data like cutoffs | ++---------------------------------+----------------------------------------------------------------------+ +| extract_peratom | provide access to internal per-atom data | ++---------------------------------+----------------------------------------------------------------------+ +| setup | initialization at the beginning of a run | ++---------------------------------+----------------------------------------------------------------------+ +| finish | called at the end of a run, e.g. to print | ++---------------------------------+----------------------------------------------------------------------+ +| write & read_restart | write/read i,j pair coeffs to restart files | ++---------------------------------+----------------------------------------------------------------------+ +| write & read_restart_settings | write/read global settings to restart files | ++---------------------------------+----------------------------------------------------------------------+ +| write_data | write Pair Coeffs section to data file | ++---------------------------------+----------------------------------------------------------------------+ +| write_data_all | write PairIJ Coeffs section to data file | ++---------------------------------+----------------------------------------------------------------------+ +| pack & unpack_forward_comm | copy data to and from buffer if style uses forward communication | ++---------------------------------+----------------------------------------------------------------------+ +| pack & unpack_reverse_comm | copy data to and from buffer if style uses reverse communication | ++---------------------------------+----------------------------------------------------------------------+ +| reinit | reset all type-based parameters, called by fix adapt for example | ++---------------------------------+----------------------------------------------------------------------+ +| reset_dt | called when the time step is changed by timestep or fix reset/dt | ++---------------------------------+----------------------------------------------------------------------+ + +Here is a list of flags or settings that should be set in the +constructor of the derived pair class when they differ from the default +setting. + ++---------------------------------+-------------------------------------------------------------+---------+ +| Name of flag | Description | default | ++=================================+=============================================================+=========+ +| single_enable | 1 if single() method is implemented, 0 if missing | 1 | ++---------------------------------+-------------------------------------------------------------+---------+ +| respa_enable | 1 if pair style has compute_inner/middle/outer() | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| restartinfo | 1 if pair style writes its settings to a restart | 1 | ++---------------------------------+-------------------------------------------------------------+---------+ +| one_coeff | 1 if only a pair_coeff * * command is allowed | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| manybody_flag | 1 if pair style is a manybody potential | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| unit_convert_flag | value != 0 indicates support for unit conversion | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| no_virial_fdotr_compute | 1 if pair style does not call virial_fdotr_compute() | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| writedata | 1 if write_data() and write_data_all() are implemented | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| comm_forward | size of buffer (in doubles) for forward communication | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| comm_reverse | size of buffer (in doubles) for reverse communication | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| ghostneigh | 1 if cutghost is set and style uses neighbors of ghosts | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| finitecutflag | 1 if cutoff depends on diameter of atoms | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| reinitflag | 1 if style has reinit() and is compatible with fix adapt | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| ewaldflag | 1 if compatible with kspace_style ewald | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| pppmflag | 1 if compatible with kspace_style pppm | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| msmflag | 1 if compatible with kspace_style msm | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| dispersionflag | 1 if compatible with ewald/disp or pppm/disp | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| tip4pflag | 1 if compatible with kspace_style pppm/tip4p | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| dipoleflag | 1 if compatible with dipole kspace_style | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ +| spinflag | 1 if compatible with spin kspace_style | 0 | ++---------------------------------+-------------------------------------------------------------+---------+ From a3e7106f31708909fa1da0404150cb4514973ead Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 7 Nov 2022 23:52:23 -0500 Subject: [PATCH 02/19] expand docs for bond/angle/dihedral/improper styles --- doc/src/Modify_bond.rst | 83 ++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 21 deletions(-) diff --git a/doc/src/Modify_bond.rst b/doc/src/Modify_bond.rst index 682237b8bd..58b08de81b 100644 --- a/doc/src/Modify_bond.rst +++ b/doc/src/Modify_bond.rst @@ -13,24 +13,65 @@ Here is a brief description of common methods you define in your new derived class. See bond.h, angle.h, dihedral.h, and improper.h for details and specific additional methods. -+-----------------------+---------------------------------------------------------------------------------------+ -| init | check if all coefficients are set, calls *init_style* (optional) | -+-----------------------+---------------------------------------------------------------------------------------+ -| init_style | check if style specific conditions are met (optional) | -+-----------------------+---------------------------------------------------------------------------------------+ -| compute | compute the molecular interactions (required) | -+-----------------------+---------------------------------------------------------------------------------------+ -| settings | apply global settings for all types (optional) | -+-----------------------+---------------------------------------------------------------------------------------+ -| coeff | set coefficients for one type (required) | -+-----------------------+---------------------------------------------------------------------------------------+ -| equilibrium_distance | length of bond, used by SHAKE (required, bond only) | -+-----------------------+---------------------------------------------------------------------------------------+ -| equilibrium_angle | opening of angle, used by SHAKE (required, angle only) | -+-----------------------+---------------------------------------------------------------------------------------+ -| write & read_restart | writes/reads coeffs to restart files (required) | -+-----------------------+---------------------------------------------------------------------------------------+ -| single | force (bond only) and energy of a single bond or angle (required, bond or angle only) | -+-----------------------+---------------------------------------------------------------------------------------+ -| memory_usage | tally memory allocated by the style (optional) | -+-----------------------+---------------------------------------------------------------------------------------+ ++-----------------------+---------------------------------------------------------------------+ +| Required | "pure" methods that *must* be overridden in a derived class | ++=======================+=====================================================================+ +| compute | compute the molecular interactions for all listed items | ++-----------------------+---------------------------------------------------------------------+ +| coeff | set coefficients for one type | ++-----------------------+---------------------------------------------------------------------+ +| equilibrium_distance | length of bond, used by SHAKE (bond styles only) | ++-----------------------+---------------------------------------------------------------------+ +| equilibrium_angle | opening of angle, used by SHAKE (angle styles only) | ++-----------------------+---------------------------------------------------------------------+ +| write & read_restart | writes/reads coeffs to restart files | ++-----------------------+---------------------------------------------------------------------+ +| single | force/r (bond styles only) and energy of a single bond or angle | ++-----------------------+---------------------------------------------------------------------+ + + ++--------------------------------+----------------------------------------------------------------------+ +| Optional | methods that have a default or dummy implementation | ++================================+======================================================================+ +| init | check if all coefficients are set, calls init_style() | ++--------------------------------+----------------------------------------------------------------------+ +| init_style | check if style specific conditions are met | ++--------------------------------+----------------------------------------------------------------------+ +| settings | apply global settings for all types | ++--------------------------------+----------------------------------------------------------------------+ +| write & read_restart_settings | writes/reads global style settings to restart files | ++--------------------------------+----------------------------------------------------------------------+ +| write_data | write corresponding Coeffs section(s) in data file | ++--------------------------------+----------------------------------------------------------------------+ +| memory_usage | tally memory allocated by the style | ++--------------------------------+----------------------------------------------------------------------+ +| extract | provide access to internal data (bond or angle styles only) | ++--------------------------------+----------------------------------------------------------------------+ +| reinit | reset all type-based parameters, called by fix adapt (bonds only) | ++--------------------------------+----------------------------------------------------------------------+ +| pack & unpack_forward_comm | copy data to and from buffer in forward communication (bonds only) | ++--------------------------------+----------------------------------------------------------------------+ +| pack & unpack_reverse_comm | copy data to and from buffer in reverse communication (bonds only) | ++--------------------------------+----------------------------------------------------------------------+ + +Here is a list of flags or settings that should be set in the +constructor of the derived class when they differ from the default +setting. + ++---------------------------------+------------------------------------------------------------------------------+---------+ +| Name of flag | Description | default | ++=================================+==============================================================================+=========+ +| writedata | 1 if write_data() is implemented | 1 | ++---------------------------------+------------------------------------------------------------------------------+---------+ +| single_extra | number of extra single values calculated (bond styles only) | 0 | ++---------------------------------+------------------------------------------------------------------------------+---------+ +| partial_flag | 1 if bond type can be set to 0 and deleted (bond styles only) | 0 | ++---------------------------------+------------------------------------------------------------------------------+---------+ +| reinitflag | 1 if style has reinit() and is compatible with fix adapt | 1 | ++---------------------------------+------------------------------------------------------------------------------+---------+ +| comm_forward | size of buffer (in doubles) for forward communication (bond styles only) | 0 | ++---------------------------------+------------------------------------------------------------------------------+---------+ +| comm_reverse | size of buffer (in doubles) for reverse communication (bond styles only) | 0 | ++---------------------------------+------------------------------------------------------------------------------+---------+ +| comm_reverse_off | size of buffer for reverse communication with newton off (bond styles only) | 0 | ++---------------------------------+------------------------------------------------------------------------------+---------+ From 2db1a74ba72239e0d8b4a17adc04dccdf5a894d1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Nov 2022 14:13:11 -0500 Subject: [PATCH 03/19] update false positives list --- doc/utils/sphinx-config/false_positives.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 9e8fb042a0..1a1845ff21 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -608,6 +608,7 @@ curv Cusentino customIDs cutbond +cutghost cuthi cutinner cutlo @@ -749,6 +750,7 @@ dimensionality dimensioned dimgray dipolar +dipoleflag dir Direc dirname @@ -757,6 +759,7 @@ discretization discretized discretizing disp +dispersionflag dissipative Dissipative distharm @@ -1022,6 +1025,7 @@ evirials ew ewald Ewald +ewaldflag excitations excv exe @@ -1094,6 +1098,7 @@ Fincham Fint fingerprintconstants fingerprintsperelement +finitecutflag Finnis Fiorin fixID @@ -2198,6 +2203,7 @@ msd msi MSI msm +msmflag msse msst Mtchell @@ -2773,6 +2779,7 @@ PowerShell ppme ppn pppm +pppmflag Prakash Praprotnik prd @@ -2952,6 +2959,7 @@ refactoring reflectionstyle Reinders reinit +reinitflag relaxbox relink relres @@ -3285,6 +3293,7 @@ SPH spica SPICA Spickermann +spinflag splined spparks Sprik @@ -3837,6 +3846,7 @@ workflows Workum Worley Wriggers +writedata Wuppertal Wurtzite www From 6fe8b84c23c3b86a141c82cd77d27f7a5f47d273 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 30 Nov 2022 19:31:00 -0500 Subject: [PATCH 04/19] correct updating Makefile.package.setting edits, fix a few broken ones. --- src/ADIOS/Install.sh | 4 ++-- src/ATC/Install.sh | 4 ++-- src/AWPMD/Install.sh | 4 ++-- src/COLVARS/Install.sh | 4 ++-- src/COMPRESS/Install.sh | 4 ++-- src/ELECTRODE/Install.sh | 8 ++++---- src/GPU/Install.sh | 4 ++-- src/H5MD/Install.sh | 4 ++-- src/KIM/Install.sh | 4 ++-- src/KOKKOS/Install.sh | 4 ++-- src/LATTE/Install.sh | 4 ++-- src/MACHDYN/Install.sh | 4 ++-- src/MDI/Install.sh | 4 ++-- src/MESONT/Install.sh | 4 ++-- src/ML-HDNNP/Install.sh | 4 ++-- src/ML-IAP/Install.sh | 8 ++++---- src/ML-PACE/Install.sh | 4 ++-- src/ML-QUIP/Install.sh | 4 ++-- src/MOLFILE/Install.sh | 4 ++-- src/MSCG/Install.sh | 4 ++-- src/Makefile | 2 +- src/NETCDF/Install.sh | 4 ++-- src/PLUGIN/Install.sh | 4 ++-- src/PLUMED/Install.sh | 4 ++-- src/POEMS/Install.sh | 4 ++-- src/PYTHON/Install.sh | 4 ++-- src/QMMM/Install.sh | 4 ++-- src/VORONOI/Install.sh | 4 ++-- src/VTK/Install.sh | 4 ++-- 29 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/ADIOS/Install.sh b/src/ADIOS/Install.sh index bd0acb1414..0ee2c5428e 100644 --- a/src/ADIOS/Install.sh +++ b/src/ADIOS/Install.sh @@ -69,7 +69,7 @@ adios_SYSLIB=${ADIOS2_LIB} fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*ADIOS.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*ADIOS.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ../ADIOS/Makefile.lammps @@ -85,7 +85,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*ADIOS.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*ADIOS.*$/d' ../Makefile.package.settings fi rm -f Makefile.lammps diff --git a/src/ATC/Install.sh b/src/ATC/Install.sh index e1dacdd7d6..2194685f92 100755 --- a/src/ATC/Install.sh +++ b/src/ATC/Install.sh @@ -60,7 +60,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*atc.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*atc.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/atc\/Makefile.lammps @@ -74,7 +74,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*atc.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*atc.*$/d' ../Makefile.package.settings fi fi diff --git a/src/AWPMD/Install.sh b/src/AWPMD/Install.sh index 70e87c3fbc..0e2e2d3473 100755 --- a/src/AWPMD/Install.sh +++ b/src/AWPMD/Install.sh @@ -46,7 +46,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*awpmd.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*awpmd.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/awpmd\/Makefile.lammps @@ -60,7 +60,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*awpmd.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*awpmd.*$/d' ../Makefile.package.settings fi fi diff --git a/src/COLVARS/Install.sh b/src/COLVARS/Install.sh index d67883a416..ebabfd7a1e 100755 --- a/src/COLVARS/Install.sh +++ b/src/COLVARS/Install.sh @@ -47,7 +47,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*colvars.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*colvars.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/colvars\/Makefile.lammps @@ -62,7 +62,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*colvars.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*colvars.*$/d' ../Makefile.package.settings fi fi diff --git a/src/COMPRESS/Install.sh b/src/COMPRESS/Install.sh index ab9dac33dc..c0d926cba4 100755 --- a/src/COMPRESS/Install.sh +++ b/src/COMPRESS/Install.sh @@ -44,7 +44,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*compress.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*compress.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/compress\/Makefile.lammps @@ -58,7 +58,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*compress.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*compress.*$/d' ../Makefile.package.settings fi fi diff --git a/src/ELECTRODE/Install.sh b/src/ELECTRODE/Install.sh index 65d0b404da..561df0dce0 100755 --- a/src/ELECTRODE/Install.sh +++ b/src/ELECTRODE/Install.sh @@ -49,11 +49,11 @@ if (test $1 = 1) then sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(electrode_SYSLIB) |' ../Makefile.package fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*electrode.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*electrode.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ - include ..\/..\/lib\/electrode\/Makefile.lammps - ' ../Makefile.package.settings +include ..\/..\/lib\/electrode\/Makefile.lammps +' ../Makefile.package.settings fi elif (test $1 = 0) then @@ -61,7 +61,7 @@ elif (test $1 = 0) then sed -i -e 's/[^ \t]*electrode[^ \t]* //g' ../Makefile.package fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*electrode.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*electrode.*$/d' ../Makefile.package.settings fi fi diff --git a/src/GPU/Install.sh b/src/GPU/Install.sh index 1768ec024f..d28e6260f8 100755 --- a/src/GPU/Install.sh +++ b/src/GPU/Install.sh @@ -176,7 +176,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*gpu.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*gpu.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/gpu\/Makefile.lammps @@ -191,7 +191,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*gpu.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*gpu.*$/d' ../Makefile.package.settings fi fi diff --git a/src/H5MD/Install.sh b/src/H5MD/Install.sh index 1070afaa96..ee442d80bc 100755 --- a/src/H5MD/Install.sh +++ b/src/H5MD/Install.sh @@ -45,7 +45,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*h5md.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*h5md.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/h5md\/Makefile.lammps @@ -60,7 +60,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*h5md.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*h5md.*$/d' ../Makefile.package.settings fi fi diff --git a/src/KIM/Install.sh b/src/KIM/Install.sh index 7ddb9c8227..533f4f997a 100755 --- a/src/KIM/Install.sh +++ b/src/KIM/Install.sh @@ -44,7 +44,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*kim.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*kim.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/kim\/Makefile.lammps @@ -58,7 +58,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*kim.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*kim.*$/d' ../Makefile.package.settings fi fi diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index 063ea44720..5c46a89e26 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -374,7 +374,7 @@ if (test $1 = 1) then if (test -e ../Makefile.package.settings) then sed -i -e '/CXX\ =\ \$(CC)/d' ../Makefile.package.settings - sed -i -e '/^include.*kokkos.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*kokkos.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ CXX = $(CC) @@ -401,7 +401,7 @@ elif (test $1 = 0) then if (test -e ../Makefile.package.settings) then sed -i -e '/CXX\ =\ \$(CC)/d' ../Makefile.package.settings - sed -i -e '/^include.*kokkos.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*kokkos.*$/d' ../Makefile.package.settings fi fi diff --git a/src/LATTE/Install.sh b/src/LATTE/Install.sh index 73f8bc24cb..4d895ca434 100755 --- a/src/LATTE/Install.sh +++ b/src/LATTE/Install.sh @@ -47,7 +47,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*latte.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*latte.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/latte\/Makefile.lammps @@ -61,7 +61,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*latte.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*latte.*$/d' ../Makefile.package.settings fi fi diff --git a/src/MACHDYN/Install.sh b/src/MACHDYN/Install.sh index bf18c332f3..604f53f8b1 100755 --- a/src/MACHDYN/Install.sh +++ b/src/MACHDYN/Install.sh @@ -45,7 +45,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*machdyn.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*machdyn.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/machdyn\/Makefile.lammps @@ -59,7 +59,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*machdyn.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*machdyn.*$/d' ../Makefile.package.settings fi fi diff --git a/src/MDI/Install.sh b/src/MDI/Install.sh index bc19162a17..804e66be5e 100755 --- a/src/MDI/Install.sh +++ b/src/MDI/Install.sh @@ -49,7 +49,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*mdi.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*mdi.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/mdi\/Makefile.lammps @@ -65,7 +65,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*mdi.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*mdi.*$/d' ../Makefile.package.settings fi fi diff --git a/src/MESONT/Install.sh b/src/MESONT/Install.sh index 6e51bfae64..09e6c03dde 100644 --- a/src/MESONT/Install.sh +++ b/src/MESONT/Install.sh @@ -47,7 +47,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*mesont.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*mesont.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/mesont\/Makefile.lammps @@ -61,7 +61,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*mesont.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*mesont.*$/d' ../Makefile.package.settings fi fi diff --git a/src/ML-HDNNP/Install.sh b/src/ML-HDNNP/Install.sh index 74e5f1b91e..f343f38851 100644 --- a/src/ML-HDNNP/Install.sh +++ b/src/ML-HDNNP/Install.sh @@ -46,7 +46,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*hdnnp.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*hdnnp.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/hdnnp\/Makefile.lammps @@ -60,7 +60,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*hdnnp.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*hdnnp.*$/d' ../Makefile.package.settings fi fi diff --git a/src/ML-IAP/Install.sh b/src/ML-IAP/Install.sh index 27c9b19b01..18812c6026 100755 --- a/src/ML-IAP/Install.sh +++ b/src/ML-IAP/Install.sh @@ -52,7 +52,7 @@ if (test $1 = 1) then sed -i -e 's|^PKG_INC =[ \t]*|&-DMLIAP_PYTHON |' ../Makefile.package fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*python.*mliap_python.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/python\/Makefile.mliap_python @@ -68,7 +68,7 @@ elif (test $1 = 0) then fi rm -f ../mliap_model_python_couple.cpp ../mliap_model_python_couple.h \ ../mliap_unified_couple.cpp ../mliap_unified_couple.h - sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*python.*mliap_python.*$/d' ../Makefile.package.settings elif (test $1 = 2) then if (type cythonize > /dev/null 2>&1 && test -e ../python_impl.cpp) then @@ -77,12 +77,12 @@ elif (test $1 = 2) then fi rm -f ../mliap_model_python_couple.cpp ../mliap_model_python_couple.h \ ../mliap_unified_couple.cpp ../mliap_unified_couple.h - sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*python.*mliap_python.*$/d' ../Makefile.package.settings if (test -e ../Makefile.package) then sed -i -e 's|^PKG_INC =[ \t]*|&-DMLIAP_PYTHON |' ../Makefile.package fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*python.*mliap_python.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*python.*mliap_python.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/python\/Makefile.mliap_python diff --git a/src/ML-PACE/Install.sh b/src/ML-PACE/Install.sh index c099ddd2c4..c0a0958424 100644 --- a/src/ML-PACE/Install.sh +++ b/src/ML-PACE/Install.sh @@ -44,7 +44,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*pace.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*pace.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/pace\/Makefile.lammps @@ -58,7 +58,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*pace.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*pace.*$/d' ../Makefile.package.settings fi fi diff --git a/src/ML-QUIP/Install.sh b/src/ML-QUIP/Install.sh index 20174e664a..03f93c14b8 100755 --- a/src/ML-QUIP/Install.sh +++ b/src/ML-QUIP/Install.sh @@ -44,7 +44,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*quip.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*quip.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/quip\/Makefile.lammps\ @@ -58,7 +58,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*quip.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*quip.*$/d' ../Makefile.package.settings fi fi diff --git a/src/MOLFILE/Install.sh b/src/MOLFILE/Install.sh index 85885f66b9..3ae4357ade 100755 --- a/src/MOLFILE/Install.sh +++ b/src/MOLFILE/Install.sh @@ -44,7 +44,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*molfile.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*molfile.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/molfile\/Makefile.lammps @@ -58,7 +58,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*molfile.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*molfile.*$/d' ../Makefile.package.settings fi fi diff --git a/src/MSCG/Install.sh b/src/MSCG/Install.sh index 353403c7da..67f0f837ce 100755 --- a/src/MSCG/Install.sh +++ b/src/MSCG/Install.sh @@ -43,7 +43,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*mscg.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*mscg.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/mscg\/Makefile.lammps @@ -57,7 +57,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*mscg.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*mscg.*$/d' ../Makefile.package.settings fi fi diff --git a/src/Makefile b/src/Makefile index 923cc535fd..39937c58d6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -55,7 +55,7 @@ PACKAGE = \ awpmd \ bocs \ body \ - bpm \ + bpm \ brownian \ cg-dna \ cg-spica \ diff --git a/src/NETCDF/Install.sh b/src/NETCDF/Install.sh index 4d21f0f894..8c70d84fd8 100755 --- a/src/NETCDF/Install.sh +++ b/src/NETCDF/Install.sh @@ -42,7 +42,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*netcdf.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*netcdf.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/netcdf\/Makefile.lammps @@ -57,7 +57,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*netcdf.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*netcdf.*$/d' ../Makefile.package.settings fi fi diff --git a/src/PLUGIN/Install.sh b/src/PLUGIN/Install.sh index 0df642193e..86de36d7df 100755 --- a/src/PLUGIN/Install.sh +++ b/src/PLUGIN/Install.sh @@ -44,7 +44,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*plugin.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*plugin.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/plugin\/Makefile.lammps @@ -58,7 +58,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*plugin.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*plugin.*$/d' ../Makefile.package.settings fi fi diff --git a/src/PLUMED/Install.sh b/src/PLUMED/Install.sh index f879d42feb..500a55ec77 100755 --- a/src/PLUMED/Install.sh +++ b/src/PLUMED/Install.sh @@ -45,7 +45,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*plumed.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*plumed.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/plumed\/Makefile.lammps @@ -59,7 +59,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*plumed.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*plumed.*$/d' ../Makefile.package.settings fi fi diff --git a/src/POEMS/Install.sh b/src/POEMS/Install.sh index be407d76f0..37f8404738 100755 --- a/src/POEMS/Install.sh +++ b/src/POEMS/Install.sh @@ -44,7 +44,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*poems.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*poems.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/poems\/Makefile.lammps @@ -58,7 +58,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*poems.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*poems.*$/d' ../Makefile.package.settings fi fi diff --git a/src/PYTHON/Install.sh b/src/PYTHON/Install.sh index 8c394d43ad..b23cf574f8 100755 --- a/src/PYTHON/Install.sh +++ b/src/PYTHON/Install.sh @@ -50,7 +50,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*python.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*python.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/python\/Makefile.lammps @@ -65,7 +65,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*python.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*python.*$/d' ../Makefile.package.settings fi fi diff --git a/src/QMMM/Install.sh b/src/QMMM/Install.sh index 4bede66d80..0c9643b84e 100755 --- a/src/QMMM/Install.sh +++ b/src/QMMM/Install.sh @@ -47,7 +47,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*qmmm.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*qmmm.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/qmmm\/Makefile.lammps @@ -62,7 +62,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*qmmm.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*qmmm.*$/d' ../Makefile.package.settings fi fi diff --git a/src/VORONOI/Install.sh b/src/VORONOI/Install.sh index 6373506b19..c7f897e5e6 100755 --- a/src/VORONOI/Install.sh +++ b/src/VORONOI/Install.sh @@ -48,7 +48,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*voronoi.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*voronoi.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/voronoi\/Makefile.lammps @@ -63,7 +63,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*voronoi.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*voronoi.*$/d' ../Makefile.package.settings fi fi diff --git a/src/VTK/Install.sh b/src/VTK/Install.sh index 3749242fb2..fda4287d51 100755 --- a/src/VTK/Install.sh +++ b/src/VTK/Install.sh @@ -43,7 +43,7 @@ if (test $1 = 1) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*vtk.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*vtk.*$/d' ../Makefile.package.settings # multiline form needed for BSD sed on Macs sed -i -e '4 i \ include ..\/..\/lib\/vtk\/Makefile.lammps @@ -58,7 +58,7 @@ elif (test $1 = 0) then fi if (test -e ../Makefile.package.settings) then - sed -i -e '/^include.*vtk.*$/d' ../Makefile.package.settings + sed -i -e '/^[ \t]*include.*vtk.*$/d' ../Makefile.package.settings fi fi From 1eb489236e6c6d232046b146a8148f461675db11 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 2 Dec 2022 14:35:21 -0500 Subject: [PATCH 05/19] make certain binlo/binhi are initialized --- src/reset_atoms_id.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/reset_atoms_id.cpp b/src/reset_atoms_id.cpp index 26685f1972..c0fce95326 100644 --- a/src/reset_atoms_id.cpp +++ b/src/reset_atoms_id.cpp @@ -43,7 +43,9 @@ static int compare_coords(const int, const int, void *); /* ---------------------------------------------------------------------- */ -ResetAtomsID::ResetAtomsID(LAMMPS *lmp) : Command(lmp) {} +ResetAtomsID::ResetAtomsID(LAMMPS *lmp) : Command(lmp) { + binlo = binhi = -1; +} /* ---------------------------------------------------------------------- */ @@ -480,6 +482,9 @@ int ResetAtomsID::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char bigint binlo = rptr->binlo; bigint binhi = rptr->binhi; + if ((binlo < 0) || (binhi < 0)) + error->one(FLERR, "Called sort_bins without previous setup of bins"); + // nbins = my subset of bins from binlo to binhi-1 // initialize linked lists of my Rvous atoms in each bin From dac55cf64d64944fb339da0fd4cdfe4ecfd28176 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 3 Dec 2022 20:45:52 -0500 Subject: [PATCH 06/19] avoid segfault on short data read when parsing tabulated potentials --- src/MOLECULE/angle_table.cpp | 3 +++ src/MOLECULE/bond_table.cpp | 3 +++ src/MOLECULE/dihedral_table.cpp | 3 +++ src/pair_table.cpp | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/MOLECULE/angle_table.cpp b/src/MOLECULE/angle_table.cpp index 4a89591612..03027700a6 100644 --- a/src/MOLECULE/angle_table.cpp +++ b/src/MOLECULE/angle_table.cpp @@ -405,6 +405,9 @@ void AngleTable::read_table(Table *tb, char *file, char *keyword) reader.skip_line(); for (int i = 0; i < tb->ninput; i++) { line = reader.next_line(); + if (!line) + error->one(FLERR, "Data missing when parsing angle table '{}' line {} of {}.", keyword, i + 1, + tb->ninput); try { ValueTokenizer values(line); values.next_int(); diff --git a/src/MOLECULE/bond_table.cpp b/src/MOLECULE/bond_table.cpp index 0b9cde32e1..5978d63561 100644 --- a/src/MOLECULE/bond_table.cpp +++ b/src/MOLECULE/bond_table.cpp @@ -330,6 +330,9 @@ void BondTable::read_table(Table *tb, char *file, char *keyword) reader.skip_line(); for (int i = 0; i < tb->ninput; i++) { line = reader.next_line(); + if (!line) + error->one(FLERR, "Data missing when parsing bond table '{}' line {} of {}.", keyword, i + 1, + tb->ninput); try { ValueTokenizer values(line); values.next_int(); diff --git a/src/MOLECULE/dihedral_table.cpp b/src/MOLECULE/dihedral_table.cpp index 4ad2a57a46..070d0a6972 100644 --- a/src/MOLECULE/dihedral_table.cpp +++ b/src/MOLECULE/dihedral_table.cpp @@ -1021,6 +1021,9 @@ void DihedralTable::read_table(Table *tb, char *file, char *keyword) for (int i = 0; i < tb->ninput; i++) { line = reader.next_line(); + if (!line) + error->one(FLERR, "Data missing when parsing dihedral table '{}' line {} of {}.", + keyword, i + 1, tb->ninput); try { ValueTokenizer values(line); if (tb->f_unspecified) { diff --git a/src/pair_table.cpp b/src/pair_table.cpp index e8a7530d6b..3e293cb414 100644 --- a/src/pair_table.cpp +++ b/src/pair_table.cpp @@ -398,6 +398,9 @@ void PairTable::read_table(Table *tb, char *file, char *keyword) reader.skip_line(); for (int i = 0; i < tb->ninput; i++) { line = reader.next_line(); + if (!line) + error->one(FLERR, "Data missing when parsing pair table '{}' line {} of {}.", keyword, i + 1, + tb->ninput); try { ValueTokenizer values(line); values.next_int(); From 1cde202079e75638e173321b3e8d31bf21d0b341 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 4 Dec 2022 04:24:10 -0500 Subject: [PATCH 07/19] test for coul/slater/long requires KSpace style ewald from KSPACE package --- unittest/force-styles/tests/mol-pair-coul_slater_long.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/unittest/force-styles/tests/mol-pair-coul_slater_long.yaml b/unittest/force-styles/tests/mol-pair-coul_slater_long.yaml index 52efdaa52d..ba11503a2c 100644 --- a/unittest/force-styles/tests/mol-pair-coul_slater_long.yaml +++ b/unittest/force-styles/tests/mol-pair-coul_slater_long.yaml @@ -6,6 +6,7 @@ skip_tests: prerequisites: ! | atom full pair coul/slater/long + kspace ewald pre_commands: ! "" post_commands: ! | pair_modify mix arithmetic From e67bec6b2fbdfd13e3111c0033864dda4e4f9d22 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 4 Dec 2022 16:59:17 -0500 Subject: [PATCH 08/19] use consistent pygments language tags --- doc/src/Developer_code_design.rst | 6 ++--- doc/src/Developer_notes.rst | 16 +++++------ doc/src/Developer_plugins.rst | 6 ++--- doc/src/Developer_unittest.rst | 4 +-- doc/src/Developer_updating.rst | 44 +++++++++++++++---------------- doc/src/Developer_utils.rst | 10 +++---- doc/src/Developer_write.rst | 14 +++++----- doc/src/Howto_pylammps.rst | 38 +++++++++++++------------- doc/src/Howto_structured_data.rst | 2 +- doc/src/Library_config.rst | 2 +- doc/src/Library_create.rst | 2 +- doc/src/Library_execute.rst | 2 +- doc/src/Library_properties.rst | 2 +- doc/src/Python_atoms.rst | 4 +-- doc/src/Python_config.rst | 2 +- doc/src/Python_create.rst | 6 ++--- doc/src/Python_error.rst | 2 +- doc/src/Python_execute.rst | 8 +++--- doc/src/Python_launch.rst | 2 +- doc/src/Python_objects.rst | 6 ++--- doc/src/Python_properties.rst | 2 +- doc/src/Python_scatter.rst | 4 +-- 22 files changed, 92 insertions(+), 92 deletions(-) diff --git a/doc/src/Developer_code_design.rst b/doc/src/Developer_code_design.rst index a5c879de82..786bd51c26 100644 --- a/doc/src/Developer_code_design.rst +++ b/doc/src/Developer_code_design.rst @@ -50,7 +50,7 @@ parallel each MPI process creates such an instance. This can be seen in the ``main.cpp`` file where the core steps of running a LAMMPS simulation are the following 3 lines of code: -.. code-block:: C++ +.. code-block:: c++ LAMMPS *lammps = new LAMMPS(argc, argv, lammps_comm); lammps->input->file(); @@ -232,7 +232,7 @@ macro ``PairStyle()`` will associate the style name "lj/cut" with a factory function creating an instance of the ``PairLJCut`` class. -.. code-block:: C++ +.. code-block:: c++ // from force.h typedef Pair *(*PairCreator)(LAMMPS *); @@ -360,7 +360,7 @@ characters; "{:<8}" would do this as left aligned, "{:^8}" as centered, argument type must be compatible or else the {fmt} formatting code will throw an exception. Some format string examples are given below: -.. code-block:: C +.. code-block:: c++ auto mesg = fmt::format(" CPU time: {:4d}:{:02d}:{:02d}\n", cpuh, cpum, cpus); mesg = fmt::format("{:<8s}| {:<10.5g} | {:<10.5g} | {:<10.5g} |{:6.1f} |{:6.2f}\n", diff --git a/doc/src/Developer_notes.rst b/doc/src/Developer_notes.rst index 2b3375265f..a781737d6f 100644 --- a/doc/src/Developer_notes.rst +++ b/doc/src/Developer_notes.rst @@ -105,7 +105,7 @@ list, where each pair of atoms is listed only once (except when the pairs straddling sub-domains or periodic boundaries will be listed twice). Thus these are the default settings when a neighbor list request is created in: -.. code-block:: C++ +.. code-block:: c++ void Pair::init_style() { @@ -129,7 +129,7 @@ neighbor list request to the specific needs of a style an additional request flag is needed. The :doc:`tersoff ` pair style, for example, needs a "full" neighbor list: -.. code-block:: C++ +.. code-block:: c++ void PairTersoff::init_style() { @@ -141,7 +141,7 @@ When a pair style supports r-RESPA time integration with different cutoff region the request flag may depend on the corresponding r-RESPA settings. Here an example from pair style lj/cut: -.. code-block:: C++ +.. code-block:: c++ void PairLJCut::init_style() { @@ -160,7 +160,7 @@ Granular pair styles need neighbor lists based on particle sizes and not cutoff and also may require to have the list of previous neighbors available ("history"). For example with: -.. code-block:: C++ +.. code-block:: c++ if (use_history) neighbor->add_request(this, NeighConst::REQ_SIZE | NeighConst::REQ_HISTORY); else neighbor->add_request(this, NeighConst::REQ_SIZE); @@ -170,7 +170,7 @@ settings each request can set an id which is then used in the corresponding ``init_list()`` function to assign it to the suitable pointer variable. This is done for example by the :doc:`pair style meam `: -.. code-block:: C++ +.. code-block:: c++ void PairMEAM::init_style() { @@ -189,7 +189,7 @@ just once) and this can also be indicated by a flag. As an example here is the request from the ``FixPeriNeigh`` class which is created internally by :doc:`Peridynamics pair styles `: -.. code-block:: C++ +.. code-block:: c++ neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); @@ -198,7 +198,7 @@ than what is usually inferred from the pair style settings (largest cutoff of all pair styles plus neighbor list skin). The following is used in the :doc:`compute rdf ` command implementation: -.. code-block:: C++ +.. code-block:: c++ if (cutflag) neighbor->add_request(this, NeighConst::REQ_OCCASIONAL)->set_cutoff(mycutneigh); @@ -212,7 +212,7 @@ for printing the neighbor list summary the name of the requesting command should be set. Below is the request from the :doc:`delete atoms ` command: -.. code-block:: C++ +.. code-block:: c++ neighbor->add_request(this, "delete_atoms", NeighConst::REQ_FULL); diff --git a/doc/src/Developer_plugins.rst b/doc/src/Developer_plugins.rst index 36fdd010b3..dd5431507e 100644 --- a/doc/src/Developer_plugins.rst +++ b/doc/src/Developer_plugins.rst @@ -95,7 +95,7 @@ a class ``PairMorse2`` in the files ``pair_morse2.h`` and ``pair_morse2.cpp`` with the factory function and initialization function would look like this: -.. code-block:: C++ +.. code-block:: c++ #include "lammpsplugin.h" #include "version.h" @@ -141,7 +141,7 @@ list of argument strings), then the pointer type is ``lammpsplugin_factory2`` and it must be assigned to the *creator.v2* member of the plugin struct. Below is an example for that: -.. code-block:: C++ +.. code-block:: c++ #include "lammpsplugin.h" #include "version.h" @@ -176,7 +176,7 @@ demonstrated in the following example, which also shows that the implementation of the plugin class may be within the same source file as the plugin interface code: -.. code-block:: C++ +.. code-block:: c++ #include "lammpsplugin.h" diff --git a/doc/src/Developer_unittest.rst b/doc/src/Developer_unittest.rst index aff6128e9c..69e29263a6 100644 --- a/doc/src/Developer_unittest.rst +++ b/doc/src/Developer_unittest.rst @@ -194,7 +194,7 @@ macro. These tests operate by capturing the screen output when executing the failing command and then comparing that with a provided regular expression string pattern. Example: -.. code-block:: C++ +.. code-block:: c++ TEST_F(SimpleCommandsTest, UnknownCommand) { @@ -249,7 +249,7 @@ MPI support. These include tests where LAMMPS is run in multi-partition mode or only on a subset of the MPI world communicator. The CMake script code for adding this kind of test looks like this: -.. code-block:: CMake +.. code-block:: cmake if (BUILD_MPI) add_executable(test_library_mpi test_library_mpi.cpp) diff --git a/doc/src/Developer_updating.rst b/doc/src/Developer_updating.rst index 90a138d2cf..c02d6763de 100644 --- a/doc/src/Developer_updating.rst +++ b/doc/src/Developer_updating.rst @@ -61,7 +61,7 @@ header file needs to be updated accordingly. Old: -.. code-block:: C++ +.. code-block:: c++ int PairEAM::pack_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) { @@ -75,7 +75,7 @@ Old: New: -.. code-block:: C++ +.. code-block:: c++ int PairEAM::pack_forward_comm(int n, int *list, double *buf, int pbc_flag, int *pbc) { @@ -112,14 +112,14 @@ Example from a pair style: Old: -.. code-block:: C++ +.. code-block:: c++ if (eflag || vflag) ev_setup(eflag, vflag); else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; New: -.. code-block:: C++ +.. code-block:: c++ ev_init(eflag, vflag); @@ -142,14 +142,14 @@ when they are called from only one or a subset of the MPI processes. Old: -.. code-block:: C++ +.. code-block:: c++ val = force->numeric(FLERR, arg[1]); num = force->inumeric(FLERR, arg[2]); New: -.. code-block:: C++ +.. code-block:: c++ val = utils::numeric(FLERR, true, arg[1], lmp); num = utils::inumeric(FLERR, false, arg[2], lmp); @@ -183,14 +183,14 @@ copy them around for simulations. Old: -.. code-block:: C++ +.. code-block:: c++ fp = force->open_potential(filename); fp = fopen(filename, "r"); New: -.. code-block:: C++ +.. code-block:: c++ fp = utils::open_potential(filename, lmp); @@ -207,7 +207,7 @@ Example: Old: -.. code-block:: C++ +.. code-block:: c++ if (fptr == NULL) { char str[128]; @@ -217,7 +217,7 @@ Old: New: -.. code-block:: C++ +.. code-block:: c++ if (fptr == nullptr) error->one(FLERR, "Cannot open AEAM potential file {}: {}", filename, utils::getsyserror()); @@ -237,7 +237,7 @@ an example from the ``FixWallReflect`` class: Old: -.. code-block:: C++ +.. code-block:: c++ FixWallReflect(class LAMMPS *, int, char **); virtual ~FixWallReflect(); @@ -247,7 +247,7 @@ Old: New: -.. code-block:: C++ +.. code-block:: c++ FixWallReflect(class LAMMPS *, int, char **); ~FixWallReflect() override; @@ -271,7 +271,7 @@ the type of the "this" pointer argument. Old: -.. code-block:: C++ +.. code-block:: c++ comm->forward_comm_pair(this); comm->forward_comm_fix(this); @@ -284,7 +284,7 @@ Old: New: -.. code-block:: C++ +.. code-block:: c++ comm->forward_comm(this); comm->reverse_comm(this); @@ -304,7 +304,7 @@ requests can be :doc:`found here `. Example from the Old: -.. code-block:: C++ +.. code-block:: c++ int irequest = neighbor->request(this,instance_me); neighbor->requests[irequest]->pair = 0; @@ -317,7 +317,7 @@ Old: New: -.. code-block:: C++ +.. code-block:: c++ auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); if (cutflag) req->set_cutoff(mycutneigh); @@ -340,7 +340,7 @@ these are internal fixes, there is no user visible change. Old: -.. code-block:: C++ +.. code-block:: c++ #include "fix_store.h" @@ -351,7 +351,7 @@ Old: New: -.. code-block:: C++ +.. code-block:: c++ #include "fix_store_peratom.h" @@ -362,7 +362,7 @@ New: Old: -.. code-block:: C++ +.. code-block:: c++ #include "fix_store.h" @@ -373,7 +373,7 @@ Old: New: -.. code-block:: C++ +.. code-block:: c++ #include "fix_store_global.h" @@ -396,7 +396,7 @@ the dump directly. Example: Old: -.. code-block:: C++ +.. code-block:: c++ int idump = output->find_dump(arg[iarg+1]); if (idump < 0) @@ -412,7 +412,7 @@ Old: New: -.. code-block:: C++ +.. code-block:: c++ auto idump = output->get_dump_by_id(arg[iarg+1]); if (!idump) error->all(FLERR,"Dump ID {} in hyper command does not exist", arg[iarg+1]); diff --git a/doc/src/Developer_utils.rst b/doc/src/Developer_utils.rst index b92d817d87..7c44ccfe56 100644 --- a/doc/src/Developer_utils.rst +++ b/doc/src/Developer_utils.rst @@ -317,7 +317,7 @@ are all "whitespace" characters, i.e. the space character, the tabulator character, the carriage return character, the linefeed character, and the form feed character. -.. code-block:: C++ +.. code-block:: c++ :caption: Tokenizer class example listing entries of the PATH environment variable #include "tokenizer.h" @@ -349,7 +349,7 @@ tokenizer into a ``try`` / ``catch`` block to handle errors. The when a (type of) number is requested as next token that is not compatible with the string representing the next word. -.. code-block:: C++ +.. code-block:: c++ :caption: ValueTokenizer class example with exception handling #include "tokenizer.h" @@ -427,7 +427,7 @@ one or two array indices "[]" with numbers > 0. A typical code segment would look like this: -.. code-block:: C++ +.. code-block:: c++ :caption: Usage example for ArgInfo class int nvalues = 0; @@ -476,7 +476,7 @@ open the file, and will call the :cpp:class:`LAMMPS_NS::Error` class in case of failures to read or to convert numbers, so that LAMMPS will be aborted. -.. code-block:: C++ +.. code-block:: c++ :caption: Use of PotentialFileReader class in pair style coul/streitz PotentialFileReader reader(lmp, file, "coul/streitz"); @@ -555,7 +555,7 @@ chunk size needs to be known in advance, 2) with :cpp:func:`MyPage::vget() its size is registered later with :cpp:func:`MyPage::vgot() `. -.. code-block:: C++ +.. code-block:: c++ :caption: Example of using :cpp:class:`MyPage ` #include "my_page.h" diff --git a/doc/src/Developer_write.rst b/doc/src/Developer_write.rst index bdc6559060..c374ec2e77 100644 --- a/doc/src/Developer_write.rst +++ b/doc/src/Developer_write.rst @@ -26,7 +26,7 @@ constructor with the signature: ``FixPrintVel(class LAMMPS *, int, char **)``. Every fix must be registered in LAMMPS by writing the following lines of code in the header before include guards: -.. code-block:: c +.. code-block:: c++ #ifdef FIX_CLASS // clang-format off @@ -47,7 +47,7 @@ keyword when it parses the input script. Let's write a simple fix which will print the average velocity at the end of each timestep. First of all, implement a constructor: -.. code-block:: C++ +.. code-block:: c++ FixPrintVel::FixPrintVel(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) @@ -72,7 +72,7 @@ in the Fix class called ``nevery`` which specifies how often the method The next method we need to implement is ``setmask()``: -.. code-block:: C++ +.. code-block:: c++ int FixPrintVel::setmask() { @@ -87,7 +87,7 @@ during execution. The constant ``END_OF_STEP`` corresponds to the are called during a timestep and the order in which they are called are shown in the previous section. -.. code-block:: C++ +.. code-block:: c++ void FixPrintVel::end_of_step() { @@ -143,7 +143,7 @@ The group membership information of an atom is contained in the *mask* property of and atom and the bit corresponding to a given group is stored in the groupbit variable which is defined in Fix base class: -.. code-block:: C++ +.. code-block:: c++ for (int i = 0; i < nlocal; ++i) { if (atom->mask[i] & groupbit) { @@ -174,7 +174,7 @@ to store positions of atoms from previous timestep, we need to add ``double** xold`` to the header file. Than add allocation code to the constructor: -.. code-block:: C++ +.. code-block:: c++ FixSavePos::FixSavePos(LAMMPS *lmp, int narg, char **arg), xold(nullptr) { @@ -190,7 +190,7 @@ to the constructor: Implement the aforementioned methods: -.. code-block:: C++ +.. code-block:: c++ double FixSavePos::memory_usage() { diff --git a/doc/src/Howto_pylammps.rst b/doc/src/Howto_pylammps.rst index 6c788e2365..a182d4a050 100644 --- a/doc/src/Howto_pylammps.rst +++ b/doc/src/Howto_pylammps.rst @@ -152,14 +152,14 @@ Creating a new instance of PyLammps To create a PyLammps object you need to first import the class from the lammps module. By using the default constructor, a new *lammps* instance is created. -.. code-block:: Python +.. code-block:: python from lammps import PyLammps L = PyLammps() You can also initialize PyLammps on top of this existing *lammps* object: -.. code-block:: Python +.. code-block:: python from lammps import lammps, PyLammps lmp = lammps() @@ -180,14 +180,14 @@ For instance, let's take the following LAMMPS command: In the original interface this command can be executed with the following Python code if *L* was a lammps instance: -.. code-block:: Python +.. code-block:: python L.command("region box block 0 10 0 5 -0.5 0.5") With the PyLammps interface, any command can be split up into arbitrary parts separated by white-space, passed as individual arguments to a region method. -.. code-block:: Python +.. code-block:: python L.region("box block", 0, 10, 0, 5, -0.5, 0.5) @@ -199,14 +199,14 @@ The benefit of this approach is avoiding redundant command calls and easier parameterization. In the original interface parameterization needed to be done manually by creating formatted strings. -.. code-block:: Python +.. code-block:: python L.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi)) In contrast, methods of PyLammps accept parameters directly and will convert them automatically to a final command string. -.. code-block:: Python +.. code-block:: python L.region("box block", xlo, xhi, ylo, yhi, zlo, zhi) @@ -256,7 +256,7 @@ LAMMPS variables can be both defined and accessed via the PyLammps interface. To define a variable you can use the :doc:`variable ` command: -.. code-block:: Python +.. code-block:: python L.variable("a index 2") @@ -265,14 +265,14 @@ A dictionary of all variables is returned by L.variables you can access an individual variable by retrieving a variable object from the L.variables dictionary by name -.. code-block:: Python +.. code-block:: python a = L.variables['a'] The variable value can then be easily read and written by accessing the value property of this object. -.. code-block:: Python +.. code-block:: python print(a.value) a.value = 4 @@ -284,7 +284,7 @@ LAMMPS expressions can be immediately evaluated by using the eval method. The passed string parameter can be any expression containing global thermo values, variables, compute or fix data. -.. code-block:: Python +.. code-block:: python result = L.eval("ke") # kinetic energy result = L.eval("pe") # potential energy @@ -298,7 +298,7 @@ All atoms in the current simulation can be accessed by using the L.atoms list. Each element of this list is an object which exposes its properties (id, type, position, velocity, force, etc.). -.. code-block:: Python +.. code-block:: python # access first atom L.atoms[0].id @@ -311,7 +311,7 @@ position, velocity, force, etc.). Some properties can also be used to set: -.. code-block:: Python +.. code-block:: python # set position in 2D simulation L.atoms[0].position = (1.0, 0.0) @@ -328,7 +328,7 @@ after a run via the L.runs list. This list contains a growing list of run data. The first element is the output of the first run, the second element that of the second run. -.. code-block:: Python +.. code-block:: python L.run(1000) L.runs[0] # data of first 1000 time steps @@ -339,14 +339,14 @@ the second run. Each run contains a dictionary of all trajectories. Each trajectory is accessible through its thermo name: -.. code-block:: Python +.. code-block:: python L.runs[0].thermo.Step # list of time steps in first run L.runs[0].thermo.Ke # list of kinetic energy values in first run Together with matplotlib plotting data out of LAMMPS becomes simple: -.. code-block:: Python +.. code-block:: python import matplotlib.plot as plt steps = L.runs[0].thermo.Step @@ -406,7 +406,7 @@ Four atoms are placed in the simulation and the dihedral potential is applied on them using a datafile. Then one of the atoms is rotated along the central axis by setting its position from Python, which changes the dihedral angle. -.. code-block:: Python +.. code-block:: python phi = [d \* math.pi / 180 for d in range(360)] @@ -439,7 +439,7 @@ Initially, a 2D system is created in a state with minimal energy. It is then disordered by moving each atom by a random delta. -.. code-block:: Python +.. code-block:: python random.seed(27848) deltaperturb = 0.2 @@ -458,7 +458,7 @@ It is then disordered by moving each atom by a random delta. Finally, the Monte Carlo algorithm is implemented in Python. It continuously moves random atoms by a random delta and only accepts certain moves. -.. code-block:: Python +.. code-block:: python estart = L.eval("pe") elast = estart @@ -517,7 +517,7 @@ PyLammps can be run in parallel using mpi4py. This python package can be install The following is a short example which reads in an existing LAMMPS input file and executes it in parallel. You can find in.melt in the examples/melt folder. -.. code-block:: Python +.. code-block:: python from mpi4py import MPI from lammps import PyLammps diff --git a/doc/src/Howto_structured_data.rst b/doc/src/Howto_structured_data.rst index 18a5dfd775..3fe630a120 100644 --- a/doc/src/Howto_structured_data.rst +++ b/doc/src/Howto_structured_data.rst @@ -43,7 +43,7 @@ JSON "ke": $(ke) }""" file current_state.json screen no -.. code-block:: JSON +.. code-block:: json :caption: current_state.json { diff --git a/doc/src/Library_config.rst b/doc/src/Library_config.rst index 04b12f35de..481edcee7c 100644 --- a/doc/src/Library_config.rst +++ b/doc/src/Library_config.rst @@ -39,7 +39,7 @@ crashes within LAMMPS may be recovered from by enabling :ref:`exceptions `, avoiding them proactively is a safer approach. -.. code-block:: C +.. code-block:: c :caption: Example for using configuration settings functions #include "library.h" diff --git a/doc/src/Library_create.rst b/doc/src/Library_create.rst index 8ccc2e80ce..546db9b3be 100644 --- a/doc/src/Library_create.rst +++ b/doc/src/Library_create.rst @@ -22,7 +22,7 @@ as the "handle" argument in subsequent function calls until that instance is destroyed by calling :cpp:func:`lammps_close`. Here is a simple example demonstrating its use: -.. code-block:: C +.. code-block:: c #include "library.h" #include diff --git a/doc/src/Library_execute.rst b/doc/src/Library_execute.rst index 201d9c01b0..44b601ba4c 100644 --- a/doc/src/Library_execute.rst +++ b/doc/src/Library_execute.rst @@ -30,7 +30,7 @@ be included in the file or strings, and expansion of variables with ``${name}`` or ``$(expression)`` syntax is performed. Below is a short example using some of these functions. -.. code-block:: C +.. code-block:: c /* define to make the otherwise hidden prototype for "lammps_open()" visible */ #define LAMMPS_LIB_MPI diff --git a/doc/src/Library_properties.rst b/doc/src/Library_properties.rst index dfd72adc95..b3a8f9ea5a 100644 --- a/doc/src/Library_properties.rst +++ b/doc/src/Library_properties.rst @@ -32,7 +32,7 @@ indexed accordingly. Per-atom data can change sizes and ordering at every neighbor list rebuild or atom sort event as atoms migrate between sub-domains and processors. -.. code-block:: C +.. code-block:: c #include "library.h" #include diff --git a/doc/src/Python_atoms.rst b/doc/src/Python_atoms.rst index be0d4ff800..2cb5c695e8 100644 --- a/doc/src/Python_atoms.rst +++ b/doc/src/Python_atoms.rst @@ -58,7 +58,7 @@ against invalid accesses. Each element of this list is a :py:class:`Atom ` or :py:class:`Atom2D ` object. The attributes of these objects provide access to their data (id, type, position, velocity, force, etc.): - .. code-block:: Python + .. code-block:: python # access first atom L.atoms[0].id @@ -71,7 +71,7 @@ against invalid accesses. Some attributes can be changed: - .. code-block:: Python + .. code-block:: python # set position in 2D simulation L.atoms[0].position = (1.0, 0.0) diff --git a/doc/src/Python_config.rst b/doc/src/Python_config.rst index 38f0ef0baf..ccbc74a46c 100644 --- a/doc/src/Python_config.rst +++ b/doc/src/Python_config.rst @@ -4,7 +4,7 @@ Configuration information The following methods can be used to query the LAMMPS library about compile time settings and included packages and styles. -.. code-block:: Python +.. code-block:: python :caption: Example for using configuration settings functions from lammps import lammps diff --git a/doc/src/Python_create.rst b/doc/src/Python_create.rst index ec4241f36a..939aad2f32 100644 --- a/doc/src/Python_create.rst +++ b/doc/src/Python_create.rst @@ -74,7 +74,7 @@ Here are simple examples using all three Python interfaces: :py:class:`PyLammps ` objects can also be created on top of an existing :py:class:`lammps ` object: - .. code-block:: Python + .. code-block:: python from lammps import lammps, PyLammps ... @@ -113,7 +113,7 @@ Here are simple examples using all three Python interfaces: You can also initialize IPyLammps on top of an existing :py:class:`lammps` or :py:class:`PyLammps` object: - .. code-block:: Python + .. code-block:: python from lammps import lammps, IPyLammps ... @@ -142,7 +142,7 @@ the MPI and/or Kokkos environment if enabled and active. Note that you can create multiple LAMMPS objects in your Python script, and coordinate and run multiple simulations, e.g. -.. code-block:: Python +.. code-block:: python from lammps import lammps lmp1 = lammps() diff --git a/doc/src/Python_error.rst b/doc/src/Python_error.rst index 744a8dd3de..5dbd940723 100644 --- a/doc/src/Python_error.rst +++ b/doc/src/Python_error.rst @@ -7,7 +7,7 @@ current Python process with an error message. C++ exceptions allow capturing them on the C++ side and rethrowing them on the Python side. This way LAMMPS errors can be handled through the Python exception handling mechanism. -.. code-block:: Python +.. code-block:: python from lammps import lammps, MPIAbortException diff --git a/doc/src/Python_execute.rst b/doc/src/Python_execute.rst index 59faa34438..01cf0e920f 100644 --- a/doc/src/Python_execute.rst +++ b/doc/src/Python_execute.rst @@ -60,7 +60,7 @@ it is possible to "compute" what the next LAMMPS command should be. can be executed using with the lammps API with the following Python code if ``lmp`` is an instance of :py:class:`lammps `: - .. code-block:: Python + .. code-block:: python from lammps import lammps @@ -73,7 +73,7 @@ it is possible to "compute" what the next LAMMPS command should be. The arguments of the command can be passed as one string, or individually. - .. code-block:: Python + .. code-block:: python from lammps import PyLammps @@ -93,14 +93,14 @@ it is possible to "compute" what the next LAMMPS command should be. parameterization. In the lammps API parameterization needed to be done manually by creating formatted command strings. - .. code-block:: Python + .. code-block:: python lmp.command("region box block %f %f %f %f %f %f" % (xlo, xhi, ylo, yhi, zlo, zhi)) In contrast, methods of PyLammps accept parameters directly and will convert them automatically to a final command string. - .. code-block:: Python + .. code-block:: python L.region("box block", xlo, xhi, ylo, yhi, zlo, zhi) diff --git a/doc/src/Python_launch.rst b/doc/src/Python_launch.rst index 500a107977..96e43a2d95 100644 --- a/doc/src/Python_launch.rst +++ b/doc/src/Python_launch.rst @@ -56,7 +56,7 @@ and you should see the same output as if you had typed Note that without the mpi4py specific lines from ``test.py`` -.. code-block:: Python +.. code-block:: python from lammps import lammps lmp = lammps() diff --git a/doc/src/Python_objects.rst b/doc/src/Python_objects.rst index 4a1496632e..6e3a329a27 100644 --- a/doc/src/Python_objects.rst +++ b/doc/src/Python_objects.rst @@ -76,7 +76,7 @@ computes, fixes, or variables in LAMMPS using the :py:mod:`lammps` module. To define a variable you can use the :doc:`variable ` command: - .. code-block:: Python + .. code-block:: python L.variable("a index 2") @@ -85,14 +85,14 @@ computes, fixes, or variables in LAMMPS using the :py:mod:`lammps` module. you can access an individual variable by retrieving a variable object from the ``L.variables`` dictionary by name - .. code-block:: Python + .. code-block:: python a = L.variables['a'] The variable value can then be easily read and written by accessing the value property of this object. - .. code-block:: Python + .. code-block:: python print(a.value) a.value = 4 diff --git a/doc/src/Python_properties.rst b/doc/src/Python_properties.rst index 02af03bbb8..227a729622 100644 --- a/doc/src/Python_properties.rst +++ b/doc/src/Python_properties.rst @@ -105,7 +105,7 @@ against invalid accesses. variables, compute or fix data (see :doc:`Howto_output`): - .. code-block:: Python + .. code-block:: python result = L.eval("ke") # kinetic energy result = L.eval("pe") # potential energy diff --git a/doc/src/Python_scatter.rst b/doc/src/Python_scatter.rst index 113b98d354..002a36cc98 100644 --- a/doc/src/Python_scatter.rst +++ b/doc/src/Python_scatter.rst @@ -1,7 +1,7 @@ Scatter/gather operations ========================= -.. code-block:: Python +.. code-block:: python data = lmp.gather_atoms(name,type,count) # return per-atom property of all atoms gathered into data, ordered by atom ID # name = "x", "charge", "type", etc @@ -42,7 +42,7 @@ For the scatter methods, the array of coordinates passed to must be a ctypes vector of ints or doubles, allocated and initialized something like this: -.. code-block:: Python +.. code-block:: python from ctypes import c_double natoms = lmp.get_natoms() From d4289a2774976ae0932817f8a703b444a64bff92 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 4 Dec 2022 16:59:35 -0500 Subject: [PATCH 09/19] update list of commands in pygments LAMMPS lexer --- doc/utils/sphinx-config/LAMMPSLexer.py | 46 +++++++++++++++----------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/doc/utils/sphinx-config/LAMMPSLexer.py b/doc/utils/sphinx-config/LAMMPSLexer.py index 524d7bf1fa..c8826a9ed6 100644 --- a/doc/utils/sphinx-config/LAMMPSLexer.py +++ b/doc/utils/sphinx-config/LAMMPSLexer.py @@ -1,25 +1,33 @@ from pygments.lexer import RegexLexer, words, include, default from pygments.token import * -LAMMPS_COMMANDS = ("angle_coeff", "angle_style", "atom_modify", "atom_style", -"balance", "bond_coeff", "bond_style", "bond_write", "boundary", "box", -"clear", "comm_modify", "comm_style", -"compute_modify", "create_atoms", "create_bonds", "create_box", "delete_atoms", -"delete_bonds", "dielectric", "dihedral_coeff", "dihedral_style", "dimension", -"displace_atoms", "dump_modify", "dynamical_matrix", "echo", "elif", "else", -"fix_modify", "group2ndx", "hyper", "if", "improper_coeff", -"improper_style", "include", "info", "jump", "kim", -"kspace_modify", "kspace_style", "label", "labelmap", "lattice", "log", -"mass", "mdi", "message", "minimize", "min_modify", "min_style", "molecule", -"ndx2group", "neb", "neb/spin", "neighbor", "neigh_modify", "newton", "next", -"package", "pair_coeff", "pair_modify", "pair_style", "pair_write", -"partition", "prd", "print", "processors", "python", "quit", "read_data", -"read_dump", "read_restart", "replicate", "rerun", "reset_ids", -"reset_timestep", "restart", "run", "run_style", "server", "set", "shell", -"special_bonds", "suffix", "tad", "temper", "temper/grem", "temper/npt", "then", -"thermo", "thermo_modify", "thermo_style", "third_order", "timer", "timestep", -"units", "velocity", "write_coeff", -"write_data", "write_restart") +LAMMPS_COMMANDS = ("angle_coeff", "angle_style", "atom_modify", + "atom_style", "balance", "bond_coeff", "bond_style", + "bond_write", "boundary", "clear", "comm_modify", + "comm_style", "compute_modify", "create_atoms", + "create_bonds", "create_box", "delete_atoms", + "delete_bonds", "dielectric", "dihedral_coeff", + "dihedral_style", "dimension", "displace_atoms", + "dump_modify", "dynamical_matrix", "echo", "elif", + "else", "fix_modify", "group2ndx", "hyper", "if", + "improper_coeff", "improper_style", "include", + "info", "jump", "kim", "kspace_modify", + "kspace_style", "label", "labelmap", "lattice", + "log", "mass", "mdi", "message", "minimize", + "min_modify", "min_style", "molecule", "ndx2group", + "neb", "neb/spin", "neighbor", "neigh_modify", + "newton", "next", "package", "pair_coeff", + "pair_modify", "pair_style", "pair_write", + "partition", "plugin", "prd", "print", "processors", + "python", "quit", "read_data", "read_dump", + "read_restart", "replicate", "rerun", "reset_atoms", + "reset_timestep", "restart", "run", "run_style", + "server", "set", "shell", "special_bonds", "suffix", + "tad", "temper", "temper/grem", "temper/npt", "then", + "thermo", "thermo_modify", "thermo_style", + "third_order", "timer", "timestep", "units", + "velocity", "write_coeff", "write_data", + "write_restart") #fix ID group-ID style args #compute ID group-ID style args From 080b3b9ccbff049607b2b179b52ee39aeffe513e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 5 Dec 2022 13:23:12 -0500 Subject: [PATCH 10/19] avoid 32-bit integer overflow --- src/ELECTRODE/pppm_electrode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ELECTRODE/pppm_electrode.cpp b/src/ELECTRODE/pppm_electrode.cpp index b43c804eb2..0b92a76c8e 100644 --- a/src/ELECTRODE/pppm_electrode.cpp +++ b/src/ELECTRODE/pppm_electrode.cpp @@ -678,7 +678,7 @@ void PPPMElectrode::compute_matrix(bigint *imat, double **matrix, bool timer_fla // fft green's function k -> r (double) double *greens_real; memory->create(greens_real, nz_pppm * ny_pppm * nx_pppm, "pppm/electrode:greens_real"); - memset(greens_real, 0, nz_pppm * ny_pppm * nx_pppm * sizeof(double)); + memset(greens_real, 0, (std::size_t)nz_pppm * (std::size_t)ny_pppm * (std::size_t)nx_pppm * sizeof(double)); for (int i = 0, n = 0; i < nfft; i++) { work2[n++] = greensfn[i]; work2[n++] = ZEROF; @@ -871,7 +871,7 @@ void PPPMElectrode::two_step_multiplication(bigint *imat, double *greens_real, d double **gw; memory->create(gw, nmat, nxyz, "pppm/electrode:gw"); - memset(&(gw[0][0]), 0, nmat * nxyz * sizeof(double)); + memset(&(gw[0][0]), 0, (std::size_t)nmat * (std::size_t)nxyz * sizeof(double)); auto fmod = [](int x, int n) { // fast unsigned mod int r = abs(x); From ecf5b5a848493602f06304c30a6a93291ee2b4f5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 5 Dec 2022 17:30:13 -0500 Subject: [PATCH 11/19] use call-by-reference to pass datastruct to functions --- src/ML-POD/fitpod_command.cpp | 20 ++++++++++---------- src/ML-POD/fitpod_command.h | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/ML-POD/fitpod_command.cpp b/src/ML-POD/fitpod_command.cpp index 619f82f4a8..e054ec23d7 100644 --- a/src/ML-POD/fitpod_command.cpp +++ b/src/ML-POD/fitpod_command.cpp @@ -872,7 +872,7 @@ int FitPOD::podfullneighborlist(double *y, int *alist, int *neighlist, int *numn return nn; } -void FitPOD::allocate_memory(datastruct data) +void FitPOD::allocate_memory(const datastruct &data) { int nd = podptr->pod.nd; memory->create(desc.gd, nd, "fitpod:desc_gd"); @@ -989,7 +989,7 @@ void FitPOD::allocate_memory(datastruct data) } } -void FitPOD::linear_descriptors(datastruct data, int ci) +void FitPOD::linear_descriptors(const datastruct &data, int ci) { int dim = 3; int nd1 = podptr->pod.nd1; @@ -1020,7 +1020,7 @@ void FitPOD::linear_descriptors(datastruct data, int ci) } -void FitPOD::quadratic_descriptors(datastruct data, int ci) +void FitPOD::quadratic_descriptors(const datastruct &data, int ci) { int dim = 3; int natom = data.num_atom[ci]; @@ -1101,7 +1101,7 @@ void FitPOD::quadratic_descriptors(datastruct data, int ci) desc.gdd[dim*natom*nd1234+i] = desc.gdd[dim*natom*nd1234+i]/(natom); } -void FitPOD::cubic_descriptors(datastruct data, int ci) +void FitPOD::cubic_descriptors(const datastruct &data, int ci) { int dim = 3; int natom = data.num_atom[ci]; @@ -1168,7 +1168,7 @@ void FitPOD::cubic_descriptors(datastruct data, int ci) desc.gdd[i] = desc.gdd[i]/(natom*natom); } -void FitPOD::least_squares_matrix(datastruct data, int ci) +void FitPOD::least_squares_matrix(const datastruct &data, int ci) { int dim = 3; int natom = data.num_atom[ci]; @@ -1214,7 +1214,7 @@ void FitPOD::least_squares_matrix(datastruct data, int ci) } -void FitPOD::least_squares_fit(datastruct data) +void FitPOD::least_squares_fit(const datastruct &data) { if (comm->me == 0) utils::logmesg(lmp, "**************** Begin of Least-Squares Fitting ****************\n"); @@ -1308,7 +1308,7 @@ void FitPOD::least_squares_fit(datastruct data) } } -double FitPOD::energyforce_calculation(double *force, double *coeff, datastruct data, int ci) +double FitPOD::energyforce_calculation(double *force, double *coeff, const datastruct &data, int ci) { int dim = 3; int *pbc = podptr->pod.pbc; @@ -1348,7 +1348,7 @@ double FitPOD::energyforce_calculation(double *force, double *coeff, datastruct return energy; } -void FitPOD::print_analysis(datastruct data, double *outarray, double *errors) +void FitPOD::print_analysis(const datastruct &data, double *outarray, double *errors) { int nfiles = data.data_files.size(); // number of files int lm = 10; @@ -1422,7 +1422,7 @@ void FitPOD::print_analysis(datastruct data, double *outarray, double *errors) fclose(fp_analysis); } -void FitPOD::error_analysis(datastruct data, double *coeff) +void FitPOD::error_analysis(const datastruct &data, double *coeff) { int dim = 3; double energy; @@ -1561,7 +1561,7 @@ void FitPOD::error_analysis(datastruct data, double *coeff) } } -void FitPOD::energyforce_calculation(datastruct data, double *coeff) +void FitPOD::energyforce_calculation(const datastruct &data, double *coeff) { int dim = 3; double energy; diff --git a/src/ML-POD/fitpod_command.h b/src/ML-POD/fitpod_command.h index 7001346522..a592380778 100644 --- a/src/ML-POD/fitpod_command.h +++ b/src/ML-POD/fitpod_command.h @@ -166,16 +166,16 @@ public: int podneighborlist(int *neighlist, int *numneigh, double *r, double rcutsq, int nx, int N, int dim); int podfullneighborlist(double *y, int *alist, int *neighlist, int *numneigh, int *numneighsum, double *x, double *a1, double *a2, double *a3, double rcut, int *pbc, int nx); - void allocate_memory(datastruct data); - void linear_descriptors(datastruct data, int ci); - void quadratic_descriptors(datastruct data, int ci); - void cubic_descriptors(datastruct data, int ci); - void least_squares_matrix(datastruct data, int ci); - void least_squares_fit(datastruct data); - void print_analysis(datastruct data, double *outarray, double *errors); - void error_analysis(datastruct data, double *coeff); - double energyforce_calculation(double *force, double *coeff, datastruct data, int ci); - void energyforce_calculation(datastruct data, double *coeff); + void allocate_memory(const datastruct &data); + void linear_descriptors(const datastruct &data, int ci); + void quadratic_descriptors(const datastruct &data, int ci); + void cubic_descriptors(const datastruct &data, int ci); + void least_squares_matrix(const datastruct &data, int ci); + void least_squares_fit(const datastruct &data); + void print_analysis(const datastruct &data, double *outarray, double *errors); + void error_analysis(const datastruct &data, double *coeff); + double energyforce_calculation(double *force, double *coeff, const datastruct &data, int ci); + void energyforce_calculation(const datastruct &data, double *coeff); }; } // namespace LAMMPS_NS From f33d7b8fc19fbfb07f8553919dd311363ae66458 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 5 Dec 2022 17:34:54 -0500 Subject: [PATCH 12/19] avoid string copy --- src/ML-POD/fitpod_command.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ML-POD/fitpod_command.cpp b/src/ML-POD/fitpod_command.cpp index e054ec23d7..0858bc06a6 100644 --- a/src/ML-POD/fitpod_command.cpp +++ b/src/ML-POD/fitpod_command.cpp @@ -241,7 +241,7 @@ void FitPOD::get_exyz_files(std::vector& files, const std::string & { auto allfiles = platform::list_directory(datapath); std::sort(allfiles.begin(), allfiles.end()); - for (auto fname : allfiles) { + for (const auto &fname : allfiles) { if (utils::strmatch(fname, fmt::format(".*\\.{}$", extension))) files.push_back(datapath + platform::filepathsep + fname); } @@ -252,7 +252,6 @@ int FitPOD::get_number_atom_exyz(std::vector& num_atom, int& num_atom_sum, std::string filename = file; FILE *fp; if (comm->me == 0) { - fp = utils::open_potential(filename,lmp,nullptr); if (fp == nullptr) error->one(FLERR,"Cannot open POD coefficient file {}: ", filename, utils::getsyserror()); @@ -469,7 +468,7 @@ void FitPOD::get_data(datastruct &data, std::vector species) utils::logmesg(lmp, "{}\n {:^{}} | number of configurations | number of atoms\n{}\n", sepline, "data file", maxname, sepline); int i = 0; - for (auto fname : data.data_files) { + for (const auto &fname : data.data_files) { std::string filename = fname.substr(data.data_path.size()+1); data.filenames.push_back(filename); if (comm->me == 0) @@ -695,7 +694,7 @@ void FitPOD::select_data(datastruct &newdata, datastruct data) data.copydatainfo(newdata); size_t maxname = 9; - for (auto fname : data.data_files) maxname = MAX(maxname,fname.size()); + for (const auto &fname : data.data_files) maxname = MAX(maxname,fname.size()); maxname -= data.data_path.size()+1; if (comm->me == 0) From 20f568e1aea165d297f283921293fbd6342cac5c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 5 Dec 2022 17:35:02 -0500 Subject: [PATCH 13/19] avoid division by zero --- src/ML-POD/fitpod_command.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ML-POD/fitpod_command.cpp b/src/ML-POD/fitpod_command.cpp index 0858bc06a6..a499ad9f25 100644 --- a/src/ML-POD/fitpod_command.cpp +++ b/src/ML-POD/fitpod_command.cpp @@ -1536,7 +1536,10 @@ void FitPOD::error_analysis(const datastruct &data, double *coeff) nforceall += nforce; ci += 1; } + int q = file + 1; + if (nconfigs == 0) nconfigs = 1; + if (nforceall == 0) nforceall = 1; errors[0 + 4*q] = emae/nconfigs; errors[1 + 4*q] = sqrt(essr/nconfigs); errors[2 + 4*q] = fmae/nforceall; @@ -1549,6 +1552,8 @@ void FitPOD::error_analysis(const datastruct &data, double *coeff) errors[3] += fssr; } + if (nc == 0) nc = 1; + if (nf == 0) nf = 1; errors[0] = errors[0]/nc; errors[1] = sqrt(errors[1]/nc); errors[2] = errors[2]/nf; From 69d402fa7b7e004827c20351b80ffdffe46477f6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 5 Dec 2022 18:01:23 -0500 Subject: [PATCH 14/19] handle dead code --- src/ML-POD/mlpod.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ML-POD/mlpod.cpp b/src/ML-POD/mlpod.cpp index 2712dd6b65..72c732b701 100644 --- a/src/ML-POD/mlpod.cpp +++ b/src/ML-POD/mlpod.cpp @@ -1641,39 +1641,37 @@ void MLPOD::InitSnap() double rcutmax = 0.0; for (int ielem = 0; ielem < ntypes; ielem++) - rcutmax = MAX(2.0*elemradius[ielem]*rcutfac,rcutmax); + rcutmax = MAX(2.0*elemradius[ielem]*rcutfac,rcutmax); snapSetup(twojmax, ntypes); - //TemplateCopytoDevice(&sna.radelem[1], elemradius, ntypes, backend); - //TemplateCopytoDevice(&sna.wjelem[1], elemweight, ntypes, backend); for (int i=0; i 1.0 ? 1.0 : costhe; costhe = costhe < -1.0 ? -1.0 : costhe; - xdot = costhe*(rij*rik); theta = acos(costhe); for (int p=0; p Date: Mon, 5 Dec 2022 18:01:49 -0500 Subject: [PATCH 15/19] avoid making members public --- src/ML-POD/fitpod_command.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ML-POD/fitpod_command.h b/src/ML-POD/fitpod_command.h index a592380778..201461e951 100644 --- a/src/ML-POD/fitpod_command.h +++ b/src/ML-POD/fitpod_command.h @@ -26,9 +26,11 @@ CommandStyle(fitpod,FitPOD); namespace LAMMPS_NS { class FitPOD : public Command { -private: - public: + FitPOD(LAMMPS *); + void command(int, char **) override; + +private: struct datastruct { std::string file_format = "extxyz"; std::string file_extension = "xyz"; @@ -120,9 +122,6 @@ public: neighborstruct nb; class MLPOD *podptr; - FitPOD(LAMMPS *lmp) : Command(lmp) {} - - // functions for collecting/collating arrays void print_matrix(const char *desc, int m, int n, int *a, int lda); @@ -148,7 +147,7 @@ public: // functions for reading input files and fitting - void command(int, char **) override; + int read_data_file(double *fitting_weights, std::string &file_format, std::string &file_extension, std::string &test_path, std::string &training_path, std::string &filenametag, const std::string &data_file); void get_exyz_files(std::vector &, const std::string &, const std::string &); From 92d89941894a2665b6e1403a1b60fac57863b65c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 5 Dec 2022 18:02:18 -0500 Subject: [PATCH 16/19] add initializer for podptr --- src/ML-POD/fitpod_command.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ML-POD/fitpod_command.cpp b/src/ML-POD/fitpod_command.cpp index a499ad9f25..c78f5eec76 100644 --- a/src/ML-POD/fitpod_command.cpp +++ b/src/ML-POD/fitpod_command.cpp @@ -46,6 +46,10 @@ using MathSpecial::powint; static constexpr double SMALL = 1.0e-10; +FitPOD::FitPOD(LAMMPS *_lmp) : Command(_lmp), podptr(nullptr) +{ +} + void FitPOD::command(int narg, char **arg) { if (narg < 2) utils::missing_cmd_args(FLERR, "fitpod", error); @@ -1820,4 +1824,3 @@ void FitPOD::triclinic_lattice_conversion(double *a, double *b, double *c, doubl b[0] = bx; b[1] = by; b[2] = 0.0; c[0] = cx; c[1] = cy; c[2] = cz; } - From 2c6cd42038c957701247b6ee269d4109a82e10ad Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 5 Dec 2022 19:17:47 -0500 Subject: [PATCH 17/19] silence compiler warnings about unused function parameters --- src/ML-POD/mlpod.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ML-POD/mlpod.cpp b/src/ML-POD/mlpod.cpp index 72c732b701..859b269375 100644 --- a/src/ML-POD/mlpod.cpp +++ b/src/ML-POD/mlpod.cpp @@ -695,8 +695,9 @@ void MLPOD::read_coeff_file(const std::string &coeff_file) /*********************************************************************************************************/ -void MLPOD::linear_descriptors(double *gd, double *efatom, double *y, double *tmpmem, int *atomtype, - int *alist, int *pairlist, int *pairnum, int *pairnumsum, int *tmpint, int natom, int Nij) +void MLPOD::linear_descriptors(double *gd, double *efatom, double *y, double *tmpmem, + int *atomtype, int *alist, int *pairlist, int * /*pairnum*/, + int *pairnumsum, int *tmpint, int natom, int Nij) { int dim = 3; int nelements = pod.nelements; @@ -1900,8 +1901,8 @@ void MLPOD::snapComputeUlist(double *Sr, double *Si, double *dSr, double *dSi, d }; void MLPOD::snapZeroUarraytot2(double *Stotr, double *Stoti, double wself, int *idxu_block, - int *type, int *map, int *ai, int wselfall_flag, int chemflag, int idxu_max, int nelements, - int twojmax, int inum) + int *type, int *map, int * /*ai*/, int wselfall_flag, int chemflag, + int idxu_max, int nelements, int twojmax, int inum) { int N1 = inum; int N2 = N1*(twojmax+1); @@ -2552,8 +2553,9 @@ void MLPOD::pod1body(double *eatom, int *atomtype, int nelements, int natom) eatom[i + natom*(m-1)] = (atomtype[i] == m) ? 1.0 : 0.0; } -void MLPOD::pod3body(double *eatom, double *yij, double *e2ij, double *tmpmem, int *elemindex, int *pairnumsum, - int *idxi, int *ti, int *tj, int nrbf, int nabf, int nelements, int natom, int Nij) +void MLPOD::pod3body(double *eatom, double *yij, double *e2ij, double *tmpmem, int *elemindex, + int *pairnumsum, int * /*idxi*/, int *ti, int *tj, int nrbf, int nabf, + int nelements, int natom, int Nij) { int dim = 3, nabf1 = nabf + 1; int nelements2 = nelements*(nelements+1)/2; @@ -3067,8 +3069,8 @@ double MLPOD::calculate_energy(double *energycoeff, double *forcecoeff, double * return energy; } -void MLPOD::pod2body_force(double *force, double *fij, double *coeff2, int *ai, int *aj, - int *ti, int *tj, int *elemindex, int nelements, int nbf, int natom, int N) +void MLPOD::pod2body_force(double *force, double *fij, double *coeff2, int *ai, int *aj, int *ti, + int *tj, int *elemindex, int nelements, int nbf, int /*natom*/, int N) { int nelements2 = nelements*(nelements+1)/2; for (int n=0; n Date: Mon, 5 Dec 2022 19:47:08 -0500 Subject: [PATCH 18/19] update .gitignore for renamed source file --- src/.gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index 0e1c7fc4e8..0fbd54afcd 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -59,8 +59,8 @@ /pair_pod.cpp /pair_pod.h -/fitpod.cpp -/fitpod.h +/fitpod_command.cpp +/fitpod_command.h /mlpod.cpp /mlpod.h From 5e2a8beb4a4edc2cdd2488e7efa555c56e1a2f00 Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Fri, 9 Dec 2022 14:28:26 -0700 Subject: [PATCH 19/19] Fix bug in Kokkos minimize on GPUs --- src/KOKKOS/min_linesearch_kokkos.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/KOKKOS/min_linesearch_kokkos.cpp b/src/KOKKOS/min_linesearch_kokkos.cpp index 101502d023..920e06f70c 100644 --- a/src/KOKKOS/min_linesearch_kokkos.cpp +++ b/src/KOKKOS/min_linesearch_kokkos.cpp @@ -376,11 +376,15 @@ double MinLineSearchKokkos::alpha_step(double alpha, int resetflag) }); } + atomKK->modified(Device,X_MASK); + // step forward along h if (alpha > 0.0) { if (nextra_global) modify->min_step(alpha,hextra); + atomKK->sync(Device,X_MASK); // positions can be modified by fix box/relax + // local variables for lambda capture auto l_xvec = xvec;