From 92dc854ed48c555b1fc7d382a2ca7acf3c795b66 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 8 Aug 2022 15:27:52 -0400 Subject: [PATCH 01/12] workaround for IBM's XLClang compiler --- src/fmt/format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fmt/format.h b/src/fmt/format.h index 0bd2fdb182..2a43b3d366 100644 --- a/src/fmt/format.h +++ b/src/fmt/format.h @@ -389,7 +389,8 @@ class uint128_fallback { hi_ += (lo_ < n ? 1 : 0); return *this; } -#if FMT_HAS_BUILTIN(__builtin_addcll) +// LAMMPS customization: XLCClang does not support __builtin_addcll() +#if FMT_HAS_BUILTIN(__builtin_addcll) && !(defined(__xlc__) && defined(__clang__)) unsigned long long carry; lo_ = __builtin_addcll(lo_, n, 0, &carry); hi_ += carry; From f7b0cb3bd4006b9536b2022838a42465ba260976 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 8 Aug 2022 15:31:45 -0400 Subject: [PATCH 02/12] AMOEBA induce bugfixes --- src/AMOEBA/amoeba_induce.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AMOEBA/amoeba_induce.cpp b/src/AMOEBA/amoeba_induce.cpp index c1c2cb1d51..7434c57e27 100644 --- a/src/AMOEBA/amoeba_induce.cpp +++ b/src/AMOEBA/amoeba_induce.cpp @@ -369,7 +369,8 @@ void PairAmoeba::induce() eps = DEBYE * sqrt(eps/atom->natoms); if (eps < poleps) done = true; - if (eps > epsold) done = true; + // also commented out in induce.f of Tinker + // if (eps > epsold) done = true; if (iter >= politer) done = true; // apply a "peek" iteration to the mutual induced dipoles @@ -390,7 +391,7 @@ void PairAmoeba::induce() // terminate the calculation if dipoles failed to converge // NOTE: could make this an error - if (iter >= maxiter || eps > epsold) + if (iter >= politer || eps > epsold) if (comm->me == 0) error->warning(FLERR,"AMOEBA induced dipoles did not converge"); } From 7e0cad7d9e602b6b223b02e1b5ad0954ec3d84db Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 8 Aug 2022 15:40:19 -0400 Subject: [PATCH 03/12] import fix from upstream --- src/fmt/format.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fmt/format.h b/src/fmt/format.h index 2a43b3d366..5483e00676 100644 --- a/src/fmt/format.h +++ b/src/fmt/format.h @@ -389,12 +389,11 @@ class uint128_fallback { hi_ += (lo_ < n ? 1 : 0); return *this; } -// LAMMPS customization: XLCClang does not support __builtin_addcll() -#if FMT_HAS_BUILTIN(__builtin_addcll) && !(defined(__xlc__) && defined(__clang__)) +#if FMT_HAS_BUILTIN(__builtin_addcll) && !defined(__ibmxl__) unsigned long long carry; lo_ = __builtin_addcll(lo_, n, 0, &carry); hi_ += carry; -#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) +#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !defined(__ibmxl__) unsigned long long result; auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result); lo_ = result; From 247a2b12b3b805742043079354523ea7e0bc81ef Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 9 Aug 2022 14:30:44 -0400 Subject: [PATCH 04/12] use utils::inumeric() instead of atoi() (not for parsing environment variables yet) --- src/KOKKOS/kokkos.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 10e64f0bd6..7e637788ec 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -116,7 +116,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) while (iarg < narg) { if (strcmp(arg[iarg],"d") == 0 || strcmp(arg[iarg],"device") == 0) { if (iarg+2 > narg) error->all(FLERR,"Invalid Kokkos command-line args"); - device = atoi(arg[iarg+1]); + device = utils::inumeric(FLERR, arg[iarg+1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg],"g") == 0 || @@ -125,11 +125,11 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) error->all(FLERR,"GPUs are requested but Kokkos has not been compiled using a GPU-enabled backend"); #endif if (iarg+2 > narg) error->all(FLERR,"Invalid Kokkos command-line args"); - ngpus = atoi(arg[iarg+1]); + ngpus = utils::inumeric(FLERR, arg[iarg+1], false, lmp); int skip_gpu = 9999; if (iarg+2 < narg && isdigit(arg[iarg+2][0])) { - skip_gpu = atoi(arg[iarg+2]); + skip_gpu = utils::inumeric(FLERR, arg[iarg+2], false, lmp); iarg++; } iarg += 2; @@ -173,7 +173,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) } else if (strcmp(arg[iarg],"t") == 0 || strcmp(arg[iarg],"threads") == 0) { - nthreads = atoi(arg[iarg+1]); + nthreads = utils::inumeric(FLERR, arg[iarg+1], false, lmp); if (nthreads <= 0) error->all(FLERR,"Invalid number of threads requested for Kokkos: must be 1 or greater"); @@ -182,19 +182,20 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) } else if (strcmp(arg[iarg],"n") == 0 || strcmp(arg[iarg],"numa") == 0) { - numa = atoi(arg[iarg+1]); + numa = utils::inumeric(FLERR, arg[iarg+1], false, lmp); iarg += 2; - } else error->all(FLERR,"Invalid Kokkos command-line args"); + } else error->all(FLERR,"Invalid Kokkos command-line arg: {}", arg[iarg]); } // Initialize Kokkos. However, we cannot change any // Kokkos library parameters after the first initalization if (args.num_threads != -1) { - if (args.num_threads != nthreads || args.num_numa != numa || args.device_id != device) + if ((args.num_threads != nthreads) || (args.num_numa != numa) || (args.device_id != device)) if (me == 0) - error->warning(FLERR,"Kokkos package already initalized, cannot reinitialize with different parameters"); + error->warning(FLERR,"Kokkos package already initalized, " + "cannot reinitialize with different parameters"); nthreads = args.num_threads; numa = args.num_numa; device = args.device_id; @@ -206,8 +207,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) init_ngpus = ngpus; } - if (me == 0) - utils::logmesg(lmp, " will use up to {} GPU(s) per node\n",ngpus); + if (me == 0) utils::logmesg(lmp, " will use up to {} GPU(s) per node\n", ngpus); #ifdef LMP_KOKKOS_GPU if (ngpus <= 0) From ba7507c9e5235d3e9007793c70b72cd124ca32dd Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 9 Aug 2022 14:47:58 -0400 Subject: [PATCH 05/12] small tweaks --- src/compute_pair_local.cpp | 2 +- src/reader_xyz.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compute_pair_local.cpp b/src/compute_pair_local.cpp index 708b31c370..3176bb667b 100644 --- a/src/compute_pair_local.cpp +++ b/src/compute_pair_local.cpp @@ -68,7 +68,7 @@ ComputePairLocal::ComputePairLocal(LAMMPS *lmp, int narg, char **arg) : pstyle[nvalues++] = DZ; else if (arg[iarg][0] == 'p') { int n = atoi(&arg[iarg][1]); - if (n <= 0) error->all(FLERR, "Invalid keyword in compute pair/local command"); + if (n <= 0) error->all(FLERR, "Invalid keyword {} in compute pair/local command", arg[iarg]); pstyle[nvalues] = PN; pindex[nvalues++] = n - 1; diff --git a/src/reader_xyz.cpp b/src/reader_xyz.cpp index 1f379bc0dd..7add54fdb9 100644 --- a/src/reader_xyz.cpp +++ b/src/reader_xyz.cpp @@ -179,8 +179,7 @@ void ReaderXYZ::read_atoms(int n, int nfield, double **fields) ++nid; rv = sscanf(line,"%*s%lg%lg%lg", &myx, &myy, &myz); - if (rv != 3) - error->one(FLERR,"Dump file is incorrectly formatted"); + if (rv != 3) error->one(FLERR,"Dump file is incorrectly formatted"); // XXX: we could insert an element2type translation here // XXX: for now we flag unrecognized types as type 0, From 5c589dbe20aafdb3818b297884aadf7a8781ef1d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 9 Aug 2022 15:52:47 -0400 Subject: [PATCH 06/12] add -nonbuf / -nb command line flag to disable buffering for screen and logfile --- doc/src/Run_options.rst | 18 ++++++++++++++++++ src/lammps.cpp | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/doc/src/Run_options.rst b/doc/src/Run_options.rst index ceae464a59..cfeecb10f0 100644 --- a/doc/src/Run_options.rst +++ b/doc/src/Run_options.rst @@ -14,6 +14,7 @@ letter abbreviation can be used: * :ref:`-m or -mpicolor ` * :ref:`-c or -cite ` * :ref:`-nc or -nocite ` +* :ref:`-nb or -nonbuf ` * :ref:`-pk or -package ` * :ref:`-p or -partition ` * :ref:`-pl or -plog ` @@ -257,6 +258,23 @@ Disable generating a citation reminder (see above) at all. ---------- +.. _nonbuf: + +**-nonbuf** + +Turn off buffering for screen and logfile output. For performance +reasons, output to the screen and logfile is usually buffered, i.e. +output is only generated if a buffer - typically 4096 bytes - has been +filled. However, when LAMMPS crashes, that can mean that there is +important output missing. When using this flag, this buffering is +turned off (only for screen and logfile output). Note that when running +in parallel with MPI, the screen output may still be buffered by the MPI +library which cannot be changed by LAMMPS. This flag should only be +used for debugging and not for production simulations as the performance +impact can be significant, especially for large parallel runs. + +---------- + .. _package: **-package style args ....** diff --git a/src/lammps.cpp b/src/lammps.cpp index e78f9e2019..418a740808 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -196,6 +196,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : int citelogfile = CiteMe::VERBOSE; char *citefile = nullptr; int helpflag = 0; + int nonbufflag = 0; suffix = suffix2 = suffixp = nullptr; suffix_enable = 0; @@ -298,6 +299,11 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : citeflag = 0; iarg++; + } else if (strcmp(arg[iarg],"-nonbuf") == 0 || + strcmp(arg[iarg],"-nb") == 0) { + nonbufflag = 1; + iarg++; + } else if (strcmp(arg[iarg],"-package") == 0 || strcmp(arg[iarg],"-pk") == 0) { if (iarg+2 > narg) @@ -520,7 +526,6 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : utils::flush_buffers(this); } - // universe is one or more worlds, as setup by partition switch // split universe communicator into separate world communicators // set world screen, logfile, communicator, infile @@ -540,6 +545,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : screen = fopen(str.c_str(),"w"); if (screen == nullptr) error->one(FLERR,"Cannot open screen file {}: {}",str,utils::getsyserror()); + setvbuf(screen, NULL, _IONBF, 0); } else if (strcmp(arg[screenflag],"none") == 0) { screen = nullptr; } else { @@ -563,6 +569,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : logfile = fopen(str.c_str(),"w"); if (logfile == nullptr) error->one(FLERR,"Cannot open logfile {}: {}",str, utils::getsyserror()); + setbuf(logfile, NULL); } else if (strcmp(arg[logflag],"none") == 0) { logfile = nullptr; } else { @@ -587,6 +594,15 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : } } + // make all screen and logfile output unbuffered for debugging crashes + + if (nonbufflag) { + if (universe->uscreen) setbuf(universe->uscreen, nullptr); + if (universe->ulogfile) setbuf(universe->ulogfile, nullptr); + if (screen) setbuf(screen, nullptr); + if (logfile) setbuf(logfile, nullptr); + } + // screen and logfile messages for universe and world if ((universe->me == 0) && (!helpflag)) { From 111caac960fd1bf72dbe15e6921859586d4621a7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 9 Aug 2022 16:11:09 -0400 Subject: [PATCH 07/12] remove references to Numeric module. we only support numpy. --- tools/python/pizza/dump.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tools/python/pizza/dump.py b/tools/python/pizza/dump.py index 6224192093..bd93d8ee95 100644 --- a/tools/python/pizza/dump.py +++ b/tools/python/pizza/dump.py @@ -189,12 +189,7 @@ import sys, re, glob, types from os import popen from math import * # any function could be used by set() -try: - import numpy as np - oldnumeric = False -except: - import Numeric as np - oldnumeric = True +import numpy as np try: from DEFAULTS import PIZZA_GUNZIP except: PIZZA_GUNZIP = "gunzip" @@ -379,10 +374,7 @@ class dump: for i in range(1,snap.natoms): words += f.readline().decode().split() floats = map(float,words) - if oldnumeric: - atom_data = np.array(list(floats),np.Float) - else: - atom_data = np.array(list(floats),np.float) + atom_data = np.array(list(floats),np.float) snap.atoms = atom_data.reshape((snap.natoms, ncol)) else: @@ -858,8 +850,7 @@ class dump: self.map(ncol+1,str) for snap in self.snaps: atoms = snap.atoms - if oldnumeric: newatoms = np.zeros((snap.natoms,ncol+1),np.Float) - else: newatoms = np.zeros((snap.natoms,ncol+1),np.float) + newatoms = np.zeros((snap.natoms,ncol+1),np.float) newatoms[:,0:ncol] = snap.atoms snap.atoms = newatoms @@ -1018,8 +1009,7 @@ class dump: # convert values to int and absolute value since can be negative types - if oldnumeric: bondlist = np.zeros((nbonds,4),np.Int) - else: bondlist = np.zeros((nbonds,4),np.int) + bondlist = np.zeros((nbonds,4),np.int) ints = [abs(int(value)) for value in words] start = 0 stop = 4 From c8b6b052fcda48399041c5790ad9d6339d02fb6e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 9 Aug 2022 16:51:00 -0400 Subject: [PATCH 08/12] port sorting by time to python 3 while retaining compatibility with 2.7 --- tools/python/pizza/dump.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/python/pizza/dump.py b/tools/python/pizza/dump.py index bd93d8ee95..01685cf582 100644 --- a/tools/python/pizza/dump.py +++ b/tools/python/pizza/dump.py @@ -194,6 +194,21 @@ import numpy as np try: from DEFAULTS import PIZZA_GUNZIP except: PIZZA_GUNZIP = "gunzip" +# -------------------------------------------------------------------- +# wrapper to convert old style comparision function to key function + +def cmp2key(oldcmp): + class keycmp: + def __init__(self, obj, *args): + self.obj = obj + def __lt__(self, other): + return oldcmp(self.obj,other.obj) < 0 + def __gt__(self, other): + return oldcmp(self.obj,other.obj) > 0 + def __eq__(self, other): + return oldcmp(self.obj,other.obj) == 0 + return keycmp + # Class definition class dump: @@ -255,7 +270,7 @@ class dump: # sort entries by timestep, cull duplicates - self.snaps.sort(self.compare_time) + self.snaps.sort(key=cmp2key(self.compare_time)) self.cull() self.nsnaps = len(self.snaps) print("read %d snapshots" % self.nsnaps) From 6eb51a68d9f047d9427d801e69bc24a0335702db Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 9 Aug 2022 16:49:44 -0400 Subject: [PATCH 09/12] move dump command after reset_timestep to avoid crash --- examples/neb/in.neb.sivac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/neb/in.neb.sivac b/examples/neb/in.neb.sivac index 941d063b90..7a35174466 100644 --- a/examples/neb/in.neb.sivac +++ b/examples/neb/in.neb.sivac @@ -57,14 +57,14 @@ variable u uloop 20 # only output atoms near vacancy -#dump events vacneigh custom 1000 dump.neb.sivac.$u id type x y z # initial minimization to relax vacancy displace_atoms all random 0.1 0.1 0.1 123456 minimize 1.0e-6 1.0e-4 1000 10000 +reset_timestep 0 -reset_timestep 0 +#dump events vacneigh custom 1000 dump.neb.sivac.$u id type x y z fix 1 all neb 1.0 From 3a4a0078cdb7a4484dbb631a1dfdd8c2f3646885 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 9 Aug 2022 16:50:16 -0400 Subject: [PATCH 10/12] whitespace --- examples/neb/in.neb.hop1 | 70 +++++++++++++++++----------------- examples/neb/in.neb.hop1.end | 60 ++++++++++++++--------------- examples/neb/in.neb.hop2 | 74 ++++++++++++++++++------------------ examples/neb/in.neb.sivac | 22 +++++------ 4 files changed, 113 insertions(+), 113 deletions(-) diff --git a/examples/neb/in.neb.hop1 b/examples/neb/in.neb.hop1 index f26b52a28a..54a22a5b87 100644 --- a/examples/neb/in.neb.hop1 +++ b/examples/neb/in.neb.hop1 @@ -1,66 +1,66 @@ # 2d NEB surface simulation, hop from surface to become adatom -dimension 2 -boundary p s p +dimension 2 +boundary p s p -atom_style atomic -neighbor 0.3 bin -neigh_modify delay 5 -atom_modify map array sort 0 0.0 +atom_style atomic +neighbor 0.3 bin +neigh_modify delay 5 +atom_modify map array sort 0 0.0 -variable u uloop 20 +variable u uloop 20 # create geometry with flat surface -lattice hex 0.9 -region box block 0 20 0 10 -0.25 0.25 +lattice hex 0.9 +region box block 0 20 0 10 -0.25 0.25 -#create_box 3 box -#create_atoms 1 box -#mass * 1.0 +#create_box 3 box +#create_atoms 1 box +#mass * 1.0 #write_data initial.hop1 read_data initial.hop1 # LJ potentials -pair_style lj/cut 2.5 -pair_coeff * * 1.0 1.0 2.5 -pair_modify shift yes +pair_style lj/cut 2.5 +pair_coeff * * 1.0 1.0 2.5 +pair_modify shift yes # initial minimization to relax surface -minimize 1.0e-6 1.0e-4 1000 10000 -reset_timestep 0 +minimize 1.0e-6 1.0e-4 1000 10000 +reset_timestep 0 # define groups -region 1 block INF INF INF 1.25 INF INF -group lower region 1 -group mobile subtract all lower -set group lower type 2 +region 1 block INF INF INF 1.25 INF INF +group lower region 1 +group mobile subtract all lower +set group lower type 2 -timestep 0.05 +timestep 0.05 # group of NEB atoms - either block or single atom ID 412 -region surround block 10 18 17 20 0 0 units box -group nebatoms region surround -#group nebatoms id 412 -set group nebatoms type 3 -group nonneb subtract all nebatoms +region surround block 10 18 17 20 0 0 units box +group nebatoms region surround +#group nebatoms id 412 +set group nebatoms type 3 +group nonneb subtract all nebatoms -fix 1 lower setforce 0.0 0.0 0.0 -fix 2 nebatoms neb 1.0 parallel ideal -fix 3 all enforce2d +fix 1 lower setforce 0.0 0.0 0.0 +fix 2 nebatoms neb 1.0 parallel ideal +fix 3 all enforce2d -thermo 100 +thermo 100 -#dump 1 nebatoms atom 10 dump.neb.$u -#dump 2 nonneb atom 10 dump.nonneb.$u +#dump 1 nebatoms atom 10 dump.neb.$u +#dump 2 nonneb atom 10 dump.nonneb.$u # run NEB for 2000 steps or to force tolerance -min_style quickmin +min_style quickmin -neb 0.0 0.1 1000 1000 100 final final.hop1 +neb 0.0 0.1 1000 1000 100 final final.hop1 diff --git a/examples/neb/in.neb.hop1.end b/examples/neb/in.neb.hop1.end index 81e5315306..c5e08b40f1 100644 --- a/examples/neb/in.neb.hop1.end +++ b/examples/neb/in.neb.hop1.end @@ -1,56 +1,56 @@ # 2d NEB surface simulation, hop from surface to become adatom -dimension 2 -boundary p s p +dimension 2 +boundary p s p -atom_style atomic -neighbor 0.3 bin -neigh_modify delay 5 -atom_modify map array sort 0 0.0 +atom_style atomic +neighbor 0.3 bin +neigh_modify delay 5 +atom_modify map array sort 0 0.0 -variable u uloop 20 +variable u uloop 20 # create geometry with flat surface -lattice hex 0.9 -region box block 0 20 0 10 -0.25 0.25 +lattice hex 0.9 +region box block 0 20 0 10 -0.25 0.25 read_data initial.hop1.end # LJ potentials -pair_style lj/cut 2.5 -pair_coeff * * 1.0 1.0 2.5 -pair_modify shift yes +pair_style lj/cut 2.5 +pair_coeff * * 1.0 1.0 2.5 +pair_modify shift yes # define groups -region 1 block INF INF INF 1.25 INF INF -group lower region 1 -group mobile subtract all lower -set group lower type 2 +region 1 block INF INF INF 1.25 INF INF +group lower region 1 +group mobile subtract all lower +set group lower type 2 -timestep 0.05 +timestep 0.05 # group of NEB atoms - either block or single atom ID 412 -region surround block 10 18 17 20 0 0 units box -group nebatoms region surround -#group nebatoms id 412 -set group nebatoms type 3 -group nonneb subtract all nebatoms +region surround block 10 18 17 20 0 0 units box +group nebatoms region surround +#group nebatoms id 412 +set group nebatoms type 3 +group nonneb subtract all nebatoms -fix 1 lower setforce 0.0 0.0 0.0 -fix 2 nebatoms neb 1.0 parallel ideal end first 1.0 -fix 3 all enforce2d +fix 1 lower setforce 0.0 0.0 0.0 +fix 2 nebatoms neb 1.0 parallel ideal end first 1.0 +fix 3 all enforce2d -thermo 100 +thermo 100 -#dump 1 nebatoms atom 10 dump.neb.$u -#dump 2 nonneb atom 10 dump.nonneb.$u +#dump 1 nebatoms atom 10 dump.neb.$u +#dump 2 nonneb atom 10 dump.nonneb.$u # run NEB for 2000 steps or to force tolerance -min_style quickmin +min_style quickmin -neb 0.0 0.1 1000 1000 100 final final.hop1 +neb 0.0 0.1 1000 1000 100 final final.hop1 diff --git a/examples/neb/in.neb.hop2 b/examples/neb/in.neb.hop2 index e69fb338cd..97512dbbf9 100644 --- a/examples/neb/in.neb.hop2 +++ b/examples/neb/in.neb.hop2 @@ -1,68 +1,68 @@ # 2d NEB surface simulation, hop of adatom on surface -dimension 2 -boundary p s p +dimension 2 +boundary p s p -atom_style atomic -neighbor 0.3 bin -neigh_modify delay 5 -atom_modify map array sort 0 0.0 +atom_style atomic +neighbor 0.3 bin +neigh_modify delay 5 +atom_modify map array sort 0 0.0 -variable u uloop 20 +variable u uloop 20 # create geometry with adatom -lattice hex 0.9 -region box block 0 20 0 11 -0.25 0.25 -region box1 block 0 20 0 10 -0.25 0.25 +lattice hex 0.9 +region box block 0 20 0 11 -0.25 0.25 +region box1 block 0 20 0 10 -0.25 0.25 -#create_box 3 box -#create_atoms 1 region box1 -#create_atoms 1 single 11.5 10.5 0 -#mass * 1.0 +#create_box 3 box +#create_atoms 1 region box1 +#create_atoms 1 single 11.5 10.5 0 +#mass * 1.0 #write_data initial.hop2 read_data initial.hop2 # LJ potentials -pair_style lj/cut 2.5 -pair_coeff * * 1.0 1.0 2.5 -pair_modify shift yes +pair_style lj/cut 2.5 +pair_coeff * * 1.0 1.0 2.5 +pair_modify shift yes # initial minimization to relax surface -minimize 1.0e-6 1.0e-4 1000 10000 -reset_timestep 0 +minimize 1.0e-6 1.0e-4 1000 10000 +reset_timestep 0 # define groups -region 1 block INF INF INF 1.25 INF INF -group lower region 1 -group mobile subtract all lower -set group lower type 2 +region 1 block INF INF INF 1.25 INF INF +group lower region 1 +group mobile subtract all lower +set group lower type 2 -timestep 0.05 +timestep 0.05 # group of NEB atoms - either block or single atom ID 421 -region surround block 10 18 17 21 0 0 units box -group nebatoms region surround -#group nebatoms id 421 -set group nebatoms type 3 -group nonneb subtract all nebatoms +region surround block 10 18 17 21 0 0 units box +group nebatoms region surround +#group nebatoms id 421 +set group nebatoms type 3 +group nonneb subtract all nebatoms -fix 1 lower setforce 0.0 0.0 0.0 -fix 2 nebatoms neb 1.0 -fix 3 all enforce2d +fix 1 lower setforce 0.0 0.0 0.0 +fix 2 nebatoms neb 1.0 +fix 3 all enforce2d -thermo 100 +thermo 100 -#dump 1 nebatoms atom 10 dump.neb.$u -#dump 2 nonneb atom 10 dump.nonneb.$u +#dump 1 nebatoms atom 10 dump.neb.$u +#dump 2 nonneb atom 10 dump.nonneb.$u # run NEB for 2000 steps or to force tolerance -min_style fire +min_style fire -neb 0.0 0.05 1000 1000 100 final final.hop2 +neb 0.0 0.05 1000 1000 100 final final.hop2 diff --git a/examples/neb/in.neb.sivac b/examples/neb/in.neb.sivac index 7a35174466..22492328c6 100644 --- a/examples/neb/in.neb.sivac +++ b/examples/neb/in.neb.sivac @@ -5,7 +5,7 @@ units metal atom_style atomic atom_modify map array boundary p p p -atom_modify sort 0 0.0 +atom_modify sort 0 0.0 # coordination number cutoff @@ -45,7 +45,7 @@ group Si type 1 group del id 300 delete_atoms group del compress no group vacneigh id 174 175 301 304 306 331 337 - + # choose potential pair_style sw @@ -53,26 +53,26 @@ pair_coeff * * Si.sw Si # set up neb run -variable u uloop 20 - -# only output atoms near vacancy - +variable u uloop 20 # initial minimization to relax vacancy displace_atoms all random 0.1 0.1 0.1 123456 -minimize 1.0e-6 1.0e-4 1000 10000 +minimize 1.0e-6 1.0e-4 1000 10000 + reset_timestep 0 +# only output atoms near vacancy + #dump events vacneigh custom 1000 dump.neb.sivac.$u id type x y z -fix 1 all neb 1.0 +fix 1 all neb 1.0 -thermo 100 +thermo 100 # run NEB for 2000 steps or to force tolerance timestep 0.01 -min_style quickmin +min_style quickmin -neb 0.0 0.01 100 100 10 final final.sivac +neb 0.0 0.01 100 100 10 final final.sivac From 631f33feb594f40eaed11d5c7eee613b4f0db88f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 10 Aug 2022 06:57:59 -0400 Subject: [PATCH 11/12] remove redundant calls --- src/lammps.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lammps.cpp b/src/lammps.cpp index 418a740808..b7318b9b55 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -545,7 +545,6 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : screen = fopen(str.c_str(),"w"); if (screen == nullptr) error->one(FLERR,"Cannot open screen file {}: {}",str,utils::getsyserror()); - setvbuf(screen, NULL, _IONBF, 0); } else if (strcmp(arg[screenflag],"none") == 0) { screen = nullptr; } else { @@ -569,7 +568,6 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : logfile = fopen(str.c_str(),"w"); if (logfile == nullptr) error->one(FLERR,"Cannot open logfile {}: {}",str, utils::getsyserror()); - setbuf(logfile, NULL); } else if (strcmp(arg[logflag],"none") == 0) { logfile = nullptr; } else { From e592f0f139e82012ad3b864f3a04e3c633401ce6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 10 Aug 2022 07:03:57 -0400 Subject: [PATCH 12/12] clarify the function of -nonbuf a bit more --- doc/src/Run_options.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/src/Run_options.rst b/doc/src/Run_options.rst index cfeecb10f0..d2d7f8c155 100644 --- a/doc/src/Run_options.rst +++ b/doc/src/Run_options.rst @@ -264,12 +264,13 @@ Disable generating a citation reminder (see above) at all. Turn off buffering for screen and logfile output. For performance reasons, output to the screen and logfile is usually buffered, i.e. -output is only generated if a buffer - typically 4096 bytes - has been -filled. However, when LAMMPS crashes, that can mean that there is -important output missing. When using this flag, this buffering is -turned off (only for screen and logfile output). Note that when running -in parallel with MPI, the screen output may still be buffered by the MPI -library which cannot be changed by LAMMPS. This flag should only be +output is only written to a file if its buffer - typically 4096 bytes - +has been filled. When LAMMPS crashes for some reason, however, that can +mean that there is important output missing. With this flag the +buffering can be turned off (only for screen and logfile output) and any +output will be committed immediately. Note that when running in +parallel with MPI, the screen output may still be buffered by the MPI +library and this cannot be changed by LAMMPS. This flag should only be used for debugging and not for production simulations as the performance impact can be significant, especially for large parallel runs.