From f8a0ff011b4f7bbddb66f7a1499da98021508375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 23 Apr 2025 00:02:25 +0200 Subject: [PATCH 01/14] Skeleton implementation of fix ave/moments --- src/EXTRA-FIX/fix_ave_moments.cpp | 555 ++++++++++++++++++++++++++++++ src/EXTRA-FIX/fix_ave_moments.h | 78 +++++ 2 files changed, 633 insertions(+) create mode 100644 src/EXTRA-FIX/fix_ave_moments.cpp create mode 100644 src/EXTRA-FIX/fix_ave_moments.h diff --git a/src/EXTRA-FIX/fix_ave_moments.cpp b/src/EXTRA-FIX/fix_ave_moments.cpp new file mode 100644 index 0000000000..901b59d949 --- /dev/null +++ b/src/EXTRA-FIX/fix_ave_moments.cpp @@ -0,0 +1,555 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Sebastian Huetter (OvGU) +------------------------------------------------------------------------- */ + +#include "fix_ave_moments.h" + +#include "arg_info.h" +#include "compute.h" +#include "error.h" +#include "input.h" +#include "memory.h" +#include "modify.h" +#include "update.h" +#include "variable.h" + +#include + +using namespace LAMMPS_NS; +using namespace FixConst; + +enum { MEAN, STDDEV, VARIANCE, SKEW, KURTOSIS }; + +/* ---------------------------------------------------------------------- */ + +FixAveMoments::FixAveMoments(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), nvalues(0), result_list(nullptr), window_list(nullptr) +{ + // this fix's data is always accessible (but might be meaningless) + global_freq = 1; + dynamic_group_allow = 1; + time_depend = 1; + + // EXAMPLE: + // fix ID group-ID ave/moments Nevery Nrepeat Nfreq value1 ... valueN moment1 ... momentM keyword value ... + + // the first six arguments are fixed & need at least one input and moment + const int nfixedargs = 6; + if (narg < nfixedargs + 2) utils::missing_cmd_args(FLERR, "fix ave/moments", error); + + nevery = utils::inumeric(FLERR,arg[3],false,lmp); + nrepeat = utils::inumeric(FLERR,arg[4],false,lmp); + nfreq = utils::inumeric(FLERR,arg[5],false,lmp); + + // scan values to count them + + nvalues = 0; + // first input name is position after the fixed args + int iarg = nfixedargs; + while (iarg < narg) { + if (utils::strmatch(arg[iarg],"^[cfv]_")) { + nvalues++; + iarg++; + } else break; + } + if (nvalues == 0) + error->all(FLERR, nfixedargs, + "No values from computes, fixes, or variables used in fix ave/moments command"); + + // next, the moments + iarg = consume_moments(iarg, narg, arg); + if (moments.empty()) + error->all(FLERR, nfixedargs, + "No values from computes, fixes, or variables used in fix ave/moments command"); + + // parse optional keywords which must follow the data + + options(iarg,narg,arg); + + // expand args if any have wildcard character "*" + // this can reset nvalues + + int expand = 0; + char **earg; + int *amap = nullptr; + nvalues = utils::expand_args(FLERR, nvalues, &arg[nfixedargs], /* mode=scalar */ 0, earg, lmp, &amap); + + if (earg != &arg[nfixedargs]) expand = 1; + arg = earg; + + // parse values + + values.clear(); + for (int i = 0; i < nvalues; i++) { + ArgInfo argi(arg[i]); + + value_t val; + val.keyword = arg[i]; + val.which = argi.get_type(); + + val.argindex = argi.get_index1(); + val.iarg = (expand ? amap[i] : i) + nfixedargs; + val.varlen = 0; + val.id = argi.get_name(); + val.val.c = nullptr; + + if ((val.which == ArgInfo::NONE) || (val.which == ArgInfo::UNKNOWN) || (argi.get_dim() > 1)) + error->all(FLERR, val.iarg, "Invalid fix ave/moments argument: {}", arg[i]); + + values.push_back(val); + } + if (nvalues != (int)values.size()) + error->all(FLERR, Error::NOPOINTER, + "Could not parse value data consistently for fix ave/moments"); + + // setup and error check + // for fix inputs, check that fix frequency is acceptable + + if (nevery <= 0) error->all(FLERR, 3, "Illegal fix ave/moments nevery value: {}", nevery); + if (nrepeat <= 0) error->all(FLERR, 4, "Illegal fix ave/moments nrepeat value: {}", nrepeat); + if (nfreq <= 0) error->all(FLERR, 5, "Illegal fix ave/moments nfreq value: {}", nfreq); + + for (auto &val : values) { + switch (val.which) { + case ArgInfo::COMPUTE: + val.val.c = modify->get_compute_by_id(val.id); + if (!val.val.c) + error->all(FLERR, val.iarg, "Compute ID {} for fix ave/moments does not exist", val.id); + if (val.argindex == 0 && (val.val.c->scalar_flag == 0)) + error->all(FLERR, val.iarg, "Fix ave/moments compute {} does not calculate a scalar", val.id); + if (val.argindex && (val.val.c->vector_flag == 0)) + error->all(FLERR, val.iarg, "Fix ave/moments compute {} does not calculate a vector", val.id); + if (val.argindex && (val.argindex > val.val.c->size_vector) && + (val.val.c->size_vector_variable == 0)) + error->all(FLERR, val.iarg, "Fix ave/moments compute {} vector is accessed out-of-range{}", + val.id, utils::errorurl(20)); + if (val.argindex && val.val.c->size_vector_variable) val.varlen = 1; + break; + + case ArgInfo::FIX: + val.val.f = modify->get_fix_by_id(val.id); + if (!val.val.f) error->all(FLERR,"Fix ID {} for fix ave/moments does not exist", val.id); + if ((val.argindex == 0) && (val.val.f->scalar_flag == 0)) + error->all(FLERR, val.iarg, "Fix ave/moments fix {} does not calculate a scalar", val.id); + if (val.argindex && (val.val.f->vector_flag == 0)) + error->all(FLERR, val.iarg, "Fix ave/moments fix {} does not calculate a vector", val.id); + if (val.argindex && (val.val.f->size_vector_variable)) + error->all(FLERR, val.iarg, "Fix ave/moments fix {} vector cannot be variable length", val.id); + if (val.argindex && (val.argindex > val.val.f->size_vector)) + error->all(FLERR, val.iarg, "Fix ave/moments fix {} vector is accessed out-of-range{}", + val.id, utils::errorurl(20)); + if (nevery % val.val.f->global_freq) + error->all(FLERR, val.iarg, "Fix {} for fix ave/moments not computed at compatible time{}", + val.id, utils::errorurl(7)); + break; + + case ArgInfo::VARIABLE: + int ivariable = input->variable->find(val.id.c_str()); + if (ivariable < 0) + error->all(FLERR, val.iarg, "Variable name {} for fix ave/moments does not exist", val.id); + if ((val.argindex == 0) && (input->variable->equalstyle(ivariable) == 0)) + error->all(FLERR, val.iarg, "Fix ave/moments variable {} is not equal-style variable", val.id); + if ((val.argindex) && (input->variable->vectorstyle(ivariable) == 0)) + error->all(FLERR, val.iarg, "Fix ave/moments variable {} is not vector-style variable", + val.id); + break; + } + } + + // if wildcard expansion occurred, free earg memory from expand_args() + // wait to do this until after file comment lines are printed + + if (expand) { + for (int i = 0; i < nvalues; i++) delete[] earg[i]; + memory->sfree(earg); + memory->sfree(amap); + } + + // allocate memory for averaging + + window_list = nullptr; + result_list = nullptr; + + // one window of nvalues columns and nrepeat rows (=all scalars of one value are consecutive) + memory->create(window_list, nvalues, nrepeat, "ave/moments:window_list"); + for (int i = 0; i < nvalues; i++) + for (int j = 0; j < nrepeat; j++) + window_list[i][j] = 0.0; + + // this fix produces a global vector and array + + vector_flag = 1; + size_vector = nvalues*moments.size(); + array_flag = 1; + size_array_rows = size_vector; + size_array_cols = nhistory; + + // produce nmoments outputs per value with nhistory depth + memory->create(result_list, nhistory, size_vector, "ave/moments:result_list"); + for (int i = 0; i < nhistory; i++) + for (int j = 0; j < size_vector; j++) + result_list[i][j] = 0.0; + + // intensive/extensive flags set by compute,fix,variable that produces value + + extvector = -1; + extarray = -2; + extlist = new int[size_vector]; + int extvalue = 0; + int i = 0; + for (auto &val : values) { + switch (val.which) { + case ArgInfo::COMPUTE: + if (val.argindex == 0) extvalue = val.val.c->extscalar; + else if (val.val.f->extvector >= 0) extvalue = val.val.c->extvector; + else extvalue = val.val.c->extlist[val.argindex-1]; + break; + + case ArgInfo::FIX: + if (val.argindex == 0) extvalue = val.val.f->extscalar; + else if (val.val.f->extvector >= 0) extvalue = val.val.f->extvector; + else extvalue = val.val.f->extlist[val.argindex-1]; + break; + + case ArgInfo::VARIABLE: + extvalue = 0; + break; + } + if (extvalue == -1) + error->all(FLERR, Error::NOLASTLINE, "Fix ave/moments cannot set output array " + "intensive/extensive from these inputs"); + if (extarray < -1) extarray = extvalue; + else if (extvalue != extarray) + error->all(FLERR, Error::NOLASTLINE, "Fix ave/moments cannot set output array " + "intensive/extensive from these inputs"); + for (int j=0; jaddstep_compute_all(nvalid); +} + +/* ---------------------------------------------------------------------- */ + +FixAveMoments::~FixAveMoments() +{ + values.clear(); + moments.clear(); + delete[] extlist; + + memory->destroy(window_list); + memory->destroy(result_list); +} + +/* ---------------------------------------------------------------------- */ + +int FixAveMoments::setmask() +{ + int mask = 0; + mask |= END_OF_STEP; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixAveMoments::init() +{ + // update indices/pointers for all computes,fixes,variables + + for (auto &val : values) { + switch (val.which) { + case ArgInfo::COMPUTE: + val.val.c = modify->get_compute_by_id(val.id); + if (!val.val.c) + error->all(FLERR, Error::NOLASTLINE, "Compute ID {} for fix ave/moments does not exist", + val.id); + break; + + case ArgInfo::FIX: + val.val.f = modify->get_fix_by_id(val.id); + if (!val.val.f) + error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for fix ave/moments does not exist", val.id); + break; + + case ArgInfo::VARIABLE: + val.val.v = input->variable->find(val.id.c_str()); + if (val.val.v < 0) + error->all(FLERR, Error::NOLASTLINE, "Variable name {} for fix ave/moments does not exist", + val.id); + break; + } + } + + // need to reset nvalid if nvalid < ntimestep b/c minimize was performed + + if (nvalid < update->ntimestep) { + setnextvalid(); + modify->addstep_compute_all(nvalid); + } +} + +/* ---------------------------------------------------------------------- + only does something if nvalid = current timestep +------------------------------------------------------------------------- */ + +void FixAveMoments::setup(int /*vflag*/) +{ + end_of_step(); +} + +/* ---------------------------------------------------------------------- */ + +void FixAveMoments::end_of_step() +{ + // skip if not step which requires doing something + + bigint ntimestep = update->ntimestep; + if (ntimestep != nvalid) return; + + // always take new values + append_values(); + + // if window boundary reached, do a compute, otherwise just schedule next take + if (ntimestep == nvalid_comp_next) { + update_results(); + setnextvalid(); + } else { + nvalid += nevery; + } + + modify->addstep_compute(nvalid); +} + +/* ---------------------------------------------------------------------- + return scalar value +------------------------------------------------------------------------- */ + +double FixAveMoments::compute_scalar() +{ + return 0.0; +} + +/* ---------------------------------------------------------------------- + return Ith vector value +------------------------------------------------------------------------- */ + +double FixAveMoments::compute_vector(int i) +{ + return compute_array(i, 0); +} + +/* ---------------------------------------------------------------------- + return I,J array value +------------------------------------------------------------------------- */ + +double FixAveMoments::compute_array(int i, int j) +{ + if (i >= moments.size()) return 0.0; + if (j >= nhistory) return 0.0; + int row = (iresult - 1 - j + nhistory) % nhistory; + if (row >= nhistory) return 0.0; + return result_list[row][i]; +} + +/* ---------------------------------------------------------------------- + parse moment names +------------------------------------------------------------------------- */ + +int FixAveMoments::consume_moments(int iarg, int narg, char **arg) +{ + moments.clear(); + + while (iarg < narg) { + if (strcmp(arg[iarg],"mean") == 0) + moments.push_back(MEAN); + else if (strcmp(arg[iarg],"stddev") == 0) + moments.push_back(STDDEV); + else if (strcmp(arg[iarg],"variance") == 0) + moments.push_back(VARIANCE); + else if (strcmp(arg[iarg],"skew") == 0) + moments.push_back(SKEW); + else if (strcmp(arg[iarg],"kurtosis") == 0) + moments.push_back(KURTOSIS); + else + break; + iarg++; + } + return iarg; +} + +/* ---------------------------------------------------------------------- + parse optional args +------------------------------------------------------------------------- */ + +void FixAveMoments::options(int iarg, int narg, char **arg) +{ + // option defaults + + nhistory = 1; + startstep = 0; + + // optional args + + while (iarg < narg) { + if (strcmp(arg[iarg],"history") == 0) { + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/moments history", error); + nhistory = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (nhistory <= 0) + error->all(FLERR, iarg+2, "Illegal ave/moments history argument {}; must be > 0", + nhistory); + iarg += 2; + } else if (strcmp(arg[iarg],"start") == 0) { + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/moments start", error); + startstep = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + iarg += 2; + } else error->all(FLERR,"Unknown fix ave/moments keyword {}", arg[iarg]); + } +} + +/* ---------------------------------------------------------------------- + return next timestep no earlier than `after`, rounded to next + multiple of freq +------------------------------------------------------------------------- */ + +bigint next_after(const bigint ts, const bigint after, const int freq) +{ + if (ts >= after) return ts; + return ts + ((after - ts) / freq + 1) * freq; +} + +/* ---------------------------------------------------------------------- + calculate nvalid = next step on which end_of_step does something + this is either a step to take data + or a step to take and compute the values (nfreq multiple) + startstep is lower bound on nfreq multiple +------------------------------------------------------------------------- */ + +void FixAveMoments::setnextvalid() +{ + bigint ntimestep = update->ntimestep; + + if (nvalid_comp_next > ntimestep) { + // next window end boundary is still in the future, just increment + nvalid = ntimestep + nevery; + return; + } + + // get next window end first + bigint next_comp = (ntimestep/nfreq)*nfreq + nfreq; + nvalid_comp_next = next_after(next_comp, startstep, nfreq); + + // from there, calculate the first time we have to take a value + bigint ntake = nvalid_comp_next - static_cast(nrepeat-1)*nevery; + nvalid = next_after(ntake, ntimestep, nevery); +} + +/* ---------------------------------------------------------------------- */ + +void FixAveMoments::get_values(std::vector& scalars) +{ + // accumulate results of computes,fixes,variables to local copy + int i = 0; + double scalar = 0.0; + for (auto &val : values) { + switch (val.which) { + case ArgInfo::COMPUTE: + // invoke compute if not previously invoked + // ensure no out-of-range access to variable-length compute vector + if (val.argindex == 0) { + if (!(val.val.c->invoked_flag & Compute::INVOKED_SCALAR)) { + val.val.c->compute_scalar(); + val.val.c->invoked_flag |= Compute::INVOKED_SCALAR; + } + scalar = val.val.c->scalar; + } else { + if (!(val.val.c->invoked_flag & Compute::INVOKED_VECTOR)) { + val.val.c->compute_vector(); + val.val.c->invoked_flag |= Compute::INVOKED_VECTOR; + } + if (val.varlen && (val.val.c->size_vector < val.argindex)) scalar = 0.0; + else scalar = val.val.c->vector[val.argindex-1]; + } + break; + + case ArgInfo::FIX: + // access fix fields, guaranteed to be ready + if (val.argindex == 0) + scalar = val.val.f->compute_scalar(); + else + scalar = val.val.f->compute_vector(val.argindex-1); + break; + + case ArgInfo::VARIABLE: + // evaluate equal-style or vector-style variable + // if index exceeds vector length, use a zero value + // this can be useful if vector length is not known a priori + if (val.argindex == 0) + scalar = input->variable->compute_equal(val.val.v); + else { + double *varvec; + int nvec = input->variable->compute_vector(val.val.v,&varvec); + if (val.argindex > nvec) scalar = 0.0; + else scalar = varvec[val.argindex-1]; + } + break; + } + + scalars[i] = scalar; + ++i; + } +} + +/* ---------------------------------------------------------------------- */ + +void FixAveMoments::append_values() +{ + // accumulate results of computes,fixes,variables to local copy + // compute/fix/variable may invoke computes so wrap with clear/add + + modify->clearstep_compute(); + + std::vector scalars(nvalues); + get_values(scalars); + + // transpose for faster access later + for (int i=0; i= nrepeat) { + window_filled = 1; + iwindow = 0; + } +} + +void FixAveMoments::update_results() +{ +} diff --git a/src/EXTRA-FIX/fix_ave_moments.h b/src/EXTRA-FIX/fix_ave_moments.h new file mode 100644 index 0000000000..30b3565ac8 --- /dev/null +++ b/src/EXTRA-FIX/fix_ave_moments.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS +// clang-format off +FixStyle(ave/moments,FixAveMoments); +// clang-format on +#else + +#ifndef LMP_FIX_AVE_MOMENTS_H +#define LMP_FIX_AVE_MOMENTS_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixAveMoments : public Fix { + public: + FixAveMoments(class LAMMPS *, int, char **); + ~FixAveMoments() override; + int setmask() override; + void init() override; + void setup(int) override; + void end_of_step() override; + double compute_scalar() override; + double compute_vector(int) override; + double compute_array(int, int) override; + + private: + struct value_t { + int which; // type of data: COMPUTE, FIX, VARIABLE + int argindex; // 1-based index if data is vector, else 0 + int iarg; // argument index in original argument list + int varlen; // 1 if value is from variable-length compute + std::string id; // compute/fix/variable ID + std::string keyword; // column keyword in output + union { + class Compute *c; + class Fix *f; + int v; + } val; + }; + std::vector values; + std::vector moments; + + int nrepeat, nfreq; + int nvalues; + bigint nvalid, nvalid_comp_next; + + int startstep; + + int nhistory, iresult; + double **result_list; + + int iwindow, window_filled; + double **window_list; + + int consume_moments(int iarg, int narg, char **arg); + void options(int, int, char **); + void setnextvalid(); + + void get_values(std::vector& scalars); + void append_values(); + void update_results(); +}; +} // namespace LAMMPS_NS +#endif +#endif From b2001e999c4c34d2eebcf8aeefec65b561b4d633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Thu, 1 May 2025 16:48:03 +0200 Subject: [PATCH 02/14] Implement moments calculation fix ave/moments --- src/EXTRA-FIX/fix_ave_moments.cpp | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/EXTRA-FIX/fix_ave_moments.cpp b/src/EXTRA-FIX/fix_ave_moments.cpp index 901b59d949..8f64cc973d 100644 --- a/src/EXTRA-FIX/fix_ave_moments.cpp +++ b/src/EXTRA-FIX/fix_ave_moments.cpp @@ -22,6 +22,7 @@ #include "compute.h" #include "error.h" #include "input.h" +#include "math_special.h" #include "memory.h" #include "modify.h" #include "update.h" @@ -31,6 +32,8 @@ using namespace LAMMPS_NS; using namespace FixConst; +using MathSpecial::square; +using MathSpecial::cube; enum { MEAN, STDDEV, VARIANCE, SKEW, KURTOSIS }; @@ -552,4 +555,80 @@ void FixAveMoments::append_values() void FixAveMoments::update_results() { + const int count = window_filled ? nrepeat : iwindow; + // Delay until we can safely do all moments. Avoids branching in the hot loop. + if (count<3) return; + + double *result = result_list[iresult]; + + // zero out previous values + + for (int i = 0; i < size_vector; i++) + result[i] = 0.0; + + const double inv_n = 1.0 / count; + const double fk2 = (double)count / (count - 1); + const double fk3 = square((double)count) / ((count - 1) * (count - 2)); + const double np1_nm3 = (count+1.0)/(count-3.0); + const double _3_nm1_nm3 = 3.0 * (count-1.0)/(count-3.0); + + // Each value is a series that can be processed individually + for (int i = 0; i < nvalues; i++) { + const double* series = window_list[i]; + + // first pass: mean + double mean = 0.0; + for (int j = 0; j= nhistory) + iresult = 0; } From 565e7b2c2b3702f5cbf780819b4c54c4cc99d310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Fri, 2 May 2025 00:13:28 +0200 Subject: [PATCH 03/14] Add documentation for ave/moments --- doc/src/Commands_fix.rst | 1 + doc/src/fix.rst | 1 + doc/src/fix_ave_moments.rst | 268 ++++++++++++++++++++ doc/utils/sphinx-config/false_positives.txt | 3 + 4 files changed, 273 insertions(+) create mode 100644 doc/src/fix_ave_moments.rst diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index 35c3804969..0c8d04c97a 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -26,6 +26,7 @@ OPT. * :doc:`ave/chunk ` * :doc:`ave/correlate ` * :doc:`ave/correlate/long ` + * :doc:`ave/moments ` * :doc:`ave/grid ` * :doc:`ave/histo ` * :doc:`ave/histo/weight ` diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 3b1bc4a75c..27cc9525e5 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -205,6 +205,7 @@ accelerated styles exist. * :doc:`ave/chunk ` - compute per-chunk time-averaged quantities * :doc:`ave/correlate ` - compute/output time correlations * :doc:`ave/correlate/long ` - alternative to :doc:`ave/correlate ` that allows efficient calculation over long time windows +* :doc:`ave/moments ` - compute moments of scalar quantities * :doc:`ave/grid ` - compute per-grid time-averaged quantities * :doc:`ave/histo ` - compute/output time-averaged histograms * :doc:`ave/histo/weight ` - weighted version of fix ave/histo diff --git a/doc/src/fix_ave_moments.rst b/doc/src/fix_ave_moments.rst new file mode 100644 index 0000000000..9ea7e758e9 --- /dev/null +++ b/doc/src/fix_ave_moments.rst @@ -0,0 +1,268 @@ +.. index:: fix ave/moments + +fix ave/moments command +======================= + +Syntax +"""""" + +.. code-block:: LAMMPS + + fix ID group-ID ave/moments Nevery Nrepeat Nfreq value1 value2 ... moment1 moment2 ... keyword args ... + +* ID, group-ID are documented in :doc:`fix ` command +* ave/moments = style name of this fix command +* Nevery = use input values every this many time steps +* Nrepeat = # of times to use input values for calculating averages +* Nfreq = calculate averages every this many time steps +* one or more input variables can be listed +* value = v_name + + .. parsed-literal:: + + c_ID = global scalar calculated by a compute with ID + c_ID[I] = Ith component of global vector calculated by a compute with ID, I can include wildcard (see below) + f_ID = global scalar calculated by a fix with ID + f_ID[I] = Ith component of global vector calculated by a fix with ID, I can include wildcard (see below) + v_name = value calculated by an equal-style variable with name + v_name[I] = value calculated by a vector-style variable with name, I can include wildcard (see below) + +* one or more moments to compute can be listed +* moment = *mean* or *stddev* or *variance* or *skew* or *kurtosis*, see exact definitions below. +* zero or more keyword/arg pairs may be appended +* keyword = *start* or *delay* + + .. parsed-literal:: + + *start* args = Nstart + Nstart = invoke first after this time step + *history* args = Ndelay + Ndelay = keep a history of up to Ndelay invocations + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all ave/moments 1 1000 100 v_volume mean sttdev + fix 1 all ave/moments 1 200 1000 v_volume variance kurtosis history 10 + +Description +""""""""""" + +Using one or more variables as input every few time steps, calculate the +moments of the underlying distribution based on the samples collected over +a time step window. The definitions of the moments calculated are given below. + +The group specified with this command is ignored. However, note that +specified values may represent calculations performed by computes and +fixes which store their own "group" definitions. + +Each listed value can be the result of a :doc:`compute ` or +:doc:`fix ` or the evaluation of an equal-style or vector-style +:doc:`variable `. In each case, the compute, fix, or variable must +produce a global quantity, quantity, not a per-atom or local quantity. +If you wish to spatial- or time-average or histogram per-atom quantities +from a compute, fix, or variable, then see the :doc:`fix ave/chunk `, +:doc:`fix ave/atom `, or :doc:`fix ave/histo ` commands. +If you wish to sum a per-atom quantity into a single global quantity, see the +:doc:`compute reduce ` command. + +:doc:`Computes ` that produce global quantities are those which +do not have the word *atom* in their style name. Only a few +:doc:`fixes ` produce global quantities. See the doc pages for +individual fixes for info on which ones produce such values. +:doc:`Variables ` of style *equal* and *vector* are the only +ones that can be used with this fix. Variables of style *atom* cannot +be used, since they produce per-atom values. + +The input values must all be scalars or vectors with a bracketed term appended, +indicating the :math:`I^\text{th}` value of the vector is used. + +The result of this fix can be accessed as a vector, containing the interleaved +moments of each input in order. The first requested moment of input 1 +has index 1, the second index 2, the first of input 2 has index 3 +and so on. + +---------- + +For input values from a compute or fix or variable, the bracketed +index I can be specified using a wildcard asterisk with the index to +effectively specify multiple values. This takes the form "\*" or +"\*n" or "m\*" or "m\*n". If :math:`N` is the size of the vector (for *mode* = +scalar) or the number of columns in the array (for *mode* = vector), +then an asterisk with no numeric values means all indices from 1 to :math:`N`. +A leading asterisk means all indices from 1 to n (inclusive). A trailing +asterisk means all indices from n to :math:`N` (inclusive). A middle asterisk +means all indices from m to n (inclusive). + +Using a wildcard is the same as if the individual elements of the +vector or columns of the array had been listed one by one. For examples, see the +description of this capability in :doc:`fix ave/time `. + +---------- + +The :math:`N_\text{every}`, :math:`N_\text{repeat}`, and :math:`N_\text{freq}` +arguments specify on what time steps the input values will be used in order to +contribute to the average. The final statistics are generated on +time steps that are a multiple of :math:`N_\text{freq}`\ . The average is over +a window of up to :math:`N_\text{repeat}` quantities, computed in the preceding +portion of the simulation every :math:`N_\text{every}` time steps. + +The values need not have any special relation: it is valid to have a window +larger than :math:`N_\text{freq}` as well as the other way around. +For example, if :math:`N_\text{freq}=100` and :math:`N_\text{repeat}=5` (and +:math:`N_\text{every}=1`), then values from time steps 96, 97, 98, 99, and 100 +will be used. This means some intervening time steps do not contribute to the result. +If :math:`N_\text{freq}=5` and :math:`N_\text{repeat}=10`, then values will +first be calculated on step 5 from steps 1-5, on step 10 from 1-10, on +step 15 from 5-15 and so on, forming a rolling average. + +---------- + +If a value begins with "c\_", a compute ID must follow which has been +previously defined in the input script. If no bracketed term is appended, +the global scalar calculated by the compute is used. If a bracketed term is +appended, the Ith element of the global vector calculated by the compute is used. +See the discussion above for how I can be specified with a wildcard +asterisk to effectively specify multiple values. + +If a value begins with "f\_", a fix ID must follow which has been +previously defined in the input script. If no bracketed term is appended, +the global scalar calculated by the fix is used. If a bracketed term is +appended, the Ith element of the global vector calculated by the fix is used. +See the discussion above for how I can be specified with a wildcard asterisk to +effectively specify multiple values. + +Note that some fixes only produce their values on certain time steps, +which must be compatible with *Nevery*, else an error will result. +Users can also write code for their own fix styles and :doc:`add them to LAMMPS `. + +If a value begins with "v\_", a variable name must follow which has +been previously defined in the input script. Only equal-style or vector-style +variables can be used, which both produce global values. Vector-style +variables require a bracketed term to specify the Ith element of the +vector calculated by the variable. + +Note that variables of style *equal* and *vector* define a formula +which can reference individual atom properties or thermodynamic +keywords, or they can invoke other computes, fixes, or variables when +they are evaluated, so this is a very general means of specifying +quantities to time average. + +---------- + +The moments are output in the order requested in the arguments following the last +input. Any number and order of moments can be specified, although it does not make +much sense to specify the same moment multiple times. All moments are computed in +terms of corrected sample (not population) cumulants :math:`k_{1..4}` (see +:ref:`(Cramer)`), the standardized moments follow :ref:`(Joanes)`. + +For *mean*, the arithmetic mean :math:`\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i` is calculated. + +For *variance*, the Bessel-corrected sample variance +:math:`var = k_2 = \frac{1}{n - 1} \sum_{i=1}^{n} (x_i - \bar{x})^2` is calculated. + +For *stddev*, the Bessel-corrected sample standard deviation +:math:`stddev = \sqrt{k_2}` is calculated. + +For *skew*, the adjusted Fisher--Pearson standardized moment +:math:`G_1 = \frac{k_3}{k_2^{3/2}} = \frac{k_3}{stddev^3}` is calculated. + +For *kurtosis*, the adjusted Fisher--Pearson standardized moment +:math:`G_2 = \frac{k_4}{k_2^2}` is calculated. + +---------- + +Fix invocation and output can be modified by optional keywords. + +The *start* keyword specifies that the first invocation should be no earlier than +the step number given (but will still occur on a multiple of *Nfreq*). +The default is step 0. Often input values can be 0.0 at time 0, so setting +*start* to a larger value can avoid including a 0.0 in a longer series. + +The *history* allows keeping a record of previous results. By default, only +the most recent invocation is accessible. + +For example, this will output values which are delayed by 10 invocations, +meaning 10000 time steps: + +.. code-block:: LAMMPS + + fix 1 all ave/moments 1 200 1000 v_volume mean history 10 + +The previous results can be accessed by additional rows on the fix output +array, containing the N-th last evaluation result. For example, the most recent +result of the first input value would be accessed as "f_name[1][1]", +"f_name[1][4]" is the 4th most recent and so on. Vector access is always the +same as the first array row, corresponding to the most recent result. + +This fix can be used in conjunction with :doc:`fix halt ` to stop +a run automatically if a quantity is converged to within some limit: + +.. code-block:: LAMMPS + + variable target equal etot + fix aveg all ave/moments 1 200 1000 v_target mean stddev history 10 + variable stopcond equal "abs(f_aveg[1]-f_aveg[1][10])`. + +This fix produces a global vector and global array which can be accessed +by various :doc:`output commands `. +The values can be accessed on any time step, but may not be current. + +A vector is produced with # of elements = number of moments * number of inputs. +The moments are output in the order given on fix definition. An array is +produced having # of rows = value of *history* and # of columns = same as +vector output, using the same ordering. + +Each element can be either "intensive" or "extensive", depending on whether +the values contributing to the element are "intensive" or "extensive". If a +compute or fix provides the value being time averaged, then the compute or +fix determines whether the value is intensive or extensive; see the page +for that compute or fix for further info. Values produced by a variable +are treated as intensive. + +No parameter of this fix can be used with the *start/stop* keywords of +the :doc:`run ` command. This fix is not invoked during +:doc:`energy minimization `. + +Restrictions +"""""""""""" + +This compute is part of the EXTRA-FIX package. It is only enabled if +LAMMPS was built with that package. See the +:doc:`Build package ` page for more info. + +Related commands +"""""""""""""""" + +:doc:`fix ave/time `, + +Default +""""""" + +The option defaults are history = 1, start = 0. + +---------- + +.. _Cramer1: + +**(Cramer)** Cramer, Mathematical Methods of Statistics, Princeton University Press (1946). + +.. _Joanes1: + +**(Joanes)** Joanes, Gill, The Statistician, 47, 183--189 (1998). diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index cf90ce802d..cdad93d55e 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -626,6 +626,7 @@ cp cpp cpu cradius +Cramer createatoms createAtoms CreateIDs @@ -666,6 +667,7 @@ cuFFT CuH Cui Cummins +cumulants Cundall cundall Curk @@ -1761,6 +1763,7 @@ jik JIK jku jN +Joanes Joannopoulos Jochim Jonsson From edb060ccf5db65ba011fc542f50ee526e2980a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Thu, 1 May 2025 16:43:45 +0200 Subject: [PATCH 04/14] Add examples and expected output for ave/moments --- examples/PACKAGES/moments/in.converge | 35 ++++ examples/PACKAGES/moments/in.simple | 27 +++ examples/PACKAGES/moments/in.valtest | 28 +++ .../moments/log.02May2025.converge.g++.1 | 171 +++++++++++++++++ .../moments/log.02May2025.converge.g++.4 | 171 +++++++++++++++++ .../moments/log.02May2025.simple.g++.1 | 177 ++++++++++++++++++ .../moments/log.02May2025.simple.g++.4 | 177 ++++++++++++++++++ 7 files changed, 786 insertions(+) create mode 100644 examples/PACKAGES/moments/in.converge create mode 100644 examples/PACKAGES/moments/in.simple create mode 100644 examples/PACKAGES/moments/in.valtest create mode 100644 examples/PACKAGES/moments/log.02May2025.converge.g++.1 create mode 100644 examples/PACKAGES/moments/log.02May2025.converge.g++.4 create mode 100644 examples/PACKAGES/moments/log.02May2025.simple.g++.1 create mode 100644 examples/PACKAGES/moments/log.02May2025.simple.g++.4 diff --git a/examples/PACKAGES/moments/in.converge b/examples/PACKAGES/moments/in.converge new file mode 100644 index 0000000000..4c77f249c2 --- /dev/null +++ b/examples/PACKAGES/moments/in.converge @@ -0,0 +1,35 @@ +# Detect convergence in a simulation using the relative change in +# moments. This demonstrates the "history" option. +# --------------------------------------------------------------------- + +# create pure copper system +units metal +lattice fcc 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box + +timestep 0.002 +create_atoms 1 box + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) + +# compute mean and stddev over the preceding 5000 steps, every 20 steps +variable toteng equal "etotal" +fix 2 all ave/moments 10 500 200 v_toteng mean stddev history 5 + +# Convergence criterion: stddev is smaller than threshold and was previously larger +# This avoids issues with system oscillations in the order of the averaging window +# that would otherwise lead to "nodes" in the stddev. +variable conv equal "(f_2[2] < 2.0) && (f_2[2][1] < f_2[2][5])" +fix 3 all halt 100 v_conv == 1 + +thermo_style custom step temp press etotal f_2[*][1] f_2[*][5] v_conv + +thermo 100 +run 10000 + diff --git a/examples/PACKAGES/moments/in.simple b/examples/PACKAGES/moments/in.simple new file mode 100644 index 0000000000..d82b8438c6 --- /dev/null +++ b/examples/PACKAGES/moments/in.simple @@ -0,0 +1,27 @@ +# Perform a simple simulation and output the moments of the total energy +# --------------------------------------------------------------------- + +# create pure copper system +units metal +lattice fcc 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box + +timestep 0.002 +create_atoms 1 box + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) + +variable toteng equal "etotal" +fix 2 all ave/moments 5 200 100 v_toteng mean stddev variance skew kurtosis + +thermo_style custom step temp press etotal f_2[*] + +thermo 100 +run 10000 + diff --git a/examples/PACKAGES/moments/in.valtest b/examples/PACKAGES/moments/in.valtest new file mode 100644 index 0000000000..214391909b --- /dev/null +++ b/examples/PACKAGES/moments/in.valtest @@ -0,0 +1,28 @@ +# Output raw and computed data. This can be used to perform the moment +# calculation in some external tool and validate our results +# --------------------------------------------------------------------- + +# create pure copper system +units metal +lattice fcc 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box + +timestep 0.002 +create_atoms 1 box + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) + +variable toteng equal "etotal" +fix 2 all ave/moments 1 10 10 v_toteng mean variance skew kurtosis + +thermo_style custom step etotal f_2[*] +thermo_modify format float %14.8f + +thermo 1 +run 100 diff --git a/examples/PACKAGES/moments/log.02May2025.converge.g++.1 b/examples/PACKAGES/moments/log.02May2025.converge.g++.1 new file mode 100644 index 0000000000..c6781927b2 --- /dev/null +++ b/examples/PACKAGES/moments/log.02May2025.converge.g++.1 @@ -0,0 +1,171 @@ +LAMMPS (2 Apr 2025 - Development - patch_4Feb2025-645-gba166d42e1-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:99) + using 1 OpenMP thread(s) per MPI task +# create pure copper system +units metal +lattice fcc 3.75 +Lattice spacing in x,y,z = 3.75 3.75 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box +Created orthogonal box = (0 0 0) to (22.5 22.5 22.5) + 1 by 1 by 1 MPI processor grid + +timestep 0.002 +create_atoms 1 box +Created 864 atoms + using lattice units in orthogonal box = (0 0 0) to (22.5 22.5 22.5) + create_atoms CPU = 0.001 seconds + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 0.2000000000000000111 + +variable toteng equal "etotal" +fix 2 all ave/moments 10 500 200 v_toteng mean stddev history 5 + +variable conv equal "(f_2[2] < 2) && (f_2[2][1] < f_2[2][5])" +fix 3 all halt 1000 v_conv == 1 + +thermo_style custom step temp press etotal f_2[*][1] f_2[*][5] v_conv + +thermo 100 +run 10000 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.6825 + ghost atom cutoff = 8.6825 + binsize = 4.34125, bins = 6 6 6 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair eam/alloy, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.484 | 3.484 | 3.484 Mbytes + Step Temp Press TotEng f_2[1][1] f_2[2][1] f_2[1][5] f_2[2][5] v_conv + 0 1000 -107410.22 -2884.9159 0 0 0 0 0 + 100 512.04214 -124.66263 -2928.6 0 0 0 0 0 + 200 479.34328 -136.26635 -2931.3905 -2928.6251 2.1584834 0 0 0 + 300 480.05298 128.92946 -2933.9233 -2928.6251 2.1584834 0 0 0 + 400 471.83641 -29.253334 -2936.8631 -2931.3742 3.3668783 0 0 0 + 500 456.96309 -274.69336 -2939.9081 -2931.3742 3.3668783 0 0 0 + 600 450.32413 14.606227 -2942.973 -2934.277 5.0681849 0 0 0 + 700 431.71192 -45.641261 -2946.006 -2934.277 5.0681849 0 0 0 + 800 436.4217 589.91981 -2948.8885 -2937.2386 6.823233 0 0 0 + 900 407.84688 -3728.1499 -2951.6643 -2937.2386 6.823233 0 0 0 + 1000 401.69178 6695.3653 -2954.2959 -2940.1463 8.4728269 -2928.6251 2.1584834 0 + 1100 370.87469 -2294.843 -2956.9413 -2940.1463 8.4728269 -2928.6251 2.1584834 0 + 1200 375.15562 704.6568 -2959.3841 -2942.9613 10.001542 -2931.3742 3.3668783 0 + 1300 371.09077 -493.04016 -2961.6803 -2942.9613 10.001542 -2931.3742 3.3668783 0 + 1400 365.88512 490.98174 -2963.8365 -2945.6475 11.378724 -2934.277 5.0681849 0 + 1500 358.42655 -218.94911 -2965.8652 -2945.6475 11.378724 -2934.277 5.0681849 0 + 1600 329.08402 56.411923 -2967.7662 -2948.1844 12.597017 -2937.2386 6.823233 0 + 1700 317.74207 1192.918 -2969.557 -2948.1844 12.597017 -2937.2386 6.823233 0 + 1800 331.98966 -2205.7213 -2971.1465 -2950.559 13.653575 -2940.1463 8.4728269 0 + 1900 330.96814 1401.3066 -2972.6923 -2950.559 13.653575 -2940.1463 8.4728269 0 + 2000 315.41816 -909.41909 -2974.0785 -2952.7764 14.568194 -2942.9613 10.001542 0 + 2100 320.4269 1226.2006 -2975.3676 -2952.7764 14.568194 -2942.9613 10.001542 0 + 2200 302.88235 -1238.8052 -2976.5099 -2954.8327 15.341787 -2945.6475 11.378724 0 + 2300 300.4349 2667.202 -2977.5329 -2954.8327 15.341787 -2945.6475 11.378724 0 + 2400 292.94691 -5532.1854 -2978.3724 -2956.7266 15.978754 -2948.1844 12.597017 0 + 2500 286.12064 4647.3841 -2979.2217 -2956.7266 15.978754 -2948.1844 12.597017 0 + 2600 290.74305 -1950.526 -2979.9142 -2958.4592 16.485773 -2950.559 13.653575 0 + 2700 281.51347 937.60472 -2980.4808 -2958.4592 16.485773 -2950.559 13.653575 0 + 2800 279.71836 -801.62498 -2980.8899 -2960.032 16.869365 -2952.7764 14.568194 0 + 2900 277.41241 609.21495 -2981.1721 -2960.032 16.869365 -2952.7764 14.568194 0 + 3000 281.31161 -760.27203 -2981.3003 -2961.4399 17.128547 -2954.8327 15.341787 0 + 3100 284.72904 315.53038 -2981.297 -2961.4399 17.128547 -2954.8327 15.341787 0 + 3200 278.39445 516.25074 -2981.1224 -2962.6768 17.263037 -2956.7266 15.978754 0 + 3300 294.46998 -655.06212 -2980.8266 -2962.6768 17.263037 -2956.7266 15.978754 0 + 3400 290.04647 788.30424 -2980.3963 -2963.7417 17.280979 -2958.4592 16.485773 0 + 3500 283.218 -844.33188 -2979.8504 -2963.7417 17.280979 -2958.4592 16.485773 0 + 3600 288.76031 1339.2734 -2979.2382 -2964.6345 17.192698 -2960.032 16.869365 0 + 3700 289.44519 -3015.7161 -2978.5394 -2964.6345 17.192698 -2960.032 16.869365 0 + 3800 309.04206 5579.3265 -2977.8282 -2965.3649 17.01845 -2961.4399 17.128547 0 + 3900 309.34588 -4255.5213 -2977.1281 -2965.3649 17.01845 -2961.4399 17.128547 0 + 4000 305.79444 2358.1383 -2976.5251 -2965.9537 16.784519 -2962.6768 17.263037 0 + 4100 309.12957 -1401.6484 -2975.9173 -2965.9537 16.784519 -2962.6768 17.263037 0 + 4200 309.41928 1180.4111 -2975.3857 -2966.4277 16.516135 -2963.7417 17.280979 0 + 4300 299.88949 -1549.6591 -2974.927 -2966.4277 16.516135 -2963.7417 17.280979 0 + 4400 319.09918 1937.7006 -2974.5598 -2966.8138 16.232551 -2964.6345 17.192698 0 + 4500 326.48719 -1489.2073 -2974.311 -2966.8138 16.232551 -2964.6345 17.192698 0 + 4600 310.93392 37.586899 -2974.1959 -2967.1394 15.948448 -2965.3649 17.01845 0 + 4700 314.28994 317.12347 -2974.1763 -2967.1394 15.948448 -2965.3649 17.01845 0 + 4800 309.88756 -698.72705 -2974.2892 -2967.4334 15.675606 -2965.9537 16.784519 0 + 4900 309.53444 962.42921 -2974.5261 -2967.4334 15.675606 -2965.9537 16.784519 0 + 5000 316.06666 -1869.3275 -2974.8492 -2967.7182 15.421633 -2966.4277 16.516135 0 + 5100 304.82485 4042.6797 -2975.2715 -2967.7182 15.421633 -2966.4277 16.516135 0 + 5200 307.75342 -5058.4814 -2975.7195 -2969.5853 13.236776 -2966.8138 16.232551 0 + 5300 298.83511 3096.4566 -2976.3329 -2969.5853 13.236776 -2966.8138 16.232551 0 + 5400 296.85413 -1929.1654 -2976.8797 -2971.2747 11.121537 -2967.1394 15.948448 0 + 5500 295.88343 1449.3005 -2977.4488 -2971.2747 11.121537 -2967.1394 15.948448 0 + 5600 305.59328 -1504.0321 -2977.9573 -2972.77 9.1579616 -2967.4334 15.675606 0 + 5700 293.40683 2579.0134 -2978.4364 -2972.77 9.1579616 -2967.4334 15.675606 0 + 5800 297.93644 -2742.705 -2978.8276 -2974.0625 7.4101102 -2967.7182 15.421633 0 + 5900 290.39408 1189.4042 -2979.2224 -2974.0625 7.4101102 -2967.7182 15.421633 0 + 6000 293.73148 -232.54292 -2979.503 -2975.1594 5.8959922 -2969.5853 13.236776 0 + 6100 292.04933 -168.30971 -2979.6898 -2975.1594 5.8959922 -2969.5853 13.236776 0 + 6200 299.23747 839.17828 -2979.7883 -2976.0647 4.6378408 -2971.2747 11.121537 0 + 6300 294.92201 -1597.9426 -2979.7975 -2976.0647 4.6378408 -2971.2747 11.121537 0 + 6400 291.7185 3411.2916 -2979.6978 -2976.7848 3.643826 -2972.77 9.1579616 0 + 6500 285.34227 -4280.7968 -2979.4874 -2976.7848 3.643826 -2972.77 9.1579616 0 + 6600 295.53838 2138.7496 -2979.2799 -2977.3265 2.9178925 -2974.0625 7.4101102 0 + 6700 288.54718 -1818.7662 -2978.9379 -2977.3265 2.9178925 -2974.0625 7.4101102 0 + 6800 290.41342 2175.3559 -2978.543 -2977.7009 2.4532223 -2975.1594 5.8959922 0 + 6900 296.34456 -4782.08 -2978.0362 -2977.7009 2.4532223 -2975.1594 5.8959922 0 + 7000 303.74314 5905.219 -2977.577 -2977.9137 2.2279716 -2976.0647 4.6378408 0 + 7100 303.90284 -3291.7627 -2977.1308 -2977.9137 2.2279716 -2976.0647 4.6378408 0 + 7200 296.13966 2209.574 -2976.7001 -2977.9829 2.1708943 -2976.7848 3.643826 0 + 7300 295.79694 -1609.1898 -2976.2816 -2977.9829 2.1708943 -2976.7848 3.643826 0 + 7400 306.53289 988.50902 -2975.8992 -2977.931 2.1935882 -2977.3265 2.9178925 0 + 7500 303.89992 -631.22838 -2975.5597 -2977.931 2.1935882 -2977.3265 2.9178925 0 + 7600 303.83684 -348.48744 -2975.3074 -2977.7831 2.2226664 -2977.7009 2.4532223 0 + 7700 309.67313 1350.9414 -2975.1279 -2977.7831 2.2226664 -2977.7009 2.4532223 0 + 7800 309.74314 -1182.8905 -2975.0174 -2977.5683 2.2106484 -2977.9137 2.2279716 0 + 7900 309.42429 999.08033 -2975.0089 -2977.5683 2.2106484 -2977.9137 2.2279716 0 + 8000 315.51872 -1337.8894 -2975.0791 -2977.3233 2.1379295 -2977.9829 2.1708943 0 + 8100 314.80533 2392.3424 -2975.25 -2977.3233 2.1379295 -2977.9829 2.1708943 0 + 8200 303.80236 -3224.5976 -2975.4744 -2977.0851 2.0176342 -2977.931 2.1935882 0 + 8300 295.0505 3296.6912 -2975.8196 -2977.0851 2.0176342 -2977.931 2.1935882 0 + 8400 302.4154 -3314.5096 -2976.1586 -2976.8877 1.883051 -2977.7831 2.2226664 1 + 8500 300.95491 2971.1291 -2976.5859 -2976.8877 1.883051 -2977.7831 2.2226664 1 + 8600 301.68919 -2297.6673 -2976.9953 -2976.7596 1.785401 -2977.5683 2.2106484 1 + 8700 291.21002 1477.5703 -2977.4323 -2976.7596 1.785401 -2977.5683 2.2106484 1 + 8800 305.87126 -1085.459 -2977.8247 -2976.7169 1.7541517 -2977.3233 2.1379295 1 + 8900 296.17567 777.95805 -2978.2081 -2976.7169 1.7541517 -2977.3233 2.1379295 1 +Fix halt condition for fix-id 3 met on step 9000 with value 1 (src/fix_halt.cpp:310) + 9000 295.71917 -425.00708 -2978.5264 -2976.7595 1.7755885 -2977.0851 2.0176342 1 +Loop time of 42.1758 on 1 procs for 9000 steps with 864 atoms + +Performance: 36.874 ns/day, 0.651 hours/ns, 213.393 timesteps/s, 184.371 katom-step/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 41.126 | 41.126 | 41.126 | 0.0 | 97.51 +Neigh | 0.0078787 | 0.0078787 | 0.0078787 | 0.0 | 0.02 +Comm | 0.26508 | 0.26508 | 0.26508 | 0.0 | 0.63 +Output | 0.0096224 | 0.0096224 | 0.0096224 | 0.0 | 0.02 +Modify | 0.65597 | 0.65597 | 0.65597 | 0.0 | 1.56 +Other | | 0.1108 | | | 0.26 + +Nlocal: 864 ave 864 max 864 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 3767 ave 3767 max 3767 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 96746 ave 96746 max 96746 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 96746 +Ave neighs/atom = 111.97454 +Neighbor list builds = 1 +Dangerous builds = 0 + +Total wall time: 0:00:42 diff --git a/examples/PACKAGES/moments/log.02May2025.converge.g++.4 b/examples/PACKAGES/moments/log.02May2025.converge.g++.4 new file mode 100644 index 0000000000..172f14d4f4 --- /dev/null +++ b/examples/PACKAGES/moments/log.02May2025.converge.g++.4 @@ -0,0 +1,171 @@ +LAMMPS (2 Apr 2025 - Development - patch_4Feb2025-645-gba166d42e1-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:99) + using 1 OpenMP thread(s) per MPI task +# create pure copper system +units metal +lattice fcc 3.75 +Lattice spacing in x,y,z = 3.75 3.75 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box +Created orthogonal box = (0 0 0) to (22.5 22.5 22.5) + 1 by 2 by 2 MPI processor grid + +timestep 0.002 +create_atoms 1 box +Created 864 atoms + using lattice units in orthogonal box = (0 0 0) to (22.5 22.5 22.5) + create_atoms CPU = 0.001 seconds + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 0.2000000000000000111 + +variable toteng equal "etotal" +fix 2 all ave/moments 10 500 200 v_toteng mean stddev history 5 + +variable conv equal "(f_2[2] < 2) && (f_2[2][1] < f_2[2][5])" +fix 3 all halt 1000 v_conv == 1 + +thermo_style custom step temp press etotal f_2[*][1] f_2[*][5] v_conv + +thermo 100 +run 10000 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.6825 + ghost atom cutoff = 8.6825 + binsize = 4.34125, bins = 6 6 6 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair eam/alloy, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.42 | 3.42 | 3.42 Mbytes + Step Temp Press TotEng f_2[1][1] f_2[2][1] f_2[1][5] f_2[2][5] v_conv + 0 1000 -107410.22 -2884.9159 0 0 0 0 0 + 100 492.38014 -134.33622 -2928.6874 0 0 0 0 0 + 200 484.82396 -214.26318 -2931.4603 -2928.6979 2.1805063 0 0 0 + 300 476.69743 15.78678 -2934.0022 -2928.6979 2.1805063 0 0 0 + 400 482.51415 141.67184 -2936.9347 -2931.4437 3.3715811 0 0 0 + 500 455.45411 2.4424602 -2939.9649 -2931.4437 3.3715811 0 0 0 + 600 455.20054 -6.8170934 -2943.0454 -2934.339 5.0598781 0 0 0 + 700 429.81168 -75.812923 -2946.0438 -2934.339 5.0598781 0 0 0 + 800 428.22097 604.18705 -2948.9285 -2937.2965 6.813037 0 0 0 + 900 399.10914 -3622.6904 -2951.7252 -2937.2965 6.813037 0 0 0 + 1000 394.62543 7905.9041 -2954.2925 -2940.2044 8.4668749 -2928.6979 2.1805063 0 + 1100 404.27007 -2565.5508 -2956.9736 -2940.2044 8.4668749 -2928.6979 2.1805063 0 + 1200 368.47178 741.43707 -2959.4264 -2943.0151 9.9914785 -2931.4437 3.3715811 0 + 1300 360.91266 -267.08372 -2961.69 -2943.0151 9.9914785 -2931.4437 3.3715811 0 + 1400 356.74405 158.09093 -2963.8501 -2945.696 11.36357 -2934.339 5.0598781 0 + 1500 335.45696 -71.007783 -2965.8817 -2945.696 11.36357 -2934.339 5.0598781 0 + 1600 331.01199 -454.90004 -2967.7708 -2948.2278 12.577884 -2937.2965 6.813037 0 + 1700 329.223 2428.4284 -2969.5452 -2948.2278 12.577884 -2937.2965 6.813037 0 + 1800 327.61481 -4757.648 -2971.1105 -2950.5985 13.632251 -2940.2044 8.4668749 0 + 1900 318.18741 2226.7765 -2972.6906 -2950.5985 13.632251 -2940.2044 8.4668749 0 + 2000 308.79313 -1089.8603 -2974.0899 -2952.8123 14.545164 -2943.0151 9.9914785 0 + 2100 303.32047 757.53534 -2975.3597 -2952.8123 14.545164 -2943.0151 9.9914785 0 + 2200 307.41102 -837.97246 -2976.4966 -2954.8654 15.317558 -2945.696 11.36357 0 + 2300 303.01088 1618.29 -2977.5454 -2954.8654 15.317558 -2945.696 11.36357 0 + 2400 297.59385 -3233.8282 -2978.4064 -2956.7565 15.953758 -2948.2278 12.577884 0 + 2500 288.72232 5209.2099 -2979.1999 -2956.7565 15.953758 -2948.2278 12.577884 0 + 2600 298.92201 -2193.618 -2979.8873 -2958.4845 16.457635 -2950.5985 13.632251 0 + 2700 282.61818 765.88178 -2980.4563 -2958.4845 16.457635 -2950.5985 13.632251 0 + 2800 273.63104 -389.49749 -2980.8636 -2960.0533 16.839029 -2952.8123 14.545164 0 + 2900 274.12166 -9.2552992 -2981.1421 -2960.0533 16.839029 -2952.8123 14.545164 0 + 3000 279.43592 212.25445 -2981.2716 -2961.4578 17.096628 -2954.8654 15.317558 0 + 3100 291.10071 -1139.205 -2981.2475 -2961.4578 17.096628 -2954.8654 15.317558 0 + 3200 281.53171 3124.6411 -2981.0818 -2962.6921 17.230604 -2956.7565 15.953758 0 + 3300 277.0223 -2795.9494 -2980.7825 -2962.6921 17.230604 -2956.7565 15.953758 0 + 3400 284.8443 1587.8876 -2980.3701 -2963.754 17.247489 -2958.4845 16.457635 0 + 3500 281.19 -1143.0785 -2979.8374 -2963.754 17.247489 -2958.4845 16.457635 0 + 3600 296.58287 1156.4706 -2979.2182 -2964.645 17.159411 -2960.0533 16.839029 0 + 3700 297.24517 -1888.4993 -2978.5352 -2964.645 17.159411 -2960.0533 16.839029 0 + 3800 290.81586 3843.3483 -2977.8509 -2965.3746 16.985916 -2961.4578 17.096628 0 + 3900 300.39456 -5584.8386 -2977.0837 -2965.3746 16.985916 -2961.4578 17.096628 0 + 4000 306.15811 3310.0105 -2976.5086 -2965.9619 16.752214 -2962.6921 17.230604 0 + 4100 295.907 -1475.0458 -2975.9096 -2965.9619 16.752214 -2962.6921 17.230604 0 + 4200 322.70162 933.76586 -2975.3867 -2966.4348 16.484219 -2963.754 17.247489 0 + 4300 306.69631 -512.7048 -2974.9324 -2966.4348 16.484219 -2963.754 17.247489 0 + 4400 309.23776 226.77219 -2974.5791 -2966.8208 16.201471 -2964.645 17.159411 0 + 4500 313.15783 508.29785 -2974.3263 -2966.8208 16.201471 -2964.645 17.159411 0 + 4600 316.26151 -2043.7571 -2974.1697 -2967.1463 15.918137 -2965.3746 16.985916 0 + 4700 312.27329 1831.682 -2974.1732 -2967.1463 15.918137 -2965.3746 16.985916 0 + 4800 307.61066 -1476.0019 -2974.2885 -2967.4397 15.645834 -2965.9619 16.752214 0 + 4900 305.73489 1303.4848 -2974.5506 -2967.4397 15.645834 -2965.9619 16.752214 0 + 5000 309.3774 -1574.6812 -2974.8687 -2967.7249 15.392787 -2966.4348 16.484219 0 + 5100 304.8602 2679.7476 -2975.3082 -2967.7249 15.392787 -2966.4348 16.484219 0 + 5200 297.54226 -5008.0905 -2975.7443 -2969.5904 13.211657 -2966.8208 16.201471 0 + 5300 306.18872 4840.4175 -2976.324 -2969.5904 13.211657 -2966.8208 16.201471 0 + 5400 299.57661 -2513.1706 -2976.8842 -2971.2774 11.099846 -2967.1463 15.918137 0 + 5500 302.30844 1301.3525 -2977.4539 -2971.2774 11.099846 -2967.1463 15.918137 0 + 5600 302.11038 -760.79712 -2977.9764 -2972.7712 9.1381778 -2967.4397 15.645834 0 + 5700 294.49825 718.67318 -2978.4584 -2972.7712 9.1381778 -2967.4397 15.645834 0 + 5800 305.97636 -478.64224 -2978.8638 -2974.0628 7.3929182 -2967.7249 15.392787 0 + 5900 291.93868 -419.74179 -2979.2292 -2974.0628 7.3929182 -2967.7249 15.392787 0 + 6000 289.50667 859.85085 -2979.5018 -2975.1575 5.8837236 -2969.5904 13.211657 0 + 6100 305.70118 -933.35917 -2979.6877 -2975.1575 5.8837236 -2969.5904 13.211657 0 + 6200 284.37805 1526.0707 -2979.806 -2976.062 4.6281363 -2971.2774 11.099846 0 + 6300 291.08863 -2156.6708 -2979.8064 -2976.062 4.6281363 -2971.2774 11.099846 0 + 6400 295.99073 2819.8245 -2979.7378 -2976.7827 3.6358684 -2972.7712 9.1381778 0 + 6500 298.06769 -3396.3504 -2979.5428 -2976.7827 3.6358684 -2972.7712 9.1381778 0 + 6600 301.78514 5496.6525 -2979.2768 -2977.3261 2.9112079 -2974.0628 7.3929182 0 + 6700 290.80665 -5229.4989 -2978.9177 -2977.3261 2.9112079 -2974.0628 7.3929182 0 + 6800 296.75761 2401.7807 -2978.5996 -2977.7014 2.4473856 -2975.1575 5.8837236 0 + 6900 295.77553 -1521.6269 -2978.1619 -2977.7014 2.4473856 -2975.1575 5.8837236 0 + 7000 303.59015 1530.7255 -2977.7097 -2977.9176 2.2219164 -2976.062 4.6281363 0 + 7100 297.51038 -3016.4426 -2977.2025 -2977.9176 2.2219164 -2976.062 4.6281363 0 + 7200 293.53789 2705.9808 -2976.7651 -2977.9894 2.1638143 -2976.7827 3.6358684 0 + 7300 301.78809 -1042.1076 -2976.3388 -2977.9894 2.1638143 -2976.7827 3.6358684 0 + 7400 307.50053 214.56923 -2975.9581 -2977.9394 2.1852009 -2977.3261 2.9112079 0 + 7500 301.98985 281.86495 -2975.6146 -2977.9394 2.1852009 -2977.3261 2.9112079 0 + 7600 318.37347 -1145.7795 -2975.3473 -2977.7949 2.2136707 -2977.7014 2.4473856 0 + 7700 314.94512 4536.9887 -2975.1351 -2977.7949 2.2136707 -2977.7014 2.4473856 0 + 7800 312.91485 -2980.6408 -2975.0156 -2977.5818 2.2038198 -2977.9176 2.2219164 0 + 7900 310.06854 2244.3877 -2975.0094 -2977.5818 2.2038198 -2977.9176 2.2219164 0 + 8000 308.55007 -2427.1464 -2975.0491 -2977.3378 2.1348358 -2977.9894 2.1638143 0 + 8100 323.02796 3187.4728 -2975.2081 -2977.3378 2.1348358 -2977.9894 2.1638143 0 + 8200 327.05029 -6447.7875 -2975.3162 -2977.0986 2.0196599 -2977.9394 2.1852009 0 + 8300 311.194 4273.1174 -2975.7217 -2977.0986 2.0196599 -2977.9394 2.1852009 0 + 8400 290.61931 -2301.019 -2976.0963 -2976.8989 1.8918948 -2977.7949 2.2136707 1 + 8500 314.00559 1966.1297 -2976.5206 -2976.8989 1.8918948 -2977.7949 2.2136707 1 + 8600 288.26541 -1608.4524 -2976.9304 -2976.7685 1.7971228 -2977.5818 2.2038198 1 + 8700 298.92083 1353.9988 -2977.355 -2976.7685 1.7971228 -2977.5818 2.2038198 1 + 8800 299.97274 -638.68301 -2977.766 -2976.722 1.7650747 -2977.3378 2.1348358 1 + 8900 300.66443 -279.62514 -2978.1476 -2976.722 1.7650747 -2977.3378 2.1348358 1 +Fix halt condition for fix-id 3 met on step 9000 with value 1 (src/fix_halt.cpp:310) + 9000 290.44715 489.06352 -2978.4892 -2976.7631 1.7846181 -2977.0986 2.0196599 1 +Loop time of 14.7347 on 4 procs for 9000 steps with 864 atoms + +Performance: 105.547 ns/day, 0.227 hours/ns, 610.804 timesteps/s, 527.735 katom-step/s +92.8% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 10.565 | 11.474 | 12.015 | 16.1 | 77.87 +Neigh | 0.0020313 | 0.0020966 | 0.002163 | 0.1 | 0.01 +Comm | 2.008 | 2.5374 | 3.4278 | 33.5 | 17.22 +Output | 0.0030284 | 0.0036299 | 0.0051776 | 1.5 | 0.02 +Modify | 0.42442 | 0.43307 | 0.44329 | 1.0 | 2.94 +Other | | 0.2849 | | | 1.93 + +Nlocal: 216 ave 224 max 204 min +Histogram: 1 0 0 0 0 0 0 2 0 1 +Nghost: 2147 ave 2159 max 2139 min +Histogram: 1 0 0 2 0 0 0 0 0 1 +Neighs: 24185.8 ave 26045 max 21309 min +Histogram: 1 0 0 0 0 1 0 0 0 2 + +Total # of neighbors = 96743 +Ave neighs/atom = 111.97106 +Neighbor list builds = 1 +Dangerous builds = 0 + +Total wall time: 0:00:14 diff --git a/examples/PACKAGES/moments/log.02May2025.simple.g++.1 b/examples/PACKAGES/moments/log.02May2025.simple.g++.1 new file mode 100644 index 0000000000..3a2fe80beb --- /dev/null +++ b/examples/PACKAGES/moments/log.02May2025.simple.g++.1 @@ -0,0 +1,177 @@ +LAMMPS (2 Apr 2025 - Development - patch_4Feb2025-645-gba166d42e1-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:99) + using 1 OpenMP thread(s) per MPI task +# create pure copper system +units metal +lattice fcc 3.75 +Lattice spacing in x,y,z = 3.75 3.75 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box +Created orthogonal box = (0 0 0) to (22.5 22.5 22.5) + 1 by 1 by 1 MPI processor grid + +timestep 0.002 +create_atoms 1 box +Created 864 atoms + using lattice units in orthogonal box = (0 0 0) to (22.5 22.5 22.5) + create_atoms CPU = 0.001 seconds + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 0.2000000000000000111 + +variable toteng equal "etotal" +fix 2 all ave/moments 5 200 100 v_toteng mean stddev variance skew kurtosis + +thermo_style custom step temp press etotal f_2[*] + +thermo 100 +run 10000 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.6825 + ghost atom cutoff = 8.6825 + binsize = 4.34125, bins = 6 6 6 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair eam/alloy, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.484 | 3.484 | 3.484 Mbytes + Step Temp Press TotEng f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] + 0 1000 -107410.22 -2884.9159 0 0 0 0 0 + 100 512.04214 -124.66263 -2928.6 -2927.1688 1.6797138 2.8214386 2.5218138 6.164012 + 200 479.34328 -136.26635 -2931.3905 -2928.6374 1.9791406 3.9169976 1.3377745 3.2426285 + 300 480.05298 128.92946 -2933.9233 -2929.9825 2.5401119 6.4521682 0.66415393 0.77130236 + 400 471.83641 -29.253334 -2936.8631 -2931.346 3.2640831 10.654239 0.29075579 -0.26904542 + 500 456.96309 -274.69336 -2939.9081 -2932.7721 4.1077082 16.873267 0.094954709 -0.72240572 + 600 450.32413 14.606227 -2942.973 -2934.2328 4.9928765 24.928816 0.0090731063 -0.93757177 + 700 431.71192 -45.641261 -2946.006 -2935.7111 5.8871117 34.658084 -0.024573652 -1.0540107 + 800 436.4217 589.91981 -2948.8885 -2937.1871 6.762411 45.730202 -0.028553126 -1.1275153 + 900 407.84688 -3728.1499 -2951.6643 -2938.652 7.6129868 57.957569 -0.020186137 -1.172618 + 1000 401.69178 6695.3653 -2954.2959 -2940.0921 8.423174 70.949861 -0.0018224075 -1.2051609 + 1100 370.87469 -2294.843 -2956.9413 -2942.9469 8.384346 70.297257 0.016964628 -1.2643199 + 1200 375.15562 704.6568 -2959.3841 -2945.7589 8.3201293 69.224551 0.070500644 -1.2400262 + 1300 371.09077 -493.04016 -2961.6803 -2948.5516 8.1425118 66.300499 0.11183042 -1.2099873 + 1400 365.88512 490.98174 -2963.8365 -2951.2897 7.8673969 61.895934 0.13639588 -1.198071 + 1500 358.42655 -218.94911 -2965.8652 -2953.9337 7.5491659 56.989906 0.15564307 -1.1896984 + 1600 329.08402 56.411923 -2967.7662 -2956.467 7.2016413 51.863637 0.17198437 -1.186472 + 1700 317.74207 1192.918 -2969.557 -2958.8765 6.8379658 46.757776 0.19041811 -1.1812241 + 1800 331.98966 -2205.7213 -2971.1465 -2961.1601 6.4614065 41.749774 0.20925197 -1.1714131 + 1900 330.96814 1401.3066 -2972.6923 -2963.3191 6.0867317 37.048302 0.22552163 -1.1523125 + 2000 315.41816 -909.41909 -2974.0785 -2965.3567 5.7020261 32.513101 0.2328316 -1.1454375 + 2100 320.4269 1226.2006 -2975.3676 -2967.2609 5.3260556 28.366869 0.24130517 -1.1432352 + 2200 302.88235 -1238.8052 -2976.5099 -2969.0355 4.9584282 24.58601 0.25200271 -1.141699 + 2300 300.4349 2667.202 -2977.5329 -2970.6815 4.5986371 21.147463 0.26764984 -1.1380521 + 2400 292.94691 -5532.1854 -2978.3724 -2972.201 4.2403749 17.980779 0.28797864 -1.1357902 + 2500 286.12064 4647.3841 -2979.2217 -2973.5946 3.8875889 15.113348 0.31556585 -1.1249025 + 2600 290.74305 -1950.526 -2979.9142 -2974.8686 3.5422986 12.547879 0.34719546 -1.0987558 + 2700 281.51347 937.60472 -2980.4808 -2976.0235 3.1955646 10.211633 0.38268676 -1.0664838 + 2800 279.71836 -801.62498 -2980.8899 -2977.0588 2.844105 8.0889331 0.41930147 -1.0460672 + 2900 277.41241 609.21495 -2981.1721 -2977.9673 2.4956133 6.2280855 0.47337432 -1.0140054 + 3000 281.31161 -760.27203 -2981.3003 -2978.7489 2.1466012 4.6078967 0.55325134 -0.95161956 + 3100 284.72904 315.53038 -2981.297 -2979.4023 1.7929581 3.2146986 0.66481771 -0.84726207 + 3200 278.39445 516.25074 -2981.1224 -2979.9226 1.4369984 2.0649644 0.82583409 -0.63830994 + 3300 294.46998 -655.06212 -2980.8266 -2980.3134 1.0905211 1.1892364 1.0357766 -0.22841943 + 3400 290.04647 788.30424 -2980.3963 -2980.5732 0.77030961 0.59337689 1.1867647 0.34447355 + 3500 283.218 -844.33188 -2979.8504 -2980.6995 0.54590076 0.29800764 0.78163948 -0.42619888 + 3600 288.76031 1339.2734 -2979.2382 -2980.6921 0.56032295 0.31396181 0.83603869 -0.30853278 + 3700 289.44519 -3015.7161 -2978.5394 -2980.5581 0.77708069 0.60385439 1.0796997 -0.022962365 + 3800 309.04206 5579.3265 -2977.8282 -2980.3052 1.0531468 1.1091181 0.890018 -0.56034495 + 3900 309.34588 -4255.5213 -2977.1281 -2979.9487 1.3153981 1.7302721 0.65242676 -0.95498589 + 4000 305.79444 2358.1383 -2976.5251 -2979.5068 1.5325477 2.3487025 0.44420123 -1.1839975 + 4100 309.12957 -1401.6484 -2975.9173 -2978.9985 1.6923829 2.86416 0.26850538 -1.3006942 + 4200 309.41928 1180.4111 -2975.3857 -2978.4446 1.7941259 3.2188877 0.11443933 -1.3365167 + 4300 299.88949 -1549.6591 -2974.927 -2977.8616 1.8268192 3.3372683 -0.018659059 -1.3293426 + 4400 319.09918 1937.7006 -2974.5598 -2977.273 1.7942266 3.219249 -0.13743367 -1.2958767 + 4500 326.48719 -1489.2073 -2974.311 -2976.7017 1.7042328 2.9044096 -0.25309558 -1.2385503 + 4600 310.93392 37.586899 -2974.1959 -2976.1697 1.5590672 2.4306905 -0.3757949 -1.1641151 + 4700 314.28994 317.12347 -2974.1763 -2975.6978 1.3661244 1.8662958 -0.51792367 -1.0609001 + 4800 309.88756 -698.72705 -2974.2892 -2975.3021 1.1422822 1.3048085 -0.69587053 -0.87319738 + 4900 309.53444 962.42921 -2974.5261 -2974.9944 0.89961859 0.80931361 -0.91892105 -0.49661907 + 5000 316.06666 -1869.3275 -2974.8492 -2974.7804 0.65817496 0.43319428 -1.0974595 0.048447651 + 5100 304.82485 4042.6797 -2975.2715 -2974.6661 0.47073268 0.22158926 -0.82059377 -0.31531887 + 5200 307.75342 -5058.4814 -2975.7195 -2974.6547 0.44733518 0.20010876 -0.68956594 -0.65171579 + 5300 298.83511 3096.4566 -2976.3329 -2974.7467 0.60599527 0.36723026 -1.0652601 0.032591262 + 5400 296.85413 -1929.1654 -2976.8797 -2974.9367 0.82832935 0.68612952 -0.91576774 -0.50322222 + 5500 295.88343 1449.3005 -2977.4488 -2975.215 1.044317 1.090598 -0.67574925 -0.92510515 + 5600 305.59328 -1504.0321 -2977.9573 -2975.5653 1.2243609 1.4990595 -0.46160433 -1.1708115 + 5700 293.40683 2579.0134 -2978.4364 -2975.97 1.3577316 1.843435 -0.27746111 -1.2993802 + 5800 297.93644 -2742.705 -2978.8276 -2976.411 1.4332742 2.054275 -0.11245859 -1.3584974 + 5900 290.39408 1189.4042 -2979.2224 -2976.8733 1.4576633 2.1247823 0.030209056 -1.3466833 + 6000 293.73148 -232.54292 -2979.503 -2977.3408 1.4300816 2.0451335 0.15663025 -1.2965878 + 6100 292.04933 -168.30971 -2979.6898 -2977.7936 1.3523929 1.8289665 0.28027258 -1.2214523 + 6200 299.23747 839.17828 -2979.7883 -2978.2154 1.2284868 1.5091798 0.40149929 -1.1382373 + 6300 294.92201 -1597.9426 -2979.7975 -2978.589 1.072002 1.1491883 0.53769821 -1.0262094 + 6400 291.7185 3411.2916 -2979.6978 -2978.9013 0.89165749 0.79505308 0.70748196 -0.83601078 + 6500 285.34227 -4280.7968 -2979.4874 -2979.1407 0.69727552 0.48619315 0.91500724 -0.4890805 + 6600 295.53838 2138.7496 -2979.2799 -2979.3084 0.50938648 0.25947459 1.0827149 -0.0043801382 + 6700 288.54718 -1818.7662 -2978.9379 -2979.3979 0.3658125 0.13381879 0.85573626 -0.20104653 + 6800 290.41342 2175.3559 -2978.543 -2979.4085 0.34439248 0.11860618 0.70989241 -0.55138716 + 6900 296.34456 -4782.08 -2978.0362 -2979.3362 0.47081063 0.22166265 1.1051059 0.16381282 + 7000 303.74314 5905.219 -2977.577 -2979.182 0.65635739 0.43080502 0.97456755 -0.34269231 + 7100 303.90284 -3291.7627 -2977.1308 -2978.9595 0.83412944 0.69577192 0.71973637 -0.85687335 + 7200 296.13966 2209.574 -2976.7001 -2978.6767 0.98885368 0.97783159 0.50554418 -1.124705 + 7300 295.79694 -1609.1898 -2976.2816 -2978.3446 1.1093729 1.2307082 0.32952142 -1.2657581 + 7400 306.53289 988.50902 -2975.8992 -2977.977 1.1910167 1.4185209 0.17936365 -1.331845 + 7500 303.89992 -631.22838 -2975.5597 -2977.5901 1.2352698 1.5258915 0.033110856 -1.3362459 + 7600 303.83684 -348.48744 -2975.3074 -2977.1915 1.2312686 1.5160224 -0.094817417 -1.3063491 + 7700 309.67313 1350.9414 -2975.1279 -2976.7984 1.1829266 1.3993154 -0.21343083 -1.2573517 + 7800 309.74314 -1182.8905 -2975.0174 -2976.4294 1.0913021 1.1909402 -0.3401118 -1.198459 + 7900 309.42429 999.08033 -2975.0089 -2976.0995 0.96393318 0.92916717 -0.48456322 -1.1149956 + 8000 315.51872 -1337.8894 -2975.0791 -2975.822 0.81535467 0.66480324 -0.67906685 -0.90499956 + 8100 314.80533 2392.3424 -2975.25 -2975.6019 0.64582022 0.41708376 -0.90521871 -0.5328796 + 8200 303.80236 -3224.5976 -2975.4744 -2975.4481 0.47449379 0.22514436 -1.0884377 -0.00018150871 + 8300 295.0505 3296.6912 -2975.8196 -2975.3667 0.34164698 0.11672266 -0.83269043 -0.31809119 + 8400 302.4154 -3314.5096 -2976.1586 -2975.3606 0.32904826 0.10827276 -0.73500255 -0.57861735 + 8500 300.95491 2971.1291 -2976.5859 -2975.4288 0.44584452 0.19877734 -1.0760301 0.014924509 + 8600 301.68919 -2297.6673 -2976.9953 -2975.5682 0.60852433 0.37030186 -0.91802963 -0.5143582 + 8700 291.21002 1477.5703 -2977.4323 -2975.7733 0.76843347 0.59048999 -0.68059043 -0.92051715 + 8800 305.87126 -1085.459 -2977.8247 -2976.0327 0.90672273 0.82214612 -0.47413162 -1.1492716 + 8900 296.17567 777.95805 -2978.2081 -2976.3349 1.0129061 1.0259789 -0.29734681 -1.271416 + 9000 295.71917 -425.00708 -2978.5264 -2976.6672 1.0786137 1.1634075 -0.14055755 -1.3302079 + 9100 296.85578 -533.46289 -2978.8197 -2977.0152 1.1000855 1.2101882 0.0045950751 -1.3434868 + 9200 293.949 605.27065 -2979.0349 -2977.3702 1.0854405 1.1781811 0.123965 -1.3093197 + 9300 289.11704 -896.44753 -2979.1981 -2977.7166 1.0353526 1.071955 0.23898813 -1.2558296 + 9400 285.34521 1181.7542 -2979.2879 -2978.0404 0.95298596 0.90818224 0.36461645 -1.1736585 + 9500 296.17714 -2503.9848 -2979.2668 -2978.3301 0.8407037 0.70678272 0.50841734 -1.0540275 + 9600 296.43744 4912.6395 -2979.1829 -2978.5736 0.70352404 0.49494608 0.68312042 -0.86335848 + 9700 288.63317 -3935.8902 -2979.0381 -2978.7635 0.55322477 0.30605764 0.88509388 -0.54108379 + 9800 296.27133 1365.4106 -2978.8723 -2978.8969 0.40665162 0.16536554 1.0460992 -0.092552905 + 9900 299.37628 -1267.2668 -2978.5934 -2978.9673 0.29467695 0.086834506 0.80391757 -0.38307943 + 10000 296.60645 1950.1018 -2978.2725 -2978.9739 0.28169006 0.079349287 0.70171659 -0.62026504 +Loop time of 47.4814 on 1 procs for 10000 steps with 864 atoms + +Performance: 36.393 ns/day, 0.659 hours/ns, 210.609 timesteps/s, 181.966 katom-step/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 46.299 | 46.299 | 46.299 | 0.0 | 97.51 +Neigh | 0.010908 | 0.010908 | 0.010908 | 0.0 | 0.02 +Comm | 0.29643 | 0.29643 | 0.29643 | 0.0 | 0.62 +Output | 0.0090682 | 0.0090682 | 0.0090682 | 0.0 | 0.02 +Modify | 0.7406 | 0.7406 | 0.7406 | 0.0 | 1.56 +Other | | 0.1254 | | | 0.26 + +Nlocal: 864 ave 864 max 864 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 3767 ave 3767 max 3767 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 96746 ave 96746 max 96746 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 96746 +Ave neighs/atom = 111.97454 +Neighbor list builds = 1 +Dangerous builds = 0 + +Total wall time: 0:00:47 diff --git a/examples/PACKAGES/moments/log.02May2025.simple.g++.4 b/examples/PACKAGES/moments/log.02May2025.simple.g++.4 new file mode 100644 index 0000000000..dde6be4aa3 --- /dev/null +++ b/examples/PACKAGES/moments/log.02May2025.simple.g++.4 @@ -0,0 +1,177 @@ +LAMMPS (2 Apr 2025 - Development - patch_4Feb2025-645-gba166d42e1-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:99) + using 1 OpenMP thread(s) per MPI task +# create pure copper system +units metal +lattice fcc 3.75 +Lattice spacing in x,y,z = 3.75 3.75 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box +Created orthogonal box = (0 0 0) to (22.5 22.5 22.5) + 1 by 2 by 2 MPI processor grid + +timestep 0.002 +create_atoms 1 box +Created 864 atoms + using lattice units in orthogonal box = (0 0 0) to (22.5 22.5 22.5) + create_atoms CPU = 0.010 seconds + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 0.2000000000000000111 + +variable toteng equal "etotal" +fix 2 all ave/moments 5 200 100 v_toteng mean stddev variance skew kurtosis + +thermo_style custom step temp press etotal f_2[*] + +thermo 100 +run 10000 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.6825 + ghost atom cutoff = 8.6825 + binsize = 4.34125, bins = 6 6 6 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair eam/alloy, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.42 | 3.42 | 3.42 Mbytes + Step Temp Press TotEng f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] + 0 1000 -107410.22 -2884.9159 0 0 0 0 0 + 100 492.38014 -134.33622 -2928.6874 -2927.2291 1.7092959 2.9216925 2.5081594 6.099781 + 200 484.82396 -214.26318 -2931.4603 -2928.71 2.0003214 4.0012857 1.3645049 3.3103886 + 300 476.69743 15.78678 -2934.0022 -2930.0515 2.5470901 6.4876682 0.6954232 0.86102766 + 400 482.51415 141.67184 -2936.9347 -2931.4152 3.2681043 10.680505 0.30641098 -0.22337036 + 500 455.45411 2.4424602 -2939.9649 -2932.8397 4.1076295 16.87262 0.10483325 -0.6997127 + 600 455.20054 -6.8170934 -2943.0454 -2934.2947 4.9842257 24.842506 0.018003661 -0.92490336 + 700 429.81168 -75.812923 -2946.0438 -2935.7704 5.8766819 34.53539 -0.019539731 -1.0444564 + 800 428.22097 604.18705 -2948.9285 -2937.2449 6.7522047 45.592268 -0.026384526 -1.1194924 + 900 399.10914 -3622.6904 -2951.7252 -2938.7094 7.6043904 57.826753 -0.019997758 -1.1658244 + 1000 394.62543 7905.9041 -2954.2925 -2940.15 8.4168551 70.84345 -0.0026187371 -1.2004009 + 1100 404.27007 -2565.5508 -2956.9736 -2943.0009 8.3722389 70.094384 0.015852037 -1.2665587 + 1200 368.47178 741.43707 -2959.4264 -2945.8091 8.3127243 69.101386 0.069744698 -1.2412651 + 1300 360.91266 -267.08372 -2961.69 -2948.5981 8.1334656 66.153263 0.1116445 -1.2129213 + 1400 356.74405 158.09093 -2963.8501 -2951.3302 7.8574973 61.740264 0.13825232 -1.1999727 + 1500 335.45696 -71.007783 -2965.8817 -2953.9689 7.5384846 56.82875 0.15915227 -1.1877331 + 1600 331.01199 -454.90004 -2967.7708 -2956.5 7.1862592 51.642321 0.17403957 -1.1840985 + 1700 329.223 2428.4284 -2969.5452 -2958.9073 6.8228029 46.55064 0.19027454 -1.1778276 + 1800 327.61481 -4757.648 -2971.1105 -2961.1863 6.4445074 41.531675 0.20819854 -1.1712539 + 1900 318.18741 2226.7765 -2972.6906 -2963.3396 6.0703365 36.848986 0.22378928 -1.1556732 + 2000 308.79313 -1089.8603 -2974.0899 -2965.3712 5.6913723 32.391718 0.23279863 -1.1445916 + 2100 303.32047 757.53534 -2975.3597 -2967.2741 5.3153102 28.252523 0.23857925 -1.1465858 + 2200 307.41102 -837.97246 -2976.4966 -2969.0433 4.9515105 24.517456 0.25216298 -1.1426077 + 2300 303.01088 1618.29 -2977.5454 -2970.6862 4.593227 21.097734 0.26914071 -1.1356519 + 2400 297.59385 -3233.8282 -2978.4064 -2972.2049 4.235209 17.936995 0.28804295 -1.1332908 + 2500 288.72232 5209.2099 -2979.1999 -2973.5963 3.8804647 15.058006 0.31533205 -1.1258312 + 2600 298.92201 -2193.618 -2979.8873 -2974.8649 3.5301507 12.461964 0.34927897 -1.1048024 + 2700 282.61818 765.88178 -2980.4563 -2976.0148 3.1852407 10.145758 0.3879755 -1.0655899 + 2800 273.63104 -389.49749 -2980.8636 -2977.0468 2.8322558 8.021673 0.4259426 -1.0370247 + 2900 274.12166 -9.2552992 -2981.1421 -2977.9525 2.4816703 6.1586877 0.47721359 -1.0061337 + 3000 279.43592 212.25445 -2981.2716 -2978.7309 2.1328425 4.5490171 0.5532015 -0.94983292 + 3100 291.10071 -1139.205 -2981.2475 -2979.3812 1.7828537 3.1785674 0.66452451 -0.83906914 + 3200 281.53171 3124.6411 -2981.0818 -2979.9003 1.4287164 2.0412304 0.81952022 -0.6386061 + 3300 277.0223 -2795.9494 -2980.7825 -2980.287 1.0830229 1.1729385 1.0186688 -0.26502454 + 3400 284.8443 1587.8876 -2980.3701 -2980.5435 0.76893619 0.59126286 1.1646672 0.27529682 + 3500 281.19 -1143.0785 -2979.8374 -2980.6693 0.54860209 0.30096426 0.79069857 -0.36626891 + 3600 296.58287 1156.4706 -2979.2182 -2980.6646 0.55745952 0.31076112 0.81914175 -0.31895116 + 3700 297.24517 -1888.4993 -2978.5352 -2980.5318 0.77195451 0.59591377 1.0713124 -0.027796216 + 3800 290.81586 3843.3483 -2977.8509 -2980.2819 1.0444771 1.0909324 0.88270245 -0.57339499 + 3900 300.39456 -5584.8386 -2977.0837 -2979.9273 1.3073719 1.7092212 0.65444496 -0.94023014 + 4000 306.15811 3310.0105 -2976.5086 -2979.4859 1.5269967 2.3317191 0.45120199 -1.1665402 + 4100 295.907 -1475.0458 -2975.9096 -2978.9779 1.6878413 2.8488082 0.27738537 -1.2909517 + 4200 322.70162 933.76586 -2975.3867 -2978.425 1.7872637 3.1943116 0.12322364 -1.3421568 + 4300 306.69631 -512.7048 -2974.9324 -2977.8465 1.8221493 3.3202281 -0.016769435 -1.3380921 + 4400 309.23776 226.77219 -2974.5791 -2977.2621 1.788532 3.1988469 -0.14279249 -1.3044784 + 4500 313.15783 508.29785 -2974.3263 -2976.6947 1.6959722 2.8763217 -0.26351575 -1.2425552 + 4600 316.26151 -2043.7571 -2974.1697 -2976.1635 1.5525328 2.4103582 -0.38443906 -1.156175 + 4700 312.27329 1831.682 -2974.1732 -2975.6917 1.3614048 1.8534231 -0.52504872 -1.0383081 + 4800 307.61066 -1476.0019 -2974.2885 -2975.296 1.1354139 1.2891647 -0.69734331 -0.84719677 + 4900 305.73489 1303.4848 -2974.5506 -2974.9905 0.8913743 0.79454814 -0.90609876 -0.50216921 + 5000 309.3774 -1574.6812 -2974.8687 -2974.7812 0.65272109 0.42604482 -1.0613188 0.00291608 + 5100 304.8602 2679.7476 -2975.3082 -2974.6718 0.4727141 0.22345862 -0.75321909 -0.42028824 + 5200 297.54226 -5008.0905 -2975.7443 -2974.6646 0.45797515 0.20974124 -0.66557441 -0.64583954 + 5300 306.18872 4840.4175 -2976.324 -2974.7575 0.61348896 0.3763687 -1.0084709 -0.10258503 + 5400 299.57661 -2513.1706 -2976.8842 -2974.9472 0.83376011 0.69515592 -0.88189118 -0.55222188 + 5500 302.30844 1301.3525 -2977.4539 -2975.2244 1.0486412 1.0996484 -0.65075151 -0.94687541 + 5600 302.11038 -760.79712 -2977.9764 -2975.5765 1.2259535 1.502962 -0.44510538 -1.1709493 + 5700 294.49825 718.67318 -2978.4584 -2975.9844 1.357155 1.8418697 -0.27309672 -1.2848748 + 5800 305.97636 -478.64224 -2978.8638 -2976.429 1.4331646 2.0539608 -0.1197893 -1.3417863 + 5900 291.93868 -419.74179 -2979.2292 -2976.8905 1.4535887 2.1129201 0.024018983 -1.349863 + 6000 289.50667 859.85085 -2979.5018 -2977.3557 1.4249736 2.0305497 0.15271261 -1.3095465 + 6100 305.70118 -933.35917 -2979.6877 -2977.8064 1.3480601 1.8172659 0.27785119 -1.2402584 + 6200 284.37805 1526.0707 -2979.806 -2978.2265 1.2296781 1.5121082 0.40681415 -1.1355005 + 6300 291.08863 -2156.6708 -2979.8064 -2978.6017 1.0733214 1.1520189 0.54137333 -1.0156432 + 6400 295.99073 2819.8245 -2979.7378 -2978.9165 0.8941904 0.79957647 0.7073501 -0.82385123 + 6500 298.06769 -3396.3504 -2979.5428 -2979.1626 0.70228297 0.49320137 0.91043588 -0.48653641 + 6600 301.78514 5496.6525 -2979.2768 -2979.3329 0.51276653 0.26292952 1.0681056 -0.036293782 + 6700 290.80665 -5229.4989 -2978.9177 -2979.4217 0.36990055 0.13682642 0.81466085 -0.37332419 + 6800 296.75761 2401.7807 -2978.5996 -2979.4338 0.34589164 0.11964103 0.65253856 -0.7737558 + 6900 295.77553 -1521.6269 -2978.1619 -2979.3685 0.46007271 0.21166689 1.0427138 -0.013014477 + 7000 303.59015 1530.7255 -2977.7097 -2979.225 0.63320287 0.40094588 0.93012255 -0.45527217 + 7100 297.51038 -3016.4426 -2977.2025 -2979.0103 0.81101521 0.65774567 0.7114444 -0.84465178 + 7200 293.53789 2705.9808 -2976.7651 -2978.7294 0.97512025 0.95085951 0.52979295 -1.0479526 + 7300 301.78809 -1042.1076 -2976.3388 -2978.3998 1.1024575 1.2154126 0.35564664 -1.2137023 + 7400 307.50053 214.56923 -2975.9581 -2978.0341 1.188001 1.4113463 0.20025025 -1.3077784 + 7500 301.98985 281.86495 -2975.6146 -2977.6451 1.2301918 1.5133718 0.063886193 -1.3465506 + 7600 318.37347 -1145.7795 -2975.3473 -2977.2486 1.2295055 1.5116837 -0.066939137 -1.3475567 + 7700 314.94512 4536.9887 -2975.1351 -2976.8564 1.1948121 1.427576 -0.19450637 -1.2864658 + 7800 312.91485 -2980.6408 -2975.0156 -2976.4828 1.1134406 1.2397499 -0.32749726 -1.207718 + 7900 310.06854 2244.3877 -2975.0094 -2976.1462 0.99080702 0.98169854 -0.48336959 -1.0840695 + 8000 308.55007 -2427.1464 -2975.0491 -2975.8566 0.83800849 0.70225823 -0.65822117 -0.89212512 + 8100 323.02796 3187.4728 -2975.2081 -2975.6251 0.66510054 0.44235872 -0.84857729 -0.62984027 + 8200 327.05029 -6447.7875 -2975.3162 -2975.4608 0.49730291 0.24731018 -1.0534735 -0.14095413 + 8300 311.194 4273.1174 -2975.7217 -2975.3642 0.35491458 0.12596436 -0.95967595 -0.04445204 + 8400 290.61931 -2301.019 -2976.0963 -2975.3446 0.31530296 0.09941596 -0.69056625 -0.72257435 + 8500 314.00559 1966.1297 -2976.5206 -2975.3995 0.41659574 0.17355201 -1.1134124 0.18107632 + 8600 288.26541 -1608.4524 -2976.9304 -2975.526 0.57968749 0.33603759 -1.0014591 -0.34698354 + 8700 298.92083 1353.9988 -2977.355 -2975.7203 0.74176087 0.55020919 -0.74109062 -0.86227705 + 8800 299.97274 -638.68301 -2977.766 -2975.9682 0.87950613 0.77353104 -0.50839929 -1.1555064 + 8900 300.66443 -279.62514 -2978.1476 -2976.262 0.99526406 0.99055054 -0.33059914 -1.261881 + 9000 290.44715 489.06352 -2978.4892 -2976.5918 1.0763797 1.1585932 -0.17871557 -1.3082755 + 9100 289.06733 -1063.4482 -2978.784 -2976.943 1.1174524 1.2486999 -0.037767225 -1.3120851 + 9200 297.63931 2664.6535 -2979.0202 -2977.3033 1.1127042 1.2381106 0.090936095 -1.2913777 + 9300 297.9983 -4684.428 -2979.1316 -2977.6563 1.0596342 1.1228247 0.20756305 -1.2867214 + 9400 285.14009 2779.1548 -2979.2804 -2977.9868 0.98034602 0.96107833 0.33668495 -1.2294268 + 9500 284.11569 -2437.5003 -2979.2918 -2978.2852 0.87286876 0.76189987 0.48407552 -1.1274969 + 9600 291.97193 2772.1396 -2979.2473 -2978.5402 0.74294711 0.55197041 0.67450455 -0.91152584 + 9700 292.59563 -3615.4496 -2979.0801 -2978.7442 0.59448857 0.35341666 0.91630006 -0.47180257 + 9800 296.1785 4869.2744 -2978.8849 -2978.891 0.43463281 0.18890568 1.1020846 0.093881572 + 9900 298.44745 -3587.7391 -2978.5978 -2978.9712 0.30680426 0.094128854 0.8532075 -0.19634913 + 10000 297.99863 1312.5643 -2978.3205 -2978.9854 0.27829395 0.077447522 0.60818263 -0.79004935 +Loop time of 15.3108 on 4 procs for 10000 steps with 864 atoms + +Performance: 112.862 ns/day, 0.213 hours/ns, 653.136 timesteps/s, 564.309 katom-step/s +92.4% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 11.428 | 12.158 | 12.621 | 13.0 | 79.41 +Neigh | 0.0019158 | 0.0020708 | 0.002163 | 0.2 | 0.01 +Comm | 1.936 | 2.3948 | 3.0967 | 28.3 | 15.64 +Output | 0.0026067 | 0.0037308 | 0.0066123 | 2.7 | 0.02 +Modify | 0.44688 | 0.45929 | 0.47131 | 1.6 | 3.00 +Other | | 0.2928 | | | 1.91 + +Nlocal: 216 ave 224 max 204 min +Histogram: 1 0 0 0 0 0 0 2 0 1 +Nghost: 2147 ave 2159 max 2139 min +Histogram: 1 0 0 2 0 0 0 0 0 1 +Neighs: 24185.8 ave 26045 max 21309 min +Histogram: 1 0 0 0 0 1 0 0 0 2 + +Total # of neighbors = 96743 +Ave neighs/atom = 111.97106 +Neighbor list builds = 1 +Dangerous builds = 0 + +Total wall time: 0:00:15 From 10077b057c99a67233ae08578d63027712ef4eca Mon Sep 17 00:00:00 2001 From: Germain Clavier Date: Fri, 2 May 2025 21:42:33 +0200 Subject: [PATCH 05/14] Update fix_ave_moments.rst Emphasized the difference in behavior between this fix and other fix ave/* commands with regards to Nevery, Nrepeat and Nfreq. --- doc/src/fix_ave_moments.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/src/fix_ave_moments.rst b/doc/src/fix_ave_moments.rst index 9ea7e758e9..1ce420a810 100644 --- a/doc/src/fix_ave_moments.rst +++ b/doc/src/fix_ave_moments.rst @@ -109,8 +109,11 @@ time steps that are a multiple of :math:`N_\text{freq}`\ . The average is over a window of up to :math:`N_\text{repeat}` quantities, computed in the preceding portion of the simulation every :math:`N_\text{every}` time steps. -The values need not have any special relation: it is valid to have a window -larger than :math:`N_\text{freq}` as well as the other way around. +.. note:: + + Contrary to some fix ave/* commands, the values of this fix are not restricted by any special relation: + it is valid to have a window larger than :math:`N_\text{freq}` as well as the other way around. + For example, if :math:`N_\text{freq}=100` and :math:`N_\text{repeat}=5` (and :math:`N_\text{every}=1`), then values from time steps 96, 97, 98, 99, and 100 will be used. This means some intervening time steps do not contribute to the result. From 6c8e758e2bd302f1ce4f73f9d447d4bf14b82d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Sat, 3 May 2025 19:00:53 +0200 Subject: [PATCH 06/14] Fix subscript range checking typo --- src/EXTRA-FIX/fix_ave_moments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-FIX/fix_ave_moments.cpp b/src/EXTRA-FIX/fix_ave_moments.cpp index 8f64cc973d..3b102cde77 100644 --- a/src/EXTRA-FIX/fix_ave_moments.cpp +++ b/src/EXTRA-FIX/fix_ave_moments.cpp @@ -375,7 +375,7 @@ double FixAveMoments::compute_vector(int i) double FixAveMoments::compute_array(int i, int j) { - if (i >= moments.size()) return 0.0; + if (i >= size_vector) return 0.0; if (j >= nhistory) return 0.0; int row = (iresult - 1 - j + nhistory) % nhistory; if (row >= nhistory) return 0.0; From 228cf1e8710e70c374d3717bf379601dcbfa2101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Sat, 3 May 2025 19:07:01 +0200 Subject: [PATCH 07/14] Correct leftover references to vector inputs in docs --- doc/src/fix_ave_moments.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/src/fix_ave_moments.rst b/doc/src/fix_ave_moments.rst index 1ce420a810..e5b59e4320 100644 --- a/doc/src/fix_ave_moments.rst +++ b/doc/src/fix_ave_moments.rst @@ -89,15 +89,14 @@ and so on. For input values from a compute or fix or variable, the bracketed index I can be specified using a wildcard asterisk with the index to effectively specify multiple values. This takes the form "\*" or -"\*n" or "m\*" or "m\*n". If :math:`N` is the size of the vector (for *mode* = -scalar) or the number of columns in the array (for *mode* = vector), +"\*n" or "m\*" or "m\*n". If :math:`N` is the size of the vector, then an asterisk with no numeric values means all indices from 1 to :math:`N`. A leading asterisk means all indices from 1 to n (inclusive). A trailing asterisk means all indices from n to :math:`N` (inclusive). A middle asterisk means all indices from m to n (inclusive). Using a wildcard is the same as if the individual elements of the -vector or columns of the array had been listed one by one. For examples, see the +vector or cells of the array had been listed one by one. For examples, see the description of this capability in :doc:`fix ave/time `. ---------- From 6843424dad115f03f1a94fdaad42ea8202457f71 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 27 May 2025 10:38:41 -0400 Subject: [PATCH 08/14] add version tag, rewrap, minor tweaks to doc page. --- doc/src/fix_ave_moments.rst | 206 +++++++++++++++++++----------------- 1 file changed, 111 insertions(+), 95 deletions(-) diff --git a/doc/src/fix_ave_moments.rst b/doc/src/fix_ave_moments.rst index e5b59e4320..c773069a0b 100644 --- a/doc/src/fix_ave_moments.rst +++ b/doc/src/fix_ave_moments.rst @@ -50,9 +50,12 @@ Examples Description """"""""""" +.. versionadded:: TBD + Using one or more variables as input every few time steps, calculate the -moments of the underlying distribution based on the samples collected over -a time step window. The definitions of the moments calculated are given below. +moments of the underlying distribution based on the samples collected +over a time step window. The definitions of the moments calculated are +given below. The group specified with this command is ignored. However, note that specified values may represent calculations performed by computes and @@ -60,116 +63,126 @@ fixes which store their own "group" definitions. Each listed value can be the result of a :doc:`compute ` or :doc:`fix ` or the evaluation of an equal-style or vector-style -:doc:`variable `. In each case, the compute, fix, or variable must -produce a global quantity, quantity, not a per-atom or local quantity. -If you wish to spatial- or time-average or histogram per-atom quantities -from a compute, fix, or variable, then see the :doc:`fix ave/chunk `, -:doc:`fix ave/atom `, or :doc:`fix ave/histo ` commands. -If you wish to sum a per-atom quantity into a single global quantity, see the -:doc:`compute reduce ` command. +:doc:`variable `. In each case, the compute, fix, or variable +must produce a global quantity, quantity, not a per-atom or local +quantity. If you wish to spatial- or time-average or histogram per-atom +quantities from a compute, fix, or variable, then see the :doc:`fix +ave/chunk `, :doc:`fix ave/atom `, or +:doc:`fix ave/histo ` commands. If you wish to sum a +per-atom quantity into a single global quantity, see the :doc:`compute +reduce ` command. :doc:`Computes ` that produce global quantities are those which -do not have the word *atom* in their style name. Only a few -:doc:`fixes ` produce global quantities. See the doc pages for -individual fixes for info on which ones produce such values. -:doc:`Variables ` of style *equal* and *vector* are the only -ones that can be used with this fix. Variables of style *atom* cannot -be used, since they produce per-atom values. +do not have the word *atom* in their style name. Only a few :doc:`fixes +` produce global quantities. See the doc pages for individual +fixes for info on which ones produce such values. :doc:`Variables +` of style *equal* and *vector* are the only ones that can be +used with this fix. Variables of style *atom* cannot be used, since +they produce per-atom values. -The input values must all be scalars or vectors with a bracketed term appended, -indicating the :math:`I^\text{th}` value of the vector is used. +The input values must all be scalars or vectors with a bracketed term +appended, indicating the :math:`I^\text{th}` value of the vector is +used. -The result of this fix can be accessed as a vector, containing the interleaved -moments of each input in order. The first requested moment of input 1 -has index 1, the second index 2, the first of input 2 has index 3 -and so on. +The result of this fix can be accessed as a vector, containing the +interleaved moments of each input in order. The first requested moment +of input 1 has index 1, the second index 2, the first of input 2 has +index 3 and so on. ---------- -For input values from a compute or fix or variable, the bracketed -index I can be specified using a wildcard asterisk with the index to -effectively specify multiple values. This takes the form "\*" or -"\*n" or "m\*" or "m\*n". If :math:`N` is the size of the vector, -then an asterisk with no numeric values means all indices from 1 to :math:`N`. -A leading asterisk means all indices from 1 to n (inclusive). A trailing -asterisk means all indices from n to :math:`N` (inclusive). A middle asterisk -means all indices from m to n (inclusive). +For input values from a compute or fix or variable, the bracketed index +I can be specified using a wildcard asterisk with the index to +effectively specify multiple values. This takes the form "\*" or "\*n" +or "m\*" or "m\*n". If :math:`N` is the size of the vector, then an +asterisk with no numeric values means all indices from 1 to :math:`N`. +A leading asterisk means all indices from 1 to n (inclusive). A +trailing asterisk means all indices from n to :math:`N` (inclusive). A +middle asterisk means all indices from m to n (inclusive). -Using a wildcard is the same as if the individual elements of the -vector or cells of the array had been listed one by one. For examples, see the +Using a wildcard is the same as if the individual elements of the vector +or cells of the array had been listed one by one. For examples, see the description of this capability in :doc:`fix ave/time `. ---------- -The :math:`N_\text{every}`, :math:`N_\text{repeat}`, and :math:`N_\text{freq}` -arguments specify on what time steps the input values will be used in order to -contribute to the average. The final statistics are generated on -time steps that are a multiple of :math:`N_\text{freq}`\ . The average is over -a window of up to :math:`N_\text{repeat}` quantities, computed in the preceding -portion of the simulation every :math:`N_\text{every}` time steps. +The :math:`N_\text{every}`, :math:`N_\text{repeat}`, and +:math:`N_\text{freq}` arguments specify on what time steps the input +values will be used in order to contribute to the average. The final +statistics are generated on time steps that are a multiple of +:math:`N_\text{freq}`\ . The average is over a window of up to +:math:`N_\text{repeat}` quantities, computed in the preceding portion of +the simulation every :math:`N_\text{every}` time steps. .. note:: - Contrary to some fix ave/* commands, the values of this fix are not restricted by any special relation: - it is valid to have a window larger than :math:`N_\text{freq}` as well as the other way around. + Contrary to some fix ave/* commands, the values of this fix are not + restricted by any special relation: it is valid to have a window + larger than :math:`N_\text{freq}` as well as the other way around. -For example, if :math:`N_\text{freq}=100` and :math:`N_\text{repeat}=5` (and -:math:`N_\text{every}=1`), then values from time steps 96, 97, 98, 99, and 100 -will be used. This means some intervening time steps do not contribute to the result. -If :math:`N_\text{freq}=5` and :math:`N_\text{repeat}=10`, then values will -first be calculated on step 5 from steps 1-5, on step 10 from 1-10, on -step 15 from 5-15 and so on, forming a rolling average. +For example, if :math:`N_\text{freq}=100` and :math:`N_\text{repeat}=5` +(and :math:`N_\text{every}=1`), then values from time steps 96, 97, 98, +99, and 100 will be used. This means some intervening time steps do not +contribute to the result. If :math:`N_\text{freq}=5` and +:math:`N_\text{repeat}=10`, then values will first be calculated on step +5 from steps 1-5, on step 10 from 1-10, on step 15 from 5-15 and so on, +forming a rolling average. ---------- If a value begins with "c\_", a compute ID must follow which has been -previously defined in the input script. If no bracketed term is appended, -the global scalar calculated by the compute is used. If a bracketed term is -appended, the Ith element of the global vector calculated by the compute is used. -See the discussion above for how I can be specified with a wildcard -asterisk to effectively specify multiple values. +previously defined in the input script. If no bracketed term is +appended, the global scalar calculated by the compute is used. If a +bracketed term is appended, the Ith element of the global vector +calculated by the compute is used. See the discussion above for how I +can be specified with a wildcard asterisk to effectively specify +multiple values. If a value begins with "f\_", a fix ID must follow which has been -previously defined in the input script. If no bracketed term is appended, -the global scalar calculated by the fix is used. If a bracketed term is -appended, the Ith element of the global vector calculated by the fix is used. -See the discussion above for how I can be specified with a wildcard asterisk to -effectively specify multiple values. +previously defined in the input script. If no bracketed term is +appended, the global scalar calculated by the fix is used. If a +bracketed term is appended, the Ith element of the global vector +calculated by the fix is used. See the discussion above for how I can +be specified with a wildcard asterisk to effectively specify multiple +values. Note that some fixes only produce their values on certain time steps, which must be compatible with *Nevery*, else an error will result. -Users can also write code for their own fix styles and :doc:`add them to LAMMPS `. +Users can also write code for their own fix styles and :doc:`add them to +LAMMPS `. -If a value begins with "v\_", a variable name must follow which has -been previously defined in the input script. Only equal-style or vector-style +If a value begins with "v\_", a variable name must follow which has been +previously defined in the input script. Only equal-style or vector-style variables can be used, which both produce global values. Vector-style variables require a bracketed term to specify the Ith element of the vector calculated by the variable. -Note that variables of style *equal* and *vector* define a formula -which can reference individual atom properties or thermodynamic -keywords, or they can invoke other computes, fixes, or variables when -they are evaluated, so this is a very general means of specifying -quantities to time average. +Note that variables of style *equal* and *vector* define a formula which +can reference individual atom properties or thermodynamic keywords, or +they can invoke other computes, fixes, or variables when they are +evaluated, so this is a very general means of specifying quantities to +time average. ---------- -The moments are output in the order requested in the arguments following the last -input. Any number and order of moments can be specified, although it does not make -much sense to specify the same moment multiple times. All moments are computed in -terms of corrected sample (not population) cumulants :math:`k_{1..4}` (see -:ref:`(Cramer)`), the standardized moments follow :ref:`(Joanes)`. +The moments are output in the order requested in the arguments following +the last input. Any number and order of moments can be specified, +although it does not make much sense to specify the same moment multiple +times. All moments are computed in terms of corrected sample (not +population) cumulants :math:`k_{1..4}` (see :ref:`(Cramer)`), +the standardized moments follow :ref:`(Joanes)`. -For *mean*, the arithmetic mean :math:`\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i` is calculated. +For *mean*, the arithmetic mean :math:`\bar{x} = \frac{1}{n} +\sum_{i=1}^{n} x_i` is calculated. -For *variance*, the Bessel-corrected sample variance -:math:`var = k_2 = \frac{1}{n - 1} \sum_{i=1}^{n} (x_i - \bar{x})^2` is calculated. +For *variance*, the Bessel-corrected sample variance :math:`var = k_2 = +\frac{1}{n - 1} \sum_{i=1}^{n} (x_i - \bar{x})^2` is calculated. For *stddev*, the Bessel-corrected sample standard deviation :math:`stddev = \sqrt{k_2}` is calculated. -For *skew*, the adjusted Fisher--Pearson standardized moment -:math:`G_1 = \frac{k_3}{k_2^{3/2}} = \frac{k_3}{stddev^3}` is calculated. +For *skew*, the adjusted Fisher--Pearson standardized moment :math:`G_1 += \frac{k_3}{k_2^{3/2}} = \frac{k_3}{stddev^3}` is calculated. For *kurtosis*, the adjusted Fisher--Pearson standardized moment :math:`G_2 = \frac{k_4}{k_2^2}` is calculated. @@ -178,16 +191,17 @@ For *kurtosis*, the adjusted Fisher--Pearson standardized moment Fix invocation and output can be modified by optional keywords. -The *start* keyword specifies that the first invocation should be no earlier than -the step number given (but will still occur on a multiple of *Nfreq*). -The default is step 0. Often input values can be 0.0 at time 0, so setting -*start* to a larger value can avoid including a 0.0 in a longer series. +The *start* keyword specifies that the first invocation should be no +earlier than the step number given (but will still occur on a multiple +of *Nfreq*). The default is step 0. Often input values can be 0.0 at +time 0, so setting *start* to a larger value can avoid including a 0.0 +in a longer series. -The *history* allows keeping a record of previous results. By default, only -the most recent invocation is accessible. +The *history* allows keeping a record of previous results. By default, +only the most recent invocation is accessible. -For example, this will output values which are delayed by 10 invocations, -meaning 10000 time steps: +For example, this will output values which are delayed by 10 +invocations, meaning 10000 time steps: .. code-block:: LAMMPS @@ -199,8 +213,9 @@ result of the first input value would be accessed as "f_name[1][1]", "f_name[1][4]" is the 4th most recent and so on. Vector access is always the same as the first array row, corresponding to the most recent result. -This fix can be used in conjunction with :doc:`fix halt ` to stop -a run automatically if a quantity is converged to within some limit: +This fix can be used in conjunction with :doc:`fix halt ` to +stop a run automatically if a quantity is converged to within some +limit: .. code-block:: LAMMPS @@ -209,10 +224,11 @@ a run automatically if a quantity is converged to within some limit: variable stopcond equal "abs(f_aveg[1]-f_aveg[1][10])`. This fix produces a global vector and global array which can be accessed -by various :doc:`output commands `. -The values can be accessed on any time step, but may not be current. +by various :doc:`output commands `. The values can be +accessed on any time step, but may not be current. -A vector is produced with # of elements = number of moments * number of inputs. -The moments are output in the order given on fix definition. An array is -produced having # of rows = value of *history* and # of columns = same as -vector output, using the same ordering. +A global vector is produced with the # of elements = number of moments * +number of inputs. The moments are output in the order given in the fix +definition. An array is produced having # of rows = value of *history* +and # of columns = same as vector output, using the same ordering. Each element can be either "intensive" or "extensive", depending on whether the values contributing to the element are "intensive" or "extensive". If a @@ -246,8 +262,8 @@ Restrictions """""""""""" This compute is part of the EXTRA-FIX package. It is only enabled if -LAMMPS was built with that package. See the -:doc:`Build package ` page for more info. +LAMMPS was built with that package. See the :doc:`Build package +` page for more info. Related commands """""""""""""""" From 747ed4244fcd6728e23172268e1b19b3567d704e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Wed, 28 May 2025 13:04:27 +0200 Subject: [PATCH 09/14] documentation updates based on review --- doc/src/Commands_fix.rst | 2 +- doc/src/fix.rst | 2 +- doc/src/fix_ave_moments.rst | 107 ++++++----- .../moments/log.02May2025.valtest.g++.1 | 178 ++++++++++++++++++ .../moments/log.02May2025.valtest.g++.4 | 178 ++++++++++++++++++ 5 files changed, 415 insertions(+), 52 deletions(-) create mode 100644 examples/PACKAGES/moments/log.02May2025.valtest.g++.1 create mode 100644 examples/PACKAGES/moments/log.02May2025.valtest.g++.4 diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index cdc7a4a89d..f8c0937e9f 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -26,10 +26,10 @@ OPT. * :doc:`ave/chunk ` * :doc:`ave/correlate ` * :doc:`ave/correlate/long ` - * :doc:`ave/moments ` * :doc:`ave/grid ` * :doc:`ave/histo ` * :doc:`ave/histo/weight ` + * :doc:`ave/moments ` * :doc:`ave/time ` * :doc:`aveforce ` * :doc:`balance ` diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 935cd842c9..d49850e7da 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -205,10 +205,10 @@ accelerated styles exist. * :doc:`ave/chunk ` - compute per-chunk time-averaged quantities * :doc:`ave/correlate ` - compute/output time correlations * :doc:`ave/correlate/long ` - alternative to :doc:`ave/correlate ` that allows efficient calculation over long time windows -* :doc:`ave/moments ` - compute moments of scalar quantities * :doc:`ave/grid ` - compute per-grid time-averaged quantities * :doc:`ave/histo ` - compute/output time-averaged histograms * :doc:`ave/histo/weight ` - weighted version of fix ave/histo +* :doc:`ave/moments ` - compute moments of scalar quantities * :doc:`ave/time ` - compute/output global time-averaged quantities * :doc:`aveforce ` - add an averaged force to each atom * :doc:`balance ` - perform dynamic load-balancing diff --git a/doc/src/fix_ave_moments.rst b/doc/src/fix_ave_moments.rst index c773069a0b..a89ebbca09 100644 --- a/doc/src/fix_ave_moments.rst +++ b/doc/src/fix_ave_moments.rst @@ -30,14 +30,14 @@ Syntax * one or more moments to compute can be listed * moment = *mean* or *stddev* or *variance* or *skew* or *kurtosis*, see exact definitions below. * zero or more keyword/arg pairs may be appended -* keyword = *start* or *delay* +* keyword = *start* or *history* .. parsed-literal:: *start* args = Nstart Nstart = invoke first after this time step - *history* args = Ndelay - Ndelay = keep a history of up to Ndelay invocations + *history* args = Nrecent + Nrecent = keep a history of up to Nrecent outputs Examples """""""" @@ -52,10 +52,10 @@ Description .. versionadded:: TBD -Using one or more variables as input every few time steps, calculate the -moments of the underlying distribution based on the samples collected -over a time step window. The definitions of the moments calculated are -given below. +Using one or more values as input, calculate the moments of the underlying +(population) distribution based on samples collected every few time +steps over a time step window. The definitions of the moments calculated +are given below. The group specified with this command is ignored. However, note that specified values may represent calculations performed by computes and @@ -64,30 +64,29 @@ fixes which store their own "group" definitions. Each listed value can be the result of a :doc:`compute ` or :doc:`fix ` or the evaluation of an equal-style or vector-style :doc:`variable `. In each case, the compute, fix, or variable -must produce a global quantity, quantity, not a per-atom or local -quantity. If you wish to spatial- or time-average or histogram per-atom +must produce a global quantity, not a per-atom or local quantity. +If you wish to spatial- or time-average or histogram per-atom quantities from a compute, fix, or variable, then see the :doc:`fix ave/chunk `, :doc:`fix ave/atom `, or :doc:`fix ave/histo ` commands. If you wish to sum a per-atom quantity into a single global quantity, see the :doc:`compute reduce ` command. -:doc:`Computes ` that produce global quantities are those which -do not have the word *atom* in their style name. Only a few :doc:`fixes -` produce global quantities. See the doc pages for individual -fixes for info on which ones produce such values. :doc:`Variables -` of style *equal* and *vector* are the only ones that can be -used with this fix. Variables of style *atom* cannot be used, since -they produce per-atom values. +Many :doc:`computes ` and :doc:`fixes ` produce global +quantities. See their doc pages for details. :doc:`Variables ` +of style *equal* and *vector* are the only ones that can be used with +this fix. Variables of style *atom* cannot be used, since they produce +per-atom values. The input values must all be scalars or vectors with a bracketed term appended, indicating the :math:`I^\text{th}` value of the vector is used. The result of this fix can be accessed as a vector, containing the -interleaved moments of each input in order. The first requested moment -of input 1 has index 1, the second index 2, the first of input 2 has -index 3 and so on. +interleaved moments of each input in order. If M moments are requested, +then the moments of input 1 will be the first M values in the vector +output by this fix. The moments of input 2 will the next M values, etc. +If there are N values, the vector length will be N*M. ---------- @@ -112,21 +111,23 @@ values will be used in order to contribute to the average. The final statistics are generated on time steps that are a multiple of :math:`N_\text{freq}`\ . The average is over a window of up to :math:`N_\text{repeat}` quantities, computed in the preceding portion of -the simulation every :math:`N_\text{every}` time steps. +the simulation once every :math:`N_\text{every}` time steps. .. note:: - Contrary to some fix ave/* commands, the values of this fix are not - restricted by any special relation: it is valid to have a window - larger than :math:`N_\text{freq}` as well as the other way around. + Contrary to most fix ave/* commands, it is not required that Nevery * + Nrepeat <= Nfreq. This is to allow the user to choose the time + window and number of samples contributing to the output at each + Nfreq interval. For example, if :math:`N_\text{freq}=100` and :math:`N_\text{repeat}=5` -(and :math:`N_\text{every}=1`), then values from time steps 96, 97, 98, -99, and 100 will be used. This means some intervening time steps do not -contribute to the result. If :math:`N_\text{freq}=5` and -:math:`N_\text{repeat}=10`, then values will first be calculated on step -5 from steps 1-5, on step 10 from 1-10, on step 15 from 5-15 and so on, -forming a rolling average. +(and :math:`N_\text{every}=1`), then on step 100 values from time steps +96, 97, 98, 99, and 100 will be used. The fix does not compute its +inputs on steps that are not required. If :math:`N_\text{freq}=5`, +:math:`N_\text{repeat}=8` and :math:`N_\text{every}=1`, then values +will first be calculated on step 5 from steps 1-5, on step 10 from 3-10, +on step 15 from 8-15 and so on, forming a rolling average over +timesteps that span a time window larger than Nfreq. ---------- @@ -191,31 +192,36 @@ For *kurtosis*, the adjusted Fisher--Pearson standardized moment Fix invocation and output can be modified by optional keywords. -The *start* keyword specifies that the first invocation should be no +The *start* keyword specifies that the first computation should be no earlier than the step number given (but will still occur on a multiple of *Nfreq*). The default is step 0. Often input values can be 0.0 at time 0, so setting *start* to a larger value can avoid including a 0.0 in a longer series. -The *history* allows keeping a record of previous results. By default, -only the most recent invocation is accessible. +The *history* keyword stores the Nrecent most recent outputs on Nfreq +timesteps, so they can be accessed as global outputs of the fix. By +default, only the most recent output is accessible. For example, if +history 10 is specified and Nfreq = 1000, then on timestep 20000, the +Nfreq outputs from steps 20000, 19000, ... 11000 are available for +access. See below for details on how to access the history values. -For example, this will output values which are delayed by 10 -invocations, meaning 10000 time steps: +For example, this will store the outputs of the previous 10 Nfreq +time steps, i.e. a window of 10000 time steps: .. code-block:: LAMMPS fix 1 all ave/moments 1 200 1000 v_volume mean history 10 -The previous results can be accessed by additional rows on the fix output -array, containing the N-th last evaluation result. For example, the most recent -result of the first input value would be accessed as "f_name[1][1]", -"f_name[1][4]" is the 4th most recent and so on. Vector access is always the -same as the first array row, corresponding to the most recent result. +The previous results can be accessed as values in a global array output +by this fix. Each column of the array is the vector output of the N-th +preceding Nfreq timestep. For example, the most recent result of the +third input value would be accessed as "f_name[3][1]", "f_name[3][4]" +is the 4th most recent and so on. The current vector output is always +the first column of the array, corresponding to the most recent result. -This fix can be used in conjunction with :doc:`fix halt ` to -stop a run automatically if a quantity is converged to within some -limit: +To illustrate the utility of keeping output history, consider using +this fix in conjunction with :doc:`fix halt ` to stop a run +automatically if a quantity is converged to within some desired tolerance: .. code-block:: LAMMPS @@ -244,15 +250,16 @@ accessed on any time step, but may not be current. A global vector is produced with the # of elements = number of moments * number of inputs. The moments are output in the order given in the fix -definition. An array is produced having # of rows = value of *history* -and # of columns = same as vector output, using the same ordering. +definition. An array is produced having # of rows = same as vector output, +using the same ordering and # of columns = value of *history*. There is +always at least one column. -Each element can be either "intensive" or "extensive", depending on whether -the values contributing to the element are "intensive" or "extensive". If a -compute or fix provides the value being time averaged, then the compute or -fix determines whether the value is intensive or extensive; see the page -for that compute or fix for further info. Values produced by a variable -are treated as intensive. +Each element of the global vector or array can be either "intensive" or +"extensive", depending on whether the values contributing to the element +are "intensive" or "extensive". If a compute or fix provides the value +being time averaged, then the compute or fix determines whether the value +is intensive or extensive; see the page for that compute or fix for +further info. Values produced by a variable are treated as intensive. No parameter of this fix can be used with the *start/stop* keywords of the :doc:`run ` command. This fix is not invoked during diff --git a/examples/PACKAGES/moments/log.02May2025.valtest.g++.1 b/examples/PACKAGES/moments/log.02May2025.valtest.g++.1 new file mode 100644 index 0000000000..86cbeee12b --- /dev/null +++ b/examples/PACKAGES/moments/log.02May2025.valtest.g++.1 @@ -0,0 +1,178 @@ +LAMMPS (2 Apr 2025 - Development - patch_4Feb2025-645-gba166d42e1-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:99) + using 1 OpenMP thread(s) per MPI task +# create pure copper system +units metal +lattice fcc 3.75 +Lattice spacing in x,y,z = 3.75 3.75 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box +Created orthogonal box = (0 0 0) to (22.5 22.5 22.5) + 1 by 1 by 1 MPI processor grid + +timestep 0.002 +create_atoms 1 box +Created 864 atoms + using lattice units in orthogonal box = (0 0 0) to (22.5 22.5 22.5) + create_atoms CPU = 0.001 seconds + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 0.2000000000000000111 + +variable toteng equal "etotal" +fix 2 all ave/moments 1 10 10 v_toteng mean variance skew kurtosis + +thermo_style custom step etotal f_2[*] +thermo_modify format float %14.8f + +thermo 1 +run 100 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.6825 + ghost atom cutoff = 8.6825 + binsize = 4.34125, bins = 6 6 6 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair eam/alloy, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.484 | 3.484 | 3.484 Mbytes + Step TotEng f_2[1] f_2[2] f_2[3] f_2[4] + 0 -2884.91592826 0.00000000 0.00000000 0.00000000 0.00000000 + 1 -2888.74461907 0.00000000 0.00000000 0.00000000 0.00000000 + 2 -2898.78491936 0.00000000 0.00000000 0.00000000 0.00000000 + 3 -2910.70619667 0.00000000 0.00000000 0.00000000 0.00000000 + 4 -2919.41734302 0.00000000 0.00000000 0.00000000 0.00000000 + 5 -2923.24980175 0.00000000 0.00000000 0.00000000 0.00000000 + 6 -2923.79800148 0.00000000 0.00000000 0.00000000 0.00000000 + 7 -2922.97580252 0.00000000 0.00000000 0.00000000 0.00000000 + 8 -2921.95601941 0.00000000 0.00000000 0.00000000 0.00000000 + 9 -2921.45319499 0.00000000 0.00000000 0.00000000 0.00000000 + 10 -2921.81460149 -2915.29004998 148.32538381 1.60272422 1.50844200 + 11 -2923.00059466 -2915.29004998 148.32538381 1.60272422 1.50844200 + 12 -2924.63075671 -2915.29004998 148.32538381 1.60272422 1.50844200 + 13 -2926.18037946 -2915.29004998 148.32538381 1.60272422 1.50844200 + 14 -2927.22356281 -2915.29004998 148.32538381 1.60272422 1.50844200 + 15 -2927.62053073 -2915.29004998 148.32538381 1.60272422 1.50844200 + 16 -2927.49949128 -2915.29004998 148.32538381 1.60272422 1.50844200 + 17 -2927.12292174 -2915.29004998 148.32538381 1.60272422 1.50844200 + 18 -2926.73637250 -2915.29004998 148.32538381 1.60272422 1.50844200 + 19 -2926.49482990 -2915.29004998 148.32538381 1.60272422 1.50844200 + 20 -2926.44714720 -2926.29565870 2.07215006 1.62317861 2.37019300 + 21 -2926.56102718 -2926.29565870 2.07215006 1.62317861 2.37019300 + 22 -2926.76734347 -2926.29565870 2.07215006 1.62317861 2.37019300 + 23 -2926.98403044 -2926.29565870 2.07215006 1.62317861 2.37019300 + 24 -2927.15193693 -2926.29565870 2.07215006 1.62317861 2.37019300 + 25 -2927.24498540 -2926.29565870 2.07215006 1.62317861 2.37019300 + 26 -2927.26914121 -2926.29565870 2.07215006 1.62317861 2.37019300 + 27 -2927.25021402 -2926.29565870 2.07215006 1.62317861 2.37019300 + 28 -2927.21637817 -2926.29565870 2.07215006 1.62317861 2.37019300 + 29 -2927.19085616 -2926.29565870 2.07215006 1.62317861 2.37019300 + 30 -2927.18360687 -2927.08195198 0.05722486 1.54894969 1.44984748 + 31 -2927.19243579 -2927.08195198 0.05722486 1.54894969 1.44984748 + 32 -2927.20805612 -2927.08195198 0.05722486 1.54894969 1.44984748 + 33 -2927.22285606 -2927.08195198 0.05722486 1.54894969 1.44984748 + 34 -2927.23274852 -2927.08195198 0.05722486 1.54894969 1.44984748 + 35 -2927.23953263 -2927.08195198 0.05722486 1.54894969 1.44984748 + 36 -2927.24805761 -2927.08195198 0.05722486 1.54894969 1.44984748 + 37 -2927.26215638 -2927.08195198 0.05722486 1.54894969 1.44984748 + 38 -2927.28298252 -2927.08195198 0.05722486 1.54894969 1.44984748 + 39 -2927.31025065 -2927.08195198 0.05722486 1.54894969 1.44984748 + 40 -2927.33874897 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 41 -2927.36224413 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 42 -2927.37729800 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 43 -2927.38671916 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 44 -2927.39115082 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 45 -2927.39614318 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 46 -2927.40444730 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 47 -2927.41888601 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 48 -2927.43954388 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 49 -2927.46210058 -2927.25378252 0.00209108 -0.65432756 -0.21113798 + 50 -2927.48270024 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 51 -2927.49822500 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 52 -2927.50765361 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 53 -2927.51223225 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 54 -2927.51510653 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 55 -2927.52035921 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 56 -2927.53170012 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 57 -2927.54910408 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 58 -2927.57357292 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 59 -2927.60356966 -2927.41212333 0.00148630 -0.72914987 -0.39161968 + 60 -2927.63344447 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 61 -2927.66186165 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 62 -2927.68810360 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 63 -2927.71163480 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 64 -2927.73036225 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 65 -2927.74726656 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 66 -2927.76525638 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 67 -2927.78432762 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 68 -2927.80305095 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 69 -2927.82406714 -2927.54449679 0.00204640 -1.06571776 0.04430271 + 70 -2927.84622122 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 71 -2927.86886493 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 72 -2927.89150302 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 73 -2927.91480122 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 74 -2927.93739399 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 75 -2927.96075707 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 76 -2927.98525702 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 77 -2928.00918972 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 78 -2928.03266453 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 79 -2928.05673430 -2927.75621522 0.00356092 0.06232090 -0.94076248 + 80 -2928.08120268 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 81 -2928.10618717 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 82 -2928.13191751 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 83 -2928.15675025 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 84 -2928.18178044 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 85 -2928.20538210 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 86 -2928.22991006 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 87 -2928.25238345 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 88 -2928.27490378 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 89 -2928.29697980 -2927.97383685 0.00511363 -0.03242365 -1.20956903 + 90 -2928.31902032 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 91 -2928.34079951 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 92 -2928.36448072 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 93 -2928.38918869 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 94 -2928.41578734 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 95 -2928.44466633 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 96 -2928.47414034 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 97 -2928.50507273 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 98 -2928.53751007 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 99 -2928.56947939 -2928.21552149 0.00511983 0.08421866 -1.19120544 + 100 -2928.60000318 -2928.46411283 0.00779929 -0.14908790 -1.24292534 +Loop time of 0.579661 on 1 procs for 100 steps with 864 atoms + +Performance: 29.811 ns/day, 0.805 hours/ns, 172.515 timesteps/s, 149.053 katom-step/s +96.3% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.54316 | 0.54316 | 0.54316 | 0.0 | 93.70 +Neigh | 0.0041212 | 0.0041212 | 0.0041212 | 0.0 | 0.71 +Comm | 0.0034702 | 0.0034702 | 0.0034702 | 0.0 | 0.60 +Output | 0.014085 | 0.014085 | 0.014085 | 0.0 | 2.43 +Modify | 0.01321 | 0.01321 | 0.01321 | 0.0 | 2.28 +Other | | 0.001612 | | | 0.28 + +Nlocal: 864 ave 864 max 864 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 3767 ave 3767 max 3767 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 96746 ave 96746 max 96746 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 96746 +Ave neighs/atom = 111.97454 +Neighbor list builds = 1 +Dangerous builds = 0 + +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/moments/log.02May2025.valtest.g++.4 b/examples/PACKAGES/moments/log.02May2025.valtest.g++.4 new file mode 100644 index 0000000000..f7321d2326 --- /dev/null +++ b/examples/PACKAGES/moments/log.02May2025.valtest.g++.4 @@ -0,0 +1,178 @@ +LAMMPS (2 Apr 2025 - Development - patch_4Feb2025-645-gba166d42e1-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:99) + using 1 OpenMP thread(s) per MPI task +# create pure copper system +units metal +lattice fcc 3.75 +Lattice spacing in x,y,z = 3.75 3.75 3.75 +region box block 0 6 0 6 0 6 +create_box 2 box +Created orthogonal box = (0 0 0) to (22.5 22.5 22.5) + 1 by 2 by 2 MPI processor grid + +timestep 0.002 +create_atoms 1 box +Created 864 atoms + using lattice units in orthogonal box = (0 0 0) to (22.5 22.5 22.5) + create_atoms CPU = 0.001 seconds + +pair_style eam/alloy +pair_coeff * * AlCu.eam.alloy Cu Al + +# Initialize to a high temperature, then cool in npt ensemble +velocity all create 1000.0 6567345 +fix 1 all npt temp 300.0 300.0 $(500*dt) iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 $(100*dt) +fix 1 all npt temp 300.0 300.0 1 iso 0.0 0.0 0.2000000000000000111 + +variable toteng equal "etotal" +fix 2 all ave/moments 1 10 10 v_toteng mean variance skew kurtosis + +thermo_style custom step etotal f_2[*] +thermo_modify format float %14.8f + +thermo 1 +run 100 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.6825 + ghost atom cutoff = 8.6825 + binsize = 4.34125, bins = 6 6 6 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair eam/alloy, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.42 | 3.42 | 3.42 Mbytes + Step TotEng f_2[1] f_2[2] f_2[3] f_2[4] + 0 -2884.91592826 0.00000000 0.00000000 0.00000000 0.00000000 + 1 -2888.74473521 0.00000000 0.00000000 0.00000000 0.00000000 + 2 -2898.78463435 0.00000000 0.00000000 0.00000000 0.00000000 + 3 -2910.70366466 0.00000000 0.00000000 0.00000000 0.00000000 + 4 -2919.40999553 0.00000000 0.00000000 0.00000000 0.00000000 + 5 -2923.23570887 0.00000000 0.00000000 0.00000000 0.00000000 + 6 -2923.77707961 0.00000000 0.00000000 0.00000000 0.00000000 + 7 -2922.94386730 0.00000000 0.00000000 0.00000000 0.00000000 + 8 -2921.92251474 0.00000000 0.00000000 0.00000000 0.00000000 + 9 -2921.42476103 0.00000000 0.00000000 0.00000000 0.00000000 + 10 -2921.79501042 -2915.27419717 148.08574615 1.60354430 1.51194865 + 11 -2922.99498349 -2915.27419717 148.08574615 1.60354430 1.51194865 + 12 -2924.64023395 -2915.27419717 148.08574615 1.60354430 1.51194865 + 13 -2926.19980790 -2915.27419717 148.08574615 1.60354430 1.51194865 + 14 -2927.25022454 -2915.27419717 148.08574615 1.60354430 1.51194865 + 15 -2927.64953875 -2915.27419717 148.08574615 1.60354430 1.51194865 + 16 -2927.52804735 -2915.27419717 148.08574615 1.60354430 1.51194865 + 17 -2927.14916045 -2915.27419717 148.08574615 1.60354430 1.51194865 + 18 -2926.76078244 -2915.27419717 148.08574615 1.60354430 1.51194865 + 19 -2926.51878380 -2915.27419717 148.08574615 1.60354430 1.51194865 + 20 -2926.47129883 -2926.31628615 2.10313655 1.62594474 2.38000930 + 21 -2926.59030835 -2926.31628615 2.10313655 1.62594474 2.38000930 + 22 -2926.80121221 -2926.31628615 2.10313655 1.62594474 2.38000930 + 23 -2927.02526150 -2926.31628615 2.10313655 1.62594474 2.38000930 + 24 -2927.20079704 -2926.31628615 2.10313655 1.62594474 2.38000930 + 25 -2927.30192483 -2926.31628615 2.10313655 1.62594474 2.38000930 + 26 -2927.33194351 -2926.31628615 2.10313655 1.62594474 2.38000930 + 27 -2927.31647527 -2926.31628615 2.10313655 1.62594474 2.38000930 + 28 -2927.28391864 -2926.31628615 2.10313655 1.62594474 2.38000930 + 29 -2927.25821953 -2926.31628615 2.10313655 1.62594474 2.38000930 + 30 -2927.25085808 -2927.13609190 0.06387000 1.52055179 1.31247839 + 31 -2927.25723201 -2927.13609190 0.06387000 1.52055179 1.31247839 + 32 -2927.27197789 -2927.13609190 0.06387000 1.52055179 1.31247839 + 33 -2927.28667044 -2927.13609190 0.06387000 1.52055179 1.31247839 + 34 -2927.29879455 -2927.13609190 0.06387000 1.52055179 1.31247839 + 35 -2927.30701891 -2927.13609190 0.06387000 1.52055179 1.31247839 + 36 -2927.31785921 -2927.13609190 0.06387000 1.52055179 1.31247839 + 37 -2927.33272014 -2927.13609190 0.06387000 1.52055179 1.31247839 + 38 -2927.35282056 -2927.13609190 0.06387000 1.52055179 1.31247839 + 39 -2927.37849130 -2927.13609190 0.06387000 1.52055179 1.31247839 + 40 -2927.40448350 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 41 -2927.42423249 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 42 -2927.43769919 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 43 -2927.44493813 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 44 -2927.44923137 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 45 -2927.45439729 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 46 -2927.46365674 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 47 -2927.48173952 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 48 -2927.50371663 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 49 -2927.52750629 -2927.32080685 0.00219675 -0.52051260 -0.50322958 + 50 -2927.54872274 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 51 -2927.56277664 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 52 -2927.57050508 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 53 -2927.57241043 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 54 -2927.57517748 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 55 -2927.58161786 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 56 -2927.59393740 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 57 -2927.61367876 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 58 -2927.64096296 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 59 -2927.67356621 -2927.47358404 0.00168128 -0.79883601 -0.48497973 + 60 -2927.70625176 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 61 -2927.73673853 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 62 -2927.76292153 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 63 -2927.78541405 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 64 -2927.80292853 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 65 -2927.81988675 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 66 -2927.83680256 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 67 -2927.85379296 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 68 -2927.87418119 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 69 -2927.89451588 -2927.60908846 0.00241645 -1.10903745 0.07175615 + 70 -2927.91602570 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 71 -2927.93874793 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 72 -2927.96195498 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 73 -2927.98521535 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 74 -2928.01060565 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 75 -2928.03584561 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 76 -2928.06090892 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 77 -2928.08509438 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 78 -2928.11095399 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 79 -2928.13711339 -2927.82832077 0.00334657 0.04700770 -0.91589129 + 80 -2928.16413424 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 81 -2928.19005959 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 82 -2928.21654649 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 83 -2928.24249986 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 84 -2928.26861892 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 85 -2928.29480718 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 86 -2928.32144325 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 87 -2928.34727619 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 88 -2928.37131285 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 89 -2928.39531126 -2928.04905744 0.00575008 -0.05409710 -1.19501222 + 90 -2928.41739503 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 91 -2928.43978811 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 92 -2928.46316822 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 93 -2928.48654219 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 94 -2928.51132482 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 95 -2928.53938009 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 96 -2928.56852408 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 97 -2928.59814410 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 98 -2928.62787940 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 99 -2928.65853178 -2928.30652706 0.00595440 0.06693205 -1.24851322 + 100 -2928.68735978 -2928.55806426 0.00711607 -0.13829819 -1.25519738 +Loop time of 0.327437 on 4 procs for 100 steps with 864 atoms + +Performance: 52.774 ns/day, 0.455 hours/ns, 305.402 timesteps/s, 263.868 katom-step/s +91.9% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.27213 | 0.27259 | 0.27312 | 0.1 | 83.25 +Neigh | 0.00096945 | 0.0015991 | 0.0022533 | 1.5 | 0.49 +Comm | 0.026726 | 0.027088 | 0.027516 | 0.2 | 8.27 +Output | 0.0029839 | 0.0048706 | 0.0097487 | 4.0 | 1.49 +Modify | 0.012374 | 0.016834 | 0.018623 | 2.0 | 5.14 +Other | | 0.004455 | | | 1.36 + +Nlocal: 216 ave 224 max 204 min +Histogram: 1 0 0 0 0 0 0 2 0 1 +Nghost: 2147 ave 2159 max 2139 min +Histogram: 1 0 0 2 0 0 0 0 0 1 +Neighs: 24185.8 ave 26045 max 21309 min +Histogram: 1 0 0 0 0 1 0 0 0 2 + +Total # of neighbors = 96743 +Ave neighs/atom = 111.97106 +Neighbor list builds = 1 +Dangerous builds = 0 + +Total wall time: 0:00:00 From ce074d475f145c26211729a23c520ac270d6be40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=BCtter?= Date: Thu, 29 May 2025 01:03:28 +0200 Subject: [PATCH 10/14] additional small changes to doc page and code comment --- doc/src/fix_ave_moments.rst | 28 +++++++++++++++------------- src/EXTRA-FIX/fix_ave_moments.cpp | 3 ++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/doc/src/fix_ave_moments.rst b/doc/src/fix_ave_moments.rst index a89ebbca09..93be06aea6 100644 --- a/doc/src/fix_ave_moments.rst +++ b/doc/src/fix_ave_moments.rst @@ -53,7 +53,7 @@ Description .. versionadded:: TBD Using one or more values as input, calculate the moments of the underlying -(population) distribution based on samples collected every few time +(population) distributions based on samples collected every few time steps over a time step window. The definitions of the moments calculated are given below. @@ -199,11 +199,12 @@ time 0, so setting *start* to a larger value can avoid including a 0.0 in a longer series. The *history* keyword stores the Nrecent most recent outputs on Nfreq -timesteps, so they can be accessed as global outputs of the fix. By -default, only the most recent output is accessible. For example, if -history 10 is specified and Nfreq = 1000, then on timestep 20000, the -Nfreq outputs from steps 20000, 19000, ... 11000 are available for -access. See below for details on how to access the history values. +timesteps, so they can be accessed as global outputs of the fix. Nrecent +must be >= 1. The default is 1, meaning only the most recent output is +accessible. For example, if history 10 is specified and Nfreq = 1000, +then on timestep 20000, the Nfreq outputs from steps 20000, 19000, ... +11000 are available for access. See below for details on how to access +the history values. For example, this will store the outputs of the previous 10 Nfreq time steps, i.e. a window of 10000 time steps: @@ -214,10 +215,11 @@ time steps, i.e. a window of 10000 time steps: The previous results can be accessed as values in a global array output by this fix. Each column of the array is the vector output of the N-th -preceding Nfreq timestep. For example, the most recent result of the -third input value would be accessed as "f_name[3][1]", "f_name[3][4]" -is the 4th most recent and so on. The current vector output is always -the first column of the array, corresponding to the most recent result. +preceding Nfreq timestep. For example, assuming a single moment is +calculated, the most recent result corresponding to the third input +value would be accessed as "f_name[3][1]", "f_name[3][4]" is the 4th +most recent and so on. The current vector output is always the first +column of the array, corresponding to the most recent result. To illustrate the utility of keeping output history, consider using this fix in conjunction with :doc:`fix halt ` to stop a run @@ -250,9 +252,9 @@ accessed on any time step, but may not be current. A global vector is produced with the # of elements = number of moments * number of inputs. The moments are output in the order given in the fix -definition. An array is produced having # of rows = same as vector output, -using the same ordering and # of columns = value of *history*. There is -always at least one column. +definition. An array is produced having # of rows = length of vector +output (with an ordering which matches the vector) and # of columns = +value of *history*. There is always at least one column. Each element of the global vector or array can be either "intensive" or "extensive", depending on whether the values contributing to the element diff --git a/src/EXTRA-FIX/fix_ave_moments.cpp b/src/EXTRA-FIX/fix_ave_moments.cpp index 3b102cde77..ec3522aeb1 100644 --- a/src/EXTRA-FIX/fix_ave_moments.cpp +++ b/src/EXTRA-FIX/fix_ave_moments.cpp @@ -377,8 +377,9 @@ double FixAveMoments::compute_array(int i, int j) { if (i >= size_vector) return 0.0; if (j >= nhistory) return 0.0; + // locate the j'th previous result in the ring buffer, relative to the + // row before iresult (the current insert cursor) int row = (iresult - 1 - j + nhistory) % nhistory; - if (row >= nhistory) return 0.0; return result_list[row][i]; } From f12d1d3c5b783cf286177ae45350c9af5b57d525 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 26 May 2025 17:56:26 -0400 Subject: [PATCH 11/14] we only need the MPI C library support for loading liblammps.so dynamically --- examples/COUPLE/plugin/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/COUPLE/plugin/CMakeLists.txt b/examples/COUPLE/plugin/CMakeLists.txt index 00f86058fb..c8deb5c7c6 100644 --- a/examples/COUPLE/plugin/CMakeLists.txt +++ b/examples/COUPLE/plugin/CMakeLists.txt @@ -27,7 +27,7 @@ if(MSVC) add_compile_definitions(_CRT_SECURE_NO_WARNINGS) endif() -find_package(MPI REQUIRED) +find_package(MPI REQUIRED COMPONENTS C) # do not include the (obsolete) MPI C++ bindings which makes # for leaner object files and avoids namespace conflicts set(MPI_CXX_SKIP_MPICXX TRUE) From f839532cf6ae85f4d7882d7e54ea7601cecda83e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 29 May 2025 05:37:01 -0400 Subject: [PATCH 12/14] silence compiler warnings --- src/EXTRA-FIX/fix_ave_moments.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EXTRA-FIX/fix_ave_moments.cpp b/src/EXTRA-FIX/fix_ave_moments.cpp index ec3522aeb1..c0d4b6c9d0 100644 --- a/src/EXTRA-FIX/fix_ave_moments.cpp +++ b/src/EXTRA-FIX/fix_ave_moments.cpp @@ -196,7 +196,7 @@ FixAveMoments::FixAveMoments(LAMMPS *lmp, int narg, char **arg) : // this fix produces a global vector and array vector_flag = 1; - size_vector = nvalues*moments.size(); + size_vector = nvalues * moments.size(); array_flag = 1; size_array_rows = size_vector; size_array_cols = nhistory; @@ -239,7 +239,7 @@ FixAveMoments::FixAveMoments(LAMMPS *lmp, int narg, char **arg) : else if (extvalue != extarray) error->all(FLERR, Error::NOLASTLINE, "Fix ave/moments cannot set output array " "intensive/extensive from these inputs"); - for (int j=0; j Date: Thu, 29 May 2025 14:27:16 +0200 Subject: [PATCH 13/14] improve documentation of moment corrections --- doc/src/fix_ave_moments.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/src/fix_ave_moments.rst b/doc/src/fix_ave_moments.rst index 93be06aea6..494c96a414 100644 --- a/doc/src/fix_ave_moments.rst +++ b/doc/src/fix_ave_moments.rst @@ -169,9 +169,10 @@ time average. The moments are output in the order requested in the arguments following the last input. Any number and order of moments can be specified, although it does not make much sense to specify the same moment multiple -times. All moments are computed in terms of corrected sample (not -population) cumulants :math:`k_{1..4}` (see :ref:`(Cramer)`), -the standardized moments follow :ref:`(Joanes)`. +times. All moments are computed using a correction of the sample estimators +used to obtain unbiased cumulants :math:`k_{1..4}` (see :ref:`(Cramer) +`). The correction for variance is the standard Bessel +correction. For other moments, see :ref:`(Joanes)`. For *mean*, the arithmetic mean :math:`\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i` is calculated. From 06af3b8c4a71d5b9ba17cec4c3ddf92e54a5ba57 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 29 May 2025 14:39:39 -0400 Subject: [PATCH 14/14] Fix typo in doc/src/fix_ave_moments.rst Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- doc/src/fix_ave_moments.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/fix_ave_moments.rst b/doc/src/fix_ave_moments.rst index 494c96a414..b80cdf5db9 100644 --- a/doc/src/fix_ave_moments.rst +++ b/doc/src/fix_ave_moments.rst @@ -44,7 +44,7 @@ Examples .. code-block:: LAMMPS - fix 1 all ave/moments 1 1000 100 v_volume mean sttdev + fix 1 all ave/moments 1 1000 100 v_volume mean stddev fix 1 all ave/moments 1 200 1000 v_volume variance kurtosis history 10 Description