From b46773e39869e0cc73fc91fdd776a76f401e4b69 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 17 Jun 2022 15:53:04 -0400 Subject: [PATCH 01/20] add support for writing a dump file footer --- src/EXTRA-DUMP/dump_yaml.cpp | 6 ++++++ src/EXTRA-DUMP/dump_yaml.h | 1 + src/dump.cpp | 2 ++ src/dump.h | 2 ++ 4 files changed, 11 insertions(+) diff --git a/src/EXTRA-DUMP/dump_yaml.cpp b/src/EXTRA-DUMP/dump_yaml.cpp index d4f3208ffb..be1c9768bf 100644 --- a/src/EXTRA-DUMP/dump_yaml.cpp +++ b/src/EXTRA-DUMP/dump_yaml.cpp @@ -124,6 +124,12 @@ void DumpYAML::write_data(int n, double *mybuf) } fputs("]\n", fp); } +} + +/* ---------------------------------------------------------------------- */ + +void DumpYAML::write_footer() +{ fputs("...\n", fp); } diff --git a/src/EXTRA-DUMP/dump_yaml.h b/src/EXTRA-DUMP/dump_yaml.h index bf621dcb51..60ab894de4 100644 --- a/src/EXTRA-DUMP/dump_yaml.h +++ b/src/EXTRA-DUMP/dump_yaml.h @@ -35,6 +35,7 @@ class DumpYAML : public DumpCustom { void write() override; void write_header(bigint) override; void write_data(int, double *) override; + void write_footer() override; int modify_param(int, char **) override; }; diff --git a/src/dump.cpp b/src/dump.cpp index 3569d32165..a354be4f04 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -517,6 +517,8 @@ void Dump::write() if (refreshflag) modify->compute[irefresh]->refresh(); + if (filewriter && fp != nullptr) write_footer(); + // if file per timestep, close file if I am filewriter if (multifile) { diff --git a/src/dump.h b/src/dump.h index a95029ada8..90866a3567 100644 --- a/src/dump.h +++ b/src/dump.h @@ -153,6 +153,8 @@ class Dump : protected Pointers { virtual void pack(tagint *) = 0; virtual int convert_string(int, double *) { return 0; } virtual void write_data(int, double *) = 0; + virtual void write_footer() {} + void pbc_allocate(); double compute_time(); From f831a776beb5318c4249ad77b2ac5f71d75e7b54 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 18 Jun 2022 22:25:32 -0400 Subject: [PATCH 02/20] correct python example --- doc/src/Howto_structured_data.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/Howto_structured_data.rst b/doc/src/Howto_structured_data.rst index 4ea6c28086..18a5dfd775 100644 --- a/doc/src/Howto_structured_data.rst +++ b/doc/src/Howto_structured_data.rst @@ -184,7 +184,7 @@ frame. .. code-block:: python - import re, yaml + import yaml import pandas as pd try: @@ -193,7 +193,7 @@ frame. from yaml import SafeLoader as Loader with open("ave.yaml") as f: - ave = yaml.load(docs, Loader=Loader) + ave = yaml.load(f, Loader=Loader) keys = ave['keywords'] df = {} From 063fc47f6478c272d01cdb002e5152d66ec0a828 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 19 Jun 2022 06:38:14 -0400 Subject: [PATCH 03/20] tweak to avoid test failure on FreeBSD --- unittest/force-styles/tests/manybody-pair-pace_product.yaml | 2 +- unittest/force-styles/tests/manybody-pair-pace_recursive.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unittest/force-styles/tests/manybody-pair-pace_product.yaml b/unittest/force-styles/tests/manybody-pair-pace_product.yaml index 1e82029777..b178586ab2 100644 --- a/unittest/force-styles/tests/manybody-pair-pace_product.yaml +++ b/unittest/force-styles/tests/manybody-pair-pace_product.yaml @@ -1,7 +1,7 @@ --- lammps_version: 17 Feb 2022 date_generated: Fri Mar 18 22:17:48 2022 -epsilon: 1e-12 +epsilon: 5e-12 skip_tests: prerequisites: ! | pair pace diff --git a/unittest/force-styles/tests/manybody-pair-pace_recursive.yaml b/unittest/force-styles/tests/manybody-pair-pace_recursive.yaml index f20440c85d..6105debb67 100644 --- a/unittest/force-styles/tests/manybody-pair-pace_recursive.yaml +++ b/unittest/force-styles/tests/manybody-pair-pace_recursive.yaml @@ -1,7 +1,7 @@ --- lammps_version: 10 Mar 2021 date_generated: Wed Apr 7 19:30:07 2021 -epsilon: 1e-12 +epsilon: 5e-12 prerequisites: ! | pair pace pre_commands: ! | From 3828c857f7bfaa9e688604618e0c8055907ac0c0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Jun 2022 18:10:19 -0400 Subject: [PATCH 04/20] accept LMP_SIZE_VECTOR as alias for LMP_SIZE_ROWS with local computes --- src/library.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library.cpp b/src/library.cpp index 079534d663..de655d74d0 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1749,6 +1749,7 @@ void *lammps_extract_compute(void *handle, const char *id, int style, int type) if (type == LMP_TYPE_SCALAR) return (void *) &compute->size_local_rows; /* for backward compatibility */ if (type == LMP_TYPE_VECTOR) return (void *) compute->vector_local; if (type == LMP_TYPE_ARRAY) return (void *) compute->array_local; + if (type == LMP_SIZE_VECTOR) return (void *) &compute->size_local_rows; /* alias for LMP_SIZE_ROWS */ if (type == LMP_SIZE_ROWS) return (void *) &compute->size_local_rows; if (type == LMP_SIZE_COLS) return (void *) &compute->size_local_cols; } From ffc5b12c5fcd97dccf7e4321c3a450be1d326fda Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Jun 2022 18:10:57 -0400 Subject: [PATCH 05/20] correct handling data of local computes which always needs to check rows and cols --- python/lammps/numpy_wrapper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/lammps/numpy_wrapper.py b/python/lammps/numpy_wrapper.py index 3619728081..ce0cb35e47 100644 --- a/python/lammps/numpy_wrapper.py +++ b/python/lammps/numpy_wrapper.py @@ -165,7 +165,7 @@ class numpy_wrapper: """ value = self.lmp.extract_compute(cid, cstyle, ctype) - if cstyle in (LMP_STYLE_GLOBAL, LMP_STYLE_LOCAL): + if cstyle == LMP_STYLE_GLOBAL: if ctype == LMP_TYPE_VECTOR: nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_VECTOR) return self.darray(value, nrows) @@ -173,6 +173,13 @@ class numpy_wrapper: nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_ROWS) ncols = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_COLS) return self.darray(value, nrows, ncols) + elif cstyle == LMP_STYLE_LOCAL: + nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_ROWS) + ncols = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_COLS) + if ncols == 0: + return self.darray(value, nrows) + else: + return self.darray(value, nrows, ncols) elif cstyle == LMP_STYLE_ATOM: if ctype == LMP_TYPE_VECTOR: nlocal = self.lmp.extract_global("nlocal") From ac615059a7aa85643e378bcb85f8b5e7cf764c72 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Jun 2022 18:15:02 -0400 Subject: [PATCH 06/20] update some linewraps for 100 col limit --- python/lammps/core.py | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index 23002b210c..930a40a4b0 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -188,20 +188,17 @@ class lammps(object): [c_void_p,POINTER(c_double),POINTER(c_double),c_double,c_double,c_double] self.lib.lammps_reset_box.restype = None - self.lib.lammps_gather_atoms.argtypes = \ - [c_void_p,c_char_p,c_int,c_int,c_void_p] + self.lib.lammps_gather_atoms.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p] self.lib.lammps_gather_atoms.restype = None - self.lib.lammps_gather_atoms_concat.argtypes = \ - [c_void_p,c_char_p,c_int,c_int,c_void_p] + self.lib.lammps_gather_atoms_concat.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p] self.lib.lammps_gather_atoms_concat.restype = None self.lib.lammps_gather_atoms_subset.argtypes = \ [c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p] self.lib.lammps_gather_atoms_subset.restype = None - self.lib.lammps_scatter_atoms.argtypes = \ - [c_void_p,c_char_p,c_int,c_int,c_void_p] + self.lib.lammps_scatter_atoms.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p] self.lib.lammps_scatter_atoms.restype = None self.lib.lammps_scatter_atoms_subset.argtypes = \ @@ -211,20 +208,17 @@ class lammps(object): self.lib.lammps_gather_bonds.argtypes = [c_void_p,c_void_p] self.lib.lammps_gather_bonds.restype = None - self.lib.lammps_gather.argtypes = \ - [c_void_p,c_char_p,c_int,c_int,c_void_p] + self.lib.lammps_gather.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p] self.lib.lammps_gather.restype = None - self.lib.lammps_gather_concat.argtypes = \ - [c_void_p,c_char_p,c_int,c_int,c_void_p] + self.lib.lammps_gather_concat.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p] self.lib.lammps_gather_concat.restype = None self.lib.lammps_gather_subset.argtypes = \ [c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p] self.lib.lammps_gather_subset.restype = None - self.lib.lammps_scatter.argtypes = \ - [c_void_p,c_char_p,c_int,c_int,c_void_p] + self.lib.lammps_scatter.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p] self.lib.lammps_scatter.restype = None self.lib.lammps_scatter_subset.argtypes = \ @@ -244,7 +238,8 @@ class lammps(object): self.lib.lammps_neighlist_num_elements.argtypes = [c_void_p, c_int] self.lib.lammps_neighlist_num_elements.restype = c_int - self.lib.lammps_neighlist_element_neighbors.argtypes = [c_void_p, c_int, c_int, POINTER(c_int), POINTER(c_int), POINTER(POINTER(c_int))] + self.lib.lammps_neighlist_element_neighbors.argtypes = \ + [c_void_p, c_int, c_int, POINTER(c_int), POINTER(c_int), POINTER(POINTER(c_int))] self.lib.lammps_neighlist_element_neighbors.restype = None self.lib.lammps_is_running.argtypes = [c_void_p] @@ -368,11 +363,9 @@ class lammps(object): if type(cmdargs[i]) is str: cmdargs[i] = cmdargs[i].encode() cargs = (c_char_p*narg)(*cmdargs) - self.lib.lammps_open.argtypes = [c_int, c_char_p*narg, \ - MPI_Comm, c_void_p] + self.lib.lammps_open.argtypes = [c_int, c_char_p*narg, MPI_Comm, c_void_p] else: - self.lib.lammps_open.argtypes = [c_int, c_char_p, \ - MPI_Comm, c_void_p] + self.lib.lammps_open.argtypes = [c_int, c_char_p, MPI_Comm, c_void_p] self.opened = 1 comm_ptr = self.MPI._addressof(comm) @@ -390,8 +383,7 @@ class lammps(object): if type(cmdargs[i]) is str: cmdargs[i] = cmdargs[i].encode() cargs = (c_char_p*narg)(*cmdargs) - self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*narg, \ - c_void_p] + self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*narg, c_void_p] self.lmp = c_void_p(self.lib.lammps_open_no_mpi(narg,cargs,None)) else: self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p, c_void_p] @@ -963,17 +955,14 @@ class lammps(object): return ptr elif ctype == LMP_SIZE_COLS: - if cstyle == LMP_STYLE_GLOBAL \ - or cstyle == LMP_STYLE_ATOM \ - or cstyle == LMP_STYLE_LOCAL: + if cstyle == LMP_STYLE_GLOBAL or cstyle == LMP_STYLE_ATOM or cstyle == LMP_STYLE_LOCAL: self.lib.lammps_extract_compute.restype = POINTER(c_int) with ExceptionCheck(self): ptr = self.lib.lammps_extract_compute(self.lmp,cid,cstyle,ctype) return ptr[0] elif ctype == LMP_SIZE_VECTOR or ctype == LMP_SIZE_ROWS: - if cstyle == LMP_STYLE_GLOBAL \ - or cstyle == LMP_STYLE_LOCAL: + if cstyle == LMP_STYLE_GLOBAL or cstyle == LMP_STYLE_LOCAL: self.lib.lammps_extract_compute.restype = POINTER(c_int) with ExceptionCheck(self): ptr = self.lib.lammps_extract_compute(self.lmp,cid,cstyle,ctype) From 78129f9078b39b97bcc0c1601ef7dd3d1de4ebd1 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Jun 2022 18:23:20 -0400 Subject: [PATCH 07/20] update embedded docs for LMP_SIZE_VECTOR update for extract_compute() --- src/library.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/library.cpp b/src/library.cpp index de655d74d0..cdc0a812c5 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1659,14 +1659,18 @@ lists the available options. - LMP_TYPE_ARRAY - ``double **`` - Local data array + * - LMP_STYLE_LOCAL + - LMP_SIZE_VECTOR + - ``int *`` + - Alias for using LMP_SIZE_ROWS * - LMP_STYLE_LOCAL - LMP_SIZE_ROWS - ``int *`` - - Number of local data rows + - Number of local array rows or length of vector * - LMP_STYLE_LOCAL - LMP_SIZE_COLS - ``int *`` - - Number of local data columns + - Number of local array columns, 0 if vector .. warning:: From 033af0c507b4be72ef9cdfb240aa0dc34762fb50 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Jun 2022 18:48:50 -0400 Subject: [PATCH 08/20] add unit test for extracting local vector and array via numpy --- unittest/python/python-numpy.py | 38 ++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/unittest/python/python-numpy.py b/unittest/python/python-numpy.py index 010255a81e..7cbae8e48d 100644 --- a/unittest/python/python-numpy.py +++ b/unittest/python/python-numpy.py @@ -93,17 +93,39 @@ class PythonNumpy(unittest.TestCase): # TODO pass - def testExtractComputeLocalScalar(self): - # TODO - pass - def testExtractComputeLocalVector(self): - # TODO - pass + self.lmp.command("region box block 0 2 0 2 0 2") + self.lmp.command("create_box 1 box") + self.lmp.command("create_atoms 1 single 1.0 1.0 1.0") + self.lmp.command("create_atoms 1 single 1.0 1.0 1.5") + self.lmp.command("mass 1 1.0") + self.lmp.command("pair_style lj/cut 1.9") + self.lmp.command("pair_coeff 1 1 1.0 1.0") + self.lmp.command("compute r0 all pair/local dist") + self.lmp.command("run 0 post no") + values = self.lmp.numpy.extract_compute("r0", LMP_STYLE_LOCAL, LMP_TYPE_VECTOR) + self.assertEqual(values.ndim, 1) + self.assertEqual(values.size, 2) + self.assertEqual(values[0], 0.5) + self.assertEqual(values[1], 1.5) def testExtractComputeLocalArray(self): - # TODO - pass + self.lmp.command("region box block 0 2 0 2 0 2") + self.lmp.command("create_box 1 box") + self.lmp.command("create_atoms 1 single 1.0 1.0 1.0") + self.lmp.command("create_atoms 1 single 1.0 1.0 1.5") + self.lmp.command("mass 1 1.0") + self.lmp.command("pair_style lj/cut 1.9") + self.lmp.command("pair_coeff 1 1 1.0 1.0") + self.lmp.command("compute r0 all pair/local dist dx dy dz") + self.lmp.command("run 0 post no") + values = self.lmp.numpy.extract_compute("r0", LMP_STYLE_LOCAL, LMP_TYPE_ARRAY) + self.assertEqual(values.ndim, 2) + self.assertEqual(values.size, 8) + self.assertEqual(values[0,0], 0.5) + self.assertEqual(values[0,3], -0.5) + self.assertEqual(values[1,0], 1.5) + self.assertEqual(values[1,3], 1.5) def testExtractAtomDeprecated(self): self.lmp.command("units lj") From ec46510d2e33e09cd23641ec0a3dcb9b0d35017a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Jun 2022 23:07:01 -0400 Subject: [PATCH 09/20] add local extract_compute() tests --- unittest/python/python-commands.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/unittest/python/python-commands.py b/unittest/python/python-commands.py index 58a0772510..cd77fa21a1 100644 --- a/unittest/python/python-commands.py +++ b/unittest/python/python-commands.py @@ -1,6 +1,8 @@ import sys,os,unittest,ctypes -from lammps import lammps, LMP_VAR_ATOM, LMP_STYLE_GLOBAL, LMP_TYPE_VECTOR, LAMMPS_DOUBLE_2D, LAMMPS_AUTODETECT +from lammps import lammps, LMP_VAR_ATOM, LMP_STYLE_GLOBAL, LMP_STYLE_LOCAL +from lammps import LMP_TYPE_VECTOR, LMP_SIZE_VECTOR, LMP_SIZE_ROWS, LMP_SIZE_COLS +from lammps import LAMMPS_DOUBLE_2D, LAMMPS_AUTODETECT has_manybody=False try: @@ -311,6 +313,14 @@ create_atoms 1 single & self.assertEqual(minval,1.0) self.assertEqual(maxval,2.1) + ndist1 = self.lmp.extract_compute("dist",LMP_STYLE_LOCAL,LMP_SIZE_VECTOR) + ndist2 = self.lmp.extract_compute("dist",LMP_STYLE_LOCAL,LMP_SIZE_ROWS) + ndist3 = self.lmp.extract_compute("dist",LMP_STYLE_LOCAL,LMP_SIZE_COLS) + + self.assertEqual(ndist1,21) + self.assertEqual(ndist2,21) + self.assertEqual(ndist3,0) + self.assertNotEqual(self.lmp.find_pair_neighlist("lj/cut"),-1) self.assertNotEqual(self.lmp.find_compute_neighlist("dist"),-1) self.assertEqual(self.lmp.find_compute_neighlist("xxx"),-1) From ad20e54638cfb2a70f529c56090a2c7035b50022 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 20 Jun 2022 23:19:00 -0400 Subject: [PATCH 10/20] fix typos --- tools/msi2lmp/src/msi2lmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/msi2lmp/src/msi2lmp.c b/tools/msi2lmp/src/msi2lmp.c index 87cffb4e6e..3136678023 100644 --- a/tools/msi2lmp/src/msi2lmp.c +++ b/tools/msi2lmp/src/msi2lmp.c @@ -66,9 +66,9 @@ * The program is started by supplying information at the command prompt * according to the usage described below. * -* USAGE: msi2lmp3 ROOTNAME {-print #} {-class #} {-frc FRC_FILE} {-ignore} {-nocenter} {-oldstyle} +* USAGE: msi2lmp ROOTNAME {-print #} {-class #} {-frc FRC_FILE} {-ignore} {-nocenter} {-oldstyle} * -* -- msi2lmp3 is the name of the executable +* -- msi2lmp is the name of the executable * -- ROOTNAME is the base name of the .car and .mdf files * -- all opther flags are optional and can be abbreviated (e.g. -p instead of -print) * From 7d49ad5924d3d3121983f2d57b2ac86395f0b96e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 21 Jun 2022 19:30:42 -0400 Subject: [PATCH 11/20] enable remap for restarting by default, add noremap option --- src/read_restart.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/read_restart.cpp b/src/read_restart.cpp index b42dcce1ca..a7fb5a828d 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -61,9 +61,10 @@ void ReadRestart::command(int narg, char **arg) // check for remap option - int remapflag = 0; + int remapflag = 1; if (narg == 2) { - if (strcmp(arg[1],"remap") == 0) remapflag = 1; + if (strcmp(arg[1],"noremap") == 0) remapflag = 0; + else if (strcmp(arg[1],"remap") == 0) remapflag = 1; // for backward compatibility else error->all(FLERR,"Illegal read_restart command"); } @@ -643,8 +644,7 @@ void ReadRestart::header() int dimension = read_int(); domain->dimension = dimension; if (domain->dimension == 2 && domain->zperiodic == 0) - error->all(FLERR, - "Cannot run 2d simulation with non-periodic Z dimension"); + error->all(FLERR, "Cannot run 2d simulation with non-periodic Z dimension"); // read nprocs from restart file, warn if different From b0f4ef8a39f684b5663071ad45c48b789bce723a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 21 Jun 2022 20:19:13 -0400 Subject: [PATCH 12/20] update docs for noremap option to read_restart --- doc/src/read_restart.rst | 67 ++++++++++----------- doc/utils/sphinx-config/false_positives.txt | 1 + 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/doc/src/read_restart.rst b/doc/src/read_restart.rst index 4d68167560..b593fd51ae 100644 --- a/doc/src/read_restart.rst +++ b/doc/src/read_restart.rst @@ -11,7 +11,7 @@ Syntax read_restart file flag * file = name of binary restart file to read in -* flag = remap (optional) +* flag = noremap (optional) Examples """""""" @@ -19,39 +19,36 @@ Examples .. code-block:: LAMMPS read_restart save.10000 - read_restart save.10000 remap + read_restart save.10000 noremap read_restart restart.* read_restart restart.*.mpiio - read_restart poly.*.% remap + read_restart poly.*.% noremap Description """"""""""" Read in a previously saved system configuration from a restart file. This allows continuation of a previous run. Details about what -information is stored (and not stored) in a restart file is given -below. Basically this operation will re-create the simulation box -with all its atoms and their attributes as well as some related global -settings, at the point in time it was written to the restart file by a -previous simulation. The simulation box will be partitioned into a -regular 3d grid of rectangular bricks, one per processor, based on the -number of processors in the current simulation and the settings of the +information is stored (and not stored) in a restart file is given below. +Basically this operation will re-create the simulation box with all its +atoms and their attributes as well as some related global settings, at +the point in time it was written to the restart file by a previous +simulation. The simulation box will be partitioned into a regular 3d +grid of rectangular bricks, one per processor, based on the number of +processors in the current simulation and the settings of the :doc:`processors ` command. The partitioning can later be -changed by the :doc:`balance ` or :doc:`fix balance ` commands. +changed by the :doc:`balance ` or :doc:`fix balance +` commands. .. note:: - Normally, restart files are written by the - :doc:`restart ` or :doc:`write_restart ` commands - so that all atoms in the restart file are inside the simulation box. - If this is not the case, the read_restart command will print an error - that atoms were "lost" when the file is read. This error should be - reported to the LAMMPS developers so the invalid writing of the - restart file can be fixed. If you still wish to use the restart file, - the optional *remap* flag can be appended to the read_restart command. - This should avoid the error, by explicitly remapping each atom back - into the simulation box, updating image flags for the atom - appropriately. + When restart files are read, atoms are explicitly remapped back into + the simulation box and image flags updated accordingly. In most + cases this will not make a difference since writing a restart file + will also trigger a rebuild of the neighbor lists and remapping of + atoms into the simulation box. This extra remap results in some + overhead that can be avoided by appending the optional *noremap* flag + to the read_restart command. Restart files are saved in binary format to enable exact restarts, meaning that the trajectories of a restarted run will precisely match @@ -65,7 +62,8 @@ certain settings such as those set by the :doc:`newton ` or these cases. Certain fixes will not restart exactly, though they should provide -statistically similar results. These include :doc:`fix shake ` and :doc:`fix langevin `. +statistically similar results. These include :doc:`fix shake +` and :doc:`fix langevin `. Certain pair styles will not restart exactly, though they should provide statistically similar results. This is because the forces @@ -81,18 +79,19 @@ produced the restart file, it could be a LAMMPS bug, so consider :doc:`reporting it ` if you think the behavior is a bug. Because restart files are binary, they may not be portable to other -machines. In this case, you can use the :doc:`-restart command-line switch ` to convert a restart file to a data file. +machines. In this case, you can use the :doc:`-restart command-line +switch ` to convert a restart file to a data file. -Similar to how restart files are written (see the -:doc:`write_restart ` and :doc:`restart ` -commands), the restart filename can contain two wild-card characters. -If a "\*" appears in the filename, the directory is searched for all -filenames that match the pattern where "\*" is replaced with a timestep -value. The file with the largest timestep value is read in. Thus, -this effectively means, read the latest restart file. It's useful if -you want your script to continue a run from where it left off. See -the :doc:`run ` command and its "upto" option for how to specify -the run command so it does not need to be changed either. +Similar to how restart files are written (see the :doc:`write_restart +` and :doc:`restart ` commands), the restart +filename can contain two wild-card characters. If a "\*" appears in the +filename, the directory is searched for all filenames that match the +pattern where "\*" is replaced with a timestep value. The file with the +largest timestep value is read in. Thus, this effectively means, read +the latest restart file. It's useful if you want your script to +continue a run from where it left off. See the :doc:`run ` command +and its "upto" option for how to specify the run command so it does not +need to be changed either. If a "%" character appears in the restart filename, LAMMPS expects a set of multiple files to exist. The :doc:`restart ` and diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index b42cff262a..cce6e92d05 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -2369,6 +2369,7 @@ nopreliminary Nord norder Nordlund +noremap normals normx normy From b0c673d8564629f35c1ed9de081ca1837536c83f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 21 Jun 2022 20:37:20 -0400 Subject: [PATCH 13/20] updates from Karl Hammond to adjust his email and correct an error message --- examples/COUPLE/fortran2/LAMMPS-wrapper.cpp | 4 ++-- examples/COUPLE/fortran2/LAMMPS-wrapper.h | 4 ++-- examples/COUPLE/fortran2/LAMMPS.F90 | 2 +- examples/COUPLE/fortran2/README | 5 ++--- examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp | 4 ++-- examples/COUPLE/fortran_dftb/LAMMPS-wrapper.h | 4 ++-- examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp | 4 ++-- examples/COUPLE/fortran_dftb/LAMMPS.F90 | 4 ++-- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp b/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp index 8b6a257755..b5b265b4dd 100644 --- a/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp +++ b/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp @@ -12,8 +12,8 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Karl D. Hammond - University of Tennessee, Knoxville (USA), 2012 + Contributing author: Karl D. Hammond + University of Missouri (USA), 2012 ------------------------------------------------------------------------- */ /* This is set of "wrapper" functions to assist LAMMPS.F90, which itself diff --git a/examples/COUPLE/fortran2/LAMMPS-wrapper.h b/examples/COUPLE/fortran2/LAMMPS-wrapper.h index 68e03ae05a..479af91738 100644 --- a/examples/COUPLE/fortran2/LAMMPS-wrapper.h +++ b/examples/COUPLE/fortran2/LAMMPS-wrapper.h @@ -12,8 +12,8 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Karl D. Hammond - University of Tennessee, Knoxville (USA), 2012 + Contributing author: Karl D. Hammond + University of Missouri (USA), 2012 ------------------------------------------------------------------------- */ /* This is set of "wrapper" functions to assist LAMMPS.F90, which itself diff --git a/examples/COUPLE/fortran2/LAMMPS.F90 b/examples/COUPLE/fortran2/LAMMPS.F90 index 8b74a38721..65ea83e245 100644 --- a/examples/COUPLE/fortran2/LAMMPS.F90 +++ b/examples/COUPLE/fortran2/LAMMPS.F90 @@ -1292,7 +1292,7 @@ contains !! Wrapper functions local to this module {{{1 Cname = string2Cstring (name) Ccount = size(data) / natoms if ( Ccount /= 1 .and. Ccount /= 3 ) & - call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires& + call lammps_error_all (ptr, FLERR, 'lammps_scatter_atoms requires& & count to be either 1 or 3') Fdata = data Cdata = C_loc (Fdata(1)) diff --git a/examples/COUPLE/fortran2/README b/examples/COUPLE/fortran2/README index 1710ca8ba6..0a7b862d86 100644 --- a/examples/COUPLE/fortran2/README +++ b/examples/COUPLE/fortran2/README @@ -11,9 +11,8 @@ This interface was created by Karl Hammond who you can contact with questions: Karl D. Hammond -University of Tennessee, Knoxville -karlh at ugcs.caltech.edu -karlh at utk.edu +University of Missouri +hammondkd at missouri.edu ------------------------------------- diff --git a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp index 8b6a257755..b5b265b4dd 100644 --- a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp +++ b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp @@ -12,8 +12,8 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Karl D. Hammond - University of Tennessee, Knoxville (USA), 2012 + Contributing author: Karl D. Hammond + University of Missouri (USA), 2012 ------------------------------------------------------------------------- */ /* This is set of "wrapper" functions to assist LAMMPS.F90, which itself diff --git a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.h b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.h index 7d94362436..553466d138 100644 --- a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.h +++ b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.h @@ -12,8 +12,8 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Karl D. Hammond - University of Tennessee, Knoxville (USA), 2012 + Contributing author: Karl D. Hammond + University of Missouri (USA), 2012 ------------------------------------------------------------------------- */ /* This is set of "wrapper" functions to assist LAMMPS.F90, which itself diff --git a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp index 5f94363346..605735a2b7 100644 --- a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp +++ b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp @@ -12,8 +12,8 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Karl D. Hammond - University of Tennessee, Knoxville (USA), 2012 + Contributing author: Karl D. Hammond + University of Missouri (USA), 2012 ------------------------------------------------------------------------- */ /* This is set of "wrapper" functions to assist LAMMPS.F90, which itself diff --git a/examples/COUPLE/fortran_dftb/LAMMPS.F90 b/examples/COUPLE/fortran_dftb/LAMMPS.F90 index 9b18bbfa5f..188fff9d60 100644 --- a/examples/COUPLE/fortran_dftb/LAMMPS.F90 +++ b/examples/COUPLE/fortran_dftb/LAMMPS.F90 @@ -12,8 +12,8 @@ !-------------------------------------------------------------------------- !! ------------------------------------------------------------------------ -! Contributing author: Karl D. Hammond -! University of Tennessee, Knoxville (USA), 2012 +! Contributing author: Karl D. Hammond +! University of Missouri (USA), 2012 !-------------------------------------------------------------------------- !! LAMMPS, a Fortran 2003 module containing an interface between Fortran From c0b109f715b08eb05535fcc318a0db19b7b3b06b Mon Sep 17 00:00:00 2001 From: Karl Hammond Date: Tue, 21 Jun 2022 20:53:45 -0500 Subject: [PATCH 14/20] Fixed some typos and updated e-mail addresses in examples/COUPLE/fortran2 --- examples/COUPLE/fortran2/LAMMPS-wrapper.cpp | 2 +- examples/COUPLE/fortran2/LAMMPS-wrapper.h | 2 +- examples/COUPLE/fortran2/LAMMPS.F90 | 4 ++-- examples/COUPLE/fortran2/README | 5 ++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp b/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp index 8b6a257755..fb8c67ecc9 100644 --- a/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp +++ b/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Karl D. Hammond + Contributing author: Karl D. Hammond University of Tennessee, Knoxville (USA), 2012 ------------------------------------------------------------------------- */ diff --git a/examples/COUPLE/fortran2/LAMMPS-wrapper.h b/examples/COUPLE/fortran2/LAMMPS-wrapper.h index 68e03ae05a..a1e5fcdd1f 100644 --- a/examples/COUPLE/fortran2/LAMMPS-wrapper.h +++ b/examples/COUPLE/fortran2/LAMMPS-wrapper.h @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Karl D. Hammond + Contributing author: Karl D. Hammond University of Tennessee, Knoxville (USA), 2012 ------------------------------------------------------------------------- */ diff --git a/examples/COUPLE/fortran2/LAMMPS.F90 b/examples/COUPLE/fortran2/LAMMPS.F90 index 8b74a38721..251b56f48f 100644 --- a/examples/COUPLE/fortran2/LAMMPS.F90 +++ b/examples/COUPLE/fortran2/LAMMPS.F90 @@ -1292,7 +1292,7 @@ contains !! Wrapper functions local to this module {{{1 Cname = string2Cstring (name) Ccount = size(data) / natoms if ( Ccount /= 1 .and. Ccount /= 3 ) & - call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires& + call lammps_error_all (ptr, FLERR, 'lammps_scatter_atoms requires& & count to be either 1 or 3') Fdata = data Cdata = C_loc (Fdata(1)) @@ -1355,7 +1355,7 @@ contains !! Wrapper functions local to this module {{{1 Cname = string2Cstring (name) Ccount = size(data) / ndata if ( Ccount /= 1 .and. Ccount /= 3 ) & - call lammps_error_all (ptr, FLERR, 'lammps_gather_atoms requires& + call lammps_error_all (ptr, FLERR, 'lammps_scatter_atoms requires& & count to be either 1 or 3') Fdata = data Cdata = C_loc (Fdata(1)) diff --git a/examples/COUPLE/fortran2/README b/examples/COUPLE/fortran2/README index 1710ca8ba6..0a7b862d86 100644 --- a/examples/COUPLE/fortran2/README +++ b/examples/COUPLE/fortran2/README @@ -11,9 +11,8 @@ This interface was created by Karl Hammond who you can contact with questions: Karl D. Hammond -University of Tennessee, Knoxville -karlh at ugcs.caltech.edu -karlh at utk.edu +University of Missouri +hammondkd at missouri.edu ------------------------------------- From 49331be33e4aeb89b69a2056b26bfdc82ada6e46 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 22 Jun 2022 07:05:30 -0400 Subject: [PATCH 15/20] simplify --- examples/COUPLE/fortran2/LAMMPS-wrapper.cpp | 1 + examples/COUPLE/fortran2/Makefile | 2 +- examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp b/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp index b5b265b4dd..1301bfe348 100644 --- a/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp +++ b/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp @@ -23,6 +23,7 @@ #include #include "LAMMPS-wrapper.h" +#define LAMMPS_LIB_MPI 1 #include #include #include diff --git a/examples/COUPLE/fortran2/Makefile b/examples/COUPLE/fortran2/Makefile index fe66914892..f8a2126233 100644 --- a/examples/COUPLE/fortran2/Makefile +++ b/examples/COUPLE/fortran2/Makefile @@ -14,7 +14,7 @@ CXXLIB = -lstdc++ # replace with your C++ runtime libs # Flags for Fortran compiler, C++ compiler, and C preprocessor, respectively FFLAGS = -O2 -fPIC CXXFLAGS = -O2 -fPIC -CPPFLAGS = -DOMPI_SKIP_MPICXX=1 -DMPICH_SKIP_MPICXX -DLAMMPS_LIB_MPI +CPPFLAGS = -DOMPI_SKIP_MPICXX=1 -DMPICH_SKIP_MPICXX all : liblammps_fortran.a liblammps_fortran.so diff --git a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp index b5b265b4dd..1301bfe348 100644 --- a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp +++ b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp @@ -23,6 +23,7 @@ #include #include "LAMMPS-wrapper.h" +#define LAMMPS_LIB_MPI 1 #include #include #include From 37f056c45590d63005f495c1cdbf0a5d89454ec2 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 22 Jun 2022 07:06:00 -0400 Subject: [PATCH 16/20] get array and vector sizes from the avaiable APIs --- examples/COUPLE/fortran2/LAMMPS-wrapper.cpp | 177 ++---------------- .../COUPLE/fortran_dftb/LAMMPS-wrapper.cpp | 177 ++---------------- 2 files changed, 36 insertions(+), 318 deletions(-) diff --git a/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp b/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp index 1301bfe348..eb6f421606 100644 --- a/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp +++ b/examples/COUPLE/fortran2/LAMMPS-wrapper.cpp @@ -57,181 +57,40 @@ void lammps_error_all (void *ptr, const char *file, int line, const char *str) int lammps_extract_compute_vectorsize (void *ptr, char *id, int style) { - class LAMMPS *lmp = (class LAMMPS *) ptr; - int icompute = lmp->modify->find_compute(id); - if ( icompute < 0 ) return 0; - class Compute *compute = lmp->modify->compute[icompute]; - - if ( style == 0 ) - { - if ( !compute->vector_flag ) - return 0; - else - return compute->size_vector; - } - else if ( style == 1 ) - { - return lammps_get_natoms (ptr); - } - else if ( style == 2 ) - { - if ( !compute->local_flag ) - return 0; - else - return compute->size_local_rows; - } - else - return 0; + int *size; + size = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_VECTOR); + if (size) return *size; + return 0; } void lammps_extract_compute_arraysize (void *ptr, char *id, int style, int *nrows, int *ncols) { - class LAMMPS *lmp = (class LAMMPS *) ptr; - int icompute = lmp->modify->find_compute(id); - if ( icompute < 0 ) - { - *nrows = 0; - *ncols = 0; - } - class Compute *compute = lmp->modify->compute[icompute]; - - if ( style == 0 ) - { - if ( !compute->array_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = compute->size_array_rows; - *ncols = compute->size_array_cols; - } - } - else if ( style == 1 ) - { - if ( !compute->peratom_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = lammps_get_natoms (ptr); - *ncols = compute->size_peratom_cols; - } - } - else if ( style == 2 ) - { - if ( !compute->local_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = compute->size_local_rows; - *ncols = compute->size_local_cols; - } - } - else - { - *nrows = 0; - *ncols = 0; - } - + int *tmp; + tmp = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_ROWS); + if (tmp) *nrows = *tmp; + tmp = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_COLS); + if (tmp) *ncols = *tmp; return; } int lammps_extract_fix_vectorsize (void *ptr, char *id, int style) { - class LAMMPS *lmp = (class LAMMPS *) ptr; - int ifix = lmp->modify->find_fix(id); - if ( ifix < 0 ) return 0; - class Fix *fix = lmp->modify->fix[ifix]; - - if ( style == 0 ) - { - if ( !fix->vector_flag ) - return 0; - else - return fix->size_vector; - } - else if ( style == 1 ) - { - return lammps_get_natoms (ptr); - } - else if ( style == 2 ) - { - if ( !fix->local_flag ) - return 0; - else - return fix->size_local_rows; - } - else - return 0; + int *size; + size = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_VECTOR, 0, 0); + if (size) return *size; + return 0; } void lammps_extract_fix_arraysize (void *ptr, char *id, int style, int *nrows, int *ncols) { - class LAMMPS *lmp = (class LAMMPS *) ptr; - int ifix = lmp->modify->find_fix(id); - if ( ifix < 0 ) - { - *nrows = 0; - *ncols = 0; - } - class Fix *fix = lmp->modify->fix[ifix]; - - if ( style == 0 ) - { - if ( !fix->array_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = fix->size_array_rows; - *ncols = fix->size_array_cols; - } - } - else if ( style == 1 ) - { - if ( !fix->peratom_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = lammps_get_natoms (ptr); - *ncols = fix->size_peratom_cols; - } - } - else if ( style == 2 ) - { - if ( !fix->local_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = fix->size_local_rows; - *ncols = fix->size_local_cols; - } - } - else - { - *nrows = 0; - *ncols = 0; - } - + int *tmp; + tmp = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_ROWS, 0, 0); + if (tmp) *nrows = *tmp; + tmp = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_COLS, 0, 0); + if (tmp) *ncols = *tmp; return; - } /* vim: set ts=3 sts=3 expandtab: */ diff --git a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp index 1301bfe348..eb6f421606 100644 --- a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp +++ b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper.cpp @@ -57,181 +57,40 @@ void lammps_error_all (void *ptr, const char *file, int line, const char *str) int lammps_extract_compute_vectorsize (void *ptr, char *id, int style) { - class LAMMPS *lmp = (class LAMMPS *) ptr; - int icompute = lmp->modify->find_compute(id); - if ( icompute < 0 ) return 0; - class Compute *compute = lmp->modify->compute[icompute]; - - if ( style == 0 ) - { - if ( !compute->vector_flag ) - return 0; - else - return compute->size_vector; - } - else if ( style == 1 ) - { - return lammps_get_natoms (ptr); - } - else if ( style == 2 ) - { - if ( !compute->local_flag ) - return 0; - else - return compute->size_local_rows; - } - else - return 0; + int *size; + size = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_VECTOR); + if (size) return *size; + return 0; } void lammps_extract_compute_arraysize (void *ptr, char *id, int style, int *nrows, int *ncols) { - class LAMMPS *lmp = (class LAMMPS *) ptr; - int icompute = lmp->modify->find_compute(id); - if ( icompute < 0 ) - { - *nrows = 0; - *ncols = 0; - } - class Compute *compute = lmp->modify->compute[icompute]; - - if ( style == 0 ) - { - if ( !compute->array_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = compute->size_array_rows; - *ncols = compute->size_array_cols; - } - } - else if ( style == 1 ) - { - if ( !compute->peratom_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = lammps_get_natoms (ptr); - *ncols = compute->size_peratom_cols; - } - } - else if ( style == 2 ) - { - if ( !compute->local_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = compute->size_local_rows; - *ncols = compute->size_local_cols; - } - } - else - { - *nrows = 0; - *ncols = 0; - } - + int *tmp; + tmp = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_ROWS); + if (tmp) *nrows = *tmp; + tmp = (int *) lammps_extract_compute(ptr, id, style, LMP_SIZE_COLS); + if (tmp) *ncols = *tmp; return; } int lammps_extract_fix_vectorsize (void *ptr, char *id, int style) { - class LAMMPS *lmp = (class LAMMPS *) ptr; - int ifix = lmp->modify->find_fix(id); - if ( ifix < 0 ) return 0; - class Fix *fix = lmp->modify->fix[ifix]; - - if ( style == 0 ) - { - if ( !fix->vector_flag ) - return 0; - else - return fix->size_vector; - } - else if ( style == 1 ) - { - return lammps_get_natoms (ptr); - } - else if ( style == 2 ) - { - if ( !fix->local_flag ) - return 0; - else - return fix->size_local_rows; - } - else - return 0; + int *size; + size = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_VECTOR, 0, 0); + if (size) return *size; + return 0; } void lammps_extract_fix_arraysize (void *ptr, char *id, int style, int *nrows, int *ncols) { - class LAMMPS *lmp = (class LAMMPS *) ptr; - int ifix = lmp->modify->find_fix(id); - if ( ifix < 0 ) - { - *nrows = 0; - *ncols = 0; - } - class Fix *fix = lmp->modify->fix[ifix]; - - if ( style == 0 ) - { - if ( !fix->array_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = fix->size_array_rows; - *ncols = fix->size_array_cols; - } - } - else if ( style == 1 ) - { - if ( !fix->peratom_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = lammps_get_natoms (ptr); - *ncols = fix->size_peratom_cols; - } - } - else if ( style == 2 ) - { - if ( !fix->local_flag ) - { - *nrows = 0; - *ncols = 0; - } - else - { - *nrows = fix->size_local_rows; - *ncols = fix->size_local_cols; - } - } - else - { - *nrows = 0; - *ncols = 0; - } - + int *tmp; + tmp = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_ROWS, 0, 0); + if (tmp) *nrows = *tmp; + tmp = (int *) lammps_extract_fix(ptr, id, style, LMP_SIZE_COLS, 0, 0); + if (tmp) *ncols = *tmp; return; - } /* vim: set ts=3 sts=3 expandtab: */ From 2fb36084625933d9544681becc550d52f9402432 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 22 Jun 2022 07:06:16 -0400 Subject: [PATCH 17/20] update/correct contact info --- examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp | 3 +-- examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp index 605735a2b7..44d7b5bca4 100644 --- a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp +++ b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.cpp @@ -12,8 +12,7 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Karl D. Hammond - University of Missouri (USA), 2012 + Contributing author: Nir Goldman, LLNL , 2016 ------------------------------------------------------------------------- */ /* This is set of "wrapper" functions to assist LAMMPS.F90, which itself diff --git a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.h b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.h index ed79015e78..d3705179ed 100644 --- a/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.h +++ b/examples/COUPLE/fortran_dftb/LAMMPS-wrapper2.h @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------ - Contributing author: Nir Goldman, ngoldman@llnl.gov, Oct. 19th, 2016 + Contributing author: Nir Goldman, LLNL , 2016 ------------------------------------------------------------------------- */ /* This is set of "wrapper" functions to assist LAMMPS.F90, which itself From 9b8c19c1a5846db7a04c8d70b6e8f74720390da6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 22 Jun 2022 10:24:56 -0400 Subject: [PATCH 18/20] correct docs about how to get synchronized timings --- doc/src/Speed_measure.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/src/Speed_measure.rst b/doc/src/Speed_measure.rst index 1daf49f4c4..888e8d9790 100644 --- a/doc/src/Speed_measure.rst +++ b/doc/src/Speed_measure.rst @@ -42,5 +42,4 @@ inaccurate relative timing data, because processors have to wait when communication occurs for other processors to catch up. Thus the reported times for "Communication" or "Other" may be higher than they really are, due to load-imbalance. If this is an issue, you can -uncomment the MPI_Barrier() lines in src/timer.cpp, and re-compile -LAMMPS, to obtain synchronized timings. +use the :doc:`timer sync ` command to obtain synchronized timings. From c5999df3039a4921f978993c06ed3df09dabf66c Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 22 Jun 2022 10:32:03 -0400 Subject: [PATCH 19/20] remove dead code and silence compiler warning about it --- src/EXTRA-COMPUTE/compute_stress_cartesian.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp index f873c70bae..2dde2397db 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp @@ -266,7 +266,7 @@ void ComputeStressCartesian::compute_array() Pair *pair = force->pair; double **cutsq = force->pair->cutsq; - double xi1, xi2, xj1, xj2; + double xi1, xi2; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; @@ -305,9 +305,6 @@ void ComputeStressCartesian::compute_array() } } } - xj1 = x[j][dir1]; - xj2 = x[j][dir2]; - delx = x[j][0] - xtmp; dely = x[j][1] - ytmp; delz = x[j][2] - ztmp; From 1099199e9303107eee6d2e7649fcaf57165c20f8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 22 Jun 2022 14:22:23 -0400 Subject: [PATCH 20/20] remove any remap related documentation. add paragraph about file compatibility --- doc/src/read_restart.rst | 55 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/doc/src/read_restart.rst b/doc/src/read_restart.rst index b593fd51ae..f3065a2a5c 100644 --- a/doc/src/read_restart.rst +++ b/doc/src/read_restart.rst @@ -11,7 +11,6 @@ Syntax read_restart file flag * file = name of binary restart file to read in -* flag = noremap (optional) Examples """""""" @@ -19,10 +18,8 @@ Examples .. code-block:: LAMMPS read_restart save.10000 - read_restart save.10000 noremap read_restart restart.* read_restart restart.*.mpiio - read_restart poly.*.% noremap Description """"""""""" @@ -40,20 +37,21 @@ processors in the current simulation and the settings of the changed by the :doc:`balance ` or :doc:`fix balance ` commands. -.. note:: - - When restart files are read, atoms are explicitly remapped back into - the simulation box and image flags updated accordingly. In most - cases this will not make a difference since writing a restart file - will also trigger a rebuild of the neighbor lists and remapping of - atoms into the simulation box. This extra remap results in some - overhead that can be avoided by appending the optional *noremap* flag - to the read_restart command. - Restart files are saved in binary format to enable exact restarts, meaning that the trajectories of a restarted run will precisely match those produced by the original run had it continued on. +The binary restart file format was not designed with backward, forward, +or cross-platform compatibility in mind, so the files are only expected +to be read correctly by the same LAMMPS executable on the same platform. +Changes to the architecture, compilation settings, or LAMMPS version can +render a restart file unreadable or it may read the data incorrectly. +If you want a more portable format, you can use the data file format as +created by the :doc:`write_data ` command. Binary restart +files can also be converted into a data file from the command line by +the LAMMPS executable that wrote them using the :ref:`-restart2data +` command line flag. + Several things can prevent exact restarts due to round-off effects, in which case the trajectories in the 2 runs will slowly diverge. These include running on a different number of processors or changing @@ -221,17 +219,17 @@ its calculations in a consistent manner. .. note:: - There are a handful of commands which can be used before or - between runs which may require a system initialization. Examples - include the "balance", "displace_atoms", "delete_atoms", "set" (some - options), and "velocity" (some options) commands. This is because - they can migrate atoms to new processors. Thus they will also discard - unused "state" information from fixes. You will know the discard has + There are a handful of commands which can be used before or between + runs which may require a system initialization. Examples include the + "balance", "displace_atoms", "delete_atoms", "set" (some options), + and "velocity" (some options) commands. This is because they can + migrate atoms to new processors. Thus they will also discard unused + "state" information from fixes. You will know the discard has occurred because a list of discarded fixes will be printed to the screen and log file, as explained above. This means that if you wish to retain that info in a restarted run, you must re-specify the - relevant fixes and computes (which create fixes) before those commands - are used. + relevant fixes and computes (which create fixes) before those + commands are used. Some pair styles, like the :doc:`granular pair styles `, also use a fix to store "state" information that persists from timestep to @@ -244,18 +242,19 @@ LAMMPS allows bond interactions (angle, etc) to be turned off or deleted in various ways, which can affect how their info is stored in a restart file. -If bonds (angles, etc) have been turned off by the :doc:`fix shake ` or :doc:`delete_bonds ` command, -their info will be written to a restart file as if they are turned on. -This means they will need to be turned off again in a new run after -the restart file is read. +If bonds (angles, etc) have been turned off by the :doc:`fix shake +` or :doc:`delete_bonds ` command, their info +will be written to a restart file as if they are turned on. This means +they will need to be turned off again in a new run after the restart +file is read. Bonds that are broken (e.g. by a bond-breaking potential) are written to the restart file as broken bonds with a type of 0. Thus these bonds will still be broken when the restart file is read. -Bonds that have been broken by the :doc:`fix bond/break ` command have disappeared from the -system. No information about these bonds is written to the restart -file. +Bonds that have been broken by the :doc:`fix bond/break +` command have disappeared from the system. No +information about these bonds is written to the restart file. ----------