From fa412c13aa3de31b8af8e6e2ac473f90dd515e21 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Fri, 15 Oct 2021 15:43:26 -0600 Subject: [PATCH 01/25] Add compute phase/atom --- src/KOKKOS/Install.sh | 2 + src/KOKKOS/compute_phase_atom_kokkos.cpp | 210 +++++++++++++++++++ src/KOKKOS/compute_phase_atom_kokkos.h | 73 +++++++ src/compute_phase_atom.cpp | 246 +++++++++++++++++++++++ src/compute_phase_atom.h | 88 ++++++++ 5 files changed, 619 insertions(+) create mode 100644 src/KOKKOS/compute_phase_atom_kokkos.cpp create mode 100644 src/KOKKOS/compute_phase_atom_kokkos.h create mode 100644 src/compute_phase_atom.cpp create mode 100644 src/compute_phase_atom.h diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index 04bf84ed31..ac5efec076 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -92,6 +92,8 @@ action compute_coord_atom_kokkos.cpp action compute_coord_atom_kokkos.h action compute_orientorder_atom_kokkos.cpp action compute_orientorder_atom_kokkos.h +action compute_phase_atom_kokkos.cpp +action compute_phase_atom_kokkos.h action compute_temp_kokkos.cpp action compute_temp_kokkos.h action compute_temp_deform_kokkos.cpp diff --git a/src/KOKKOS/compute_phase_atom_kokkos.cpp b/src/KOKKOS/compute_phase_atom_kokkos.cpp new file mode 100644 index 0000000000..0b30c5d6fd --- /dev/null +++ b/src/KOKKOS/compute_phase_atom_kokkos.cpp @@ -0,0 +1,210 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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. +------------------------------------------------------------------------- */ + +#include "compute_phase_atom_kokkos.h" + +#include "atom_kokkos.h" +#include "atom_masks.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "memory_kokkos.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor_kokkos.h" +#include "pair.h" +#include "update.h" +#include "math_const.h" + +#include +#include + +using namespace LAMMPS_NS; +using namespace MathConst; + + +/* ---------------------------------------------------------------------- */ + +template +ComputePhaseAtomKokkos::ComputePhaseAtomKokkos(LAMMPS *lmp, int narg, char **arg) : + ComputePhaseAtom(lmp, narg, arg) +{ + kokkosable = 1; + atomKK = (AtomKokkos *) atom; + execution_space = ExecutionSpaceFromDevice::space; + datamask_read = EMPTY_MASK; + datamask_modify = EMPTY_MASK; +} + +/* ---------------------------------------------------------------------- */ + +template +ComputePhaseAtomKokkos::~ComputePhaseAtomKokkos() +{ + if (copymode) return; + + memoryKK->destroy_kokkos(k_phase,phase); +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputePhaseAtomKokkos::init() +{ + ComputePhaseAtom::init(); + + // need an occasional full neighbor list + + // irequest = neigh request made by parent class + + int irequest = neighbor->nrequest - 1; + + neighbor->requests[irequest]-> + kokkos_host = std::is_same::value && + !std::is_same::value; + neighbor->requests[irequest]-> + kokkos_device = std::is_same::value; +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputePhaseAtomKokkos::compute_peratom() +{ + invoked_peratom = update->ntimestep; + + // grow phase array if necessary + + if (atom->nmax > nmax) { + memoryKK->destroy_kokkos(k_phase,phase); + nmax = atom->nmax; + memoryKK->create_kokkos(k_phase,phase,nmax,2,"phase/atom:phase"); + d_phase = k_phase.view(); + array_atom = phase; + } + + // need velocities of ghost atoms + + atomKK->sync(Host,V_MASK); + comm->forward_comm_compute(this); + atomKK->modified(Host,V_MASK); + + // invoke full neighbor list (will copy or build if necessary) + + neighbor->build_one(list); + int inum = list->inum; + + NeighListKokkos* k_list = static_cast*>(list); + d_numneigh = k_list->d_numneigh; + d_neighbors = k_list->d_neighbors; + d_ilist = k_list->d_ilist; + + // compute phase for each atom in group + // use full neighbor list to count atoms less than cutoff + + atomKK->sync(execution_space,X_MASK|V_MASK|TYPE_MASK|MASK_MASK); + x = atomKK->k_x.view(); + v = atomKK->k_v.view(); + type = atomKK->k_type.view(); + mask = atomKK->k_mask.view(); + + Kokkos::deep_copy(d_phase,0.0); + + copymode = 1; + typename Kokkos::RangePolicy policy(0,inum); + Kokkos::parallel_for("ComputePhaseAtom",policy,*this); + copymode = 0; + + k_phase.modify(); + k_phase.sync_host(); +} + +template +KOKKOS_INLINE_FUNCTION +void ComputePhaseAtomKokkos::operator()(TagComputePhaseAtom, const int &ii) const +{ + const int i = d_ilist[ii]; + if (mask[i] & groupbit) { + const X_FLOAT xtmp = x(i,0); + const X_FLOAT ytmp = x(i,1); + const X_FLOAT ztmp = x(i,2); + const int jnum = d_numneigh[i]; + + // i atom contribution + + int count = 1; + double vsum[3]; + vsum[0] = v(i,0); + vsum[1] = v(i,1); + vsum[2] = v(i,2); + + for (int jj = 0; jj < jnum; jj++) { + int j = d_neighbors(i,jj); + j &= NEIGHMASK; + + const F_FLOAT delx = x(j,0) - xtmp; + const F_FLOAT dely = x(j,1) - ytmp; + const F_FLOAT delz = x(j,2) - ztmp; + const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + count++; + vsum[0] += v(j,0); + vsum[1] += v(j,1); + vsum[2] += v(j,2); + } + } + + double vavg[3]; + vavg[0] = vsum[0]/count; + vavg[1] = vsum[1]/count; + vavg[2] = vsum[2]/count; + + // i atom contribution + + count = 1; + double vnet[3]; + vnet[0] = v(i,0) - vavg[0]; + vnet[1] = v(i,1) - vavg[1]; + vnet[2] = v(i,2) - vavg[2]; + double ke_sum = vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2]; + + for (int jj = 0; jj < jnum; jj++) { + int j = d_neighbors(i,jj); + j &= NEIGHMASK; + + const F_FLOAT delx = x(j,0) - xtmp; + const F_FLOAT dely = x(j,1) - ytmp; + const F_FLOAT delz = x(j,2) - ztmp; + const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + count++; + vnet[0] = v(j,0) - vavg[0]; + vnet[1] = v(j,1) - vavg[1]; + vnet[2] = v(j,2) - vavg[2]; + ke_sum += vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2]; + } + } + double density = count/sphere_vol; + double temp = ke_sum/3.0/count; + d_phase(i,0) = density; + d_phase(i,1) = temp; + } +} + +namespace LAMMPS_NS { +template class ComputePhaseAtomKokkos; +#ifdef LMP_KOKKOS_GPU +template class ComputePhaseAtomKokkos; +#endif +} diff --git a/src/KOKKOS/compute_phase_atom_kokkos.h b/src/KOKKOS/compute_phase_atom_kokkos.h new file mode 100644 index 0000000000..8cfa35d2c8 --- /dev/null +++ b/src/KOKKOS/compute_phase_atom_kokkos.h @@ -0,0 +1,73 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 COMPUTE_CLASS + +ComputeStyle(phase/atom/kk,ComputePhaseAtomKokkos) +ComputeStyle(phase/atom/kk/device,ComputePhaseAtomKokkos) +ComputeStyle(phase/atom/kk/host,ComputePhaseAtomKokkos) + +#else + +#ifndef LMP_COMPUTE_PHASE_KOKKOS_ATOM_H +#define LMP_COMPUTE_PHASE_KOKKOS_ATOM_H + +#include "compute_phase_atom.h" +#include "kokkos_type.h" + +namespace LAMMPS_NS { + +struct TagComputePhaseAtom{}; + +template +class ComputePhaseAtomKokkos : public ComputePhaseAtom { + public: + typedef DeviceType device_type; + typedef ArrayTypes AT; + + ComputePhaseAtomKokkos(class LAMMPS *, int, char **); + virtual ~ComputePhaseAtomKokkos(); + void init(); + void compute_peratom(); + + KOKKOS_INLINE_FUNCTION + void operator()(TagComputePhaseAtom, const int&) const; + + private: + typename AT::t_x_array_randomread x; + typename AT::t_v_array_randomread v; + typename ArrayTypes::t_int_1d_randomread type; + typename ArrayTypes::t_int_1d mask; + + typename AT::t_neighbors_2d d_neighbors; + typename AT::t_int_1d_randomread d_ilist; + typename AT::t_int_1d_randomread d_numneigh; + + DAT::tdual_float_2d k_phase; + typename AT::t_float_2d d_phase; +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +*/ diff --git a/src/compute_phase_atom.cpp b/src/compute_phase_atom.cpp new file mode 100644 index 0000000000..0f166b2be2 --- /dev/null +++ b/src/compute_phase_atom.cpp @@ -0,0 +1,246 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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. +------------------------------------------------------------------------- */ + +#include "compute_phase_atom.h" + +#include "atom.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "group.h" +#include "memory.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" +#include "math_const.h" + +#include +#include + +using namespace LAMMPS_NS; +using namespace MathConst; + + +/* ---------------------------------------------------------------------- */ + +ComputePhaseAtom::ComputePhaseAtom(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), + phase(nullptr) +{ + if (narg != 4) error->all(FLERR,"Illegal compute phase/atom command"); + + cutoff = utils::numeric(FLERR,arg[3],false,lmp); + cutsq = cutoff*cutoff; + sphere_vol = 4.0/3.0*MY_PI*cutsq*cutoff; + + peratom_flag = 1; + size_peratom_cols = 2; + + comm_forward = 3; + + nmax = 0; +} + +/* ---------------------------------------------------------------------- */ + +ComputePhaseAtom::~ComputePhaseAtom() +{ + if (copymode) return; + + memory->destroy(phase); +} + +/* ---------------------------------------------------------------------- */ + +void ComputePhaseAtom::init() +{ + int cutflag = 1; + if (force->pair && sqrt(cutsq) <= force->pair->cutforce) + cutflag = 0; + + // need an occasional full neighbor list + + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->pair = 0; + neighbor->requests[irequest]->compute = 1; + neighbor->requests[irequest]->half = 0; + neighbor->requests[irequest]->full = 1; + neighbor->requests[irequest]->occasional = 1; + if (cutflag) { + neighbor->requests[irequest]->cut = 1; + neighbor->requests[irequest]->cutoff = cutoff; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputePhaseAtom::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void ComputePhaseAtom::compute_peratom() +{ + int i,j,ii,jj,inum,jnum; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count; + double vsum[3],vavg[3],vnet[3]; + + invoked_peratom = update->ntimestep; + + // grow phase array if necessary + + if (atom->nmax > nmax) { + memory->destroy(phase); + nmax = atom->nmax; + memory->create(phase,nmax,2,"phase/atom:phase"); + array_atom = phase; + } + + // need velocities of ghost atoms + + comm->forward_comm_compute(this); + + // invoke full neighbor list (will copy or build if necessary) + + neighbor->build_one(list); + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // compute phase for each atom in group + // use full neighbor list to count atoms less than cutoff + + double **x = atom->x; + double **v = atom->v; + int *type = atom->type; + int *mask = atom->mask; + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + + if (mask[i] & groupbit) { + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + // i atom contribution + + count = 1; + vsum[0] = v[i][0]; + vsum[1] = v[i][1]; + vsum[2] = v[i][2]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + count++; + vsum[0] += v[j][0]; + vsum[1] += v[j][1]; + vsum[2] += v[j][2]; + } + } + + vavg[0] = vsum[0]/count; + vavg[1] = vsum[1]/count; + vavg[2] = vsum[2]/count; + + // i atom contribution + + count = 1; + vnet[0] = v[i][0] - vavg[0]; + vnet[1] = v[i][1] - vavg[1]; + vnet[2] = v[i][2] - vavg[2]; + double ke_sum = vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + count++; + vnet[0] = v[j][0] - vavg[0]; + vnet[1] = v[j][1] - vavg[1]; + vnet[2] = v[j][2] - vavg[2]; + ke_sum += vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2]; + } + } + double density = count/sphere_vol; + double temp = ke_sum/3.0/count; + phase[i][0] = density; + phase[i][1] = temp; + } + } +} + +/* ---------------------------------------------------------------------- */ + +int ComputePhaseAtom::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + double **v = atom->v; + + int i,m=0; + for (i = 0; i < n; ++i) { + buf[m++] = v[list[i]][0]; + buf[m++] = v[list[i]][1]; + buf[m++] = v[list[i]][2]; + } + + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputePhaseAtom::unpack_forward_comm(int n, int first, double *buf) +{ + double **v = atom->v; + + int i,last,m=0; + last = first + n; + for (i = first; i < last; ++i) { + v[i][0] = buf[m++]; + v[i][1] = buf[m++]; + v[i][2] = buf[m++]; + } +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based array +------------------------------------------------------------------------- */ + +double ComputePhaseAtom::memory_usage() +{ + double bytes = (double)2*nmax * sizeof(double); + return bytes; +} diff --git a/src/compute_phase_atom.h b/src/compute_phase_atom.h new file mode 100644 index 0000000000..26d9636cc8 --- /dev/null +++ b/src/compute_phase_atom.h @@ -0,0 +1,88 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 COMPUTE_CLASS + +ComputeStyle(phase/atom,ComputePhaseAtom) + +#else + +#ifndef LMP_COMPUTE_PHASE_ATOM_H +#define LMP_COMPUTE_PHASE_ATOM_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputePhaseAtom : public Compute { + public: + ComputePhaseAtom(class LAMMPS *, int, char **); + virtual ~ComputePhaseAtom(); + virtual void init(); + void init_list(int, class NeighList *); + virtual void compute_peratom(); + int pack_forward_comm(int, int *, double *, int, int *); + void unpack_forward_comm(int, int, double *); + double memory_usage(); + + protected: + int nmax; + double cutoff,cutsq,sphere_vol; + class NeighList *list; + + double **phase; +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Could not find compute phase/atom compute ID + +UNDOCUMENTED + +E: Compute phase/atom compute ID is not orientorder/atom + +UNDOCUMENTED + +E: Compute phase/atom threshold not between -1 and 1 + +UNDOCUMENTED + +E: Invalid cstyle in compute phase/atom + +UNDOCUMENTED + +E: Compute phase/atom requires components option in compute orientorder/atom + +UNDOCUMENTED + +E: Compute phase/atom requires a pair style be defined + +Self-explanatory. + +E: Compute phase/atom cutoff is longer than pairwise cutoff + +Cannot compute phase at distances longer than the pair cutoff, +since those atoms are not in the neighbor list. + +*/ From 20cd742b4ab6ec6645ba1fd7ed9209f90af2d199 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Fri, 15 Oct 2021 15:59:15 -0600 Subject: [PATCH 02/25] whitespace & urls --- src/KOKKOS/compute_phase_atom_kokkos.cpp | 4 ++-- src/KOKKOS/compute_phase_atom_kokkos.h | 2 +- src/compute_phase_atom.cpp | 20 ++++++++++---------- src/compute_phase_atom.h | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/KOKKOS/compute_phase_atom_kokkos.cpp b/src/KOKKOS/compute_phase_atom_kokkos.cpp index 0b30c5d6fd..b0637526de 100644 --- a/src/KOKKOS/compute_phase_atom_kokkos.cpp +++ b/src/KOKKOS/compute_phase_atom_kokkos.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://lammps.sandia.gov/, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -182,7 +182,7 @@ void ComputePhaseAtomKokkos::operator()(TagComputePhaseAtom, const i for (int jj = 0; jj < jnum; jj++) { int j = d_neighbors(i,jj); j &= NEIGHMASK; - + const F_FLOAT delx = x(j,0) - xtmp; const F_FLOAT dely = x(j,1) - ytmp; const F_FLOAT delz = x(j,2) - ztmp; diff --git a/src/KOKKOS/compute_phase_atom_kokkos.h b/src/KOKKOS/compute_phase_atom_kokkos.h index 8cfa35d2c8..247acd3f03 100644 --- a/src/KOKKOS/compute_phase_atom_kokkos.h +++ b/src/KOKKOS/compute_phase_atom_kokkos.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://lammps.sandia.gov/, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/compute_phase_atom.cpp b/src/compute_phase_atom.cpp index 0f166b2be2..c1382392d7 100644 --- a/src/compute_phase_atom.cpp +++ b/src/compute_phase_atom.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://lammps.sandia.gov/, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract @@ -152,19 +152,19 @@ void ComputePhaseAtom::compute_peratom() vsum[2] = v[i][2]; for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; + j = jlist[jj]; + j &= NEIGHMASK; - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutsq) { - count++; + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq < cutsq) { + count++; vsum[0] += v[j][0]; vsum[1] += v[j][1]; vsum[2] += v[j][2]; - } + } } vavg[0] = vsum[0]/count; diff --git a/src/compute_phase_atom.h b/src/compute_phase_atom.h index 26d9636cc8..ab0dc3081e 100644 --- a/src/compute_phase_atom.h +++ b/src/compute_phase_atom.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://lammps.sandia.gov/, Sandia National Laboratories + https://www.lammps.org/, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract From 136c15a8bafc43c7245d6f02e6f22eae0cfd40f1 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 4 Nov 2021 19:59:48 -0600 Subject: [PATCH 03/25] Allow dump sort to work with more than 2 billion atoms --- src/dump.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dump.cpp b/src/dump.cpp index 4c02aa3070..282ea0c696 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -237,7 +237,8 @@ void Dump::init() irregular = new Irregular(lmp); bigint size = group->count(igroup); - if (size > MAXSMALLINT) error->all(FLERR,"Too many atoms to dump sort"); + int bigintflag = 0; + if (size > MAXSMALLINT) bigintflag = 1; int isize = static_cast (size); // set reorderflag = 1 if can simply reorder local atoms rather than sort @@ -252,7 +253,7 @@ void Dump::init() if (utils::strmatch(fix->style,"^gcmc")) gcmcflag = 1; - if (sortcol == 0 && atom->tag_consecutive() && !gcmcflag) { + if (sortcol == 0 && atom->tag_consecutive() && !gcmcflag && !bigintflag) { tagint *tag = atom->tag; int *mask = atom->mask; int nlocal = atom->nlocal; From 07a25144ee23560d7d612df96d73b7eaa9d9bbb0 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 4 Nov 2021 20:06:30 -0600 Subject: [PATCH 04/25] Remove error from dump.h --- src/dump.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/dump.h b/src/dump.h index 730d4c9ca9..4237faf8b4 100644 --- a/src/dump.h +++ b/src/dump.h @@ -186,10 +186,6 @@ E: Dump sort column is invalid Self-explanatory. -E: Too many atoms to dump sort - -Cannot sort when running with more than 2^31 atoms. - E: Dump could not find refresh compute ID UNDOCUMENTED From ebb3dcd9ff2317665dcb11476aacc0c2e651b0e8 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 4 Nov 2021 20:20:07 -0600 Subject: [PATCH 05/25] Remove error message --- doc/src/Errors_messages.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/src/Errors_messages.rst b/doc/src/Errors_messages.rst index 3a593b5a3f..c06f4c86e3 100644 --- a/doc/src/Errors_messages.rst +++ b/doc/src/Errors_messages.rst @@ -7772,9 +7772,6 @@ keyword to allow for additional bonds to be formed The system size must fit in a 32-bit integer to use this dump style. -*Too many atoms to dump sort* - Cannot sort when running with more than 2\^31 atoms. - *Too many elements extracted from MEAM library.* Increase 'maxelt' in meam.h and recompile. From 5616336d5e711630857301f9c618d8755b4e5de4 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 18 Nov 2021 07:59:45 -0700 Subject: [PATCH 06/25] Allow sorting with reorderflag for more than 2 billion atoms --- src/dump.cpp | 9 +++------ src/dump.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/dump.cpp b/src/dump.cpp index 282ea0c696..587bd6c9d3 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -237,9 +237,6 @@ void Dump::init() irregular = new Irregular(lmp); bigint size = group->count(igroup); - int bigintflag = 0; - if (size > MAXSMALLINT) bigintflag = 1; - int isize = static_cast (size); // set reorderflag = 1 if can simply reorder local atoms rather than sort // criteria: sorting by ID, atom IDs are consecutive from 1 to Natoms @@ -253,7 +250,7 @@ void Dump::init() if (utils::strmatch(fix->style,"^gcmc")) gcmcflag = 1; - if (sortcol == 0 && atom->tag_consecutive() && !gcmcflag && !bigintflag) { + if (sortcol == 0 && atom->tag_consecutive() && !gcmcflag) { tagint *tag = atom->tag; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -269,7 +266,7 @@ void Dump::init() MPI_Allreduce(&min,&minall,1,MPI_LMP_TAGINT,MPI_MIN,world); MPI_Allreduce(&max,&maxall,1,MPI_LMP_TAGINT,MPI_MAX,world); - if (maxall-minall+1 == isize) { + if (maxall-minall+1 == size) { reorderflag = 1; double range = maxall-minall + EPSILON; idlo = static_cast (range*me/nprocs + minall); @@ -285,7 +282,7 @@ void Dump::init() else if (me+1 != hi) idhi++; nme_reorder = idhi-idlo; - ntotal_reorder = isize; + ntotal_reorder = size; } } } diff --git a/src/dump.h b/src/dump.h index 4237faf8b4..681ce88c96 100644 --- a/src/dump.h +++ b/src/dump.h @@ -116,7 +116,7 @@ class Dump : protected Pointers { bigint ntotal; // total # of per-atom lines in snapshot int reorderflag; // 1 if OK to reorder instead of sort - int ntotal_reorder; // # of atoms that must be in snapshot + bigint ntotal_reorder; // # of atoms that must be in snapshot int nme_reorder; // # of atoms I must own in snapshot tagint idlo; // lowest ID I own when reordering From 94b11964f80c4b4243267c04c6d58244b0226ba6 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 18 Nov 2021 08:32:41 -0700 Subject: [PATCH 07/25] Write dump header after sort to fix incorrect atom count for multiproc --- src/dump.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/dump.cpp b/src/dump.cpp index 587bd6c9d3..9ca7e61e76 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -367,16 +367,6 @@ void Dump::write() if (multiproc != nprocs) MPI_Allreduce(&nme,&nmax,1,MPI_INT,MPI_MAX,world); else nmax = nme; - // write timestep header - // for multiproc, - // nheader = # of lines in this file via Allreduce on clustercomm - - bigint nheader = ntotal; - if (multiproc) - MPI_Allreduce(&bnme,&nheader,1,MPI_LMP_BIGINT,MPI_SUM,clustercomm); - - if (filewriter && write_header_flag) write_header(nheader); - // insure buf is sized for packing and communicating // use nmax to insure filewriter proc can receive info from others // limit nmax*size_one to int since used as arg in MPI calls @@ -429,6 +419,19 @@ void Dump::write() else pack(nullptr); if (sort_flag) sort(); + // write timestep header + // for multiproc, + // nheader = # of lines in this file via Allreduce on clustercomm + // must come after sort, which can change nme + + bigint nheader = ntotal; + if (multiproc) { + bnme = nme; + MPI_Allreduce(&bnme,&nheader,1,MPI_LMP_BIGINT,MPI_SUM,clustercomm); + } + + if (filewriter && write_header_flag) write_header(nheader); + // if buffering, convert doubles into strings // insure sbuf is sized for communicating // cannot buffer if output is to binary file From 15f1c2d9600562624fb9a9a82f61d4a5b080fceb Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Thu, 18 Nov 2021 08:50:09 -0700 Subject: [PATCH 08/25] Fix inaccurate error message --- doc/src/dump_modify.rst | 4 +++- src/dump.cpp | 2 +- src/dump.h | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/src/dump_modify.rst b/doc/src/dump_modify.rst index da7ccffeb2..88b375ecb6 100644 --- a/doc/src/dump_modify.rst +++ b/doc/src/dump_modify.rst @@ -561,7 +561,9 @@ The dump *local* style cannot be sorted by atom ID, since there are typically multiple lines of output per atom. Some dump styles, such as *dcd* and *xtc*, require sorting by atom ID to format the output file correctly. If multiple processors are writing the dump file, via -the "%" wildcard in the dump filename, then sorting cannot be +the "%" wildcard in the dump filename and the *nfile* or *fileper* +keywords are set to non-default values (i.e. the number of dump file +pieces is not equal to the number of procs), then sorting cannot be performed. .. note:: diff --git a/src/dump.cpp b/src/dump.cpp index 9ca7e61e76..2917099ff9 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -228,7 +228,7 @@ void Dump::init() if (sort_flag) { if (multiproc > 1) error->all(FLERR, - "Cannot dump sort when multiple dump files are written"); + "Cannot dump sort when 'nfile' or 'fileper' keywords are set to non-default values"); if (sortcol == 0 && atom->tag_enable == 0) error->all(FLERR,"Cannot dump sort on atom IDs with no atom IDs defined"); if (sortcol && sortcol > size_one) diff --git a/src/dump.h b/src/dump.h index 681ce88c96..468b007096 100644 --- a/src/dump.h +++ b/src/dump.h @@ -173,10 +173,9 @@ E: Dump file MPI-IO output not allowed with % in filename This is because a % signifies one file per processor and MPI-IO creates one large file for all processors. -E: Cannot dump sort when multiple dump files are written +E: Cannot dump sort when 'nfile' or 'fileper' keywords are set to non-default values -In this mode, each processor dumps its atoms to a file, so -no sorting is allowed. +Can only dump sort when the number of dump file pieces using % in filename equals the number of processors E: Cannot dump sort on atom IDs with no atom IDs defined From 97b5651633a8c695c1f38ca8465f8055a7c8ab6e Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 20 Dec 2021 10:33:05 -0700 Subject: [PATCH 09/25] minor correction to angle class2 --- doc/src/angle_class2.rst | 38 +++++++++++++++++++++++-------------- src/CLASS2/angle_class2.cpp | 5 +++++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/doc/src/angle_class2.rst b/doc/src/angle_class2.rst index f257d96dc3..4e8e515564 100644 --- a/doc/src/angle_class2.rst +++ b/doc/src/angle_class2.rst @@ -64,34 +64,44 @@ These are the 4 coefficients for the :math:`E_a` formula: radians internally; hence the various :math:`K` are effectively energy per radian\^2 or radian\^3 or radian\^4. -For the :math:`E_{bb}` formula, each line in a :doc:`angle_coeff ` -command in the input script lists 4 coefficients, the first of which -is "bb" to indicate they are BondBond coefficients. In a data file, -these coefficients should be listed under a "BondBond Coeffs" heading -and you must leave out the "bb", i.e. only list 3 coefficients after -the angle type. +For the :math:`E_{bb}` formula, each line in a :doc:`angle_coeff +` command in the input script lists 4 coefficients, the +first of which is "bb" to indicate they are BondBond coefficients. In +a data file, these coefficients should be listed under a "BondBond +Coeffs" heading and you must leave out the "bb", i.e. only list 3 +coefficients after the angle type. * bb * :math:`M` (energy/distance\^2) * :math:`r_1` (distance) * :math:`r_2` (distance) -For the :math:`E_{ba}` formula, each line in a :doc:`angle_coeff ` -command in the input script lists 5 coefficients, the first of which -is "ba" to indicate they are BondAngle coefficients. In a data file, -these coefficients should be listed under a "BondAngle Coeffs" heading -and you must leave out the "ba", i.e. only list 4 coefficients after -the angle type. +For the :math:`E_{ba}` formula, each line in a :doc:`angle_coeff +` command in the input script lists 5 coefficients, the +first of which is "ba" to indicate they are BondAngle coefficients. +In a data file, these coefficients should be listed under a "BondAngle +Coeffs" heading and you must leave out the "ba", i.e. only list 4 +coefficients after the angle type. * ba -* :math:`N_1` (energy/distance\^2) -* :math:`N_2` (energy/distance\^2) +* :math:`N_1` (energy/distance) +* :math:`N_2` (energy/distance) * :math:`r_1` (distance) * :math:`r_2` (distance) The :math:`\theta_0` value in the :math:`E_{ba}` formula is not specified, since it is the same value from the :math:`E_a` formula. +.. note:: + + It is important that the order of the I,J,K atoms in each angle + listed in the Angles section of the data file read by the + :doc:`read_data ` command be consistent with the order + of the :math:`r_1` and :math:`r_2` BondBond and BondAngle + coefficients. This is because the terms in the formulas for + :math:`E_{bb}` and :math:`E_{ba}` will use the I,J atoms to compute + :math:`r_{ij}` and the J,K atoms to compute :math:`r_{jk}`. + ---------- .. include:: accel_styles.rst diff --git a/src/CLASS2/angle_class2.cpp b/src/CLASS2/angle_class2.cpp index 82e31440f5..c37c5a8f65 100644 --- a/src/CLASS2/angle_class2.cpp +++ b/src/CLASS2/angle_class2.cpp @@ -169,6 +169,8 @@ void AngleClass2::compute(int eflag, int vflag) // force & energy for bond-angle term + dr1 = r1 - ba_r1[type]; + dr2 = r2 - ba_r2[type]; aa1 = s * dr1 * ba_k1[type]; aa2 = s * dr2 * ba_k2[type]; @@ -459,6 +461,9 @@ double AngleClass2::single(int type, int i1, int i2, int i3) double dr2 = r2 - bb_r2[type]; energy += bb_k[type]*dr1*dr2; + dr1 = r1 - ba_r1[type]; + dr2 = r2 - ba_r2[type]; energy += ba_k1[type]*dr1*dtheta + ba_k2[type]*dr2*dtheta; + return energy; } From 2ee88dab7ee31c439df607c408b48c00b7b88b22 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 20 Dec 2021 10:35:41 -0700 Subject: [PATCH 10/25] same change for angle class2/p6 --- src/MOFFF/angle_class2_p6.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/MOFFF/angle_class2_p6.cpp b/src/MOFFF/angle_class2_p6.cpp index 0fccf6c4cb..e72f9f34fc 100644 --- a/src/MOFFF/angle_class2_p6.cpp +++ b/src/MOFFF/angle_class2_p6.cpp @@ -174,6 +174,8 @@ void AngleClass2P6::compute(int eflag, int vflag) // force & energy for bond-angle term + dr1 = r1 - ba_r1[type]; + dr2 = r2 - ba_r2[type]; aa1 = s * dr1 * ba_k1[type]; aa2 = s * dr2 * ba_k2[type]; @@ -479,6 +481,9 @@ double AngleClass2P6::single(int type, int i1, int i2, int i3) double dr2 = r2 - bb_r2[type]; energy += bb_k[type]*dr1*dr2; + dr1 = r1 - ba_r1[type]; + dr2 = r2 - ba_r2[type]; energy += ba_k1[type]*dr1*dtheta + ba_k2[type]*dr2*dtheta; + return energy; } From 4bc85f07e376ddd6a557bc3635663283cb3fb5be Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 20 Dec 2021 14:29:17 -0700 Subject: [PATCH 11/25] same changes in OPENMP and KOKKOS versions of angle class2 --- src/KOKKOS/angle_class2_kokkos.cpp | 2 ++ src/OPENMP/angle_class2_omp.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/KOKKOS/angle_class2_kokkos.cpp b/src/KOKKOS/angle_class2_kokkos.cpp index 146e8b40ea..0bcc3ad458 100644 --- a/src/KOKKOS/angle_class2_kokkos.cpp +++ b/src/KOKKOS/angle_class2_kokkos.cpp @@ -241,6 +241,8 @@ void AngleClass2Kokkos::operator()(TagAngleClass2Compute Date: Mon, 20 Dec 2021 16:05:44 -0700 Subject: [PATCH 12/25] Remove unused variable --- src/KOKKOS/compute_phase_atom_kokkos.cpp | 1 - src/KOKKOS/compute_phase_atom_kokkos.h | 1 - src/compute_phase_atom.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/src/KOKKOS/compute_phase_atom_kokkos.cpp b/src/KOKKOS/compute_phase_atom_kokkos.cpp index b0637526de..5a21393252 100644 --- a/src/KOKKOS/compute_phase_atom_kokkos.cpp +++ b/src/KOKKOS/compute_phase_atom_kokkos.cpp @@ -116,7 +116,6 @@ void ComputePhaseAtomKokkos::compute_peratom() atomKK->sync(execution_space,X_MASK|V_MASK|TYPE_MASK|MASK_MASK); x = atomKK->k_x.view(); v = atomKK->k_v.view(); - type = atomKK->k_type.view(); mask = atomKK->k_mask.view(); Kokkos::deep_copy(d_phase,0.0); diff --git a/src/KOKKOS/compute_phase_atom_kokkos.h b/src/KOKKOS/compute_phase_atom_kokkos.h index 247acd3f03..7bcc418d85 100644 --- a/src/KOKKOS/compute_phase_atom_kokkos.h +++ b/src/KOKKOS/compute_phase_atom_kokkos.h @@ -46,7 +46,6 @@ class ComputePhaseAtomKokkos : public ComputePhaseAtom { private: typename AT::t_x_array_randomread x; typename AT::t_v_array_randomread v; - typename ArrayTypes::t_int_1d_randomread type; typename ArrayTypes::t_int_1d mask; typename AT::t_neighbors_2d d_neighbors; diff --git a/src/compute_phase_atom.cpp b/src/compute_phase_atom.cpp index c1382392d7..ed6bbb844f 100644 --- a/src/compute_phase_atom.cpp +++ b/src/compute_phase_atom.cpp @@ -131,7 +131,6 @@ void ComputePhaseAtom::compute_peratom() double **x = atom->x; double **v = atom->v; - int *type = atom->type; int *mask = atom->mask; for (ii = 0; ii < inum; ii++) { From 6187431399a1ad6711d882061ec28c697dbd45a7 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 08:34:02 -0700 Subject: [PATCH 13/25] Fix compile error in angle_class2_kokkos --- src/KOKKOS/angle_class2_kokkos.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/KOKKOS/angle_class2_kokkos.cpp b/src/KOKKOS/angle_class2_kokkos.cpp index 0bcc3ad458..2a386f6489 100644 --- a/src/KOKKOS/angle_class2_kokkos.cpp +++ b/src/KOKKOS/angle_class2_kokkos.cpp @@ -224,8 +224,8 @@ void AngleClass2Kokkos::operator()(TagAngleClass2Compute::operator()(TagAngleClass2Compute Date: Tue, 21 Dec 2021 11:28:26 -0500 Subject: [PATCH 14/25] reset force test references for Class2 angle styles --- unittest/force-styles/tests/angle-class2.yaml | 129 ++++++++--------- .../force-styles/tests/angle-class2_p6.yaml | 131 +++++++++--------- 2 files changed, 131 insertions(+), 129 deletions(-) diff --git a/unittest/force-styles/tests/angle-class2.yaml b/unittest/force-styles/tests/angle-class2.yaml index c8896efba1..0b50cce4f6 100644 --- a/unittest/force-styles/tests/angle-class2.yaml +++ b/unittest/force-styles/tests/angle-class2.yaml @@ -1,7 +1,8 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:09:23 2021 +lammps_version: 14 Dec 2021 +date_generated: Tue Dec 21 11:26:44 2021 epsilon: 1e-12 +skip_tests: prerequisites: ! | atom full angle class2 @@ -21,73 +22,73 @@ angle_coeff: ! | 1 ba 20.0 0.0 1.5 1.5 3 ba 10.0 10.0 1.5 1.5 4 ba 0.0 20.0 1.5 1.5 -equilibrium: 4 1.9216075064457565 1.9373154697137058 2.0943951023931953 1.8936822384138474 +equilibrium: 4 1.9216075064457567 1.9373154697137058 2.0943951023931953 1.8936822384138476 extract: ! "" natoms: 29 -init_energy: 45.6315872862689 +init_energy: 46.440896837749044 init_stress: ! |2- - 1.0380900034455654e+02 -8.5596888576343744e+01 1.0543371457027396e+01 9.3533772092305199e+01 -3.0453078736699425e+01 1.6197471265279837e+00 + 1.1893382158997322e+02 -8.8291447119046992e+01 -1.8868912456859972e+00 1.1299617626314146e+02 -8.5358891009896780e+00 7.6967639957246794e+00 init_forces: ! |2 - 1 4.7202113476907201e+01 9.2452097148049379e+00 -2.1894202744712533e+01 - 2 -1.7062797644104073e+00 -1.3815331678107317e+01 -1.1109216556988997e+01 - 3 -1.0818552868961547e+01 4.2757153900854306e+01 4.0134050204129267e+01 - 4 -1.6107291199158311e+01 -2.0450831607561582e+01 1.2394641799374179e+01 - 5 -4.1997303662023540e+01 -4.1453062742803219e+01 -1.7536792897035419e+01 - 6 5.6639792403457349e+01 -1.3580769610788053e+01 -3.9712060060785255e+01 - 7 -1.8054439727078506e+01 1.6983062508083172e+01 1.5587306726806713e+00 - 8 -1.0525801597483865e+01 -1.5574411954009244e+01 8.4303126221362277e+01 - 9 -1.4606126670427546e+01 1.7088847325775880e+01 3.5265027966992148e+00 - 10 -9.2168170333014618e+00 2.5310906045489432e+01 -6.6219876033939016e+01 + 1 4.9843771864003834e+01 3.0925122596911816e+00 -3.5312722193312226e+01 + 2 -7.6547115157834666e-01 -6.1978334793953476e+00 -4.9838162348189323e+00 + 3 -2.0132137208074248e+01 6.1565994561526715e+01 5.8548546756498347e+01 + 4 -1.1800898073962109e+01 -2.7342191490108263e+01 3.6024091179236257e+00 + 5 -3.5756372747916700e+01 -5.0661360858658405e+01 -1.9085859271498553e+01 + 6 5.0734800121225135e+01 -1.5633459340466136e+01 -3.6451541950394720e+01 + 7 -1.8030285239813821e+01 1.7009172193091111e+01 1.5544411167675971e+00 + 8 -1.5632958318497042e+01 -2.1571227015465091e+01 7.4636601692831320e+01 + 9 -1.4606126670427546e+01 1.7088847325775880e+01 3.5265027966992157e+00 + 10 4.9412614063426892e+00 3.2891848318072718e+01 -5.8999099084298045e+01 11 -2.0537012066379056e+01 -7.0930129287428976e+00 7.5068656204459945e+00 - 12 -2.8436344574011141e-01 -6.5767250423083183e+00 -7.8126221608778286e+00 - 13 3.1055904718024561e+00 8.1431271170459514e+00 -1.2597779054058647e+00 - 14 1.6321646299623836e+01 -6.4737292023940052e+00 -6.0969666237587319e+00 - 15 1.2014703003264437e+01 -4.7819952969181587e+00 1.5497667618539472e+01 - 16 9.3845211462413065e+00 9.2380044230210405e+00 6.9332654848904189e+00 - 17 -8.1437876633224571e-01 1.0335590285580882e+00 -2.1333543461785509e-01 - 18 4.7908728028679270e-01 1.6800089801308631e+00 -5.5268875505867383e+00 - 19 -2.0533806941129176e+00 -2.3525964439530416e+00 2.1320670955883561e+00 - 20 1.5742934138261249e+00 6.7258746382217860e-01 3.3948204549983823e+00 - 21 3.9487378529081880e+00 4.3175316427012014e+00 -1.1481919601133793e+01 - 22 -6.5477089696018744e+00 -4.1918690971369452e+00 3.4304260006102911e+00 - 23 2.5989711166936864e+00 -1.2566254556425660e-01 8.0514936005235018e+00 - 24 -8.4094048868779181e-01 4.6838060982897600e+00 -2.5056979703433946e+00 - 25 -1.3589399152326838e+00 -3.2194810517526529e+00 2.1726606908305435e-01 - 26 2.1998804039204756e+00 -1.4643250465371074e+00 2.2884319012603402e+00 - 27 -1.3120258950869723e-01 2.3248353742613195e+00 -7.0687277526256109e-01 - 28 -7.9798149428972343e-01 -1.3623378004463826e+00 -7.5274691791676882e-02 - 29 9.2918408379842066e-01 -9.6249757381493684e-01 7.8214746705423799e-01 -run_energy: 45.4459195202412 + 12 1.3804183606931298e+01 6.4447653590032914e+00 -2.7232856026007504e+01 + 13 3.5360349619705711e-01 9.1396982628926138e-01 4.4753951517849107e+00 + 14 9.6171168365401805e+00 -1.2052302426663841e+01 -3.9493877514992031e+00 + 15 6.4860723734536965e+00 -7.3468753785680629e+00 2.2291265160011950e+01 + 16 -2.1230106290243054e+00 1.3874285421512146e+01 6.8398804299585079e+00 + 17 3.6034624009792791e+00 -4.9831323468942506e+00 3.0333746689077179e+00 + 18 8.4504245756073892e-01 5.5042293626682808e+00 -2.1046811461460457e+01 + 19 -6.5342341140829419e+00 -7.9348302620004993e+00 8.7785874834232587e+00 + 20 5.6891916565222029e+00 2.4306008993322186e+00 1.2268223978037199e+01 + 21 7.8687847056106097e+00 9.2247825951126554e+00 -2.6147407661059020e+01 + 22 -1.3528173582118603e+01 -8.9511461518324538e+00 8.6148798736605858e+00 + 23 5.6593888765079932e+00 -2.7363644328020120e-01 1.7532527787398436e+01 + 24 -4.3228091413199312e+00 1.8218035887352222e+01 -1.0563459250035294e+01 + 25 -4.1518972409293955e+00 -1.2576945219214169e+01 1.7476216234117312e+00 + 26 8.4747063822493267e+00 -5.6410906681380535e+00 8.8158376266235621e+00 + 27 -1.9941459534406549e+00 1.7618141002760062e+01 -5.9162802776486032e+00 + 28 -4.8714180504657234e+00 -1.0506429973856317e+01 1.3714179563487131e-01 + 29 6.8655640039063783e+00 -7.1117110289037466e+00 5.7791384820137317e+00 +run_energy: 46.04254213414856 run_stress: ! |2- - 1.0224296939567702e+02 -8.5149951148281033e+01 1.1077450496851872e+01 9.2245165502849829e+01 -3.1084418227269154e+01 5.2366663320491313e-01 + 1.1725321346181148e+02 -8.7851127936553254e+01 -1.2820805825603960e+00 1.1164348489319656e+02 -9.3238396977559397e+00 6.5868867241338807e+00 run_forces: ! |2 - 1 4.6696948163060675e+01 9.5469544165543052e+00 -2.1330948302985508e+01 - 2 -1.7341210851964273e+00 -1.4128897827282087e+01 -1.1408863992275160e+01 - 3 -1.0105551089272240e+01 4.2277702428791336e+01 3.9657670069675063e+01 - 4 -1.6122111935066883e+01 -2.0098532812588481e+01 1.2653235408843411e+01 - 5 -4.2111565648427224e+01 -4.1283493356078523e+01 -1.7589964848850386e+01 - 6 5.6633343610296642e+01 -1.3630420678353568e+01 -3.9740642386699271e+01 - 7 -1.8067962126721181e+01 1.7005582120491120e+01 1.5568169485445109e+00 - 8 -1.0459403976386902e+01 -1.5611162457913967e+01 8.4226500676174069e+01 - 9 -1.4631300686651667e+01 1.7116506905325277e+01 3.5366459989463483e+00 - 10 -9.1067423535925318e+00 2.5083637022662394e+01 -6.6120603070314331e+01 - 11 -2.0531188000382802e+01 -7.0572039110412836e+00 7.4976926119744087e+00 - 12 -4.5804053460484440e-01 -6.7408368318088137e+00 -7.3612432437675679e+00 - 13 3.0256565331949181e+00 7.9773964875310250e+00 -1.1599249084139895e+00 - 14 1.6325797226942768e+01 -6.0364594808671850e+00 -6.0596304628457736e+00 - 15 1.2032950547216590e+01 -4.6547008559207024e+00 1.4984306358892226e+01 - 16 9.4390365741788855e+00 9.1831264349550388e+00 6.8856125869099509e+00 - 17 -8.2574521858778427e-01 1.0508023955441044e+00 -2.2665944380799952e-01 - 18 4.1662989783566795e-01 1.4355996853101134e+00 -4.6916036738076876e+00 - 19 -1.7454972366844239e+00 -2.0016596312326365e+00 1.8125096846165301e+00 - 20 1.3288673388487560e+00 5.6605994592252307e-01 2.8790939891911576e+00 - 21 3.7257661846966093e+00 4.0481711597815977e+00 -1.0827752619904448e+01 - 22 -6.1593135050903065e+00 -3.9305106214838132e+00 3.2463364124342222e+00 - 23 2.4335473203936973e+00 -1.1766053829778456e-01 7.5814162074702249e+00 - 24 -7.6007405188534261e-01 4.2086623877720974e+00 -2.2508903613389659e+00 - 25 -1.2107922910240914e+00 -2.8924997143595577e+00 1.9797185345341334e-01 - 26 1.9708663429094340e+00 -1.3161626734125400e+00 2.0529185078855527e+00 - 27 -1.2690270648686752e-01 2.1785298399231308e+00 -6.5914069723159696e-01 - 28 -7.4337188418354749e-01 -1.2769741286441925e+00 -7.1075298614674390e-02 - 29 8.7027459067041502e-01 -9.0155571127893830e-01 7.3021599584627139e-01 + 1 4.9310488854556048e+01 3.4204699131043999e+00 -3.4719646460390109e+01 + 2 -8.0299294685685085e-01 -6.5454065929116556e+00 -5.2863994125400326e+00 + 3 -1.9344188743451483e+01 6.1008236345827427e+01 5.7990450617574737e+01 + 4 -1.1820915021801847e+01 -2.6960419197209372e+01 3.9252515610422387e+00 + 5 -3.5905034771726200e+01 -5.0435101635947014e+01 -1.9146824911182328e+01 + 6 5.0729278972279332e+01 -1.5703691297521928e+01 -3.6490325001299325e+01 + 7 -1.8043757960499846e+01 1.7038616039733434e+01 1.5516900804512148e+00 + 8 -1.5552591757457865e+01 -2.1589081417070179e+01 7.4580844287823936e+01 + 9 -1.4632487393832747e+01 1.7116771489893083e+01 3.5369114786793467e+00 + 10 5.0177324966376649e+00 3.2655409113932286e+01 -5.8914010758009439e+01 + 11 -2.0526018243356614e+01 -7.0603095274350611e+00 7.4991583014498691e+00 + 12 1.3523522841409502e+01 6.2514718031216852e+00 -2.6685798485651077e+01 + 13 3.0043046271322960e-01 7.8431109074530148e-01 4.5328635576848786e+00 + 14 9.6740453376714228e+00 -1.1603919453433887e+01 -3.9205080570168040e+00 + 15 6.5345442098934683e+00 -7.2391735244141353e+00 2.1740136588792641e+01 + 16 -2.0494434617404407e+00 1.3825958913895089e+01 6.7881976680816249e+00 + 17 3.5873871255632257e+00 -4.9641420643094554e+00 3.0180089445086313e+00 + 18 7.9531230378610207e-01 5.2629626454507630e+00 -2.0172279025467247e+01 + 19 -6.1997999385006839e+00 -7.5645533008417640e+00 8.4605118212170112e+00 + 20 5.4044876347145818e+00 2.3015906553910015e+00 1.1711767204250236e+01 + 21 7.6462499201271452e+00 8.9238366526271982e+00 -2.5489460284469285e+01 + 22 -1.3116044133706563e+01 -8.6583255717724796e+00 8.4434021193141291e+00 + 23 5.4697942135794175e+00 -2.6551108085471875e-01 1.7046058165155156e+01 + 24 -4.2497082139356905e+00 1.7742951256065766e+01 -1.0303002556901220e+01 + 25 -3.9777181755411437e+00 -1.2246864111150519e+01 1.7323644652289971e+00 + 26 8.2274263894768342e+00 -5.4960871449152453e+00 8.5706380916722225e+00 + 27 -2.0048516565658536e+00 1.7446299537442144e+01 -5.8315780788096188e+00 + 28 -4.7894277572886974e+00 -1.0406054769833135e+01 1.3027326655161572e-01 + 29 6.7942794138545510e+00 -7.0402447676090096e+00 5.7013048122580035e+00 ... diff --git a/unittest/force-styles/tests/angle-class2_p6.yaml b/unittest/force-styles/tests/angle-class2_p6.yaml index 68676960f7..367dc2f450 100644 --- a/unittest/force-styles/tests/angle-class2_p6.yaml +++ b/unittest/force-styles/tests/angle-class2_p6.yaml @@ -1,7 +1,8 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:09:23 2021 +lammps_version: 14 Dec 2021 +date_generated: Tue Dec 21 11:26:44 2021 epsilon: 5e-13 +skip_tests: prerequisites: ! | atom full angle class2/p6 @@ -21,73 +22,73 @@ angle_coeff: ! | 1 ba 20.0 0.0 1.5 1.5 3 ba 10.0 10.0 1.5 1.5 4 ba 0.0 20.0 1.5 1.5 -equilibrium: 4 1.9216075064457565 1.9373154697137058 2.0943951023931953 1.8936822384138474 +equilibrium: 4 1.9216075064457567 1.9373154697137058 2.0943951023931953 1.8936822384138476 extract: ! "" natoms: 29 -init_energy: 45.6314933281677 +init_energy: 46.440802879647805 init_stress: ! |2- - 1.0380655176146676e+02 -8.5598294304263064e+01 1.0547225768036466e+01 9.3533997442530364e+01 -3.0452940351933286e+01 1.6213985364060581e+00 + 1.1893137300688346e+02 -8.8292852846966269e+01 -1.8830369346769591e+00 1.1299640161336661e+02 -8.5357507162235464e+00 7.6984154056027378e+00 init_forces: ! |2 - 1 4.7202230480286389e+01 9.2446782757168187e+00 -2.1892853730746999e+01 - 2 -1.7062799943363052e+00 -1.3815333539761312e+01 -1.1109218053986531e+01 - 3 -1.0819442137600213e+01 4.2755643579721394e+01 4.0131978148937094e+01 - 4 -1.6107331786015202e+01 -2.0450833016170897e+01 1.2394698445624217e+01 - 5 -4.1996775288710346e+01 -4.1451276926607676e+01 -1.7536151963373857e+01 - 6 5.6640330905804802e+01 -1.3581373316126099e+01 -3.9714075413905050e+01 - 7 -1.8054191673295325e+01 1.6982840171711775e+01 1.5587849314106879e+00 - 8 -1.0524752828621686e+01 -1.5572494690475857e+01 8.4307006012653105e+01 - 9 -1.4606116746275049e+01 1.7088845087132931e+01 3.5265010989798085e+00 - 10 -9.2183983294618113e+00 2.5308833813269253e+01 -6.6220570658369525e+01 - 11 -2.0536178089795950e+01 -7.0922505905966178e+00 7.5061958159305595e+00 - 12 -2.8507497680544613e-01 -6.5761946491161254e+00 -7.8131884119322397e+00 - 13 3.1055913097859387e+00 8.1431291943766304e+00 -1.2597770427903630e+00 - 14 1.6321556949530429e+01 -6.4737931388148002e+00 -6.0969371866598330e+00 - 15 1.2014697273266693e+01 -4.7819939276460772e+00 1.5497663357748195e+01 - 16 9.3845137052789855e+00 9.2380146356987876e+00 6.9332800900251534e+00 - 17 -8.1437877303591466e-01 1.0335590376878656e+00 -2.1333543954444023e-01 - 18 4.7908727278798890e-01 1.6800089017685975e+00 -5.5268872325673071e+00 - 19 -2.0533806022955563e+00 -2.3525963295672470e+00 2.1320669593942201e+00 - 20 1.5742933295075674e+00 6.7258742779864933e-01 3.3948202731730870e+00 - 21 3.9487365123920992e+00 4.3175299645965515e+00 -1.1481914586060395e+01 - 22 -6.5477065825321601e+00 -4.1918674696340856e+00 3.4304242277121375e+00 - 23 2.5989700701400609e+00 -1.2566249496246562e-01 8.0514903583482571e+00 - 24 -8.4094044796366130e-01 4.6838059399926504e+00 -2.5056978760993669e+00 - 25 -1.3589398825660985e+00 -3.2194809423072277e+00 2.1726605118393005e-01 - 26 2.1998803305297598e+00 -1.4643249976854225e+00 2.2884318249154370e+00 - 27 -1.3120258888530634e-01 2.3248353691437700e+00 -7.0687277351935407e-01 - 28 -7.9798149292664289e-01 -1.3623377973865247e+00 -7.5274691862757134e-02 - 29 9.2918408181194923e-01 -9.6249757175724537e-01 7.8214746538211122e-01 -run_energy: 45.4458285940593 + 1 4.9843888867383036e+01 3.0919808206030721e+00 -3.5311373179346681e+01 + 2 -7.6547138150424543e-01 -6.1978353410493483e+00 -4.9838177318164663e+00 + 3 -2.0133026476712903e+01 6.1564484240393824e+01 5.8546474701306153e+01 + 4 -1.1800938660819003e+01 -2.7342192898717585e+01 3.6024657641736728e+00 + 5 -3.5755844374603512e+01 -5.0659575042462862e+01 -1.9085218337836995e+01 + 6 5.0735338623572588e+01 -1.5634063045804186e+01 -3.6453557303514501e+01 + 7 -1.8030037186030640e+01 1.7008949856719713e+01 1.5544953754976136e+00 + 8 -1.5631909549634866e+01 -2.1569309751931716e+01 7.4640481484122148e+01 + 9 -1.4606116746275049e+01 1.7088845087132935e+01 3.5265010989798080e+00 + 10 4.9396801101823433e+00 3.2889776085852560e+01 -5.8999793708728561e+01 + 11 -2.0536178089795950e+01 -7.0922505905966178e+00 7.5061958159305604e+00 + 12 1.3803472075865960e+01 6.4452957521954772e+00 -2.7233422277061912e+01 + 13 3.5360433418053783e-01 9.1397190361994329e-01 4.4753960144004115e+00 + 14 9.6170274864467693e+00 -1.2052366363084635e+01 -3.9493583144003042e+00 + 15 6.4860666434559526e+00 -7.3468740092959814e+00 2.2291260899220667e+01 + 16 -2.1230180699866263e+00 1.3874295634189895e+01 6.8398950350932433e+00 + 17 3.6034623942756108e+00 -4.9831323377644736e+00 3.0333746639811334e+00 + 18 8.4504245006193557e-01 5.5042292843060157e+00 -2.1046811143441026e+01 + 19 -6.5342340222655810e+00 -7.9348301476147052e+00 8.7785873472291236e+00 + 20 5.6891915722036455e+00 2.4306008633086891e+00 1.2268223796211903e+01 + 21 7.8687833650945196e+00 9.2247809170080028e+00 -2.6147402645985622e+01 + 22 -1.3528171195048888e+01 -8.9511445243295924e+00 8.6148781007624322e+00 + 23 5.6593878299543681e+00 -2.7363639267841045e-01 1.7532524545223190e+01 + 24 -4.3228091005958014e+00 1.8218035729055110e+01 -1.0563459155791266e+01 + 25 -4.1518972082628096e+00 -1.2576945109768744e+01 1.7476216055126070e+00 + 26 8.4747063088586110e+00 -5.6410906192863681e+00 8.8158375502786583e+00 + 27 -1.9941459528172638e+00 1.7618140997642513e+01 -5.9162802759053958e+00 + 28 -4.8714180491026431e+00 -1.0506429970796459e+01 1.3714179556379100e-01 + 29 6.8655640019199069e+00 -7.1117110268460557e+00 5.7791384803416053e+00 +run_energy: 46.04245232805462 run_stress: ! |2- - 1.0224054425179162e+02 -8.5151354715203126e+01 1.1081280882090672e+01 9.2245389115064398e+01 -3.1084294543117402e+01 5.2530572051471558e-01 + 1.1725078883087194e+02 -8.7852531332776422e+01 -1.2782508811995987e+00 1.1164371026778049e+02 -9.3237176305934248e+00 6.5885234111489295e+00 run_forces: ! |2 - 1 4.6697063144899758e+01 9.5464292184313084e+00 -2.1329615486413495e+01 - 2 -1.7341213469343071e+00 -1.4128899311205867e+01 -1.1408865229626386e+01 - 3 -1.0106423829890657e+01 4.2276216760085092e+01 3.9655618981253937e+01 - 4 -1.6122153804166530e+01 -2.0098535935851185e+01 1.2653292967815302e+01 - 5 -4.2111045474433908e+01 -4.1281732299841927e+01 -1.7589329659171515e+01 - 6 5.6633872451307042e+01 -1.3631017853516695e+01 -3.9742648484553712e+01 - 7 -1.8067710814224181e+01 1.7005356519278848e+01 1.5568722867815019e+00 - 8 -1.0458368774535296e+01 -1.5609267760781632e+01 8.4230369919214809e+01 - 9 -1.4631291097137083e+01 1.7116505329041448e+01 3.5366441447941890e+00 - 10 -9.1083165882262076e+00 2.5081593622661249e+01 -6.6121298210985884e+01 - 11 -2.0530357257878578e+01 -7.0564447871249403e+00 7.4970247183653580e+00 - 12 -4.5873997835014801e-01 -6.7403152848189372e+00 -7.3618095936615644e+00 - 13 3.0256572433426814e+00 7.9773984059331964e+00 -1.1599242567025270e+00 - 14 1.6325706512702343e+01 -6.0365250687180749e+00 -6.0596004500231722e+00 - 15 1.2032945183866531e+01 -4.6546995895395877e+00 1.4984301967909428e+01 - 16 9.4390297519529085e+00 9.1831355042234861e+00 6.8856259318712949e+00 - 17 -8.2574532229437936e-01 1.0508025317442151e+00 -2.2665954686757872e-01 - 18 4.1662989358421232e-01 1.4355996421935044e+00 -4.6916034993533247e+00 - 19 -1.7454971864999060e+00 -2.0016595685522596e+00 1.8125096096904596e+00 - 20 1.3288672929156937e+00 5.6605992635875502e-01 2.8790938896628648e+00 - 21 3.7257651397379274e+00 4.0481698601097618e+00 -1.0827748711362894e+01 - 22 -6.1593116505043302e+00 -3.9305093611054267e+00 3.2463350269770475e+00 - 23 2.4335465107664027e+00 -1.1766049900433539e-01 7.5814136843858462e+00 - 24 -7.6007402633523591e-01 4.2086622887143186e+00 -2.2508903023980524e+00 - 25 -1.2107922707762828e+00 -2.8924996458903025e+00 1.9797184221876996e-01 - 26 1.9708662971115187e+00 -1.3161626428240165e+00 2.0529184601792827e+00 - 27 -1.2690270602781828e-01 2.1785298361926788e+00 -6.5914069596767511e-01 - 28 -7.4337188319492098e-01 -1.2769741264135199e+00 -7.1075298663885261e-02 - 29 8.7027458922273926e-01 -9.0155570977915866e-01 7.3021599463156039e-01 + 1 4.9310604335655682e+01 3.4199456337672487e+00 -3.4718316191911107e+01 + 2 -8.0299317271452264e-01 -6.5454081333117653e+00 -5.2864006747626604e+00 + 3 -1.9345060126536442e+01 6.1006753750400470e+01 5.7988403049659411e+01 + 4 -1.1820957153105841e+01 -2.6960422682106536e+01 3.9253092142830135e+00 + 5 -3.5904516097808205e+01 -5.0433344031821314e+01 -1.9146190690682918e+01 + 6 5.0729808044888514e+01 -1.5704289267936588e+01 -3.6492333161602460e+01 + 7 -1.8043506480508537e+01 1.7038390298430201e+01 1.5517454554100727e+00 + 8 -1.5551557230614444e+01 -2.1587186230569777e+01 7.4584717878493251e+01 + 9 -1.4632477702925939e+01 1.7116769814092336e+01 3.5369096257061594e+00 + 10 5.0161578855418893e+00 3.2653366582115979e+01 -5.8914707964769292e+01 + 11 -2.0525187366514267e+01 -7.0595502886286221e+00 7.4984902661515953e+00 + 12 1.3522823846822945e+01 6.2519930281569955e+00 -2.6686365074578834e+01 + 13 3.0043118312382699e-01 7.8431307047186760e-01 4.5328641811452499e+00 + 14 9.6739544192178748e+00 -1.1603985265483198e+01 -3.9204779603734119e+00 + 15 6.5345389143893406e+00 -7.2391722622226151e+00 2.1740132205563690e+01 + 16 -2.0494503520587521e+00 1.3825967887607892e+01 6.7882109957643362e+00 + 17 3.5873870531468781e+00 -4.9641419029625879e+00 3.0180088465038910e+00 + 18 7.9531229968056927e-01 5.2629626038099762e+00 -2.0172278856982508e+01 + 19 -6.1997998900621667e+00 -7.5645532403308380e+00 8.4605117488474431e+00 + 20 5.4044875903815974e+00 2.3015906365208618e+00 1.1711767108135064e+01 + 21 7.6462488915955822e+00 8.9238353733854954e+00 -2.5489456437353834e+01 + 22 -1.3116042308945529e+01 -8.6583243315139509e+00 8.4434007553408890e+00 + 23 5.4697934173499467e+00 -2.6551104187154384e-01 1.7046055682012945e+01 + 24 -4.2497081893768893e+00 1.7742951160854016e+01 -1.0303002500248269e+01 + 25 -3.9777181560986339e+00 -1.2246864045350220e+01 1.7323644544198329e+00 + 26 8.2274263454755232e+00 -5.4960871155037951e+00 8.5706380458284350e+00 + 27 -2.0048516561480048e+00 1.7446299534047586e+01 -5.8315780776594286e+00 + 28 -4.7894277563898591e+00 -1.0406054767803472e+01 1.3027326650644638e-01 + 29 6.7942794125378638e+00 -7.0402447662441157e+00 5.7013048111529825e+00 ... From 65204e5df06b4be860d250b1f8e5011511a06ed9 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 10:46:00 -0700 Subject: [PATCH 15/25] Add error checks, tweak input --- src/compute_phase_atom.cpp | 49 ++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/compute_phase_atom.cpp b/src/compute_phase_atom.cpp index ed6bbb844f..b8c6b374bf 100644 --- a/src/compute_phase_atom.cpp +++ b/src/compute_phase_atom.cpp @@ -40,15 +40,24 @@ ComputePhaseAtom::ComputePhaseAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), phase(nullptr) { - if (narg != 4) error->all(FLERR,"Illegal compute phase/atom command"); + if (narg < 3 || narg > 5) error->all(FLERR,"Illegal compute phase/atom command"); - cutoff = utils::numeric(FLERR,arg[3],false,lmp); - cutsq = cutoff*cutoff; - sphere_vol = 4.0/3.0*MY_PI*cutsq*cutoff; + // process optional args + + cutoff = 0.0; + + int iarg = 3; + while (iarg < narg) { + if (strcmp(arg[iarg],"cutoff") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal compute phase/atom command"); + cutoff = utils::numeric(FLERR,arg[iarg+1],false,lmp); + if (cutoff <= 0.0) error->all(FLERR,"Illegal compute phase/atom command"); + iarg += 2; + } else error->all(FLERR,"Illegal compute phase/atom command"); + } peratom_flag = 1; size_peratom_cols = 2; - comm_forward = 3; nmax = 0; @@ -67,9 +76,35 @@ ComputePhaseAtom::~ComputePhaseAtom() void ComputePhaseAtom::init() { + if (!force->pair && cutoff == 0.0) + error->all(FLERR,"Compute phase/atom requires a cutoff be specified " + "or a pair style be defined"); + + double skin = neighbor->skin; + if (cutoff != 0.0) { + double mycutneigh = cutoff + skin; + + double cutghost; // as computed by Neighbor and Comm + if (force->pair) + cutghost = MAX(force->pair->cutforce+skin,comm->cutghostuser); + else + cutghost = comm->cutghostuser; + + if (mycutneigh > cutghost) + error->all(FLERR,"Compute phase/atom cutoff exceeds ghost atom range - " + "use comm_modify cutoff command"); + } + int cutflag = 1; - if (force->pair && sqrt(cutsq) <= force->pair->cutforce) - cutflag = 0; + if (force->pair) { + if (cutoff == 0.0) { + cutoff = force->pair->cutforce; + } + if (cutoff <= force->pair->cutforce+skin) cutflag = 0; + } + + cutsq = cutoff*cutoff; + sphere_vol = 4.0/3.0*MY_PI*cutsq*cutoff; // need an occasional full neighbor list From 2533abb2668266a8e070f875737735c1bfb559a0 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 10:46:23 -0700 Subject: [PATCH 16/25] Add doc page --- doc/src/compute_phase_atom.rst | 98 ++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 doc/src/compute_phase_atom.rst diff --git a/doc/src/compute_phase_atom.rst b/doc/src/compute_phase_atom.rst new file mode 100644 index 0000000000..db1e1725f6 --- /dev/null +++ b/doc/src/compute_phase_atom.rst @@ -0,0 +1,98 @@ +.. index:: compute phase/atom +.. index:: compute phase/atom/kk + +compute phase/atom command +================================ + +Accelerator Variants: *phase/atom/kk* + +Syntax +"""""" + +.. parsed-literal:: + + compute ID group-ID phase/atom keyword values ... + +* ID, group-ID are documented in :doc:`compute ` command +* phase/atom = style name of this compute command +* one or more keyword/value pairs may be appended + + .. parsed-literal:: + + keyword = *cutoff* + *cutoff* value = distance cutoff + +Examples +"""""""" + +.. code-block:: LAMMPS + + compute 1 all phase/atom + + compute 1 all phase/atom cutoff 5.0 + comm_modify cutoff 5.0 + +Description +""""""""""" + +Define a computation that calculates the local density and temperature +for each atom and neighbors inside a spherical cutoff. + +The optional keyword *cutoff* defines the distance cutoff +used when searching for neighbors. The default value is the cutoff +specified by the pair style. If the specified cutoff is larger than +that of the pair_style plus neighbor skin, the *comm_modify cutoff* +option must also be set to match the specified cutoff. + +The neighbor list needed to compute this quantity is constructed each +time the calculation is performed (i.e. each time a snapshot of atoms +is dumped). Thus it can be inefficient to compute/dump this quantity +too frequently. + +.. note:: + + If you have a bonded system, then the settings of + :doc:`special_bonds ` command can remove pairwise + interactions between atoms in the same bond, angle, or dihedral. This + is the default setting for the :doc:`special_bonds ` + command, and means those pairwise interactions do not appear in the + neighbor list. Because this fix uses the neighbor list, it also means + those pairs will not be included in the order parameter. This + difficulty can be circumvented by writing a dump file, and using the + :doc:`rerun ` command to compute the order parameter for + snapshots in the dump file. The rerun script can use a + :doc:`special_bonds ` command that includes all pairs in + the neighbor list. + +---------- + + +.. include:: accel_styles.rst + + +---------- + +Output info +""""""""""" + +This compute calculates a per-atom array with two columns: density and temperature. + +These values can be accessed by any command that uses per-atom values +from a compute as input. See the :doc:`Howto output ` doc +page for an overview of LAMMPS output options. + +Restrictions +"""""""""""" + +none + +Related commands +"""""""""""""""" + +:doc:`comm_modify ` + +Default +""""""" + +The option defaults are *cutoff* = pair style cutoff + From a2ab59b162f94f665a7db43f756b5a23eb5f43bd Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 11:07:03 -0700 Subject: [PATCH 17/25] Fix cutoff logic --- src/compute_phase_atom.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compute_phase_atom.cpp b/src/compute_phase_atom.cpp index b8c6b374bf..f8f5e35abf 100644 --- a/src/compute_phase_atom.cpp +++ b/src/compute_phase_atom.cpp @@ -82,15 +82,13 @@ void ComputePhaseAtom::init() double skin = neighbor->skin; if (cutoff != 0.0) { - double mycutneigh = cutoff + skin; - double cutghost; // as computed by Neighbor and Comm if (force->pair) cutghost = MAX(force->pair->cutforce+skin,comm->cutghostuser); else cutghost = comm->cutghostuser; - if (mycutneigh > cutghost) + if (cutoff > cutghost) error->all(FLERR,"Compute phase/atom cutoff exceeds ghost atom range - " "use comm_modify cutoff command"); } From c98f7b3e50bdde536d9b3333950675ab4ce35d15 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 11:40:04 -0700 Subject: [PATCH 18/25] Clean up error message text --- src/KOKKOS/compute_phase_atom_kokkos.h | 6 ------ src/compute_phase_atom.h | 27 +++----------------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/src/KOKKOS/compute_phase_atom_kokkos.h b/src/KOKKOS/compute_phase_atom_kokkos.h index 7bcc418d85..d65f3d571e 100644 --- a/src/KOKKOS/compute_phase_atom_kokkos.h +++ b/src/KOKKOS/compute_phase_atom_kokkos.h @@ -63,10 +63,4 @@ class ComputePhaseAtomKokkos : public ComputePhaseAtom { /* ERROR/WARNING messages: -E: Illegal ... command - -Self-explanatory. Check the input script syntax and compare to the -documentation for the command. You can use -echo screen as a -command-line option when running LAMMPS to see the offending line. - */ diff --git a/src/compute_phase_atom.h b/src/compute_phase_atom.h index ab0dc3081e..b39026b3b5 100644 --- a/src/compute_phase_atom.h +++ b/src/compute_phase_atom.h @@ -56,33 +56,12 @@ Self-explanatory. Check the input script syntax and compare to the documentation for the command. You can use -echo screen as a command-line option when running LAMMPS to see the offending line. -E: Could not find compute phase/atom compute ID - -UNDOCUMENTED - -E: Compute phase/atom compute ID is not orientorder/atom - -UNDOCUMENTED - -E: Compute phase/atom threshold not between -1 and 1 - -UNDOCUMENTED - -E: Invalid cstyle in compute phase/atom - -UNDOCUMENTED - -E: Compute phase/atom requires components option in compute orientorder/atom - -UNDOCUMENTED - -E: Compute phase/atom requires a pair style be defined +E: Compute phase/atom requires a cutoff be specified or a pair style be defined Self-explanatory. -E: Compute phase/atom cutoff is longer than pairwise cutoff +E: Compute phase/atom cutoff exceeds ghost atom range - use comm_modify cutoff command -Cannot compute phase at distances longer than the pair cutoff, -since those atoms are not in the neighbor list. +Self-explanatory. */ From e06222099a45884040503823995c451b7fdf63da Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 11:51:30 -0700 Subject: [PATCH 19/25] Small tweak to docs --- doc/src/compute_phase_atom.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/src/compute_phase_atom.rst b/doc/src/compute_phase_atom.rst index db1e1725f6..6540e52041 100644 --- a/doc/src/compute_phase_atom.rst +++ b/doc/src/compute_phase_atom.rst @@ -40,9 +40,11 @@ for each atom and neighbors inside a spherical cutoff. The optional keyword *cutoff* defines the distance cutoff used when searching for neighbors. The default value is the cutoff -specified by the pair style. If the specified cutoff is larger than -that of the pair_style plus neighbor skin, the *comm_modify cutoff* -option must also be set to match the specified cutoff. +specified by the pair style. If no pair style is defined, then a cutoff +must be defined using this keyword. If the specified cutoff is larger than +that of the pair_style plus neighbor skin (or no pair style is defined), +the *comm_modify cutoff* option must also be set to match that of the +*cutoff* keyword. The neighbor list needed to compute this quantity is constructed each time the calculation is performed (i.e. each time a snapshot of atoms From 2fec3eee6b18f5fc2f21ed392bc5ef6ffc16bd53 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 13:28:36 -0700 Subject: [PATCH 20/25] Add overflow check to dump_h5md --- src/H5MD/dump_h5md.cpp | 1 + src/H5MD/dump_h5md.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/H5MD/dump_h5md.cpp b/src/H5MD/dump_h5md.cpp index bc9c98caa0..a59de9773c 100644 --- a/src/H5MD/dump_h5md.cpp +++ b/src/H5MD/dump_h5md.cpp @@ -181,6 +181,7 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) // allocate global array for atom coords bigint n = group->count(igroup); + if ((bigint) domain->dimension*n > MAXSMALLINT) error->all(FLERR,"Too many atoms for dump h5md"); natoms = static_cast (n); if (every_position>=0) diff --git a/src/H5MD/dump_h5md.h b/src/H5MD/dump_h5md.h index 28b74649c6..5e3f3f8279 100644 --- a/src/H5MD/dump_h5md.h +++ b/src/H5MD/dump_h5md.h @@ -90,6 +90,11 @@ E: Dump h5md requires sorting by atom ID Use the dump_modify sort command to enable this. +E: Too many atoms for dump h5md + +The system size must fit in a 32-bit integer to use this dump +style. + E: Cannot use variable every setting for dump xtc The format of this file requires snapshots at regular intervals. From 1bbf45784bd7c7b6be26351907921547b0743ec6 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 16:29:11 -0700 Subject: [PATCH 21/25] Rename and relocate --- ...e_atom.rst => compute_ave_sphere_atom.rst} | 19 ++++---- src/Depend.sh | 4 ++ .../compute_ave_sphere_atom.cpp} | 48 +++++++++---------- .../compute_ave_sphere_atom.h} | 18 +++---- src/KOKKOS/Install.sh | 4 +- ...cpp => compute_ave_sphere_atom_kokkos.cpp} | 48 +++++++++---------- ...kos.h => compute_ave_sphere_atom_kokkos.h} | 26 +++++----- 7 files changed, 86 insertions(+), 81 deletions(-) rename doc/src/{compute_phase_atom.rst => compute_ave_sphere_atom.rst} (82%) rename src/{compute_phase_atom.cpp => EXTRA-COMPUTE/compute_ave_sphere_atom.cpp} (82%) rename src/{compute_phase_atom.h => EXTRA-COMPUTE/compute_ave_sphere_atom.h} (74%) rename src/KOKKOS/{compute_phase_atom_kokkos.cpp => compute_ave_sphere_atom_kokkos.cpp} (79%) rename src/KOKKOS/{compute_phase_atom_kokkos.h => compute_ave_sphere_atom_kokkos.h} (63%) diff --git a/doc/src/compute_phase_atom.rst b/doc/src/compute_ave_sphere_atom.rst similarity index 82% rename from doc/src/compute_phase_atom.rst rename to doc/src/compute_ave_sphere_atom.rst index 6540e52041..db04682865 100644 --- a/doc/src/compute_phase_atom.rst +++ b/doc/src/compute_ave_sphere_atom.rst @@ -1,20 +1,20 @@ -.. index:: compute phase/atom -.. index:: compute phase/atom/kk +.. index:: compute ave/sphere/atom +.. index:: compute ave/sphere/atom/kk -compute phase/atom command +compute ave/sphere/atom command ================================ -Accelerator Variants: *phase/atom/kk* +Accelerator Variants: *ave/sphere/atom/kk* Syntax """""" .. parsed-literal:: - compute ID group-ID phase/atom keyword values ... + compute ID group-ID ave/sphere/atom keyword values ... * ID, group-ID are documented in :doc:`compute ` command -* phase/atom = style name of this compute command +* ave/sphere/atom = style name of this compute command * one or more keyword/value pairs may be appended .. parsed-literal:: @@ -27,9 +27,9 @@ Examples .. code-block:: LAMMPS - compute 1 all phase/atom + compute 1 all ave/sphere/atom - compute 1 all phase/atom cutoff 5.0 + compute 1 all ave/sphere/atom cutoff 5.0 comm_modify cutoff 5.0 Description @@ -86,7 +86,8 @@ page for an overview of LAMMPS output options. Restrictions """""""""""" -none +This compute is part of the EXTRA-COMPUTE package. It is only enabled if +LAMMPS was built with that package. See the :doc:`Build package ` page for more info. Related commands """""""""""""""" diff --git a/src/Depend.sh b/src/Depend.sh index af88f24bb4..a8e17e0546 100755 --- a/src/Depend.sh +++ b/src/Depend.sh @@ -77,6 +77,10 @@ if (test $1 = "DPD-BASIC") then depend INTEL fi +if (test $1 = "EXTRA-COMPUTE") then + depend KOKKOS +fi + if (test $1 = "EXTRA-MOLECULE") then depend GPU depend OPENMP diff --git a/src/compute_phase_atom.cpp b/src/EXTRA-COMPUTE/compute_ave_sphere_atom.cpp similarity index 82% rename from src/compute_phase_atom.cpp rename to src/EXTRA-COMPUTE/compute_ave_sphere_atom.cpp index f8f5e35abf..14a4c364a1 100644 --- a/src/compute_phase_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_ave_sphere_atom.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "compute_phase_atom.h" +#include "compute_ave_sphere_atom.h" #include "atom.h" #include "comm.h" @@ -36,11 +36,11 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -ComputePhaseAtom::ComputePhaseAtom(LAMMPS *lmp, int narg, char **arg) : +ComputeAveSphereAtom::ComputeAveSphereAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), - phase(nullptr) + result(nullptr) { - if (narg < 3 || narg > 5) error->all(FLERR,"Illegal compute phase/atom command"); + if (narg < 3 || narg > 5) error->all(FLERR,"Illegal compute ave/sphere/atom command"); // process optional args @@ -49,11 +49,11 @@ ComputePhaseAtom::ComputePhaseAtom(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"cutoff") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal compute phase/atom command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute ave/sphere/atom command"); cutoff = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (cutoff <= 0.0) error->all(FLERR,"Illegal compute phase/atom command"); + if (cutoff <= 0.0) error->all(FLERR,"Illegal compute ave/sphere/atom command"); iarg += 2; - } else error->all(FLERR,"Illegal compute phase/atom command"); + } else error->all(FLERR,"Illegal compute ave/sphere/atom command"); } peratom_flag = 1; @@ -65,19 +65,19 @@ ComputePhaseAtom::ComputePhaseAtom(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -ComputePhaseAtom::~ComputePhaseAtom() +ComputeAveSphereAtom::~ComputeAveSphereAtom() { if (copymode) return; - memory->destroy(phase); + memory->destroy(result); } /* ---------------------------------------------------------------------- */ -void ComputePhaseAtom::init() +void ComputeAveSphereAtom::init() { if (!force->pair && cutoff == 0.0) - error->all(FLERR,"Compute phase/atom requires a cutoff be specified " + error->all(FLERR,"Compute ave/sphere/atom requires a cutoff be specified " "or a pair style be defined"); double skin = neighbor->skin; @@ -89,7 +89,7 @@ void ComputePhaseAtom::init() cutghost = comm->cutghostuser; if (cutoff > cutghost) - error->all(FLERR,"Compute phase/atom cutoff exceeds ghost atom range - " + error->all(FLERR,"Compute ave/sphere/atom cutoff exceeds ghost atom range - " "use comm_modify cutoff command"); } @@ -120,14 +120,14 @@ void ComputePhaseAtom::init() /* ---------------------------------------------------------------------- */ -void ComputePhaseAtom::init_list(int /*id*/, NeighList *ptr) +void ComputeAveSphereAtom::init_list(int /*id*/, NeighList *ptr) { list = ptr; } /* ---------------------------------------------------------------------- */ -void ComputePhaseAtom::compute_peratom() +void ComputeAveSphereAtom::compute_peratom() { int i,j,ii,jj,inum,jnum; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; @@ -137,13 +137,13 @@ void ComputePhaseAtom::compute_peratom() invoked_peratom = update->ntimestep; - // grow phase array if necessary + // grow result array if necessary if (atom->nmax > nmax) { - memory->destroy(phase); + memory->destroy(result); nmax = atom->nmax; - memory->create(phase,nmax,2,"phase/atom:phase"); - array_atom = phase; + memory->create(result,nmax,2,"ave/sphere/atom:result"); + array_atom = result; } // need velocities of ghost atoms @@ -159,7 +159,7 @@ void ComputePhaseAtom::compute_peratom() numneigh = list->numneigh; firstneigh = list->firstneigh; - // compute phase for each atom in group + // compute properties for each atom in group // use full neighbor list to count atoms less than cutoff double **x = atom->x; @@ -229,15 +229,15 @@ void ComputePhaseAtom::compute_peratom() } double density = count/sphere_vol; double temp = ke_sum/3.0/count; - phase[i][0] = density; - phase[i][1] = temp; + result[i][0] = density; + result[i][1] = temp; } } } /* ---------------------------------------------------------------------- */ -int ComputePhaseAtom::pack_forward_comm(int n, int *list, double *buf, +int ComputeAveSphereAtom::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { double **v = atom->v; @@ -254,7 +254,7 @@ int ComputePhaseAtom::pack_forward_comm(int n, int *list, double *buf, /* ---------------------------------------------------------------------- */ -void ComputePhaseAtom::unpack_forward_comm(int n, int first, double *buf) +void ComputeAveSphereAtom::unpack_forward_comm(int n, int first, double *buf) { double **v = atom->v; @@ -271,7 +271,7 @@ void ComputePhaseAtom::unpack_forward_comm(int n, int first, double *buf) memory usage of local atom-based array ------------------------------------------------------------------------- */ -double ComputePhaseAtom::memory_usage() +double ComputeAveSphereAtom::memory_usage() { double bytes = (double)2*nmax * sizeof(double); return bytes; diff --git a/src/compute_phase_atom.h b/src/EXTRA-COMPUTE/compute_ave_sphere_atom.h similarity index 74% rename from src/compute_phase_atom.h rename to src/EXTRA-COMPUTE/compute_ave_sphere_atom.h index b39026b3b5..9b5e38750b 100644 --- a/src/compute_phase_atom.h +++ b/src/EXTRA-COMPUTE/compute_ave_sphere_atom.h @@ -13,21 +13,21 @@ #ifdef COMPUTE_CLASS -ComputeStyle(phase/atom,ComputePhaseAtom) +ComputeStyle(ave/sphere/atom,ComputeAveSphereAtom) #else -#ifndef LMP_COMPUTE_PHASE_ATOM_H -#define LMP_COMPUTE_PHASE_ATOM_H +#ifndef LMP_COMPUTE_AVE_SPHERE_ATOM_H +#define LMP_COMPUTE_AVE_SPHERE_ATOM_H #include "compute.h" namespace LAMMPS_NS { -class ComputePhaseAtom : public Compute { +class ComputeAveSphereAtom : public Compute { public: - ComputePhaseAtom(class LAMMPS *, int, char **); - virtual ~ComputePhaseAtom(); + ComputeAveSphereAtom(class LAMMPS *, int, char **); + virtual ~ComputeAveSphereAtom(); virtual void init(); void init_list(int, class NeighList *); virtual void compute_peratom(); @@ -40,7 +40,7 @@ class ComputePhaseAtom : public Compute { double cutoff,cutsq,sphere_vol; class NeighList *list; - double **phase; + double **result; }; } @@ -56,11 +56,11 @@ Self-explanatory. Check the input script syntax and compare to the documentation for the command. You can use -echo screen as a command-line option when running LAMMPS to see the offending line. -E: Compute phase/atom requires a cutoff be specified or a pair style be defined +E: Compute ave/sphere/atom requires a cutoff be specified or a pair style be defined Self-explanatory. -E: Compute phase/atom cutoff exceeds ghost atom range - use comm_modify cutoff command +E: Compute ave/sphere/atom cutoff exceeds ghost atom range - use comm_modify cutoff command Self-explanatory. diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index ac5efec076..261a4d807a 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -88,12 +88,12 @@ action comm_kokkos.cpp action comm_kokkos.h action comm_tiled_kokkos.cpp action comm_tiled_kokkos.h +action compute_ave_sphere_atom_kokkos.cpp +action compute_ave_sphere_atom_kokkos.h action compute_coord_atom_kokkos.cpp action compute_coord_atom_kokkos.h action compute_orientorder_atom_kokkos.cpp action compute_orientorder_atom_kokkos.h -action compute_phase_atom_kokkos.cpp -action compute_phase_atom_kokkos.h action compute_temp_kokkos.cpp action compute_temp_kokkos.h action compute_temp_deform_kokkos.cpp diff --git a/src/KOKKOS/compute_phase_atom_kokkos.cpp b/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp similarity index 79% rename from src/KOKKOS/compute_phase_atom_kokkos.cpp rename to src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp index 5a21393252..3f83c24fb6 100644 --- a/src/KOKKOS/compute_phase_atom_kokkos.cpp +++ b/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp @@ -11,7 +11,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "compute_phase_atom_kokkos.h" +#include "compute_ave_sphere_atom_kokkos.h" #include "atom_kokkos.h" #include "atom_masks.h" @@ -37,8 +37,8 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ template -ComputePhaseAtomKokkos::ComputePhaseAtomKokkos(LAMMPS *lmp, int narg, char **arg) : - ComputePhaseAtom(lmp, narg, arg) +ComputeAveSphereAtomKokkos::ComputeAveSphereAtomKokkos(LAMMPS *lmp, int narg, char **arg) : + ComputeAveSphereAtom(lmp, narg, arg) { kokkosable = 1; atomKK = (AtomKokkos *) atom; @@ -50,19 +50,19 @@ ComputePhaseAtomKokkos::ComputePhaseAtomKokkos(LAMMPS *lmp, int narg /* ---------------------------------------------------------------------- */ template -ComputePhaseAtomKokkos::~ComputePhaseAtomKokkos() +ComputeAveSphereAtomKokkos::~ComputeAveSphereAtomKokkos() { if (copymode) return; - memoryKK->destroy_kokkos(k_phase,phase); + memoryKK->destroy_kokkos(k_result,result); } /* ---------------------------------------------------------------------- */ template -void ComputePhaseAtomKokkos::init() +void ComputeAveSphereAtomKokkos::init() { - ComputePhaseAtom::init(); + ComputeAveSphereAtom::init(); // need an occasional full neighbor list @@ -80,18 +80,18 @@ void ComputePhaseAtomKokkos::init() /* ---------------------------------------------------------------------- */ template -void ComputePhaseAtomKokkos::compute_peratom() +void ComputeAveSphereAtomKokkos::compute_peratom() { invoked_peratom = update->ntimestep; - // grow phase array if necessary + // grow result array if necessary if (atom->nmax > nmax) { - memoryKK->destroy_kokkos(k_phase,phase); + memoryKK->destroy_kokkos(k_result,result); nmax = atom->nmax; - memoryKK->create_kokkos(k_phase,phase,nmax,2,"phase/atom:phase"); - d_phase = k_phase.view(); - array_atom = phase; + memoryKK->create_kokkos(k_result,result,nmax,2,"ave/sphere/atom:result"); + d_result = k_result.view(); + array_atom = result; } // need velocities of ghost atoms @@ -110,7 +110,7 @@ void ComputePhaseAtomKokkos::compute_peratom() d_neighbors = k_list->d_neighbors; d_ilist = k_list->d_ilist; - // compute phase for each atom in group + // compute properties for each atom in group // use full neighbor list to count atoms less than cutoff atomKK->sync(execution_space,X_MASK|V_MASK|TYPE_MASK|MASK_MASK); @@ -118,20 +118,20 @@ void ComputePhaseAtomKokkos::compute_peratom() v = atomKK->k_v.view(); mask = atomKK->k_mask.view(); - Kokkos::deep_copy(d_phase,0.0); + Kokkos::deep_copy(d_result,0.0); copymode = 1; - typename Kokkos::RangePolicy policy(0,inum); - Kokkos::parallel_for("ComputePhaseAtom",policy,*this); + typename Kokkos::RangePolicy policy(0,inum); + Kokkos::parallel_for("ComputeAveSphereAtom",policy,*this); copymode = 0; - k_phase.modify(); - k_phase.sync_host(); + k_result.modify(); + k_result.sync_host(); } template KOKKOS_INLINE_FUNCTION -void ComputePhaseAtomKokkos::operator()(TagComputePhaseAtom, const int &ii) const +void ComputeAveSphereAtomKokkos::operator()(TagComputeAveSphereAtom, const int &ii) const { const int i = d_ilist[ii]; if (mask[i] & groupbit) { @@ -196,14 +196,14 @@ void ComputePhaseAtomKokkos::operator()(TagComputePhaseAtom, const i } double density = count/sphere_vol; double temp = ke_sum/3.0/count; - d_phase(i,0) = density; - d_phase(i,1) = temp; + d_result(i,0) = density; + d_result(i,1) = temp; } } namespace LAMMPS_NS { -template class ComputePhaseAtomKokkos; +template class ComputeAveSphereAtomKokkos; #ifdef LMP_KOKKOS_GPU -template class ComputePhaseAtomKokkos; +template class ComputeAveSphereAtomKokkos; #endif } diff --git a/src/KOKKOS/compute_phase_atom_kokkos.h b/src/KOKKOS/compute_ave_sphere_atom_kokkos.h similarity index 63% rename from src/KOKKOS/compute_phase_atom_kokkos.h rename to src/KOKKOS/compute_ave_sphere_atom_kokkos.h index d65f3d571e..42607e5239 100644 --- a/src/KOKKOS/compute_phase_atom_kokkos.h +++ b/src/KOKKOS/compute_ave_sphere_atom_kokkos.h @@ -13,35 +13,35 @@ #ifdef COMPUTE_CLASS -ComputeStyle(phase/atom/kk,ComputePhaseAtomKokkos) -ComputeStyle(phase/atom/kk/device,ComputePhaseAtomKokkos) -ComputeStyle(phase/atom/kk/host,ComputePhaseAtomKokkos) +ComputeStyle(ave/sphere/atom/kk,ComputeAveSphereAtomKokkos) +ComputeStyle(ave/sphere/atom/kk/device,ComputeAveSphereAtomKokkos) +ComputeStyle(ave/sphere/atom/kk/host,ComputeAveSphereAtomKokkos) #else -#ifndef LMP_COMPUTE_PHASE_KOKKOS_ATOM_H -#define LMP_COMPUTE_PHASE_KOKKOS_ATOM_H +#ifndef LMP_COMPUTE_AVE_SPHERE_ATOM_KOKKOS_H +#define LMP_COMPUTE_AVE_SPHERE_ATOM_KOKKOS_H -#include "compute_phase_atom.h" +#include "compute_ave_sphere_atom.h" #include "kokkos_type.h" namespace LAMMPS_NS { -struct TagComputePhaseAtom{}; +struct TagComputeAveSphereAtom{}; template -class ComputePhaseAtomKokkos : public ComputePhaseAtom { +class ComputeAveSphereAtomKokkos : public ComputeAveSphereAtom { public: typedef DeviceType device_type; typedef ArrayTypes AT; - ComputePhaseAtomKokkos(class LAMMPS *, int, char **); - virtual ~ComputePhaseAtomKokkos(); + ComputeAveSphereAtomKokkos(class LAMMPS *, int, char **); + virtual ~ComputeAveSphereAtomKokkos(); void init(); void compute_peratom(); KOKKOS_INLINE_FUNCTION - void operator()(TagComputePhaseAtom, const int&) const; + void operator()(TagComputeAveSphereAtom, const int&) const; private: typename AT::t_x_array_randomread x; @@ -52,8 +52,8 @@ class ComputePhaseAtomKokkos : public ComputePhaseAtom { typename AT::t_int_1d_randomread d_ilist; typename AT::t_int_1d_randomread d_numneigh; - DAT::tdual_float_2d k_phase; - typename AT::t_float_2d d_phase; + DAT::tdual_float_2d k_result; + typename AT::t_float_2d d_result; }; } From 9271323cc0ccef50818b8044dcb8814aa1d205b9 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 16:33:14 -0700 Subject: [PATCH 22/25] Add dependency --- src/KOKKOS/Install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index 261a4d807a..45fa0654a9 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -88,8 +88,8 @@ action comm_kokkos.cpp action comm_kokkos.h action comm_tiled_kokkos.cpp action comm_tiled_kokkos.h -action compute_ave_sphere_atom_kokkos.cpp -action compute_ave_sphere_atom_kokkos.h +action compute_ave_sphere_atom_kokkos.cpp compute_ave_sphere_atom.cpp +action compute_ave_sphere_atom_kokkos.h compute_ave_sphere_atom.h action compute_coord_atom_kokkos.cpp action compute_coord_atom_kokkos.h action compute_orientorder_atom_kokkos.cpp From 2788bc666a3ce67d0c364fc66ed6b829557ac0ce Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 16:44:14 -0700 Subject: [PATCH 23/25] Update .gitignore --- src/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/.gitignore b/src/.gitignore index 19bafa4b52..695c9a19af 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -429,6 +429,8 @@ /commgrid.h /compute_ackland_atom.cpp /compute_ackland_atom.h +/compute_ave_sphere_atom.cpp +/compute_ave_sphere_atom.h /compute_basal_atom.cpp /compute_basal_atom.h /compute_body_local.cpp From cde7dd34fdc02215a89c9c13e56e1cdc9454fbe5 Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Tue, 21 Dec 2021 16:46:53 -0700 Subject: [PATCH 24/25] Doc update --- doc/src/Commands_compute.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 2c67d44f24..91910ccdaa 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -28,6 +28,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`angle ` * :doc:`angle/local ` * :doc:`angmom/chunk ` + * :doc:`ave/sphere/atom (k) ` * :doc:`basal/atom ` * :doc:`body/local ` * :doc:`bond ` From 8f62cd79f4be90edf24a9ccae41bac786ee620fe Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 22 Dec 2021 19:55:06 -0500 Subject: [PATCH 25/25] add missing list entry --- doc/src/compute.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 71d3bada76..9edd7e8474 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -174,6 +174,7 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`angle ` - energy of each angle sub-style * :doc:`angle/local ` - theta and energy of each angle * :doc:`angmom/chunk ` - angular momentum for each chunk +* :doc:`ave/sphere/atom ` - compute local density and temperature around each atom * :doc:`basal/atom ` - calculates the hexagonal close-packed "c" lattice vector of each atom * :doc:`body/local ` - attributes of body sub-particles * :doc:`bond ` - energy of each bond sub-style