From 69b8a8c7b37bd3befb1052ad3028df5eb73f31a4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 15 May 2024 13:49:07 -0400 Subject: [PATCH 1/6] remove dead code --- src/EXTRA-FIX/fix_deform_pressure.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/EXTRA-FIX/fix_deform_pressure.cpp b/src/EXTRA-FIX/fix_deform_pressure.cpp index 672f097c2da..e93def4926d 100644 --- a/src/EXTRA-FIX/fix_deform_pressure.cpp +++ b/src/EXTRA-FIX/fix_deform_pressure.cpp @@ -114,7 +114,6 @@ FixDeformPressure::FixDeformPressure(LAMMPS *lmp, int narg, char **arg) : if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure erate/rescale", error); set[index].style = ERATERS; set[index].rate = utils::numeric(FLERR, arg[iarg + 2], false, lmp); - iarg += 3; i += 3; } else error->all(FLERR, "Illegal fix deform/pressure command: {}", arg[iarg + 1]); From 16b2ed5cc9842a40a8ccd2df3046c42ae9814d7b Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 15 May 2024 13:49:54 -0400 Subject: [PATCH 2/6] initialize pointers to null in constructor --- src/replicate.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/replicate.cpp b/src/replicate.cpp index e07c7d9a26f..15c477faa63 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -26,29 +26,34 @@ #include "comm.h" #include "domain.h" #include "error.h" +#include "label_map.h" #include "memory.h" #include "special.h" -#include "label_map.h" #include using namespace LAMMPS_NS; static constexpr double LB_FACTOR = 1.1; -static constexpr double EPSILON = 1.0e-6; +static constexpr double EPSILON = 1.0e-6; /* ---------------------------------------------------------------------- */ -Replicate::Replicate(LAMMPS *lmp) : Command(lmp) {} +Replicate::Replicate(LAMMPS *lmp) : Command(lmp), old(nullptr), old_x(nullptr), old_tag(nullptr) +{ + bbox_flag = 0; + bond_flag = 0; +} /* ---------------------------------------------------------------------- */ void Replicate::command(int narg, char **arg) { - int i,j,m,n; + int i,n; if (domain->box_exist == 0) error->all(FLERR,"Replicate command before simulation box is defined"); + if (narg < 3 || narg > 4) error->all(FLERR,"Illegal replicate command"); int me = comm->me; @@ -78,9 +83,6 @@ void Replicate::command(int narg, char **arg) // optional keywords - bbox_flag = 0; - bond_flag = 0; - int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"bbox") == 0) { From 6aec49619ff91412e38b0c3f0acb148ce6690abe Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 16 May 2024 09:41:42 -0400 Subject: [PATCH 3/6] remove redundant initializers from headers --- src/ML-PACE/pair_pace.h | 2 +- src/ML-PACE/pair_pace_extrapolation.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ML-PACE/pair_pace.h b/src/ML-PACE/pair_pace.h index 9b5d2c54806..5cff7045fa0 100644 --- a/src/ML-PACE/pair_pace.h +++ b/src/ML-PACE/pair_pace.h @@ -52,7 +52,7 @@ class PairPACE : public Pair { protected: struct ACEImpl *aceimpl; - int nmax_corerep = 0; + int nmax_corerep; virtual void allocate(); double *corerep_factor; //per-atom core-rep factor (= 1 - fcut) diff --git a/src/ML-PACE/pair_pace_extrapolation.h b/src/ML-PACE/pair_pace_extrapolation.h index 440d999029e..e01fdd23298 100644 --- a/src/ML-PACE/pair_pace_extrapolation.h +++ b/src/ML-PACE/pair_pace_extrapolation.h @@ -46,15 +46,15 @@ class PairPACEExtrapolation : public Pair { protected: struct ACEALImpl *aceimpl; - int nmax = 0, nmax_corerep = 0; + int nmax, nmax_corerep; virtual void allocate(); std::vector element_names; // list of elements (used by dump pace/extrapolation) - double *extrapolation_grade_gamma = nullptr; //per-atom gamma value - double *corerep_factor = nullptr; //per-atom core-rep factor (= 1 - fcut) + double *extrapolation_grade_gamma; //per-atom gamma value + double *corerep_factor; //per-atom core-rep factor (= 1 - fcut) - int flag_compute_extrapolation_grade = 0; - int flag_corerep_factor = 0; + int flag_compute_extrapolation_grade; + int flag_corerep_factor; double **scale; From 0577e1ff77d6751f542449a67aae2fc193df586d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 May 2024 06:08:43 -0400 Subject: [PATCH 4/6] install runtime dlls for LAMMPS library only with -DBUILD_SHARED_LIBS=yes --- tools/lammps-gui/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/lammps-gui/CMakeLists.txt b/tools/lammps-gui/CMakeLists.txt index b1469794bbd..951b350edbc 100644 --- a/tools/lammps-gui/CMakeLists.txt +++ b/tools/lammps-gui/CMakeLists.txt @@ -250,7 +250,9 @@ if(APPLE) elseif(MSVC) install(TARGETS lammps-gui DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES $ TYPE BIN) - install(FILES $ TYPE BIN) + if(BUILD_SHARED_LIBS) + install(FILES $ TYPE BIN) + endif() install(FILES $ TYPE BIN) # find path to VC++ init batch file get_filename_component(VC_COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY) @@ -262,7 +264,9 @@ elseif(MSVC) elseif((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING) install(TARGETS lammps-gui DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES $ TYPE BIN) - install(FILES $ TYPE BIN) + if(BUILD_SHARED_LIBS) + install(FILES $ TYPE BIN) + endif() install(FILES $ TYPE BIN) add_custom_target(zip COMMAND sh -vx ${LAMMPS_DIR}/cmake/packaging/build_windows_cross_zip.sh ${CMAKE_INSTALL_PREFIX} From 658dcef145a8c459f3b1ee3b33d4818231e53233 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 May 2024 06:21:23 -0400 Subject: [PATCH 5/6] fix bug with newton_bond off --- src/EXTRA-COMPUTE/compute_stress_cartesian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp index 622ea839bec..b8946b3647f 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp @@ -386,7 +386,7 @@ void ComputeStressCartesian::compute_array() if (tag[i] > tag[j]) { if ((tag[i] + tag[j]) % 2 == 0) continue; } else if (tag[i] < tag[j]) { - if ((tag[i] < tag[j]) % 2 == 1) continue; + if ((tag[i] + tag[j]) % 2 == 1) continue; } } From 30704d095dac3f0c2029293dc3fb6c4b39bc6520 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 May 2024 16:00:19 -0400 Subject: [PATCH 6/6] support that cmdargs is used multiple times and may be bytearrays directly --- python/lammps/core.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index 3498041454e..7bd22d62ed8 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -376,12 +376,16 @@ def __init__(self,name='',cmdargs=None,ptr=None,comm=None): narg = 0 cargs = None if cmdargs is not None: - cmdargs.insert(0,"lammps") - narg = len(cmdargs) - for i in range(narg): - if type(cmdargs[i]) is str: - cmdargs[i] = cmdargs[i].encode() - cargs = (c_char_p*(narg+1))(*cmdargs) + myargs = ["lammps".encode()] + narg = len(cmdargs) + 1 + for arg in cmdargs: + if type(arg) is str: + myargs.append(arg.encode()) + elif type(arg) is bytes: + myargs.append(arg) + else: + raise TypeError('Unsupported cmdargs type ', type(arg)) + cargs = (c_char_p*(narg+1))(*myargs) cargs[narg] = None self.lib.lammps_open.argtypes = [c_int, c_char_p*(narg+1), MPI_Comm, c_void_p] else: @@ -397,12 +401,16 @@ def __init__(self,name='',cmdargs=None,ptr=None,comm=None): self.comm = self.MPI.COMM_WORLD self.opened = 1 if cmdargs is not None: - cmdargs.insert(0,"lammps") - narg = len(cmdargs) - for i in range(narg): - if type(cmdargs[i]) is str: - cmdargs[i] = cmdargs[i].encode() - cargs = (c_char_p*(narg+1))(*cmdargs) + myargs = ["lammps".encode()] + narg = len(cmdargs) + 1 + for arg in cmdargs: + if type(arg) is str: + myargs.append(arg.encode()) + elif type(arg) is bytes: + myargs.append(arg) + else: + raise TypeError('Unsupported cmdargs type ', type(arg)) + cargs = (c_char_p*(narg+1))(*myargs) cargs[narg] = None self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*(narg+1), c_void_p] self.lmp = c_void_p(self.lib.lammps_open_no_mpi(narg,cargs,None))