From 348296e638628f3552deea0c6ef9a6a29805b527 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 15 Feb 2023 16:07:10 -0700 Subject: [PATCH 001/104] Adding base fix and atom style --- src/RHEO/atom_vec_rheo.cpp | 135 ++++++++++++++ src/RHEO/atom_vec_rheo.h | 45 +++++ src/RHEO/fix_rheo.cpp | 365 +++++++++++++++++++++++++++++++++++++ src/RHEO/fix_rheo.h | 91 +++++++++ src/atom.cpp | 20 ++ src/atom.h | 5 + 6 files changed, 661 insertions(+) create mode 100644 src/RHEO/atom_vec_rheo.cpp create mode 100644 src/RHEO/atom_vec_rheo.h create mode 100644 src/RHEO/fix_rheo.cpp create mode 100644 src/RHEO/fix_rheo.h diff --git a/src/RHEO/atom_vec_rheo.cpp b/src/RHEO/atom_vec_rheo.cpp new file mode 100644 index 0000000000..9effad685c --- /dev/null +++ b/src/RHEO/atom_vec_rheo.cpp @@ -0,0 +1,135 @@ +/* ---------------------------------------------------------------------- + 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. + ------------------------------------------------------------------------- */ + +#include "atom_vec_rheo.h" + +#include "atom.h" + +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +AtomVecRHEO::AtomVecRHEO(LAMMPS *lmp) : AtomVec(lmp) +{ + molecular = Atom::ATOMIC; + mass_type = PER_TYPE; + forceclearflag = 1; + + atom->status_flag = 1; + atom->rho_flag = 1; + + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file + + fields_grow = {"status", "rho", "drho"}; + fields_copy = {"status", "rho", "drho"}; + fields_comm = {"status", "rho"}; + fields_comm_vel = {"status", "rho"}; + fields_reverse = {"drho"}; + fields_border = {"status", "rho"}; + fields_border_vel = {"status", "rho"}; + fields_exchange = {"status", "rho"}; + fields_restart = {"status", "rho"}; + fields_create = {"status", "rho", "drho"}; + fields_data_atom = {"id", "type", "status", "rho", "x"}; + fields_data_vel = {"id", "v"}; + + setup_fields(); +} + +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecRHEO::grow_pointers() +{ + status = atom->status; + rho = atom->rho; + drho = atom->drho; +} + +/* ---------------------------------------------------------------------- + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector +------------------------------------------------------------------------- */ + +void AtomVecRHEO::force_clear(int n, size_t nbytes) +{ + memset(&drho[n], 0, nbytes); +} + +/* ---------------------------------------------------------------------- + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecRHEO::data_atom_post(int ilocal) +{ + drho[ilocal] = 0.0; +} + +/* ---------------------------------------------------------------------- + assign an index to named atom property and return index + return -1 if name is unknown to this atom style +------------------------------------------------------------------------- */ + +int AtomVecRHEO::property_atom(const std::string &name) +{ + if (name == "status") return 0; + if (name == "rho") return 1; + if (name == "drho") return 2; + return -1; +} + +/* ---------------------------------------------------------------------- + pack per-atom data into buf for ComputePropertyAtom + index maps to data specific to this atom style +------------------------------------------------------------------------- */ + +void AtomVecRHEO::pack_property_atom(int index, double *buf, int nvalues, int groupbit) +{ + int *mask = atom->mask; + int nlocal = atom->nlocal; + int n = 0; + + if (index == 0) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = status[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } if else (index == 1) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = rho[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 2) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = drho[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } +} diff --git a/src/RHEO/atom_vec_rheo.h b/src/RHEO/atom_vec_rheo.h new file mode 100644 index 0000000000..bdd617a01d --- /dev/null +++ b/src/RHEO/atom_vec_rheo.h @@ -0,0 +1,45 @@ +/* -*- 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 ATOM_CLASS +// clang-format off +AtomStyle(rheo,AtomVecRHEO); +// clang-format on +#else + +#ifndef LMP_ATOM_VEC_RHEO_H +#define LMP_ATOM_VEC_RHEO_H + +#include "atom_vec.h" + +namespace LAMMPS_NS { + +class AtomVecRHEO : virtual public AtomVec { + public: + AtomVecRHEO(class LAMMPS *); + + void grow_pointers() override; + void force_clear(int, size_t) override; + void data_atom_post(int) override; + int property_atom(const std::string &) override; + void pack_property_atom(int, double *, int, int) override; + + private: + int *status; + double *rho, *drho; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp new file mode 100644 index 0000000000..fd476d4c9e --- /dev/null +++ b/src/RHEO/fix_rheo.cpp @@ -0,0 +1,365 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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 "fix_rheo.h" + +#include "atom.h" +#include "compute_rheo_grad.h" +#include "compute_rheo_interface.h" +#include "compute_rheo_kernel.h" +#include "compute_rheo_rhosum.h" +#include "compute_rheo_vshift.h" +#include "domain.h" +#include "error.h" +#include "force.h" +#include "modify.h" +#include "update.h" +#include "utils.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), compute_grad(nullptr), compute_kernel(nullptr), + compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr) +{ + thermal_flag = 0; + rhosum_flag = 0; + shift_flag = 0; + solid_flag = 0; + rho0 = 1.0; + csq = 1.0; + + if (atom->rho_flag != 1) + error->all(FLERR,"fix rheo command requires atom_style with density"); + if (atom->status_flag != 1) + error->all(FLERR,"fix rheo command requires atom_style with status"); + + if (narg < 5) + error->all(FLERR,"Insufficient arguments for fix rheo command"); + + cut = utils::numeric(FLERR,arg[3],false,lmp); + if (strcmp(arg[4],"Quintic") == 0) { + kernel_style = QUINTIC; + } else if (strcmp(arg[4],"CRK0") == 0) { + kernel_style = CRK0; + } else if (strcmp(arg[4],"CRK1") == 0) { + kernel_style = CRK1; + } else if (strcmp(arg[4],"CRK2") == 0) { + kernel_style = CRK2; + } else error->all(FLERR,"Unknown kernel style {} in fix rheo", arg[4]); + zmin_kernel = utils::numeric(FLERR,arg[5],false,lmp); + + int iarg = 6; + while (iarg < narg){ + if (strcmp(arg[iarg],"shift") == 0) { + shift_flag = 1; + } else if (strcmp(arg[iarg],"thermal") == 0) { + thermal_flag = 1; + } else if (strcmp(arg[iarg],"rhosum") == 0) { + rhosum_flag = 1; + if(iarg + 1 >= narg) error->all(FLERR,"Illegal rhosum option in fix rheo"); + zmin_rhosum = utils::inumeric(FLERR,arg[iarg + 1],false,lmp); + iarg += 1; + } else if (strcmp(arg[iarg],"rho0") == 0) { + if(iarg + 1 >= narg) error->all(FLERR,"Illegal rho0 option in fix rheo"); + rho0 = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + iarg += 1; + } else if (strcmp(arg[iarg],"csq") == 0) { + if(iarg+1 >= narg) error->all(FLERR,"Illegal csq option in fix rheo"); + csq = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + iarg += 1; + } else { + error->all(FLERR, "Illegal fix rheo command: {}", arg[iarg]); + } + iarg += 1; + } + + time_integrate = 1; + thermal_fix_defined = 0; + viscosity_fix_defined = 0; + pressure_fix_defined = 0; +} + +/* ---------------------------------------------------------------------- */ + +FixRHEO::~FixRHEO() +{ + if (compute_kernel) modify->delete_compute("rheo_kernel"); + if (compute_grad) modify->delete_compute("rheo_grad"); + if (compute_interface) modify->delete_compute("rheo_interface"); + if (compute_rhosum) modify->delete_compute("rheo_rhosum"); + if (compute_vshift) modify->delete_compute("rheo_vshift"); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEO::post_constructor() +{ + compute_kernel = dynamic_cast(modify->add_compute(fmt::format("rheo_kernel all rheo/kernel {} {} {}", kernel_style, zmin_kernel, cut))); + + if (thermal_flag) + compute_grad = dynamic_cast(modify->add_compute(fmt::format("rheo_grad all rheo/grad {} velocity rho viscosity temprature", cut))); + else + compute_grad = dynamic_cast(modify->add_compute(fmt::format("rheo_grad all rheo/grad {} velocity rho viscosity", cut))); + + compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface {}", cut))); + + if (rhosum_flag) + compute_rhosum = dynamic_cast(modify->add_compute(fmt::format("rheo_rhosum all rheo/rho/sum {} {}", cut, zmin_rhosum))); + + if (shift_flag) + compute_vshift = dynamic_cast(modify->add_compute(fmt::format("rheo_vshift all rheo/vshift {}", cut))); +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEO::setmask() +{ + int mask = 0; + mask |= INITIAL_INTEGRATE; + mask |= FINAL_INTEGRATE; + mask |= PRE_FORCE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEO::init() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEO::setup_pre_force(int /*vflag*/) +{ + // Check to confirm all accessory fixes are defined + if(!thermal_fix_defined && thermal_flag) + error->all(FLERR, "Missing fix rheo/thermal"); + + if (!viscosity_fix_defined) + error->all(FLERR, "Missing fix rheo/viscosity"); + + if (!pressure_fix_defined) + error->all(FLERR, "Missing fix rheo/pressure"); + + // Reset to zero for next run + thermal_fix_defined = 0; + viscosity_fix_defined = 0; + pressure_fix_defined = 0; + + pre_force(0); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEO::initial_integrate(int /*vflag*/) +{ + // update v and x and rho of atoms in group + int i, a, b; + double dtfm, divu; + int dim = domain->dimension; + + int *status = atom->status; + double **x = atom->x; + double **v = atom->v; + double **f = atom->f; + double *rho = atom->rho; + double *drho = atom->drho; + double *mass = atom->mass; + double *rmass = atom->rmass; + int rmass_flag = atom->rmass_flag; + + double **gradr = compute_grad->gradr; + double **gradv = compute_grad->gradv; + double **vshift = compute_vshift->array_atom; + + int *type = atom->type; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + if (igroup == atom->firstgroup) + nlocal = atom->nfirst; + + //Density Half-step + for (i = 0; i < nlocal; i++) { + if (status[i] & STATUS_NO_FORCE) continue; + + if (mask[i] & groupbit) { + if (rmass_flag) { + dtfm = dtf / rmass[i]; + } else { + dtfm = dtf / mass[type[i]]; + } + + v[i][0] += dtfm * f[i][0]; + v[i][1] += dtfm * f[i][1]; + v[i][2] += dtfm * f[i][2]; + } + } + + // Update gradients and interpolate solid properties + compute_grad->forward_fields(); // also forwards v and rho for chi + compute_interface->store_forces(); // Need to save, wiped in exchange + compute_interface->compute_peratom(); + compute_grad->compute_peratom(); + + // Position half-step + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + for (a = 0; a < dim; a++) { + x[i][a] += dtv * v[i][a]; + } + } + } + + // Update density using div(u) + if (!rhosum_flag) { + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + if (status[i] & STATUS_NO_FORCE) continue; + if (!(status[i] & STATUS_FLUID)) continue; + + divu = 0; + for (a = 0; a < dim; a++) { + divu += gradv[i][a * (1 + dim)]; + } + rho[i] += dtf * (drho[i] - rho[i] * divu); + } + } + } + + // Shifting atoms + if (shift_flag) { + compute_vshift->correct_surfaces(); + for (i = 0; i < nlocal; i++) { + + if (!(status[i] & STATUS_SHIFT)) continue; + + if (mask[i] & groupbit) { + for (a = 0; a < dim; a++) { + x[i][a] += dtv * vshift[i][a]; + for (b = 0; b < dim; b++) { + v[i][a] += dtv * vshift[i][b] * gradv[i][a * dim + b]; + } + } + + if (!rhosum_flag) { + for (a = 0; a < dim; a++) { + rho[i] += dtv * vshift[i][a] * gradr[i][a]; + } + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEO::pre_force(int /*vflag*/) +{ + if (rhosum_flag) + compute_rhosum->compute_peratom(); + + compute_grad->forward_fields(); // also forwards v and rho for chi + compute_kernel->compute_peratom(); + compute_interface->compute_peratom(); + + compute_grad->compute_peratom(); + compute_grad->forward_gradients(); + + if (shift_flag) + compute_vshift->compute_peratom(); + + // Remove extra shifting/no force options options + int *status = atom->status; + int nall = atom->nlocal + atom->nghost; + for (int i = 0; i < nall; i++) { + if (mask[i] & groupbit) { + status[i] &= ~STATUS_NO_FORCE; + + if (status[i] & STATUS_FLUID) + status[i] &= ~STATUS_SHIFT; + } + } +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEO::final_integrate() { + int *status = atom->status; + double **gradv = compute_grad->gradv; + double **x = atom->x; + double **v = atom->v; + double **f = atom->f; + + double *rho = atom->rho; + double *drho = atom->drho; + int *type = atom->type; + int *mask = atom->mask; + double *mass = atom->mass; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) + nlocal = atom->nfirst; + double dtfm, divu; + double *rmass = atom->rmass; + int rmass_flag = atom->rmass_flag; + int i, a; + + int dim = domain->dimension; + + // Update velocity + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + if (status[i] & STATUS_NO_FORCE) continue; + + if (rmass_flag) { + dtfm = dtf / rmass[i]; + } else { + dtfm = dtf / mass[type[i]]; + } + + for (a = 0; a < dim; a++) { + v[i][a] += dtfm * f[i][a]; + } + } + } + + // Update density using divu + if (!rhosum_flag) { + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + if (status[i] & STATUS_NO_FORCE) continue; + if (!(status[i] & STATUS_FLUID)) continue; + + divu = 0; + for (a = 0; a < dim; a++) { + divu += gradv[i][a * (1 + dim)]; + } + rho[i] += dtf * (drho[i] - rho[i] * divu); + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEO::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; +} diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h new file mode 100644 index 0000000000..8597eb2809 --- /dev/null +++ b/src/RHEO/fix_rheo.h @@ -0,0 +1,91 @@ +/* -*- 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(rheo,FixRHEO) +// clang-format on +#else + +#ifndef LMP_FIX_RHEO_H +#define LMP_FIX_RHEO_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixRHEO : public Fix { + public: + FixRHEO(class LAMMPS *, int, char **); + virtual ~FixRHEO(); + int setmask(); + virtual void post_constructor(); + virtual void init(); + virtual void setup_pre_force(int); + virtual void pre_force(int); + virtual void initial_integrate(int); + virtual void final_integrate(); + void reset_dt(); + + int kernel_style; + int thermal_flag; + int rhosum_flag; + int shift_flag; + int solid_flag; + + int thermal_fix_defined; + int viscosity_fix_defined; + int pressure_fix_defined; + + int *status, *surface; + double *conductivity, *viscosity, *pressure; + double **f_pressure; + + class ComputeRHEOGrad *compute_grad; + class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOInterface *compute_interface; + class ComputeRHEORhoSum *compute_rhosum; + class ComputeRHEOVShift *compute_vshift; + + enum {QUINTIC, CRK0, CRK1, CRK2}; + enum {LINEAR, CUBIC, TAITWATER}; + + enum { + // Phase status + STATUS_FLUID = 1 << 0, + STATUS_REACTIVE = 1 << 1, + STATUS_SOLID = 1 << 2, + STATUS_FREEZING = 1 << 3 + + // Temporary status options - reset in preforce + STATUS_SHIFT = 1 << 4, + STATUS_NO_FORCE = 1 << 5, + + // Surface status + STATUS_BULK = 1 << 6, + STATUS_LAYER = 1 << 7, + STATUS_SURFACE = 1 << 8, + STATUS_SPLASH = 1 << 9, + }; + + protected: + double cut, rho0, csq; + int zmin_kernel, rhosum_zmin; + + double dtv, dtf; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/atom.cpp b/src/atom.cpp index 32285758c0..e2613c801e 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -195,6 +195,10 @@ Atom::Atom(LAMMPS *_lmp) : Pointers(_lmp) eff_plastic_strain_rate = nullptr; damage = nullptr; + // RHEO package + + status = nullptr; + // SPH package rho = drho = esph = desph = cv = nullptr; @@ -521,6 +525,10 @@ void Atom::peratom_create() add_peratom("cc",&cc,DOUBLE,1); add_peratom("cc_flux",&cc_flux,DOUBLE,1,1); // set per-thread flag + // RHEO package + + add_peratom("status",&status,INT,0); + // SPH package add_peratom("rho",&rho,DOUBLE,0); @@ -625,6 +633,7 @@ void Atom::set_atomflag_defaults() rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0; vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; cs_flag = csforce_flag = vforce_flag = ervelforce_flag = etag_flag = 0; + status_flag = 0; rho_flag = esph_flag = cv_flag = vest_flag = 0; dpd_flag = edpd_flag = tdpd_flag = 0; sp_flag = 0; @@ -2911,7 +2920,12 @@ void *Atom::extract(const char *name) if (strcmp(name,"vforce") == 0) return (void *) vforce; if (strcmp(name,"etag") == 0) return (void *) etag; + // RHEO package + + if (strcmp(name,"status") == 0) return (void *) status; + // SPH package + if (strcmp(name,"rho") == 0) return (void *) rho; if (strcmp(name,"drho") == 0) return (void *) drho; if (strcmp(name,"esph") == 0) return (void *) esph; @@ -3030,6 +3044,12 @@ int Atom::extract_datatype(const char *name) if (strcmp(name,"vforce") == 0) return LAMMPS_DOUBLE_2D; if (strcmp(name,"etag") == 0) return LAMMPS_INT; + // RHEO package + + if (strcmp(name,"status") == 0) return LAMMPS_INT; + + // SPH package + if (strcmp(name,"rho") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"drho") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"esph") == 0) return LAMMPS_DOUBLE; diff --git a/src/atom.h b/src/atom.h index 20f2021947..52cec2b1bb 100644 --- a/src/atom.h +++ b/src/atom.h @@ -154,6 +154,10 @@ class Atom : protected Pointers { double *eff_plastic_strain_rate; double *damage; + // RHEO package + + int *status; + // SPH package double *rho, *drho, *esph, *desph, *cv; @@ -188,6 +192,7 @@ class Atom : protected Pointers { int rmass_flag, radius_flag, omega_flag, torque_flag, angmom_flag, quat_flag; int vfrac_flag, spin_flag, eradius_flag, ervel_flag, erforce_flag; int cs_flag, csforce_flag, vforce_flag, ervelforce_flag, etag_flag; + int status_flag; int rho_flag, esph_flag, cv_flag, vest_flag; int dpd_flag, edpd_flag, tdpd_flag; int mesont_flag; From 6cbade576c7d5726226dbb7236d81bb5f5ddfed4 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 19 Feb 2023 20:41:33 -0700 Subject: [PATCH 002/104] Adding gradient compute, minor patch bond history --- src/RHEO/compute_rheo_grad.cpp | 457 +++++++++++++++++++++++++++++++++ src/RHEO/compute_rheo_grad.h | 62 +++++ src/RHEO/fix_rheo.cpp | 1 + src/fix_bond_history.cpp | 4 +- 4 files changed, 522 insertions(+), 2 deletions(-) create mode 100644 src/RHEO/compute_rheo_grad.cpp create mode 100644 src/RHEO/compute_rheo_grad.h diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp new file mode 100644 index 0000000000..33dd3dc3bc --- /dev/null +++ b/src/RHEO/compute_rheo_grad.cpp @@ -0,0 +1,457 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "compute_rheo_grad.h" + +#include "atom.h" +#include "comm.h" +#include "compute_rheo_kernel.h" +#include "compute_rheo_solids.h" +#include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "pair.h" +#include "memory.h" +#include "modify.h" +#include "update.h" +#include "utils.h" + +#include +#include + +using namespace LAMMPS_NS; +enum{COMMGRAD, COMMFIELD}; + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), compute_interface(nullptr), compute_kernel(nullptr) +{ + if (narg < 4) error->all(FLERR,"Illegal compute rheo/grad command"); + + + velocity_flag = temperature_flag = rho_flag = eta_flag = 0; + for (int iarg = 3; iarg < narg; iarg ++) { + if (strcmp(arg[iarg],"velocity") == 0) velocity_flag = 1; + else if (strcmp(arg[iarg],"rho") == 0) rho_flag = 1; + else if (strcmp(arg[iarg],"temperature") == 0) temperature_flag = 1; + else if (strcmp(arg[iarg],"viscosity") == 0) eta_flag = 1; + else error->all(FLERR, "Illegal compute rheo/grad command, {}", arg[iarg]); + } + + dim = domain->dimension; + + ncomm_grad = 0; + ncomm_field = 0; + comm_reverse = 0; + + std::string fix_cmd = "rheo_grad_property_atom all property/atom" + + if (velocity_flag) { + ncomm_grad += dim * dim; + ncomm_field += dim; + comm_reverse += dim * dim; + fix_cmd += " d2_gradv 9" + } + + if (rho_flag) { + ncomm_grad += dim; + ncomm_field += 1; + comm_reverse += dim; + fix_cmd += " d2_gradr 3" + } + + if (temperature_flag) { + ncomm_grad += dim; + ncomm_field += 1; + comm_reverse += dim; + fix_cmd += " d2_gradt 3" + } + + if (eta_flag) { + ncomm_grad += dim; + comm_reverse += dim; + fix_cmd += " d2_gradn 3" + } + + comm_forward = ncomm_grad; + + modify->add_fix(fix_cmd); + + int tmp1, tmp2, index; + if (velocity_flag) { + index = atom->find_custom("gradv", tmp1, tmp2); + gradv = atom->darray[index]; + } + + if (rho_flag) { + index = atom->find_custom("gradr", tmp1, tmp2); + gradr = atom->darray[index]; + } + + if (temperature_flag) { + index = atom->find_custom("gradt", tmp1, tmp2); + gradt = atom->darray[index]; + } + + if (eta_flag) { + index = atom->find_custom("gradn", tmp1, tmp2); + gradn = atom->darray[index]; + } +} + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOGrad::~ComputeRHEOGrad() +{ + modify->delete_fix("rheo_grad_property_atom"); +} + + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOGrad::init() +{ + neighbor->add_request(this, NeighConst::REQ_DEFAULT); + + cut = fix_rheo->cut; + cutsq = cut * cut; + rho0 = fix_rheo->rho0; + compute_kernel = fix_rheo->compute_kernel; + compute_interface = fix_rheo->compute_interface; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOGrad::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOGrad::compute_peratom() +{ + int i, j, k, ii, jj, jnum, itype, jtype, a, b; + double xtmp, ytmp, ztmp, delx, dely, delz; + double rsq, imass, jmass; + double rhoi, rhoj, Voli, Volj, drho, dT, deta; + double vij[3]; + double wp, *dWij, *dWji; + + int inum, *ilist, *numneigh, **firstneigh; + int *jlist; + int nlocal = atom->nlocal; + + double **x = atom->x; + double **v = atom->v; + double *rho = atom->rho; + double *temperature = atom->temperature; + double *eta = atom->viscosity; + int *status = atom->status; + int *type = atom->type; + double *mass = atom->mass; + int newton = force->newton; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // initialize arrays + for (i = 0; i < nmax; i++) { + if (velocity_flag) { + for (k = 0; k < dim * dim; k++) + gradv[i][k] = 0.0; + } + if (rho_flag) { + for (k = 0; k < dim; k++) + gradr[i][k] = 0.0; + } + if (temperature_flag) { + for (k = 0; k < dim; k++) + gradt[i][k] = 0.0; + } + if (eta_flag) { + for (k = 0; k < dim; k++) + gradn[i][k] = 0.0; + } + } + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + jtype = type[j]; + 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) { + rhoi = rho[i]; + rhoj = rho[j]; + + // Add corrections for walls + if ((status[i] & FixRHEO::STATUS_FLUID) && !(status[j] & FixRHEO::STATUS_FLUID)) { + compute_interface->correct_v(v[i], v[j], vi, i, j); + rhoj = compute_interface->correct_rho(j,i); + } else if (!(status[i] & FixRHEO::STATUS_FLUID) && (status[j] & FixRHEO::STATUS_FLUID)) { + compute_interface->correct_v(v[j], v[i], vj, j, i); + rhoi = compute_interface->correct_rho(i,j); + } else if (!(status[i] & FixRHEO::STATUS_FLUID) && !(status[j] & FixRHEO::STATUS_FLUID)) { + rhoi = rho0; + rhoj = rho0; + } + + Voli = mass[itype] / rhoi; + Volj = mass[jtype] / rhoj; + + vij[0] = v[i][0] - v[j][0]; + vij[1] = v[i][1] - v[j][1]; + vij[2] = v[i][2] - v[j][2]; + + if (rho_flag) drho = rhoi - rhoj; + if (temperature_flag) dT = temperature[i] - temperature[j]; + if (eta_flag) deta = eta[i] - eta[j]; + + wp = compute_kernel->calc_dw(i, j, delx, dely, delz, sqrt(rsq)); + dWij = compute_kernel->dWij; + dWji = compute_kernel->dWji; + + for (a = 0; a < dim; a++) { + for (b = 0; b < dim; b++) { + if (velocity_flag) // uxx uxy uxz uyx uyy uyz uzx uzy uzz + gradv[i][a * dim + b] -= vij[a] * Volj * dWij[b]; + } + + if (rho_flag) // P,x P,y P,z + gradr[i][a] -= drho * Volj * dWij[a]; + + if (temperature_flag) // T,x T,y T,z + gradt[i][a] -= dT * Volj * dWij[a]; + + if (eta_flag) // n,x n,y n,z + gradn[i][a] -= deta * Volj * dWij[a]; + } + + if (newton || j < nlocal) { + for (a = 0; a < dim; a++) { + for (b = 0; b < dim; b++) { + if (velocity_flag) // uxx uxy uxz uyx uyy uyz uzx uzy uzz + gradv[j][a * dim + b] += vij[a] * Voli * dWji[b]; + } + + if (rho_flag) // P,x P,y P,z + gradr[j][a] += drho * Voli * dWji[a]; + + if (temperature_flag) // T,x T,y T,z + gradt[j][a] += dT * Voli * dWji[a]; + + if (eta_flag) // n,x n,y n,z + gradn[j][a] += deta * Voli * dWji[a]; + } + } + } + } + } + + if (newton) comm->reverse_comm(this); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOGrad::forward_gradients() +{ + comm_stage = COMMGRAD; + comm_forward = ncomm_grad; + comm->forward_comm(this); +} + + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOGrad::forward_fields() +{ + comm_stage = COMMFIELD; + comm_forward = ncomm_field; + comm->forward_comm(this); +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i,j,k,m; + double *rho = atom->rho; + double *temperature = atom->temperature; + double *eta = atom->viscosity; + double **v = atom->v; + + m = 0; + + for (i = 0; i < n; i++) { + j = list[i]; + if (comm_stage == COMMGRAD) { + + if (velocity_flag){ + for (k = 0; k < dim * dim; k++) + buf[m++] = gradv[j][k]; + } + + if (rho_flag) { + for (k = 0; k < dim; k++) + buf[m++] = gradr[j][k]; + } + + if (temperature_flag) { + for (k = 0; k < dim; k++) + buf[m++] = gradt[j][k]; + } + + if (eta_flag){ + for (k = 0; k < dim; k++) + buf[m++] = gradn[j][k]; + } + } else if (comm_stage == COMMFIELD) { + + if (velocity_flag) { + for (k = 0; k < dim; k++) + buf[m++] = v[j][k]; + } + + if (rho_flag) { + buf[m++] = rho[j]; + } + + if (temperature_flag) { + buf[m++] = temperature[j]; + } + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOGrad::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double * rho = atom->rho; + double * temperature = atom->temperature; + double ** v = atom->v; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (comm_stage == COMMGRAD) { + if (velocity_flag) { + for (k = 0; k < dim * dim; k++) + gradv[i][k] = buf[m++]; + } + if (rho_flag) { + for (k = 0; k < dim; k++) + gradr[i][k] = buf[m++]; + } + if (temperature_flag) { + for (k = 0; k < dim; k++) + gradt[i][k] = buf[m++]; + } + if (eta_flag) { + for (k = 0; k < dim; k++) + gradn[i][k] = buf[m++]; + } + } else if (comm_stage == COMMFIELD) { + if (velocity_flag) { + for (k = 0; k < dim; k++) + v[i][k] = buf[m++]; + } + if (rho_flag) { + rho[i] = buf[m++]; + } + if (temperature_flag) { + temperature[i] = buf[m++]; + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOGrad::pack_reverse_comm(int n, int first, double *buf) +{ + int i,k,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (velocity_flag) { + for (k = 0; k < dim * dim; k++) + buf[m++] = gradv[i][k]; + } + if (rho_flag) { + for (k = 0; k < dim; k++) + buf[m++] = gradr[i][k]; + } + if (temperature_flag) { + for (k = 0; k < dim; k++) + buf[m++] = gradt[i][k]; + } + if (eta_flag) { + for (k = 0; k < dim; k++) + buf[m++] = gradn[i][k]; + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOGrad::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i,k,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + if (velocity_flag) { + for (k = 0; k < dim * dim; k++) + gradv[j][k] += buf[m++]; + } + if (rho_flag) { + for (k = 0; k < dim; k++) + gradr[j][k] += buf[m++]; + } + if (temperature_flag) { + for (k = 0; k < dim; k++) + gradt[j][k] += buf[m++]; + } + if (eta_flag) { + for (k = 0; k < dim; k++) + gradn[j][k] += buf[m++]; + } + } +} diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h new file mode 100644 index 0000000000..8b8e28fd98 --- /dev/null +++ b/src/RHEO/compute_rheo_grad.h @@ -0,0 +1,62 @@ +/* -*- 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 COMPUTE_CLASS +// clang-format off +ComputeStyle(rheo/grad,ComputeRHEOGrad) +// clang-format on +#else + +#ifndef LMP_COMPUTE_RHEO_GRAD_H +#define LMP_COMPUTE_RHEO_GRAD_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeRHEOGrad : public Compute { + public: + ComputeRHEOGrad(class LAMMPS *, int, char **); + ~ComputeRHEOGrad(); + void init(); + void init_list(int, class NeighList *); + void compute_peratom(); + int pack_forward_comm(int, int *, double *, int, int *); + void unpack_forward_comm(int, int, double *); + int pack_reverse_comm(int, int, double *); + void unpack_reverse_comm(int, int *, double *); + void forward_gradients(); + void forward_fields(); + double **gradv; + double **gradr; + double **gradt; + double **gradn; + int stage; + + private: + int dim, comm_stage; + int ncomm_grad, ncomm_field; + double cut, cutsq, rho0; + class NeighList *list; + + class FixRHEO *fix_rheo; + class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOInterface *compute_interface; + + int velocity_flag, temperature_flag, rho_flag, eta_flag; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index fd476d4c9e..17108b4c91 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -114,6 +114,7 @@ void FixRHEO::post_constructor() compute_grad = dynamic_cast(modify->add_compute(fmt::format("rheo_grad all rheo/grad {} velocity rho viscosity temprature", cut))); else compute_grad = dynamic_cast(modify->add_compute(fmt::format("rheo_grad all rheo/grad {} velocity rho viscosity", cut))); + compute_grad->fix_rheo = this; compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface {}", cut))); diff --git a/src/fix_bond_history.cpp b/src/fix_bond_history.cpp index cae9dc744d..277df75085 100644 --- a/src/fix_bond_history.cpp +++ b/src/fix_bond_history.cpp @@ -97,7 +97,7 @@ void FixBondHistory::post_constructor() void FixBondHistory::update_atom_value(int i, int m, int idata, double value) { - if (idata >= ndata || m > nbond) error->all(FLERR, "Index exceeded in fix bond history"); + if (idata >= ndata || m > nbond) error->one(FLERR, "Index exceeded in fix bond history"); atom->darray[index][i][m * ndata + idata] = value; } @@ -105,7 +105,7 @@ void FixBondHistory::update_atom_value(int i, int m, int idata, double value) double FixBondHistory::get_atom_value(int i, int m, int idata) { - if (idata >= ndata || m > nbond) error->all(FLERR, "Index exceeded in fix bond history"); + if (idata >= ndata || m > nbond) error->one(FLERR, "Index exceeded in fix bond history"); return atom->darray[index][i][m * ndata + idata]; } From 560bd90e1149bd880600b1edea291b7b2f1963cb Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 19 Feb 2023 22:08:02 -0700 Subject: [PATCH 003/104] Drafting viscosity fix --- src/RHEO/compute_rheo_grad.cpp | 11 +- src/RHEO/compute_rheo_grad.h | 16 +-- src/RHEO/fix_rheo.cpp | 9 ++ src/RHEO/fix_rheo.h | 3 +- src/RHEO/fix_rheo_viscosity.cpp | 198 ++++++++++++++++++++++++++++++++ src/RHEO/fix_rheo_viscosity.h | 49 ++++++++ 6 files changed, 272 insertions(+), 14 deletions(-) create mode 100644 src/RHEO/fix_rheo_viscosity.cpp create mode 100644 src/RHEO/fix_rheo_viscosity.h diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 33dd3dc3bc..e87d39aa53 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -23,11 +23,8 @@ #include "force.h" #include "neighbor.h" #include "neigh_list.h" -#include "pair.h" -#include "memory.h" #include "modify.h" #include "update.h" -#include "utils.h" #include #include @@ -52,14 +49,13 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : else error->all(FLERR, "Illegal compute rheo/grad command, {}", arg[iarg]); } - dim = domain->dimension; - ncomm_grad = 0; ncomm_field = 0; comm_reverse = 0; std::string fix_cmd = "rheo_grad_property_atom all property/atom" + int dim = domain->dimension; if (velocity_flag) { ncomm_grad += dim * dim; ncomm_field += dim; @@ -165,6 +161,7 @@ void ComputeRHEOGrad::compute_peratom() int *type = atom->type; double *mass = atom->mass; int newton = force->newton; + int dim = domain->dimension; inum = list->inum; ilist = list->ilist; @@ -310,6 +307,7 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, double *temperature = atom->temperature; double *eta = atom->viscosity; double **v = atom->v; + int dim = domain->dimension; m = 0; @@ -363,6 +361,7 @@ void ComputeRHEOGrad::unpack_forward_comm(int n, int first, double *buf) double * rho = atom->rho; double * temperature = atom->temperature; double ** v = atom->v; + int dim = domain->dimension; m = 0; last = first + n; @@ -404,6 +403,7 @@ void ComputeRHEOGrad::unpack_forward_comm(int n, int first, double *buf) int ComputeRHEOGrad::pack_reverse_comm(int n, int first, double *buf) { int i,k,m,last; + int dim = domain->dimension; m = 0; last = first + n; @@ -433,6 +433,7 @@ int ComputeRHEOGrad::pack_reverse_comm(int n, int first, double *buf) void ComputeRHEOGrad::unpack_reverse_comm(int n, int *list, double *buf) { int i,k,j,m; + int dim = domain->dimension; m = 0; for (i = 0; i < n; i++) { diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index 8b8e28fd98..35b50ca834 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -28,13 +28,13 @@ class ComputeRHEOGrad : public Compute { public: ComputeRHEOGrad(class LAMMPS *, int, char **); ~ComputeRHEOGrad(); - void init(); - void init_list(int, class NeighList *); - void compute_peratom(); - int pack_forward_comm(int, int *, double *, int, int *); - void unpack_forward_comm(int, int, double *); - int pack_reverse_comm(int, int, double *); - void unpack_reverse_comm(int, int *, double *); + void init() override; + void init_list(int, class NeighList *) override; + void compute_peratom() override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; void forward_gradients(); void forward_fields(); double **gradv; @@ -44,7 +44,7 @@ class ComputeRHEOGrad : public Compute { int stage; private: - int dim, comm_stage; + int comm_stage; int ncomm_grad, ncomm_field; double cut, cutsq, rho0; class NeighList *list; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 17108b4c91..b77a35dd95 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -123,6 +123,12 @@ void FixRHEO::post_constructor() if (shift_flag) compute_vshift = dynamic_cast(modify->add_compute(fmt::format("rheo_vshift all rheo/vshift {}", cut))); + + + //todo here + //allocate memory for viscosity, pressure, etc + //don't want to save to restart/datafiles (could disable fix store/state) + //but do want it available for dupm files } /* ---------------------------------------------------------------------- */ @@ -142,6 +148,9 @@ void FixRHEO::init() { dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; + + if (modify->get_fix_by_style("rheo").size() > 1) + error->all(FLERR,"Can only specify one instance of fix rheo"); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 8597eb2809..24be629efe 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -47,7 +47,8 @@ class FixRHEO : public Fix { int viscosity_fix_defined; int pressure_fix_defined; - int *status, *surface; + // Non-persistent per-atom arrays are initialized here + int *surface; double *conductivity, *viscosity, *pressure; double **f_pressure; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp new file mode 100644 index 0000000000..9f7d3cf23c --- /dev/null +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -0,0 +1,198 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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 "fix_rheo_viscosity.h" + +#include "atom.h" +#include "comm.h" +#include "compute_rheo_grad.h" +#include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "memory.h" +#include "modify.h" +#include "update.h" + +#include + +using namespace LAMMPS_NS; +using namespace FixConst; +enum {NONE, CONSTANT, TYPE, POWER}; + +/* ---------------------------------------------------------------------- */ + +FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), eta_type(nullptr) +{ + if (narg < 4) error->all(FLERR,"Illegal fix command"); + + viscosity_style = NONE; + + comm_forward = 1; + + int ntypes = atom->ntypes; + int iarg = 3; + if (strcmp(arg[iarg],"constant") == 0) { + if (iarg+1 >= narg) error->all(FLERR,"Insufficient arguments for fix rheo/viscosity"); + viscosity_style = CONSTANT; + eta = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + if (eta < 0.0) error->all(FLERR,"The viscosity must be positive in fix rheo/viscosity"); + iarg += 1; + } else if (strcmp(arg[iarg],"type") == 0) { + if(iarg+ntypes >= narg) error->all(FLERR,"Insufficient arguments for fix rheo/viscosity"); + viscosity_style = TYPE; + memory->create(eta_type, ntypes + 1, "rheo_thermal:eta_type"); + for (int i = 1; i <= ntypes; i++) { + eta_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i], false, lmp); + if (eta_type[i] < 0.0) error->all(FLERR,"The viscosity must be positive in fix rheo/viscosity"); + } + iarg += ntypes; + } else if (strcmp(arg[iarg],"power") == 0) { + if (iarg+4 >= narg) error->all(FLERR,"Insufficient arguments for fix rheo/viscosity"); + viscosity_style = POWER; + eta = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + gd0 = utils::numeric(FLERR,arg[iarg + 2],false,lmp); + K = utils::numeric(FLERR,arg[iarg + 3],false,lmp); + npow = utils::numeric(FLERR,arg[iarg + 4],false,lmp); + tau0 = eta * gd0 - K * pow(gd0, npow); + if (eta < 0.0) error->all(FLERR,"The viscosity must be positive in fix rheo/viscosity"); + iarg += 5; + } else { + error->all(FLERR,"Illegal fix command, {}", arg[iarg]); + } + + if (viscosity_style == NONE) + error->all(FLERR,"Must specify viscosity style for fix/rheo/viscosity"); +} + +/* ---------------------------------------------------------------------- */ + +FixRHEOViscosity::~FixRHEOViscosity() +{ + memory->destroy(eta_type); +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOViscosity::setmask() +{ + int mask = 0; + mask |= PRE_FORCE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOViscosity::init() +{ + auto fixes = modify->get_fix_by_style("rheo"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); + fix_rheo = dynamic_cast(fixes[0]); + + fix_rheo->viscosity_fix_defined = 1; + compute_grad = fix_rheo->compute_grad; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOViscosity::setup_pre_force(int /*vflag*/) +{ + // Identify whether this is the last instance of fix viscosity + // Will handle communication + last_flag = 0; + + int i = 0; + auto fixlist = modify->get_fix_by_style("rheo/viscosity"); + for (const auto &ifix : fixlist) { + if (strcmp(ifix->id, id) == 0) break; + i++; + } + + if ((i + 1) == fixlist.size()) last_flag = 1; + + pre_force(0); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOViscosity::pre_force(int /*vflag*/) +{ + int i, a, b; + double tmp, gdot; + + int *type = atom->type; + double *viscosity = fix_rheo->viscosity; + int *mask = atom->mask; + double **gradv = compute_grad->gradv; + + int nlocal = atom->nlocal; + int dim = domain->dimension; + + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + if (viscosity_style == CONSTANT) { + viscosity[i] = eta; + } else if (viscosity_style == TYPE) { + viscosity[i] = eta_type[type[i]]; + } else if (viscosity_style == POWER) { + gdot = 0.0; + for (a = 0; a < dim; a++) { + for (b = a; b < dim; b++) { + tmp = gradv[i][a * dim + b] + gradv[i][b * dim + a]; + tmp = tmp * tmp; + if (a == b) tmp *= 0.5; + gdot += tmp; + } + } + gdot = sqrt(gdot); + if (gdot <= gd0) { + viscosity[i] = eta; + } else { + viscosity[i] = K * pow(gdot, npow - 1) + tau0 / gdot; + } + } + } + } + + if (last_flag) comm->forward_comm(this); +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i,j,k,m; + double *viscosity = fix_rheo->viscosity; + m = 0; + + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = viscosity[j]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double *viscosity = fix_rheo->viscosity; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + viscosity[i] = buf[m++]; + } +} diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h new file mode 100644 index 0000000000..130d4d8cc8 --- /dev/null +++ b/src/RHEO/fix_rheo_viscosity.h @@ -0,0 +1,49 @@ +/* -*- 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(rheo/viscosity,FixRHEOViscosity) +// clang-format on +#else + +#ifndef LMP_FIX_RHEO_VISCOSITY_H +#define LMP_FIX_RHEO_VISCOSITY_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixRHEOViscosity : public Fix { + public: + FixRHEOViscosity(class LAMMPS *, int, char **); + ~FixRHEOViscosity(); + int setmask() override; + void init() override; + virtual void setup_pre_force(int) override; + void pre_force(int) override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; + private: + double *eta_type, eta; + double npow, K, gd0, tau0; + int viscosity_style; + int last_flag; + class FixRHEO *fix_rheo; + class ComputeRHEOGrad *compute_grad; +}; + +} // namespace LAMMPS_NS + +#endif +#endif From 4ac7a228b5ebcb6ba656713179d8ac331417ed6f Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 20 Feb 2023 12:47:51 -0700 Subject: [PATCH 004/104] Revamping atom data storage in fixes --- src/RHEO/fix_rheo.cpp | 84 +++++++++++++++++++++++++-------- src/RHEO/fix_rheo.h | 14 ++++-- src/RHEO/fix_rheo_viscosity.cpp | 13 ++++- src/RHEO/fix_rheo_viscosity.h | 3 +- 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index b77a35dd95..f5a5f8b151 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -21,6 +21,7 @@ #include "compute_rheo_vshift.h" #include "domain.h" #include "error.h" +#include "fix_store_peratom.h" #include "force.h" #include "modify.h" #include "update.h" @@ -33,15 +34,30 @@ using namespace FixConst; FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), compute_grad(nullptr), compute_kernel(nullptr), - compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr) + compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr), + fix_store_visc(nullptr), fix_store_pres(nullptr), fix_store_cond(nullptr), + fix_store_surf(nullptr), fix_store_fp(nullptr), surface(nullptr), conductivity(nullptr), + viscosity(nullptr), pressure(nullptr), f_pressure(nullptr) { + time_integrate = 1; + + viscosity_fix_defined = 0; + pressure_fix_defined = 0; + thermal_fix_defined = 0; + surface_fix_defined = 0; + thermal_flag = 0; rhosum_flag = 0; shift_flag = 0; - solid_flag = 0; + interface_flag = 0; + surface_flag = 0; + rho0 = 1.0; csq = 1.0; + if (igroup != 0) + error->all(FLERR,"fix rheo command requires group all"); + if (atom->rho_flag != 1) error->all(FLERR,"fix rheo command requires atom_style with density"); if (atom->status_flag != 1) @@ -68,6 +84,10 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : shift_flag = 1; } else if (strcmp(arg[iarg],"thermal") == 0) { thermal_flag = 1; + } else if (strcmp(arg[iarg],"surface/detection") == 0) { + surface_flag = 1; + } else if (strcmp(arg[iarg],"interface/reconstruction") == 0) { + interface_flag = 1; } else if (strcmp(arg[iarg],"rhosum") == 0) { rhosum_flag = 1; if(iarg + 1 >= narg) error->all(FLERR,"Illegal rhosum option in fix rheo"); @@ -86,17 +106,18 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : } iarg += 1; } - - time_integrate = 1; - thermal_fix_defined = 0; - viscosity_fix_defined = 0; - pressure_fix_defined = 0; } /* ---------------------------------------------------------------------- */ FixRHEO::~FixRHEO() { + if (fix_store_visc) modify->delete_fix("rheo_store_visc"); + if (fix_store_pres) modify->delete_fix("rheo_store_pres"); + if (fix_store_surf) modify->delete_fix("rheo_store_surf"); + if (fix_store_cond) modify->delete_fix("rheo_store_cond"); + if (fix_store_fp) modify->delete_fix("rheo_store_fp"); + if (compute_kernel) modify->delete_compute("rheo_kernel"); if (compute_grad) modify->delete_compute("rheo_grad"); if (compute_interface) modify->delete_compute("rheo_interface"); @@ -110,13 +131,18 @@ void FixRHEO::post_constructor() { compute_kernel = dynamic_cast(modify->add_compute(fmt::format("rheo_kernel all rheo/kernel {} {} {}", kernel_style, zmin_kernel, cut))); - if (thermal_flag) - compute_grad = dynamic_cast(modify->add_compute(fmt::format("rheo_grad all rheo/grad {} velocity rho viscosity temprature", cut))); - else - compute_grad = dynamic_cast(modify->add_compute(fmt::format("rheo_grad all rheo/grad {} velocity rho viscosity", cut))); - compute_grad->fix_rheo = this; + fix_store_visc = dynamic_cast(modify->add_fix("rheo_store_visc all STORE/PERATOM 0 1")) + fix_store_visc->disable = 1; + viscosity = fix_store_visc->vstore; + fix_store_pres = dynamic_cast(modify->add_fix("rheo_store_pres all STORE/PERATOM 0 1")) + pressure = fix_store_pres->vstore; + fix_store_pres->disable = 1; - compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface {}", cut))); + + std::string cmd = "rheo_grad all rheo/grad {} velocity rho viscosity"; + if (thermal_flag) cmd += "temperature"; + compute_grad = dynamic_cast(modify->add_compute(fmt::format(cmd, cut))); + compute_grad->fix_rheo = this; if (rhosum_flag) compute_rhosum = dynamic_cast(modify->add_compute(fmt::format("rheo_rhosum all rheo/rho/sum {} {}", cut, zmin_rhosum))); @@ -124,11 +150,25 @@ void FixRHEO::post_constructor() if (shift_flag) compute_vshift = dynamic_cast(modify->add_compute(fmt::format("rheo_vshift all rheo/vshift {}", cut))); + if (surface_flag) { + fix_store_surf = dynamic_cast(modify->add_fix("rheo_store_surf all STORE/PERATOM 0 1")) + surface = fix_store_surf->vstore; + fix_store_surf->disable = 1; + } - //todo here - //allocate memory for viscosity, pressure, etc - //don't want to save to restart/datafiles (could disable fix store/state) - //but do want it available for dupm files + if (thermal_flag) { + fix_store_cond = dynamic_cast(modify->add_fix("rheo_store_cond all STORE/PERATOM 0 1")) + conductivity = fix_store_cond->vstore; + fix_store_cond->disable = 1; + } + + if (interface_flag) { + compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface {}", cut))); + + fix_store_fp = dynamic_cast(modify->add_fix("rheo_store_fp all STORE/PERATOM 0 3")) + f_pressure = fix_store_fp->astore; + fix_store_fp->disable = 1; + } } /* ---------------------------------------------------------------------- */ @@ -158,19 +198,23 @@ void FixRHEO::init() void FixRHEO::setup_pre_force(int /*vflag*/) { // Check to confirm all accessory fixes are defined - if(!thermal_fix_defined && thermal_flag) - error->all(FLERR, "Missing fix rheo/thermal"); - if (!viscosity_fix_defined) error->all(FLERR, "Missing fix rheo/viscosity"); if (!pressure_fix_defined) error->all(FLERR, "Missing fix rheo/pressure"); + if(!thermal_fix_defined && thermal_flag) + error->all(FLERR, "Missing fix rheo/thermal"); + + if(!surface_fix_defined && surface_flag) + error->all(FLERR, "Missing fix rheo/surface"); + // Reset to zero for next run thermal_fix_defined = 0; viscosity_fix_defined = 0; pressure_fix_defined = 0; + surface_fix_defined = 0; pre_force(0); } diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 24be629efe..1e35701278 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -41,17 +41,25 @@ class FixRHEO : public Fix { int thermal_flag; int rhosum_flag; int shift_flag; - int solid_flag; + int interface_flag; + int surface_flag; - int thermal_fix_defined; int viscosity_fix_defined; int pressure_fix_defined; + int thermal_fix_defined; + int surface_fix_defined; - // Non-persistent per-atom arrays are initialized here + // Non-persistent per-atom arrays int *surface; double *conductivity, *viscosity, *pressure; double **f_pressure; + class FixStorePeratom *fix_store_visc; + class FixStorePeratom *fix_store_pres; + class FixStorePeratom *fix_store_cond; + class FixStorePeratom *fix_store_surf; + class FixStorePeratom *fix_store_fp; + class ComputeRHEOGrad *compute_grad; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 9f7d3cf23c..846eb0f97f 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -39,6 +39,7 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : viscosity_style = NONE; comm_forward = 1; + nmax = atom->nmax; int ntypes = atom->ntypes; int iarg = 3; @@ -107,8 +108,10 @@ void FixRHEOViscosity::init() void FixRHEOViscosity::setup_pre_force(int /*vflag*/) { - // Identify whether this is the last instance of fix viscosity - // Will handle communication + // Identify whether this is the first/last instance of fix viscosity + // First will handle growing arrays + // Last will handle communication + first_flag = 0 last_flag = 0; int i = 0; @@ -118,6 +121,7 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) i++; } + if (i == 0) first_flag = 1; if ((i + 1) == fixlist.size()) last_flag = 1; pre_force(0); @@ -138,6 +142,11 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) int nlocal = atom->nlocal; int dim = domain->dimension; + if (first_flag & nmax < atom->nmax) { + nmax = atom->nmax; + fix_rheo->fix_store_visc->grow_arrays(nmax); + } + for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (viscosity_style == CONSTANT) { diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h index 130d4d8cc8..b907617477 100644 --- a/src/RHEO/fix_rheo_viscosity.h +++ b/src/RHEO/fix_rheo_viscosity.h @@ -38,7 +38,8 @@ class FixRHEOViscosity : public Fix { double *eta_type, eta; double npow, K, gd0, tau0; int viscosity_style; - int last_flag; + int first_flag, last_flag; + int nmax; class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; }; From c73f9188ce5d26c78e4119436a44ebb582bc6792 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 20 Feb 2023 20:42:44 -0700 Subject: [PATCH 005/104] Initial thermal/pair files --- src/RHEO/fix_rheo_thermal.cpp | 382 +++++++++++++++++++++++++ src/RHEO/fix_rheo_thermal.h | 73 +++++ src/RHEO/pair_rheo.cpp | 517 ++++++++++++++++++++++++++++++++++ src/RHEO/pair_rheo.h | 59 ++++ 4 files changed, 1031 insertions(+) create mode 100644 src/RHEO/fix_rheo_thermal.cpp create mode 100644 src/RHEO/fix_rheo_thermal.h create mode 100644 src/RHEO/pair_rheo.cpp create mode 100644 src/RHEO/pair_rheo.h diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp new file mode 100644 index 0000000000..ed56d5a618 --- /dev/null +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -0,0 +1,382 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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 "fix_rheo_thermal.h" +#include "fix_rheo.h" +#include "atom.h" +#include "memory.h" +#include "modify.h" +#include "error.h" +#include "update.h" +#include "force.h" +#include "math_extra.h" + +using namespace LAMMPS_NS; +using namespace FixConst; +enum {NONE, CONSTANT, TYPE, ALUMINUM}; + +/* ---------------------------------------------------------------------- */ + +FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg) +{ + if (narg < 4) error->all(FLERR,"Illegal fix command"); + + Tc_style = NONE; + cv_style = NONE; + alpha_style = NONE; + conductivity_style = NONE; + dynamic_group_allow = 1; + + Tc_type = nullptr; + kappa_type = nullptr; + cv_type = nullptr; + alpha_type = nullptr; + + int ntypes = atom->ntypes; + int iarg = 3; + while (iarg < narg) { + if (strcmp(arg[iarg],"conductivity") == 0) { + // Conductivity arguments + if (iarg+1 >= narg) error->all(FLERR,"Illegal fix command"); + if (strcmp(arg[iarg+1],"constant") == 0) { + if (iarg+2 >= narg) error->all(FLERR,"Illegal fix command"); + conductivity_style = CONSTANT; + kappa = utils::numeric(FLERR,arg[iarg+2],false,lmp); + if (kappa < 0.0) error->all(FLERR,"Illegal fix command"); + iarg += 2; + } else if (strcmp(arg[iarg+1],"type") == 0) { + if (iarg+1+ntypes >= narg) error->all(FLERR,"Illegal fix command"); + conductivity_style = TYPE; + memory->create(kappa_type,ntypes+1,"rheo_thermal:kappa_type"); + for (int i = 1; i <= ntypes; i++) { + kappa_type[i] = utils::numeric(FLERR,arg[iarg+1+i],false,lmp); + if (kappa_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); + } + iarg += 1+ntypes; + } else { + error->all(FLERR,"Illegal fix command"); + } + } else if (strcmp(arg[iarg],"cv") == 0) { + // Cv arguments + if (iarg+1 >= narg) error->all(FLERR,"Illegal fix command"); + if (strcmp(arg[iarg+1],"constant") == 0) { + if (iarg+2 >= narg) error->all(FLERR,"Illegal fix command"); + cv_style = CONSTANT; + cv = utils::numeric(FLERR,arg[iarg+2],false,lmp); + if (cv < 0.0) error->all(FLERR,"Illegal fix command"); + iarg += 2; + } else if (strcmp(arg[iarg+1],"type") == 0) { + if (iarg+1+ntypes >= narg) error->all(FLERR,"Illegal fix command"); + cv_style = TYPE; + memory->create(cv_type,ntypes+1,"rheo_thermal:cv_type"); + for (int i = 1; i <= ntypes; i++) { + cv_type[i] = utils::numeric(FLERR,arg[iarg+1+i],false,lmp); + if (cv_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); + } + iarg += 1+ntypes; + } else { + error->all(FLERR,"Illegal fix command"); + } + } else if (strcmp(arg[iarg],"alpha") == 0) { + // Cv arguments + if (iarg+1 >= narg) error->all(FLERR,"Illegal fix command"); + if (strcmp(arg[iarg+1],"constant") == 0) { + if (iarg+2 >= narg) error->all(FLERR,"Illegal fix command"); + alpha_style = CONSTANT; + alpha = utils::numeric(FLERR,arg[iarg+2],false,lmp); + iarg += 2; + } else if (strcmp(arg[iarg+1],"type") == 0) { + if (iarg+1+ntypes >= narg) error->all(FLERR,"Illegal fix command"); + alpha_style = TYPE; + memory->create(alpha_type,ntypes+1,"rheo_thermal:alpha_type"); + for (int i = 1; i <= ntypes; i++) { + alpha_type[i] = utils::numeric(FLERR,arg[iarg+1+i],false,lmp); + if (alpha_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); + } + iarg += 1+ntypes; + } else { + error->all(FLERR,"Illegal fix command"); + } + } else if (strcmp(arg[iarg],"Tfreeze") == 0) { + // T freeze arguments + if (iarg+1 >= narg) error->all(FLERR,"Illegal fix command"); + if (strcmp(arg[iarg+1],"constant") == 0) { + if (iarg+2 >= narg) error->all(FLERR,"Illegal fix command"); + Tc_style = CONSTANT; + Tc = utils::numeric(FLERR,arg[iarg+2],false,lmp); + if (Tc < 0.0) error->all(FLERR,"Illegal fix command"); + iarg += 2; + } else if (strcmp(arg[iarg+1],"type") == 0) { + if (iarg+1+ntypes >= narg) error->all(FLERR,"Illegal fix command"); + Tc_style = TYPE; + memory->create(Tc_type,ntypes+1,"rheo_thermal:Tc_type"); + for (int i = 1; i <= ntypes; i++) { + Tc_type[i] = utils::numeric(FLERR,arg[iarg+1+i],false,lmp); + if (Tc_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); + } + iarg += 1+ntypes; + } else { + error->all(FLERR,"Illegal fix command"); + } + } else { + error->all(FLERR,"Illegal fix command"); + } + iarg += 1; + } + + if (cv_style == NONE || conductivity_style == NONE) + error->all(FLERR, "Must specify specific heat and conductivity styles\n"); +} + +/* ---------------------------------------------------------------------- */ + +FixRHEOThermal::~FixRHEOThermal() +{ + // If fix rheo is still defined, remove any set flags + if (fix_rheo) { + //fix_rheo->thermal_fix_defined = 0; + //if(viscosity_style != NONE) fix_rheo->viscosity_fix_defined = 0; + } + + memory->destroy(cv_type); + memory->destroy(Tc_type); + memory->destroy(kappa_type); + memory->destroy(alpha_type); +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOThermal::setmask() +{ + int mask = 0; + mask |= PRE_FORCE; + mask |= INITIAL_INTEGRATE; + mask |= POST_INTEGRATE; + mask |= END_OF_STEP; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::init() +{ + int flag; + int ifix = modify->find_fix_by_style("rheo"); + if (ifix == -1) error->all(FLERR, "Need to define fix rheo to use fix rheo/thermal"); + fix_rheo = ((FixRHEO *) modify->fix[ifix]); + + if (!fix_rheo->thermal_flag) error->all(FLERR, "Need to define thermal setting in fix rheo"); + + if (fix_rheo->thermal_fix_defined) + error->all(FLERR, "Cannot define two rheo thermal evolution fixes"); + fix_rheo->thermal_fix_defined = 1; + + int ifix2 = modify->find_fix_by_style("rheo/thermal"); + if (ifix > ifix2) + error->all(FLERR, "Fix RHEO must be defined before fix RHEO/thermal"); + + dtf = 0.5 * update->dt * force->ftm2v; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::initial_integrate(int /*vflag*/) +{ + // update temperature from shifting + int i; + int *status = atom->status; + double **gradt = compute_grad->gradt; + double **vshift = compute_vshift->array_atom; + + int *mask = atom->mask; + int nlocal = atom->nlocal; + + if (igroup == atom->firstgroup) + nlocal = atom->nfirst; + + if (shift_flag) { + compute_vshift->correct_surfaces(); + for (i = 0; i < nlocal; i++) { + + if (!(status[i] & STATUS_SHIFT)) continue; + + if (mask[i] & groupbit) { + for (a = 0; a < dim; a++) { + temperature[i] += dtv * vshift[i][a] * gradt[i][a]; + } + } + } + } +} + + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::setup_pre_force(int /*vflag*/) +{ + pre_force(0); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::post_integrate() +{ + //Post integrate teo ensure gradient up to date + int *phase = atom->phase; + double *temp = atom->temp; + double *heat = atom->heat; + double *rho = atom->rho; + int *mask = atom->mask; + + double cvi, Tc, Tci, Ti, alphai; + + //Integrate temperature and check phase + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + if (phase[i] == FixRHEO::FLUID_NO_FORCE) continue; + + cvi = calc_cv(i); + temp[i] += dtf*heat[i]/cvi; + + if (alpha_style != NONE && phase[i] <= FixRHEO::FLUID_MAX) { + alphai = calc_alpha(i); + rho[i] += dtf*heat[i]/cvi*alphai; + } + + if (Tc_style != NONE) { + Ti = temp[i]; + Tci = calc_Tc(i); + + if (Ti > Tci) { + phase[i] = FixRHEO::FLUID; + } else { + if (phase[i] == FixRHEO::SOLID) { + continue; + } else { + phase[i] = FixRHEO::FREEZING; + } + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::pre_force(int /*vflag*/) +{ + double *conductivity = atom->conductivity; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + // Calculate non-persistent quantities before pairstyles + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + conductivity[i] = calc_kappa(i); + } + } +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::end_of_step() +{ + double *temp = atom->temp; + double *heat = atom->heat; + int *phase = atom->phase; + int *mask = atom->mask; + double *rho = atom->rho; + + double cvi, alphai; + + //Integrate temperature and check phase + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + if (phase[i] == FixRHEO::FLUID_NO_FORCE) continue; + + cvi = calc_cv(i); + temp[i] += dtf*heat[i]/cvi; + + if (alpha_style != NONE && phase[i] <= FixRHEO::FLUID_MAX) { + alphai = calc_alpha(i); + rho[i] += dtf*heat[i]/cvi*alphai; + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; +} + +/* ---------------------------------------------------------------------- */ + +double FixRHEOThermal::calc_kappa(int i) +{ + if (conductivity_style == CONSTANT) { + return kappa; + } else if (conductivity_style == TYPE) { + int itype = atom->type[i]; + return(kappa_type[itype]); + } else { + error->all(FLERR, "Invalid style"); + } +} + +/* ---------------------------------------------------------------------- */ + +double FixRHEOThermal::calc_cv(int i) +{ + if (cv_style == CONSTANT) { + return cv; + } else if (cv_style == TYPE) { + int itype = atom->type[i]; + return(cv_type[itype]); + } else { + error->all(FLERR, "Invalid style"); + } +} + + +/* ---------------------------------------------------------------------- */ + +double FixRHEOThermal::calc_alpha(int i) +{ + if (alpha_style == CONSTANT) { + return alpha; + } else if (alpha_style == TYPE) { + int itype = atom->type[i]; + return(alpha_type[itype]); + } else { + error->all(FLERR, "Invalid style"); + } +} + +/* ---------------------------------------------------------------------- */ + +double FixRHEOThermal::calc_Tc(int i) +{ + if (Tc_style == CONSTANT) { + return Tc; + } else if (Tc_style == TYPE) { + int itype = atom->type[i]; + return(Tc_type[itype]); + } else { + error->all(FLERR, "Invalid style"); + } +} \ No newline at end of file diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h new file mode 100644 index 0000000000..d1dcdc6e4d --- /dev/null +++ b/src/RHEO/fix_rheo_thermal.h @@ -0,0 +1,73 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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 FIX_CLASS + +FixStyle(rheo/thermal,FixRHEOThermal) + +#else + +#ifndef LMP_FIX_RHEO_THERMAL_H +#define LMP_FIX_RHEO_THERMAL_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixRHEOThermal : public Fix { + public: + FixRHEOThermal(class LAMMPS *, int, char **); + ~FixRHEOThermal(); + int setmask(); + void init(); + void setup_pre_force(int); + void initial_integrate(); + void post_integrate(); + void pre_force(int); + void end_of_step(); + void reset_dt(); + + private: + double *cv_type, cv; + double *Tc_type, Tc; + double *kappa_type, kappa; + double *alpha_type, alpha; + double dtf, dtv; + + double calc_kappa(int); + double calc_cv(int); + double calc_Tc(int); + double calc_alpha(int); + + int Tc_style; + int cv_style; + int alpha_style; + int conductivity_style; + + class FixRHEO *fix_rheo; +}; + +} + +#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/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp new file mode 100644 index 0000000000..b0443933e1 --- /dev/null +++ b/src/RHEO/pair_rheo.cpp @@ -0,0 +1,517 @@ +/* ---------------------------------------------------------------------- + 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. + ------------------------------------------------------------------------- */ + +#include "pair_rheo.h" + +#include "atom.h" +#include "comm.h" +#include "compute_rheo_kernel.h" +#include "compute_rheo_grad.h" +#include "compute_rheo_interface.h" +#include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "memory.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "update.h" +#include "utils.h" + +#include + +using namespace LAMMPS_NS; + +#define EPSILON 1e-2 + +/* ---------------------------------------------------------------------- */ + +PairRHEO::PairRHEO(LAMMPS *lmp) : + Pair(lmp), compute_kernel(nullptr), compute_grad(nullptr), + compute_interface(nullptr), fix_rheo(nullptr) +{ + restartinfo = 0; + single_enable = 0; + + artificial_visc_flag = 0; + rho_damp_flag = 0; + thermal_flag = 0; +} + +/* ---------------------------------------------------------------------- */ + +PairRHEO::~PairRHEO() +{ + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairRHEO::compute(int eflag, int vflag) +{ + int i, j, a, b, ii, jj, inum, jnum, itype, jtype; + int error_flag, pair_force_flag, pair_rho_flag, pair_avisc_flag; + double xtmp, ytmp, ztmp; + + int *ilist, *jlist, *numneigh, **firstneigh; + double imass, jmass, rsq, r, ir; + + double w, wp, rhoi, rhoj, voli, volj, Pi, Pj; + double *dWij, *dWji, *d2Wij, *d2Wji, *dW1ij, *dW1ji; + double vijeij, etai, etaj, kappai, kappaj; + double Ti, Tj, dT; + double drho_damp, fmag; + double mu, q, cs, fp_prefactor; + double dx[3] = {0}; + double fv[3] = {0}; + double dfp[3] = {0}; + double fsolid[3] = {0}; + double du[3] = {0}; + double vi[3] = {0}; + double vj[3] = {0}; + double dv[3] = {0}; + double psi_ij = 0.0; + double Fij = 0.0; + + ev_init(eflag, vflag); + + double **gradv = compute_grad->gradv; + double **gradt = compute_grad->gradt; + double **gradr = compute_grad->gradr; + double **gradn = compute_grad->gradn; + double **v = atom->v; + double **x = atom->x; + double **f = atom->f; + double **fp = atom->fp; + double *rho = atom->rho; + double *mass = atom->mass; + double *drho = atom->drho; + double *temp = atom->temp; + double *heat = atom->heat; + double *viscosity = atom->viscosity; + double *conductivity = atom->conductivity; + double *special_lj = force->special_lj; + tagint *tag = atom->tag; + int *type = atom->type; + int *phase = atom->phase; + + int nlocal = atom->nlocal; + int newton_pair = force->newton_pair; + int dim = domain->dimension; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + imass = mass[itype]; + + kappai = conductivity[i]; + etai = viscosity[i]; + Ti = temp[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + factor_lj = special_lj[sbmask(j)]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; + jtype = type[j]; + jmass = mass[jtype]; + + if (rsq < cutsq[itype][jtype]) { + r = sqrt(rsq); + ir = 1/r; + + kappaj = conductivity[j]; + etaj = viscosity[j]; + Tj = temp[j]; + + pair_rho_flag = 0; + pair_force_flag = 0; + pair_avisc_flag = 0; + if (phase[i] <= FixRHEO::FLUID_MAX || phase[j] <= FixRHEO::FLUID_MAX) { + pair_force_flag = 1; + } + if (phase[i] <= FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) { + pair_avisc_flag = 1; + pair_rho_flag = 1; + } + + wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2], r); + dWij = compute_kernel->dWij; + dWji = compute_kernel->dWji; + + for (a = 0; a < dim; a ++) { + vi[a] = v[i][a]; + vj[a] = v[j][a]; + fsolid[a] = 0.0; + } + + // Add corrections for walls + rhoi = rho[i]; + rhoj = rho[j]; + if (phase[i] <= FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { + compute_sinterpolation->correct_v(v[i], v[j], vi, i, j); + rhoj = compute_sinterpolation->correct_rho(j,i); + + // Repel if close to inner solid particle + if (compute_sinterpolation->chi[j] > 0.9 && r < (cut[itype][jtype] * 0.5)) { + fmag = (compute_sinterpolation->chi[j] - 0.9) * (cut[itype][jtype] * 0.5 - r); + fmag *= rho0[itype] * csq[itype] * cut[itype][jtype] * ir; + fsolid[0] = fmag * dx[0]; + fsolid[1] = fmag * dx[1]; + fsolid[2] = fmag * dx[2]; + } + } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) { + compute_sinterpolation->correct_v(v[j], v[i], vj, j, i); + rhoi = compute_sinterpolation->correct_rho(i,j); + + // Repel if close to inner solid particle + if (compute_sinterpolation->chi[i] > 0.9 && r < (cut[itype][jtype] * 0.5)) { + fmag = (compute_sinterpolation->chi[i] - 0.9) * (cut[itype][jtype] * 0.5 - r); + fmag *= rho0[jtype] * csq[jtype] * cut[itype][jtype] * ir; + fsolid[0] = fmag * dx[0]; + fsolid[1] = fmag * dx[1]; + fsolid[2] = fmag * dx[2]; + } + } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { + rhoi = 1.0; + rhoj = 1.0; + } + + // Compute volume and pressure after reconstructing + voli = imass / rhoi; + volj = jmass / rhoj; + Pj = calc_pressure(rhoj, jtype); + Pi = calc_pressure(rhoi, itype); + + //Check if Second order kernels will be used for eta*Lap(v) + error_flag = 0; + if (laplacian_order == 2) { + error_flag = compute_kernel->calc_d2w(i, j, dx[0], dx[1], dx[2], r); + d2Wij = compute_kernel->d2Wij; + d2Wji = compute_kernel->d2Wji; + } + + //Thermal Evolution + if (thermal_flag) { + dT = 0.0; + for (a = 0; a < dim; a++) { + dT += (kappai + kappaj) * (Ti-Tj) * dx[a] * dWij[a] * ir * ir; + //Assumes heat capacity and density = 1, needs to be generalized + } + dT *= voli * volj; + heat[i] += dT; + } + + // If either particle is fluid, compute hydrostatic and viscous forces + // Compute eta*Lap(v) - different forms depending on order of RK correction + if (pair_force_flag) { + //Hydrostatic pressure forces + fp_prefactor = voli * volj * (Pj + Pi); + + //Add artificial viscous pressure if required + if (artificial_visc_flag && pair_avisc_flag){ + //Interpolate velocities to midpoint and use this difference for artificial viscosity + for (a = 0; a < dim; a++) { + du[a] = vi[a] - vj[a]; + for (b = 0; b < dim; b++) { + du[a] -= 0.5 * (gradv[i][a * dim + b] + gradv[j][a * dim + b]) * dx[b]; + } + } + mu = (du[0] * dx[0] + du[1] * dx[1]+ du[2] * dx[2]) * hinv3; + mu = mu / (rsq * hinv3 * hinv3 + EPSILON); + mu= MIN(0.0, mu); + cs = 0.5 * (sqrt(csq[itype]) + sqrt(csq[jtype])); + // "kinematic viscous pressure" q = Q/rho + q = av*(-2.0*cs*mu + 1.0*mu*mu); + fp_prefactor += voli*volj*q*(rhoj + rhoi); + } + + // -Grad[P + Q] + dfp[0] = - fp_prefactor*dWij[0]; + dfp[1] = - fp_prefactor*dWij[1]; + dfp[2] = - fp_prefactor*dWij[2]; + + // Now compute viscous eta*Lap[v] terms + for (a = 0; a < dim; a ++) { + fv[a] = 0.0; + for (b = 0; b < dim; b++) { + fv[a] += (etai+etaj)*(vi[a]-vj[a])*dx[b]*dWij[b]*ir*ir; + } + fv[a] *= voli*volj; + } + + } else { + for (a = 0; a < dim; a ++) { + fv[a] = 0; + dfp[a] = 0; + } + } + + if (pair_force_flag) { + f[i][0] += fv[0] + dfp[0] + fsolid[0]; + f[i][1] += fv[1] + dfp[1] + fsolid[1]; + f[i][2] += fv[2] + dfp[2] + fsolid[2]; + fp[i][0] += dfp[0]; + fp[i][1] += dfp[1]; + fp[i][2] += dfp[2]; + } + + // Density damping + // conventional for low-order h + // interpolated for RK 1 & 2 (Antuono et al, Computers & Fluids 2021) + if (rho_damp_flag && pair_rho_flag) { + if (laplacian_order>=1 && error_flag == 0){ + psi_ij = rhoj-rhoi; + Fij = 0.0; + for (a = 0; a < dim; a++){ + psi_ij += 0.5*(gradr[i][a]+gradr[j][a])*dx[a]; + Fij -= dx[a]*dWij[a]; + } + Fij *= ir*ir; + drho[i] += 2*rho_damp*psi_ij*Fij*volj; + } + else { + drho_damp = 2*rho_damp*(rhoj-rhoi)*ir*wp; + drho[i] -= drho_damp*volj; + } + } + + if (evflag) // Doesn't account for unbalanced forces + ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, fv[0]+dfp[0], fv[1]+dfp[1], fv[2]+dfp[2], dx[0], dx[1], dx[2]); + + // Newton neighbors + if (newton_pair || j < nlocal) { + + if (thermal_flag) { + dT = 0.0; + for(a = 0; a < dim; a++){ + //dT += kappai*dWji[a]*gradt[i][a]; + //dT -= kappaj*dWji[a]*gradt[j][a]; + dT += 1/1*(kappai+kappaj)*(Ti-Tj)*dx[a]*dWji[a]*ir*ir; //Assumes heat capacity and density = 1, needs to be generalized + } + dT *= -voli*volj; + heat[j] -= dT; + } + + for (a = 0; a < dim; a ++) { + fv[a] = 0.0; + for (b = 0; b < dim; b++) { + //fv[a] += etai*dWji[b]*(gradv[i][a*dim+b]+gradv[i][b*dim+a]); + //fv[a] -= etaj*dWji[b]*(gradv[j][a*dim+b]+gradv[j][b*dim+a]); + fv[a] += (etai+etaj)*(vi[a]-vj[a])*dx[b]*dWji[b]*ir*ir; + } + fv[a] *= -voli*volj; // flip sign here b/c -= at accummulator + } + + + + if (pair_force_flag) { + for (a = 0; a < dim; a++) + dfp[a] = fp_prefactor*dWji[a]; + } + + if (rho_damp_flag && pair_rho_flag){ + if (laplacian_order>=1 && error_flag == 0){ + Fij = 0.0; + for (a = 0; a < dim; a++){ + Fij += dx[a]*dWji[a]; + } + Fij *= ir*ir; + psi_ij *= -1; + drho[j] += 2*rho_damp*psi_ij*Fij*voli; + } + else { + drho_damp = 2*rho_damp*(rhoj-rhoi)*ir*wp; + drho[j] += drho_damp*voli; + } + } + if (pair_force_flag) { + f[j][0] -= fv[0] + dfp[0] + fsolid[0]; + f[j][1] -= fv[1] + dfp[1] + fsolid[1]; + f[j][2] -= fv[2] + dfp[2] + fsolid[2]; + + fp[j][0] -= dfp[0]; + fp[j][1] -= dfp[1]; + fp[j][2] -= dfp[2]; + } + } + } + } + } + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- + allocate all arrays + ------------------------------------------------------------------------- */ + +void PairRHEO::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag, n + 1, n + 1, "pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); +} + +/* ---------------------------------------------------------------------- + global settings + ------------------------------------------------------------------------- */ + +void PairRHEO::settings(int narg, char **arg) +{ + if(narg < 1) error->all(FLERR,"Illegal pair_style command"); + + int iarg = 0; + while (iarg < narg) { + if (strcmp(arg[iarg], "rho/damp") == 0) { + if (iarg+1 >= narg) error->all(FLERR,"Illegal pair_style command"); + + rho_damp_flag = 1; + rho_damp = utils::numeric(FLERR,arg[iarg+1],false,lmp); + iarg ++; + } else if (strcmp(arg[iarg], "artificial/visc") == 0) { + if (iarg+1 >= narg) error->all(FLERR,"Illegal pair_style command"); + + artificial_visc_flag = 1; + av = utils::numeric(FLERR,arg[iarg+1],false,lmp); + iarg ++; + } else error->all(FLERR,"Illegal pair_style command"); + iarg++; + } +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs + ------------------------------------------------------------------------- */ + +void PairRHEO::coeff(int narg, char **arg) +{ + if (narg != 4) + error->all(FLERR,"Incorrect number of args for pair_style llns coefficients"); + if (!allocated) + allocate(); + + int ilo, ihi, jlo, jhi; + utils::bounds(FLERR,arg[0],1, atom->ntypes, ilo, ihi,error); + utils::bounds(FLERR,arg[1],1, atom->ntypes, jlo, jhi,error); + + double rho0_one = utils::numeric(FLERR,arg[2],false,lmp); + double c_one = utils::numeric(FLERR,arg[3],false,lmp); + + if (c_one != 1.0) error->warning(FLERR, "Need c = 1 for assumption in compute rheo/solids"); + if (rho0_one != 1.0) error->warning(FLERR, "Need rho0 = 1 for assumption in compute rheo/solids"); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + rho0[i] = rho0_one; + csq[i] = c_one*c_one; + + for (int j = 0; j <= atom->ntypes; j++) { + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) + error->all(FLERR,"Incorrect args for pair llns coefficients"); +} + +/* ---------------------------------------------------------------------- + setup specific to this pair style + ------------------------------------------------------------------------- */ + +void PairRHEO::setup() +{ + int flag; + int ifix = modify->find_fix_by_style("rheo"); + if (ifix == -1) error->all(FLERR, "Using pair RHEO without fix RHEO"); + fix_rheo = ((FixRHEO *) modify->fix[ifix]); + + compute_kernel = fix_rheo->compute_kernel; + compute_grad = fix_rheo->compute_grad; + compute_sinterpolation = fix_rheo->compute_sinterpolation; + thermal_flag = fix_rheo->thermal_flag; + + + + + h = utils::numeric(FLERR,arg[0],false,lmp); + if (h <= 0.0) error->all(FLERR,"Illegal pair_style command"); + hinv = 1.0 / h; + hinv3 = 3.0 * hinv; + laplacian_order = -1; + + + if (comm->ghost_velocity == 0) + error->all(FLERR,"Pair RHEO requires ghost atoms store velocity"); + + if (laplacian_order == -1) { + if (fix_rheo->kernel_type == FixRHEO::CRK2) + laplacian_order = 2; + else if (fix_rheo->kernel_type == FixRHEO::CRK1) + laplacian_order = 1; + else + laplacian_order = 0; + } +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i + ------------------------------------------------------------------------- */ + +double PairRHEO::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + error->all(FLERR,"All pair rheo coeffs are not set"); + } + + cut[i][j] = h; + cut[j][i] = cut[i][j]; + + return cut[i][j]; +} + +/* ---------------------------------------------------------------------- */ + +double PairRHEO::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/, + double /*rsq*/, double /*factor_coul*/, double /*factor_lj*/, double &fforce) +{ + fforce = 0.0; + + return 0.0; +} diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h new file mode 100644 index 0000000000..ebe97cd542 --- /dev/null +++ b/src/RHEO/pair_rheo.h @@ -0,0 +1,59 @@ +/* -*- 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 PAIR_CLASS + +PairStyle(rheo,PairRHEO) + +#else + +#ifndef LMP_PAIR_RHEO_H +#define LMP_PAIR_RHEO_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairRHEO : public Pair { + public: + PairRHEO(class LAMMPS *); + virtual ~PairRHEO(); + virtual void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void setup(); + virtual double init_one(int, int); + virtual double single(int, int, int, int, double, double, double, double &); + + protected: + int laplacian_order; // From fix RHEO + double h, csq*, rho0*; // From fix RHEO + + double hsq, hinv, rho0, av, rho_damp; + + int artificial_visc_flag; + int rho_damp_flag; + int thermal_flag; + + void allocate(); + + class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOGrad *compute_grad; + class ComputeRHEOSolidInterpolation *compute_sinterpolation; + class FixRHEO *fix_rheo; +}; + +} + +#endif +#endif From 1adc66e82ba7c3252d28ab86771c1e3c2369caa3 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 20 Feb 2023 22:07:30 -0700 Subject: [PATCH 006/104] Beginning updates to thermal fix --- src/RHEO/compute_rheo_grad.h | 2 +- src/RHEO/fix_rheo.cpp | 1 + src/RHEO/fix_rheo.h | 22 +-- src/RHEO/fix_rheo_thermal.cpp | 330 +++++++++++++------------------- src/RHEO/fix_rheo_thermal.h | 53 ++--- src/RHEO/fix_rheo_viscosity.cpp | 60 ++++-- src/RHEO/fix_rheo_viscosity.h | 5 +- src/RHEO/pair_rheo.h | 14 +- 8 files changed, 222 insertions(+), 265 deletions(-) diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index 35b50ca834..52c5d7c924 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS { class ComputeRHEOGrad : public Compute { public: ComputeRHEOGrad(class LAMMPS *, int, char **); - ~ComputeRHEOGrad(); + ~ComputeRHEOGrad() override; void init() override; void init_list(int, class NeighList *) override; void compute_peratom() override; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index f5a5f8b151..0c3f784c0e 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -197,6 +197,7 @@ void FixRHEO::init() void FixRHEO::setup_pre_force(int /*vflag*/) { + //Need to rethink and replan // Check to confirm all accessory fixes are defined if (!viscosity_fix_defined) error->all(FLERR, "Missing fix rheo/viscosity"); diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 1e35701278..432d319728 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -27,15 +27,15 @@ namespace LAMMPS_NS { class FixRHEO : public Fix { public: FixRHEO(class LAMMPS *, int, char **); - virtual ~FixRHEO(); - int setmask(); - virtual void post_constructor(); - virtual void init(); - virtual void setup_pre_force(int); - virtual void pre_force(int); - virtual void initial_integrate(int); - virtual void final_integrate(); - void reset_dt(); + ~FixRHEO() override; + int setmask() override; + void post_constructor() override; + void init() override; + void setup_pre_force(int) override; + void pre_force(int) override; + void initial_integrate(int) override; + void final_integrate() override; + void reset_dt() override; int kernel_style; int thermal_flag; @@ -71,7 +71,7 @@ class FixRHEO : public Fix { enum { // Phase status - STATUS_FLUID = 1 << 0, + STATUS_FLUID = 1 << 0, //Need to turn off other options STATUS_REACTIVE = 1 << 1, STATUS_SOLID = 1 << 2, STATUS_FREEZING = 1 << 3 @@ -81,7 +81,7 @@ class FixRHEO : public Fix { STATUS_NO_FORCE = 1 << 5, // Surface status - STATUS_BULK = 1 << 6, + STATUS_BULK = 1 << 6, //Need to turn off other options STATUS_LAYER = 1 << 7, STATUS_SURFACE = 1 << 8, STATUS_SPLASH = 1 << 9, diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index ed56d5a618..0fc4fe294b 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -1,136 +1,116 @@ /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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. + 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. -------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. + ------------------------------------------------------------------------- */ #include "fix_rheo_thermal.h" -#include "fix_rheo.h" + #include "atom.h" -#include "memory.h" -#include "modify.h" +#include "comm.h" +#include "compute_rheo_grad.h" +#include "compute_rheo_vshift.h" #include "error.h" -#include "update.h" +#include "fix_rheo.h" #include "force.h" #include "math_extra.h" +#include "memory.h" +#include "modify.h" +#include "update.h" using namespace LAMMPS_NS; using namespace FixConst; -enum {NONE, CONSTANT, TYPE, ALUMINUM}; +enum {NONE, CONSTANT, TYPE}; /* ---------------------------------------------------------------------- */ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); Tc_style = NONE; cv_style = NONE; - alpha_style = NONE; conductivity_style = NONE; - dynamic_group_allow = 1; - Tc_type = nullptr; - kappa_type = nullptr; - cv_type = nullptr; - alpha_type = nullptr; + comm_forward = 0; + nmax = atom->nmax; int ntypes = atom->ntypes; int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"conductivity") == 0) { // Conductivity arguments - if (iarg+1 >= narg) error->all(FLERR,"Illegal fix command"); - if (strcmp(arg[iarg+1],"constant") == 0) { - if (iarg+2 >= narg) error->all(FLERR,"Illegal fix command"); + if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for conductivity option"); + if (strcmp(arg[iarg + 1],"constant") == 0) { + if (iarg + 2 >= narg) error->all(FLERR,"Insufficient arguments for conductivity option"); conductivity_style = CONSTANT; - kappa = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (kappa < 0.0) error->all(FLERR,"Illegal fix command"); + kappa = utils::numeric(FLERR,arg[iarg + 2],false,lmp); + if (kappa < 0.0) error->all(FLERR,"The conductivity must be positive"); iarg += 2; - } else if (strcmp(arg[iarg+1],"type") == 0) { - if (iarg+1+ntypes >= narg) error->all(FLERR,"Illegal fix command"); + } else if (strcmp(arg[iarg + 1],"type") == 0) { + if (iarg + 1 + ntypes >= narg) error->all(FLERR,"Insufficient arguments for conductivity option"); conductivity_style = TYPE; memory->create(kappa_type,ntypes+1,"rheo_thermal:kappa_type"); for (int i = 1; i <= ntypes; i++) { - kappa_type[i] = utils::numeric(FLERR,arg[iarg+1+i],false,lmp); - if (kappa_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); + kappa_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i],false,lmp); + if (kappa_type[i] < 0.0) error->all(FLERR,"The conductivity must be positive"); } - iarg += 1+ntypes; + iarg += 1 + ntypes; } else { - error->all(FLERR,"Illegal fix command"); + error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); } } else if (strcmp(arg[iarg],"cv") == 0) { // Cv arguments - if (iarg+1 >= narg) error->all(FLERR,"Illegal fix command"); - if (strcmp(arg[iarg+1],"constant") == 0) { - if (iarg+2 >= narg) error->all(FLERR,"Illegal fix command"); + if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for cv option"); + if (strcmp(arg[iarg + 1],"constant") == 0) { + if (iarg + 2 >= narg) error->all(FLERR,"Insufficient arguments for cv option"); cv_style = CONSTANT; - cv = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (cv < 0.0) error->all(FLERR,"Illegal fix command"); + cv = utils::numeric(FLERR,arg[iarg + 2],false,lmp); + if (cv < 0.0) error->all(FLERR,"The specific heat must be positive"); iarg += 2; - } else if (strcmp(arg[iarg+1],"type") == 0) { - if (iarg+1+ntypes >= narg) error->all(FLERR,"Illegal fix command"); + } else if (strcmp(arg[iarg + 1],"type") == 0) { + if (iarg + 1 + ntypes >= narg) error->all(FLERR,"Insufficient arguments for cv option"); cv_style = TYPE; - memory->create(cv_type,ntypes+1,"rheo_thermal:cv_type"); + memory->create(cv_type,ntypes + 1,"rheo_thermal:cv_type"); for (int i = 1; i <= ntypes; i++) { - cv_type[i] = utils::numeric(FLERR,arg[iarg+1+i],false,lmp); - if (cv_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); + cv_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i],false,lmp); + if (cv_type[i] < 0.0) error->all(FLERR,"The specific heat must be positive"); } - iarg += 1+ntypes; + iarg += 1 + ntypes; } else { - error->all(FLERR,"Illegal fix command"); - } - } else if (strcmp(arg[iarg],"alpha") == 0) { - // Cv arguments - if (iarg+1 >= narg) error->all(FLERR,"Illegal fix command"); - if (strcmp(arg[iarg+1],"constant") == 0) { - if (iarg+2 >= narg) error->all(FLERR,"Illegal fix command"); - alpha_style = CONSTANT; - alpha = utils::numeric(FLERR,arg[iarg+2],false,lmp); - iarg += 2; - } else if (strcmp(arg[iarg+1],"type") == 0) { - if (iarg+1+ntypes >= narg) error->all(FLERR,"Illegal fix command"); - alpha_style = TYPE; - memory->create(alpha_type,ntypes+1,"rheo_thermal:alpha_type"); - for (int i = 1; i <= ntypes; i++) { - alpha_type[i] = utils::numeric(FLERR,arg[iarg+1+i],false,lmp); - if (alpha_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); - } - iarg += 1+ntypes; - } else { - error->all(FLERR,"Illegal fix command"); + error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); } } else if (strcmp(arg[iarg],"Tfreeze") == 0) { // T freeze arguments - if (iarg+1 >= narg) error->all(FLERR,"Illegal fix command"); - if (strcmp(arg[iarg+1],"constant") == 0) { - if (iarg+2 >= narg) error->all(FLERR,"Illegal fix command"); + if (iarg+1 >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); + if (strcmp(arg[iarg + 1],"constant") == 0) { + if (iarg + 2 >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); Tc_style = CONSTANT; - Tc = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (Tc < 0.0) error->all(FLERR,"Illegal fix command"); + Tc = utils::numeric(FLERR,arg[iarg + 2],false,lmp); + if (Tc < 0.0) error->all(FLERR,"The melting temperature must be positive"); iarg += 2; - } else if (strcmp(arg[iarg+1],"type") == 0) { - if (iarg+1+ntypes >= narg) error->all(FLERR,"Illegal fix command"); + } else if (strcmp(arg[iarg + 1],"type") == 0) { + if (iarg + 1 + ntypes >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); Tc_style = TYPE; - memory->create(Tc_type,ntypes+1,"rheo_thermal:Tc_type"); + memory->create(Tc_type,ntypes + 1,"rheo_thermal:Tc_type"); for (int i = 1; i <= ntypes; i++) { - Tc_type[i] = utils::numeric(FLERR,arg[iarg+1+i],false,lmp); - if (Tc_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); + Tc_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i],false,lmp); + if (Tc_type[i] < 0.0) error->all(FLERR,"The melting temperature must be positive"); } - iarg += 1+ntypes; + iarg += 1 + ntypes; } else { - error->all(FLERR,"Illegal fix command"); + error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); } } else { - error->all(FLERR,"Illegal fix command"); + error->all(FLERR,"Illegal fix command, {}", arg[iarg]); } iarg += 1; } @@ -143,16 +123,9 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : FixRHEOThermal::~FixRHEOThermal() { - // If fix rheo is still defined, remove any set flags - if (fix_rheo) { - //fix_rheo->thermal_fix_defined = 0; - //if(viscosity_style != NONE) fix_rheo->viscosity_fix_defined = 0; - } - memory->destroy(cv_type); memory->destroy(Tc_type); memory->destroy(kappa_type); - memory->destroy(alpha_type); } /* ---------------------------------------------------------------------- */ @@ -160,10 +133,11 @@ FixRHEOThermal::~FixRHEOThermal() int FixRHEOThermal::setmask() { int mask = 0; - mask |= PRE_FORCE; mask |= INITIAL_INTEGRATE; mask |= POST_INTEGRATE; - mask |= END_OF_STEP; + mask |= POST_NEIGHBOR; + mask |= PRE_FORCE; + mask |= FINAL_INTEGRATE; return mask; } @@ -171,29 +145,49 @@ int FixRHEOThermal::setmask() void FixRHEOThermal::init() { - int flag; - int ifix = modify->find_fix_by_style("rheo"); - if (ifix == -1) error->all(FLERR, "Need to define fix rheo to use fix rheo/thermal"); - fix_rheo = ((FixRHEO *) modify->fix[ifix]); + auto fixes = modify->get_fix_by_style("rheo"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); + fix_rheo = dynamic_cast(fixes[0]); - if (!fix_rheo->thermal_flag) error->all(FLERR, "Need to define thermal setting in fix rheo"); - - if (fix_rheo->thermal_fix_defined) - error->all(FLERR, "Cannot define two rheo thermal evolution fixes"); fix_rheo->thermal_fix_defined = 1; - - int ifix2 = modify->find_fix_by_style("rheo/thermal"); - if (ifix > ifix2) - error->all(FLERR, "Fix RHEO must be defined before fix RHEO/thermal"); + if (!fix_rheo->thermal_flag) + error->all(FLERR, "Need to define thermal setting in fix rheo"); + compute_grad = fix_rheo->compute_grad; + compute_vshift = fix_rheo->compute_vshift; dtf = 0.5 * update->dt * force->ftm2v; } /* ---------------------------------------------------------------------- */ +void FixRHEOThermal::setup_pre_force(int /*vflag*/) +{ + // Identify whether this is the first/last instance of fix thermal + // First will handle growing arrays + // Last will handle communication + first_flag = 0 + last_flag = 0; + + int i = 0; + auto fixlist = modify->get_fix_by_style("rheo/thermal"); + for (const auto &ifix : fixlist) { + if (strcmp(ifix->id, id) == 0) break; + i++; + } + + if (i == 0) first_flag = 1; + if ((i + 1) == fixlist.size()) last_flag = 1; + + post_neighbor(); + pre_force(0); +} + +/* ---------------------------------------------------------------------- */ + void FixRHEOThermal::initial_integrate(int /*vflag*/) { // update temperature from shifting + if (!fix_rheo->shift_flag) return; int i; int *status = atom->status; double **gradt = compute_grad->gradt; @@ -205,73 +199,58 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) if (igroup == atom->firstgroup) nlocal = atom->nfirst; - if (shift_flag) { - compute_vshift->correct_surfaces(); - for (i = 0; i < nlocal; i++) { + for (i = 0; i < nlocal; i++) { + if (!(status[i] & STATUS_SHIFT)) continue; - if (!(status[i] & STATUS_SHIFT)) continue; - - if (mask[i] & groupbit) { - for (a = 0; a < dim; a++) { - temperature[i] += dtv * vshift[i][a] * gradt[i][a]; - } + if (mask[i] & groupbit) { + for (a = 0; a < dim; a++) { + temperature[i] += dtv * vshift[i][a] * gradt[i][a]; } } } } - -/* ---------------------------------------------------------------------- */ - -void FixRHEOThermal::setup_pre_force(int /*vflag*/) -{ - pre_force(0); -} - /* ---------------------------------------------------------------------- */ void FixRHEOThermal::post_integrate() { - //Post integrate teo ensure gradient up to date - int *phase = atom->phase; - double *temp = atom->temp; + int *status = atom->status; + double *temperature = atom->temperature; double *heat = atom->heat; double *rho = atom->rho; int *mask = atom->mask; + int *type = aotm->type; - double cvi, Tc, Tci, Ti, alphai; + double cvi, Tci, Ti; - //Integrate temperature and check phase + //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - if (phase[i] == FixRHEO::FLUID_NO_FORCE) continue; + if (status[i] == FixRHEO::FLUID_NO_FORCE) continue; cvi = calc_cv(i); - temp[i] += dtf*heat[i]/cvi; - - if (alpha_style != NONE && phase[i] <= FixRHEO::FLUID_MAX) { - alphai = calc_alpha(i); - rho[i] += dtf*heat[i]/cvi*alphai; - } + temperature[i] += dtf*heat[i]/cvi; if (Tc_style != NONE) { - Ti = temp[i]; - Tci = calc_Tc(i); + Ti = temperature[i]; + if (Tc_style == CONSTANT) { + Tci = Tc; + } else if (Tc_style == TYPE) { + Tci = Tc_type[type[i]]); + } - if (Ti > Tci) { - phase[i] = FixRHEO::FLUID; - } else { - if (phase[i] == FixRHEO::SOLID) { - continue; - } else { - phase[i] = FixRHEO::FREEZING; - } + if (Ti > Tci) { //Need to untoggle other phase options + status[i] |= FixRHEO::STATUS_FLUID; + } else if (!(status[i] & FixRHEO::STATUS_SOLID)) + status[i] |= FixRHEO::STATUS_FREEZING; } } } } } + +add post neighbor then update preforce below /* ---------------------------------------------------------------------- */ void FixRHEOThermal::pre_force(int /*vflag*/) @@ -286,32 +265,35 @@ void FixRHEOThermal::pre_force(int /*vflag*/) conductivity[i] = calc_kappa(i); } } + + if (conductivity_style == CONSTANT) { + return kappa; + } else if (conductivity_style == TYPE) { + int itype = atom->type[i]; + return(kappa_type[itype]); + } else { + error->all(FLERR, "Invalid style"); + } } /* ---------------------------------------------------------------------- */ -void FixRHEOThermal::end_of_step() +void FixRHEOThermal::final_integrate() { - double *temp = atom->temp; + double *temperature = atom->temperature; double *heat = atom->heat; - int *phase = atom->phase; + int *status = atom->status; int *mask = atom->mask; - double *rho = atom->rho; - double cvi, alphai; + double cvi; - //Integrate temperature and check phase + //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - if (phase[i] == FixRHEO::FLUID_NO_FORCE) continue; + if (status[i] & FixRHEO::STATUS_NO_FORCE) continue; cvi = calc_cv(i); - temp[i] += dtf*heat[i]/cvi; - - if (alpha_style != NONE && phase[i] <= FixRHEO::FLUID_MAX) { - alphai = calc_alpha(i); - rho[i] += dtf*heat[i]/cvi*alphai; - } + temperature[i] += dtf * heat[i] / cvi; } } } @@ -326,57 +308,11 @@ void FixRHEOThermal::reset_dt() /* ---------------------------------------------------------------------- */ -double FixRHEOThermal::calc_kappa(int i) -{ - if (conductivity_style == CONSTANT) { - return kappa; - } else if (conductivity_style == TYPE) { - int itype = atom->type[i]; - return(kappa_type[itype]); - } else { - error->all(FLERR, "Invalid style"); - } -} - -/* ---------------------------------------------------------------------- */ - double FixRHEOThermal::calc_cv(int i) { if (cv_style == CONSTANT) { return cv; } else if (cv_style == TYPE) { - int itype = atom->type[i]; - return(cv_type[itype]); - } else { - error->all(FLERR, "Invalid style"); + return(cv_type[atom->type[i]]); } } - - -/* ---------------------------------------------------------------------- */ - -double FixRHEOThermal::calc_alpha(int i) -{ - if (alpha_style == CONSTANT) { - return alpha; - } else if (alpha_style == TYPE) { - int itype = atom->type[i]; - return(alpha_type[itype]); - } else { - error->all(FLERR, "Invalid style"); - } -} - -/* ---------------------------------------------------------------------- */ - -double FixRHEOThermal::calc_Tc(int i) -{ - if (Tc_style == CONSTANT) { - return Tc; - } else if (Tc_style == TYPE) { - int itype = atom->type[i]; - return(Tc_type[itype]); - } else { - error->all(FLERR, "Invalid style"); - } -} \ No newline at end of file diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index d1dcdc6e4d..c0b5255caa 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -12,9 +12,9 @@ ------------------------------------------------------------------------- */ #ifdef FIX_CLASS - +// clang-format off FixStyle(rheo/thermal,FixRHEOThermal) - +// clang-format on #else #ifndef LMP_FIX_RHEO_THERMAL_H @@ -27,47 +27,36 @@ namespace LAMMPS_NS { class FixRHEOThermal : public Fix { public: FixRHEOThermal(class LAMMPS *, int, char **); - ~FixRHEOThermal(); - int setmask(); - void init(); - void setup_pre_force(int); - void initial_integrate(); - void post_integrate(); - void pre_force(int); - void end_of_step(); - void reset_dt(); + ~FixRHEOThermal() override; + int setmask() override; + void init() override; + void setup_pre_force(int) override; + void initial_integrate() override; + void post_integrate() override; + void post_neighbor() override; + void pre_force(int) override; + void final_integrate() override; + void reset_dt() override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; private: double *cv_type, cv; double *Tc_type, Tc; double *kappa_type, kappa; - double *alpha_type, alpha; double dtf, dtv; - - double calc_kappa(int); - double calc_cv(int); - double calc_Tc(int); - double calc_alpha(int); - int Tc_style; int cv_style; - int alpha_style; int conductivity_style; + int first_flag, last_flag; + int nmax; class FixRHEO *fix_rheo; + + double calc_cv(int); }; -} +} // namespace LAMMPS_NS #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/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 846eb0f97f..72168b2ee9 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -38,35 +38,36 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : viscosity_style = NONE; - comm_forward = 1; + comm_forward = 0; nmax = atom->nmax; int ntypes = atom->ntypes; int iarg = 3; if (strcmp(arg[iarg],"constant") == 0) { - if (iarg+1 >= narg) error->all(FLERR,"Insufficient arguments for fix rheo/viscosity"); + if (iarg+1 >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); viscosity_style = CONSTANT; eta = utils::numeric(FLERR,arg[iarg + 1],false,lmp); - if (eta < 0.0) error->all(FLERR,"The viscosity must be positive in fix rheo/viscosity"); + if (eta < 0.0) error->all(FLERR,"The viscosity must be positive"); iarg += 1; } else if (strcmp(arg[iarg],"type") == 0) { - if(iarg+ntypes >= narg) error->all(FLERR,"Insufficient arguments for fix rheo/viscosity"); + if(iarg+ntypes >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); viscosity_style = TYPE; memory->create(eta_type, ntypes + 1, "rheo_thermal:eta_type"); for (int i = 1; i <= ntypes; i++) { eta_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i], false, lmp); - if (eta_type[i] < 0.0) error->all(FLERR,"The viscosity must be positive in fix rheo/viscosity"); + if (eta_type[i] < 0.0) error->all(FLERR,"The viscosity must be positive"); } iarg += ntypes; } else if (strcmp(arg[iarg],"power") == 0) { - if (iarg+4 >= narg) error->all(FLERR,"Insufficient arguments for fix rheo/viscosity"); + if (iarg+4 >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); viscosity_style = POWER; + comm_forward = 1; eta = utils::numeric(FLERR,arg[iarg + 1],false,lmp); gd0 = utils::numeric(FLERR,arg[iarg + 2],false,lmp); K = utils::numeric(FLERR,arg[iarg + 3],false,lmp); npow = utils::numeric(FLERR,arg[iarg + 4],false,lmp); tau0 = eta * gd0 - K * pow(gd0, npow); - if (eta < 0.0) error->all(FLERR,"The viscosity must be positive in fix rheo/viscosity"); + if (eta < 0.0) error->all(FLERR,"The viscosity must be positive"); iarg += 5; } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg]); @@ -88,6 +89,7 @@ FixRHEOViscosity::~FixRHEOViscosity() int FixRHEOViscosity::setmask() { int mask = 0; + mask |= POST_NEIGHBOR; mask |= PRE_FORCE; return mask; } @@ -124,9 +126,40 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) if (i == 0) first_flag = 1; if ((i + 1) == fixlist.size()) last_flag = 1; + post_neighbor(); pre_force(0); } + +/* ---------------------------------------------------------------------- */ + +void FixRHEOViscosity::post_neighbor() +{ + int i; + + int *type = atom->type; + double *viscosity = fix_rheo->viscosity; + int *mask = atom->mask; + + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + + if (first_flag & nmax < atom->nmax) { + nmax = atom->nmax; + fix_rheo->fix_store_visc->grow_arrays(nmax); + } + + // Update non-evolving viscosity styles only after atoms can exchange + if (viscosity_style == CONSTANT) { + for (i = 0; i < nall; i++) + if (mask[i] & groupbit) viscosity[i] = eta; + } else if (viscosity_style == TYPE) { + for (i = 0; i < nall; i++) + if (mask[i] & groupbit) viscosity[i] = eta_type[type[i]]; + } + } +} + /* ---------------------------------------------------------------------- */ void FixRHEOViscosity::pre_force(int /*vflag*/) @@ -147,13 +180,10 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) fix_rheo->fix_store_visc->grow_arrays(nmax); } - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - if (viscosity_style == CONSTANT) { - viscosity[i] = eta; - } else if (viscosity_style == TYPE) { - viscosity[i] = eta_type[type[i]]; - } else if (viscosity_style == POWER) { + // Update viscosity styles that evolve in time every timestep + if (viscosity_style == POWER) { + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { gdot = 0.0; for (a = 0; a < dim; a++) { for (b = a; b < dim; b++) { @@ -173,7 +203,7 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) } } - if (last_flag) comm->forward_comm(this); + if (last_flag && comm_forward) comm->forward_comm(this); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h index b907617477..31c1441e40 100644 --- a/src/RHEO/fix_rheo_viscosity.h +++ b/src/RHEO/fix_rheo_viscosity.h @@ -27,10 +27,11 @@ namespace LAMMPS_NS { class FixRHEOViscosity : public Fix { public: FixRHEOViscosity(class LAMMPS *, int, char **); - ~FixRHEOViscosity(); + ~FixRHEOViscosity() override; int setmask() override; void init() override; - virtual void setup_pre_force(int) override; + void setup_pre_force(int) override; + void post_neighbor() override; void pre_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index ebe97cd542..9a9d751d45 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -27,13 +27,13 @@ namespace LAMMPS_NS { class PairRHEO : public Pair { public: PairRHEO(class LAMMPS *); - virtual ~PairRHEO(); - virtual void compute(int, int); - void settings(int, char **); - void coeff(int, char **); - void setup(); - virtual double init_one(int, int); - virtual double single(int, int, int, int, double, double, double, double &); + ~PairRHEO() override; + void compute(int, int) override; + void settings(int, char **) override; + void coeff(int, char **) override; + void setup() override; + double init_one(int, int) override; + double single(int, int, int, int, double, double, double, double &) override; protected: int laplacian_order; // From fix RHEO From c715552f7e77ea0575869749f728293e37b14abd Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 21 Feb 2023 10:17:15 -0700 Subject: [PATCH 007/104] Ensuring fix order --- src/RHEO/fix_rheo.cpp | 18 +++++++++++++++--- src/RHEO/fix_rheo_thermal.cpp | 3 ++- src/RHEO/fix_rheo_viscosity.cpp | 3 ++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 0c3f784c0e..5ff72045f7 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -197,8 +197,22 @@ void FixRHEO::init() void FixRHEO::setup_pre_force(int /*vflag*/) { - //Need to rethink and replan + // Check to confirm no accessory fixes are yet defined + // FixRHEO must be the first fix + // Note: these fixes set this flag in setup_pre_force() + if (viscosity_fix_defined || pressure_fix_defined || thermal_fix_defined || surface_fix_defined) + error->all(FLERR, "Fix RHEO must be defined before all other RHEO fixes"); + + pre_force(0); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEO::setup() +{ // Check to confirm all accessory fixes are defined + // Does not ensure fixes correctly cover all atoms (could be a subset group) + // Note: these fixes set this flag in setup_pre_force() if (!viscosity_fix_defined) error->all(FLERR, "Missing fix rheo/viscosity"); @@ -216,8 +230,6 @@ void FixRHEO::setup_pre_force(int /*vflag*/) viscosity_fix_defined = 0; pressure_fix_defined = 0; surface_fix_defined = 0; - - pre_force(0); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 0fc4fe294b..37290e3951 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -149,7 +149,6 @@ void FixRHEOThermal::init() if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); fix_rheo = dynamic_cast(fixes[0]); - fix_rheo->thermal_fix_defined = 1; if (!fix_rheo->thermal_flag) error->all(FLERR, "Need to define thermal setting in fix rheo"); compute_grad = fix_rheo->compute_grad; @@ -162,6 +161,8 @@ void FixRHEOThermal::init() void FixRHEOThermal::setup_pre_force(int /*vflag*/) { + fix_rheo->thermal_fix_defined = 1; + // Identify whether this is the first/last instance of fix thermal // First will handle growing arrays // Last will handle communication diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 72168b2ee9..8ac32cd1dc 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -102,7 +102,6 @@ void FixRHEOViscosity::init() if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); fix_rheo = dynamic_cast(fixes[0]); - fix_rheo->viscosity_fix_defined = 1; compute_grad = fix_rheo->compute_grad; } @@ -110,6 +109,8 @@ void FixRHEOViscosity::init() void FixRHEOViscosity::setup_pre_force(int /*vflag*/) { + fix_rheo->viscosity_fix_defined = 1; + // Identify whether this is the first/last instance of fix viscosity // First will handle growing arrays // Last will handle communication From 99e7673e8ea44429a52c3b0c53f68dde001b75a4 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 21 Feb 2023 19:41:52 -0700 Subject: [PATCH 008/104] Starting pair style, various clean ups --- src/RHEO/fix_rheo.cpp | 23 +++++------ src/RHEO/fix_rheo.h | 63 +++++++++++++++-------------- src/RHEO/fix_rheo_thermal.cpp | 70 +++++++++++++++++++++++---------- src/RHEO/fix_rheo_viscosity.cpp | 12 +++--- src/RHEO/pair_rheo.cpp | 58 ++++++++------------------- src/RHEO/pair_rheo.h | 15 ++++--- 6 files changed, 126 insertions(+), 115 deletions(-) diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 5ff72045f7..e2819ad320 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -66,7 +66,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : if (narg < 5) error->all(FLERR,"Insufficient arguments for fix rheo command"); - cut = utils::numeric(FLERR,arg[3],false,lmp); + h = utils::numeric(FLERR,arg[3],false,lmp); if (strcmp(arg[4],"Quintic") == 0) { kernel_style = QUINTIC; } else if (strcmp(arg[4],"CRK0") == 0) { @@ -125,11 +125,14 @@ FixRHEO::~FixRHEO() if (compute_vshift) modify->delete_compute("rheo_vshift"); } -/* ---------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Create necessary internal computes +------------------------------------------------------------------------- */ void FixRHEO::post_constructor() { - compute_kernel = dynamic_cast(modify->add_compute(fmt::format("rheo_kernel all rheo/kernel {} {} {}", kernel_style, zmin_kernel, cut))); + compute_kernel = dynamic_cast(modify->add_compute(fmt::format("rheo_kernel all rheo/kernel {} {} {}", kernel_style, zmin_kernel, h))); fix_store_visc = dynamic_cast(modify->add_fix("rheo_store_visc all STORE/PERATOM 0 1")) fix_store_visc->disable = 1; @@ -141,14 +144,14 @@ void FixRHEO::post_constructor() std::string cmd = "rheo_grad all rheo/grad {} velocity rho viscosity"; if (thermal_flag) cmd += "temperature"; - compute_grad = dynamic_cast(modify->add_compute(fmt::format(cmd, cut))); + compute_grad = dynamic_cast(modify->add_compute(fmt::format(cmd, h))); compute_grad->fix_rheo = this; if (rhosum_flag) - compute_rhosum = dynamic_cast(modify->add_compute(fmt::format("rheo_rhosum all rheo/rho/sum {} {}", cut, zmin_rhosum))); + compute_rhosum = dynamic_cast(modify->add_compute(fmt::format("rheo_rhosum all rheo/rho/sum {} {}", h, zmin_rhosum))); if (shift_flag) - compute_vshift = dynamic_cast(modify->add_compute(fmt::format("rheo_vshift all rheo/vshift {}", cut))); + compute_vshift = dynamic_cast(modify->add_compute(fmt::format("rheo_vshift all rheo/vshift {}", h))); if (surface_flag) { fix_store_surf = dynamic_cast(modify->add_fix("rheo_store_surf all STORE/PERATOM 0 1")) @@ -163,7 +166,7 @@ void FixRHEO::post_constructor() } if (interface_flag) { - compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface {}", cut))); + compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface {}", h))); fix_store_fp = dynamic_cast(modify->add_fix("rheo_store_fp all STORE/PERATOM 0 3")) f_pressure = fix_store_fp->astore; @@ -197,8 +200,7 @@ void FixRHEO::init() void FixRHEO::setup_pre_force(int /*vflag*/) { - // Check to confirm no accessory fixes are yet defined - // FixRHEO must be the first fix + // Check to confirm accessory fixes do not preceed FixRHEO // Note: these fixes set this flag in setup_pre_force() if (viscosity_fix_defined || pressure_fix_defined || thermal_fix_defined || surface_fix_defined) error->all(FLERR, "Fix RHEO must be defined before all other RHEO fixes"); @@ -210,8 +212,7 @@ void FixRHEO::setup_pre_force(int /*vflag*/) void FixRHEO::setup() { - // Check to confirm all accessory fixes are defined - // Does not ensure fixes correctly cover all atoms (could be a subset group) + // Confirm all accessory fixes are defined, may not cover group all // Note: these fixes set this flag in setup_pre_force() if (!viscosity_fix_defined) error->all(FLERR, "Missing fix rheo/viscosity"); diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 432d319728..3487dd7273 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -32,12 +32,45 @@ class FixRHEO : public Fix { void post_constructor() override; void init() override; void setup_pre_force(int) override; + void setup() override; void pre_force(int) override; void initial_integrate(int) override; void final_integrate() override; void reset_dt() override; + // Model parameters + double h, rho0, csq; + int zmin_kernel, rhosum_zmin; int kernel_style; + enum {QUINTIC, CRK0, CRK1, CRK2}; + + // Non-persistent per-atom arrays + int *surface; + double *conductivity, *viscosity, *pressure; + double **f_pressure; + + // Status variables + enum { + // Phase status + STATUS_FLUID = 1 << 0, + STATUS_REACTIVE = 1 << 1, + STATUS_SOLID = 1 << 2, + STATUS_FREEZING = 1 << 3 + + // Surface status + STATUS_BULK = 1 << 4, + STATUS_LAYER = 1 << 5, + STATUS_SURFACE = 1 << 6, + STATUS_SPLASH = 1 << 7, + + // Temporary status options - reset in preforce + STATUS_SHIFT = 1 << 8, + STATUS_NO_FORCE = 1 << 9, + }; + int phasemask = FFFFFFF0; + int surfacemask = FFFFFF0F; + + // Accessory fixes/computes int thermal_flag; int rhosum_flag; int shift_flag; @@ -47,13 +80,9 @@ class FixRHEO : public Fix { int viscosity_fix_defined; int pressure_fix_defined; int thermal_fix_defined; + int interface_fix_defined; int surface_fix_defined; - // Non-persistent per-atom arrays - int *surface; - double *conductivity, *viscosity, *pressure; - double **f_pressure; - class FixStorePeratom *fix_store_visc; class FixStorePeratom *fix_store_pres; class FixStorePeratom *fix_store_cond; @@ -66,31 +95,7 @@ class FixRHEO : public Fix { class ComputeRHEORhoSum *compute_rhosum; class ComputeRHEOVShift *compute_vshift; - enum {QUINTIC, CRK0, CRK1, CRK2}; - enum {LINEAR, CUBIC, TAITWATER}; - - enum { - // Phase status - STATUS_FLUID = 1 << 0, //Need to turn off other options - STATUS_REACTIVE = 1 << 1, - STATUS_SOLID = 1 << 2, - STATUS_FREEZING = 1 << 3 - - // Temporary status options - reset in preforce - STATUS_SHIFT = 1 << 4, - STATUS_NO_FORCE = 1 << 5, - - // Surface status - STATUS_BULK = 1 << 6, //Need to turn off other options - STATUS_LAYER = 1 << 7, - STATUS_SURFACE = 1 << 8, - STATUS_SPLASH = 1 << 9, - }; - protected: - double cut, rho0, csq; - int zmin_kernel, rhosum_zmin; - double dtv, dtf; }; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 37290e3951..406439f93e 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -240,9 +240,11 @@ void FixRHEOThermal::post_integrate() Tci = Tc_type[type[i]]); } - if (Ti > Tci) { //Need to untoggle other phase options + if (Ti > Tci) { + status[i] &= phasemask; status[i] |= FixRHEO::STATUS_FLUID; } else if (!(status[i] & FixRHEO::STATUS_SOLID)) + status[i] &= phasemask; status[i] |= FixRHEO::STATUS_FREEZING; } } @@ -250,31 +252,59 @@ void FixRHEOThermal::post_integrate() } } +/* ---------------------------------------------------------------------- + Only need to update non-evolving conductivity styles after atoms exchange +------------------------------------------------------------------------- */ -add post neighbor then update preforce below -/* ---------------------------------------------------------------------- */ +void FixRHEOThermal::post_neighbor() +{ + int i; + int *type = atom->type; + double *conductivity = fix_rheo->conductivity; + int *mask = atom->mask; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + + if (first_flag & nmax < atom->nmax) { + nmax = atom->nmax; + fix_rheo->fix_store_cond->grow_arrays(nmax); + } + + if (conductivity_style == CONSTANT) { + for (i = 0; i < nall; i++) + if (mask[i] & groupbit) conductivity[i] = kappa; + } else if (conductivity_style == TYPE) { + for (i = 0; i < nall; i++) + if (mask[i] & groupbit) conductivity[i] = kappa_type[type[i]]; + } + } +} + +/* ---------------------------------------------------------------------- + Update (and forward) evolving conductivity styles every timestep +------------------------------------------------------------------------- */ void FixRHEOThermal::pre_force(int /*vflag*/) { - double *conductivity = atom->conductivity; - int *mask = atom->mask; - int nlocal = atom->nlocal; + // So far, none exist + //int i; + //double *conductivity = fix_rheo->conductivity; + //int *mask = atom->mask; + //int nlocal = atom->nlocal; - // Calculate non-persistent quantities before pairstyles - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - conductivity[i] = calc_kappa(i); - } - } + //if (first_flag & nmax < atom->nmax) { + // nmax = atom->nmax; + // fix_rheo->fix_store_cond->grow_arrays(nmax); + //} - if (conductivity_style == CONSTANT) { - return kappa; - } else if (conductivity_style == TYPE) { - int itype = atom->type[i]; - return(kappa_type[itype]); - } else { - error->all(FLERR, "Invalid style"); - } + //if (conductivity_style == TBD) { + // for (i = 0; i < nlocal; i++) { + // if (mask[i] & groupbit) { + // } + // } + //} + + //if (last_flag && comm_forward) comm->forward_comm(this); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 8ac32cd1dc..f57410783c 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -131,8 +131,9 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) pre_force(0); } - -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Only need to update non-evolving viscosity styles after atoms exchange +------------------------------------------------------------------------- */ void FixRHEOViscosity::post_neighbor() { @@ -150,7 +151,6 @@ void FixRHEOViscosity::post_neighbor() fix_rheo->fix_store_visc->grow_arrays(nmax); } - // Update non-evolving viscosity styles only after atoms can exchange if (viscosity_style == CONSTANT) { for (i = 0; i < nall; i++) if (mask[i] & groupbit) viscosity[i] = eta; @@ -161,14 +161,15 @@ void FixRHEOViscosity::post_neighbor() } } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Update (and forward) evolving viscosity styles every timestep +------------------------------------------------------------------------- */ void FixRHEOViscosity::pre_force(int /*vflag*/) { int i, a, b; double tmp, gdot; - int *type = atom->type; double *viscosity = fix_rheo->viscosity; int *mask = atom->mask; double **gradv = compute_grad->gradv; @@ -181,7 +182,6 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) fix_rheo->fix_store_visc->grow_arrays(nmax); } - // Update viscosity styles that evolve in time every timestep if (viscosity_style == POWER) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index b0443933e1..c796db208a 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -394,23 +394,23 @@ void PairRHEO::allocate() void PairRHEO::settings(int narg, char **arg) { - if(narg < 1) error->all(FLERR,"Illegal pair_style command"); + if (narg < 1) error->all(FLERR,"Illegal pair_style command"); int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg], "rho/damp") == 0) { - if (iarg+1 >= narg) error->all(FLERR,"Illegal pair_style command"); + if (iarg + 1 >= narg) error->all(FLERR,"Illegal pair_style command"); rho_damp_flag = 1; - rho_damp = utils::numeric(FLERR,arg[iarg+1],false,lmp); - iarg ++; + rho_damp = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + iarg++; } else if (strcmp(arg[iarg], "artificial/visc") == 0) { - if (iarg+1 >= narg) error->all(FLERR,"Illegal pair_style command"); + if (iarg + 1 >= narg) error->all(FLERR,"Illegal pair_style command"); artificial_visc_flag = 1; av = utils::numeric(FLERR,arg[iarg+1],false,lmp); - iarg ++; - } else error->all(FLERR,"Illegal pair_style command"); + iarg++; + } else error->all(FLERR,"Illegal pair_style command, {}", arg[iarg]); iarg++; } } @@ -421,8 +421,8 @@ void PairRHEO::settings(int narg, char **arg) void PairRHEO::coeff(int narg, char **arg) { - if (narg != 4) - error->all(FLERR,"Incorrect number of args for pair_style llns coefficients"); + if (narg != 2) + error->all(FLERR,"Incorrect number of args for pair_style rheo coefficients"); if (!allocated) allocate(); @@ -430,17 +430,8 @@ void PairRHEO::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1, atom->ntypes, ilo, ihi,error); utils::bounds(FLERR,arg[1],1, atom->ntypes, jlo, jhi,error); - double rho0_one = utils::numeric(FLERR,arg[2],false,lmp); - double c_one = utils::numeric(FLERR,arg[3],false,lmp); - - if (c_one != 1.0) error->warning(FLERR, "Need c = 1 for assumption in compute rheo/solids"); - if (rho0_one != 1.0) error->warning(FLERR, "Need rho0 = 1 for assumption in compute rheo/solids"); - int count = 0; for (int i = ilo; i <= ihi; i++) { - rho0[i] = rho0_one; - csq[i] = c_one*c_one; - for (int j = 0; j <= atom->ntypes; j++) { setflag[i][j] = 1; count++; @@ -448,7 +439,7 @@ void PairRHEO::coeff(int narg, char **arg) } if (count == 0) - error->all(FLERR,"Incorrect args for pair llns coefficients"); + error->all(FLERR,"Incorrect args for pair rheo coefficients"); } /* ---------------------------------------------------------------------- @@ -457,26 +448,21 @@ void PairRHEO::coeff(int narg, char **arg) void PairRHEO::setup() { - int flag; - int ifix = modify->find_fix_by_style("rheo"); - if (ifix == -1) error->all(FLERR, "Using pair RHEO without fix RHEO"); - fix_rheo = ((FixRHEO *) modify->fix[ifix]); + auto fixes = modify->get_fix_by_style("rheo"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); + fix_rheo = dynamic_cast(fixes[0]); compute_kernel = fix_rheo->compute_kernel; compute_grad = fix_rheo->compute_grad; - compute_sinterpolation = fix_rheo->compute_sinterpolation; + compute_interface = fix_rheo->compute_interface; thermal_flag = fix_rheo->thermal_flag; + h = fix_rheo->h; + csq = fix_rheo->csq; + rho0 = fix_rheo->rho0; - - - - h = utils::numeric(FLERR,arg[0],false,lmp); - if (h <= 0.0) error->all(FLERR,"Illegal pair_style command"); hinv = 1.0 / h; - hinv3 = 3.0 * hinv; laplacian_order = -1; - if (comm->ghost_velocity == 0) error->all(FLERR,"Pair RHEO requires ghost atoms store velocity"); @@ -505,13 +491,3 @@ double PairRHEO::init_one(int i, int j) return cut[i][j]; } - -/* ---------------------------------------------------------------------- */ - -double PairRHEO::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/, - double /*rsq*/, double /*factor_coul*/, double /*factor_lj*/, double &fforce) -{ - fforce = 0.0; - - return 0.0; -} diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index 9a9d751d45..026bc16527 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -12,9 +12,9 @@ ------------------------------------------------------------------------- */ #ifdef PAIR_CLASS - +// clang-format off PairStyle(rheo,PairRHEO) - +// clang-format on #else #ifndef LMP_PAIR_RHEO_H @@ -33,14 +33,13 @@ class PairRHEO : public Pair { void coeff(int, char **) override; void setup() override; double init_one(int, int) override; - double single(int, int, int, int, double, double, double, double &) override; protected: - int laplacian_order; // From fix RHEO - double h, csq*, rho0*; // From fix RHEO + double h, csq, rho0; // From fix RHEO - double hsq, hinv, rho0, av, rho_damp; + double hsq, hinv, av, rho_damp; + int laplacian_order; int artificial_visc_flag; int rho_damp_flag; int thermal_flag; @@ -49,11 +48,11 @@ class PairRHEO : public Pair { class ComputeRHEOKernel *compute_kernel; class ComputeRHEOGrad *compute_grad; - class ComputeRHEOSolidInterpolation *compute_sinterpolation; + class ComputeRHEOInterface *compute_interface; class FixRHEO *fix_rheo; }; -} +} // namespace LAMMPS_NS #endif #endif From ecf43524d4ff2320b226d381af0090f0fd4e3aff Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 21 Feb 2023 22:07:11 -0700 Subject: [PATCH 009/104] Most updates to pair --- src/RHEO/pair_rheo.cpp | 199 +++++++++++++++++++---------------------- src/RHEO/pair_rheo.h | 2 +- 2 files changed, 91 insertions(+), 110 deletions(-) diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index c796db208a..1bed3f1d3e 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -22,6 +22,7 @@ #include "error.h" #include "fix_rheo.h" #include "force.h" +#include "math_extra.h" #include "memory.h" #include "modify.h" #include "neighbor.h" @@ -32,6 +33,7 @@ #include using namespace LAMMPS_NS; +using namespace MathExtra; #define EPSILON 1e-2 @@ -66,16 +68,17 @@ void PairRHEO::compute(int eflag, int vflag) int i, j, a, b, ii, jj, inum, jnum, itype, jtype; int error_flag, pair_force_flag, pair_rho_flag, pair_avisc_flag; double xtmp, ytmp, ztmp; + int fluidi, fluidj; int *ilist, *jlist, *numneigh, **firstneigh; - double imass, jmass, rsq, r, ir; + double imass, jmass, rsq, r, rinv; double w, wp, rhoi, rhoj, voli, volj, Pi, Pj; double *dWij, *dWji, *d2Wij, *d2Wji, *dW1ij, *dW1ji; double vijeij, etai, etaj, kappai, kappaj; double Ti, Tj, dT; double drho_damp, fmag; - double mu, q, cs, fp_prefactor; + double mu, q, fp_prefactor; double dx[3] = {0}; double fv[3] = {0}; double dfp[3] = {0}; @@ -96,18 +99,20 @@ void PairRHEO::compute(int eflag, int vflag) double **v = atom->v; double **x = atom->x; double **f = atom->f; - double **fp = atom->fp; double *rho = atom->rho; double *mass = atom->mass; double *drho = atom->drho; - double *temp = atom->temp; - double *heat = atom->heat; - double *viscosity = atom->viscosity; - double *conductivity = atom->conductivity; + double *temperature = atom->temperature; + double *heatflow = atom->heatflow; + double *chi = compute_interface->chi; + double **f_pressure = fix_rheo->f_pressure; + double *viscosity = fix_rheo->viscosity; + double *conductivity = fix_rheo->conductivity; + double *pressure = fix_rheo->pressure; double *special_lj = force->special_lj; tagint *tag = atom->tag; int *type = atom->type; - int *phase = atom->phase; + int *status = atom->status; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; @@ -132,7 +137,8 @@ void PairRHEO::compute(int eflag, int vflag) kappai = conductivity[i]; etai = viscosity[i]; - Ti = temp[i]; + Ti = temperature[i]; + fluidi = status[i] & FixRHEO::STATUS_FLUID; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -142,25 +148,26 @@ void PairRHEO::compute(int eflag, int vflag) dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; - rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; + rsq = lensq3(dx); jtype = type[j]; jmass = mass[jtype]; if (rsq < cutsq[itype][jtype]) { r = sqrt(rsq); - ir = 1/r; + rinv = 1 / r; kappaj = conductivity[j]; etaj = viscosity[j]; - Tj = temp[j]; + Tj = temperature[j]; + fluidj = status[j] & FixRHEO::STATUS_FLUID; pair_rho_flag = 0; pair_force_flag = 0; pair_avisc_flag = 0; - if (phase[i] <= FixRHEO::FLUID_MAX || phase[j] <= FixRHEO::FLUID_MAX) { + if (fluidi || fluidj) { pair_force_flag = 1; } - if (phase[i] <= FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) { + if (fluidi && fluidj) { pair_avisc_flag = 1; pair_rho_flag = 1; } @@ -169,51 +176,45 @@ void PairRHEO::compute(int eflag, int vflag) dWij = compute_kernel->dWij; dWji = compute_kernel->dWji; - for (a = 0; a < dim; a ++) { + for (a = 0; a < dim; a++) { vi[a] = v[i][a]; vj[a] = v[j][a]; - fsolid[a] = 0.0; } + // TODO: search for fix pressure and add calculate P function // Add corrections for walls rhoi = rho[i]; rhoj = rho[j]; - if (phase[i] <= FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { - compute_sinterpolation->correct_v(v[i], v[j], vi, i, j); - rhoj = compute_sinterpolation->correct_rho(j,i); + Pi = pressure[i]; + Pj = pressure[j]; + fmag = 0; + if (fluidi && (!fluidj)) { + compute_interface->correct_v(v[i], v[j], vi, i, j); + rhoj = compute_interface->correct_rho(j, i); + Pj = fix_pressure->calculate_P(rhoj); + if ((chi[j] > 0.9) && (r < (h * 0.5))) + fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; - // Repel if close to inner solid particle - if (compute_sinterpolation->chi[j] > 0.9 && r < (cut[itype][jtype] * 0.5)) { - fmag = (compute_sinterpolation->chi[j] - 0.9) * (cut[itype][jtype] * 0.5 - r); - fmag *= rho0[itype] * csq[itype] * cut[itype][jtype] * ir; - fsolid[0] = fmag * dx[0]; - fsolid[1] = fmag * dx[1]; - fsolid[2] = fmag * dx[2]; - } - } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) { - compute_sinterpolation->correct_v(v[j], v[i], vj, j, i); - rhoi = compute_sinterpolation->correct_rho(i,j); + } else if ((!fluidi) && fluidj) { + compute_interface->correct_v(v[j], v[i], vj, j, i); + rhoi = compute_interface->correct_rho(i,j); + Pi = fix_pressure->calculate_P(rhoi); + if ((chi[i] > 0.9) && (r < (h * 0.5))) + fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; - // Repel if close to inner solid particle - if (compute_sinterpolation->chi[i] > 0.9 && r < (cut[itype][jtype] * 0.5)) { - fmag = (compute_sinterpolation->chi[i] - 0.9) * (cut[itype][jtype] * 0.5 - r); - fmag *= rho0[jtype] * csq[jtype] * cut[itype][jtype] * ir; - fsolid[0] = fmag * dx[0]; - fsolid[1] = fmag * dx[1]; - fsolid[2] = fmag * dx[2]; - } - } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { + } else if ((!fluidi) && (!fluidj)) { rhoi = 1.0; rhoj = 1.0; } - // Compute volume and pressure after reconstructing + // Repel if close to inner solid particle + scale3(fmag, dx, fsolid); + + // Compute volume after reconstructing voli = imass / rhoi; volj = jmass / rhoj; - Pj = calc_pressure(rhoj, jtype); - Pi = calc_pressure(rhoi, itype); - //Check if Second order kernels will be used for eta*Lap(v) + //Check if Second order kernels will be used for eta * Lap(v) error_flag = 0; if (laplacian_order == 2) { error_flag = compute_kernel->calc_d2w(i, j, dx[0], dx[1], dx[2], r); @@ -221,15 +222,13 @@ void PairRHEO::compute(int eflag, int vflag) d2Wji = compute_kernel->d2Wji; } - //Thermal Evolution + // Thermal Evolution if (thermal_flag) { dT = 0.0; - for (a = 0; a < dim; a++) { - dT += (kappai + kappaj) * (Ti-Tj) * dx[a] * dWij[a] * ir * ir; - //Assumes heat capacity and density = 1, needs to be generalized - } - dT *= voli * volj; - heat[i] += dT; + for (a = 0; a < dim; a++) dT += dx[a] * dWij[a]; + //TODO: Assumes heat capacity and density = 1, needs to be generalized + dT *= voli * volj * (kappai + kappaj) * (Ti - Tj) * rinv * rinv; + heatflow[i] += dT; } // If either particle is fluid, compute hydrostatic and viscous forces @@ -247,62 +246,56 @@ void PairRHEO::compute(int eflag, int vflag) du[a] -= 0.5 * (gradv[i][a * dim + b] + gradv[j][a * dim + b]) * dx[b]; } } - mu = (du[0] * dx[0] + du[1] * dx[1]+ du[2] * dx[2]) * hinv3; - mu = mu / (rsq * hinv3 * hinv3 + EPSILON); + // TODO is hinv3 supposed to be 3.0/h? + mu = lensq3(du) * 3 * hinv; + mu /= (rsq * 9 * hinv * hinv + EPSILON); mu= MIN(0.0, mu); - cs = 0.5 * (sqrt(csq[itype]) + sqrt(csq[jtype])); + // "kinematic viscous pressure" q = Q/rho - q = av*(-2.0*cs*mu + 1.0*mu*mu); - fp_prefactor += voli*volj*q*(rhoj + rhoi); + q = av * (-2.0 * cs * mu + 1.0 * mu * mu); //TODO is 1.0 supposed to be something? + fp_prefactor += voli * volj * q * (rhoj + rhoi); } // -Grad[P + Q] - dfp[0] = - fp_prefactor*dWij[0]; - dfp[1] = - fp_prefactor*dWij[1]; - dfp[2] = - fp_prefactor*dWij[2]; + scale3(-fp_prefactor, dWij, dfp); - // Now compute viscous eta*Lap[v] terms + // Now compute viscous eta * Lap[v] terms for (a = 0; a < dim; a ++) { fv[a] = 0.0; - for (b = 0; b < dim; b++) { - fv[a] += (etai+etaj)*(vi[a]-vj[a])*dx[b]*dWij[b]*ir*ir; - } - fv[a] *= voli*volj; + for (b = 0; b < dim; b++) fv[a] += (vi[a] - vj[a]) * dx[b] * dWij[b]; + fv[a] *= voli * volj * rinv * rinv * (etai + etaj); } } else { - for (a = 0; a < dim; a ++) { - fv[a] = 0; - dfp[a] = 0; - } + zero3(fv); + zero3(dfp); } if (pair_force_flag) { f[i][0] += fv[0] + dfp[0] + fsolid[0]; f[i][1] += fv[1] + dfp[1] + fsolid[1]; f[i][2] += fv[2] + dfp[2] + fsolid[2]; - fp[i][0] += dfp[0]; - fp[i][1] += dfp[1]; - fp[i][2] += dfp[2]; + f_pressure[i][0] += dfp[0]; + f_pressure[i][1] += dfp[1]; + f_pressure[i][2] += dfp[2]; } // Density damping // conventional for low-order h // interpolated for RK 1 & 2 (Antuono et al, Computers & Fluids 2021) if (rho_damp_flag && pair_rho_flag) { - if (laplacian_order>=1 && error_flag == 0){ - psi_ij = rhoj-rhoi; + if ((laplacian_order >= 1) && (error_flag == 0)) { + psi_ij = rhoj - rhoi; Fij = 0.0; for (a = 0; a < dim; a++){ - psi_ij += 0.5*(gradr[i][a]+gradr[j][a])*dx[a]; - Fij -= dx[a]*dWij[a]; + psi_ij += 0.5 * (gradr[i][a] + gradr[j][a]) * dx[a]; + Fij -= dx[a] * dWij[a]; } - Fij *= ir*ir; - drho[i] += 2*rho_damp*psi_ij*Fij*volj; - } - else { - drho_damp = 2*rho_damp*(rhoj-rhoi)*ir*wp; - drho[i] -= drho_damp*volj; + Fij *= rinv * rinv; + drho[i] += 2 * rho_damp * psi_ij * Fij * volj; + } else { + drho_damp = 2 * rho_damp * (rhoj - rhoi) * rinv * wp; + drho[i] -= drho_damp * volj; } } @@ -314,55 +307,42 @@ void PairRHEO::compute(int eflag, int vflag) if (thermal_flag) { dT = 0.0; - for(a = 0; a < dim; a++){ - //dT += kappai*dWji[a]*gradt[i][a]; - //dT -= kappaj*dWji[a]*gradt[j][a]; - dT += 1/1*(kappai+kappaj)*(Ti-Tj)*dx[a]*dWji[a]*ir*ir; //Assumes heat capacity and density = 1, needs to be generalized - } - dT *= -voli*volj; + for (a = 0; a < dim; a++) dT += dx[a] * dWji[a]; //TODO csq and h terms + dT *= -voli * volj * (kappai + kappaj) * (Ti - Tj) * rinv * rinv; heat[j] -= dT; } for (a = 0; a < dim; a ++) { fv[a] = 0.0; - for (b = 0; b < dim; b++) { - //fv[a] += etai*dWji[b]*(gradv[i][a*dim+b]+gradv[i][b*dim+a]); - //fv[a] -= etaj*dWji[b]*(gradv[j][a*dim+b]+gradv[j][b*dim+a]); - fv[a] += (etai+etaj)*(vi[a]-vj[a])*dx[b]*dWji[b]*ir*ir; - } - fv[a] *= -voli*volj; // flip sign here b/c -= at accummulator + for (b = 0; b < dim; b++) fv[a] += (vi[a] - vj[a]) * dx[b] * dWji[b]; + fv[a] *= -voli * volj * (etai + etaj) * rinv * rinv; + // flip sign here b/c -= at accummulator } - - if (pair_force_flag) { for (a = 0; a < dim; a++) - dfp[a] = fp_prefactor*dWji[a]; + dfp[a] = fp_prefactor * dWji[a]; } if (rho_damp_flag && pair_rho_flag){ - if (laplacian_order>=1 && error_flag == 0){ + if ((laplacian_order >= 1) && (error_flag == 0)) { Fij = 0.0; - for (a = 0; a < dim; a++){ - Fij += dx[a]*dWji[a]; - } - Fij *= ir*ir; + for (a = 0; a < dim; a++) Fij += dx[a] * dWji[a]; + Fij *= rinv * rinv; psi_ij *= -1; - drho[j] += 2*rho_damp*psi_ij*Fij*voli; - } - else { - drho_damp = 2*rho_damp*(rhoj-rhoi)*ir*wp; - drho[j] += drho_damp*voli; + drho[j] += 2 * rho_damp * psi_ij * Fij * voli; + } else { + drho_damp = 2 * rho_damp * (rhoj - rhoi) * rinv * wp; + drho[j] += drho_damp * voli; } } if (pair_force_flag) { f[j][0] -= fv[0] + dfp[0] + fsolid[0]; f[j][1] -= fv[1] + dfp[1] + fsolid[1]; f[j][2] -= fv[2] + dfp[2] + fsolid[2]; - - fp[j][0] -= dfp[0]; - fp[j][1] -= dfp[1]; - fp[j][2] -= dfp[2]; + f_pressure[j][0] -= dfp[0]; + f_pressure[j][1] -= dfp[1]; + f_pressure[j][2] -= dfp[2]; } } } @@ -461,6 +441,7 @@ void PairRHEO::setup() rho0 = fix_rheo->rho0; hinv = 1.0 / h; + cs = sqrt(csq); laplacian_order = -1; if (comm->ghost_velocity == 0) diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index 026bc16527..42172be3a4 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -37,7 +37,7 @@ class PairRHEO : public Pair { protected: double h, csq, rho0; // From fix RHEO - double hsq, hinv, av, rho_damp; + double cs, hsq, hinv, av, rho_damp; int laplacian_order; int artificial_visc_flag; From 6e65d13ad31f36a9b30b8852c676e1efd8a9bd57 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 26 Feb 2023 21:13:32 -0700 Subject: [PATCH 010/104] Adding vshift + pressure, various fixes --- src/RHEO/compute_rheo_grad.cpp | 2 +- src/RHEO/compute_rheo_vshift.cpp | 294 +++++++++++++++++++++++++++++++ src/RHEO/compute_rheo_vshift.h | 57 ++++++ src/RHEO/fix_rheo.cpp | 45 ++++- src/RHEO/fix_rheo_pressure.cpp | 206 ++++++++++++++++++++++ src/RHEO/fix_rheo_pressure.h | 49 ++++++ src/RHEO/fix_rheo_thermal.cpp | 2 +- src/RHEO/fix_rheo_viscosity.cpp | 6 +- src/RHEO/pair_rheo.cpp | 51 +++--- src/RHEO/pair_rheo.h | 1 + 10 files changed, 669 insertions(+), 44 deletions(-) create mode 100644 src/RHEO/compute_rheo_vshift.cpp create mode 100644 src/RHEO/compute_rheo_vshift.h create mode 100644 src/RHEO/fix_rheo_pressure.cpp create mode 100644 src/RHEO/fix_rheo_pressure.h diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index e87d39aa53..0cefd2ac6a 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -41,7 +41,7 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : velocity_flag = temperature_flag = rho_flag = eta_flag = 0; - for (int iarg = 3; iarg < narg; iarg ++) { + for (int iarg = 3; iarg < narg; iarg++) { if (strcmp(arg[iarg],"velocity") == 0) velocity_flag = 1; else if (strcmp(arg[iarg],"rho") == 0) rho_flag = 1; else if (strcmp(arg[iarg],"temperature") == 0) temperature_flag = 1; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp new file mode 100644 index 0000000000..42fa1e8c82 --- /dev/null +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -0,0 +1,294 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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_rheo_vshift.h" +#include "fix_rheo.h" +#include "compute_rheo_solids.h" +#include "compute_rheo_grad.h" +#include "compute_rheo_kernel.h" +#include "fix_rheo_surface.h" +#include +#include +#include "atom.h" +#include "modify.h" +#include "domain.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "force.h" +#include "pair.h" +#include "comm.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), vshift(nullptr), fix_rheo(nullptr), compute_kernel(nullptr), + compute_grad(nullptr), compute_surface(nullptr), compute_interface(nullptr) +{ + if (narg != 3) error->all(FLERR,"Illegal compute RHEO/VShift command"); + + comm_reverse = 3; + surface_flag = 0; + + nmax = atom->nmax; + memory->create(vshift, nmax, 3, "rheo/vshift:vshift"); + array_atom = vshift; + peratom_flag = 1; + size_peratom_cols = 3; +} + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOVShift::~ComputeRHEOVShift() +{ + memory->destroy(vshift); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOVShift::init() +{ + neighbor->add_request(this, NeighConst::REQ_DEFAULT); + + surface_flag = 0; + if (fix_rheo->surface_flag) { + surface_flag = 1; + fix_rheo_surface = fix_rheo->fix_rheo_surface; + } + + compute_kernel = fix_rheo->compute_kernel; + compute_grad = fix_rheo->compute_grad; + compute_interface = fix_rheo->compute_interface; + + cut = fix_rheo->cut; + cutsq = cut * cut; + cutthird = cut / 3.0; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOVShift::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOVShift::compute_peratom() +{ + int i, j, a, b, ii, jj, jnum, itype, jtype; + int fluidi, fluidj; + double xtmp, ytmp, ztmp, rsq, r, rinv; + double w, wp, dr, w0, w4, vmag, prefactor; + double imass, jmass, voli, volj, rhoi, rhoj; + double dx[3], vi[3], vj[3] = {0}; + int dim = domain->dimension; + + int *jlist; + int inum, *ilist, *numneigh, **firstneigh; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + + double **x = atom->x; + double **v = atom->v; + int *type = atom->type; + int *status = atom->status; + int *surface = atom->surface; + double *rho = atom->rho; + double *mass = atom->mass; + int newton_pair = force->newton_pair; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + if (nall > nmax) { + nmax = nall; + memory->destroy(vshift); + memory->create(vshift, nmax, 3, "rheo/vshift:vshift"); + array_atom = vshift; + } + + for (i = 0; i < nall; i++) + for (a = 0; a < dim; a++) + vshift[i][a] = 0.0; + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + imass = mass[itype]; + fluidi = status[i] & FixRHEO::STATUS_FLUID; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + fluidj = status[j] & FixRHEO::STATUS_FLUID; + if ((!fluidi) && (!fluidj)) continue; + if (!(status[i] & FixRHEO::STATUS_SHIFT) && !(status[j] & FixRHEO::STATUS_SHIFT)) continue; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; + + if (rsq < cutsq) { + jtype = type[j]; + jmass = mass[jtype]; + + r = sqrt(rsq); + rinv = 1 / r; + + for (a = 0; a < dim; a ++) { + vi[a] = v[i][a]; + vj[a] = v[j][a]; + } + + rhoi = rho[i]; + rhoj = rho[j]; + + // Add corrections for walls + if (fluidi && (!fluidj)) { + compute_interface->correct_v(v[i], v[j], vi, i, j); + rhoj = compute_interface->correct_rho(j,i); + } else if ((!fluidi) && fluidj) { + compute_interface->correct_v(v[j], v[i], vj, j, i); + rhoi = compute_interface->correct_rho(i,j); + } else if ((!fluidi) && (!fluidj)) { + rhoi = 1.0; + rhoj = 1.0; + } + + voli = imass / rhoi; + volj = jmass / rhoj; + + wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2], r); + w = compute_kernel->calc_w(i, j, dx[0], dx[1], dx[2], r); + w0 = compute_kernel->calc_w(i, j, 0, 0, 0, cutthird); // dx, dy, dz irrelevant + w4 = w * w * w * w / (w0 * w0 * w0 * w0); + dr = -2 * cutthird * (1 + 0.2 * w4) * wp * rinv; + + if (mask[i] & groupbit) { + vmag = sqrt(vi[0] * vi[0] + vi[1] * vi[1] + vi[2] * vi[2]); + prefactor = vmag * volj * dr; + vshift[i][0] += prefactor * dx[0]; + vshift[i][1] += prefactor * dx[1]; + vshift[i][2] += prefactor * dx[2]; + } + + if (newton_pair || j < nlocal) { + if (mask[j] & groupbit) { + vmag = sqrt(vj[0] * vj[0] + vj[1] * vj[1] + vj[2] * vj[2]); + prefactor = vmag * voli * dr; + vshift[j][0] -= prefactor * dx[0]; + vshift[j][1] -= prefactor * dx[1]; + vshift[j][2] -= prefactor * dx[2]; + } + } + } + } + } + + if (newton_pair) comm->reverse_comm_compute(this); +} + + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOVShift::correct_surfaces() +{ + if (!surface_flag) return; + + int *status = atom->status; + int *mask = atom->mask; + int nlocal = atom->nlocal; + int i, a, b; + int dim = domain->dimension; + int *surface = atom->surface; + + double **nsurf; + nsurf = fix_rheo_surface->n_surface; + double nx,ny,nz,vx,vy,vz; + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + if (surface[i] == 1 || surface[i] == 2) { + nx = nsurf[i][0]; + ny = nsurf[i][1]; + vx = vshift[i][0]; + vy = vshift[i][1]; + vz = vshift[i][2]; + vshift[i][0] = (1 - nx * nx) * vx - nx * ny * vy; + vshift[i][1] = (1 - ny * ny) * vy - nx * ny * vx; + if (dim > 2) { + nz = nsurf[i][2]; + vshift[i][0] -= nx * nz * vz; + vshift[i][1] -= ny * nz * vz; + vshift[i][2] = (1 - nz * nz) * vz - nz * ny * vy - nx * nz * vx; + } else { + vshift[i][2] = 0.0; + } + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOVShift::pack_reverse_comm(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = vshift[i][0]; + buf[m++] = vshift[i][1]; + buf[m++] = vshift[i][2]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOVShift::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + vshift[j][0] += buf[m++]; + vshift[j][1] += buf[m++]; + vshift[j][2] += buf[m++]; + } +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based array +------------------------------------------------------------------------- */ + +double ComputeRHEOVShift::memory_usage() +{ + double bytes = 3 * nmax * sizeof(double); + return bytes; +} diff --git a/src/RHEO/compute_rheo_vshift.h b/src/RHEO/compute_rheo_vshift.h new file mode 100644 index 0000000000..fceb287510 --- /dev/null +++ b/src/RHEO/compute_rheo_vshift.h @@ -0,0 +1,57 @@ +/* -*- 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 COMPUTE_CLASS +// clang-format off +ComputeStyle(rheo/vshift,ComputeRHEOVShift) +// clang-format on +#else + +#ifndef LMP_COMPUTE_RHEO_VSHIFT_H +#define LMP_COMPUTE_RHEO_VSHIFT_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeRHEOVShift : public Compute { + public: + ComputeRHEOVShift(class LAMMPS *, int, char **); + ~ComputeRHEOVShift() override; + void init() override; + void init_list(int, class NeighList *) override; + void compute_peratom() override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; + double memory_usage() override; + void correct_surfaces(); + + private: + int nmax; + double dtv, cut, cutsq, cutthird; + int surface_flag; + + double **vshift; + + class NeighList *list; + class FixRHEO *fix_rheo; + class FixRHEOSurface *fix_rheo_surface; + class ComputeRHEOInterface *compute_interface ; + class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOGrad *compute_grad; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index e2819ad320..12185b549c 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -132,7 +132,7 @@ FixRHEO::~FixRHEO() void FixRHEO::post_constructor() { - compute_kernel = dynamic_cast(modify->add_compute(fmt::format("rheo_kernel all rheo/kernel {} {} {}", kernel_style, zmin_kernel, h))); + compute_kernel = dynamic_cast(modify->add_compute("rheo_kernel all rheo/kernel")); fix_store_visc = dynamic_cast(modify->add_fix("rheo_store_visc all STORE/PERATOM 0 1")) fix_store_visc->disable = 1; @@ -142,16 +142,18 @@ void FixRHEO::post_constructor() fix_store_pres->disable = 1; - std::string cmd = "rheo_grad all rheo/grad {} velocity rho viscosity"; + std::string cmd = "rheo_grad all rheo/grad velocity rho viscosity"; if (thermal_flag) cmd += "temperature"; - compute_grad = dynamic_cast(modify->add_compute(fmt::format(cmd, h))); + compute_grad = dynamic_cast(modify->add_compute(cmd)); compute_grad->fix_rheo = this; if (rhosum_flag) - compute_rhosum = dynamic_cast(modify->add_compute(fmt::format("rheo_rhosum all rheo/rho/sum {} {}", h, zmin_rhosum))); + compute_rhosum = dynamic_cast(modify->add_compute("rheo_rhosum all rheo/rho/sum")); - if (shift_flag) - compute_vshift = dynamic_cast(modify->add_compute(fmt::format("rheo_vshift all rheo/vshift {}", h))); + if (shift_flag) { + compute_vshift = dynamic_cast(modify->add_compute("rheo_vshift all rheo/vshift")); + compute_vshift->fix_rheo = this; + } if (surface_flag) { fix_store_surf = dynamic_cast(modify->add_fix("rheo_store_surf all STORE/PERATOM 0 1")) @@ -166,7 +168,7 @@ void FixRHEO::post_constructor() } if (interface_flag) { - compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface {}", h))); + compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface"))); fix_store_fp = dynamic_cast(modify->add_fix("rheo_store_fp all STORE/PERATOM 0 3")) f_pressure = fix_store_fp->astore; @@ -212,7 +214,7 @@ void FixRHEO::setup_pre_force(int /*vflag*/) void FixRHEO::setup() { - // Confirm all accessory fixes are defined, may not cover group all + // Confirm all accessory fixes are defined // Note: these fixes set this flag in setup_pre_force() if (!viscosity_fix_defined) error->all(FLERR, "Missing fix rheo/viscosity"); @@ -231,6 +233,33 @@ void FixRHEO::setup() viscosity_fix_defined = 0; pressure_fix_defined = 0; surface_fix_defined = 0; + + // Check fixes cover all atoms (doesnt ensure user covers atoms created midrun) + // (pressure is currently required to be group all) + auto visc_fixes = modify->get_fix_by_style("rheo/viscosity"); + auto therm_fixes = modify->get_fix_by_style("rheo/thermal"); + + int *mask = atom->mask; + int v_coverage_flag = 1; + int t_coverage_flag = 1; + int covered; + for (int i = 0; i < atom->nlocal; i++) { + covered = 0; + for (auto fix in visc_fixes) + if (mask[i] & fix->groupbit) covered = 1; + if (!covered) v_coverage_flag = 0; + if (thermal_flag) { + covered = 0; + for (auto fix in therm_fixes) + if (mask[i] & fix->groupbit) covered = 1; + if (!covered) v_coverage_flag = 0; + } + } + + if (!v_coverage_flag) + error->one(FLERR, "Fix rheo/viscosity does not fully cover all atoms"); + if (!t_coverage_flag) + error->one(FLERR, "Fix rheo/thermal does not fully cover all atoms"); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp new file mode 100644 index 0000000000..8f42e22239 --- /dev/null +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -0,0 +1,206 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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 "fix_rheo_pressure.h" + +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "memory.h" +#include "modify.h" +#include "update.h" + +#include + +using namespace LAMMPS_NS; +using namespace FixConst; +enum {NONE, LINEAR, CUBIC, TAITWATER}; + +/* ---------------------------------------------------------------------- */ + +FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg) +{ + if (narg < 4) error->all(FLERR,"Illegal fix command"); + + pressure_style = NONE; + + comm_forward = 1; + nmax = atom->nmax; + + // Currently can only have one instance of fix rheo/pressure + if (igroup != 0) + error->all(FLERR,"fix rheo/pressure command requires group all"); + + int ntypes = atom->ntypes; + int iarg = 3; + if (strcmp(arg[iarg],"linear") == 0) { + pressure_style = LINEAR; + } else if (strcmp(arg[iarg],"taitwater") == 0) { + pressure_style = TAITWATER; + } else if (strcmp(arg[iarg],"cubic") == 0) { + pressure_style = CUBIC; + if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for pressure option"); + c_cubic = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + } else { + error->all(FLERR,"Illegal fix command, {}", arg[iarg]); + } + + if (pressure_style == NONE) + error->all(FLERR,"Must specify pressure style for fix/rheo/pressure"); +} + +/* ---------------------------------------------------------------------- */ + +FixRHEOPressure::~FixRHEOPressure() {} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOPressure::setmask() +{ + int mask = 0; + mask |= PRE_FORCE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOPressure::init() +{ + auto fixes = modify->get_fix_by_style("rheo"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/pressure"); + fix_rheo = dynamic_cast(fixes[0]); + + csq = fix_rheo->csq; + rho0 = fix_rheo->rho0; + rho0inv = 1.0 / rho0; + + // Cannot define multiple as pair rheo cannot currently distinguish + if (modify->get_fix_by_style("rheo/pressure").size() > 1) + error->all(FLERR,"Can only specify one instance of fix rheo/pressure"); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOPressure::setup_pre_force(int /*vflag*/) +{ + fix_rheo->pressure_fix_defined = 1; + + // Identify whether this is the first/last instance of fix pressure + // First will handle growing arrays + // Last will handle communication + first_flag = 0 + last_flag = 0; + + int i = 0; + auto fixlist = modify->get_fix_by_style("rheo/pressure"); + for (const auto &ifix : fixlist) { + if (strcmp(ifix->id, id) == 0) break; + i++; + } + + if (i == 0) first_flag = 1; + if ((i + 1) == fixlist.size()) last_flag = 1; + + pre_force(0); +} + +/* ---------------------------------------------------------------------- + Update (and forward) pressure every timestep +------------------------------------------------------------------------- */ + +void FixRHEOPressure::pre_force(int /*vflag*/) +{ + int i; + double dr, rr3, rho_ratio; + + double *p = fix_rheo->pressure; + int *mask = atom->mask; + double *rho = atom->rho; + + int nlocal = atom->nlocal; + int dim = domain->dimension; + + if (first_flag & nmax < atom->nmax) { + nmax = atom->nmax; + fix_rheo->fix_store_visc->grow_arrays(nmax); + } + + if (pressure_style == TAITWATER) inv7 = 1.0 / 7.0; + + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + if (pressure_style == LINEAR) { + p[i] = csq * (rho[i] - rho0); + } else if (pressure_style == CUBIC) { + dr = rho[i] - rho0; + p[i] = csq * (dr + c_cubic * dr * dr * dr); + } else if (pressure_style == TAITWATER) { + rho_ratio = rho[i] / rho0inv; + rr3 = rho_ratio * rho_ratio * rho_ratio; + p[i] = csq * rho0 * inv7 * (rr3 * rr3 * rho_ratio - 1.0); + } + } + } + + + if (last_flag && comm_forward) comm->forward_comm(this); +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i,j,k,m; + double *pressure = fix_rheo->pressure; + m = 0; + + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = pressure[j]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double *pressure = fix_rheo->pressure; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + pressure[i] = buf[m++]; + } +} + +double FixRHEOPressure::calculate_p(double rho) +{ + double rho; + if (pressure_style == LINEAR) { + p = csq * (rho - rho0); + } else if (pressure_style == CUBIC) { + dr = rho - rho0; + p = csq * (dr + c_cubic * dr * dr * dr); + } else if (pressure_style == TAITWATER) { + rho_ratio = rho / rho0inv; + rr3 = rho_ratio * rho_ratio * rho_ratio; + p = csq * rho0 * inv7 * (rr3 * rr3 * rho_ratio - 1.0); + } + return rho; +} \ No newline at end of file diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h new file mode 100644 index 0000000000..45217c7f75 --- /dev/null +++ b/src/RHEO/fix_rheo_pressure.h @@ -0,0 +1,49 @@ +/* -*- 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(rheo/pressure,FixRHEOPressure) +// clang-format on +#else + +#ifndef LMP_FIX_RHEO_PRESSURE_H +#define LMP_FIX_RHEO_PRESSURE_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixRHEOPressure : public Fix { + public: + FixRHEOPressure(class LAMMPS *, int, char **); + ~FixRHEOPressure() override; + int setmask() override; + void init() override; + void setup_pre_force(int) override; + void pre_force(int) override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; + double calculate_p(double); + private: + double c_cubic, csq, rho0, rho0inv; + int pressure_style; + int first_flag, last_flag; + int nmax; + class FixRHEO *fix_rheo; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 406439f93e..8f4094527e 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -230,7 +230,7 @@ void FixRHEOThermal::post_integrate() if (status[i] == FixRHEO::FLUID_NO_FORCE) continue; cvi = calc_cv(i); - temperature[i] += dtf*heat[i]/cvi; + temperature[i] += dtf * heat[i] / cvi; if (Tc_style != NONE) { Ti = temperature[i]; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index f57410783c..0774eff731 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -44,13 +44,13 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : int ntypes = atom->ntypes; int iarg = 3; if (strcmp(arg[iarg],"constant") == 0) { - if (iarg+1 >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); + if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); viscosity_style = CONSTANT; eta = utils::numeric(FLERR,arg[iarg + 1],false,lmp); if (eta < 0.0) error->all(FLERR,"The viscosity must be positive"); iarg += 1; } else if (strcmp(arg[iarg],"type") == 0) { - if(iarg+ntypes >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); + if (iarg + ntypes >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); viscosity_style = TYPE; memory->create(eta_type, ntypes + 1, "rheo_thermal:eta_type"); for (int i = 1; i <= ntypes; i++) { @@ -59,7 +59,7 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : } iarg += ntypes; } else if (strcmp(arg[iarg],"power") == 0) { - if (iarg+4 >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); + if (iarg + 4 >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); viscosity_style = POWER; comm_forward = 1; eta = utils::numeric(FLERR,arg[iarg + 1],false,lmp); diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 1bed3f1d3e..edb3bb313e 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -21,6 +21,7 @@ #include "domain.h" #include "error.h" #include "fix_rheo.h" +#include "fix_rheo_pressure.h" #include "force.h" #include "math_extra.h" #include "memory.h" @@ -41,7 +42,7 @@ using namespace MathExtra; PairRHEO::PairRHEO(LAMMPS *lmp) : Pair(lmp), compute_kernel(nullptr), compute_grad(nullptr), - compute_interface(nullptr), fix_rheo(nullptr) + compute_interface(nullptr), fix_rheo(nullptr), fix_rheo_pressure(nullptr) { restartinfo = 0; single_enable = 0; @@ -69,33 +70,15 @@ void PairRHEO::compute(int eflag, int vflag) int error_flag, pair_force_flag, pair_rho_flag, pair_avisc_flag; double xtmp, ytmp, ztmp; int fluidi, fluidj; - - int *ilist, *jlist, *numneigh, **firstneigh; - double imass, jmass, rsq, r, rinv; - + double imass, jmass, rsq, r, rinv, psi_ij, Fij; double w, wp, rhoi, rhoj, voli, volj, Pi, Pj; - double *dWij, *dWji, *d2Wij, *d2Wji, *dW1ij, *dW1ji; - double vijeij, etai, etaj, kappai, kappaj; - double Ti, Tj, dT; - double drho_damp, fmag; - double mu, q, fp_prefactor; - double dx[3] = {0}; - double fv[3] = {0}; - double dfp[3] = {0}; - double fsolid[3] = {0}; - double du[3] = {0}; - double vi[3] = {0}; - double vj[3] = {0}; - double dv[3] = {0}; - double psi_ij = 0.0; - double Fij = 0.0; + double *dWij, *dWji, *d2Wij, *d2Wji; + double Ti, Tj, dT, etai, etaj, kappai, kappaj; + double drho_damp, fmag, mu, q, fp_prefactor; + double dx[3], fv[3], dfp[3], fsolid[3], du[3], vi[3], vj[3]; ev_init(eflag, vflag); - double **gradv = compute_grad->gradv; - double **gradt = compute_grad->gradt; - double **gradr = compute_grad->gradr; - double **gradn = compute_grad->gradn; double **v = atom->v; double **x = atom->x; double **f = atom->f; @@ -104,16 +87,20 @@ void PairRHEO::compute(int eflag, int vflag) double *drho = atom->drho; double *temperature = atom->temperature; double *heatflow = atom->heatflow; + double **gradv = compute_grad->gradv; + double **gradt = compute_grad->gradt; + double **gradr = compute_grad->gradr; + double **gradn = compute_grad->gradn; double *chi = compute_interface->chi; double **f_pressure = fix_rheo->f_pressure; double *viscosity = fix_rheo->viscosity; double *conductivity = fix_rheo->conductivity; double *pressure = fix_rheo->pressure; - double *special_lj = force->special_lj; tagint *tag = atom->tag; int *type = atom->type; int *status = atom->status; + int *ilist, *jlist, *numneigh, **firstneigh; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; int dim = domain->dimension; @@ -142,7 +129,6 @@ void PairRHEO::compute(int eflag, int vflag) for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; - factor_lj = special_lj[sbmask(j)]; j &= NEIGHMASK; dx[0] = xtmp - x[j][0]; @@ -152,7 +138,7 @@ void PairRHEO::compute(int eflag, int vflag) jtype = type[j]; jmass = mass[jtype]; - if (rsq < cutsq[itype][jtype]) { + if (rsq < hsq) { r = sqrt(rsq); rinv = 1 / r; @@ -181,7 +167,6 @@ void PairRHEO::compute(int eflag, int vflag) vj[a] = v[j][a]; } - // TODO: search for fix pressure and add calculate P function // Add corrections for walls rhoi = rho[i]; rhoj = rho[j]; @@ -191,14 +176,14 @@ void PairRHEO::compute(int eflag, int vflag) if (fluidi && (!fluidj)) { compute_interface->correct_v(v[i], v[j], vi, i, j); rhoj = compute_interface->correct_rho(j, i); - Pj = fix_pressure->calculate_P(rhoj); + Pj = fix_rheo_pressure->calculate_p(rhoj); if ((chi[j] > 0.9) && (r < (h * 0.5))) fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; } else if ((!fluidi) && fluidj) { compute_interface->correct_v(v[j], v[i], vj, j, i); rhoi = compute_interface->correct_rho(i,j); - Pi = fix_pressure->calculate_P(rhoi); + Pi = fix_rheo_pressure->calculate_p(rhoi); if ((chi[i] > 0.9) && (r < (h * 0.5))) fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; @@ -429,9 +414,13 @@ void PairRHEO::coeff(int narg, char **arg) void PairRHEO::setup() { auto fixes = modify->get_fix_by_style("rheo"); - if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use pair rheo"); fix_rheo = dynamic_cast(fixes[0]); + fixes = modify->get_fix_by_style("rheo/pressure"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo/pressure to use pair rheo"); + fix_rheo_pressure = dynamic_cast(fixes[0]); + compute_kernel = fix_rheo->compute_kernel; compute_grad = fix_rheo->compute_grad; compute_interface = fix_rheo->compute_interface; diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index 42172be3a4..ab7d796a74 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -50,6 +50,7 @@ class PairRHEO : public Pair { class ComputeRHEOGrad *compute_grad; class ComputeRHEOInterface *compute_interface; class FixRHEO *fix_rheo; + class FixRHEOPressure *fix_rheo_pressure; }; } // namespace LAMMPS_NS From bad1188c526672b2055caf6be5e01da1875c89b6 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 22 Mar 2023 17:27:51 -0600 Subject: [PATCH 011/104] Reorganizing peratom arrays --- src/RHEO/compute_rheo_grad.cpp | 160 ++++++++++++++++---------------- src/RHEO/compute_rheo_grad.h | 4 +- src/RHEO/fix_rheo.cpp | 2 +- src/RHEO/fix_rheo_thermal.cpp | 49 ++++++---- src/RHEO/fix_rheo_thermal.h | 2 +- src/RHEO/fix_rheo_viscosity.cpp | 44 ++++++--- src/RHEO/fix_rheo_viscosity.h | 6 +- src/RHEO/pair_rheo.cpp | 13 ++- 8 files changed, 162 insertions(+), 118 deletions(-) diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index e87d39aa53..f963485157 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -23,11 +23,9 @@ #include "force.h" #include "neighbor.h" #include "neigh_list.h" -#include "modify.h" #include "update.h" #include -#include using namespace LAMMPS_NS; enum{COMMGRAD, COMMFIELD}; @@ -35,11 +33,11 @@ enum{COMMGRAD, COMMFIELD}; /* ---------------------------------------------------------------------- */ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), compute_interface(nullptr), compute_kernel(nullptr) + Compute(lmp, narg, arg), compute_interface(nullptr), compute_kernel(nullptr), + gradv(nullptr), gradr(nullptr), gradt(nullptr), gradn(nullptr) { if (narg < 4) error->all(FLERR,"Illegal compute rheo/grad command"); - velocity_flag = temperature_flag = rho_flag = eta_flag = 0; for (int iarg = 3; iarg < narg; iarg ++) { if (strcmp(arg[iarg],"velocity") == 0) velocity_flag = 1; @@ -53,70 +51,62 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : ncomm_field = 0; comm_reverse = 0; - std::string fix_cmd = "rheo_grad_property_atom all property/atom" - int dim = domain->dimension; if (velocity_flag) { ncomm_grad += dim * dim; ncomm_field += dim; comm_reverse += dim * dim; - fix_cmd += " d2_gradv 9" + indexv = atom->add_custom("rheo_grad_v", 1, dim * dim); + gradv = atom->darray[indexv]; } if (rho_flag) { ncomm_grad += dim; ncomm_field += 1; comm_reverse += dim; - fix_cmd += " d2_gradr 3" + indexr = atom->add_custom("rheo_grad_rho", 1, dim); + gradr = atom->darray[indexr]; } if (temperature_flag) { ncomm_grad += dim; ncomm_field += 1; comm_reverse += dim; - fix_cmd += " d2_gradt 3" + indext= atom->add_custom("rheo_grad_temp", 1, dim); + gradt = atom->darray[indext]; } if (eta_flag) { ncomm_grad += dim; comm_reverse += dim; - fix_cmd += " d2_gradn 3" + indexn = atom->add_custom("rheo_grad_eta", 1, dim); + gradn = atom->darray[indexn]; } + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded + comm_forward = ncomm_grad; - - modify->add_fix(fix_cmd); - - int tmp1, tmp2, index; - if (velocity_flag) { - index = atom->find_custom("gradv", tmp1, tmp2); - gradv = atom->darray[index]; - } - - if (rho_flag) { - index = atom->find_custom("gradr", tmp1, tmp2); - gradr = atom->darray[index]; - } - - if (temperature_flag) { - index = atom->find_custom("gradt", tmp1, tmp2); - gradt = atom->darray[index]; - } - - if (eta_flag) { - index = atom->find_custom("gradn", tmp1, tmp2); - gradn = atom->darray[index]; - } + nmax_old = 0; + grow_arrays(atom->nmax); } /* ---------------------------------------------------------------------- */ ComputeRHEOGrad::~ComputeRHEOGrad() { - modify->delete_fix("rheo_grad_property_atom"); + int dim = domain->dimension; + if (velocity_flag) + atom->remove_custom(indexv, 1, dim * dim); + if (rho_flag) + atom->remove_custom(indexr, 1, dim); + if (temperature_flag) + atom->remove_custom(indext, 1, dim); + if (eta_flag) + atom->remove_custom(indexn, 1, dim); } - /* ---------------------------------------------------------------------- */ void ComputeRHEOGrad::init() @@ -169,6 +159,8 @@ void ComputeRHEOGrad::compute_peratom() firstneigh = list->firstneigh; // initialize arrays + if (nmax > nmax_old) grow_arrays(nmax); + for (i = 0; i < nmax; i++) { if (velocity_flag) { for (k = 0; k < dim * dim; k++) @@ -315,39 +307,33 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, j = list[i]; if (comm_stage == COMMGRAD) { - if (velocity_flag){ + if (velocity_flag) for (k = 0; k < dim * dim; k++) buf[m++] = gradv[j][k]; - } - if (rho_flag) { + if (rho_flag) for (k = 0; k < dim; k++) buf[m++] = gradr[j][k]; - } - if (temperature_flag) { + if (temperature_flag) for (k = 0; k < dim; k++) buf[m++] = gradt[j][k]; - } - if (eta_flag){ + if (eta_flag) for (k = 0; k < dim; k++) buf[m++] = gradn[j][k]; - } + } else if (comm_stage == COMMFIELD) { - if (velocity_flag) { + if (velocity_flag) for (k = 0; k < dim; k++) buf[m++] = v[j][k]; - } - if (rho_flag) { + if (rho_flag) buf[m++] = rho[j]; - } - if (temperature_flag) { + if (temperature_flag) buf[m++] = temperature[j]; - } } } return m; @@ -367,33 +353,32 @@ void ComputeRHEOGrad::unpack_forward_comm(int n, int first, double *buf) last = first + n; for (i = first; i < last; i++) { if (comm_stage == COMMGRAD) { - if (velocity_flag) { + if (velocity_flag) for (k = 0; k < dim * dim; k++) gradv[i][k] = buf[m++]; - } - if (rho_flag) { + + if (rho_flag) for (k = 0; k < dim; k++) gradr[i][k] = buf[m++]; - } - if (temperature_flag) { + + if (temperature_flag) for (k = 0; k < dim; k++) gradt[i][k] = buf[m++]; - } - if (eta_flag) { + + if (eta_flag) for (k = 0; k < dim; k++) gradn[i][k] = buf[m++]; - } + } else if (comm_stage == COMMFIELD) { - if (velocity_flag) { + if (velocity_flag) for (k = 0; k < dim; k++) v[i][k] = buf[m++]; - } - if (rho_flag) { + + if (rho_flag) rho[i] = buf[m++]; - } - if (temperature_flag) { + + if (temperature_flag) temperature[i] = buf[m++]; - } } } } @@ -408,22 +393,21 @@ int ComputeRHEOGrad::pack_reverse_comm(int n, int first, double *buf) m = 0; last = first + n; for (i = first; i < last; i++) { - if (velocity_flag) { + if (velocity_flag) for (k = 0; k < dim * dim; k++) buf[m++] = gradv[i][k]; - } - if (rho_flag) { + + if (rho_flag) for (k = 0; k < dim; k++) buf[m++] = gradr[i][k]; - } - if (temperature_flag) { + + if (temperature_flag) for (k = 0; k < dim; k++) buf[m++] = gradt[i][k]; - } - if (eta_flag) { + + if (eta_flag) for (k = 0; k < dim; k++) buf[m++] = gradn[i][k]; - } } return m; } @@ -438,21 +422,39 @@ void ComputeRHEOGrad::unpack_reverse_comm(int n, int *list, double *buf) m = 0; for (i = 0; i < n; i++) { j = list[i]; - if (velocity_flag) { + if (velocity_flag) for (k = 0; k < dim * dim; k++) gradv[j][k] += buf[m++]; - } - if (rho_flag) { + + if (rho_flag) for (k = 0; k < dim; k++) gradr[j][k] += buf[m++]; - } - if (temperature_flag) { + + if (temperature_flag) for (k = 0; k < dim; k++) gradt[j][k] += buf[m++]; - } - if (eta_flag) { + + if (eta_flag) for (k = 0; k < dim; k++) gradn[j][k] += buf[m++]; - } } } + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOGrad::grow_arrays(int nmax) +{ + int dim = domain->dimension; + if (velocity_flag) + memory->grow(gradv, nmax, dim * dim, "atom:rheo_grad_v"); + + if (rho_flag) + memory->grow(gradr, nmax, dim, "atom:rheo_grad_rho"); + + if (temperature_flag) + memory->grow(gradt, nmax, dim, "atom:rheo_grad_temp"); + + if (eta_flag) + memory->grow(gradn, nmax, dim, "atom:rheo_grad_eta"); + nmax_old = nmax; +} \ No newline at end of file diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index 52c5d7c924..220b5813e3 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -44,8 +44,8 @@ class ComputeRHEOGrad : public Compute { int stage; private: - int comm_stage; - int ncomm_grad, ncomm_field; + int comm_stage, ncomm_grad, ncomm_field, nmax_old; + int indexv, indexr, indext, indexn; double cut, cutsq, rho0; class NeighList *list; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index e2819ad320..d142af6483 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -313,7 +313,7 @@ void FixRHEO::initial_integrate(int /*vflag*/) // Shifting atoms if (shift_flag) { - compute_vshift->correct_surfaces(); + compute_vshift->correct_surfaces(); // COuld this be moved to preforce after the surface fix runs? for (i = 0; i < nlocal; i++) { if (!(status[i] & STATUS_SHIFT)) continue; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 406439f93e..f000bf65cc 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -32,7 +32,8 @@ enum {NONE, CONSTANT, TYPE}; /* ---------------------------------------------------------------------- */ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr) + Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr), + conductivity(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -40,8 +41,8 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : cv_style = NONE; conductivity_style = NONE; - comm_forward = 0; - nmax = atom->nmax; + comm_forward = 1; + nmax_old = 0; int ntypes = atom->ntypes; int iarg = 3; @@ -123,6 +124,11 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : FixRHEOThermal::~FixRHEOThermal() { + // Remove custom property if it exists + int tmp1, tmp2, index; + index = atom->find_custom("rheo_conductivity", tmp1, tmp2); + if (index != -1) atom->remove_custom(index_cond, 1, 0); + memory->destroy(cv_type); memory->destroy(Tc_type); memory->destroy(kappa_type); @@ -164,8 +170,7 @@ void FixRHEOThermal::setup_pre_force(int /*vflag*/) fix_rheo->thermal_fix_defined = 1; // Identify whether this is the first/last instance of fix thermal - // First will handle growing arrays - // Last will handle communication + // First will grow arrays, last will communicate first_flag = 0 last_flag = 0; @@ -179,6 +184,18 @@ void FixRHEOThermal::setup_pre_force(int /*vflag*/) if (i == 0) first_flag = 1; if ((i + 1) == fixlist.size()) last_flag = 1; + // Create conductivity array if it doesn't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded + + int tmp1, tmp2; + index_cond = atom->find_custom("rheo_conductivity", tmp1, tmp2); + if (index_cond == -1) { + index_cond = atom->add_custom("rheo_conductivity", 1, 0); + nmax_old = atom->nmax; + } + post_neighbor(); pre_force(0); } @@ -230,7 +247,7 @@ void FixRHEOThermal::post_integrate() if (status[i] == FixRHEO::FLUID_NO_FORCE) continue; cvi = calc_cv(i); - temperature[i] += dtf*heat[i]/cvi; + temperature[i] += dtf * heat[i] / cvi; if (Tc_style != NONE) { Ti = temperature[i]; @@ -260,15 +277,14 @@ void FixRHEOThermal::post_neighbor() { int i; int *type = atom->type; - double *conductivity = fix_rheo->conductivity; + double *conductivity = atom->dvector[index_cond]; int *mask = atom->mask; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - if (first_flag & nmax < atom->nmax) { - nmax = atom->nmax; - fix_rheo->fix_store_cond->grow_arrays(nmax); - } + if (first_flag && (nmax_old < atom->nmax)) + memory->grow(conductivity, atom->nmax, "atom:rheo_conductivity"); + nmax_old = atom->nmax; if (conductivity_style == CONSTANT) { for (i = 0; i < nall; i++) @@ -286,16 +302,15 @@ void FixRHEOThermal::post_neighbor() void FixRHEOThermal::pre_force(int /*vflag*/) { - // So far, none exist + // Not needed yet, when needed add (un)pack_forward_comm() methods //int i; - //double *conductivity = fix_rheo->conductivity; + //double *conductivity = atom->dvector[index_cond]; //int *mask = atom->mask; //int nlocal = atom->nlocal; - //if (first_flag & nmax < atom->nmax) { - // nmax = atom->nmax; - // fix_rheo->fix_store_cond->grow_arrays(nmax); - //} + //if (first_flag && (nmax_old < atom->nmax)) + // memory->grow(conductivity, atom->nmax, "atom:rheo_conductivity"); + //nmax_old = atom->nmax; //if (conductivity_style == TBD) { // for (i = 0; i < nlocal; i++) { diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index c0b5255caa..e4ed426fb4 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -49,7 +49,7 @@ class FixRHEOThermal : public Fix { int cv_style; int conductivity_style; int first_flag, last_flag; - int nmax; + int nmax_old, index_cond; class FixRHEO *fix_rheo; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index f57410783c..3dfbfc1058 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -39,7 +39,7 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : viscosity_style = NONE; comm_forward = 0; - nmax = atom->nmax; + nmax_old = 0; int ntypes = atom->ntypes; int iarg = 3; @@ -81,6 +81,11 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : FixRHEOViscosity::~FixRHEOViscosity() { + // Remove custom property if it exists + int tmp1, tmp2, index; + index = atom->find_custom("rheo_viscosity", tmp1, tmp2); + if (index != -1) atom->remove_custom(index_visc, 1, 0); + memory->destroy(eta_type); } @@ -112,8 +117,7 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) fix_rheo->viscosity_fix_defined = 1; // Identify whether this is the first/last instance of fix viscosity - // First will handle growing arrays - // Last will handle communication + // First will grow arrays, last will communicate first_flag = 0 last_flag = 0; @@ -127,6 +131,18 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) if (i == 0) first_flag = 1; if ((i + 1) == fixlist.size()) last_flag = 1; + // Create viscosity array if it doesn't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded + + int tmp1, tmp2; + index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); + if (index_cond == -1) { + index_visc = atom->add_custom("rheo_viscosity", 1, 0); + nmax_old = atom->nmax; + } + post_neighbor(); pre_force(0); } @@ -140,16 +156,15 @@ void FixRHEOViscosity::post_neighbor() int i; int *type = atom->type; - double *viscosity = fix_rheo->viscosity; + double *viscosity = atom->dvector[index_visc]; int *mask = atom->mask; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - if (first_flag & nmax < atom->nmax) { - nmax = atom->nmax; - fix_rheo->fix_store_visc->grow_arrays(nmax); - } + if (first_flag && (nmax_old < atom->nmax)) + memory->grow(viscosity, atom->nmax, "atom:rheo_viscosity"); + nmax_old = atom->nmax; if (viscosity_style == CONSTANT) { for (i = 0; i < nall; i++) @@ -170,17 +185,16 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) int i, a, b; double tmp, gdot; - double *viscosity = fix_rheo->viscosity; + double *viscosity = atom->dvector[index_visc]; int *mask = atom->mask; double **gradv = compute_grad->gradv; int nlocal = atom->nlocal; int dim = domain->dimension; - if (first_flag & nmax < atom->nmax) { - nmax = atom->nmax; - fix_rheo->fix_store_visc->grow_arrays(nmax); - } + if (first_flag && (nmax_old < atom->nmax)) + memory->grow(viscosity, atom->nmax, "atom:rheo_viscosity"); + nmax_old = atom->nmax; if (viscosity_style == POWER) { for (i = 0; i < nlocal; i++) { @@ -213,7 +227,7 @@ int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,k,m; - double *viscosity = fix_rheo->viscosity; + double *viscosity = atom->dvector[index_visc]; m = 0; for (i = 0; i < n; i++) { @@ -228,7 +242,7 @@ int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf, void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; - double *viscosity = fix_rheo->viscosity; + double *viscosity = atom->dvector[index_visc]; m = 0; last = first + n; diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h index 31c1441e40..d531507a72 100644 --- a/src/RHEO/fix_rheo_viscosity.h +++ b/src/RHEO/fix_rheo_viscosity.h @@ -35,12 +35,14 @@ class FixRHEOViscosity : public Fix { void pre_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; + private: double *eta_type, eta; - double npow, K, gd0, tau0; + double npow, K, gd0, tau0; int viscosity_style; int first_flag, last_flag; - int nmax; + int nmax_old, index_visc; + class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; }; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index c796db208a..fd4e525b34 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -92,7 +92,6 @@ void PairRHEO::compute(int eflag, int vflag) double **gradv = compute_grad->gradv; double **gradt = compute_grad->gradt; double **gradr = compute_grad->gradr; - double **gradn = compute_grad->gradn; double **v = atom->v; double **x = atom->x; double **f = atom->f; @@ -109,6 +108,18 @@ void PairRHEO::compute(int eflag, int vflag) int *type = atom->type; int *phase = atom->phase; + int tmp1, tmp2; + int index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); + if (index_visc == -1) error->all(FLERR, "Cannot find rheo viscosity"); + double *viscosity = atom->dvector[index_visc]; + + double *conductivity; + if (thermal_flag) { + int index_cond = atom->find_custom("rheo_conductivity", tmp1, tmp2); + if (index_cond == -1) error->all(FLERR, "Cannot find rheo conductivity"); + conductivity = atom->dvector[index_cond]; + } + int nlocal = atom->nlocal; int newton_pair = force->newton_pair; int dim = domain->dimension; From 886c642e0155e97bf51d81475978ddcf74526a87 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 22 Mar 2023 21:15:54 -0600 Subject: [PATCH 012/104] Cleaning up pairstyle --- src/RHEO/pair_rheo.cpp | 291 +++++++++++++++++------------------------ src/RHEO/pair_rheo.h | 2 +- 2 files changed, 119 insertions(+), 174 deletions(-) diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index fd4e525b34..06913e45e6 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -22,6 +22,7 @@ #include "error.h" #include "fix_rheo.h" #include "force.h" +#include "math_extra.h" #include "memory.h" #include "modify.h" #include "neighbor.h" @@ -32,6 +33,7 @@ #include using namespace LAMMPS_NS; +using namespace MathExtra; #define EPSILON 1e-2 @@ -64,28 +66,15 @@ PairRHEO::~PairRHEO() void PairRHEO::compute(int eflag, int vflag) { int i, j, a, b, ii, jj, inum, jnum, itype, jtype; - int error_flag, pair_force_flag, pair_rho_flag, pair_avisc_flag; - double xtmp, ytmp, ztmp; + int pair_force_flag, pair_rho_flag, pair_avisc_flag; + double xtmp, ytmp, ztmp, w, wp, Ti, Tj, dT; + double rhoi, rhoj, voli, volj, Pi, Pj, etai, etaj, kappai, kappaj; + double mu, q, fp_prefactor, drho_damp, fmag, psi_ij, Fij; + double *dWij, *dWji, *dW1ij, *dW1ji; + double dx[3], du[3], fv[3], dfp[3], fsolid[3], ft[3], vi[3], vj[3]; int *ilist, *jlist, *numneigh, **firstneigh; - double imass, jmass, rsq, r, ir; - - double w, wp, rhoi, rhoj, voli, volj, Pi, Pj; - double *dWij, *dWji, *d2Wij, *d2Wji, *dW1ij, *dW1ji; - double vijeij, etai, etaj, kappai, kappaj; - double Ti, Tj, dT; - double drho_damp, fmag; - double mu, q, cs, fp_prefactor; - double dx[3] = {0}; - double fv[3] = {0}; - double dfp[3] = {0}; - double fsolid[3] = {0}; - double du[3] = {0}; - double vi[3] = {0}; - double vj[3] = {0}; - double dv[3] = {0}; - double psi_ij = 0.0; - double Fij = 0.0; + double imass, jmass, rsq, r, rinv; ev_init(eflag, vflag); @@ -95,18 +84,17 @@ void PairRHEO::compute(int eflag, int vflag) double **v = atom->v; double **x = atom->x; double **f = atom->f; - double **fp = atom->fp; + double **fp = atom->fp; // rewrite later + double *pressure = atom->pressure; // rewrite later double *rho = atom->rho; double *mass = atom->mass; double *drho = atom->drho; double *temp = atom->temp; double *heat = atom->heat; - double *viscosity = atom->viscosity; - double *conductivity = atom->conductivity; double *special_lj = force->special_lj; tagint *tag = atom->tag; int *type = atom->type; - int *phase = atom->phase; + int *status = atom->status; int tmp1, tmp2; int index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); @@ -140,10 +128,11 @@ void PairRHEO::compute(int eflag, int vflag) jlist = firstneigh[i]; jnum = numneigh[i]; imass = mass[itype]; - - kappai = conductivity[i]; etai = viscosity[i]; - Ti = temp[i]; + if (thermal_flag) { + kappai = conductivity[i]; + Ti = temp[i]; + } for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -153,25 +142,27 @@ void PairRHEO::compute(int eflag, int vflag) dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; - rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; + rsq = lensq3(dx); jtype = type[j]; - jmass = mass[jtype]; if (rsq < cutsq[itype][jtype]) { r = sqrt(rsq); - ir = 1/r; + rinv = 1 / r; - kappaj = conductivity[j]; + jmass = mass[jtype]; etaj = viscosity[j]; - Tj = temp[j]; + if (thermal_flag) { + Tj = temp[j]; + kappaj = conductivity[j]; + } pair_rho_flag = 0; pair_force_flag = 0; pair_avisc_flag = 0; - if (phase[i] <= FixRHEO::FLUID_MAX || phase[j] <= FixRHEO::FLUID_MAX) { + if (status[i] <= FixRHEO::FLUID_MAX || status[j] <= FixRHEO::FLUID_MAX) { pair_force_flag = 1; } - if (phase[i] <= FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) { + if (status[i] <= FixRHEO::FLUID_MAX && status[j] <= FixRHEO::FLUID_MAX) { pair_avisc_flag = 1; pair_rho_flag = 1; } @@ -189,31 +180,31 @@ void PairRHEO::compute(int eflag, int vflag) // Add corrections for walls rhoi = rho[i]; rhoj = rho[j]; - if (phase[i] <= FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { - compute_sinterpolation->correct_v(v[i], v[j], vi, i, j); - rhoj = compute_sinterpolation->correct_rho(j,i); + Pi = pressure[i]; + Pj = pressure[j]; + if ((status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { + compute_interface->correct_v(vi, vj, i, j); + rhoj = compute_interface->correct_rho(j, i); + Pj = calc_pressure(rhoj, jtype); // Repel if close to inner solid particle - if (compute_sinterpolation->chi[j] > 0.9 && r < (cut[itype][jtype] * 0.5)) { - fmag = (compute_sinterpolation->chi[j] - 0.9) * (cut[itype][jtype] * 0.5 - r); - fmag *= rho0[itype] * csq[itype] * cut[itype][jtype] * ir; - fsolid[0] = fmag * dx[0]; - fsolid[1] = fmag * dx[1]; - fsolid[2] = fmag * dx[2]; + if (compute_interface->chi[j] > 0.9 && r < (h * 0.5)) { + fmag = (compute_interface->chi[j] - 0.9) * (h * 0.5 - r); + fmag *= rho0 * csq * h * ir; + scale3(fmag, dx, fsolid); } - } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) { - compute_sinterpolation->correct_v(v[j], v[i], vj, j, i); - rhoi = compute_sinterpolation->correct_rho(i,j); + } else if (!(status[i] & STATUS_FLUID) && (status[j] & STATUS_FLUID)) { + compute_interface->correct_v(vj, vi, j, i); + rhoi = compute_interface->correct_rho(i, j); + Pi = calc_pressure(rhoi, itype); // Repel if close to inner solid particle - if (compute_sinterpolation->chi[i] > 0.9 && r < (cut[itype][jtype] * 0.5)) { - fmag = (compute_sinterpolation->chi[i] - 0.9) * (cut[itype][jtype] * 0.5 - r); - fmag *= rho0[jtype] * csq[jtype] * cut[itype][jtype] * ir; - fsolid[0] = fmag * dx[0]; - fsolid[1] = fmag * dx[1]; - fsolid[2] = fmag * dx[2]; + if (compute_interface->chi[i] > 0.9 && r < (h * 0.5)) { + fmag = (compute_interface->chi[i] - 0.9) * (h * 0.5 - r); + fmag *= rho0 * csq * h * ir; + scale3(fmag, dx, fsolid); } - } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { + } else if (!(status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { rhoi = 1.0; rhoj = 1.0; } @@ -221,26 +212,19 @@ void PairRHEO::compute(int eflag, int vflag) // Compute volume and pressure after reconstructing voli = imass / rhoi; volj = jmass / rhoj; - Pj = calc_pressure(rhoj, jtype); - Pi = calc_pressure(rhoi, itype); - - //Check if Second order kernels will be used for eta*Lap(v) - error_flag = 0; - if (laplacian_order == 2) { - error_flag = compute_kernel->calc_d2w(i, j, dx[0], dx[1], dx[2], r); - d2Wij = compute_kernel->d2Wij; - d2Wji = compute_kernel->d2Wji; - } //Thermal Evolution if (thermal_flag) { - dT = 0.0; - for (a = 0; a < dim; a++) { - dT += (kappai + kappaj) * (Ti-Tj) * dx[a] * dWij[a] * ir * ir; - //Assumes heat capacity and density = 1, needs to be generalized - } - dT *= voli * volj; + dT = dot3(dx, dWij); + dT *= (kappai + kappaj) * (Ti - Tj) * rinv * rinv * voli * volj; + //Assumes heat capacity and density = 1, needs to be generalized heat[i] += dT; + + if (newton_pair || j < nlocal) { + dT = dot3(dx, dWji); + dT *= (kappai + kappaj) * (Tj - Ti) * rinv * rinv * voli * volj; + heat[j] -= dT; + } } // If either particle is fluid, compute hydrostatic and viscous forces @@ -248,133 +232,94 @@ void PairRHEO::compute(int eflag, int vflag) if (pair_force_flag) { //Hydrostatic pressure forces fp_prefactor = voli * volj * (Pj + Pi); + sub3(v1, vj, du); //Add artificial viscous pressure if required if (artificial_visc_flag && pair_avisc_flag){ //Interpolate velocities to midpoint and use this difference for artificial viscosity - for (a = 0; a < dim; a++) { - du[a] = vi[a] - vj[a]; - for (b = 0; b < dim; b++) { + for (a = 0; a < dim; a++) + for (b = 0; b < dim; b++) du[a] -= 0.5 * (gradv[i][a * dim + b] + gradv[j][a * dim + b]) * dx[b]; - } - } - mu = (du[0] * dx[0] + du[1] * dx[1]+ du[2] * dx[2]) * hinv3; + + mu = dot3(du, dx) * hinv3; mu = mu / (rsq * hinv3 * hinv3 + EPSILON); - mu= MIN(0.0, mu); - cs = 0.5 * (sqrt(csq[itype]) + sqrt(csq[jtype])); - // "kinematic viscous pressure" q = Q/rho - q = av*(-2.0*cs*mu + 1.0*mu*mu); - fp_prefactor += voli*volj*q*(rhoj + rhoi); + mu = MIN(0.0, mu); + q = av * (-2.0 * cs * mu + mu * mu); + fp_prefactor += voli * volj * q * (rhoj + rhoi); } // -Grad[P + Q] - dfp[0] = - fp_prefactor*dWij[0]; - dfp[1] = - fp_prefactor*dWij[1]; - dfp[2] = - fp_prefactor*dWij[2]; + scale3(-fp_prefactor, dWij, dfp); // Now compute viscous eta*Lap[v] terms - for (a = 0; a < dim; a ++) { + for (a = 0; a < dim; a++) { fv[a] = 0.0; - for (b = 0; b < dim; b++) { - fv[a] += (etai+etaj)*(vi[a]-vj[a])*dx[b]*dWij[b]*ir*ir; - } - fv[a] *= voli*volj; + for (b = 0; b < dim; b++) + fv[a] += du[a] * dx[b] * dWij[b]; + fv[a] *= (etai + etaj) * voli * volj * rinv * rinv; } - } else { - for (a = 0; a < dim; a ++) { - fv[a] = 0; - dfp[a] = 0; - } - } + add3(fv, dfp, ft); + add3(fsolid, ft, ft); - if (pair_force_flag) { - f[i][0] += fv[0] + dfp[0] + fsolid[0]; - f[i][1] += fv[1] + dfp[1] + fsolid[1]; - f[i][2] += fv[2] + dfp[2] + fsolid[2]; + f[i][0] += ft[0]; + f[i][1] += ft[1]; + f[i][2] += ft[2]; fp[i][0] += dfp[0]; fp[i][1] += dfp[1]; fp[i][2] += dfp[2]; - } - // Density damping - // conventional for low-order h - // interpolated for RK 1 & 2 (Antuono et al, Computers & Fluids 2021) - if (rho_damp_flag && pair_rho_flag) { - if (laplacian_order>=1 && error_flag == 0){ - psi_ij = rhoj-rhoi; - Fij = 0.0; - for (a = 0; a < dim; a++){ - psi_ij += 0.5*(gradr[i][a]+gradr[j][a])*dx[a]; - Fij -= dx[a]*dWij[a]; + if (newton_pair || j < nlocal) { + for (a = 0; a < dim; a ++) { + fv[a] = 0.0; + for (b = 0; b < dim; b++) + fv[a] += (vi[a] - vj[a]) * dx[b] * dWji[b]; + fv[a] *= -(etai + etaj) * voli * volj * rinv * rinv; + // flip sign here b/c -= at accummulator } - Fij *= ir*ir; - drho[i] += 2*rho_damp*psi_ij*Fij*volj; - } - else { - drho_damp = 2*rho_damp*(rhoj-rhoi)*ir*wp; - drho[i] -= drho_damp*volj; - } - } - if (evflag) // Doesn't account for unbalanced forces - ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, fv[0]+dfp[0], fv[1]+dfp[1], fv[2]+dfp[2], dx[0], dx[1], dx[2]); + scale3(fp_prefact,r dWji, dfp); - // Newton neighbors - if (newton_pair || j < nlocal) { + add3(fv, dfp, ft); + add3(fsolid, ft, ft); - if (thermal_flag) { - dT = 0.0; - for(a = 0; a < dim; a++){ - //dT += kappai*dWji[a]*gradt[i][a]; - //dT -= kappaj*dWji[a]*gradt[j][a]; - dT += 1/1*(kappai+kappaj)*(Ti-Tj)*dx[a]*dWji[a]*ir*ir; //Assumes heat capacity and density = 1, needs to be generalized - } - dT *= -voli*volj; - heat[j] -= dT; - } - - for (a = 0; a < dim; a ++) { - fv[a] = 0.0; - for (b = 0; b < dim; b++) { - //fv[a] += etai*dWji[b]*(gradv[i][a*dim+b]+gradv[i][b*dim+a]); - //fv[a] -= etaj*dWji[b]*(gradv[j][a*dim+b]+gradv[j][b*dim+a]); - fv[a] += (etai+etaj)*(vi[a]-vj[a])*dx[b]*dWji[b]*ir*ir; - } - fv[a] *= -voli*volj; // flip sign here b/c -= at accummulator - } - - - - if (pair_force_flag) { - for (a = 0; a < dim; a++) - dfp[a] = fp_prefactor*dWji[a]; - } - - if (rho_damp_flag && pair_rho_flag){ - if (laplacian_order>=1 && error_flag == 0){ - Fij = 0.0; - for (a = 0; a < dim; a++){ - Fij += dx[a]*dWji[a]; - } - Fij *= ir*ir; - psi_ij *= -1; - drho[j] += 2*rho_damp*psi_ij*Fij*voli; - } - else { - drho_damp = 2*rho_damp*(rhoj-rhoi)*ir*wp; - drho[j] += drho_damp*voli; - } - } - if (pair_force_flag) { - f[j][0] -= fv[0] + dfp[0] + fsolid[0]; - f[j][1] -= fv[1] + dfp[1] + fsolid[1]; - f[j][2] -= fv[2] + dfp[2] + fsolid[2]; + f[j][0] -= ft[0]; + f[j][1] -= ft[1]; + f[j][2] -= ft[2]; fp[j][0] -= dfp[0]; fp[j][1] -= dfp[1]; fp[j][2] -= dfp[2]; } + + if (evflag) // Doesn't account for unbalanced forces + ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], dx[0], dx[1], dx[2]); + } + + // Density damping + // conventional for low-order h + // interpolated for RK 1 & 2 (Antuono et al., Computers & Fluids 2021) + if (rho_damp_flag && pair_rho_flag) { + if (laplacian_order >= 1) { + psi_ij = rhoj - rhoi; + Fij = -rinv * rinv * dot3(dx, dWij); + for (a = 0; a < dim; a++) + psi_ij += 0.5 * (gradr[i][a] + gradr[j][a]) * dx[a]; + drho[i] += 2 * rho_damp * psi_ij * Fij * volj; + } else { + drho_damp = 2 * rho_damp * (rhoj - rhoi) * rinv * wp; + drho[i] -= drho_damp * volj; + } + + if (newton_pair || j < nlocal) { + if (laplacian_order >= 1) { + Fij = rinv * rinv * dot3(dx, dWji); + psi_ij *= -1; + drho[j] += 2 * rho_damp * psi_ij * Fij * voli; + } else { + drho[j] += drho_damp * voli; + } + } } } } @@ -411,15 +356,13 @@ void PairRHEO::settings(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg], "rho/damp") == 0) { if (iarg + 1 >= narg) error->all(FLERR,"Illegal pair_style command"); - rho_damp_flag = 1; rho_damp = utils::numeric(FLERR,arg[iarg + 1],false,lmp); iarg++; } else if (strcmp(arg[iarg], "artificial/visc") == 0) { if (iarg + 1 >= narg) error->all(FLERR,"Illegal pair_style command"); - artificial_visc_flag = 1; - av = utils::numeric(FLERR,arg[iarg+1],false,lmp); + av = utils::numeric(FLERR,arg[iarg + 1],false,lmp); iarg++; } else error->all(FLERR,"Illegal pair_style command, {}", arg[iarg]); iarg++; @@ -438,8 +381,8 @@ void PairRHEO::coeff(int narg, char **arg) allocate(); int ilo, ihi, jlo, jhi; - utils::bounds(FLERR,arg[0],1, atom->ntypes, ilo, ihi,error); - utils::bounds(FLERR,arg[1],1, atom->ntypes, jlo, jhi,error); + utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi,error); + utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi,error); int count = 0; for (int i = ilo; i <= ihi; i++) { @@ -472,6 +415,8 @@ void PairRHEO::setup() rho0 = fix_rheo->rho0; hinv = 1.0 / h; + hinv3 = hinv * 3.0; + cs = sqrt(csq); laplacian_order = -1; if (comm->ghost_velocity == 0) diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index 026bc16527..18458048f6 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -37,7 +37,7 @@ class PairRHEO : public Pair { protected: double h, csq, rho0; // From fix RHEO - double hsq, hinv, av, rho_damp; + double cs, hsq, hinv, hinv3, av, rho_damp; int laplacian_order; int artificial_visc_flag; From beb6f934f8e34a4a5bd55ff057500f095009245d Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 22 Mar 2023 21:44:11 -0600 Subject: [PATCH 013/104] adding new peratom storage to pressure --- src/RHEO/fix_rheo_pressure.cpp | 52 ++++++++++++++++----------------- src/RHEO/fix_rheo_pressure.h | 3 +- src/RHEO/fix_rheo_viscosity.cpp | 2 +- src/RHEO/pair_rheo.cpp | 9 +++--- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 8f42e22239..e4c1c44163 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -38,7 +38,7 @@ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : pressure_style = NONE; comm_forward = 1; - nmax = atom->nmax; + nmax_old = 0; // Currently can only have one instance of fix rheo/pressure if (igroup != 0) @@ -64,7 +64,13 @@ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : /* ---------------------------------------------------------------------- */ -FixRHEOPressure::~FixRHEOPressure() {} +FixRHEOPressure::~FixRHEOPressure() +{ + // Remove custom property if it exists + int tmp1, tmp2, index; + index = atom->find_custom("rheo_pressure", tmp1, tmp2); + if (index != -1) atom->remove_custom(index_pres, 1, 0); +} /* ---------------------------------------------------------------------- */ @@ -98,22 +104,18 @@ void FixRHEOPressure::setup_pre_force(int /*vflag*/) { fix_rheo->pressure_fix_defined = 1; - // Identify whether this is the first/last instance of fix pressure - // First will handle growing arrays - // Last will handle communication - first_flag = 0 - last_flag = 0; + // Create pressure array if it doesn't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded - int i = 0; - auto fixlist = modify->get_fix_by_style("rheo/pressure"); - for (const auto &ifix : fixlist) { - if (strcmp(ifix->id, id) == 0) break; - i++; + int tmp1, tmp2; + index_pres = atom->find_custom("rheo_pressure", tmp1, tmp2); + if (index_pres == -1) { + index_pres = atom->add_custom("rheo_pressure", 1, 0); + nmax_old = atom->nmax; } - if (i == 0) first_flag = 1; - if ((i + 1) == fixlist.size()) last_flag = 1; - pre_force(0); } @@ -126,16 +128,15 @@ void FixRHEOPressure::pre_force(int /*vflag*/) int i; double dr, rr3, rho_ratio; - double *p = fix_rheo->pressure; + double *pressure = atom->dvector[index_pres]; int *mask = atom->mask; double *rho = atom->rho; int nlocal = atom->nlocal; - int dim = domain->dimension; - if (first_flag & nmax < atom->nmax) { - nmax = atom->nmax; - fix_rheo->fix_store_visc->grow_arrays(nmax); + if (nmax_old < atom->nmax) { + memory->grow(pressure, atom->nmax, "atom:rheo_pressure"); + nmax_old = atom->nmax; } if (pressure_style == TAITWATER) inv7 = 1.0 / 7.0; @@ -143,19 +144,18 @@ void FixRHEOPressure::pre_force(int /*vflag*/) for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (pressure_style == LINEAR) { - p[i] = csq * (rho[i] - rho0); + pressure[i] = csq * (rho[i] - rho0); } else if (pressure_style == CUBIC) { dr = rho[i] - rho0; - p[i] = csq * (dr + c_cubic * dr * dr * dr); + pressure[i] = csq * (dr + c_cubic * dr * dr * dr); } else if (pressure_style == TAITWATER) { rho_ratio = rho[i] / rho0inv; rr3 = rho_ratio * rho_ratio * rho_ratio; - p[i] = csq * rho0 * inv7 * (rr3 * rr3 * rho_ratio - 1.0); + pressure[i] = csq * rho0 * inv7 * (rr3 * rr3 * rho_ratio - 1.0); } } } - if (last_flag && comm_forward) comm->forward_comm(this); } @@ -165,7 +165,7 @@ int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,k,m; - double *pressure = fix_rheo->pressure; + double *pressure = atom->dvector[index_pres]; m = 0; for (i = 0; i < n; i++) { @@ -180,7 +180,7 @@ int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf, void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; - double *pressure = fix_rheo->pressure; + double *pressure = atom->dvector[index_pres]; m = 0; last = first + n; diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h index 45217c7f75..6c7ee73370 100644 --- a/src/RHEO/fix_rheo_pressure.h +++ b/src/RHEO/fix_rheo_pressure.h @@ -39,7 +39,8 @@ class FixRHEOPressure : public Fix { double c_cubic, csq, rho0, rho0inv; int pressure_style; int first_flag, last_flag; - int nmax; + int nmax_old, index_pressure; + class FixRHEO *fix_rheo; }; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 0fe9c7796e..2b63c7633b 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -138,7 +138,7 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) int tmp1, tmp2; index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); - if (index_cond == -1) { + if (index_visc == -1) { index_visc = atom->add_custom("rheo_viscosity", 1, 0); nmax_old = atom->nmax; } diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index d3ac28d3d5..d1a30d3b40 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -229,9 +229,8 @@ void PairRHEO::compute(int eflag, int vflag) } } - // If either particle is fluid, compute hydrostatic and viscous forces - // Compute eta*Lap(v) - different forms depending on order of RK correction if (pair_force_flag) { + //Hydrostatic pressure forces fp_prefactor = voli * volj * (Pj + Pi); sub3(v1, vj, du); @@ -271,6 +270,9 @@ void PairRHEO::compute(int eflag, int vflag) fp[i][1] += dfp[1]; fp[i][2] += dfp[2]; + if (evflag) // Does not account for unbalanced forces + ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], dx[0], dx[1], dx[2]); + if (newton_pair || j < nlocal) { for (a = 0; a < dim; a ++) { fv[a] = 0.0; @@ -293,9 +295,6 @@ void PairRHEO::compute(int eflag, int vflag) fp[j][1] -= dfp[1]; fp[j][2] -= dfp[2]; } - - if (evflag) // Doesn't account for unbalanced forces - ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], dx[0], dx[1], dx[2]); } // Density damping From bf669d526bfcce31d40f7f58ff95ff62dc186c34 Mon Sep 17 00:00:00 2001 From: EricPalermo Date: Fri, 24 Mar 2023 15:38:26 -0400 Subject: [PATCH 014/104] test adding file --- src/RHEO/test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/RHEO/test.txt diff --git a/src/RHEO/test.txt b/src/RHEO/test.txt new file mode 100644 index 0000000000..e69de29bb2 From 0a3a4c527d987c0b250d208d3559fe5849188c5e Mon Sep 17 00:00:00 2001 From: EricPalermo Date: Fri, 24 Mar 2023 16:43:34 -0400 Subject: [PATCH 015/104] generalized density in dT calculation --- src/RHEO/pair_rheo.cpp | 3 +-- src/RHEO/test.txt | 0 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 src/RHEO/test.txt diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index d1a30d3b40..f03e2b25cd 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -218,8 +218,7 @@ void PairRHEO::compute(int eflag, int vflag) // Thermal Evolution if (thermal_flag) { dT = dot3(dx, dWij); - dT *= (kappai + kappaj) * (Ti - Tj) * rinv * rinv * voli * volj; - //TODO: Assumes heat capacity and density = 1, needs to be generalized + dT *= (kappai + kappaj) * (Ti - Tj) * rinv * rinv * voli * volj / rho0; // Assumes heat capacity = 1 heatflow[i] += dT; if (newton_pair || j < nlocal) { diff --git a/src/RHEO/test.txt b/src/RHEO/test.txt deleted file mode 100644 index e69de29bb2..0000000000 From 29edfc45d7d7c55342b3e4c1f890b27401d869ad Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 24 Mar 2023 21:59:17 -0600 Subject: [PATCH 016/104] Adding heat/temperature checks/zeroing to thermal fix --- src/GRANULAR/fix_heat_flow.cpp | 4 +- src/RHEO/fix_rheo_thermal.cpp | 81 +++++++++++++++++++++++++++++++--- src/RHEO/fix_rheo_thermal.h | 2 + src/RHEO/pair_rheo.cpp | 1 - 4 files changed, 80 insertions(+), 8 deletions(-) diff --git a/src/GRANULAR/fix_heat_flow.cpp b/src/GRANULAR/fix_heat_flow.cpp index a9c110a2e7..1b2e55e673 100644 --- a/src/GRANULAR/fix_heat_flow.cpp +++ b/src/GRANULAR/fix_heat_flow.cpp @@ -80,9 +80,9 @@ void FixHeatFlow::init() dt = update->dt; if (!atom->temperature_flag) - error->all(FLERR,"Fix temp/integrate requires atom style with temperature property"); + error->all(FLERR,"Fix temp/integrate requires atoms store temperature property"); if (!atom->heatflow_flag) - error->all(FLERR,"Fix temp/integrate requires atom style with heatflow property"); + error->all(FLERR,"Fix temp/integrate requires atoms store heatflow property"); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index f000bf65cc..272daf9bd0 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -161,6 +161,11 @@ void FixRHEOThermal::init() compute_vshift = fix_rheo->compute_vshift; dtf = 0.5 * update->dt * force->ftm2v; + + if (atom->temperature_flag != 1) + error->all(FLERR,"fix rheo/thermal command requires atoms store temperature property"); + if (atom->heatflow_flag != 1) + error->all(FLERR,"fix rheo/thermal command requires atoms store heatflow property"); } /* ---------------------------------------------------------------------- */ @@ -234,7 +239,7 @@ void FixRHEOThermal::post_integrate() { int *status = atom->status; double *temperature = atom->temperature; - double *heat = atom->heat; + double *heatflow = atom->heatflow; double *rho = atom->rho; int *mask = atom->mask; int *type = aotm->type; @@ -247,7 +252,7 @@ void FixRHEOThermal::post_integrate() if (status[i] == FixRHEO::FLUID_NO_FORCE) continue; cvi = calc_cv(i); - temperature[i] += dtf * heat[i] / cvi; + temperature[i] += dtf * heatflow[i] / cvi; if (Tc_style != NONE) { Ti = temperature[i]; @@ -298,11 +303,20 @@ void FixRHEOThermal::post_neighbor() /* ---------------------------------------------------------------------- Update (and forward) evolving conductivity styles every timestep + Zero heat flow ------------------------------------------------------------------------- */ void FixRHEOThermal::pre_force(int /*vflag*/) { - // Not needed yet, when needed add (un)pack_forward_comm() methods + // send updated temperatures to ghosts if first instance of fix + // then clear heatflow for next force calculation + double *heatflow = atom->heatflow; + if (first_flag) { + comm->forward_comm(this); + for (int i = 0; i < atom->nmax; i++) heatflow[i] = 0.0; + } + + // Not needed yet, when needed add stage check for (un)pack_forward_comm() methods //int i; //double *conductivity = atom->dvector[index_cond]; //int *mask = atom->mask; @@ -327,7 +341,7 @@ void FixRHEOThermal::pre_force(int /*vflag*/) void FixRHEOThermal::final_integrate() { double *temperature = atom->temperature; - double *heat = atom->heat; + double *heatflow = atom->heatflow; int *status = atom->status; int *mask = atom->mask; @@ -339,7 +353,7 @@ void FixRHEOThermal::final_integrate() if (status[i] & FixRHEO::STATUS_NO_FORCE) continue; cvi = calc_cv(i); - temperature[i] += dtf * heat[i] / cvi; + temperature[i] += dtf * heatflow[i] / cvi; } } } @@ -362,3 +376,60 @@ double FixRHEOThermal::calc_cv(int i) return(cv_type[atom->type[i]]); } } + +/* ---------------------------------------------------------------------- */ + +int FixRHEOThermal::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) +{ + int i, j, m; + + double *temperature = atom->temperature; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = temperature[j]; + } + + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::unpack_forward_comm(int n, int first, double *buf) +{ + int i, m, last; + + m = 0; + last = first + n; + + double *temperature = atom->temperature; + + for (i = first; i < last; i++) temperature[i] = buf[m++]; +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOThermal::pack_reverse_comm(int n, int first, double *buf) +{ + int m = 0; + int last = first + n; + double *heatflow = atom->heatflow; + + for (int i = first; i < last; i++) { + buf[m++] = heatflow[i]; + } + + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::unpack_reverse_comm(int n, int *list, double *buf) +{ + int m = 0; + double *heatflow = atom->heatflow; + + for (int i = 0; i < n; i++) + heatflow[list[i]] += buf[m++]; +} diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index e4ed426fb4..d9a17ebd60 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -39,6 +39,8 @@ class FixRHEOThermal : public Fix { void reset_dt() override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; private: double *cv_type, cv; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index d1a30d3b40..d78af46249 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -219,7 +219,6 @@ void PairRHEO::compute(int eflag, int vflag) if (thermal_flag) { dT = dot3(dx, dWij); dT *= (kappai + kappaj) * (Ti - Tj) * rinv * rinv * voli * volj; - //TODO: Assumes heat capacity and density = 1, needs to be generalized heatflow[i] += dT; if (newton_pair || j < nlocal) { From 908c32788cab5c2f3b7dbeaec208c26577ead8b2 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sat, 25 Mar 2023 20:17:17 -0600 Subject: [PATCH 017/104] Cleaning up fix rheo, initial sketch of kernel compute --- src/RHEO/compute_rheo_kernel.cpp | 870 +++++++++++++++++++++++++++++++ src/RHEO/compute_rheo_kernel.h | 71 +++ src/RHEO/fix_rheo.cpp | 42 +- src/RHEO/fix_rheo.h | 11 - src/RHEO/fix_rheo_thermal.cpp | 3 +- 5 files changed, 948 insertions(+), 49 deletions(-) create mode 100644 src/RHEO/compute_rheo_kernel.cpp create mode 100644 src/RHEO/compute_rheo_kernel.h diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp new file mode 100644 index 0000000000..116ac08745 --- /dev/null +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -0,0 +1,870 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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_rheo_kernel.h" + +#include "atom.h" +#include "comm.h" +#include "compute_rheo_solids.h" +#include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "math_extra.h" +#include "memory.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "pair.h" +#include "update.h" +#include "utils.h" + +#include +#include +#include +#include +#include +#include + +using namespace LAMMPS_NS; +enum {QUINTIC, CRK0, CRK1, CRK2}; +#define DELTA 2000 + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), + C(nullptr), C0(nullptr), compute_solids(nullptr); +{ + if (narg != 3) error->all(FLERR,"Illegal compute rheo/kernel command"); + + comm_forward = 1; // For coordination + solid_flag = 0; +} + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOKernel::~ComputeRHEOKernel() +{ + // Remove custom property if it exists + int tmp1, tmp2, index; + index = atom->find_custom("rheo_coordination", tmp1, tmp2); + if (index != -1) atom->remove_custom(index_coord, 1, 0); + + memory->destroy(C); + memory->destroy(C0); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOKernel::init() +{ + neighbor->add_request(this, NeighConst::REQ_FULL); + + auto fixes = modify->get_fix_by_style("rheo"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use compute rheo/kernel"); + fix_rheo = dynamic_cast(fixes[0]); + + int icompute = modify->find_compute("rheo_solids"); + if (icompute != -1) { + compute_solids = ((ComputeRHEOSolids *) modify->compute[icompute]); + solid_flag = 1; + } + + + N2min = utils::inumeric(FLERR,arg[4],false,lmp); + + cutsq = cut*cut; + cutinv = 1.0/cut; + h = cut/3.0; + ih = 1.0/h; + ihsq = ih*ih; + + kernel_type = QUINTIC; + correction_order = -1; + } else if (strcmp(arg[3],"CRK0") == 0) { + kernel_type = CRK0; + correction_order = 0; + } else if (strcmp(arg[3],"CRK1") == 0) { + kernel_type = CRK1; + correction_order = 1; + } else if (strcmp(arg[3],"CRK2") == 0) { + kernel_type = CRK2; + correction_order = 2; + + if (dim == 3) { + pre_w = 0.002652582384864922*ihsq*ih; + pre_wp = pre_w*ih; + } else { + pre_w = 0.004661441847879780*ihsq; + pre_wp = pre_w*ih; + } + + //Use property atom, can fix store save integers? + char **fixarg = new char*[4]; + fixarg[0] = (char *) "PROPERTY_ATOM_RHEO_KERNEL"; + fixarg[1] = (char *) "all"; + fixarg[2] = (char *) "property/atom"; + fixarg[3] = (char *) "i_coordination"; + modify->add_fix(4,fixarg,1); + + + nmax = atom->nmax; + + if (kernel_type == CRK0) { + memory->create(C0, nmax, "rheo/kernel:C0"); + comm_forward = 1; + } + + if (kernel_type == CRK1) { + Mdim = 1 + dim; + ncor = 1 + dim; + memory->create(C, nmax, ncor, Mdim, "rheo/kernel:C"); + comm_forward = ncor*Mdim; + } + + if (kernel_type == CRK2) { + //Polynomial basis size (up to quadratic order) + Mdim = 1 + dim + dim*(dim+1)/2; + //Number of sets of correction coefficients (1 x y xx yy) + z zz (3D) + ncor = 1 + 2*dim; + //variables that require forwarding + memory->create(C, nmax, ncor, Mdim, "rheo/kernel:C"); + comm_forward = ncor*Mdim; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOKernel::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOKernel::check_corrections(int i) +{ + int corrections = 1; + + if (gsl_error_flag) { + // If there were errors, check to see if it occured for this atom + if (gsl_error_tags.find(atom->tag[i]) != gsl_error_tags.end()) + corrections = 0; + } + + coordination = atom->ivector[index_coord]; + if (coordination[i] < N2min) corrections = 0; + + return corrections; +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double delz, double r) +{ + double w; + + int corrections_i = check_corrections(i); + int corrections_j = check_corrections(j); + int corrections = corrections_i & corrections_j; + + if (memory_flag) { + long long key; + int v_index; + tagint tag1 = atom->tag[i]; + tagint tag2 = atom->tag[j]; + + // Use Szudzik's pairing function to define unique index for two tags + // szudzik.com/elegantpairing.pdf + if (tag1 > tag2) key = (long long) tag1*tag1 + tag2; + else key = (long long) tag2*tag2 + tag1; + + if (locations_w.find(key) != locations_w.end()){ + v_index = locations_w[key]; + w = stored_w[v_index]; + } else { + if (kernel_type == QUINTIC || !corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); + else if (kernel_type == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); + else if (kernel_type == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); + else if (kernel_type == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); + + locations_w[key] = nstored_w; + stored_w[nstored_w] = w; + nstored_w ++; + if (nstored_w >= max_nstored) grow_memory(); + } + } else { + if (kernel_type == QUINTIC || !corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); + else if (kernel_type == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); + else if (kernel_type == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); + else if (kernel_type == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); + } + + return w; +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double delz, double r) +{ + double wp; + + int corrections_i = check_corrections(i); + int corrections_j = check_corrections(j); + + // Calc wp and default dW's, a bit inefficient but can redo later + wp = calc_dw_quintic(i,j,delx,dely,delz,r,dWij,dWji); + if(kernel_type == CRK1) { + //check if kernel correction calculated successfully. If not, revert to quintic + if (corrections_i) calc_dw_crk1(i,j,delx,dely,delz,r,dWij); + if (corrections_j) calc_dw_crk1(j,i,-delx,-dely,-delz,r,dWji); + } else if(kernel_type == CRK2) { + if (corrections_i) calc_dw_crk2(i,j,delx,dely,delz,r,dWij); + if (corrections_j) calc_dw_crk2(j,i,-delx,-dely,-delz,r,dWji); + } + + return wp; +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_w_quintic(int i, int j, double delx, double dely, double delz, double r) +{ + double w, tmp1, tmp2, tmp3, tmp1sq, tmp2sq, tmp3sq, s; + s = r*ih; + + if (s>3.0) { + w = 0.0; + } + + if (s <= 3.0) { + tmp3 = 3 - s; + tmp3sq = tmp3*tmp3; + w = tmp3sq*tmp3sq*tmp3; + } + if (s <= 2.0) { + tmp2 = 2 - s; + tmp2sq = tmp2*tmp2; + w -= 6*tmp2sq*tmp2sq*tmp2; + } + if (s <= 1.0) { + tmp1 = 1 - s; + tmp1sq = tmp1*tmp1; + w += 15*tmp1sq*tmp1sq*tmp1; + } + + w *= pre_w; + + Wij = w; + Wji = w; + + return w; +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_dw_quintic(int i, int j, double delx, double dely, double delz, double r, double *dW1, double *dW2) +{ + double wp, tmp1, tmp2, tmp3, tmp1sq, tmp2sq, tmp3sq, s, wprinv; + double *mass = atom->mass; + int *type = atom->type; + + s = r*ih; + + if (s>3.0) { + wp = 0.0; + } + if (s <= 3.0) { + tmp3 = 3 - s; + tmp3sq = tmp3*tmp3; + wp = -5.0*tmp3sq*tmp3sq; + } + if (s <= 2.0) { + tmp2 = 2 - s; + tmp2sq = tmp2*tmp2; + wp += 30.0*tmp2sq*tmp2sq; + } + if (s <= 1.0) { + tmp1 = 1 - s; + tmp1sq = tmp1*tmp1; + wp -= 75.0*tmp1sq*tmp1sq; + } + + wp *= pre_wp; + wprinv = wp/r; + dW1[0] = delx*wprinv; + dW1[1] = dely*wprinv; + dW1[2] = delz*wprinv; + + dW2[0] = -delx*wprinv; + dW2[1] = -dely*wprinv; + dW2[2] = -delz*wprinv; + + return wp; +} + + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_w_crk0(int i, int j, double delx, double dely, double delz, double r) +{ + double w; + + w = calc_w_quintic(i,j,delx,dely,delz,r); + + Wij = C0[i]*w; + Wji = C0[j]*w; + + return w; +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_w_crk1(int i, int j, double delx, double dely, double delz, double r) +{ + int b; + double w, wR, dx[3], H[Mdim]; + + dx[0] = delx; + dx[1] = dely; + dx[2] = delz; + w = calc_w_quintic(i,j,delx,dely,delz,r); + + if (dim == 2) { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + } else { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + H[3] = dx[2]*cutinv; + } + Wij = 0; + for (b = 0; b < Mdim; b++) { + Wij += C[i][0][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + } + Wij *= w; + + //Now compute Wji + H[1] *= -1; + H[2] *= -1; + if (dim == 3) H[3] *= -1; + + Wji = 0; + for (b = 0; b < Mdim; b++) { + Wji += C[j][0][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + } + Wji *= w; + + return w; +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_w_crk2(int i, int j, double delx, double dely, double delz, double r) +{ + int b; + double w, wR, dx[3], H[Mdim]; + dx[0] = delx; + dx[1] = dely; + dx[2] = delz; + w = calc_w_quintic(i,j,delx,dely,delz,r); + + + if (dim == 2) { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + H[3] = 0.5*dx[0]*dx[0]*cutinv*cutinv; + H[4] = 0.5*dx[1]*dx[1]*cutinv*cutinv; + H[5] = dx[0]*dx[1]*cutinv*cutinv; + } else { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + H[3] = dx[2]*cutinv; + H[4] = 0.5*dx[0]*dx[0]*cutinv*cutinv; + H[5] = 0.5*dx[1]*dx[1]*cutinv*cutinv; + H[6] = 0.5*dx[2]*dx[2]*cutinv*cutinv; + H[7] = dx[0]*dx[1]*cutinv*cutinv; + H[8] = dx[0]*dx[2]*cutinv*cutinv; + H[9] = dx[1]*dx[2]*cutinv*cutinv; + } + Wij = 0; + for (b = 0; b < Mdim; b++) { + Wij += C[i][0][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + } + Wij *= w; + + //Now compute Wji + H[1] *= -1; + H[2] *= -1; + if (dim == 3) H[3] *= -1; + + Wji = 0; + for (b = 0; b < Mdim; b++) { + Wji += C[j][0][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + } + Wji *= w; + + return w; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOKernel::calc_dw_crk1(int i, int j, double delx, double dely, double delz, double r, double *dW) +{ + int a, b; + double w, dx[3], H[Mdim]; + dx[0] = delx; + dx[1] = dely; + dx[2] = delz; + + w = calc_w_quintic(i,j,delx,dely,delz,r); + //Populate correction basis + if (dim == 2) { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + } else { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + H[3] = dx[2]*cutinv; + } + // dWij[] = dWx dWy (dWz) + //compute derivative operators + for (a = 0; a < dim; a++) { + dW[a] = 0.0; + for (b = 0; b < Mdim; b++) { + //First derivative kernels + dW[a] += C[i][1+a][b]*H[b]; // C columns: 1 x y (z) + } + dW[a] *= w; + } +} + + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOKernel::calc_dw_crk2(int i, int j, double delx, double dely, double delz, double r, double *dW) +{ + int a, b; + double w, dx[3], H[Mdim]; + dx[0] = delx; + dx[1] = dely; + dx[2] = delz; + + w = calc_w_quintic(i,j,delx,dely,delz,r); + + //Populate correction basis + if (dim == 2) { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + H[3] = 0.5*dx[0]*dx[0]*cutinv*cutinv; + H[4] = 0.5*dx[1]*dx[1]*cutinv*cutinv; + H[5] = dx[0]*dx[1]*cutinv*cutinv; + } else { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + H[3] = dx[2]*cutinv; + H[4] = 0.5*dx[0]*dx[0]*cutinv*cutinv; + H[5] = 0.5*dx[1]*dx[1]*cutinv*cutinv; + H[6] = 0.5*dx[2]*dx[2]*cutinv*cutinv; + H[7] = dx[0]*dx[1]*cutinv*cutinv; + H[8] = dx[0]*dx[2]*cutinv*cutinv; + H[9] = dx[1]*dx[2]*cutinv*cutinv; + } + + // dWij[] = dWx dWy (dWz) + //compute derivative operators + for (a = 0; a < dim; a++) { + dW[a] = 0.0; + for (b = 0; b < Mdim; b++) { + //First derivative kernels + dW[a] += C[i][1+a][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + } + dW[a] *= w; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOKernel::compute_peratom() +{ + gsl_error_flag = 0; + gsl_error_tags.clear(); + + int i, j, ii, jj, jnum, itype, jtype; + double xtmp, ytmp, ztmp, delx, dely, delz; + double r, rinv, rsq, imass, jmass; + double dx[3]; + double w, wp, s, vi, vj, M, vjw; + double vjdw[3] = {0}; + bool sflag; + + double **x = atom->x; + int *type = atom->type; + double *mass = atom->mass; + double *rho = atom->rho; + int *phase = atom->phase; + tagint *tag = atom->tag; + coordination = atom->ivector[index_coord]; + + int inum, *ilist, *jlist, *numneigh, **firstneigh; + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + if (kernel_type == QUINTIC) { + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; // Will be ignored in 2D + + jlist = firstneigh[i]; + jnum = numneigh[i]; + itype = type[i]; + coordination[i] = 0; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + + rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; + r = sqrt(rsq); + rinv = 1/r; + + if (rsq < cutsq) { + coordination[i] += 1; + } + } + } + + comm->forward_comm_compute(this); + + } else if (kernel_type == CRK0) { + if (atom->nmax > nmax){ + nmax = atom->nmax; + memory->destroy(C0); + memory->create(C0, nmax, "rheo/kernel:C"); + } + + //The moment Matrix array has to be 1D to be compatible with gsl + // Solve linear system for each atom + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; // Will be ignored in 2D + + jlist = firstneigh[i]; + jnum = numneigh[i]; + itype = type[i]; + + //Initialize M and H to zero: + M = 0; + + //variable for insufficient neighbors + coordination[i] = 0; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + + rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; + r = sqrt(rsq); + rinv = 1/r; + + if (rsq < cutsq) { + //Compute Wij + w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); + if (phase[j] > FixRHEO::FLUID_MAX && solid_flag) + vj = mass[type[j]]/compute_solids->correct_rho(j,i); + else vj = mass[type[j]]/rho[j]; + coordination[i] += 1; // Increment contributing neighbor + + M += w*vj; + } + } + + if (coordination[i] < N2min) continue; + //Get inverse of 1x1 matrix + M = 1.0/M; + C0[i] = M; + } + + // communicate densities - maybe not needed for ghost atoms but just to be safe + // can remove in future once we determine they aren't necessary + comm->forward_comm_compute(this); + + } else if (correction_order > 0) { + + int i, j, ii, jj, jnum, itype, jtype; + int g, a, b, c, d, ib, ic, id, nperm; + double xtmp, ytmp, ztmp, delx, dely, delz; + double dx[3] = {0}; + + //Turn off GSL error handler so we can check and revert RK to Quintic + //when inssuficient neighbors + gsl_set_error_handler_off(); + + // Create Moment matrix M and polynomial basis vector H + //The moment Matrix array has to be 1D to be compatible with gsl + double H[Mdim], M[Mdim*Mdim]; + + if (atom->nmax > nmax){ + nmax = atom->nmax; + memory->destroy(C); + memory->create(C, nmax,ncor,Mdim, "rheo/kernel:C"); + } + + // Solve linear system for each atom + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; // Will be ignored in 2D + + jlist = firstneigh[i]; + jnum = numneigh[i]; + itype = type[i]; + + //Initialize M and H to zero: + for (a = 0; a < Mdim; a++) { + for (b = a; b < Mdim; b++) { + //Just zero upper-triangle of M since it will be symmetric + M[a*Mdim+b] = 0; + } + } + //Zero moment + //variables for switching off RK caclulation if insufficient neighbors + sflag = 0; + coordination[i] = 0; + // Loop over neighbors to populate elements of L + //m0[i] = 0.0; + + //Self contribution + //w = calc_w_quintic(i,i,0.,0.,0.,0.); + //m0[i] += w; + //vi = 1/vw[i]; + + vi = mass[type[i]]/rho[i]; // Overwritten if i is solid + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + + rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; + r = sqrt(rsq); + rinv = 1/r; + + if (rsq < cutsq) { + //Compute Wij + w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); + //vj = 1/vw[j]; // + + if (phase[i] > FixRHEO::FLUID_MAX && solid_flag) + vi = mass[type[i]]/compute_solids->correct_rho(i,j); + + if (phase[j] > FixRHEO::FLUID_MAX && solid_flag) + vj = mass[type[j]]/compute_solids->correct_rho(j,i); + else vj = mass[type[j]]/rho[j]; + //m0[i] += w; + + //Populate the H-vector of polynomials (2D) + if (dim == 2) { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + if (kernel_type == CRK2) { + H[3] = 0.5*dx[0]*dx[0]*cutinv*cutinv; + H[4] = 0.5*dx[1]*dx[1]*cutinv*cutinv; + H[5] = dx[0]*dx[1]*cutinv*cutinv; + } + } else { + H[0] = 1.0; + H[1] = dx[0]*cutinv; + H[2] = dx[1]*cutinv; + H[3] = dx[2]*cutinv; + if (kernel_type == CRK2) { + H[4] = 0.5*dx[0]*dx[0]*cutinv*cutinv; + H[5] = 0.5*dx[1]*dx[1]*cutinv*cutinv; + H[6] = 0.5*dx[2]*dx[2]*cutinv*cutinv; + H[7] = dx[0]*dx[1]*cutinv*cutinv; + H[8] = dx[0]*dx[2]*cutinv*cutinv; + H[9] = dx[1]*dx[2]*cutinv*cutinv; + } + } + coordination[i] += 1; // Increment contributing neighbor + + //Populate the upper triangle of the + for (a = 0; a < Mdim; a++) { + for (b = a; b < Mdim; b++) { + M[a*Mdim+b] += H[a]*H[b]*w*vj; + } + } + } + } + //Now populate the lower triangle from the symmetric entries of M: + for (a = 0; a < Mdim; a++) { + for (b = a; b < Mdim; b++) { + M[b*Mdim+a] = M[a*Mdim+b]; + } + } + + if (coordination[i] < N2min) continue; + + //Use gsl to get Minv + //Since the polynomials are independent, M is symmetrix & positive-definite + //So we will use a Cholesky decomposition + gsl_matrix_view gM = gsl_matrix_view_array(M,Mdim,Mdim); + int status; + status = 0; + //gsl_linalg_cholesky_decomp1 -> gsl_linalg_cholesky_decomp + //So I don't have to update my gsl (me being lazy, can revert) + status = gsl_linalg_cholesky_decomp(&gM.matrix); //M is now the cholesky decomposition of M + // check if erro in inversion + if (status) { + //Revert to uncorrected SPH for this particle + gsl_error_flag = 1; + gsl_error_tags.insert(tag[i]); + + //check if not positive-definite + if (status != GSL_EDOM) + fprintf(stderr, "failed, gsl_errno=%d.n", status); + + continue; + } else { + gsl_linalg_cholesky_invert(&gM.matrix); //M is now M^-1 + } + + // Correction coefficients are just the columns of M^-1 multiplied by an appropriate coefficient + //Solve the linear system several times to get coefficientns + // M: 1 x y (z) x^2 y^2 (z^2) xy (xz) (yz) + //---------------------------------------------------------- + // 0 1 2 3 4 5 || 2D indexing + // 0 1 2 3 4 5 6 7 8 9 || 3D indexing + // W 1 . . . . . . . . . + // dWx . -1 . . . . . . . . + // dWy . . -1 . . . . . . . + // dWz . . . (-1) . . . . . . + // d2Wx . . . . 2 . . . . . + // d2Wy . . . . . 2 . . . . + // d2Wz . . . . . . (2) . . . + + //0 1 2 3 4 + //0 1 2 3 4 5 6 + + // Use coefficents to compute smoothed density + //Pack coefficients into C + for (a = 0; a < Mdim; a++) { + //W + C[i][0][a] = M[a*Mdim + 0]; // all rows of column 0 + for (b = 0; b < dim; b++) { + //First derivatives + C[i][1+b][a] = -M[a*Mdim + b+1]/cut; // columns 1-2 (2D) or 1-3 (3D) + //Second derivatives + if (kernel_type == CRK2) + C[i][1+dim+b][a] = M[a*Mdim + b+1+dim]/cutsq; // columns 3-4 (2D) or 4-6 (3D) + } + } + } + + // communicate densities - maybe not needed for ghost atoms but just to be safe + // can remove in future once we determine they aren't necessary + comm->forward_comm_compute(this); + } +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i,j,k,m,a,b; + coordination = atom->ivector[index_coord]; + m = 0; + if (correction_order > 0) { + for (i = 0; i < n; i++) { + j = list[i]; + for (a = 0; a < ncor; a++) { + for (b = 0; b < Mdim; b++) { + buf[m++] = C[j][a][b]; + } + } + buf[m++] = coordination[j]; + } + } else if (kernel_type == CRK0) { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = C0[j]; + buf[m++] = coordination[j]; + } + } else { + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = coordination[j]; + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last,a,b; + coordination = atom->ivector[index_coord]; + m = 0; + last = first + n; + if (correction_order > 0) { + for (i = first; i < last; i++) { + for (a = 0; a < ncor; a++) { + for (b = 0; b < Mdim; b++) { + C[i][a][b] = buf[m++]; + } + } + coordination[i] = buf[m++]; + } + } else if (kernel_type == CRK0) { + for (i = first; i < last; i++) { + C0[i] = buf[m++]; + coordination[i] = buf[m++]; + } + } else { + for (i = first; i < last; i++) { + coordination[i] = buf[m++]; + } + } +} diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h new file mode 100644 index 0000000000..114f39e85e --- /dev/null +++ b/src/RHEO/compute_rheo_kernel.h @@ -0,0 +1,71 @@ +/* -*- 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 COMPUTE_CLASS +// clang-format off +ComputeStyle(rheo/kernel,ComputeRHEOKernel) +// clang-format on +#else + +#ifndef LMP_COMPUTE_RHEO_KERNEL_H +#define LMP_COMPUTE_RHEO_KERNEL_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeRHEOKernel : public Compute { + public: + ComputeRHEOKernel(class LAMMPS *, int, char **); + ~ComputeRHEOKernel() override; + void init() override; + void init_list(int, class NeighList *) override; + void compute_peratom() override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; + double memory_usage() override; + double calc_w(int,int,double,double,double,double); + double calc_dw(int,int,double,double,double,double); + double calc_w_quintic(int,int,double,double,double,double); + double calc_dw_quintic(int,int,double,double,double,double,double *,double *); + + double dWij[3], dWji[3], Wij, Wji; + int correction_order; + + private: + int solid_flag; + int gsl_error_flag; + + int kernel_type, N2min, nmax, Mdim, ncor; + int nmax_old, index_coord; + double cut, cutsq, cutinv, h, ih, ihsq, pre_w, pre_wp; + double ***C; + double *C0; + + class NeighList *list; + class ComputeRHEOSolids *compute_solids; + class FixRHEO *fix_rheo; + + int check_corrections(int); + + double calc_w_crk0(int,int,double,double,double,double); + double calc_w_crk1(int,int,double,double,double,double); + double calc_w_crk2(int,int,double,double,double,double); + void calc_dw_crk1(int,int,double,double,double,double,double *); + void calc_dw_crk2(int,int,double,double,double,double,double *); +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index cccaa792ff..6d16bf2782 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -21,7 +21,6 @@ #include "compute_rheo_vshift.h" #include "domain.h" #include "error.h" -#include "fix_store_peratom.h" #include "force.h" #include "modify.h" #include "update.h" @@ -34,10 +33,7 @@ using namespace FixConst; FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), compute_grad(nullptr), compute_kernel(nullptr), - compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr), - fix_store_visc(nullptr), fix_store_pres(nullptr), fix_store_cond(nullptr), - fix_store_surf(nullptr), fix_store_fp(nullptr), surface(nullptr), conductivity(nullptr), - viscosity(nullptr), pressure(nullptr), f_pressure(nullptr) + compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr) { time_integrate = 1; @@ -112,12 +108,6 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : FixRHEO::~FixRHEO() { - if (fix_store_visc) modify->delete_fix("rheo_store_visc"); - if (fix_store_pres) modify->delete_fix("rheo_store_pres"); - if (fix_store_surf) modify->delete_fix("rheo_store_surf"); - if (fix_store_cond) modify->delete_fix("rheo_store_cond"); - if (fix_store_fp) modify->delete_fix("rheo_store_fp"); - if (compute_kernel) modify->delete_compute("rheo_kernel"); if (compute_grad) modify->delete_compute("rheo_grad"); if (compute_interface) modify->delete_compute("rheo_interface"); @@ -133,46 +123,26 @@ FixRHEO::~FixRHEO() void FixRHEO::post_constructor() { compute_kernel = dynamic_cast(modify->add_compute("rheo_kernel all rheo/kernel")); - - fix_store_visc = dynamic_cast(modify->add_fix("rheo_store_visc all STORE/PERATOM 0 1")) - fix_store_visc->disable = 1; - viscosity = fix_store_visc->vstore; - fix_store_pres = dynamic_cast(modify->add_fix("rheo_store_pres all STORE/PERATOM 0 1")) - pressure = fix_store_pres->vstore; - fix_store_pres->disable = 1; - + compute_kernel->fix_rheo = this; std::string cmd = "rheo_grad all rheo/grad velocity rho viscosity"; if (thermal_flag) cmd += "temperature"; compute_grad = dynamic_cast(modify->add_compute(cmd)); compute_grad->fix_rheo = this; - if (rhosum_flag) + if (rhosum_flag) { compute_rhosum = dynamic_cast(modify->add_compute("rheo_rhosum all rheo/rho/sum")); + compute_rhosum->fix_rheo = this; + } if (shift_flag) { compute_vshift = dynamic_cast(modify->add_compute("rheo_vshift all rheo/vshift")); compute_vshift->fix_rheo = this; } - if (surface_flag) { - fix_store_surf = dynamic_cast(modify->add_fix("rheo_store_surf all STORE/PERATOM 0 1")) - surface = fix_store_surf->vstore; - fix_store_surf->disable = 1; - } - - if (thermal_flag) { - fix_store_cond = dynamic_cast(modify->add_fix("rheo_store_cond all STORE/PERATOM 0 1")) - conductivity = fix_store_cond->vstore; - fix_store_cond->disable = 1; - } - if (interface_flag) { compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface"))); - - fix_store_fp = dynamic_cast(modify->add_fix("rheo_store_fp all STORE/PERATOM 0 3")) - f_pressure = fix_store_fp->astore; - fix_store_fp->disable = 1; + compute_interface->fix_rheo = this; } } diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 3487dd7273..0132f32bcc 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -44,11 +44,6 @@ class FixRHEO : public Fix { int kernel_style; enum {QUINTIC, CRK0, CRK1, CRK2}; - // Non-persistent per-atom arrays - int *surface; - double *conductivity, *viscosity, *pressure; - double **f_pressure; - // Status variables enum { // Phase status @@ -83,12 +78,6 @@ class FixRHEO : public Fix { int interface_fix_defined; int surface_fix_defined; - class FixStorePeratom *fix_store_visc; - class FixStorePeratom *fix_store_pres; - class FixStorePeratom *fix_store_cond; - class FixStorePeratom *fix_store_surf; - class FixStorePeratom *fix_store_fp; - class ComputeRHEOGrad *compute_grad; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 272daf9bd0..8b0c9e46de 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -32,8 +32,7 @@ enum {NONE, CONSTANT, TYPE}; /* ---------------------------------------------------------------------- */ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr), - conductivity(nullptr) + Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); From 98050c96cc132ad8c5e6b6d96cad193eaad22437 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 26 Mar 2023 14:30:34 -0600 Subject: [PATCH 018/104] Cleaning up kernel compute --- src/RHEO/compute_rheo_kernel.cpp | 534 +++++++++++++------------------ src/RHEO/compute_rheo_kernel.h | 8 +- 2 files changed, 234 insertions(+), 308 deletions(-) diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 116ac08745..62a4283977 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -15,7 +15,7 @@ #include "atom.h" #include "comm.h" -#include "compute_rheo_solids.h" +#include "compute_rheo_interface.h" #include "domain.h" #include "error.h" #include "fix_rheo.h" @@ -31,26 +31,32 @@ #include "utils.h" #include -#include #include #include #include #include using namespace LAMMPS_NS; +using namespace MathExtra; + enum {QUINTIC, CRK0, CRK1, CRK2}; #define DELTA 2000 +Todo: convert delx dely delz to an array +Should vshift be using kernel quintic? +Move away from h notation, use cut? + /* ---------------------------------------------------------------------- */ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), - C(nullptr), C0(nullptr), compute_solids(nullptr); + C(nullptr), C0(nullptr), compute_interface(nullptr); { if (narg != 3) error->all(FLERR,"Illegal compute rheo/kernel command"); - comm_forward = 1; // For coordination + comm_forward = 1; // Always minimum for coordination solid_flag = 0; + dim = domain->dimension; } /* ---------------------------------------------------------------------- */ @@ -76,72 +82,67 @@ void ComputeRHEOKernel::init() if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use compute rheo/kernel"); fix_rheo = dynamic_cast(fixes[0]); - int icompute = modify->find_compute("rheo_solids"); + int icompute = modify->find_compute("rheo_interface"); if (icompute != -1) { - compute_solids = ((ComputeRHEOSolids *) modify->compute[icompute]); + compute_interface = ((ComputeRHEOInterface *) modify->compute[icompute]); solid_flag = 1; } + kernel_style = fix_rheo->kernel_style; + zmin = fix_rheo->zmin_kernel; + h = fix_rheo->h; + hsq = h * h; + hinv = 1.0 / h; + hsqinv = hinv * hinv; - N2min = utils::inumeric(FLERR,arg[4],false,lmp); - - cutsq = cut*cut; - cutinv = 1.0/cut; - h = cut/3.0; - ih = 1.0/h; - ihsq = ih*ih; - - kernel_type = QUINTIC; + if (kernel_style == FixRHEO::QUINTIC) { correction_order = -1; - } else if (strcmp(arg[3],"CRK0") == 0) { - kernel_type = CRK0; + } else if (kernel_style == FixRHEO::CRK0) { correction_order = 0; - } else if (strcmp(arg[3],"CRK1") == 0) { - kernel_type = CRK1; + } else if (kernel_style == FixRHEO::CRK1) { correction_order = 1; - } else if (strcmp(arg[3],"CRK2") == 0) { - kernel_type = CRK2; + } else if (kernel_style == FixRHEO::CRK2) { correction_order = 2; + } if (dim == 3) { - pre_w = 0.002652582384864922*ihsq*ih; - pre_wp = pre_w*ih; + pre_w = 0.002652582384864922 * 27.0 * ihsq * ih; + pre_wp = pre_w * 3.0 * ih; } else { - pre_w = 0.004661441847879780*ihsq; - pre_wp = pre_w*ih; + pre_w = 0.004661441847879780 * 9 * ihsq; + pre_wp = pre_w * 3.0 * ih; } - //Use property atom, can fix store save integers? - char **fixarg = new char*[4]; - fixarg[0] = (char *) "PROPERTY_ATOM_RHEO_KERNEL"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "property/atom"; - fixarg[3] = (char *) "i_coordination"; - modify->add_fix(4,fixarg,1); + // Create coordination array if it doesn't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded + int tmp1, tmp2; + int nmax = atom->nmax; + index_coord = atom->find_custom("rheo_coordination", tmp1, tmp2); + if (index_coord == -1) { + index_coord = atom->add_custom("rheo_coordination", 0, 0); + nmax_old = nmax; + } - nmax = atom->nmax; - + comm_forward = 1; + ncor = 0; + Mdim = 0; if (kernel_type == CRK0) { memory->create(C0, nmax, "rheo/kernel:C0"); - comm_forward = 1; - } - - if (kernel_type == CRK1) { + } else if (kernel_type == CRK1) { Mdim = 1 + dim; ncor = 1 + dim; memory->create(C, nmax, ncor, Mdim, "rheo/kernel:C"); - comm_forward = ncor*Mdim; - } - - if (kernel_type == CRK2) { + comm_forward = ncor * Mdim; + } else if (kernel_type == CRK2) { //Polynomial basis size (up to quadratic order) - Mdim = 1 + dim + dim*(dim+1)/2; + Mdim = 1 + dim + dim * (dim + 1) / 2; //Number of sets of correction coefficients (1 x y xx yy) + z zz (3D) - ncor = 1 + 2*dim; - //variables that require forwarding + ncor = 1 + 2 * dim; memory->create(C, nmax, ncor, Mdim, "rheo/kernel:C"); - comm_forward = ncor*Mdim; + comm_forward = ncor * Mdim; } } @@ -164,8 +165,8 @@ int ComputeRHEOKernel::check_corrections(int i) corrections = 0; } - coordination = atom->ivector[index_coord]; - if (coordination[i] < N2min) corrections = 0; + int *coordination = atom->ivector[index_coord]; + if (coordination[i] < zmin) corrections = 0; return corrections; } @@ -180,37 +181,10 @@ double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double int corrections_j = check_corrections(j); int corrections = corrections_i & corrections_j; - if (memory_flag) { - long long key; - int v_index; - tagint tag1 = atom->tag[i]; - tagint tag2 = atom->tag[j]; - - // Use Szudzik's pairing function to define unique index for two tags - // szudzik.com/elegantpairing.pdf - if (tag1 > tag2) key = (long long) tag1*tag1 + tag2; - else key = (long long) tag2*tag2 + tag1; - - if (locations_w.find(key) != locations_w.end()){ - v_index = locations_w[key]; - w = stored_w[v_index]; - } else { - if (kernel_type == QUINTIC || !corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); - else if (kernel_type == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); - else if (kernel_type == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); - else if (kernel_type == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); - - locations_w[key] = nstored_w; - stored_w[nstored_w] = w; - nstored_w ++; - if (nstored_w >= max_nstored) grow_memory(); - } - } else { - if (kernel_type == QUINTIC || !corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); - else if (kernel_type == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); - else if (kernel_type == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); - else if (kernel_type == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); - } + if (kernel_type == QUINTIC || !corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); + else if (kernel_type == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); + else if (kernel_type == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); + else if (kernel_type == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); return w; } @@ -243,26 +217,26 @@ double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double double ComputeRHEOKernel::calc_w_quintic(int i, int j, double delx, double dely, double delz, double r) { double w, tmp1, tmp2, tmp3, tmp1sq, tmp2sq, tmp3sq, s; - s = r*ih; + s = r * 3.0 * ih; - if (s>3.0) { + if (s > 3.0) { w = 0.0; } if (s <= 3.0) { - tmp3 = 3 - s; - tmp3sq = tmp3*tmp3; - w = tmp3sq*tmp3sq*tmp3; + tmp3 = 3.0 - s; + tmp3sq = tmp3 * tmp3; + w = tmp3sq * tmp3sq * tmp3; } if (s <= 2.0) { - tmp2 = 2 - s; - tmp2sq = tmp2*tmp2; - w -= 6*tmp2sq*tmp2sq*tmp2; + tmp2 = 2.0 - s; + tmp2sq = tmp2 * tmp2; + w -= 6.0 * tmp2sq * tmp2sq * tmp2; } if (s <= 1.0) { - tmp1 = 1 - s; - tmp1sq = tmp1*tmp1; - w += 15*tmp1sq*tmp1sq*tmp1; + tmp1 = 1.0 - s; + tmp1sq = tmp1 * tmp1; + w += 15.0 * tmp1sq * tmp1sq * tmp1; } w *= pre_w; @@ -281,36 +255,36 @@ double ComputeRHEOKernel::calc_dw_quintic(int i, int j, double delx, double dely double *mass = atom->mass; int *type = atom->type; - s = r*ih; + s = r * 3.0 * ih; - if (s>3.0) { + if (s > 3.0) { wp = 0.0; } if (s <= 3.0) { - tmp3 = 3 - s; - tmp3sq = tmp3*tmp3; - wp = -5.0*tmp3sq*tmp3sq; + tmp3 = 3.0 - s; + tmp3sq = tmp3 * tmp3; + wp = -5.0 * tmp3sq * tmp3sq; } if (s <= 2.0) { - tmp2 = 2 - s; - tmp2sq = tmp2*tmp2; - wp += 30.0*tmp2sq*tmp2sq; + tmp2 = 2.0 - s; + tmp2sq = tmp2 * tmp2; + wp += 30.0 * tmp2sq * tmp2sq; } if (s <= 1.0) { - tmp1 = 1 - s; - tmp1sq = tmp1*tmp1; - wp -= 75.0*tmp1sq*tmp1sq; + tmp1 = 1.0 - s; + tmp1sq = tmp1 * tmp1; + wp -= 75.0 * tmp1sq * tmp1sq; } wp *= pre_wp; - wprinv = wp/r; - dW1[0] = delx*wprinv; - dW1[1] = dely*wprinv; - dW1[2] = delz*wprinv; + wprinv = wp / r; + dW1[0] = delx * wprinv; + dW1[1] = dely * wprinv; + dW1[2] = delz * wprinv; - dW2[0] = -delx*wprinv; - dW2[1] = -dely*wprinv; - dW2[2] = -delz*wprinv; + dW2[0] = -delx * wprinv; + dW2[1] = -dely * wprinv; + dW2[2] = -delz * wprinv; return wp; } @@ -324,8 +298,8 @@ double ComputeRHEOKernel::calc_w_crk0(int i, int j, double delx, double dely, do w = calc_w_quintic(i,j,delx,dely,delz,r); - Wij = C0[i]*w; - Wji = C0[j]*w; + Wij = C0[i] * w; + Wji = C0[j] * w; return w; } @@ -344,17 +318,17 @@ double ComputeRHEOKernel::calc_w_crk1(int i, int j, double delx, double dely, do if (dim == 2) { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; } else { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; - H[3] = dx[2]*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; + H[3] = dx[2] * hinv; } Wij = 0; for (b = 0; b < Mdim; b++) { - Wij += C[i][0][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + Wij += C[i][0][b] * H[b]; // C columns: 1 x y (z) xx yy (zz) } Wij *= w; @@ -365,7 +339,7 @@ double ComputeRHEOKernel::calc_w_crk1(int i, int j, double delx, double dely, do Wji = 0; for (b = 0; b < Mdim; b++) { - Wji += C[j][0][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + Wji += C[j][0][b] * H[b]; // C columns: 1 x y (z) xx yy (zz) } Wji *= w; @@ -383,29 +357,28 @@ double ComputeRHEOKernel::calc_w_crk2(int i, int j, double delx, double dely, do dx[2] = delz; w = calc_w_quintic(i,j,delx,dely,delz,r); - if (dim == 2) { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; - H[3] = 0.5*dx[0]*dx[0]*cutinv*cutinv; - H[4] = 0.5*dx[1]*dx[1]*cutinv*cutinv; - H[5] = dx[0]*dx[1]*cutinv*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; + H[3] = 0.5 * dx[0] * dx[0] * hsqinv; + H[4] = 0.5 * dx[1] * dx[1] * hsqinv; + H[5] = dx[0] * dx[1] * hsqinv; } else { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; - H[3] = dx[2]*cutinv; - H[4] = 0.5*dx[0]*dx[0]*cutinv*cutinv; - H[5] = 0.5*dx[1]*dx[1]*cutinv*cutinv; - H[6] = 0.5*dx[2]*dx[2]*cutinv*cutinv; - H[7] = dx[0]*dx[1]*cutinv*cutinv; - H[8] = dx[0]*dx[2]*cutinv*cutinv; - H[9] = dx[1]*dx[2]*cutinv*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; + H[3] = dx[2] * hinv; + H[4] = 0.5 * dx[0] * dx[0] * hsqinv; + H[5] = 0.5 * dx[1] * dx[1] * hsqinv; + H[6] = 0.5 * dx[2] * dx[2] * hsqinv; + H[7] = dx[0] * dx[1] * hsqinv; + H[8] = dx[0] * dx[2] * hsqinv; + H[9] = dx[1] * dx[2] * hsqinv; } Wij = 0; for (b = 0; b < Mdim; b++) { - Wij += C[i][0][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + Wij += C[i][0][b] * H[b]; // C columns: 1 x y (z) xx yy (zz) } Wij *= w; @@ -416,7 +389,7 @@ double ComputeRHEOKernel::calc_w_crk2(int i, int j, double delx, double dely, do Wji = 0; for (b = 0; b < Mdim; b++) { - Wji += C[j][0][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + Wji += C[j][0][b] * H[b]; // C columns: 1 x y (z) xx yy (zz) } Wji *= w; @@ -434,24 +407,26 @@ void ComputeRHEOKernel::calc_dw_crk1(int i, int j, double delx, double dely, dou dx[2] = delz; w = calc_w_quintic(i,j,delx,dely,delz,r); + //Populate correction basis if (dim == 2) { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; } else { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; - H[3] = dx[2]*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; + H[3] = dx[2] * hinv; } + // dWij[] = dWx dWy (dWz) //compute derivative operators for (a = 0; a < dim; a++) { dW[a] = 0.0; for (b = 0; b < Mdim; b++) { //First derivative kernels - dW[a] += C[i][1+a][b]*H[b]; // C columns: 1 x y (z) + dW[a] += C[i][1 + a][b] * H[b]; // C columns: 1 x y (z) } dW[a] *= w; } @@ -473,22 +448,22 @@ void ComputeRHEOKernel::calc_dw_crk2(int i, int j, double delx, double dely, dou //Populate correction basis if (dim == 2) { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; - H[3] = 0.5*dx[0]*dx[0]*cutinv*cutinv; - H[4] = 0.5*dx[1]*dx[1]*cutinv*cutinv; - H[5] = dx[0]*dx[1]*cutinv*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; + H[3] = 0.5 * dx[0] * dx[0] * hsqinv; + H[4] = 0.5 * dx[1] * dx[1] * hsqinv; + H[5] = dx[0] * dx[1] * hsqinv; } else { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; - H[3] = dx[2]*cutinv; - H[4] = 0.5*dx[0]*dx[0]*cutinv*cutinv; - H[5] = 0.5*dx[1]*dx[1]*cutinv*cutinv; - H[6] = 0.5*dx[2]*dx[2]*cutinv*cutinv; - H[7] = dx[0]*dx[1]*cutinv*cutinv; - H[8] = dx[0]*dx[2]*cutinv*cutinv; - H[9] = dx[1]*dx[2]*cutinv*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; + H[3] = dx[2] * hinv; + H[4] = 0.5 * dx[0] * dx[0] * hsqinv; + H[5] = 0.5 * dx[1] * dx[1] * hsqinv; + H[6] = 0.5 * dx[2] * dx[2] * hsqinv; + H[7] = dx[0] * dx[1] * hsqinv; + H[8] = dx[0] * dx[2] * hsqinv; + H[9] = dx[1] * dx[2] * hsqinv; } // dWij[] = dWx dWy (dWz) @@ -497,7 +472,7 @@ void ComputeRHEOKernel::calc_dw_crk2(int i, int j, double delx, double dely, dou dW[a] = 0.0; for (b = 0; b < Mdim; b++) { //First derivative kernels - dW[a] += C[i][1+a][b]*H[b]; // C columns: 1 x y (z) xx yy (zz) + dW[a] += C[i][1 + a][b] * H[b]; // C columns: 1 x y (z) xx yy (zz) } dW[a] *= w; } @@ -510,21 +485,21 @@ void ComputeRHEOKernel::compute_peratom() gsl_error_flag = 0; gsl_error_tags.clear(); - int i, j, ii, jj, jnum, itype, jtype; - double xtmp, ytmp, ztmp, delx, dely, delz; - double r, rinv, rsq, imass, jmass; + int i, j, ii, jj, jnum, g, a, b, gsl_error; + double xtmp, ytmp, ztmp, r, rsq, w, vj; double dx[3]; - double w, wp, s, vi, vj, M, vjw; - double vjdw[3] = {0}; - bool sflag; + gsl_matrix_view gM; + + // Turn off GSL error handler, revert RK to Quintic when insufficient neighbors + gsl_set_error_handler_off(); double **x = atom->x; int *type = atom->type; double *mass = atom->mass; double *rho = atom->rho; - int *phase = atom->phase; + int *status = atom->status; + int *coordination = atom->ivector[index_coord]; tagint *tag = atom->tag; - coordination = atom->ivector[index_coord]; int inum, *ilist, *jlist, *numneigh, **firstneigh; inum = list->inum; @@ -532,17 +507,29 @@ void ComputeRHEOKernel::compute_peratom() numneigh = list->numneigh; firstneigh = list->firstneigh; - if (kernel_type == QUINTIC) { + // Grow arrays if necessary + int nmax = atom->nmax; + if (nmax_old < nmax) + memory->grow(coordination, nmax, "atom:rheo_coordination"); + if (kernel_type == FixRHEO::CRK0) { + memory->grow(C0, nmax, "rheo/kernel:C0"); + } else if (correction_order > 0) { + memory->grow(C, nmax, ncor, Mdim, "rheo/kernel:C"); + } + + nmax_old = atom->nmax; + } + + if (kernel_type == FixRHEO::QUINTIC) { for (ii = 0; ii < inum; ii++) { i = ilist[ii]; xtmp = x[i][0]; ytmp = x[i][1]; - ztmp = x[i][2]; // Will be ignored in 2D + ztmp = x[i][2]; jlist = firstneigh[i]; jnum = numneigh[i]; - itype = type[i]; coordination[i] = 0; for (jj = 0; jj < jnum; jj++) { @@ -552,42 +539,28 @@ void ComputeRHEOKernel::compute_peratom() dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; + rsq = lensq(dx); - rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; - r = sqrt(rsq); - rinv = 1/r; - - if (rsq < cutsq) { + if (rsq < hsq) { coordination[i] += 1; } } } + } else if (kernel_type == FixRHEO::CRK0) { - comm->forward_comm_compute(this); + double M; - } else if (kernel_type == CRK0) { - if (atom->nmax > nmax){ - nmax = atom->nmax; - memory->destroy(C0); - memory->create(C0, nmax, "rheo/kernel:C"); - } - - //The moment Matrix array has to be 1D to be compatible with gsl - // Solve linear system for each atom for (ii = 0; ii < inum; ii++) { i = ilist[ii]; xtmp = x[i][0]; ytmp = x[i][1]; - ztmp = x[i][2]; // Will be ignored in 2D + ztmp = x[i][2]; jlist = firstneigh[i]; jnum = numneigh[i]; - itype = type[i]; - //Initialize M and H to zero: + //Initialize M to zero: M = 0; - - //variable for insufficient neighbors coordination[i] = 0; for (jj = 0; jj < jnum; jj++) { @@ -597,85 +570,45 @@ void ComputeRHEOKernel::compute_peratom() dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; + rsq = lensq(dx); - rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; - r = sqrt(rsq); - rinv = 1/r; - - if (rsq < cutsq) { - //Compute Wij + if (rsq < hsq) { + r = sqrt(rsq); w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); - if (phase[j] > FixRHEO::FLUID_MAX && solid_flag) - vj = mass[type[j]]/compute_solids->correct_rho(j,i); - else vj = mass[type[j]]/rho[j]; - coordination[i] += 1; // Increment contributing neighbor + if (!(status[j] & FixRHEO::STATUS_FLUID) && solid_flag) { + vj = mass[type[j]] / compute_interface->correct_rho(j,i); + } else vj = mass[type[j]] / rho[j]; - M += w*vj; + coordination[i] += 1; + M += w * vj; } } - if (coordination[i] < N2min) continue; - //Get inverse of 1x1 matrix - M = 1.0/M; - C0[i] = M; + // Inverse of 1x1 matrix + if (coordination[i] >= zmin) C0[i] = 1.0 / M; } - - // communicate densities - maybe not needed for ghost atoms but just to be safe - // can remove in future once we determine they aren't necessary - comm->forward_comm_compute(this); - } else if (correction_order > 0) { - int i, j, ii, jj, jnum, itype, jtype; - int g, a, b, c, d, ib, ic, id, nperm; - double xtmp, ytmp, ztmp, delx, dely, delz; - double dx[3] = {0}; + // Moment matrix M and polynomial basis vector H (1d for gsl compatibility) + double H[Mdim], M[Mdim * Mdim]; - //Turn off GSL error handler so we can check and revert RK to Quintic - //when inssuficient neighbors - gsl_set_error_handler_off(); - - // Create Moment matrix M and polynomial basis vector H - //The moment Matrix array has to be 1D to be compatible with gsl - double H[Mdim], M[Mdim*Mdim]; - - if (atom->nmax > nmax){ - nmax = atom->nmax; - memory->destroy(C); - memory->create(C, nmax,ncor,Mdim, "rheo/kernel:C"); - } - - // Solve linear system for each atom for (ii = 0; ii < inum; ii++) { i = ilist[ii]; xtmp = x[i][0]; ytmp = x[i][1]; - ztmp = x[i][2]; // Will be ignored in 2D + ztmp = x[i][2]; jlist = firstneigh[i]; jnum = numneigh[i]; itype = type[i]; - //Initialize M and H to zero: + // Zero upper-triangle M and H (will be symmetric): for (a = 0; a < Mdim; a++) { for (b = a; b < Mdim; b++) { - //Just zero upper-triangle of M since it will be symmetric - M[a*Mdim+b] = 0; + M[a * Mdim + b] = 0; } } - //Zero moment - //variables for switching off RK caclulation if insufficient neighbors - sflag = 0; coordination[i] = 0; - // Loop over neighbors to populate elements of L - //m0[i] = 0.0; - - //Self contribution - //w = calc_w_quintic(i,i,0.,0.,0.,0.); - //m0[i] += w; - //vi = 1/vw[i]; - - vi = mass[type[i]]/rho[i]; // Overwritten if i is solid for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -685,94 +618,85 @@ void ComputeRHEOKernel::compute_peratom() dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; - rsq = dx[0]*dx[0] + dx[1]*dx[1] + dx[2]*dx[2]; - r = sqrt(rsq); - rinv = 1/r; + rsq = lensq(dx); if (rsq < cutsq) { - //Compute Wij + r = sqrt(rsq); w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); - //vj = 1/vw[j]; // - if (phase[i] > FixRHEO::FLUID_MAX && solid_flag) - vi = mass[type[i]]/compute_solids->correct_rho(i,j); - - if (phase[j] > FixRHEO::FLUID_MAX && solid_flag) - vj = mass[type[j]]/compute_solids->correct_rho(j,i); + if (status[j] > FixRHEO::FLUID_MAX && solid_flag) + vj = mass[type[j]]/compute_interface->correct_rho(j,i); else vj = mass[type[j]]/rho[j]; - //m0[i] += w; //Populate the H-vector of polynomials (2D) if (dim == 2) { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; - if (kernel_type == CRK2) { - H[3] = 0.5*dx[0]*dx[0]*cutinv*cutinv; - H[4] = 0.5*dx[1]*dx[1]*cutinv*cutinv; - H[5] = dx[0]*dx[1]*cutinv*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; + if (kernel_type == FixRHEO::CRK2) { + H[3] = 0.5 * dx[0] * dx[0] * hsqinv; + H[4] = 0.5 * dx[1] * dx[1] * hsqinv; + H[5] = dx[0] * dx[1] * hsqinv; } } else { H[0] = 1.0; - H[1] = dx[0]*cutinv; - H[2] = dx[1]*cutinv; - H[3] = dx[2]*cutinv; - if (kernel_type == CRK2) { - H[4] = 0.5*dx[0]*dx[0]*cutinv*cutinv; - H[5] = 0.5*dx[1]*dx[1]*cutinv*cutinv; - H[6] = 0.5*dx[2]*dx[2]*cutinv*cutinv; - H[7] = dx[0]*dx[1]*cutinv*cutinv; - H[8] = dx[0]*dx[2]*cutinv*cutinv; - H[9] = dx[1]*dx[2]*cutinv*cutinv; + H[1] = dx[0] * hinv; + H[2] = dx[1] * hinv; + H[3] = dx[2] * hinv; + if (kernel_type == FixRHEO::CRK2) { + H[4] = 0.5 * dx[0] * dx[0] * hsqinv; + H[5] = 0.5 * dx[1] * dx[1] * hsqinv; + H[6] = 0.5 * dx[2] * dx[2] * hsqinv; + H[7] = dx[0] * dx[1] * hsqinv; + H[8] = dx[0] * dx[2] * hsqinv; + H[9] = dx[1] * dx[2] * hsqinv; } } - coordination[i] += 1; // Increment contributing neighbor - //Populate the upper triangle of the + coordination[i] += 1; + + // Populate the upper triangle for (a = 0; a < Mdim; a++) { for (b = a; b < Mdim; b++) { - M[a*Mdim+b] += H[a]*H[b]*w*vj; + M[a * Mdim + b] += H[a] * H[b] * w * vj; } } } } - //Now populate the lower triangle from the symmetric entries of M: + + // Populate the lower triangle from the symmetric entries of M: for (a = 0; a < Mdim; a++) { for (b = a; b < Mdim; b++) { - M[b*Mdim+a] = M[a*Mdim+b]; + M[b * Mdim + a] = M[a * Mdim + b]; } } - if (coordination[i] < N2min) continue; + // Skip if undercoordinated + if (coordination[i] < zmin) continue - //Use gsl to get Minv - //Since the polynomials are independent, M is symmetrix & positive-definite - //So we will use a Cholesky decomposition - gsl_matrix_view gM = gsl_matrix_view_array(M,Mdim,Mdim); - int status; - status = 0; - //gsl_linalg_cholesky_decomp1 -> gsl_linalg_cholesky_decomp - //So I don't have to update my gsl (me being lazy, can revert) - status = gsl_linalg_cholesky_decomp(&gM.matrix); //M is now the cholesky decomposition of M - // check if erro in inversion - if (status) { + // Use gsl to get Minv, use Cholesky decomposition since the + // polynomials are independent, M is symmetrix & positive-definite + gM = gsl_matrix_view_array(M,Mdim,Mdim); + gsl_error = gsl_linalg_cholesky_decomp(&gM.matrix); + + if (gsl_error) { //Revert to uncorrected SPH for this particle gsl_error_flag = 1; gsl_error_tags.insert(tag[i]); //check if not positive-definite - if (status != GSL_EDOM) - fprintf(stderr, "failed, gsl_errno=%d.n", status); + if (gsl_error != GSL_EDOM) + error->warn(FLERR, "Failed decomposition in rheo/kernel, gsl_error = {}", gsl_error); continue; - } else { - gsl_linalg_cholesky_invert(&gM.matrix); //M is now M^-1 } - // Correction coefficients are just the columns of M^-1 multiplied by an appropriate coefficient - //Solve the linear system several times to get coefficientns + gsl_linalg_cholesky_invert(&gM.matrix); //M is now M^-1 + + // Correction coefficients are columns of M^-1 multiplied by an appropriate coefficient + // Solve the linear system several times to get coefficientns // M: 1 x y (z) x^2 y^2 (z^2) xy (xz) (yz) - //---------------------------------------------------------- + // ---------------------------------------------------------- // 0 1 2 3 4 5 || 2D indexing // 0 1 2 3 4 5 6 7 8 9 || 3D indexing // W 1 . . . . . . . . . @@ -786,25 +710,25 @@ void ComputeRHEOKernel::compute_peratom() //0 1 2 3 4 //0 1 2 3 4 5 6 - // Use coefficents to compute smoothed density - //Pack coefficients into C + // Pack coefficients into C for (a = 0; a < Mdim; a++) { - //W - C[i][0][a] = M[a*Mdim + 0]; // all rows of column 0 + C[i][0][a] = M[a * Mdim + 0]; // all rows of column 0 for (b = 0; b < dim; b++) { //First derivatives - C[i][1+b][a] = -M[a*Mdim + b+1]/cut; // columns 1-2 (2D) or 1-3 (3D) + C[i][1 + b][a] = -M[a * Mdim + b + 1] * hinv; + // columns 1-2 (2D) or 1-3 (3D) + //Second derivatives - if (kernel_type == CRK2) - C[i][1+dim+b][a] = M[a*Mdim + b+1+dim]/cutsq; // columns 3-4 (2D) or 4-6 (3D) + if (kernel_type == FixRHEO::CRK2) + C[i][1 + dim + b][a] = M[a * Mdim + b + 1 + dim] * hsqinv; + // columns 3-4 (2D) or 4-6 (3D) } } } - - // communicate densities - maybe not needed for ghost atoms but just to be safe - // can remove in future once we determine they aren't necessary - comm->forward_comm_compute(this); } + + // communicate calculated quantities + comm->forward_comm_compute(this); } /* ---------------------------------------------------------------------- */ @@ -825,7 +749,7 @@ int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf, } buf[m++] = coordination[j]; } - } else if (kernel_type == CRK0) { + } else if (kernel_type == FixRHEO::CRK0) { for (i = 0; i < n; i++) { j = list[i]; buf[m++] = C0[j]; @@ -857,7 +781,7 @@ void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) } coordination[i] = buf[m++]; } - } else if (kernel_type == CRK0) { + } else if (kernel_type == FixRHEO::CRK0) { for (i = first; i < last; i++) { C0[i] = buf[m++]; coordination[i] = buf[m++]; diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index 114f39e85e..346df5a20c 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -21,6 +21,7 @@ ComputeStyle(rheo/kernel,ComputeRHEOKernel) #define LMP_COMPUTE_RHEO_KERNEL_H #include "compute.h" +#include namespace LAMMPS_NS { @@ -45,15 +46,16 @@ class ComputeRHEOKernel : public Compute { private: int solid_flag; int gsl_error_flag; + std::unordered_set gsl_error_tags; - int kernel_type, N2min, nmax, Mdim, ncor; + int kernel_style, zmin, dim, Mdim, ncor; int nmax_old, index_coord; - double cut, cutsq, cutinv, h, ih, ihsq, pre_w, pre_wp; + double h, hsq, hinv, hsqinv, pre_w, pre_wp; double ***C; double *C0; class NeighList *list; - class ComputeRHEOSolids *compute_solids; + class ComputeRHEOInterface *compute_interface; class FixRHEO *fix_rheo; int check_corrections(int); From bfb3457b9e1dfab7fedd6e4c328318914f38302b Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 26 Mar 2023 14:44:01 -0600 Subject: [PATCH 019/104] Adding memory usage --- src/RHEO/compute_rheo_kernel.cpp | 15 +++++++++++++++ src/RHEO/fix_rheo_pressure.cpp | 11 ++++++++++- src/RHEO/fix_rheo_pressure.h | 1 + src/RHEO/fix_rheo_thermal.cpp | 9 +++++++++ src/RHEO/fix_rheo_thermal.h | 1 + src/RHEO/fix_rheo_viscosity.cpp | 9 +++++++++ src/RHEO/fix_rheo_viscosity.h | 1 + 7 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 62a4283977..a3f7ed3da5 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -792,3 +792,18 @@ void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) } } } + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::memory_usage() +{ + double bytes = 0.0; + bytes = (size_t) atom->nmax * sizeof(int); + + if (kernel_type == FixRHEO::CRK0) { + bytes += (size_t) atom->nmax * sizeof(double); + } else if (correction_order > 0) { + bytes += (size_t) atom->nmax * ncor * Mdim * sizeof(double); + } + return bytes; +} diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index e4c1c44163..0a92e10767 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -203,4 +203,13 @@ double FixRHEOPressure::calculate_p(double rho) p = csq * rho0 * inv7 * (rr3 * rr3 * rho_ratio - 1.0); } return rho; -} \ No newline at end of file +} + +/* ---------------------------------------------------------------------- */ + +double FixRHEOPressure::memory_usage() +{ + double bytes = 0.0; + bytes += (size_t) atom->nmax * sizeof(double); + return bytes; +} diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h index 6c7ee73370..8272cc38f5 100644 --- a/src/RHEO/fix_rheo_pressure.h +++ b/src/RHEO/fix_rheo_pressure.h @@ -34,6 +34,7 @@ class FixRHEOPressure : public Fix { void pre_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; + double memory_usage() override; double calculate_p(double); private: double c_cubic, csq, rho0, rho0inv; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 8b0c9e46de..c8171f9beb 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -432,3 +432,12 @@ void FixRHEOThermal::unpack_reverse_comm(int n, int *list, double *buf) for (int i = 0; i < n; i++) heatflow[list[i]] += buf[m++]; } + +/* ---------------------------------------------------------------------- */ + +double FixRHEOThermal::memory_usage() +{ + double bytes = 0.0; + bytes += (size_t) atom->nmax * sizeof(double); + return bytes; +} diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index d9a17ebd60..3b62e86fa8 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -41,6 +41,7 @@ class FixRHEOThermal : public Fix { void unpack_forward_comm(int, int, double *) override; int pack_reverse_comm(int, int, double *) override; void unpack_reverse_comm(int, int *, double *) override; + double memory_usage() override; private: double *cv_type, cv; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 2b63c7633b..d81a1e9b4f 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -250,3 +250,12 @@ void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) viscosity[i] = buf[m++]; } } + +/* ---------------------------------------------------------------------- */ + +double FixRHEOViscosity::memory_usage() +{ + double bytes = 0.0; + bytes += (size_t) atom->nmax * sizeof(double); + return bytes; +} diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h index d531507a72..407170f668 100644 --- a/src/RHEO/fix_rheo_viscosity.h +++ b/src/RHEO/fix_rheo_viscosity.h @@ -35,6 +35,7 @@ class FixRHEOViscosity : public Fix { void pre_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; + double memory_usage() override; private: double *eta_type, eta; From 79ddd1445f051fdc7c78bb03123855a94bef2ad9 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 26 Mar 2023 17:04:56 -0600 Subject: [PATCH 020/104] Misc clean ups, initial draft of interface --- src/RHEO/atom_vec_rheo.cpp | 5 + src/RHEO/compute_rheo_grad.cpp | 27 +- src/RHEO/compute_rheo_grad.h | 1 + src/RHEO/compute_rheo_interface.cpp | 432 ++++++++++++++++++++++++++++ src/RHEO/compute_rheo_interface.h | 61 ++++ src/RHEO/compute_rheo_kernel.cpp | 29 +- src/RHEO/compute_rheo_vshift.cpp | 95 +++--- src/RHEO/compute_rheo_vshift.h | 7 +- src/RHEO/fix_rheo.cpp | 9 +- src/RHEO/fix_rheo_pressure.cpp | 11 +- src/RHEO/fix_rheo_thermal.cpp | 11 +- src/RHEO/fix_rheo_viscosity.cpp | 11 +- src/RHEO/pair_rheo.cpp | 5 + 13 files changed, 634 insertions(+), 70 deletions(-) create mode 100644 src/RHEO/compute_rheo_interface.cpp create mode 100644 src/RHEO/compute_rheo_interface.h diff --git a/src/RHEO/atom_vec_rheo.cpp b/src/RHEO/atom_vec_rheo.cpp index 9effad685c..a8496a18e9 100644 --- a/src/RHEO/atom_vec_rheo.cpp +++ b/src/RHEO/atom_vec_rheo.cpp @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + #include "atom_vec_rheo.h" #include "atom.h" diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index ce351048be..03e76b194a 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + #include "compute_rheo_grad.h" #include "atom.h" @@ -457,4 +462,24 @@ void ComputeRHEOGrad::grow_arrays(int nmax) if (eta_flag) memory->grow(gradn, nmax, dim, "atom:rheo_grad_eta"); nmax_old = nmax; -} \ No newline at end of file +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::memory_usage() +{ + double bytes = 0.0; + if (velocity_flag) + bytes = (size_t) nmax_old * dim * dim * sizeof(double); + + if (rho_flag) + bytes = (size_t) nmax_old * dim * sizeof(double); + + if (temperature_flag) + bytes = (size_t) nmax_old * dim * sizeof(double); + + if (eta_flag) + bytes = (size_t) nmax_old * dim * sizeof(double); + + return bytes; +} diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index 220b5813e3..d86efe47ee 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -35,6 +35,7 @@ class ComputeRHEOGrad : public Compute { void unpack_forward_comm(int, int, double *) override; int pack_reverse_comm(int, int, double *) override; void unpack_reverse_comm(int, int *, double *) override; + double memory_usage() override; void forward_gradients(); void forward_fields(); double **gradv; diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp new file mode 100644 index 0000000000..e76e46d422 --- /dev/null +++ b/src/RHEO/compute_rheo_interface.cpp @@ -0,0 +1,432 @@ +/* ---------------------------------------------------------------------- + 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 authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + +#include "compute_rheo_interface.h" + +#include "fix_rheo.h" +#include "compute_rheo_kernel.h" +#include "fix_store.h" +#include "fix.h" +#include +#include +#include "atom.h" +#include "update.h" +#include "modify.h" +#include "domain.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "force.h" +#include "pair.h" +#include "comm.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; + +#define EPSILON 1e-1 + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOInterface::ComputeRHEOInterface(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), + id_fix_chi(nullptr) +{ + if (narg != 4) error->all(FLERR,"Illegal compute RHEO/chi command"); + + cut = utils::numeric(FLERR,arg[3],false,lmp); + cutsq = cut*cut; + + wall_max = sqrt(3)/12.0*cut; + + nmax = 0; + + comm_forward = 3; + comm_reverse = 4; + + fix_chi = nullptr; + norm = nullptr; + normwf = nullptr; + + // new id = fix-ID + FIX_STORE_ATTRIBUTE + // new fix group = group for this fix + + id_fix_chi = nullptr; + std::string fixcmd = id + std::string("_chi"); + id_fix_chi = new char[fixcmd.size()+1]; + strcpy(id_fix_chi,fixcmd.c_str()); + fixcmd += fmt::format(" all STORE peratom 0 {}", 1); + modify->add_fix(fixcmd); + fix_chi = (FixStore *) modify->fix[modify->nfix-1]; + chi = fix_chi->vstore; +} + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOInterface::~ComputeRHEOInterface() +{ + if (id_fix_chi && modify->nfix) modify->delete_fix(id_fix_chi); + if (modify->nfix) modify->delete_fix("PROPERTY_ATOM_COMP_RHEO_SOLIDS"); + + memory->destroy(norm); + memory->destroy(normwf); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOInterface::init() +{ + // 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 = 1; + neighbor->requests[irequest]->full = 0; + //neighbor->requests[irequest]->occasional = 1; //Anticipate needing regulalry + + int icompute = modify->find_compute("rheo_kernel"); + if (icompute == -1) error->all(FLERR, "Using compute/RHEO/chi without compute/RHEO/kernel"); + + compute_kernel = ((ComputeRHEOKernel *) modify->compute[icompute]); + + //Store persistent per atom quantities - need to be exchanged + char **fixarg = new char*[8]; + fixarg[0] = (char *) "PROPERTY_ATOM_COMP_RHEO_SOLIDS"; + fixarg[1] = (char *) "all"; + fixarg[2] = (char *) "property/atom"; + fixarg[3] = (char *) "d_fx"; + fixarg[4] = (char *) "d_fy"; + fixarg[5] = (char *) "d_fz"; + fixarg[6] = (char *) "ghost"; + fixarg[7] = (char *) "yes"; + modify->add_fix(8,fixarg,1); + delete [] fixarg; + + int temp_flag; + index_fx = atom->find_custom("fx", temp_flag); + if ((index_fx < 0) || (temp_flag != 1)) + error->all(FLERR, "Compute rheo/solids can't find fix property/atom fx"); + index_fy = atom->find_custom("fy", temp_flag); + if ((index_fy < 0) || (temp_flag != 1)) + error->all(FLERR, "Compute rheo/solids can't find fix property/atom fy"); + index_fz = atom->find_custom("fz", temp_flag); + if ((index_fz < 0) || (temp_flag != 1)) + error->all(FLERR, "Compute rheo/solids can't find fix property/atom fz"); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOInterface::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOInterface::compute_peratom() +{ + int i, j, ii, jj, jnum, itype, jtype, phase_match; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + int *jlist; + double w; + + // neighbor list ariables + int inum, *ilist, *numneigh, **firstneigh; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + + double **x = atom->x; + int *type = atom->type; + int newton = force->newton; + int *phase = atom->phase; + double *rho = atom->rho; + double *fx = atom->dvector[index_fx]; + double *fy = atom->dvector[index_fy]; + double *fz = atom->dvector[index_fz]; + double mi, mj; + + //Declare mass pointer to calculate acceleration from force + double *mass = atom->mass; + + cs2 = 1.0; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + if (atom->nmax > nmax) { + nmax = atom->nmax; + fix_chi->grow_arrays(nmax); + chi = fix_chi->vstore; + memory->destroy(norm); + memory->destroy(normwf); + memory->create(norm, nmax, "RHEO/chi:norm"); + memory->create(normwf, nmax, "RHEO/chi:normwf"); + } + + for (i = 0; i < nall; i++) { + if (phase[i] > FixRHEO::FLUID_MAX) rho[i] = 0.0; + normwf[i] = 0.0; + norm[i] = 0.0; + chi[i] = 0.0; + } + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + mi = mass[type[i]]; + + 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) { + jtype = type[j]; + mj = mass[type[j]]; + w = compute_kernel->calc_w_quintic(i, j, delx, dely, delz, sqrt(rsq)); + + phase_match = 0; + norm[i] += w; + if ((phase[i] <= FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) + || (phase[i] > FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX)) { + phase_match = 1; + } + + if (phase_match) { + chi[i] += w; + } else { + if (phase[i] > FixRHEO::FLUID_MAX) { + //speed of sound and rho0 assumed to = 1 (units in density not pressure) + //In general, rho is calculated using the force vector on the wall particle + //fx stores f-fp + rho[i] += w*(cs2*(rho[j] - 1.0) - rho[j]*((-fx[j]/mj+fx[i]/mi)*delx + (-fy[j]/mj+fy[i]/mi)*dely + (-fz[j]/mj+fz[i]/mi)*delz)); + //For the specific taste case whre force on wall particles = 0 + //rho[i] += w*(1.0*(rho[j] - 1.0) + rho[j]*(1e-3*delx)); + normwf[i] += w; + } + } + + if (newton || j < nlocal) { + norm[j] += w; + if (phase_match) { + chi[j] += w; + } else { + if (phase[j] > FixRHEO::FLUID_MAX) { + rho[j] += w*(cs2*(rho[i] - 1.0) + rho[i]*((-fx[i]/mi+fx[j]/mj)*delx + (-fy[i]/mi+fy[j]/mj)*dely + (-fz[i]/mi+fz[j]/mj)*delz)); + normwf[j] += w; + } + } + } + } + } + } + + if (newton) comm->reverse_comm_compute(this); + + for (i = 0; i < nlocal; i++) { + if (norm[i] != 0.0) chi[i] /= norm[i]; + if (normwf[i] != 0.0) { // Only if it's a wall particle + rho[i] = 1.0 + (rho[i] / normwf[i])/cs2; // Stores rho for solid particles 1+Pw in Adami Adams 2012 + if (rho[i] < EPSILON) rho[i] = EPSILON; + } + + if (normwf[i] == 0.0 && phase[i] > FixRHEO::FLUID_MAX) rho[i] = 1.0; + } + + comm_stage = 1; + comm_forward = 2; + comm->forward_comm_compute(this); +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOInterface::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i,j,k,m; + m = 0; + double *rho = atom->rho; + double *fx = atom->dvector[index_fx]; + double *fy = atom->dvector[index_fy]; + double *fz = atom->dvector[index_fz]; + + for (i = 0; i < n; i++) { + j = list[i]; + if (comm_stage == 0) { + buf[m++] = fx[j]; + buf[m++] = fy[j]; + buf[m++] = fz[j]; + } else { + buf[m++] = chi[j]; + buf[m++] = rho[j]; + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOInterface::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double *rho = atom->rho; + double *fx = atom->dvector[index_fx]; + double *fy = atom->dvector[index_fy]; + double *fz = atom->dvector[index_fz]; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (comm_stage == 0) { + fx[i] = buf[m++]; + fy[i] = buf[m++]; + fz[i] = buf[m++]; + } else { + chi[i] = buf[m++]; + rho[i] = buf[m++]; // Won't do anything for fluids + } + } +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOInterface::pack_reverse_comm(int n, int first, double *buf) +{ + int i,k,m,last; + double *rho = atom->rho; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = norm[i]; + buf[m++] = chi[i]; + buf[m++] = normwf[i]; + buf[m++] = rho[i]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i,k,j,m; + double *rho = atom->rho; + int *phase = atom->phase; + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + norm[j] += buf[m++]; + chi[j] += buf[m++]; + if (phase[j] > FixRHEO::FLUID_MAX){ + normwf[j] += buf[m++]; + rho[j] += buf[m++]; + } else { + m++; + m++; + } + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOInterface::correct_v(double *vi, double *vj, double *vi_out, int i, int j) +{ + double wall_prefactor, wall_denom, wall_numer; + + wall_numer = 2.0*cut*(chi[i]-0.5); + if (wall_numer < 0) wall_numer = 0; + wall_denom = 2.0*cut*(chi[j]-0.5); + if (wall_denom < wall_max) wall_denom = wall_max; + + wall_prefactor = wall_numer / wall_denom; + + vi_out[0] = (vi[0]-vj[0])*wall_prefactor + vi[0]; + vi_out[1] = (vi[1]-vj[1])*wall_prefactor + vi[1]; + vi_out[2] = (vi[2]-vj[2])*wall_prefactor + vi[2]; +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOInterface::correct_rho(int i, int j) // i is wall, j is fluid +{ + //In future may depend on atom type j's pressure equation + return atom->rho[i]; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOInterface::store_forces() +{ + double *fx = atom->dvector[index_fx]; + double *fy = atom->dvector[index_fy]; + double *fz = atom->dvector[index_fz]; + double **f = atom->f; + double **fp = atom->fp; + int *mask = atom->mask; + + int flag; + int ifix = modify->find_fix_by_style("setforce"); + if (ifix != -1) { + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & modify->fix[ifix]->groupbit) { + fx[i] = f[i][0]; + fy[i] = f[i][1]; + fz[i] = f[i][2]; + } else { + fx[i] = f[i][0] - fp[i][0]; + fy[i] = f[i][1] - fp[i][1]; + fz[i] = f[i][2] - fp[i][2]; + } + } + } else { + for (int i = 0; i < atom->nlocal; i++) { + fx[i] = f[i][0] - fp[i][0]; + fy[i] = f[i][1] - fp[i][1]; + fz[i] = f[i][2] - fp[i][2]; + } + } + + //Forward comm forces -note only needed here b/c property atom will forward otherwise + comm_forward = 3; + comm_stage = 0; + comm->forward_comm_compute(this); +} + + +/* ---------------------------------------------------------------------- + memory usage of local atom-based array +------------------------------------------------------------------------- */ + +double ComputeRHEOInterface::memory_usage() +{ + double bytes = nmax * sizeof(double); + return bytes; +} + diff --git a/src/RHEO/compute_rheo_interface.h b/src/RHEO/compute_rheo_interface.h new file mode 100644 index 0000000000..635f190aed --- /dev/null +++ b/src/RHEO/compute_rheo_interface.h @@ -0,0 +1,61 @@ +/* -*- 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 COMPUTE_CLASS +// clang-format off +ComputeStyle(rheo/interface,ComputeRHEOInterface) +// clang-format on +#else + +#ifndef LMP_COMPUTE_RHEO_INTERFACE_H +#define LMP_COMPUTE_RHEO_INTERFACE_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeRHEOInterface : public Compute { + public: + ComputeRHEOInterface(class LAMMPS *, int, char **); + ~ComputeRHEOInterface(); + void init(); + void init_list(int, class NeighList *); + void compute_peratom(); + int pack_forward_comm(int, int *, double *, int, int *); + void unpack_forward_comm(int, int, double *); + int pack_reverse_comm(int, int, double *); + void unpack_reverse_comm(int, int *, double *); + void correct_v(double *, double *, double *, int, int); + double correct_rho(int, int); + double memory_usage(); + void store_forces(); + double *chi; + + private: + int nmax; + double cut, cutsq, cs2; + class NeighList *list; + double *norm, *normwf, wall_max; + + class ComputeRHEOKernel *compute_kernel; + char *id_fix_chi; + class FixStore *fix_chi; + + int index_fx, index_fy, index_fz; + int comm_stage; +}; + +} + +#endif +#endif diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index a3f7ed3da5..15b5f9568b 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -1,15 +1,20 @@ /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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. + 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. -------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. + ------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ #include "compute_rheo_kernel.h" @@ -798,12 +803,12 @@ void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) double ComputeRHEOKernel::memory_usage() { double bytes = 0.0; - bytes = (size_t) atom->nmax * sizeof(int); + bytes = (size_t) nmax_old * sizeof(int); if (kernel_type == FixRHEO::CRK0) { - bytes += (size_t) atom->nmax * sizeof(double); + bytes += (size_t) nmax_old * sizeof(double); } else if (correction_order > 0) { - bytes += (size_t) atom->nmax * ncor * Mdim * sizeof(double); + bytes += (size_t) nmax_old * ncor * Mdim * sizeof(double); } return bytes; } diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 42fa1e8c82..2b7c9394d3 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -1,35 +1,36 @@ /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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. + 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. -------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. + ------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ #include "compute_rheo_vshift.h" -#include "fix_rheo.h" -#include "compute_rheo_solids.h" + +#include "atom.h" +#include "comm.h" +#include "compute_rheo_interface.h" #include "compute_rheo_grad.h" #include "compute_rheo_kernel.h" -#include "fix_rheo_surface.h" -#include -#include -#include "atom.h" -#include "modify.h" #include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "memory.h" #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" -#include "force.h" -#include "pair.h" -#include "comm.h" -#include "memory.h" -#include "error.h" using namespace LAMMPS_NS; @@ -44,18 +45,28 @@ ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) : comm_reverse = 3; surface_flag = 0; - nmax = atom->nmax; - memory->create(vshift, nmax, 3, "rheo/vshift:vshift"); - array_atom = vshift; - peratom_flag = 1; - size_peratom_cols = 3; + // Create vshift array if it doesn't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded + + int tmp1, tmp2; + index_vshift = atom->find_custom("rheo_vshift", tmp1, tmp2); + if (index_vshift == -1) { + index_vshift = atom->add_custom("rheo_vshift", 1, 3); + nmax_old = atom->nmax; + } } /* ---------------------------------------------------------------------- */ ComputeRHEOVShift::~ComputeRHEOVShift() { - memory->destroy(vshift); + // Remove custom property if it exists + int tmp1, tmp2, index; + index = atom->find_custom("rheo_vshift", tmp1, tmp2); + if (index != -1) atom->remove_custom(index_vshift, 1, 3); + } /* ---------------------------------------------------------------------- */ @@ -65,10 +76,8 @@ void ComputeRHEOVShift::init() neighbor->add_request(this, NeighConst::REQ_DEFAULT); surface_flag = 0; - if (fix_rheo->surface_flag) { + if (fix_rheo->surface_flag) surface_flag = 1; - fix_rheo_surface = fix_rheo->fix_rheo_surface; - } compute_kernel = fix_rheo->compute_kernel; compute_grad = fix_rheo->compute_grad; @@ -110,6 +119,7 @@ void ComputeRHEOVShift::compute_peratom() int *surface = atom->surface; double *rho = atom->rho; double *mass = atom->mass; + double **vshift = atom->darray[index_vshift]; int newton_pair = force->newton_pair; inum = list->inum; @@ -117,12 +127,10 @@ void ComputeRHEOVShift::compute_peratom() numneigh = list->numneigh; firstneigh = list->firstneigh; - if (nall > nmax) { - nmax = nall; - memory->destroy(vshift); - memory->create(vshift, nmax, 3, "rheo/vshift:vshift"); - array_atom = vshift; - } + + if (nmax_old < atom->nmax) + memory->grow(vshift, atom->nmax, 3, "atom:rheo_vshift"); + nmax_old = atom->nmax; for (i = 0; i < nall; i++) for (a = 0; a < dim; a++) @@ -224,14 +232,17 @@ void ComputeRHEOVShift::correct_surfaces() int nlocal = atom->nlocal; int i, a, b; int dim = domain->dimension; - int *surface = atom->surface; + double **vshift = atom->darray[index_vshift]; + + int tmp1, tmp2; + int index_nsurf = atom->find_custom("rheo_nsurf", tmp1, tmp2); + if (index_nsurf == -1) error->all(FLERR, "Cannot find rheo nsurf"); + double **nsurf = atom->darray[index_nsurf]; - double **nsurf; - nsurf = fix_rheo_surface->n_surface; double nx,ny,nz,vx,vy,vz; for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if (surface[i] == 1 || surface[i] == 2) { + if ((surface[i] & FixRHEO::STATUS_SURFACE) || (surface[i] & FixRHEO::STATUS_LAYER)) { nx = nsurf[i][0]; ny = nsurf[i][1]; vx = vshift[i][0]; @@ -257,6 +268,7 @@ void ComputeRHEOVShift::correct_surfaces() int ComputeRHEOVShift::pack_reverse_comm(int n, int first, double *buf) { int i,m,last; + double **vshift = atom->darray[index_vshift]; m = 0; last = first + n; @@ -273,6 +285,7 @@ int ComputeRHEOVShift::pack_reverse_comm(int n, int first, double *buf) void ComputeRHEOVShift::unpack_reverse_comm(int n, int *list, double *buf) { int i,j,m; + double **vshift = atom->darray[index_vshift]; m = 0; for (i = 0; i < n; i++) { @@ -289,6 +302,6 @@ void ComputeRHEOVShift::unpack_reverse_comm(int n, int *list, double *buf) double ComputeRHEOVShift::memory_usage() { - double bytes = 3 * nmax * sizeof(double); + double bytes = 3 * nmax_old * sizeof(double); return bytes; } diff --git a/src/RHEO/compute_rheo_vshift.h b/src/RHEO/compute_rheo_vshift.h index fceb287510..f93cced31c 100644 --- a/src/RHEO/compute_rheo_vshift.h +++ b/src/RHEO/compute_rheo_vshift.h @@ -37,15 +37,12 @@ class ComputeRHEOVShift : public Compute { void correct_surfaces(); private: - int nmax; + int nmax_old; double dtv, cut, cutsq, cutthird; - int surface_flag; - - double **vshift; + int surface_flag, index_vshift; class NeighList *list; class FixRHEO *fix_rheo; - class FixRHEOSurface *fix_rheo_surface; class ComputeRHEOInterface *compute_interface ; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOGrad *compute_grad; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 6d16bf2782..25a97bd52a 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -1,7 +1,7 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + #include "fix_rheo.h" #include "atom.h" diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 0a92e10767..4fa4ece0f9 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -1,7 +1,7 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + #include "fix_rheo_pressure.h" #include "atom.h" @@ -210,6 +215,6 @@ double FixRHEOPressure::calculate_p(double rho) double FixRHEOPressure::memory_usage() { double bytes = 0.0; - bytes += (size_t) atom->nmax * sizeof(double); + bytes += (size_t) nmax_old * sizeof(double); return bytes; } diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index c8171f9beb..3ef9fab853 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -1,7 +1,7 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + #include "fix_rheo_thermal.h" #include "atom.h" @@ -438,6 +443,6 @@ void FixRHEOThermal::unpack_reverse_comm(int n, int *list, double *buf) double FixRHEOThermal::memory_usage() { double bytes = 0.0; - bytes += (size_t) atom->nmax * sizeof(double); + bytes += (size_t) nmax_old * sizeof(double); return bytes; } diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index d81a1e9b4f..3f779aa3c6 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -1,7 +1,7 @@ /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + #include "fix_rheo_viscosity.h" #include "atom.h" @@ -256,6 +261,6 @@ void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) double FixRHEOViscosity::memory_usage() { double bytes = 0.0; - bytes += (size_t) atom->nmax * sizeof(double); + bytes += (size_t) nmax_old * sizeof(double); return bytes; } diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 0fed0297b4..7d5d0f425f 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + #include "pair_rheo.h" #include "atom.h" From 986cfd66414da8a9cf7cc4a09a19cf1f44a94dae Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 12 Apr 2023 17:05:05 -0600 Subject: [PATCH 021/104] Cleaning up peratom variables, adding peratom variables to fix rheo/interface --- src/RHEO/compute_rheo_grad.cpp | 72 +++++++++++------ src/RHEO/compute_rheo_grad.h | 2 - src/RHEO/compute_rheo_interface.cpp | 121 ++++++++++++---------------- src/RHEO/compute_rheo_interface.h | 39 +++++---- src/RHEO/compute_rheo_kernel.cpp | 16 ++-- src/RHEO/compute_rheo_kernel.h | 3 +- src/RHEO/compute_rheo_vshift.cpp | 21 ++--- src/RHEO/compute_rheo_vshift.h | 4 +- src/RHEO/fix_rheo.cpp | 5 +- src/RHEO/fix_rheo.h | 1 + src/RHEO/fix_rheo_pressure.cpp | 16 ++-- src/RHEO/fix_rheo_pressure.h | 3 +- src/RHEO/fix_rheo_thermal.cpp | 12 +-- src/RHEO/fix_rheo_thermal.h | 3 +- src/RHEO/fix_rheo_viscosity.cpp | 11 +-- src/RHEO/fix_rheo_viscosity.h | 3 +- src/RHEO/pair_rheo.cpp | 30 ++++--- src/RHEO/pair_rheo.h | 2 +- 18 files changed, 184 insertions(+), 180 deletions(-) diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 03e76b194a..31f60550c1 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -38,7 +38,7 @@ enum{COMMGRAD, COMMFIELD}; /* ---------------------------------------------------------------------- */ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), compute_interface(nullptr), compute_kernel(nullptr), + Compute(lmp, narg, arg), fix_rheo(nullptr), compute_interface(nullptr), compute_kernel(nullptr), gradv(nullptr), gradr(nullptr), gradt(nullptr), gradn(nullptr) { if (narg < 4) error->all(FLERR,"Illegal compute rheo/grad command"); @@ -61,40 +61,26 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : ncomm_grad += dim * dim; ncomm_field += dim; comm_reverse += dim * dim; - indexv = atom->add_custom("rheo_grad_v", 1, dim * dim); - gradv = atom->darray[indexv]; } if (rho_flag) { ncomm_grad += dim; ncomm_field += 1; comm_reverse += dim; - indexr = atom->add_custom("rheo_grad_rho", 1, dim); - gradr = atom->darray[indexr]; } if (temperature_flag) { ncomm_grad += dim; ncomm_field += 1; comm_reverse += dim; - indext= atom->add_custom("rheo_grad_temp", 1, dim); - gradt = atom->darray[indext]; } if (eta_flag) { ncomm_grad += dim; comm_reverse += dim; - indexn = atom->add_custom("rheo_grad_eta", 1, dim); - gradn = atom->darray[indexn]; } - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded - comm_forward = ncomm_grad; - nmax_old = 0; - grow_arrays(atom->nmax); } /* ---------------------------------------------------------------------- */ @@ -102,14 +88,16 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : ComputeRHEOGrad::~ComputeRHEOGrad() { int dim = domain->dimension; - if (velocity_flag) - atom->remove_custom(indexv, 1, dim * dim); - if (rho_flag) - atom->remove_custom(indexr, 1, dim); - if (temperature_flag) - atom->remove_custom(indext, 1, dim); - if (eta_flag) - atom->remove_custom(indexn, 1, dim); + int tmp1, tmp2, index; + + index = atom->find_custom("rheo_grad_v", tmp1, tmp2); + if (index != 1) atom->remove_custom(index, 1, dim * dim); + index = atom->find_custom("rheo_grad_rho", tmp1, tmp2); + if (index != 1) atom->remove_custom(index, 1, dim); + index = atom->find_custom("rheo_grad_t", tmp1, tmp2); + if (index != 1) atom->remove_custom(index, 1, dim); + index = atom->find_custom("rheo_grad_eta", tmp1, tmp2); + if (index != 1) atom->remove_custom(index, 1, dim); } /* ---------------------------------------------------------------------- */ @@ -123,6 +111,36 @@ void ComputeRHEOGrad::init() rho0 = fix_rheo->rho0; compute_kernel = fix_rheo->compute_kernel; compute_interface = fix_rheo->compute_interface; + + // Create coordination array if it doesn't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded + + int index; + int dim = domain->dimension; + if (velocity_flag) { + index = atom->add_custom("rheo_grad_v", 1, dim * dim); + gradv = atom->darray[index]; + } + + if (rho_flag) { + index = atom->add_custom("rheo_grad_rho", 1, dim); + gradr = atom->darray[index]; + } + + if (temperature_flag) { + index= atom->add_custom("rheo_grad_temp", 1, dim); + gradt = atom->darray[index]; + } + + if (eta_flag) { + index = atom->add_custom("rheo_grad_eta", 1, dim); + gradn = atom->darray[index]; + } + + nmax_old = 0; + grow_arrays(atom->nmax); } /* ---------------------------------------------------------------------- */ @@ -151,13 +169,17 @@ void ComputeRHEOGrad::compute_peratom() double **v = atom->v; double *rho = atom->rho; double *temperature = atom->temperature; - double *eta = atom->viscosity; int *status = atom->status; int *type = atom->type; double *mass = atom->mass; int newton = force->newton; int dim = domain->dimension; + int tmp1, tmp2; + int index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); + if (index_visc == -1) error->all(FLERR, "Cannot find rheo viscosity"); + double *viscosity = atom->dvector[index_visc]; + inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; @@ -229,7 +251,7 @@ void ComputeRHEOGrad::compute_peratom() if (rho_flag) drho = rhoi - rhoj; if (temperature_flag) dT = temperature[i] - temperature[j]; - if (eta_flag) deta = eta[i] - eta[j]; + if (eta_flag) deta = viscosity[i] - viscosity[j]; wp = compute_kernel->calc_dw(i, j, delx, dely, delz, sqrt(rsq)); dWij = compute_kernel->dWij; diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index d86efe47ee..7804ee72dd 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -42,11 +42,9 @@ class ComputeRHEOGrad : public Compute { double **gradr; double **gradt; double **gradn; - int stage; private: int comm_stage, ncomm_grad, ncomm_field, nmax_old; - int indexv, indexr, indext, indexn; double cut, cutsq, rho0; class NeighList *list; diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index e76e46d422..ae1bc13831 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -18,24 +18,20 @@ #include "compute_rheo_interface.h" -#include "fix_rheo.h" -#include "compute_rheo_kernel.h" -#include "fix_store.h" -#include "fix.h" -#include -#include #include "atom.h" -#include "update.h" -#include "modify.h" +#include "comm.h" #include "domain.h" +#include "compute_rheo_kernel.h" +#include "error.h" +#include "force.h" +#include "fix_rheo.h" +#include "memory.h" +#include "modify.h" #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" -#include "force.h" -#include "pair.h" -#include "comm.h" -#include "memory.h" -#include "error.h" + +#include using namespace LAMMPS_NS; @@ -44,45 +40,29 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeRHEOInterface::ComputeRHEOInterface(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - id_fix_chi(nullptr) + Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr), fx_m_norm(nullptr), + norm(nullptr), normwf(nullptr), chi(nullptr), f_pressure(nullptr), id_fix_pa(nullptr) { - if (narg != 4) error->all(FLERR,"Illegal compute RHEO/chi command"); - - cut = utils::numeric(FLERR,arg[3],false,lmp); - cutsq = cut*cut; - - wall_max = sqrt(3)/12.0*cut; + if (narg != 3) error->all(FLERR,"Illegal compute rheo/interface command"); nmax = 0; comm_forward = 3; comm_reverse = 4; - - fix_chi = nullptr; - norm = nullptr; - normwf = nullptr; - - // new id = fix-ID + FIX_STORE_ATTRIBUTE - // new fix group = group for this fix - - id_fix_chi = nullptr; - std::string fixcmd = id + std::string("_chi"); - id_fix_chi = new char[fixcmd.size()+1]; - strcpy(id_fix_chi,fixcmd.c_str()); - fixcmd += fmt::format(" all STORE peratom 0 {}", 1); - modify->add_fix(fixcmd); - fix_chi = (FixStore *) modify->fix[modify->nfix-1]; - chi = fix_chi->vstore; } /* ---------------------------------------------------------------------- */ ComputeRHEOInterface::~ComputeRHEOInterface() { - if (id_fix_chi && modify->nfix) modify->delete_fix(id_fix_chi); - if (modify->nfix) modify->delete_fix("PROPERTY_ATOM_COMP_RHEO_SOLIDS"); + // Remove custom property if it exists + int tmp1, tmp2, index; + index = atom->find_custom("rheo_chi", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 0); + if (id_fix_pa && modify->nfix) modify->delete_fix(id_fix_pa); + + memory->destroy(fx_m_norm); memory->destroy(norm); memory->destroy(normwf); } @@ -91,42 +71,40 @@ ComputeRHEOInterface::~ComputeRHEOInterface() void ComputeRHEOInterface::init() { - // 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 = 1; - neighbor->requests[irequest]->full = 0; - //neighbor->requests[irequest]->occasional = 1; //Anticipate needing regulalry + compute_kernel = fix_rheo->compute_kernel; + cut = fix_rheo->cut; + cutsq = cut * cut; + wall_max = sqrt(3.0) / 12.0 * cut; - int icompute = modify->find_compute("rheo_kernel"); - if (icompute == -1) error->all(FLERR, "Using compute/RHEO/chi without compute/RHEO/kernel"); + // Create chi array if it doesn't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded - compute_kernel = ((ComputeRHEOKernel *) modify->compute[icompute]); + int create_flag = 0; + int tmp1, tmp2; + int nmax = atom->nmax; + int index = atom->find_custom("rheo_chi", tmp1, tmp2); + if (index == -1) { + index = atom->add_custom("rheo_chi", 1, 0); + nmax_old = nmax; + } + chi = atom->dvector[index]; - //Store persistent per atom quantities - need to be exchanged - char **fixarg = new char*[8]; - fixarg[0] = (char *) "PROPERTY_ATOM_COMP_RHEO_SOLIDS"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "property/atom"; - fixarg[3] = (char *) "d_fx"; - fixarg[4] = (char *) "d_fy"; - fixarg[5] = (char *) "d_fz"; - fixarg[6] = (char *) "ghost"; - fixarg[7] = (char *) "yes"; - modify->add_fix(8,fixarg,1); - delete [] fixarg; + // For fpressure, go ahead and create an instance of fix property atom + // Need restarts + exchanging with neighbors since it needs to persist + // between timesteps (fix property atom will handle callbacks) - int temp_flag; - index_fx = atom->find_custom("fx", temp_flag); - if ((index_fx < 0) || (temp_flag != 1)) - error->all(FLERR, "Compute rheo/solids can't find fix property/atom fx"); - index_fy = atom->find_custom("fy", temp_flag); - if ((index_fy < 0) || (temp_flag != 1)) - error->all(FLERR, "Compute rheo/solids can't find fix property/atom fy"); - index_fz = atom->find_custom("fz", temp_flag); - if ((index_fz < 0) || (temp_flag != 1)) - error->all(FLERR, "Compute rheo/solids can't find fix property/atom fz"); + index = atom->find_custom("rheo_pressure", tmp1, tmp2); + if (index == -1) { + id_fix_pa = utils::strdup(id + std::string("_fix_property_atom")); + modify->add_fix(fmt::format("{} all property/atom d2_f_pressure 3", id_fix_pa))); + index = atom->find_custom("rheo_pressure", tmp1, tmp2); + } + f_pressure = atom->darray[index]; + + // need an occasional half neighbor list + neighbor->add_request(this, NeighConst::REQ_HALF); } /* ---------------------------------------------------------------------- */ @@ -138,6 +116,7 @@ void ComputeRHEOInterface::init_list(int /*id*/, NeighList *ptr) /* ---------------------------------------------------------------------- */ +// Left off here void ComputeRHEOInterface::compute_peratom() { int i, j, ii, jj, jnum, itype, jtype, phase_match; diff --git a/src/RHEO/compute_rheo_interface.h b/src/RHEO/compute_rheo_interface.h index 635f190aed..f314c16aa9 100644 --- a/src/RHEO/compute_rheo_interface.h +++ b/src/RHEO/compute_rheo_interface.h @@ -27,35 +27,34 @@ namespace LAMMPS_NS { class ComputeRHEOInterface : public Compute { public: ComputeRHEOInterface(class LAMMPS *, int, char **); - ~ComputeRHEOInterface(); - void init(); - void init_list(int, class NeighList *); - void compute_peratom(); - int pack_forward_comm(int, int *, double *, int, int *); - void unpack_forward_comm(int, int, double *); - int pack_reverse_comm(int, int, double *); - void unpack_reverse_comm(int, int *, double *); + ~ComputeRHEOInterface() override; + void init() override; + void init_list(int, class NeighList *) override; + void compute_peratom() override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; + double memory_usage() override; void correct_v(double *, double *, double *, int, int); double correct_rho(int, int); - double memory_usage(); void store_forces(); - double *chi; + + double *chi, **f_pressure; private: - int nmax; - double cut, cutsq, cs2; + int nmax_old, comm_stage; + double cut, cutsq, cs, wall_max; + double **fx_m_norm, *norm, *normwf; + + char *id_fix_pa; + class NeighList *list; - double *norm, *normwf, wall_max; - + class FixRHEO *fix_rheo; class ComputeRHEOKernel *compute_kernel; - char *id_fix_chi; - class FixStore *fix_chi; - - int index_fx, index_fy, index_fz; - int comm_stage; }; -} +} // namespace LAMMPS_NS #endif #endif diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 15b5f9568b..ac9ea75fc4 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -55,7 +55,7 @@ Move away from h notation, use cut? ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), - C(nullptr), C0(nullptr), compute_interface(nullptr); + C(nullptr), C0(nullptr), coordination(nullptr), compute_interface(nullptr) { if (narg != 3) error->all(FLERR,"Illegal compute rheo/kernel command"); @@ -71,7 +71,7 @@ ComputeRHEOKernel::~ComputeRHEOKernel() // Remove custom property if it exists int tmp1, tmp2, index; index = atom->find_custom("rheo_coordination", tmp1, tmp2); - if (index != -1) atom->remove_custom(index_coord, 1, 0); + if (index != -1) atom->remove_custom(index, 0, 0); memory->destroy(C); memory->destroy(C0); @@ -125,12 +125,14 @@ void ComputeRHEOKernel::init() int tmp1, tmp2; int nmax = atom->nmax; - index_coord = atom->find_custom("rheo_coordination", tmp1, tmp2); - if (index_coord == -1) { - index_coord = atom->add_custom("rheo_coordination", 0, 0); + int index = atom->find_custom("rheo_coordination", tmp1, tmp2); + if (index == -1) { + index = atom->add_custom("rheo_coordination", 0, 0); nmax_old = nmax; } + coordination = atom->ivector[index]; + // Create local arrays for kernel arrays, I can't foresee a reason to print comm_forward = 1; ncor = 0; Mdim = 0; @@ -170,7 +172,6 @@ int ComputeRHEOKernel::check_corrections(int i) corrections = 0; } - int *coordination = atom->ivector[index_coord]; if (coordination[i] < zmin) corrections = 0; return corrections; @@ -503,7 +504,6 @@ void ComputeRHEOKernel::compute_peratom() double *mass = atom->mass; double *rho = atom->rho; int *status = atom->status; - int *coordination = atom->ivector[index_coord]; tagint *tag = atom->tag; int inum, *ilist, *jlist, *numneigh, **firstneigh; @@ -742,7 +742,6 @@ int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,k,m,a,b; - coordination = atom->ivector[index_coord]; m = 0; if (correction_order > 0) { for (i = 0; i < n; i++) { @@ -774,7 +773,6 @@ int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf, void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last,a,b; - coordination = atom->ivector[index_coord]; m = 0; last = first + n; if (correction_order > 0) { diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index 346df5a20c..df659c47de 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -42,6 +42,7 @@ class ComputeRHEOKernel : public Compute { double dWij[3], dWji[3], Wij, Wji; int correction_order; + int *coordination; private: int solid_flag; @@ -49,7 +50,7 @@ class ComputeRHEOKernel : public Compute { std::unordered_set gsl_error_tags; int kernel_style, zmin, dim, Mdim, ncor; - int nmax_old, index_coord; + int nmax_old; double h, hsq, hinv, hsqinv, pre_w, pre_wp; double ***C; double *C0; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 2b7c9394d3..dccd3867cd 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -21,7 +21,6 @@ #include "atom.h" #include "comm.h" #include "compute_rheo_interface.h" -#include "compute_rheo_grad.h" #include "compute_rheo_kernel.h" #include "domain.h" #include "error.h" @@ -37,8 +36,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), vshift(nullptr), fix_rheo(nullptr), compute_kernel(nullptr), - compute_grad(nullptr), compute_surface(nullptr), compute_interface(nullptr) + Compute(lmp, narg, arg), vshift(nullptr), fix_rheo(nullptr), fix_rheo(nullptr), + compute_kernel(nullptr), compute_interface(nullptr) { if (narg != 3) error->all(FLERR,"Illegal compute RHEO/VShift command"); @@ -51,11 +50,12 @@ ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) : // Manually grow if nmax_old exceeded int tmp1, tmp2; - index_vshift = atom->find_custom("rheo_vshift", tmp1, tmp2); - if (index_vshift == -1) { - index_vshift = atom->add_custom("rheo_vshift", 1, 3); + int index = atom->find_custom("rheo_vshift", tmp1, tmp2); + if (index == -1) { + index = atom->add_custom("rheo_vshift", 1, 3); nmax_old = atom->nmax; } + vshift = atom->dvector[index]; } /* ---------------------------------------------------------------------- */ @@ -65,7 +65,7 @@ ComputeRHEOVShift::~ComputeRHEOVShift() // Remove custom property if it exists int tmp1, tmp2, index; index = atom->find_custom("rheo_vshift", tmp1, tmp2); - if (index != -1) atom->remove_custom(index_vshift, 1, 3); + if (index != -1) atom->remove_custom(index, 1, 3); } @@ -80,7 +80,6 @@ void ComputeRHEOVShift::init() surface_flag = 1; compute_kernel = fix_rheo->compute_kernel; - compute_grad = fix_rheo->compute_grad; compute_interface = fix_rheo->compute_interface; cut = fix_rheo->cut; @@ -119,7 +118,6 @@ void ComputeRHEOVShift::compute_peratom() int *surface = atom->surface; double *rho = atom->rho; double *mass = atom->mass; - double **vshift = atom->darray[index_vshift]; int newton_pair = force->newton_pair; inum = list->inum; @@ -127,7 +125,6 @@ void ComputeRHEOVShift::compute_peratom() numneigh = list->numneigh; firstneigh = list->firstneigh; - if (nmax_old < atom->nmax) memory->grow(vshift, atom->nmax, 3, "atom:rheo_vshift"); nmax_old = atom->nmax; @@ -232,9 +229,9 @@ void ComputeRHEOVShift::correct_surfaces() int nlocal = atom->nlocal; int i, a, b; int dim = domain->dimension; - double **vshift = atom->darray[index_vshift]; int tmp1, tmp2; + define after surf int index_nsurf = atom->find_custom("rheo_nsurf", tmp1, tmp2); if (index_nsurf == -1) error->all(FLERR, "Cannot find rheo nsurf"); double **nsurf = atom->darray[index_nsurf]; @@ -268,7 +265,6 @@ void ComputeRHEOVShift::correct_surfaces() int ComputeRHEOVShift::pack_reverse_comm(int n, int first, double *buf) { int i,m,last; - double **vshift = atom->darray[index_vshift]; m = 0; last = first + n; @@ -285,7 +281,6 @@ int ComputeRHEOVShift::pack_reverse_comm(int n, int first, double *buf) void ComputeRHEOVShift::unpack_reverse_comm(int n, int *list, double *buf) { int i,j,m; - double **vshift = atom->darray[index_vshift]; m = 0; for (i = 0; i < n; i++) { diff --git a/src/RHEO/compute_rheo_vshift.h b/src/RHEO/compute_rheo_vshift.h index f93cced31c..af5675fd8d 100644 --- a/src/RHEO/compute_rheo_vshift.h +++ b/src/RHEO/compute_rheo_vshift.h @@ -35,17 +35,17 @@ class ComputeRHEOVShift : public Compute { void unpack_reverse_comm(int, int *, double *) override; double memory_usage() override; void correct_surfaces(); + double **vshift; private: int nmax_old; double dtv, cut, cutsq, cutthird; - int surface_flag, index_vshift; + int surface_flag; class NeighList *list; class FixRHEO *fix_rheo; class ComputeRHEOInterface *compute_interface ; class ComputeRHEOKernel *compute_kernel; - class ComputeRHEOGrad *compute_grad; }; } // namespace LAMMPS_NS diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 25a97bd52a..e83a95751a 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "compute_rheo_grad.h" #include "compute_rheo_interface.h" +#include "compute_rheo_surface.h" #include "compute_rheo_kernel.h" #include "compute_rheo_rhosum.h" #include "compute_rheo_vshift.h" @@ -37,7 +38,7 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), compute_grad(nullptr), compute_kernel(nullptr), + Fix(lmp, narg, arg), compute_grad(nullptr), compute_kernel(nullptr), compute_surface(nullptr), compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr) { time_integrate = 1; @@ -258,7 +259,7 @@ void FixRHEO::initial_integrate(int /*vflag*/) double **gradr = compute_grad->gradr; double **gradv = compute_grad->gradv; - double **vshift = compute_vshift->array_atom; + double **vshift = compute_vshift->vshift; int *type = atom->type; int *mask = atom->mask; diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 0132f32bcc..89304fe22f 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -81,6 +81,7 @@ class FixRHEO : public Fix { class ComputeRHEOGrad *compute_grad; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; + class ComputeRHEOSurface *compute_surface; class ComputeRHEORhoSum *compute_rhosum; class ComputeRHEOVShift *compute_vshift; diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 4fa4ece0f9..726c44c32b 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -36,7 +36,7 @@ enum {NONE, LINEAR, CUBIC, TAITWATER}; /* ---------------------------------------------------------------------- */ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), fix_rheo(nullptr), pressure(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -74,7 +74,7 @@ FixRHEOPressure::~FixRHEOPressure() // Remove custom property if it exists int tmp1, tmp2, index; index = atom->find_custom("rheo_pressure", tmp1, tmp2); - if (index != -1) atom->remove_custom(index_pres, 1, 0); + if (index != -1) atom->remove_custom(index, 1, 0); } /* ---------------------------------------------------------------------- */ @@ -115,11 +115,12 @@ void FixRHEOPressure::setup_pre_force(int /*vflag*/) // Manually grow if nmax_old exceeded int tmp1, tmp2; - index_pres = atom->find_custom("rheo_pressure", tmp1, tmp2); - if (index_pres == -1) { - index_pres = atom->add_custom("rheo_pressure", 1, 0); + int index = atom->find_custom("rheo_pressure", tmp1, tmp2); + if (index == -1) { + index = atom->add_custom("rheo_pressure", 1, 0); nmax_old = atom->nmax; } + pressure = atom->dvector[index]; pre_force(0); } @@ -133,7 +134,6 @@ void FixRHEOPressure::pre_force(int /*vflag*/) int i; double dr, rr3, rho_ratio; - double *pressure = atom->dvector[index_pres]; int *mask = atom->mask; double *rho = atom->rho; @@ -170,7 +170,6 @@ int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,k,m; - double *pressure = atom->dvector[index_pres]; m = 0; for (i = 0; i < n; i++) { @@ -185,7 +184,6 @@ int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf, void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; - double *pressure = atom->dvector[index_pres]; m = 0; last = first + n; @@ -194,6 +192,8 @@ void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf) } } +/* ---------------------------------------------------------------------- */ + double FixRHEOPressure::calculate_p(double rho) { double rho; diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h index 8272cc38f5..197cab6e5c 100644 --- a/src/RHEO/fix_rheo_pressure.h +++ b/src/RHEO/fix_rheo_pressure.h @@ -38,9 +38,10 @@ class FixRHEOPressure : public Fix { double calculate_p(double); private: double c_cubic, csq, rho0, rho0inv; + double *pressure; int pressure_style; int first_flag, last_flag; - int nmax_old, index_pressure; + int nmax_old; class FixRHEO *fix_rheo; }; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 3ef9fab853..1a5d894ced 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -37,7 +37,8 @@ enum {NONE, CONSTANT, TYPE}; /* ---------------------------------------------------------------------- */ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr) + Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr), + conductivity(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -131,7 +132,7 @@ FixRHEOThermal::~FixRHEOThermal() // Remove custom property if it exists int tmp1, tmp2, index; index = atom->find_custom("rheo_conductivity", tmp1, tmp2); - if (index != -1) atom->remove_custom(index_cond, 1, 0); + if (index != -1) atom->remove_custom(index, 1, 0); memory->destroy(cv_type); memory->destroy(Tc_type); @@ -199,11 +200,12 @@ void FixRHEOThermal::setup_pre_force(int /*vflag*/) // Manually grow if nmax_old exceeded int tmp1, tmp2; - index_cond = atom->find_custom("rheo_conductivity", tmp1, tmp2); - if (index_cond == -1) { - index_cond = atom->add_custom("rheo_conductivity", 1, 0); + index = atom->find_custom("rheo_conductivity", tmp1, tmp2); + if (index== -1) { + index = atom->add_custom("rheo_conductivity", 1, 0); nmax_old = atom->nmax; } + conductivity = atom->dvector[index]; post_neighbor(); pre_force(0); diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index 3b62e86fa8..4f0e89f17c 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -48,11 +48,12 @@ class FixRHEOThermal : public Fix { double *Tc_type, Tc; double *kappa_type, kappa; double dtf, dtv; + double *conductivity; int Tc_style; int cv_style; int conductivity_style; int first_flag, last_flag; - int nmax_old, index_cond; + int nmax_old; class FixRHEO *fix_rheo; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 3f779aa3c6..bb7094c43e 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -37,7 +37,7 @@ enum {NONE, CONSTANT, TYPE, POWER}; /* ---------------------------------------------------------------------- */ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), eta_type(nullptr) + Fix(lmp, narg, arg), fix_rheo(nullptr), eta_type(nullptr), viscosity(nullptr), compute_grad(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -142,11 +142,12 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) // Manually grow if nmax_old exceeded int tmp1, tmp2; - index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); + int index = atom->find_custom("rheo_viscosity", tmp1, tmp2); if (index_visc == -1) { - index_visc = atom->add_custom("rheo_viscosity", 1, 0); + index = atom->add_custom("rheo_viscosity", 1, 0); nmax_old = atom->nmax; } + viscosity = atom->dvector[index]; post_neighbor(); pre_force(0); @@ -161,7 +162,6 @@ void FixRHEOViscosity::post_neighbor() int i; int *type = atom->type; - double *viscosity = atom->dvector[index_visc]; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -190,7 +190,6 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) int i, a, b; double tmp, gdot; - double *viscosity = atom->dvector[index_visc]; int *mask = atom->mask; double **gradv = compute_grad->gradv; @@ -232,7 +231,6 @@ int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,k,m; - double *viscosity = atom->dvector[index_visc]; m = 0; for (i = 0; i < n; i++) { @@ -247,7 +245,6 @@ int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf, void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; - double *viscosity = atom->dvector[index_visc]; m = 0; last = first + n; diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h index 407170f668..14f8b70de9 100644 --- a/src/RHEO/fix_rheo_viscosity.h +++ b/src/RHEO/fix_rheo_viscosity.h @@ -40,9 +40,10 @@ class FixRHEOViscosity : public Fix { private: double *eta_type, eta; double npow, K, gd0, tau0; + double *viscosity; int viscosity_style; int first_flag, last_flag; - int nmax_old, index_visc; + int nmax_old; class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 7d5d0f425f..7b9425cf20 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -47,7 +47,7 @@ using namespace MathExtra; PairRHEO::PairRHEO(LAMMPS *lmp) : Pair(lmp), compute_kernel(nullptr), compute_grad(nullptr), - compute_interface(nullptr), fix_rheo(nullptr), fix_rheo_pressure(nullptr) + compute_interface(nullptr), fix_rheo(nullptr), fix_pressure(nullptr) { restartinfo = 0; single_enable = 0; @@ -91,8 +91,7 @@ void PairRHEO::compute(int eflag, int vflag) double **v = atom->v; double **x = atom->x; double **f = atom->f; - double **f_pressure = fix_rheo->f_pressure; // rewrite later - double *pressure = atom->pressure; // rewrite later + double **f_pressure = compute_interface->f_pressure; double *rho = atom->rho; double *mass = atom->mass; double *drho = atom->drho; @@ -105,15 +104,19 @@ void PairRHEO::compute(int eflag, int vflag) int *status = atom->status; int tmp1, tmp2; - int index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); - if (index_visc == -1) error->all(FLERR, "Cannot find rheo viscosity"); - double *viscosity = atom->dvector[index_visc]; + int index = atom->find_custom("rheo_viscosity", tmp1, tmp2); + if (index == -1) error->all(FLERR, "Cannot find rheo viscosity"); + double *viscosity = atom->dvector[index]; + + index = atom->find_custom("rheo_pressure", tmp1, tmp2); + if (index == -1) error->all(FLERR, "Cannot find rheo pressure"); + double *pressure = atom->dvector[index]; double *conductivity; if (thermal_flag) { - int index_cond = atom->find_custom("rheo_conductivity", tmp1, tmp2); - if (index_cond == -1) error->all(FLERR, "Cannot find rheo conductivity"); - conductivity = atom->dvector[index_cond]; + index = atom->find_custom("rheo_conductivity", tmp1, tmp2); + if (index == -1) error->all(FLERR, "Cannot find rheo conductivity"); + conductivity = atom->dvector[index]; } int *ilist, *jlist, *numneigh, **firstneigh; @@ -195,7 +198,7 @@ void PairRHEO::compute(int eflag, int vflag) if (fluidi && (!fluidj)) { compute_interface->correct_v(vi, vj, i, j); rhoj = compute_interface->correct_rho(j, i); - Pj = fix_rheo_pressure->calculate_p(rhoj); + Pj = fix_pressure->calculate_p(rhoj); if ((chi[j] > 0.9) && (r < (h * 0.5))) fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; @@ -413,7 +416,12 @@ void PairRHEO::setup() fixes = modify->get_fix_by_style("rheo/pressure"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo/pressure to use pair rheo"); - fix_rheo_pressure = dynamic_cast(fixes[0]); + fix_pressure = dynamic_cast(fixes[0]); + + int tmp1, tmp2; + index_pressure = atom->find_custom("rheo_pressure", tmp1, tmp2); + if (index_pressure == -1) index_pressure = atom->add_custom("rheo_pressure", 1, 0); + else error->all(FLERR, "Cannot find pressure value in pair rheo"); compute_kernel = fix_rheo->compute_kernel; compute_grad = fix_rheo->compute_grad; diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index aa98e63ddc..49aa1ad025 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -49,7 +49,7 @@ class PairRHEO : public Pair { class ComputeRHEOGrad *compute_grad; class ComputeRHEOInterface *compute_interface; class FixRHEO *fix_rheo; - class FixRHEOPressure *fix_rheo_pressure; + class FixRHEOPressure *fix_pressure; }; } // namespace LAMMPS_NS From 5980fdf9fdad22d75a395078a61319f3e453c71e Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sat, 15 Apr 2023 21:15:37 -0600 Subject: [PATCH 022/104] Revising interface compute --- src/RHEO/compute_rheo_interface.cpp | 185 +++++++++++++--------------- src/RHEO/compute_rheo_interface.h | 4 +- src/RHEO/compute_rheo_vshift.cpp | 8 +- src/RHEO/fix_rheo_thermal.cpp | 10 +- src/RHEO/fix_rheo_viscosity.cpp | 10 +- src/RHEO/pair_rheo.cpp | 29 +++-- 6 files changed, 126 insertions(+), 120 deletions(-) diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index ae1bc13831..ff76b75f77 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -61,8 +61,8 @@ ComputeRHEOInterface::~ComputeRHEOInterface() if (index != -1) atom->remove_custom(index, 1, 0); if (id_fix_pa && modify->nfix) modify->delete_fix(id_fix_pa); + delete[] id_fix_pa; - memory->destroy(fx_m_norm); memory->destroy(norm); memory->destroy(normwf); } @@ -72,7 +72,10 @@ ComputeRHEOInterface::~ComputeRHEOInterface() void ComputeRHEOInterface::init() { compute_kernel = fix_rheo->compute_kernel; + rho0 = fix_rheo->rho0; cut = fix_rheo->cut; + cs = fix_rheo->cs; + cs_inv = 1.0 / cs; cutsq = cut * cut; wall_max = sqrt(3.0) / 12.0 * cut; @@ -87,21 +90,25 @@ void ComputeRHEOInterface::init() int index = atom->find_custom("rheo_chi", tmp1, tmp2); if (index == -1) { index = atom->add_custom("rheo_chi", 1, 0); + memory->destroy(norm); + memory->destroy(normwf); + memory->create(norm, nmax, "rheo/interface:norm"); + memory->create(normwf, nmax, "rheo/interface:normwf"); nmax_old = nmax; } chi = atom->dvector[index]; - // For fpressure, go ahead and create an instance of fix property atom + // For fp_store, go ahead and create an instance of fix property atom // Need restarts + exchanging with neighbors since it needs to persist // between timesteps (fix property atom will handle callbacks) - index = atom->find_custom("rheo_pressure", tmp1, tmp2); + index = atom->find_custom("fp_store", tmp1, tmp2); if (index == -1) { id_fix_pa = utils::strdup(id + std::string("_fix_property_atom")); - modify->add_fix(fmt::format("{} all property/atom d2_f_pressure 3", id_fix_pa))); - index = atom->find_custom("rheo_pressure", tmp1, tmp2); + modify->add_fix(fmt::format("{} all property/atom d2_fp_store 3", id_fix_pa))); + index = atom->find_custom("fp_store", tmp1, tmp2); } - f_pressure = atom->darray[index]; + fp_store = atom->darray[index]; // need an occasional half neighbor list neighbor->add_request(this, NeighConst::REQ_HALF); @@ -116,51 +123,37 @@ void ComputeRHEOInterface::init_list(int /*id*/, NeighList *ptr) /* ---------------------------------------------------------------------- */ -// Left off here void ComputeRHEOInterface::compute_peratom() { - int i, j, ii, jj, jnum, itype, jtype, phase_match; - double xtmp, ytmp, ztmp, delx, dely, delz, rsq; - int *jlist; - double w; + int i, j, ii, jj, jnum, itype, jtype, fluidi, fluidj, status_match; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq, w, dot; - // neighbor list ariables - int inum, *ilist, *numneigh, **firstneigh; + int inum, *ilist, *jlist, *numneigh, **firstneigh; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; double **x = atom->x; int *type = atom->type; int newton = force->newton; - int *phase = atom->phase; + int *status = atom->status; double *rho = atom->rho; - double *fx = atom->dvector[index_fx]; - double *fy = atom->dvector[index_fy]; - double *fz = atom->dvector[index_fz]; - double mi, mj; - - //Declare mass pointer to calculate acceleration from force - double *mass = atom->mass; - - cs2 = 1.0; inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; - if (atom->nmax > nmax) { - nmax = atom->nmax; - fix_chi->grow_arrays(nmax); - chi = fix_chi->vstore; + if (atom->nmax > nmax_old) { + nmax_old = atom->nmax; memory->destroy(norm); memory->destroy(normwf); - memory->create(norm, nmax, "RHEO/chi:norm"); - memory->create(normwf, nmax, "RHEO/chi:normwf"); + memory->create(norm, nmax_old, "rheo/interface:norm"); + memory->create(normwf, nmax_old, "rheo/interface:normwf"); + memory->grow(chi, nmax_old, "rheo/interface:chi"); } for (i = 0; i < nall; i++) { - if (phase[i] > FixRHEO::FLUID_MAX) rho[i] = 0.0; + if (!(status[i] & FixRHEO::STATUS_FLUID)) rho[i] = 0.0; normwf[i] = 0.0; norm[i] = 0.0; chi[i] = 0.0; @@ -172,9 +165,9 @@ void ComputeRHEOInterface::compute_peratom() ytmp = x[i][1]; ztmp = x[i][2]; itype = type[i]; + fluidi = status[i] & FixRHEO::STATUS_FLUID; jlist = firstneigh[i]; jnum = numneigh[i]; - mi = mass[type[i]]; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -187,37 +180,36 @@ void ComputeRHEOInterface::compute_peratom() if (rsq < cutsq) { jtype = type[j]; - mj = mass[type[j]]; + fluidj = status[j] & FixRHEO::STATUS_FLUID; w = compute_kernel->calc_w_quintic(i, j, delx, dely, delz, sqrt(rsq)); - phase_match = 0; + status_match = 0; norm[i] += w; - if ((phase[i] <= FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) - || (phase[i] > FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX)) { - phase_match = 1; - } + if ((fluidi && fluidj) || ((!fluid) && (!fluidj))) + status_match = 1; - if (phase_match) { + if (status_match) { chi[i] += w; } else { - if (phase[i] > FixRHEO::FLUID_MAX) { - //speed of sound and rho0 assumed to = 1 (units in density not pressure) - //In general, rho is calculated using the force vector on the wall particle - //fx stores f-fp - rho[i] += w*(cs2*(rho[j] - 1.0) - rho[j]*((-fx[j]/mj+fx[i]/mi)*delx + (-fy[j]/mj+fy[i]/mi)*dely + (-fz[j]/mj+fz[i]/mi)*delz)); - //For the specific taste case whre force on wall particles = 0 - //rho[i] += w*(1.0*(rho[j] - 1.0) + rho[j]*(1e-3*delx)); + if (!fluidi) { + dot = (-fp_store[0][j] + fp_store[0][i]) * delx; + dot += (-fp_store[1][j] + fp_store[1][i]) * dely; + dot += (-fp_store[2][j] + fp_store[2][i]) * delz; + rho[i] += w * (cs * (rho[j] - rho0) - rho[j] * dot); normwf[i] += w; } } if (newton || j < nlocal) { norm[j] += w; - if (phase_match) { + if (status_match) { chi[j] += w; } else { - if (phase[j] > FixRHEO::FLUID_MAX) { - rho[j] += w*(cs2*(rho[i] - 1.0) + rho[i]*((-fx[i]/mi+fx[j]/mj)*delx + (-fy[i]/mi+fy[j]/mj)*dely + (-fz[i]/mi+fz[j]/mj)*delz)); + if (!fluidj) { + dot = (-fp_store[0][i] + fp_store[0][j]) * delx; + dot += (-fp_store[1][i] + fp_store[1][j]) * dely; + dot += (-fp_store[2][i] + fp_store[2][j]) * delz; + rho[j] += w * (cs * (rho[i] - rho0) + rho[i] * dot); normwf[j] += w; } } @@ -226,41 +218,41 @@ void ComputeRHEOInterface::compute_peratom() } } - if (newton) comm->reverse_comm_compute(this); + if (newton) comm->reverse_comm(this); for (i = 0; i < nlocal; i++) { if (norm[i] != 0.0) chi[i] /= norm[i]; - if (normwf[i] != 0.0) { // Only if it's a wall particle - rho[i] = 1.0 + (rho[i] / normwf[i])/cs2; // Stores rho for solid particles 1+Pw in Adami Adams 2012 - if (rho[i] < EPSILON) rho[i] = EPSILON; - } - if (normwf[i] == 0.0 && phase[i] > FixRHEO::FLUID_MAX) rho[i] = 1.0; + // Recalculate rho for non-fluid particles + if (!(status[i] & FixRHEO::STATUS_FLUID)) { + if (normwf[i] != 0.0) { + // Stores rho for solid particles 1+Pw in Adami Adams 2012 + rho[i] = MAX(EPSILON, rho0 + (rho[i] / normwf[i]) * cs_inv); + } else { + rho[i] = rho0; + } + } } comm_stage = 1; comm_forward = 2; - comm->forward_comm_compute(this); + comm->forward_comm(this); } /* ---------------------------------------------------------------------- */ -int ComputeRHEOInterface::pack_forward_comm(int n, int *list, double *buf, - int /*pbc_flag*/, int * /*pbc*/) +int ComputeRHEOInterface::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,k,m; m = 0; double *rho = atom->rho; - double *fx = atom->dvector[index_fx]; - double *fy = atom->dvector[index_fy]; - double *fz = atom->dvector[index_fz]; for (i = 0; i < n; i++) { j = list[i]; if (comm_stage == 0) { - buf[m++] = fx[j]; - buf[m++] = fy[j]; - buf[m++] = fz[j]; + buf[m++] = fp_store[j][0]; + buf[m++] = fp_store[j][1]; + buf[m++] = fp_store[j][2]; } else { buf[m++] = chi[j]; buf[m++] = rho[j]; @@ -275,20 +267,16 @@ void ComputeRHEOInterface::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; double *rho = atom->rho; - double *fx = atom->dvector[index_fx]; - double *fy = atom->dvector[index_fy]; - double *fz = atom->dvector[index_fz]; - m = 0; last = first + n; for (i = first; i < last; i++) { if (comm_stage == 0) { - fx[i] = buf[m++]; - fy[i] = buf[m++]; - fz[i] = buf[m++]; + fp_store[i][0] = buf[m++]; + fp_store[i][1] = buf[m++]; + fp_store[i][2] = buf[m++]; } else { chi[i] = buf[m++]; - rho[i] = buf[m++]; // Won't do anything for fluids + rho[i] = buf[m++]; } } } @@ -317,13 +305,13 @@ void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf) { int i,k,j,m; double *rho = atom->rho; - int *phase = atom->phase; + int *status = atom->status; m = 0; for (i = 0; i < n; i++) { j = list[i]; norm[j] += buf[m++]; chi[j] += buf[m++]; - if (phase[j] > FixRHEO::FLUID_MAX){ + if (!(status[j] & FixRHEO::STATUS_FLUID)){ normwf[j] += buf[m++]; rho[j] += buf[m++]; } else { @@ -339,22 +327,23 @@ void ComputeRHEOInterface::correct_v(double *vi, double *vj, double *vi_out, int { double wall_prefactor, wall_denom, wall_numer; - wall_numer = 2.0*cut*(chi[i]-0.5); + wall_numer = 2.0 * cut * (chi[i] - 0.5); if (wall_numer < 0) wall_numer = 0; - wall_denom = 2.0*cut*(chi[j]-0.5); + wall_denom = 2.0 * cut * (chi[j] - 0.5); if (wall_denom < wall_max) wall_denom = wall_max; wall_prefactor = wall_numer / wall_denom; - vi_out[0] = (vi[0]-vj[0])*wall_prefactor + vi[0]; - vi_out[1] = (vi[1]-vj[1])*wall_prefactor + vi[1]; - vi_out[2] = (vi[2]-vj[2])*wall_prefactor + vi[2]; + vi_out[0] = (vi[0] - vj[0]) * wall_prefactor + vi[0]; + vi_out[1] = (vi[1] - vj[1]) * wall_prefactor + vi[1]; + vi_out[2] = (vi[2] - vj[2]) * wall_prefactor + vi[2]; } /* ---------------------------------------------------------------------- */ -double ComputeRHEOInterface::correct_rho(int i, int j) // i is wall, j is fluid +double ComputeRHEOInterface::correct_rho(int i, int j) { + // i is wall, j is fluid //In future may depend on atom type j's pressure equation return atom->rho[i]; } @@ -363,42 +352,46 @@ double ComputeRHEOInterface::correct_rho(int i, int j) // i is wall, j is fluid void ComputeRHEOInterface::store_forces() { - double *fx = atom->dvector[index_fx]; - double *fy = atom->dvector[index_fy]; - double *fz = atom->dvector[index_fz]; + double minv; + double mass = atom->mass; + double type = atom->type; double **f = atom->f; - double **fp = atom->fp; int *mask = atom->mask; - int flag; + // When this is called, fp_store stores the pressure force + // After this method, fp_store instead stores non-pressure forces + // and is also normalized by the particles mass + // If forces are overwritten by a fix, there are no pressure forces + // so just normalize int ifix = modify->find_fix_by_style("setforce"); if (ifix != -1) { for (int i = 0; i < atom->nlocal; i++) { + minv = 1.0 / mass[type[i]]; if (mask[i] & modify->fix[ifix]->groupbit) { - fx[i] = f[i][0]; - fy[i] = f[i][1]; - fz[i] = f[i][2]; + fp_store[i][0] = f[i][0] * minv; + fp_store[i][1] = f[i][1] * minv; + fp_store[i][2] = f[i][2] * minv; } else { - fx[i] = f[i][0] - fp[i][0]; - fy[i] = f[i][1] - fp[i][1]; - fz[i] = f[i][2] - fp[i][2]; + fp_store[i][0] = (f[i][0] - fp_store[i][0]) * minv; + fp_store[i][1] = (f[i][1] - fp_store[i][1]) * minv; + fp_store[i][2] = (f[i][2] - fp_store[i][2]) * minv; } } } else { for (int i = 0; i < atom->nlocal; i++) { - fx[i] = f[i][0] - fp[i][0]; - fy[i] = f[i][1] - fp[i][1]; - fz[i] = f[i][2] - fp[i][2]; + minv = 1.0 / mass[type[i]]; + fp_store[i][0] = (f[i][0] - fp_store[i][0]) * minv; + fp_store[i][1] = (f[i][1] - fp_store[i][1]) * minv; + fp_store[i][2] = (f[i][2] - fp_store[i][2]) * minv; } } - //Forward comm forces -note only needed here b/c property atom will forward otherwise + // Forward comm forces comm_forward = 3; comm_stage = 0; - comm->forward_comm_compute(this); + comm->forward_comm(this); } - /* ---------------------------------------------------------------------- memory usage of local atom-based array ------------------------------------------------------------------------- */ diff --git a/src/RHEO/compute_rheo_interface.h b/src/RHEO/compute_rheo_interface.h index f314c16aa9..8e190c5430 100644 --- a/src/RHEO/compute_rheo_interface.h +++ b/src/RHEO/compute_rheo_interface.h @@ -44,8 +44,8 @@ class ComputeRHEOInterface : public Compute { private: int nmax_old, comm_stage; - double cut, cutsq, cs, wall_max; - double **fx_m_norm, *norm, *normwf; + double rho0, cut, cutsq, cs, cs_inv, wall_max; + double *norm, *normwf, **fom_store; char *id_fix_pa; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index dccd3867cd..6cbd6e96da 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -125,9 +125,10 @@ void ComputeRHEOVShift::compute_peratom() numneigh = list->numneigh; firstneigh = list->firstneigh; - if (nmax_old < atom->nmax) + if (nmax_old < atom->nmax) { memory->grow(vshift, atom->nmax, 3, "atom:rheo_vshift"); - nmax_old = atom->nmax; + nmax_old = atom->nmax; + } for (i = 0; i < nall; i++) for (a = 0; a < dim; a++) @@ -231,7 +232,6 @@ void ComputeRHEOVShift::correct_surfaces() int dim = domain->dimension; int tmp1, tmp2; - define after surf int index_nsurf = atom->find_custom("rheo_nsurf", tmp1, tmp2); if (index_nsurf == -1) error->all(FLERR, "Cannot find rheo nsurf"); double **nsurf = atom->darray[index_nsurf]; @@ -239,7 +239,7 @@ void ComputeRHEOVShift::correct_surfaces() double nx,ny,nz,vx,vy,vz; for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if ((surface[i] & FixRHEO::STATUS_SURFACE) || (surface[i] & FixRHEO::STATUS_LAYER)) { + if ((status[i] & FixRHEO::STATUS_SURFACE) || (status[i] & FixRHEO::STATUS_LAYER)) { nx = nsurf[i][0]; ny = nsurf[i][1]; vx = vshift[i][0]; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 1a5d894ced..1912dc9f8c 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -293,9 +293,10 @@ void FixRHEOThermal::post_neighbor() int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - if (first_flag && (nmax_old < atom->nmax)) + if (first_flag && (nmax_old < atom->nmax)) { memory->grow(conductivity, atom->nmax, "atom:rheo_conductivity"); - nmax_old = atom->nmax; + nmax_old = atom->nmax; + } if (conductivity_style == CONSTANT) { for (i = 0; i < nall; i++) @@ -328,9 +329,10 @@ void FixRHEOThermal::pre_force(int /*vflag*/) //int *mask = atom->mask; //int nlocal = atom->nlocal; - //if (first_flag && (nmax_old < atom->nmax)) + //if (first_flag && (nmax_old < atom->nmax)) { // memory->grow(conductivity, atom->nmax, "atom:rheo_conductivity"); - //nmax_old = atom->nmax; + // nmax_old = atom->nmax; + //} //if (conductivity_style == TBD) { // for (i = 0; i < nlocal; i++) { diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index bb7094c43e..5ae1b95529 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -167,9 +167,10 @@ void FixRHEOViscosity::post_neighbor() int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - if (first_flag && (nmax_old < atom->nmax)) + if (first_flag && (nmax_old < atom->nmax)) { memory->grow(viscosity, atom->nmax, "atom:rheo_viscosity"); - nmax_old = atom->nmax; + nmax_old = atom->nmax; + } if (viscosity_style == CONSTANT) { for (i = 0; i < nall; i++) @@ -196,9 +197,10 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) int nlocal = atom->nlocal; int dim = domain->dimension; - if (first_flag && (nmax_old < atom->nmax)) + if (first_flag && (nmax_old < atom->nmax)) { memory->grow(viscosity, atom->nmax, "atom:rheo_viscosity"); - nmax_old = atom->nmax; + nmax_old = atom->nmax; + } if (viscosity_style == POWER) { for (i = 0; i < nlocal; i++) { diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 7b9425cf20..1eb2a43e1a 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -91,17 +91,21 @@ void PairRHEO::compute(int eflag, int vflag) double **v = atom->v; double **x = atom->x; double **f = atom->f; - double **f_pressure = compute_interface->f_pressure; double *rho = atom->rho; double *mass = atom->mass; double *drho = atom->drho; double *temperature = atom->temperature; double *heatflow = atom->heatflow; double *special_lj = force->special_lj; - tagint *tag = atom->tag; - int *chi = compute_interface->chi; int *type = atom->type; int *status = atom->status; + tagint *tag = atom->tag; + + double **fp_store, *chi; + if (compute_interface) { + fp_store = compute_interface->fp_store; + chi = compute_interface->chi; + } int tmp1, tmp2; int index = atom->find_custom("rheo_viscosity", tmp1, tmp2); @@ -273,9 +277,6 @@ void PairRHEO::compute(int eflag, int vflag) f[i][0] += ft[0]; f[i][1] += ft[1]; f[i][2] += ft[2]; - fp[i][0] += dfp[0]; - fp[i][1] += dfp[1]; - fp[i][2] += dfp[2]; if (evflag) // Does not account for unbalanced forces ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], dx[0], dx[1], dx[2]); @@ -289,7 +290,7 @@ void PairRHEO::compute(int eflag, int vflag) // flip sign here b/c -= at accummulator } - scale3(fp_prefact,r dWji, dfp); + scale3(fp_prefactor, dWji, dfp); add3(fv, dfp, ft); add3(fsolid, ft, ft); @@ -297,10 +298,18 @@ void PairRHEO::compute(int eflag, int vflag) f[j][0] -= ft[0]; f[j][1] -= ft[1]; f[j][2] -= ft[2]; + } - fp[j][0] -= dfp[0]; - fp[j][1] -= dfp[1]; - fp[j][2] -= dfp[2]; + if (compute_interface) { + fp_store[i][0] += dfp[0]; + fp_store[i][1] += dfp[1]; + fp_store[i][2] += dfp[2]; + + if (newton_pair || j < nlocal) { + fp_store[j][0] -= dfp[0]; + fp_store[j][1] -= dfp[1]; + fp_store[j][2] -= dfp[2]; + } } } From d85ce6a39247254ec64baaf1b8879c15c0aeecef Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 19 Apr 2023 17:15:00 -0600 Subject: [PATCH 023/104] Initial surface compute --- src/RHEO/compute_rheo_grad.h | 2 +- src/RHEO/compute_rheo_interface.cpp | 2 +- src/RHEO/compute_rheo_interface.h | 2 +- src/RHEO/compute_rheo_kernel.h | 2 +- src/RHEO/compute_rheo_surface.cpp | 595 ++++++++++++++++++++++++++++ src/RHEO/compute_rheo_surface.h | 72 ++++ src/RHEO/compute_rheo_vshift.h | 2 +- src/RHEO/fix_rheo.cpp | 54 ++- src/RHEO/fix_rheo.h | 8 +- 9 files changed, 714 insertions(+), 25 deletions(-) create mode 100644 src/RHEO/compute_rheo_surface.cpp create mode 100644 src/RHEO/compute_rheo_surface.h diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index 7804ee72dd..ee4b4a5bd6 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -13,7 +13,7 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(rheo/grad,ComputeRHEOGrad) +ComputeStyle(RHEO/GRAD,ComputeRHEOGrad) // clang-format on #else diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index ff76b75f77..55cb81382b 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -398,7 +398,7 @@ void ComputeRHEOInterface::store_forces() double ComputeRHEOInterface::memory_usage() { - double bytes = nmax * sizeof(double); + double bytes = 3 * nmax_old * sizeof(double); return bytes; } diff --git a/src/RHEO/compute_rheo_interface.h b/src/RHEO/compute_rheo_interface.h index 8e190c5430..cdb2eb6c54 100644 --- a/src/RHEO/compute_rheo_interface.h +++ b/src/RHEO/compute_rheo_interface.h @@ -13,7 +13,7 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(rheo/interface,ComputeRHEOInterface) +ComputeStyle(RHEO/INTERFACE,ComputeRHEOInterface) // clang-format on #else diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index df659c47de..ed2b6ff5f2 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -13,7 +13,7 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(rheo/kernel,ComputeRHEOKernel) +ComputeStyle(RHEO/KERNEL,ComputeRHEOKernel) // clang-format on #else diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp new file mode 100644 index 0000000000..dff5db4cfa --- /dev/null +++ b/src/RHEO/compute_rheo_surface.cpp @@ -0,0 +1,595 @@ +/* ---------------------------------------------------------------------- + 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 authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + +#include "compute_rheo_surface.h" + +#include "fix_rheo.h" +#include "compute_rheo_kernel.h" +#include "compute_rheo_solids.h" +#include "atom.h" +#include "memory.h" +#include "atom.h" +#include "comm.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "error.h" +#include "force.h" +#include "domain.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOSurface::ComputeRHEOSurface(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg) +{ + if (narg < 6) error->all(FLERR,"Illegal fix rheo/surface command"); + + cut = utils::numeric(FLERR,arg[3],false,lmp); + divR_limit = utils::numeric(FLERR,arg[4],false,lmp); + coord_limit = utils::inumeric(FLERR,arg[5],false,lmp); + + divr_flag = 1; + if (narg == 7) { + divr_flag = 0; + } + + int dim = domain->dimension; + + peratom_flag = 1; + size_peratom_cols = dim; + peratom_freq = 1; + + + comm_forward = 2; + comm_reverse = dim*dim + 1; + + cutsq = cut*cut; + + B = nullptr; + gradC = nullptr; + n_surface = nullptr; + + int nall = atom->nlocal + atom->nghost; + nmax = nall; + memory->create(B,nmax,dim*dim,"fix/rheo/surface:B"); + memory->create(gradC,nmax,dim*dim,"fix/rheo/surface:gradC"); + memory->create(n_surface,nmax,dim,"fix/rheo/surface:B"); + array_atom = n_surface; + + compute_kernel = nullptr; + compute_solids = NULL; + fix_rheo = nullptr; +} + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOSurface::~ComputeRHEOSurface() +{ + if (modify->nfix) modify->delete_fix("PROPERTY_ATOM_RHEO_SURFACE"); + + memory->destroy(B); + memory->destroy(gradC); + memory->destroy(n_surface); +} + +void ComputeRHEOSurface::post_constructor() +{ + //Store persistent per atom quantities + char **fixarg = new char*[5]; + fixarg[0] = (char *) "PROPERTY_ATOM_RHEO_SURFACE"; + fixarg[1] = (char *) "all"; + fixarg[2] = (char *) "property/atom"; + fixarg[3] = (char *) "d_divr"; + fixarg[4] = (char *) "d_rsurf"; + modify->add_fix(5,fixarg,1); + + int temp_flag; + index_divr = atom->find_custom("divr", temp_flag); + if ((index_divr < 0) || (temp_flag != 1)) + error->all(FLERR, "Pair rheo/surface can't find fix property/atom divr"); + + index_rsurf = atom->find_custom("rsurf", temp_flag); + if ((index_rsurf < 0) || (temp_flag != 1)) + error->all(FLERR, "Pair rheo/surface can't find fix property/atom rsurf"); + + delete [] fixarg; + divr = atom->dvector[index_divr]; +} +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOSurface::setmask() +{ + int mask = 0; + mask |= PRE_FORCE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOSurface::init() +{ + // need an occasional full neighbor list + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->pair = 0; + neighbor->requests[irequest]->fix = 1; + neighbor->requests[irequest]->half = 1; + neighbor->requests[irequest]->full = 0; + + int flag; + int ifix = modify->find_fix_by_style("rheo"); + if (ifix == -1) error->all(FLERR, "Need to define fix rheo to use fix rheo/surface"); + fix_rheo = ((FixRHEO *) modify->fix[ifix]); + compute_kernel = fix_rheo->compute_kernel; + compute_solids = fix_rheo->compute_solids; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOSurface::setup_pre_force(int /*vflag*/) +{ + pre_force(0); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOSurface::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOSurface::pre_force(int /*vflag*/) +{ + int i, j, ii, jj, jnum, a, b, itype, jtype; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq, r, wp, Voli, Volj, rhoi, rhoj; + int *jlist; + double *dWij, *dWji; + double dx[3]; + + divr = atom->dvector[index_divr]; + + // neighbor list variables + int inum, *ilist, *numneigh, **firstneigh; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + + double **x = atom->x; + int *surface = atom->surface; + int *phase = atom->phase; + double *rsurf = atom->dvector[index_rsurf]; + int newton = force->newton; + int dim = domain->dimension; + int *mask = atom->mask; + int *type = atom->type; + double *mass = atom->mass; + double *rho = atom->rho; + double *temp = atom->temp; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + if (nmax <= nall) { + nmax = nall; + memory->destroy(B); + memory->destroy(gradC); + memory->destroy(n_surface); + + memory->create(B,nmax,dim*dim,"fix/rheo/surface:B"); + memory->create(gradC,nmax,dim*dim,"fix/rheo/surface:gradC"); + memory->create(n_surface,nmax,dim,"fix/rheo/surface:n_surface"); + array_atom = n_surface; + } + + for (i = 0; i < nall; i++) { + for (a = 0; a < dim; a++) { + for (b = 0; b < dim; b++) { + B[i][a*dim + b] = 0.0; + gradC[i][a*dim + b] = 0.0; + } + n_surface[i][a] = 0.0; + } + divr[i] = 0.0; + surface[i] = 0; + } + + // loop over neighbors to calculate the average orientation of neighbors + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + + jlist = firstneigh[i]; + jnum = numneigh[i]; + itype = type[i]; + + 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]; + dx[0] = delx; + dx[1] = dely; + dx[2] = delz; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq < cutsq) { + jtype = type[j]; + + rhoi = rho[i]; + rhoj = rho[j]; + + // Add corrections for walls + if (phase[i] <= FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { + rhoj = compute_solids->correct_rho(j,i); + } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) { + rhoi = compute_solids->correct_rho(i,j); + } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { + rhoi = 1.0; + rhoj = 1.0; + } + + Voli = mass[itype]/rhoi; + Volj = mass[jtype]/rhoj; + + //compute kernel gradient + wp = compute_kernel->calc_dw_quintic(i, j, delx, dely, delz, sqrt(rsq),compute_kernel->dWij,compute_kernel->dWji); + //wp = compute_kernel->calc_dw(i, j, delx, dely, delz, sqrt(rsq));//,compute_kernel->dWij,compute_kernel->dWji); + + dWij = compute_kernel->dWij; + dWji = compute_kernel->dWji; + + for (a=0; areverse_comm_fix(this); + comm->forward_comm_fix(this); + + int *coordination = compute_kernel->coordination; + // Find the free-surface + //0-bulk 1-surf vicinity 2-surface 3-splash + if (divr_flag) { + for (i = 0; i < nall; i++) { + if (mask[i] & groupbit) { + surface[i] = 0; + rsurf[i] = cut; //Maximum range that can be seen + if (divr[i] < divR_limit) { + surface[i] = 2; + rsurf[i] = 0.0; + if (coordination[i] < coord_limit) surface[i] = 3; + } + } + } + } else { + for (i = 0; i < nall; i++) { + if (mask[i] & groupbit) { + surface[i] = 0; + rsurf[i] = cut; //Maximum range that can be seen + if (coordination[i] < divR_limit) { + surface[i] = 2; + rsurf[i] = 0.0; + if (coordination[i] < coord_limit) surface[i] = 3; + } + } + } + } + + //comm_stage = 1; + //comm_forward = 1; + //comm->forward_comm_fix(this); // communicate free surface particles + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + + jlist = firstneigh[i]; + jnum = numneigh[i]; + + 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) { + r = sqrt(rsq); + if (surface[i] == 0 && surface[j] == 2) surface[i] = 1; + if (surface[j] == 0 && surface[i] == 2) surface[j] = 1; + if (surface[j] == 2) rsurf[i] = MIN(rsurf[i], r); + if (surface[i] == 2) rsurf[j] = MIN(rsurf[j], r); + } + } + } + + comm_stage = 1; + comm_reverse = 2; + comm_forward = 2; + if (newton) comm->reverse_comm_fix(this); + comm->forward_comm_fix(this); + + //Now loop again and for each surface particle (2) + // find its neighbors that are bulk (0) and convert to surface vicinity (1) + // if the surface particle has no (0) or (1) neighbors then it is a spash (3) + + //for (ii = 0; ii < inum; ii++) { // is this the right i and j loop for this? + // i = ilist[ii]; + // + // if (surface[i]!=2) continue; //Only consider surface particles + // + // bool nobulkneigh = true; // whether we have no bulk neighbors + // xtmp = x[i][0]; + // ytmp = x[i][1]; + // ztmp = x[i][2]; + // jlist = firstneigh[i]; + // jnum = numneigh[i]; + // + // for (jj = 0; jj < jnum; jj++) { + // j = jlist[jj]; + // j &= NEIGHMASK; + // + // //other surface or splash neighbors do not need labeling + // if (surface[j]>=2){ + // continue; + // } + // + // //check distance criterion rij < h = cutsq/9 for quintic kernel + // delx = xtmp - x[j][0]; + // dely = ytmp - x[j][1]; + // delz = ztmp - x[j][2]; + // dx[0] = 3.0*delx; // multiplied by three here to make criterion rreverse_comm_fix(this); +// +// +// // Now need to invert each B +// int status, s; +// //LU requires a permuation matrix +// gsl_permutation * p = gsl_permutation_alloc(dim); +// for (ii = 0; ii < inum; ii++) { +// i = ilist[ii]; +// if ((surface[i]==0)||(surface[i]==3)){ +// continue; +// } +// +// //Use gsl to get Binv +// //B is not symmteric so we will use a LU decomp +// gsl_matrix_view gB = gsl_matrix_view_array(B[i],dim,dim); +// status = 0; +// status = gsl_linalg_LU_decomp(&gB.matrix,p,&s); //B[i] is now the LU decomp +// // check if decomposition failure +// if (status) { +// fprintf(stderr, "failed, gsl_errno=%d.n", status); +// continue; +// } else { +// gsl_linalg_LU_invx(&gB.matrix,p); //B[i] is now inv(B[i]) +// } +// } +// gsl_permutation_free(p); + double maggC = 0.0; + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + maggC=0; + for (a=0;adimension; + int *surface = atom->surface; + double *rsurf = atom->dvector[index_rsurf]; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (comm_stage == 0) { + buf[m++] = divr[i]; + for (a = 0; a < dim; a ++ ) + for (b = 0; b < dim; b ++) + buf[m++] = gradC[i][a*dim + b]; + } else if (comm_stage == 1) { + buf[m++] = (double) surface[i]; + buf[m++] = rsurf[i]; + } else if (comm_stage == 2) { + for (a = 0; a < dim; a ++ ) + for (b = 0; b < dim; b ++) + buf[m++] = B[i][a*dim + b]; + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOSurface::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i,a,b,k,j,m; + int dim = domain->dimension; + int *surface = atom->surface; + double *rsurf = atom->dvector[index_rsurf]; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + if (comm_stage == 0) { + divr[j] += buf[m++]; + for (a = 0; a < dim; a ++ ) + for (b = 0; b < dim; b ++) + gradC[j][a*dim + b] += buf[m++]; + } else if (comm_stage == 1) { + int temp = (int) buf[m++]; + surface[j] = MAX(surface[j], temp); + double temp2 = buf[m++]; + rsurf[j] = MIN(rsurf[j], temp2); + } else if (comm_stage == 2) { + for (a = 0; a < dim; a ++ ) + for (b = 0; b < dim; b ++) + B[j][a*dim + b] += buf[m++]; + } + } +} + + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOSurface::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i,j,a,b,k,m; + int *surface = atom->surface; + double *rsurf = atom->dvector[index_rsurf]; + m = 0; + + for (i = 0; i < n; i++) { + j = list[i]; + if (comm_stage == 0) { + buf[m++] = divr[j]; + } else if (comm_stage == 1) { + buf[m++] = (double) surface[j]; + buf[m++] = rsurf[j]; + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOSurface::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, a, b, m, last; + int *surface = atom->surface; + double *rsurf = atom->dvector[index_rsurf]; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (comm_stage == 0) { + divr[i] = buf[m++]; + } else if (comm_stage == 1) { + surface[i] = (int) buf[m++]; + rsurf[i] = buf[m++]; + } + } +} diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h new file mode 100644 index 0000000000..480a8cd8ec --- /dev/null +++ b/src/RHEO/compute_rheo_surface.h @@ -0,0 +1,72 @@ +/* -*- 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 COMPUTE_CLASS +// clang-format off +ComputeStyle(RHEO/SURFACE,ComputeRHEOSurface) +// clang-format on +#else + +#ifndef LMP_COMPUTE_RHEO_INTERFACE_H +#define LMP_COMPUTE_RHEO_INTERFACE_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeRHEOSurface : public Compute { + public: + ComputeRHEOSurface(class LAMMPS *, int, char **); + ~ComputeRHEOSurface(); + void init() override; + void init_list(int, class NeighList *) override; + void compute_peratom() override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; + + double **gradC, **n_surface; + + private: + double cut, cutsq, threshold; + int surface_style, nmax_old; + double **B, *divr; + int comm_stage; + + int index_divr; + int index_rsurf; + + double divR_limit; + int coord_limit; + + class NeighList *list; + class FixRHEO *fix_rheo; + class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOSolids *compute_solids; +}; + +} + +#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/RHEO/compute_rheo_vshift.h b/src/RHEO/compute_rheo_vshift.h index af5675fd8d..e76476e7fd 100644 --- a/src/RHEO/compute_rheo_vshift.h +++ b/src/RHEO/compute_rheo_vshift.h @@ -13,7 +13,7 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(rheo/vshift,ComputeRHEOVShift) +ComputeStyle(RHEO/VSHIFT,ComputeRHEOVShift) // clang-format on #else diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index e83a95751a..8fc48c0b3b 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -88,12 +88,24 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : thermal_flag = 1; } else if (strcmp(arg[iarg],"surface/detection") == 0) { surface_flag = 1; + if(iarg + 2 >= narg) error->all(FLERR,"Illegal surface/detection option in fix rheo"); + if (strcmp(arg[iarg + 1], "coordination")) { + surface_style = COORDINATION; + zmin_surface = utils::inumeric(FLERR,arg[iarg + 2],false,lmp); + } else if (strcmp(arg[iarg + 1], "divergence")) { + surface_style = DIVR; + divr_surface = utils::numeric(FLERR,arg[iarg + 2],false,lmp); + } else { + error->all(FLERR,"Illegal surface/detection option in fix rheo, {}", arg[iarg + 1]); + } + + iarg += 2; } else if (strcmp(arg[iarg],"interface/reconstruction") == 0) { interface_flag = 1; } else if (strcmp(arg[iarg],"rhosum") == 0) { rhosum_flag = 1; if(iarg + 1 >= narg) error->all(FLERR,"Illegal rhosum option in fix rheo"); - zmin_rhosum = utils::inumeric(FLERR,arg[iarg + 1],false,lmp); + rhosum_zmin = utils::inumeric(FLERR,arg[iarg + 1],false,lmp); iarg += 1; } else if (strcmp(arg[iarg],"rho0") == 0) { if(iarg + 1 >= narg) error->all(FLERR,"Illegal rho0 option in fix rheo"); @@ -117,6 +129,7 @@ FixRHEO::~FixRHEO() if (compute_kernel) modify->delete_compute("rheo_kernel"); if (compute_grad) modify->delete_compute("rheo_grad"); if (compute_interface) modify->delete_compute("rheo_interface"); + if (compute_surface) modify->delete_compute("compute_surface"); if (compute_rhosum) modify->delete_compute("rheo_rhosum"); if (compute_vshift) modify->delete_compute("rheo_vshift"); } @@ -128,28 +141,33 @@ FixRHEO::~FixRHEO() void FixRHEO::post_constructor() { - compute_kernel = dynamic_cast(modify->add_compute("rheo_kernel all rheo/kernel")); + compute_kernel = dynamic_cast(modify->add_compute("rheo_kernel all RHEO/KERNEL")); compute_kernel->fix_rheo = this; - std::string cmd = "rheo_grad all rheo/grad velocity rho viscosity"; + std::string cmd = "rheo_grad all RHEO/GRAD velocity rho viscosity"; if (thermal_flag) cmd += "temperature"; compute_grad = dynamic_cast(modify->add_compute(cmd)); compute_grad->fix_rheo = this; if (rhosum_flag) { - compute_rhosum = dynamic_cast(modify->add_compute("rheo_rhosum all rheo/rho/sum")); + compute_rhosum = dynamic_cast(modify->add_compute("rheo_rhosum all RHEO/RHO/SUM")); compute_rhosum->fix_rheo = this; } if (shift_flag) { - compute_vshift = dynamic_cast(modify->add_compute("rheo_vshift all rheo/vshift")); + compute_vshift = dynamic_cast(modify->add_compute("rheo_vshift all RHEO/VSHIFT")); compute_vshift->fix_rheo = this; } if (interface_flag) { - compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all rheo/interface"))); + compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all RHEO/INTERFACE"))); compute_interface->fix_rheo = this; } + + if (surface_flag) { + compute_surface = dynamic_cast(modify->add_compute(fmt::format("rheo_surface all RHEO/SURFACE"))); + compute_surface->fix_rheo = this; + } } /* ---------------------------------------------------------------------- */ @@ -180,10 +198,11 @@ void FixRHEO::setup_pre_force(int /*vflag*/) { // Check to confirm accessory fixes do not preceed FixRHEO // Note: these fixes set this flag in setup_pre_force() - if (viscosity_fix_defined || pressure_fix_defined || thermal_fix_defined || surface_fix_defined) + if (viscosity_fix_defined || pressure_fix_defined || thermal_fix_defined) error->all(FLERR, "Fix RHEO must be defined before all other RHEO fixes"); - pre_force(0); + // Calculate surfaces + if (surface_flag) compute_surface->compute_peratom(); } /* ---------------------------------------------------------------------- */ @@ -201,14 +220,10 @@ void FixRHEO::setup() if(!thermal_fix_defined && thermal_flag) error->all(FLERR, "Missing fix rheo/thermal"); - if(!surface_fix_defined && surface_flag) - error->all(FLERR, "Missing fix rheo/surface"); - // Reset to zero for next run thermal_fix_defined = 0; viscosity_fix_defined = 0; pressure_fix_defined = 0; - surface_fix_defined = 0; // Check fixes cover all atoms (doesnt ensure user covers atoms created midrun) // (pressure is currently required to be group all) @@ -259,7 +274,8 @@ void FixRHEO::initial_integrate(int /*vflag*/) double **gradr = compute_grad->gradr; double **gradv = compute_grad->gradv; - double **vshift = compute_vshift->vshift; + double **vshift; + if (shift_flag) compute_vshift->vshift; int *type = atom->type; int *mask = atom->mask; @@ -287,8 +303,11 @@ void FixRHEO::initial_integrate(int /*vflag*/) // Update gradients and interpolate solid properties compute_grad->forward_fields(); // also forwards v and rho for chi - compute_interface->store_forces(); // Need to save, wiped in exchange - compute_interface->compute_peratom(); + if (interface_flag) { + // Need to save, wiped in exchange + compute_interface->store_forces(); + compute_interface->compute_peratom(); + } compute_grad->compute_peratom(); // Position half-step @@ -350,7 +369,7 @@ void FixRHEO::pre_force(int /*vflag*/) compute_grad->forward_fields(); // also forwards v and rho for chi compute_kernel->compute_peratom(); - compute_interface->compute_peratom(); + if (interface_flag) compute_interface->compute_peratom(); compute_grad->compute_peratom(); compute_grad->forward_gradients(); @@ -369,6 +388,9 @@ void FixRHEO::pre_force(int /*vflag*/) status[i] &= ~STATUS_SHIFT; } } + + // Calculate surfaces, update status + if (surface_flag) compute_surface->compute_peratom(); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 89304fe22f..d2097ade71 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -40,9 +40,11 @@ class FixRHEO : public Fix { // Model parameters double h, rho0, csq; - int zmin_kernel, rhosum_zmin; - int kernel_style; + int zmin_kernel, zmin_rhosum, zmin_surface; + int kernel_style, surface_style; + double divr_surface; enum {QUINTIC, CRK0, CRK1, CRK2}; + enum {COORDINATION, DIVR}; // Status variables enum { @@ -75,8 +77,6 @@ class FixRHEO : public Fix { int viscosity_fix_defined; int pressure_fix_defined; int thermal_fix_defined; - int interface_fix_defined; - int surface_fix_defined; class ComputeRHEOGrad *compute_grad; class ComputeRHEOKernel *compute_kernel; From a4d971df526e71f04a8de31b642ddd512100e89c Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 20 Apr 2023 14:45:35 -0600 Subject: [PATCH 024/104] Updating surface compute --- src/RHEO/compute_rheo_grad.cpp | 2 +- src/RHEO/compute_rheo_interface.cpp | 1 - src/RHEO/compute_rheo_kernel.cpp | 12 +- src/RHEO/compute_rheo_surface.cpp | 528 ++++++++++------------------ src/RHEO/compute_rheo_surface.h | 13 +- src/RHEO/compute_rheo_vshift.cpp | 2 +- src/RHEO/fix_rheo.cpp | 2 +- src/RHEO/fix_rheo_thermal.cpp | 4 +- src/RHEO/pair_rheo.cpp | 4 +- 9 files changed, 195 insertions(+), 373 deletions(-) diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 31f60550c1..add3ed712d 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -38,7 +38,7 @@ enum{COMMGRAD, COMMFIELD}; /* ---------------------------------------------------------------------- */ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), fix_rheo(nullptr), compute_interface(nullptr), compute_kernel(nullptr), + Compute(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), compute_interface(nullptr), compute_kernel(nullptr), gradv(nullptr), gradr(nullptr), gradt(nullptr), gradn(nullptr) { if (narg < 4) error->all(FLERR,"Illegal compute rheo/grad command"); diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index 55cb81382b..059f4057f4 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -84,7 +84,6 @@ void ComputeRHEOInterface::init() // Do not create grow callback as there's no reason to copy/exchange data // Manually grow if nmax_old exceeded - int create_flag = 0; int tmp1, tmp2; int nmax = atom->nmax; int index = atom->find_custom("rheo_chi", tmp1, tmp2); diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index ac9ea75fc4..2fd189e1e4 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -55,7 +55,7 @@ Move away from h notation, use cut? ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), - C(nullptr), C0(nullptr), coordination(nullptr), compute_interface(nullptr) + list(nullptr), C(nullptr), C0(nullptr), coordination(nullptr), compute_interface(nullptr) { if (narg != 3) error->all(FLERR,"Illegal compute rheo/kernel command"); @@ -137,18 +137,18 @@ void ComputeRHEOKernel::init() ncor = 0; Mdim = 0; if (kernel_type == CRK0) { - memory->create(C0, nmax, "rheo/kernel:C0"); + memory->create(C0, nmax_old, "rheo/kernel:C0"); } else if (kernel_type == CRK1) { Mdim = 1 + dim; ncor = 1 + dim; - memory->create(C, nmax, ncor, Mdim, "rheo/kernel:C"); + memory->create(C, nmax_old, ncor, Mdim, "rheo/kernel:C"); comm_forward = ncor * Mdim; } else if (kernel_type == CRK2) { //Polynomial basis size (up to quadratic order) Mdim = 1 + dim + dim * (dim + 1) / 2; //Number of sets of correction coefficients (1 x y xx yy) + z zz (3D) ncor = 1 + 2 * dim; - memory->create(C, nmax, ncor, Mdim, "rheo/kernel:C"); + memory->create(C, nmax_old, ncor, Mdim, "rheo/kernel:C"); comm_forward = ncor * Mdim; } } @@ -491,7 +491,7 @@ void ComputeRHEOKernel::compute_peratom() gsl_error_flag = 0; gsl_error_tags.clear(); - int i, j, ii, jj, jnum, g, a, b, gsl_error; + int i, j, ii, jj, inum, jnum, g, a, b, gsl_error; double xtmp, ytmp, ztmp, r, rsq, w, vj; double dx[3]; gsl_matrix_view gM; @@ -506,7 +506,7 @@ void ComputeRHEOKernel::compute_peratom() int *status = atom->status; tagint *tag = atom->tag; - int inum, *ilist, *jlist, *numneigh, **firstneigh; + int *ilist, *jlist, *numneigh, **firstneigh; inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index dff5db4cfa..5b3aeabf26 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -18,135 +18,97 @@ #include "compute_rheo_surface.h" -#include "fix_rheo.h" -#include "compute_rheo_kernel.h" -#include "compute_rheo_solids.h" -#include "atom.h" -#include "memory.h" #include "atom.h" #include "comm.h" -#include "modify.h" +#include "compute_rheo_kernel.h" +#include "compute_rheo_solids.h" +#include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "math_extra.h" +#include "memory.h" #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" -#include "error.h" -#include "force.h" -#include "domain.h" using namespace LAMMPS_NS; using namespace FixConst; +using namespace MathExtra; + +#define epsilon 1e-10; /* ---------------------------------------------------------------------- */ ComputeRHEOSurface::ComputeRHEOSurface(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) + Fix(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), compute_kernel(nullptr), compute_solids(nullptr), + B(nullptr), gradC(nullptr), nsurface(nullptr), divr(nullptr), rsurface(nullptr) { - if (narg < 6) error->all(FLERR,"Illegal fix rheo/surface command"); - - cut = utils::numeric(FLERR,arg[3],false,lmp); - divR_limit = utils::numeric(FLERR,arg[4],false,lmp); - coord_limit = utils::inumeric(FLERR,arg[5],false,lmp); - - divr_flag = 1; - if (narg == 7) { - divr_flag = 0; - } + if (narg != 3) error->all(FLERR,"Illegal fix RHEO/SURFACE command"); int dim = domain->dimension; - - peratom_flag = 1; - size_peratom_cols = dim; - peratom_freq = 1; - - comm_forward = 2; - comm_reverse = dim*dim + 1; - - cutsq = cut*cut; - - B = nullptr; - gradC = nullptr; - n_surface = nullptr; - - int nall = atom->nlocal + atom->nghost; - nmax = nall; - memory->create(B,nmax,dim*dim,"fix/rheo/surface:B"); - memory->create(gradC,nmax,dim*dim,"fix/rheo/surface:gradC"); - memory->create(n_surface,nmax,dim,"fix/rheo/surface:B"); - array_atom = n_surface; - - compute_kernel = nullptr; - compute_solids = NULL; - fix_rheo = nullptr; + comm_reverse = dim * dim + 1; } /* ---------------------------------------------------------------------- */ ComputeRHEOSurface::~ComputeRHEOSurface() { - if (modify->nfix) modify->delete_fix("PROPERTY_ATOM_RHEO_SURFACE"); + // Remove custom property if it exists + int tmp1, tmp2, index; + index = atom->find_custom("rheo_divr", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 0); + + index = atom->find_custom("rheo_rsurface", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 0); + + index = atom->find_custom("rheo_nsurface", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 3); memory->destroy(B); memory->destroy(gradC); - memory->destroy(n_surface); -} - -void ComputeRHEOSurface::post_constructor() -{ - //Store persistent per atom quantities - char **fixarg = new char*[5]; - fixarg[0] = (char *) "PROPERTY_ATOM_RHEO_SURFACE"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "property/atom"; - fixarg[3] = (char *) "d_divr"; - fixarg[4] = (char *) "d_rsurf"; - modify->add_fix(5,fixarg,1); - - int temp_flag; - index_divr = atom->find_custom("divr", temp_flag); - if ((index_divr < 0) || (temp_flag != 1)) - error->all(FLERR, "Pair rheo/surface can't find fix property/atom divr"); - - index_rsurf = atom->find_custom("rsurf", temp_flag); - if ((index_rsurf < 0) || (temp_flag != 1)) - error->all(FLERR, "Pair rheo/surface can't find fix property/atom rsurf"); - - delete [] fixarg; - divr = atom->dvector[index_divr]; -} -/* ---------------------------------------------------------------------- */ - -int ComputeRHEOSurface::setmask() -{ - int mask = 0; - mask |= PRE_FORCE; - return mask; } /* ---------------------------------------------------------------------- */ void ComputeRHEOSurface::init() { - // need an occasional full neighbor list - int irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->pair = 0; - neighbor->requests[irequest]->fix = 1; - neighbor->requests[irequest]->half = 1; - neighbor->requests[irequest]->full = 0; - - int flag; - int ifix = modify->find_fix_by_style("rheo"); - if (ifix == -1) error->all(FLERR, "Need to define fix rheo to use fix rheo/surface"); - fix_rheo = ((FixRHEO *) modify->fix[ifix]); compute_kernel = fix_rheo->compute_kernel; compute_solids = fix_rheo->compute_solids; -} + cut = fix_rheo->cut; + rho0 = fix_rheo->rho0; + threshold_style = fix_rheo->surface_style; + threshold_divr = fix_rheo->divrsurface; + threshold_z = fix_rheo->zminsurface; -/* ---------------------------------------------------------------------- */ + cutsq = cut * cut; -void ComputeRHEOSurface::setup_pre_force(int /*vflag*/) -{ - pre_force(0); + // Create rsurface, divr, nsurface arrays if they don't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_old exceeded + // For B and gradC, create a local array since they are unlikely to be printed + + int tmp1, tmp2; + int index = atom->find_custom("rheo_divr", tmp1, tmp2); + if (index == -1) index = atom->add_custom("rheo_divr", 1, 0); + divr = atom->dvector[index]; + + index = atom->find_custom("rheo_rsurface", tmp1, tmp2); + if (index == -1) index = atom->add_custom("rheo_rsurface", 1, 0); + rsurface = atom->dvector[index]; + + index = atom->find_custom("rheo_nsurface", tmp1, tmp2); + if (index == -1) index = atom->add_custom("rheo_nsurface", 1, 3); + nsurface = atom->darray[index]; + + nmax_old = atom->nmax; + memory->create(B, nmax_old, dim * dim, "rheo/surface:B"); + memory->create(gradC, nmax_old, dim * dim, "rheo/surface:gradC"); + + // need an occasional half neighbor list + neighbor->add_request(this, NeighConst::REQ_HALF); } /* ---------------------------------------------------------------------- */ @@ -158,60 +120,56 @@ void ComputeRHEOSurface::init_list(int /*id*/, NeighList *ptr) /* ---------------------------------------------------------------------- */ -void ComputeRHEOSurface::pre_force(int /*vflag*/) +void ComputeRHEOSurface::compute_peratom() { - int i, j, ii, jj, jnum, a, b, itype, jtype; - double xtmp, ytmp, ztmp, delx, dely, delz, rsq, r, wp, Voli, Volj, rhoi, rhoj; - int *jlist; + int i, j, ii, jj, inum, jnum, a, b, itype, jtype, fluidi, fluidj; + double xtmp, ytmp, ztmp, rsq, Voli, Volj, rhoi, rhoj; double *dWij, *dWji; double dx[3]; + int *ilist, *jlist, *numneigh, **firstneigh; - divr = atom->dvector[index_divr]; - - // neighbor list variables - int inum, *ilist, *numneigh, **firstneigh; int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; double **x = atom->x; - int *surface = atom->surface; - int *phase = atom->phase; - double *rsurf = atom->dvector[index_rsurf]; + int *status = atom->status; int newton = force->newton; int dim = domain->dimension; int *mask = atom->mask; int *type = atom->type; double *mass = atom->mass; double *rho = atom->rho; - double *temp = atom->temp; + int *coordination = compute_kernel->coordination; inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; - if (nmax <= nall) { - nmax = nall; - memory->destroy(B); - memory->destroy(gradC); - memory->destroy(n_surface); + int nmax = atom->nmax; + if (nmax_old <= nmax) { + memory->grow(divr, nmax, "atom:rheo_divr"); + memory->grow(rsurface, nmax, "atom:rheo_rsurface"); + memory->grow(nsurface, nmax, 3, "atom:rheo_nsurface"); - memory->create(B,nmax,dim*dim,"fix/rheo/surface:B"); - memory->create(gradC,nmax,dim*dim,"fix/rheo/surface:gradC"); - memory->create(n_surface,nmax,dim,"fix/rheo/surface:n_surface"); - array_atom = n_surface; + memory->grow(B, nmax, dim * dim, "rheo/surface:B"); + memory->grow(gradC, nmax, dim * dim, "rheo/surface:gradC"); + + nmax_old = atom->nmax; } + int nall = nlocal + atom->nghost; for (i = 0; i < nall; i++) { for (a = 0; a < dim; a++) { for (b = 0; b < dim; b++) { - B[i][a*dim + b] = 0.0; - gradC[i][a*dim + b] = 0.0; + B[i][a * dim + b] = 0.0; + gradC[i][a * dim + b] = 0.0; } - n_surface[i][a] = 0.0; + nsurface[i][a] = 0.0; } divr[i] = 0.0; - surface[i] = 0; + + // Remove surface settings + status[i] &= FixRHEO::surfacemask; } // loop over neighbors to calculate the average orientation of neighbors @@ -224,98 +182,105 @@ void ComputeRHEOSurface::pre_force(int /*vflag*/) jlist = firstneigh[i]; jnum = numneigh[i]; itype = type[i]; + fluidi = status[i] & FixRHEO::STATUS_FLUID; 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]; - dx[0] = delx; - dx[1] = dely; - dx[2] = delz; - rsq = delx * delx + dely * dely + delz * delz; + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + + rsq = lensq(dx); if (rsq < cutsq) { jtype = type[j]; + fluidj = status[j] & FixRHEO::STATUS_FLUID; rhoi = rho[i]; rhoj = rho[j]; // Add corrections for walls - if (phase[i] <= FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { - rhoj = compute_solids->correct_rho(j,i); - } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] <= FixRHEO::FLUID_MAX) { - rhoi = compute_solids->correct_rho(i,j); - } else if (phase[i] > FixRHEO::FLUID_MAX && phase[j] > FixRHEO::FLUID_MAX) { - rhoi = 1.0; - rhoj = 1.0; + if (fluidi && (!fluidj)) { + rhoj = compute_solids->correct_rho(j, i); + } else if ((!fluidi) && fluidj) { + rhoi = compute_solids->correct_rho(i, j); + } else if ((!fluidi) && (!fluidj)) { + rhoi = rho0; + rhoj = rho0; } - Voli = mass[itype]/rhoi; - Volj = mass[jtype]/rhoj; + Voli = mass[itype] / rhoi; + Volj = mass[jtype] / rhoj; - //compute kernel gradient - wp = compute_kernel->calc_dw_quintic(i, j, delx, dely, delz, sqrt(rsq),compute_kernel->dWij,compute_kernel->dWji); - //wp = compute_kernel->calc_dw(i, j, delx, dely, delz, sqrt(rsq));//,compute_kernel->dWij,compute_kernel->dWji); + wp = compute_kernel->calc_dw_quintic(i, j, dx[0], dx[1], dx[2], sqrt(rsq),dWij, dWji); - dWij = compute_kernel->dWij; - dWji = compute_kernel->dWji; - - for (a=0; areverse_comm_fix(this); - comm->forward_comm_fix(this); + comm_reverse = dim * dim + 1; + comm_forward = 1; + if (newton) comm->reverse_comm(this); + comm->forward_comm(this); + + // calculate nsurface for local atoms + // Note, this isn't forwarded to ghosts + double maggC; + for (i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + maggC = 0.0; + for (a = 0;a < dim; a++) + maggC += gradC[i][a] * gradC[i][a]; + maggC = sqrt(maggC) + EPSILON; + maggC = 1.0 / maggC; + for (a = 0; a < dim; a++) + nsurface[i][a] = -gradC[i][a] * maggC; + } + } - int *coordination = compute_kernel->coordination; // Find the free-surface - //0-bulk 1-surf vicinity 2-surface 3-splash - if (divr_flag) { + if (threshold_style == FixRHEO::DIVR) { for (i = 0; i < nall; i++) { if (mask[i] & groupbit) { - surface[i] = 0; - rsurf[i] = cut; //Maximum range that can be seen - if (divr[i] < divR_limit) { - surface[i] = 2; - rsurf[i] = 0.0; - if (coordination[i] < coord_limit) surface[i] = 3; + status[i] |= FixRHEO::STATUS_BULK; + rsurface[i] = cut; + if (divr[i] < threshold_divr) { + status[i] |= FixRHEO::STATUS_SURFACE; + rsurface[i] = 0.0; + if (coordination[i] < threshold_z) + status[i] |= FixRHEO::STATUS_SPLASH; } } } } else { for (i = 0; i < nall; i++) { if (mask[i] & groupbit) { - surface[i] = 0; - rsurf[i] = cut; //Maximum range that can be seen + status[i] |= FixRHEO::STATUS_BULK; + rsurface[i] = cut; if (coordination[i] < divR_limit) { - surface[i] = 2; - rsurf[i] = 0.0; - if (coordination[i] < coord_limit) surface[i] = 3; + status[i] |= FixRHEO::STATUS_SURFACE; + rsurface[i] = 0.0; + if (coordination[i] < threshold_z) + status[i] |= FixRHEO::STATUS_SPLASH; } } } } - //comm_stage = 1; - //comm_forward = 1; - //comm->forward_comm_fix(this); // communicate free surface particles - for (ii = 0; ii < inum; ii++) { i = ilist[ii]; xtmp = x[i][0]; @@ -329,167 +294,37 @@ void ComputeRHEOSurface::pre_force(int /*vflag*/) 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; + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = lensq(dx); if (rsq < cutsq) { - r = sqrt(rsq); - if (surface[i] == 0 && surface[j] == 2) surface[i] = 1; - if (surface[j] == 0 && surface[i] == 2) surface[j] = 1; - if (surface[j] == 2) rsurf[i] = MIN(rsurf[i], r); - if (surface[i] == 2) rsurf[j] = MIN(rsurf[j], r); + if ((status[i] & FixRHEO::STATUS_BULK) && (status[j] & FixRHEO::STATUS_SURFACE)) { + status[i] &= FixRHEO::surfacemask; + status[i] |= FixRHEO::STATUS_LAYER; + } + + if (status[j] & FixRHEO::STATUS_SURFACE) rsurface[i] = MIN(rsurface[i], sqrt(rsq)); + + + if (j < nlocal || newton) { + if ((status[j] & FixRHEO::STATUS_BULK) && (status[i] & FixRHEO::STATUS_SURFACE)) { + status[j] &= FixRHEO::surfacemask; + status[j] |= FixRHEO::STATUS_LAYER; + } + + if (status[i] & FixRHEO::STATUS_SURFACE) rsurface[j] = MIN(rsurface[j], sqrt(rsq)); + } } } } + // forward/reverse status and rsurface comm_stage = 1; comm_reverse = 2; comm_forward = 2; - if (newton) comm->reverse_comm_fix(this); - comm->forward_comm_fix(this); - - //Now loop again and for each surface particle (2) - // find its neighbors that are bulk (0) and convert to surface vicinity (1) - // if the surface particle has no (0) or (1) neighbors then it is a spash (3) - - //for (ii = 0; ii < inum; ii++) { // is this the right i and j loop for this? - // i = ilist[ii]; - // - // if (surface[i]!=2) continue; //Only consider surface particles - // - // bool nobulkneigh = true; // whether we have no bulk neighbors - // xtmp = x[i][0]; - // ytmp = x[i][1]; - // ztmp = x[i][2]; - // jlist = firstneigh[i]; - // jnum = numneigh[i]; - // - // for (jj = 0; jj < jnum; jj++) { - // j = jlist[jj]; - // j &= NEIGHMASK; - // - // //other surface or splash neighbors do not need labeling - // if (surface[j]>=2){ - // continue; - // } - // - // //check distance criterion rij < h = cutsq/9 for quintic kernel - // delx = xtmp - x[j][0]; - // dely = ytmp - x[j][1]; - // delz = ztmp - x[j][2]; - // dx[0] = 3.0*delx; // multiplied by three here to make criterion rreverse_comm_fix(this); -// -// -// // Now need to invert each B -// int status, s; -// //LU requires a permuation matrix -// gsl_permutation * p = gsl_permutation_alloc(dim); -// for (ii = 0; ii < inum; ii++) { -// i = ilist[ii]; -// if ((surface[i]==0)||(surface[i]==3)){ -// continue; -// } -// -// //Use gsl to get Binv -// //B is not symmteric so we will use a LU decomp -// gsl_matrix_view gB = gsl_matrix_view_array(B[i],dim,dim); -// status = 0; -// status = gsl_linalg_LU_decomp(&gB.matrix,p,&s); //B[i] is now the LU decomp -// // check if decomposition failure -// if (status) { -// fprintf(stderr, "failed, gsl_errno=%d.n", status); -// continue; -// } else { -// gsl_linalg_LU_invx(&gB.matrix,p); //B[i] is now inv(B[i]) -// } -// } -// gsl_permutation_free(p); - double maggC = 0.0; - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - maggC=0; - for (a=0;areverse_comm(this); + comm->forward_comm(this); } /* ---------------------------------------------------------------------- */ @@ -498,8 +333,7 @@ int ComputeRHEOSurface::pack_reverse_comm(int n, int first, double *buf) { int i,a,b,k,m,last; int dim = domain->dimension; - int *surface = atom->surface; - double *rsurf = atom->dvector[index_rsurf]; + int *status = atom->status; m = 0; last = first + n; @@ -508,14 +342,10 @@ int ComputeRHEOSurface::pack_reverse_comm(int n, int first, double *buf) buf[m++] = divr[i]; for (a = 0; a < dim; a ++ ) for (b = 0; b < dim; b ++) - buf[m++] = gradC[i][a*dim + b]; + buf[m++] = gradC[i][a * dim + b]; } else if (comm_stage == 1) { - buf[m++] = (double) surface[i]; - buf[m++] = rsurf[i]; - } else if (comm_stage == 2) { - for (a = 0; a < dim; a ++ ) - for (b = 0; b < dim; b ++) - buf[m++] = B[i][a*dim + b]; + buf[m++] = (double) status[i]; + buf[m++] = rsurface[i]; } } return m; @@ -527,8 +357,8 @@ void ComputeRHEOSurface::unpack_reverse_comm(int n, int *list, double *buf) { int i,a,b,k,j,m; int dim = domain->dimension; - int *surface = atom->surface; - double *rsurf = atom->dvector[index_rsurf]; + int *status = atom->status; + int temp; m = 0; for (i = 0; i < n; i++) { @@ -537,16 +367,14 @@ void ComputeRHEOSurface::unpack_reverse_comm(int n, int *list, double *buf) divr[j] += buf[m++]; for (a = 0; a < dim; a ++ ) for (b = 0; b < dim; b ++) - gradC[j][a*dim + b] += buf[m++]; + gradC[j][a * dim + b] += buf[m++]; } else if (comm_stage == 1) { - int temp = (int) buf[m++]; - surface[j] = MAX(surface[j], temp); - double temp2 = buf[m++]; - rsurf[j] = MIN(rsurf[j], temp2); - } else if (comm_stage == 2) { - for (a = 0; a < dim; a ++ ) - for (b = 0; b < dim; b ++) - B[j][a*dim + b] += buf[m++]; + + temp = (int) buf[m++]; + if ((status[j] & FixRHEO::STATUS_BULK) && (temp & FixRHEO::STATUS_LAYER)) + status[j] = temp; + + rsurface[j] = MIN(rsurface[j], buf[m++]); } } } @@ -558,8 +386,7 @@ int ComputeRHEOSurface::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,a,b,k,m; - int *surface = atom->surface; - double *rsurf = atom->dvector[index_rsurf]; + int *status = atom->status; m = 0; for (i = 0; i < n; i++) { @@ -567,8 +394,8 @@ int ComputeRHEOSurface::pack_forward_comm(int n, int *list, double *buf, if (comm_stage == 0) { buf[m++] = divr[j]; } else if (comm_stage == 1) { - buf[m++] = (double) surface[j]; - buf[m++] = rsurf[j]; + buf[m++] = (double) status[j]; + buf[m++] = rsurface[j]; } } return m; @@ -579,8 +406,7 @@ int ComputeRHEOSurface::pack_forward_comm(int n, int *list, double *buf, void ComputeRHEOSurface::unpack_forward_comm(int n, int first, double *buf) { int i, k, a, b, m, last; - int *surface = atom->surface; - double *rsurf = atom->dvector[index_rsurf]; + int *status = atom->status; m = 0; last = first + n; @@ -588,8 +414,8 @@ void ComputeRHEOSurface::unpack_forward_comm(int n, int first, double *buf) if (comm_stage == 0) { divr[i] = buf[m++]; } else if (comm_stage == 1) { - surface[i] = (int) buf[m++]; - rsurf[i] = buf[m++]; + status[i] = (int) buf[m++]; + rsurface[i] = buf[m++]; } } } diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index 480a8cd8ec..8d0b681c6f 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -36,16 +36,13 @@ class ComputeRHEOSurface : public Compute { int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; - double **gradC, **n_surface; + double **nsurface, **rsurface; private: - double cut, cutsq, threshold; - int surface_style, nmax_old; - double **B, *divr; - int comm_stage; - - int index_divr; - int index_rsurf; + double cut, cutsq, rho0, threshold_divr; + int surface_style, nmax_old, threshold_z; + double **B, **gradC, *divr; + int threshold_style, comm_stage; double divR_limit; int coord_limit; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 6cbd6e96da..1b3edcffd8 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -36,7 +36,7 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), vshift(nullptr), fix_rheo(nullptr), fix_rheo(nullptr), + Compute(lmp, narg, arg), list(nullptr), vshift(nullptr), fix_rheo(nullptr), compute_kernel(nullptr), compute_interface(nullptr) { if (narg != 3) error->all(FLERR,"Illegal compute RHEO/VShift command"); diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 8fc48c0b3b..5358cc4cba 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -377,7 +377,7 @@ void FixRHEO::pre_force(int /*vflag*/) if (shift_flag) compute_vshift->compute_peratom(); - // Remove extra shifting/no force options options + // Remove extra shifting/no force options int *status = atom->status; int nall = atom->nlocal + atom->nghost; for (int i = 0; i < nall; i++) { diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 1912dc9f8c..fd08f39fd7 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -269,10 +269,10 @@ void FixRHEOThermal::post_integrate() } if (Ti > Tci) { - status[i] &= phasemask; + status[i] &= FixRHEO::phasemask; status[i] |= FixRHEO::STATUS_FLUID; } else if (!(status[i] & FixRHEO::STATUS_SOLID)) - status[i] &= phasemask; + status[i] &= FixRHEO::phasemask; status[i] |= FixRHEO::STATUS_FREEZING; } } diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 1eb2a43e1a..5974b9b756 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -216,8 +216,8 @@ void PairRHEO::compute(int eflag, int vflag) fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; } else if ((!fluidi) && (!fluidj)) { - rhoi = 1.0; - rhoj = 1.0; + rhoi = rho0; + rhoj = rho0; } // Repel if close to inner solid particle From de0e4bb170f7a2f7ae59616ca4f4d203e6eccc68 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 20 Apr 2023 16:17:04 -0600 Subject: [PATCH 025/104] Rho sum compute --- src/RHEO/compute_rheo_kernel.cpp | 234 ++++++++++++++++-------------- src/RHEO/compute_rheo_kernel.h | 3 + src/RHEO/compute_rheo_rho_sum.cpp | 184 +++++++++++++++++++++++ src/RHEO/compute_rheo_rho_sum.h | 50 +++++++ src/RHEO/compute_rheo_surface.cpp | 2 +- src/RHEO/compute_rheo_surface.h | 17 +-- src/RHEO/fix_rheo.cpp | 6 +- 7 files changed, 371 insertions(+), 125 deletions(-) create mode 100644 src/RHEO/compute_rheo_rho_sum.cpp create mode 100644 src/RHEO/compute_rheo_rho_sum.h diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 2fd189e1e4..c0b61daae3 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -47,21 +47,46 @@ using namespace MathExtra; enum {QUINTIC, CRK0, CRK1, CRK2}; #define DELTA 2000 -Todo: convert delx dely delz to an array -Should vshift be using kernel quintic? -Move away from h notation, use cut? - /* ---------------------------------------------------------------------- */ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), list(nullptr), C(nullptr), C0(nullptr), coordination(nullptr), compute_interface(nullptr) { - if (narg != 3) error->all(FLERR,"Illegal compute rheo/kernel command"); + if (narg != 4) error->all(FLERR,"Illegal compute rheo/kernel command"); + + kernel_style = (SubModelType) utils::inumeric(FLERR,arg[3],false,lmp); + + + if (kernel_style == FixRHEO::QUINTIC) { + correction_order = -1; + } else if (kernel_style == FixRHEO::CRK0) { + correction_order = 0; + } else if (kernel_style == FixRHEO::CRK1) { + correction_order = 1; + } else if (kernel_style == FixRHEO::CRK2) { + correction_order = 2; + } - comm_forward = 1; // Always minimum for coordination solid_flag = 0; dim = domain->dimension; + + comm_forward = 1; + ncor = 0; + Mdim = 0; + if (kernel_type == CRK1) { + Mdim = 1 + dim; + ncor = 1 + dim; + comm_forward = ncor * Mdim; + } else if (kernel_type == CRK2) { + //Polynomial basis size (up to quadratic order) + Mdim = 1 + dim + dim * (dim + 1) / 2; + //Number of sets of correction coefficients (1 x y xx yy) + z zz (3D) + ncor = 1 + 2 * dim; + comm_forward = ncor * Mdim; + } + + comm_forward_save = comm_forward; } /* ---------------------------------------------------------------------- */ @@ -93,22 +118,12 @@ void ComputeRHEOKernel::init() solid_flag = 1; } - kernel_style = fix_rheo->kernel_style; zmin = fix_rheo->zmin_kernel; h = fix_rheo->h; hsq = h * h; hinv = 1.0 / h; hsqinv = hinv * hinv; - if (kernel_style == FixRHEO::QUINTIC) { - correction_order = -1; - } else if (kernel_style == FixRHEO::CRK0) { - correction_order = 0; - } else if (kernel_style == FixRHEO::CRK1) { - correction_order = 1; - } else if (kernel_style == FixRHEO::CRK2) { - correction_order = 2; - } if (dim == 3) { pre_w = 0.002652582384864922 * 27.0 * ihsq * ih; @@ -133,23 +148,13 @@ void ComputeRHEOKernel::init() coordination = atom->ivector[index]; // Create local arrays for kernel arrays, I can't foresee a reason to print - comm_forward = 1; - ncor = 0; - Mdim = 0; + if (kernel_type == CRK0) { memory->create(C0, nmax_old, "rheo/kernel:C0"); } else if (kernel_type == CRK1) { - Mdim = 1 + dim; - ncor = 1 + dim; memory->create(C, nmax_old, ncor, Mdim, "rheo/kernel:C"); - comm_forward = ncor * Mdim; } else if (kernel_type == CRK2) { - //Polynomial basis size (up to quadratic order) - Mdim = 1 + dim + dim * (dim + 1) / 2; - //Number of sets of correction coefficients (1 x y xx yy) + z zz (3D) - ncor = 1 + 2 * dim; memory->create(C, nmax_old, ncor, Mdim, "rheo/kernel:C"); - comm_forward = ncor * Mdim; } } @@ -491,6 +496,8 @@ void ComputeRHEOKernel::compute_peratom() gsl_error_flag = 0; gsl_error_tags.clear(); + if (kernel_type == FixRHEO::QUINTIC) return; + int i, j, ii, jj, inum, jnum, g, a, b, gsl_error; double xtmp, ytmp, ztmp, r, rsq, w, vj; double dx[3]; @@ -513,48 +520,11 @@ void ComputeRHEOKernel::compute_peratom() firstneigh = list->firstneigh; // Grow arrays if necessary - int nmax = atom->nmax; - if (nmax_old < nmax) - memory->grow(coordination, nmax, "atom:rheo_coordination"); + if (nmax_old < atom->nmax) grow_arrays(atom->nmax); - if (kernel_type == FixRHEO::CRK0) { - memory->grow(C0, nmax, "rheo/kernel:C0"); - } else if (correction_order > 0) { - memory->grow(C, nmax, ncor, Mdim, "rheo/kernel:C"); - } - - nmax_old = atom->nmax; - } - - if (kernel_type == FixRHEO::QUINTIC) { - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - jlist = firstneigh[i]; - jnum = numneigh[i]; - coordination[i] = 0; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - dx[0] = xtmp - x[j][0]; - dx[1] = ytmp - x[j][1]; - dx[2] = ztmp - x[j][2]; - rsq = lensq(dx); - - if (rsq < hsq) { - coordination[i] += 1; - } - } - } - } else if (kernel_type == FixRHEO::CRK0) { + if (kernel_type == FixRHEO::CRK0) { double M; - for (ii = 0; ii < inum; ii++) { i = ilist[ii]; xtmp = x[i][0]; @@ -566,7 +536,6 @@ void ComputeRHEOKernel::compute_peratom() //Initialize M to zero: M = 0; - coordination[i] = 0; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -584,7 +553,6 @@ void ComputeRHEOKernel::compute_peratom() vj = mass[type[j]] / compute_interface->correct_rho(j,i); } else vj = mass[type[j]] / rho[j]; - coordination[i] += 1; M += w * vj; } } @@ -613,7 +581,6 @@ void ComputeRHEOKernel::compute_peratom() M[a * Mdim + b] = 0; } } - coordination[i] = 0; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -658,8 +625,6 @@ void ComputeRHEOKernel::compute_peratom() } } - coordination[i] += 1; - // Populate the upper triangle for (a = 0; a < Mdim; a++) { for (b = a; b < Mdim; b++) { @@ -733,7 +698,74 @@ void ComputeRHEOKernel::compute_peratom() } // communicate calculated quantities - comm->forward_comm_compute(this); + comm_stage = 1; + comm_forward = comm_forward_save; + comm->forward_comm(this); +} + + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOKernel::compute_coordination() +{ + int i, j, ii, jj, inum, jnum; + double xtmp, ytmp, ztmp, rsq; + double dx[3]; + + double **x = atom->x; + + int *ilist, *jlist, *numneigh, **firstneigh; + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // Grow arrays if necessary + if (nmax_old < atom->nmax) grow_arrays(atom->nmax); + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + + jlist = firstneigh[i]; + jnum = numneigh[i]; + coordination[i] = 0; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = lensq(dx); + + if (rsq < hsq) + coordination[i] += 1; + } + } + + // communicate calculated quantities + comm_stage = 0; + comm_forward = 1; + comm->forward_comm(this); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOKernel::grow_arrays(int nmax) +{ + memory->grow(coordination, nmax, "atom:rheo_coordination"); + + if (kernel_type == FixRHEO::CRK0) { + memory->grow(C0, nmax, "rheo/kernel:C0"); + } else if (correction_order > 0) { + memory->grow(C, nmax, ncor, Mdim, "rheo/kernel:C"); + } + + nmax_old = nmax; } /* ---------------------------------------------------------------------- */ @@ -743,26 +775,19 @@ int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf, { int i,j,k,m,a,b; m = 0; - if (correction_order > 0) { - for (i = 0; i < n; i++) { - j = list[i]; - for (a = 0; a < ncor; a++) { - for (b = 0; b < Mdim; b++) { - buf[m++] = C[j][a][b]; - } + + for (i = 0; i < n; i++) { + j = list[i]; + if (comm_stage == 0) { + buf[m++] = coordination[j]; + } else { + if (kernel_type == FixRHEO::CRK0) { + buf[m++] = C0[j]; + } else { + for (a = 0; a < ncor; a++) + for (b = 0; b < Mdim; b++) + buf[m++] = C[j][a][b]; } - buf[m++] = coordination[j]; - } - } else if (kernel_type == FixRHEO::CRK0) { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = C0[j]; - buf[m++] = coordination[j]; - } - } else { - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = coordination[j]; } } return m; @@ -775,23 +800,18 @@ void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) int i, k, m, last,a,b; m = 0; last = first + n; - if (correction_order > 0) { - for (i = first; i < last; i++) { - for (a = 0; a < ncor; a++) { - for (b = 0; b < Mdim; b++) { - C[i][a][b] = buf[m++]; - } + + for (i = first; i < last; i++) { + if (comm_stage == 0) { + coordination[i] = buf[m++]; + } else { + if (kernel_type == FixRHEO::CRK0) { + C0[i] = buf[m++]; + } else { + for (a = 0; a < ncor; a++) + for (b = 0; b < Mdim; b++) + C[i][a][b] = buf[m++]; } - coordination[i] = buf[m++]; - } - } else if (kernel_type == FixRHEO::CRK0) { - for (i = first; i < last; i++) { - C0[i] = buf[m++]; - coordination[i] = buf[m++]; - } - } else { - for (i = first; i < last; i++) { - coordination[i] = buf[m++]; } } } diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index ed2b6ff5f2..4fbdb966b4 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -35,16 +35,19 @@ class ComputeRHEOKernel : public Compute { int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; double memory_usage() override; + void compute_coordination(); double calc_w(int,int,double,double,double,double); double calc_dw(int,int,double,double,double,double); double calc_w_quintic(int,int,double,double,double,double); double calc_dw_quintic(int,int,double,double,double,double,double *,double *); + void grow_arrays(int); double dWij[3], dWji[3], Wij, Wji; int correction_order; int *coordination; private: + int comm_stage, comm_forward_save; int solid_flag; int gsl_error_flag; std::unordered_set gsl_error_tags; diff --git a/src/RHEO/compute_rheo_rho_sum.cpp b/src/RHEO/compute_rheo_rho_sum.cpp new file mode 100644 index 0000000000..fafd948538 --- /dev/null +++ b/src/RHEO/compute_rheo_rho_sum.cpp @@ -0,0 +1,184 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://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_rheo_rho_sum.h" + +#include "atom.h" +#include "comm.h" +#include "compute_rheo_kernel.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeRHEORhoSum::ComputeRHEORhoSum(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr) +{ + if (narg != 3) error->all(FLERR,"Illegal compute RHEO/rho command"); + + comm_forward = 1; + comm_reverse = 1; +} + +/* ---------------------------------------------------------------------- */ + +ComputeRHEORhoSum::~ComputeRHEORhoSum() {} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEORhoSum::init() +{ + compute_kernel = fix_rheo->compute_kernel; + cut = fix_rheo->cut; + cutsq = cut * cut; + + // need an occasional half neighbor list + neighbor->add_request(this, NeighConst::REQ_HALF); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEORhoSum::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + + +void ComputeRHEORhoSum::compute_peratom() +{ + int i, j, ii, jj, inum, jnum, itype, jtype; + double xtmp, ytmp, ztmp, delx, dely, delz; + int *ilist, *jlist, *numneigh, **firstneigh; + double rsq, w; + + int nlocal = atom->nlocal; + + double **x = atom->x; + double *rho = atom->rho; + int *type = atom->type; + int *status = atom->status; + double *mass = atom->mass; + int newton = force->newton; + + double jmass; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + int nall = nlocal + atom->nghost; + + // initialize arrays, local with quintic self-contribution, ghosts are zeroed + for (i = 0; i < nlocal; i++) { + w = compute_kernel->calc_w_quintic(i, i, 0.0, 0.0, 0.0, 0.0); + rho[i] += w * mass[type[i]]; + } + + for (i = nlocal; i < nall; i++) rho[i] = 0.0; + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + 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) { + w = compute_kernel->calc_w(i, j, delx, dely, delz, sqrt(rsq)); + rho[i] += w * mass[type[i]]; + if (newton || j < nlocal) { + rho[j] += w * mass[type[j]]; + } + } + } + } + + if (newton) comm->reverse_comm(this); + comm->forward_comm(this); +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEORhoSum::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i,j,k,m; + double * rho = atom->rho; + m = 0; + + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = coordination[j]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ +void ComputeRHEORhoSum::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double * rho = atom->rho; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + rho[i] = buf[m++]; + } +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEORhoSum::pack_reverse_comm(int n, int first, double *buf) +{ + int i,k,m,last; + double *rho = atom->rho; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = rho[i]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEORhoSum::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i,k,j,m; + double *rho = atom->rho; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + rho[j] += buf[m++]; + } +} diff --git a/src/RHEO/compute_rheo_rho_sum.h b/src/RHEO/compute_rheo_rho_sum.h new file mode 100644 index 0000000000..a411d5ed29 --- /dev/null +++ b/src/RHEO/compute_rheo_rho_sum.h @@ -0,0 +1,50 @@ +/* -*- 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 COMPUTE_CLASS +// clang-format off +ComputeStyle(RHEO/RHO/SUM,ComputeRHEORhoSum) +// clang-format on +#else + +#ifndef LMP_COMPUTE_RHEO_RHO_SUM_H +#define LMP_COMPUTE_RHEO_RHO_SUM_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeRHEORhoSum : public Compute { + public: + ComputeRHEORhoSum(class LAMMPS *, int, char **); + ~ComputeRHEORhoSum() override; + void init() override; + void init_list(int, class NeighList *) override; + void compute_peratom() override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; + + private: + double cut, cutsq; + + class NeighList *list; + class FixRHEO *fix_rheo; + class ComputeRHEOKernel *compute_kernel; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 5b3aeabf26..9a94ea6a76 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -36,7 +36,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathExtra; -#define epsilon 1e-10; +#define EPSILON 1e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index 8d0b681c6f..00cfb56b31 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS { class ComputeRHEOSurface : public Compute { public: ComputeRHEOSurface(class LAMMPS *, int, char **); - ~ComputeRHEOSurface(); + ~ComputeRHEOSurface() override; void init() override; void init_list(int, class NeighList *) override; void compute_peratom() override; @@ -44,26 +44,13 @@ class ComputeRHEOSurface : public Compute { double **B, **gradC, *divr; int threshold_style, comm_stage; - double divR_limit; - int coord_limit; - class NeighList *list; class FixRHEO *fix_rheo; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOSolids *compute_solids; }; -} +} // namespace LAMMPS_NS #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/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 5358cc4cba..e2f9467b34 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -141,7 +141,7 @@ FixRHEO::~FixRHEO() void FixRHEO::post_constructor() { - compute_kernel = dynamic_cast(modify->add_compute("rheo_kernel all RHEO/KERNEL")); + compute_kernel = dynamic_cast(modify->add_compute("rheo_kernel all RHEO/KERNEL {}", kernel_style)); compute_kernel->fix_rheo = this; std::string cmd = "rheo_grad all RHEO/GRAD velocity rho viscosity"; @@ -150,7 +150,7 @@ void FixRHEO::post_constructor() compute_grad->fix_rheo = this; if (rhosum_flag) { - compute_rhosum = dynamic_cast(modify->add_compute("rheo_rhosum all RHEO/RHO/SUM")); + compute_rhosum = dynamic_cast(modify->add_compute("rheo_rho_sum all RHEO/RHO/SUM")); compute_rhosum->fix_rheo = this; } @@ -364,6 +364,8 @@ void FixRHEO::initial_integrate(int /*vflag*/) void FixRHEO::pre_force(int /*vflag*/) { + compute_kernel->compute_coordination(); // Needed for rho sum + if (rhosum_flag) compute_rhosum->compute_peratom(); From 35d1178cfaf29a543ee58e9b230738750966523a Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 20 Apr 2023 20:15:17 -0600 Subject: [PATCH 026/104] Adding cmake options, fixing a few misc errors --- cmake/CMakeLists.txt | 1 + cmake/presets/all_off.cmake | 1 + cmake/presets/all_on.cmake | 1 + cmake/presets/mingw-cross.cmake | 1 + cmake/presets/most.cmake | 1 + cmake/presets/windows.cmake | 1 + src/.gitignore | 25 +++++++++++++++++++++++++ src/RHEO/compute_rheo_grad.h | 2 +- src/RHEO/compute_rheo_interface.h | 2 +- src/RHEO/compute_rheo_kernel.h | 2 +- src/RHEO/compute_rheo_rho_sum.h | 3 ++- src/RHEO/compute_rheo_surface.h | 2 +- src/RHEO/compute_rheo_vshift.h | 3 ++- src/RHEO/fix_rheo.cpp | 8 ++------ src/RHEO/fix_rheo.h | 12 ++++++------ 15 files changed, 47 insertions(+), 18 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 14961209c8..f4a8b9c1ef 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -295,6 +295,7 @@ set(STANDARD_PACKAGES REACTION REAXFF REPLICA + RHEO RIGID SCAFACOS SHOCK diff --git a/cmake/presets/all_off.cmake b/cmake/presets/all_off.cmake index 3d5ee95b3d..64cc88d669 100644 --- a/cmake/presets/all_off.cmake +++ b/cmake/presets/all_off.cmake @@ -83,6 +83,7 @@ set(ALL_PACKAGES REACTION REAXFF REPLICA + RHEO RIGID SCAFACOS SHOCK diff --git a/cmake/presets/all_on.cmake b/cmake/presets/all_on.cmake index 474051f6ec..ac721b30fd 100644 --- a/cmake/presets/all_on.cmake +++ b/cmake/presets/all_on.cmake @@ -85,6 +85,7 @@ set(ALL_PACKAGES REACTION REAXFF REPLICA + RHEO RIGID SCAFACOS SHOCK diff --git a/cmake/presets/mingw-cross.cmake b/cmake/presets/mingw-cross.cmake index 6c6170acd3..ec21809edd 100644 --- a/cmake/presets/mingw-cross.cmake +++ b/cmake/presets/mingw-cross.cmake @@ -67,6 +67,7 @@ set(WIN_PACKAGES REACTION REAXFF REPLICA + RHEO RIGID SHOCK SMTBQ diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake index 00c74c81b8..2a2cac2755 100644 --- a/cmake/presets/most.cmake +++ b/cmake/presets/most.cmake @@ -58,6 +58,7 @@ set(ALL_PACKAGES REACTION REAXFF REPLICA + RHEO RIGID SHOCK SPH diff --git a/cmake/presets/windows.cmake b/cmake/presets/windows.cmake index aa9a4656af..9253d439a8 100644 --- a/cmake/presets/windows.cmake +++ b/cmake/presets/windows.cmake @@ -56,6 +56,7 @@ set(WIN_PACKAGES REACTION REAXFF REPLICA + RHEO RIGID SHOCK SMTBQ diff --git a/src/.gitignore b/src/.gitignore index ac4a776cfc..d0fcaf495c 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -197,6 +197,31 @@ /pair_tdpd.cpp /pair_tdpd.h +/atom_vec_rheo.cpp +/atom_vec_rheo.h +/compute_rheo_grad.cpp +/compute_rheo_grad.h +/compute_rheo_interface.cpp +/compute_rheo_interface.h +/compute_rheo_kernel.cpp +/compute_rheo_kernel.h +/compute_rheo_rho_sum.cpp +/compute_rheo_rho_sum.h +/compute_rheo_surface.cpp +/compute_rheo_surface.h +/compute_rheo_vshift.cpp +/compute_rheo_vshift.h +/fix_rheo.cpp +/fix_rheo.h +/fix_rheo_pressure.cpp +/fix_rheo_pressure.h +/fix_rheo_thermal.cpp +/fix_rheo_thermal.h +/fix_rheo_viscosity.cpp +/fix_rheo_viscosity.h +/pair_rheo.cpp +/pair_rheo.h + /compute_grid.cpp /compute_grid.h /compute_grid_local.cpp diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index ee4b4a5bd6..4c2461c73f 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -42,13 +42,13 @@ class ComputeRHEOGrad : public Compute { double **gradr; double **gradt; double **gradn; + class FixRHEO *fix_rheo; private: int comm_stage, ncomm_grad, ncomm_field, nmax_old; double cut, cutsq, rho0; class NeighList *list; - class FixRHEO *fix_rheo; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; diff --git a/src/RHEO/compute_rheo_interface.h b/src/RHEO/compute_rheo_interface.h index cdb2eb6c54..04733ff334 100644 --- a/src/RHEO/compute_rheo_interface.h +++ b/src/RHEO/compute_rheo_interface.h @@ -41,6 +41,7 @@ class ComputeRHEOInterface : public Compute { void store_forces(); double *chi, **f_pressure; + class FixRHEO *fix_rheo; private: int nmax_old, comm_stage; @@ -50,7 +51,6 @@ class ComputeRHEOInterface : public Compute { char *id_fix_pa; class NeighList *list; - class FixRHEO *fix_rheo; class ComputeRHEOKernel *compute_kernel; }; diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index 4fbdb966b4..19062e483b 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -45,6 +45,7 @@ class ComputeRHEOKernel : public Compute { double dWij[3], dWji[3], Wij, Wji; int correction_order; int *coordination; + class FixRHEO *fix_rheo; private: int comm_stage, comm_forward_save; @@ -60,7 +61,6 @@ class ComputeRHEOKernel : public Compute { class NeighList *list; class ComputeRHEOInterface *compute_interface; - class FixRHEO *fix_rheo; int check_corrections(int); diff --git a/src/RHEO/compute_rheo_rho_sum.h b/src/RHEO/compute_rheo_rho_sum.h index a411d5ed29..6ec2547b95 100644 --- a/src/RHEO/compute_rheo_rho_sum.h +++ b/src/RHEO/compute_rheo_rho_sum.h @@ -36,11 +36,12 @@ class ComputeRHEORhoSum : public Compute { int pack_reverse_comm(int, int, double *) override; void unpack_reverse_comm(int, int *, double *) override; + class FixRHEO *fix_rheo; + private: double cut, cutsq; class NeighList *list; - class FixRHEO *fix_rheo; class ComputeRHEOKernel *compute_kernel; }; diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index 00cfb56b31..224b2594a1 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -37,6 +37,7 @@ class ComputeRHEOSurface : public Compute { void unpack_forward_comm(int, int, double *) override; double **nsurface, **rsurface; + class FixRHEO *fix_rheo; private: double cut, cutsq, rho0, threshold_divr; @@ -45,7 +46,6 @@ class ComputeRHEOSurface : public Compute { int threshold_style, comm_stage; class NeighList *list; - class FixRHEO *fix_rheo; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOSolids *compute_solids; }; diff --git a/src/RHEO/compute_rheo_vshift.h b/src/RHEO/compute_rheo_vshift.h index e76476e7fd..88a9cdcd1d 100644 --- a/src/RHEO/compute_rheo_vshift.h +++ b/src/RHEO/compute_rheo_vshift.h @@ -37,13 +37,14 @@ class ComputeRHEOVShift : public Compute { void correct_surfaces(); double **vshift; + class FixRHEO *fix_rheo; + private: int nmax_old; double dtv, cut, cutsq, cutthird; int surface_flag; class NeighList *list; - class FixRHEO *fix_rheo; class ComputeRHEOInterface *compute_interface ; class ComputeRHEOKernel *compute_kernel; }; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index e2f9467b34..2b55320c4e 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -23,7 +23,7 @@ #include "compute_rheo_interface.h" #include "compute_rheo_surface.h" #include "compute_rheo_kernel.h" -#include "compute_rheo_rhosum.h" +#include "compute_rheo_rho_sum.h" #include "compute_rheo_vshift.h" #include "domain.h" #include "error.h" @@ -46,7 +46,6 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : viscosity_fix_defined = 0; pressure_fix_defined = 0; thermal_fix_defined = 0; - surface_fix_defined = 0; thermal_flag = 0; rhosum_flag = 0; @@ -104,9 +103,6 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : interface_flag = 1; } else if (strcmp(arg[iarg],"rhosum") == 0) { rhosum_flag = 1; - if(iarg + 1 >= narg) error->all(FLERR,"Illegal rhosum option in fix rheo"); - rhosum_zmin = utils::inumeric(FLERR,arg[iarg + 1],false,lmp); - iarg += 1; } else if (strcmp(arg[iarg],"rho0") == 0) { if(iarg + 1 >= narg) error->all(FLERR,"Illegal rho0 option in fix rheo"); rho0 = utils::numeric(FLERR,arg[iarg + 1],false,lmp); @@ -207,7 +203,7 @@ void FixRHEO::setup_pre_force(int /*vflag*/) /* ---------------------------------------------------------------------- */ -void FixRHEO::setup() +void FixRHEO::setup(int /*vflag*/) { // Confirm all accessory fixes are defined // Note: these fixes set this flag in setup_pre_force() diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index d2097ade71..0064f4c90b 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -32,7 +32,7 @@ class FixRHEO : public Fix { void post_constructor() override; void init() override; void setup_pre_force(int) override; - void setup() override; + void setup(int) override; void pre_force(int) override; void initial_integrate(int) override; void final_integrate() override; @@ -40,7 +40,7 @@ class FixRHEO : public Fix { // Model parameters double h, rho0, csq; - int zmin_kernel, zmin_rhosum, zmin_surface; + int zmin_kernel, zmin_surface; int kernel_style, surface_style; double divr_surface; enum {QUINTIC, CRK0, CRK1, CRK2}; @@ -52,7 +52,7 @@ class FixRHEO : public Fix { STATUS_FLUID = 1 << 0, STATUS_REACTIVE = 1 << 1, STATUS_SOLID = 1 << 2, - STATUS_FREEZING = 1 << 3 + STATUS_FREEZING = 1 << 3, // Surface status STATUS_BULK = 1 << 4, @@ -62,10 +62,10 @@ class FixRHEO : public Fix { // Temporary status options - reset in preforce STATUS_SHIFT = 1 << 8, - STATUS_NO_FORCE = 1 << 9, + STATUS_NO_FORCE = 1 << 9 }; - int phasemask = FFFFFFF0; - int surfacemask = FFFFFF0F; + int phasemask = 0xFFFFFFF0; + int surfacemask = 0xFFFFFF0F; // Accessory fixes/computes int thermal_flag; From 47b8cdc94fa750bc088225124e1f911d40d63885 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 24 Apr 2023 19:46:27 -0600 Subject: [PATCH 027/104] Fixing compilation errors --- src/RHEO/atom_vec_rheo.cpp | 2 +- src/RHEO/compute_rheo_grad.cpp | 66 +++++++++------- src/RHEO/compute_rheo_grad.h | 5 +- src/RHEO/compute_rheo_interface.cpp | 91 +++++++++++----------- src/RHEO/compute_rheo_interface.h | 10 +-- src/RHEO/compute_rheo_kernel.cpp | 112 ++++++++++++++-------------- src/RHEO/compute_rheo_kernel.h | 2 +- src/RHEO/compute_rheo_rho_sum.cpp | 13 ++-- src/RHEO/compute_rheo_surface.cpp | 83 +++++++++++---------- src/RHEO/compute_rheo_surface.h | 10 +-- src/RHEO/compute_rheo_vshift.cpp | 38 +++++----- src/RHEO/compute_rheo_vshift.h | 2 +- src/RHEO/fix_rheo.cpp | 79 +++++++++++--------- src/RHEO/fix_rheo.h | 51 +++++++------ src/RHEO/fix_rheo_pressure.cpp | 25 ++++--- src/RHEO/fix_rheo_pressure.h | 5 +- src/RHEO/fix_rheo_thermal.cpp | 57 +++++++------- src/RHEO/fix_rheo_thermal.h | 6 +- src/RHEO/fix_rheo_viscosity.cpp | 27 ++++--- src/RHEO/fix_rheo_viscosity.h | 2 +- src/RHEO/pair_rheo.cpp | 39 ++++------ 21 files changed, 379 insertions(+), 346 deletions(-) diff --git a/src/RHEO/atom_vec_rheo.cpp b/src/RHEO/atom_vec_rheo.cpp index a8496a18e9..de2e2f77ad 100644 --- a/src/RHEO/atom_vec_rheo.cpp +++ b/src/RHEO/atom_vec_rheo.cpp @@ -120,7 +120,7 @@ void AtomVecRHEO::pack_property_atom(int index, double *buf, int nvalues, int gr buf[n] = 0.0; n += nvalues; } - } if else (index == 1) { + } else if (index == 1) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = rho[i]; diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index add3ed712d..606cec7dfc 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -21,11 +21,12 @@ #include "atom.h" #include "comm.h" #include "compute_rheo_kernel.h" -#include "compute_rheo_solids.h" +#include "compute_rheo_interface.h" #include "domain.h" #include "error.h" #include "fix_rheo.h" #include "force.h" +#include "memory.h" #include "neighbor.h" #include "neigh_list.h" #include "update.h" @@ -33,6 +34,8 @@ #include using namespace LAMMPS_NS; +using namespace RHEO_NS; + enum{COMMGRAD, COMMFIELD}; /* ---------------------------------------------------------------------- */ @@ -112,10 +115,13 @@ void ComputeRHEOGrad::init() compute_kernel = fix_rheo->compute_kernel; compute_interface = fix_rheo->compute_interface; + int tmp1, tmp2; + index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); + // Create coordination array if it doesn't already exist // Create a custom atom property so it works with compute property/atom // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded + // Manually grow if nmax_store exceeded int index; int dim = domain->dimension; @@ -139,7 +145,7 @@ void ComputeRHEOGrad::init() gradn = atom->darray[index]; } - nmax_old = 0; + nmax_store = 0; grow_arrays(atom->nmax); } @@ -158,7 +164,7 @@ void ComputeRHEOGrad::compute_peratom() double xtmp, ytmp, ztmp, delx, dely, delz; double rsq, imass, jmass; double rhoi, rhoj, Voli, Volj, drho, dT, deta; - double vij[3]; + double vi[3], vj[3], vij[3]; double wp, *dWij, *dWji; int inum, *ilist, *numneigh, **firstneigh; @@ -169,26 +175,22 @@ void ComputeRHEOGrad::compute_peratom() double **v = atom->v; double *rho = atom->rho; double *temperature = atom->temperature; + double *viscosity = atom->dvector[index_visc]; int *status = atom->status; int *type = atom->type; double *mass = atom->mass; int newton = force->newton; int dim = domain->dimension; - int tmp1, tmp2; - int index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); - if (index_visc == -1) error->all(FLERR, "Cannot find rheo viscosity"); - double *viscosity = atom->dvector[index_visc]; - inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; // initialize arrays - if (nmax > nmax_old) grow_arrays(nmax); + if (atom->nmax > nmax_store) grow_arrays(atom->nmax); - for (i = 0; i < nmax; i++) { + for (i = 0; i < nmax_store; i++) { if (velocity_flag) { for (k = 0; k < dim * dim; k++) gradv[i][k] = 0.0; @@ -212,6 +214,9 @@ void ComputeRHEOGrad::compute_peratom() xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + vi[0] = v[i][0]; + vi[1] = v[i][1]; + vi[2] = v[i][2]; itype = type[i]; jlist = firstneigh[i]; jnum = numneigh[i]; @@ -230,14 +235,18 @@ void ComputeRHEOGrad::compute_peratom() rhoi = rho[i]; rhoj = rho[j]; + vj[0] = v[j][0]; + vj[1] = v[j][1]; + vj[2] = v[j][2]; + // Add corrections for walls - if ((status[i] & FixRHEO::STATUS_FLUID) && !(status[j] & FixRHEO::STATUS_FLUID)) { - compute_interface->correct_v(v[i], v[j], vi, i, j); - rhoj = compute_interface->correct_rho(j,i); - } else if (!(status[i] & FixRHEO::STATUS_FLUID) && (status[j] & FixRHEO::STATUS_FLUID)) { - compute_interface->correct_v(v[j], v[i], vj, j, i); - rhoi = compute_interface->correct_rho(i,j); - } else if (!(status[i] & FixRHEO::STATUS_FLUID) && !(status[j] & FixRHEO::STATUS_FLUID)) { + if ((status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { + compute_interface->correct_v(vi, vj, i, j); + rhoj = compute_interface->correct_rho(j, i); + } else if (!(status[i] & STATUS_FLUID) && (status[j] & STATUS_FLUID)) { + compute_interface->correct_v(vj, vi, j, i); + rhoi = compute_interface->correct_rho(i, j); + } else if (!(status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { rhoi = rho0; rhoj = rho0; } @@ -324,7 +333,6 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, int i,j,k,m; double *rho = atom->rho; double *temperature = atom->temperature; - double *eta = atom->viscosity; double **v = atom->v; int dim = domain->dimension; @@ -371,9 +379,9 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, void ComputeRHEOGrad::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; - double * rho = atom->rho; - double * temperature = atom->temperature; - double ** v = atom->v; + double *rho = atom->rho; + double *temperature = atom->temperature; + double **v = atom->v; int dim = domain->dimension; m = 0; @@ -483,25 +491,27 @@ void ComputeRHEOGrad::grow_arrays(int nmax) if (eta_flag) memory->grow(gradn, nmax, dim, "atom:rheo_grad_eta"); - nmax_old = nmax; + nmax_store = nmax; } /* ---------------------------------------------------------------------- */ -double ComputeRHEOKernel::memory_usage() +double ComputeRHEOGrad::memory_usage() { double bytes = 0.0; + int dim = domain->dimension; + if (velocity_flag) - bytes = (size_t) nmax_old * dim * dim * sizeof(double); + bytes = (size_t) nmax_store * dim * dim * sizeof(double); if (rho_flag) - bytes = (size_t) nmax_old * dim * sizeof(double); + bytes = (size_t) nmax_store * dim * sizeof(double); if (temperature_flag) - bytes = (size_t) nmax_old * dim * sizeof(double); + bytes = (size_t) nmax_store * dim * sizeof(double); if (eta_flag) - bytes = (size_t) nmax_old * dim * sizeof(double); + bytes = (size_t) nmax_store * dim * sizeof(double); return bytes; } diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index 4c2461c73f..8c7962a978 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -45,7 +45,8 @@ class ComputeRHEOGrad : public Compute { class FixRHEO *fix_rheo; private: - int comm_stage, ncomm_grad, ncomm_field, nmax_old; + int comm_stage, ncomm_grad, ncomm_field, nmax_store; + int index_visc; double cut, cutsq, rho0; class NeighList *list; @@ -53,6 +54,8 @@ class ComputeRHEOGrad : public Compute { class ComputeRHEOInterface *compute_interface; int velocity_flag, temperature_flag, rho_flag, eta_flag; + + void grow_arrays(int); }; } // namespace LAMMPS_NS diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index 059f4057f4..72dcdc17d7 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -34,18 +34,19 @@ #include using namespace LAMMPS_NS; +using namespace RHEO_NS; -#define EPSILON 1e-1 +static constexpr double EPSILON = 1e-1; /* ---------------------------------------------------------------------- */ ComputeRHEOInterface::ComputeRHEOInterface(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr), fx_m_norm(nullptr), - norm(nullptr), normwf(nullptr), chi(nullptr), f_pressure(nullptr), id_fix_pa(nullptr) + Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr), fp_store(nullptr), + norm(nullptr), normwf(nullptr), chi(nullptr), id_fix_pa(nullptr) { if (narg != 3) error->all(FLERR,"Illegal compute rheo/interface command"); - nmax = 0; + nmax_store = 0; comm_forward = 3; comm_reverse = 4; @@ -74,15 +75,15 @@ void ComputeRHEOInterface::init() compute_kernel = fix_rheo->compute_kernel; rho0 = fix_rheo->rho0; cut = fix_rheo->cut; - cs = fix_rheo->cs; - cs_inv = 1.0 / cs; + csq = fix_rheo->csq; + csq_inv = 1.0 / csq; cutsq = cut * cut; wall_max = sqrt(3.0) / 12.0 * cut; // Create chi array if it doesn't already exist // Create a custom atom property so it works with compute property/atom // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded + // Manually grow if nmax_store exceeded int tmp1, tmp2; int nmax = atom->nmax; @@ -93,7 +94,7 @@ void ComputeRHEOInterface::init() memory->destroy(normwf); memory->create(norm, nmax, "rheo/interface:norm"); memory->create(normwf, nmax, "rheo/interface:normwf"); - nmax_old = nmax; + nmax_store = nmax; } chi = atom->dvector[index]; @@ -104,13 +105,13 @@ void ComputeRHEOInterface::init() index = atom->find_custom("fp_store", tmp1, tmp2); if (index == -1) { id_fix_pa = utils::strdup(id + std::string("_fix_property_atom")); - modify->add_fix(fmt::format("{} all property/atom d2_fp_store 3", id_fix_pa))); + modify->add_fix(fmt::format("{} all property/atom d2_fp_store 3", id_fix_pa)); index = atom->find_custom("fp_store", tmp1, tmp2); } fp_store = atom->darray[index]; // need an occasional half neighbor list - neighbor->add_request(this, NeighConst::REQ_HALF); + neighbor->add_request(this, NeighConst::REQ_DEFAULT); } /* ---------------------------------------------------------------------- */ @@ -142,17 +143,17 @@ void ComputeRHEOInterface::compute_peratom() numneigh = list->numneigh; firstneigh = list->firstneigh; - if (atom->nmax > nmax_old) { - nmax_old = atom->nmax; + if (atom->nmax > nmax_store) { + nmax_store = atom->nmax; memory->destroy(norm); memory->destroy(normwf); - memory->create(norm, nmax_old, "rheo/interface:norm"); - memory->create(normwf, nmax_old, "rheo/interface:normwf"); - memory->grow(chi, nmax_old, "rheo/interface:chi"); + memory->create(norm, nmax_store, "rheo/interface:norm"); + memory->create(normwf, nmax_store, "rheo/interface:normwf"); + memory->grow(chi, nmax_store, "rheo/interface:chi"); } for (i = 0; i < nall; i++) { - if (!(status[i] & FixRHEO::STATUS_FLUID)) rho[i] = 0.0; + if (!(status[i] & STATUS_FLUID)) rho[i] = 0.0; normwf[i] = 0.0; norm[i] = 0.0; chi[i] = 0.0; @@ -164,7 +165,7 @@ void ComputeRHEOInterface::compute_peratom() ytmp = x[i][1]; ztmp = x[i][2]; itype = type[i]; - fluidi = status[i] & FixRHEO::STATUS_FLUID; + fluidi = status[i] & STATUS_FLUID; jlist = firstneigh[i]; jnum = numneigh[i]; @@ -179,12 +180,12 @@ void ComputeRHEOInterface::compute_peratom() if (rsq < cutsq) { jtype = type[j]; - fluidj = status[j] & FixRHEO::STATUS_FLUID; + fluidj = status[j] & STATUS_FLUID; w = compute_kernel->calc_w_quintic(i, j, delx, dely, delz, sqrt(rsq)); status_match = 0; norm[i] += w; - if ((fluidi && fluidj) || ((!fluid) && (!fluidj))) + if ((fluidi && fluidj) || ((!fluidi) && (!fluidj))) status_match = 1; if (status_match) { @@ -194,7 +195,7 @@ void ComputeRHEOInterface::compute_peratom() dot = (-fp_store[0][j] + fp_store[0][i]) * delx; dot += (-fp_store[1][j] + fp_store[1][i]) * dely; dot += (-fp_store[2][j] + fp_store[2][i]) * delz; - rho[i] += w * (cs * (rho[j] - rho0) - rho[j] * dot); + rho[i] += w * (csq * (rho[j] - rho0) - rho[j] * dot); normwf[i] += w; } } @@ -208,7 +209,7 @@ void ComputeRHEOInterface::compute_peratom() dot = (-fp_store[0][i] + fp_store[0][j]) * delx; dot += (-fp_store[1][i] + fp_store[1][j]) * dely; dot += (-fp_store[2][i] + fp_store[2][j]) * delz; - rho[j] += w * (cs * (rho[i] - rho0) + rho[i] * dot); + rho[j] += w * (csq * (rho[i] - rho0) + rho[i] * dot); normwf[j] += w; } } @@ -223,10 +224,10 @@ void ComputeRHEOInterface::compute_peratom() if (norm[i] != 0.0) chi[i] /= norm[i]; // Recalculate rho for non-fluid particles - if (!(status[i] & FixRHEO::STATUS_FLUID)) { + if (!(status[i] & STATUS_FLUID)) { if (normwf[i] != 0.0) { // Stores rho for solid particles 1+Pw in Adami Adams 2012 - rho[i] = MAX(EPSILON, rho0 + (rho[i] / normwf[i]) * cs_inv); + rho[i] = MAX(EPSILON, rho0 + (rho[i] / normwf[i]) * csq_inv); } else { rho[i] = rho0; } @@ -310,7 +311,7 @@ void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf) j = list[i]; norm[j] += buf[m++]; chi[j] += buf[m++]; - if (!(status[j] & FixRHEO::STATUS_FLUID)){ + if (!(status[j] & STATUS_FLUID)){ normwf[j] += buf[m++]; rho[j] += buf[m++]; } else { @@ -322,7 +323,7 @@ void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf) /* ---------------------------------------------------------------------- */ -void ComputeRHEOInterface::correct_v(double *vi, double *vj, double *vi_out, int i, int j) +void ComputeRHEOInterface::correct_v(double *vi, double *vj, int i, int j) { double wall_prefactor, wall_denom, wall_numer; @@ -333,9 +334,9 @@ void ComputeRHEOInterface::correct_v(double *vi, double *vj, double *vi_out, int wall_prefactor = wall_numer / wall_denom; - vi_out[0] = (vi[0] - vj[0]) * wall_prefactor + vi[0]; - vi_out[1] = (vi[1] - vj[1]) * wall_prefactor + vi[1]; - vi_out[2] = (vi[2] - vj[2]) * wall_prefactor + vi[2]; + vi[0] = (vi[0] - vj[0]) * wall_prefactor + vi[0]; + vi[1] = (vi[1] - vj[1]) * wall_prefactor + vi[1]; + vi[2] = (vi[2] - vj[2]) * wall_prefactor + vi[2]; } /* ---------------------------------------------------------------------- */ @@ -352,28 +353,30 @@ double ComputeRHEOInterface::correct_rho(int i, int j) void ComputeRHEOInterface::store_forces() { double minv; - double mass = atom->mass; - double type = atom->type; - double **f = atom->f; + int *type = atom->type; int *mask = atom->mask; + double *mass = atom->mass; + double **f = atom->f; // When this is called, fp_store stores the pressure force // After this method, fp_store instead stores non-pressure forces // and is also normalized by the particles mass // If forces are overwritten by a fix, there are no pressure forces // so just normalize - int ifix = modify->find_fix_by_style("setforce"); - if (ifix != -1) { - for (int i = 0; i < atom->nlocal; i++) { - minv = 1.0 / mass[type[i]]; - if (mask[i] & modify->fix[ifix]->groupbit) { - fp_store[i][0] = f[i][0] * minv; - fp_store[i][1] = f[i][1] * minv; - fp_store[i][2] = f[i][2] * minv; - } else { - fp_store[i][0] = (f[i][0] - fp_store[i][0]) * minv; - fp_store[i][1] = (f[i][1] - fp_store[i][1]) * minv; - fp_store[i][2] = (f[i][2] - fp_store[i][2]) * minv; + auto fixlist = modify->get_fix_by_style("setforce"); + if (fixlist.size() == 0) { + for (const auto &fix : fixlist) { + for (int i = 0; i < atom->nlocal; i++) { + minv = 1.0 / mass[type[i]]; + if (mask[i] & fix->groupbit) { + fp_store[i][0] = f[i][0] * minv; + fp_store[i][1] = f[i][1] * minv; + fp_store[i][2] = f[i][2] * minv; + } else { + fp_store[i][0] = (f[i][0] - fp_store[i][0]) * minv; + fp_store[i][1] = (f[i][1] - fp_store[i][1]) * minv; + fp_store[i][2] = (f[i][2] - fp_store[i][2]) * minv; + } } } } else { @@ -397,7 +400,7 @@ void ComputeRHEOInterface::store_forces() double ComputeRHEOInterface::memory_usage() { - double bytes = 3 * nmax_old * sizeof(double); + double bytes = 3 * nmax_store * sizeof(double); return bytes; } diff --git a/src/RHEO/compute_rheo_interface.h b/src/RHEO/compute_rheo_interface.h index 04733ff334..50cec97790 100644 --- a/src/RHEO/compute_rheo_interface.h +++ b/src/RHEO/compute_rheo_interface.h @@ -36,17 +36,17 @@ class ComputeRHEOInterface : public Compute { int pack_reverse_comm(int, int, double *) override; void unpack_reverse_comm(int, int *, double *) override; double memory_usage() override; - void correct_v(double *, double *, double *, int, int); + void correct_v(double *, double *, int, int); double correct_rho(int, int); void store_forces(); - double *chi, **f_pressure; + double *chi, **fp_store; class FixRHEO *fix_rheo; private: - int nmax_old, comm_stage; - double rho0, cut, cutsq, cs, cs_inv, wall_max; - double *norm, *normwf, **fom_store; + int nmax_store, comm_stage; + double rho0, cut, cutsq, csq, csq_inv, wall_max; + double *norm, *normwf; char *id_fix_pa; diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index c0b61daae3..d96d8d234e 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -42,10 +42,10 @@ #include using namespace LAMMPS_NS; +using namespace RHEO_NS; using namespace MathExtra; -enum {QUINTIC, CRK0, CRK1, CRK2}; -#define DELTA 2000 +static constexpr int DELTA = 2000; /* ---------------------------------------------------------------------- */ @@ -55,16 +55,16 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : { if (narg != 4) error->all(FLERR,"Illegal compute rheo/kernel command"); - kernel_style = (SubModelType) utils::inumeric(FLERR,arg[3],false,lmp); + kernel_style = utils::inumeric(FLERR,arg[3],false,lmp); - if (kernel_style == FixRHEO::QUINTIC) { + if (kernel_style == QUINTIC) { correction_order = -1; - } else if (kernel_style == FixRHEO::CRK0) { + } else if (kernel_style == CRK0) { correction_order = 0; - } else if (kernel_style == FixRHEO::CRK1) { + } else if (kernel_style == CRK1) { correction_order = 1; - } else if (kernel_style == FixRHEO::CRK2) { + } else if (kernel_style == CRK2) { correction_order = 2; } @@ -74,11 +74,11 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : comm_forward = 1; ncor = 0; Mdim = 0; - if (kernel_type == CRK1) { + if (kernel_style == CRK1) { Mdim = 1 + dim; ncor = 1 + dim; comm_forward = ncor * Mdim; - } else if (kernel_type == CRK2) { + } else if (kernel_style == CRK2) { //Polynomial basis size (up to quadratic order) Mdim = 1 + dim + dim * (dim + 1) / 2; //Number of sets of correction coefficients (1 x y xx yy) + z zz (3D) @@ -126,35 +126,35 @@ void ComputeRHEOKernel::init() if (dim == 3) { - pre_w = 0.002652582384864922 * 27.0 * ihsq * ih; - pre_wp = pre_w * 3.0 * ih; + pre_w = 0.002652582384864922 * 27.0 * hsqinv * hinv; + pre_wp = pre_w * 3.0 * hinv; } else { - pre_w = 0.004661441847879780 * 9 * ihsq; - pre_wp = pre_w * 3.0 * ih; + pre_w = 0.004661441847879780 * 9 * hsqinv; + pre_wp = pre_w * 3.0 * hinv; } // Create coordination array if it doesn't already exist // Create a custom atom property so it works with compute property/atom // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded + // Manually grow if nmax_store exceeded int tmp1, tmp2; int nmax = atom->nmax; int index = atom->find_custom("rheo_coordination", tmp1, tmp2); if (index == -1) { index = atom->add_custom("rheo_coordination", 0, 0); - nmax_old = nmax; + nmax_store = nmax; } coordination = atom->ivector[index]; // Create local arrays for kernel arrays, I can't foresee a reason to print - if (kernel_type == CRK0) { - memory->create(C0, nmax_old, "rheo/kernel:C0"); - } else if (kernel_type == CRK1) { - memory->create(C, nmax_old, ncor, Mdim, "rheo/kernel:C"); - } else if (kernel_type == CRK2) { - memory->create(C, nmax_old, ncor, Mdim, "rheo/kernel:C"); + if (kernel_style == CRK0) { + memory->create(C0, nmax_store, "rheo/kernel:C0"); + } else if (kernel_style == CRK1) { + memory->create(C, nmax_store, ncor, Mdim, "rheo/kernel:C"); + } else if (kernel_style == CRK2) { + memory->create(C, nmax_store, ncor, Mdim, "rheo/kernel:C"); } } @@ -192,10 +192,10 @@ double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double int corrections_j = check_corrections(j); int corrections = corrections_i & corrections_j; - if (kernel_type == QUINTIC || !corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); - else if (kernel_type == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); - else if (kernel_type == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); - else if (kernel_type == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); + if (kernel_style == QUINTIC || !corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); + else if (kernel_style == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); + else if (kernel_style == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); + else if (kernel_style == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); return w; } @@ -211,11 +211,11 @@ double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double // Calc wp and default dW's, a bit inefficient but can redo later wp = calc_dw_quintic(i,j,delx,dely,delz,r,dWij,dWji); - if(kernel_type == CRK1) { + if(kernel_style == CRK1) { //check if kernel correction calculated successfully. If not, revert to quintic if (corrections_i) calc_dw_crk1(i,j,delx,dely,delz,r,dWij); if (corrections_j) calc_dw_crk1(j,i,-delx,-dely,-delz,r,dWji); - } else if(kernel_type == CRK2) { + } else if(kernel_style == CRK2) { if (corrections_i) calc_dw_crk2(i,j,delx,dely,delz,r,dWij); if (corrections_j) calc_dw_crk2(j,i,-delx,-dely,-delz,r,dWji); } @@ -228,7 +228,7 @@ double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double double ComputeRHEOKernel::calc_w_quintic(int i, int j, double delx, double dely, double delz, double r) { double w, tmp1, tmp2, tmp3, tmp1sq, tmp2sq, tmp3sq, s; - s = r * 3.0 * ih; + s = r * 3.0 * hinv; if (s > 3.0) { w = 0.0; @@ -266,7 +266,7 @@ double ComputeRHEOKernel::calc_dw_quintic(int i, int j, double delx, double dely double *mass = atom->mass; int *type = atom->type; - s = r * 3.0 * ih; + s = r * 3.0 * hinv; if (s > 3.0) { wp = 0.0; @@ -496,9 +496,9 @@ void ComputeRHEOKernel::compute_peratom() gsl_error_flag = 0; gsl_error_tags.clear(); - if (kernel_type == FixRHEO::QUINTIC) return; + if (kernel_style == QUINTIC) return; - int i, j, ii, jj, inum, jnum, g, a, b, gsl_error; + int i, j, ii, jj, inum, jnum, itype, g, a, b, gsl_error; double xtmp, ytmp, ztmp, r, rsq, w, vj; double dx[3]; gsl_matrix_view gM; @@ -520,9 +520,9 @@ void ComputeRHEOKernel::compute_peratom() firstneigh = list->firstneigh; // Grow arrays if necessary - if (nmax_old < atom->nmax) grow_arrays(atom->nmax); + if (nmax_store < atom->nmax) grow_arrays(atom->nmax); - if (kernel_type == FixRHEO::CRK0) { + if (kernel_style == CRK0) { double M; for (ii = 0; ii < inum; ii++) { @@ -544,12 +544,12 @@ void ComputeRHEOKernel::compute_peratom() dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; - rsq = lensq(dx); + rsq = lensq3(dx); if (rsq < hsq) { r = sqrt(rsq); w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); - if (!(status[j] & FixRHEO::STATUS_FLUID) && solid_flag) { + if (!(status[j] & STATUS_FLUID) && solid_flag) { vj = mass[type[j]] / compute_interface->correct_rho(j,i); } else vj = mass[type[j]] / rho[j]; @@ -590,22 +590,24 @@ void ComputeRHEOKernel::compute_peratom() dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; - rsq = lensq(dx); + rsq = lensq3(dx); - if (rsq < cutsq) { + if (rsq < hsq) { r = sqrt(rsq); w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); - if (status[j] > FixRHEO::FLUID_MAX && solid_flag) - vj = mass[type[j]]/compute_interface->correct_rho(j,i); - else vj = mass[type[j]]/rho[j]; + if (solid_flag) + if (!(status[j] & STATUS_FLUID)) + vj = mass[type[j]]/compute_interface->correct_rho(j,i); + else + vj = mass[type[j]]/rho[j]; //Populate the H-vector of polynomials (2D) if (dim == 2) { H[0] = 1.0; H[1] = dx[0] * hinv; H[2] = dx[1] * hinv; - if (kernel_type == FixRHEO::CRK2) { + if (kernel_style == CRK2) { H[3] = 0.5 * dx[0] * dx[0] * hsqinv; H[4] = 0.5 * dx[1] * dx[1] * hsqinv; H[5] = dx[0] * dx[1] * hsqinv; @@ -615,7 +617,7 @@ void ComputeRHEOKernel::compute_peratom() H[1] = dx[0] * hinv; H[2] = dx[1] * hinv; H[3] = dx[2] * hinv; - if (kernel_type == FixRHEO::CRK2) { + if (kernel_style == CRK2) { H[4] = 0.5 * dx[0] * dx[0] * hsqinv; H[5] = 0.5 * dx[1] * dx[1] * hsqinv; H[6] = 0.5 * dx[2] * dx[2] * hsqinv; @@ -642,7 +644,7 @@ void ComputeRHEOKernel::compute_peratom() } // Skip if undercoordinated - if (coordination[i] < zmin) continue + if (coordination[i] < zmin) continue; // Use gsl to get Minv, use Cholesky decomposition since the // polynomials are independent, M is symmetrix & positive-definite @@ -656,7 +658,7 @@ void ComputeRHEOKernel::compute_peratom() //check if not positive-definite if (gsl_error != GSL_EDOM) - error->warn(FLERR, "Failed decomposition in rheo/kernel, gsl_error = {}", gsl_error); + error->warning(FLERR, "Failed decomposition in rheo/kernel, gsl_error = {}", gsl_error); continue; } @@ -689,7 +691,7 @@ void ComputeRHEOKernel::compute_peratom() // columns 1-2 (2D) or 1-3 (3D) //Second derivatives - if (kernel_type == FixRHEO::CRK2) + if (kernel_style == CRK2) C[i][1 + dim + b][a] = M[a * Mdim + b + 1 + dim] * hsqinv; // columns 3-4 (2D) or 4-6 (3D) } @@ -721,7 +723,7 @@ void ComputeRHEOKernel::compute_coordination() firstneigh = list->firstneigh; // Grow arrays if necessary - if (nmax_old < atom->nmax) grow_arrays(atom->nmax); + if (nmax_store < atom->nmax) grow_arrays(atom->nmax); for (ii = 0; ii < inum; ii++) { i = ilist[ii]; @@ -740,7 +742,7 @@ void ComputeRHEOKernel::compute_coordination() dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; - rsq = lensq(dx); + rsq = lensq3(dx); if (rsq < hsq) coordination[i] += 1; @@ -759,13 +761,13 @@ void ComputeRHEOKernel::grow_arrays(int nmax) { memory->grow(coordination, nmax, "atom:rheo_coordination"); - if (kernel_type == FixRHEO::CRK0) { + if (kernel_style == CRK0) { memory->grow(C0, nmax, "rheo/kernel:C0"); } else if (correction_order > 0) { memory->grow(C, nmax, ncor, Mdim, "rheo/kernel:C"); } - nmax_old = nmax; + nmax_store = nmax; } /* ---------------------------------------------------------------------- */ @@ -781,7 +783,7 @@ int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf, if (comm_stage == 0) { buf[m++] = coordination[j]; } else { - if (kernel_type == FixRHEO::CRK0) { + if (kernel_style == CRK0) { buf[m++] = C0[j]; } else { for (a = 0; a < ncor; a++) @@ -805,7 +807,7 @@ void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) if (comm_stage == 0) { coordination[i] = buf[m++]; } else { - if (kernel_type == FixRHEO::CRK0) { + if (kernel_style == CRK0) { C0[i] = buf[m++]; } else { for (a = 0; a < ncor; a++) @@ -821,12 +823,12 @@ void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) double ComputeRHEOKernel::memory_usage() { double bytes = 0.0; - bytes = (size_t) nmax_old * sizeof(int); + bytes = (size_t) nmax_store * sizeof(int); - if (kernel_type == FixRHEO::CRK0) { - bytes += (size_t) nmax_old * sizeof(double); + if (kernel_style == CRK0) { + bytes += (size_t) nmax_store * sizeof(double); } else if (correction_order > 0) { - bytes += (size_t) nmax_old * ncor * Mdim * sizeof(double); + bytes += (size_t) nmax_store * ncor * Mdim * sizeof(double); } return bytes; } diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index 19062e483b..1842406977 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -54,7 +54,7 @@ class ComputeRHEOKernel : public Compute { std::unordered_set gsl_error_tags; int kernel_style, zmin, dim, Mdim, ncor; - int nmax_old; + int nmax_store; double h, hsq, hinv, hsqinv, pre_w, pre_wp; double ***C; double *C0; diff --git a/src/RHEO/compute_rheo_rho_sum.cpp b/src/RHEO/compute_rheo_rho_sum.cpp index fafd948538..726d876ea1 100644 --- a/src/RHEO/compute_rheo_rho_sum.cpp +++ b/src/RHEO/compute_rheo_rho_sum.cpp @@ -49,7 +49,7 @@ void ComputeRHEORhoSum::init() cutsq = cut * cut; // need an occasional half neighbor list - neighbor->add_request(this, NeighConst::REQ_HALF); + neighbor->add_request(this, NeighConst::REQ_DEFAULT); } /* ---------------------------------------------------------------------- */ @@ -130,8 +130,9 @@ void ComputeRHEORhoSum::compute_peratom() int ComputeRHEORhoSum::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { - int i,j,k,m; - double * rho = atom->rho; + int i, j, k, m; + double *rho = atom->rho; + int *coordination = compute_kernel->coordination; m = 0; for (i = 0; i < n; i++) { @@ -145,7 +146,7 @@ int ComputeRHEORhoSum::pack_forward_comm(int n, int *list, double *buf, void ComputeRHEORhoSum::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; - double * rho = atom->rho; + double *rho = atom->rho; m = 0; last = first + n; @@ -158,7 +159,7 @@ void ComputeRHEORhoSum::unpack_forward_comm(int n, int first, double *buf) int ComputeRHEORhoSum::pack_reverse_comm(int n, int first, double *buf) { - int i,k,m,last; + int i, k, m, last; double *rho = atom->rho; m = 0; @@ -173,7 +174,7 @@ int ComputeRHEORhoSum::pack_reverse_comm(int n, int first, double *buf) void ComputeRHEORhoSum::unpack_reverse_comm(int n, int *list, double *buf) { - int i,k,j,m; + int i, k, j, m; double *rho = atom->rho; m = 0; diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 9a94ea6a76..180c430dd1 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -20,8 +20,8 @@ #include "atom.h" #include "comm.h" +#include "compute_rheo_interface.h" #include "compute_rheo_kernel.h" -#include "compute_rheo_solids.h" #include "domain.h" #include "error.h" #include "fix_rheo.h" @@ -33,18 +33,19 @@ #include "neigh_request.h" using namespace LAMMPS_NS; +using namespace RHEO_NS; using namespace FixConst; using namespace MathExtra; -#define EPSILON 1e-10; +static constexpr double EPSILON = 1e-10; /* ---------------------------------------------------------------------- */ ComputeRHEOSurface::ComputeRHEOSurface(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), compute_kernel(nullptr), compute_solids(nullptr), + Compute(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), compute_kernel(nullptr), compute_interface(nullptr), B(nullptr), gradC(nullptr), nsurface(nullptr), divr(nullptr), rsurface(nullptr) { - if (narg != 3) error->all(FLERR,"Illegal fix RHEO/SURFACE command"); + if (narg != 3) error->all(FLERR,"Illegal compute RHEO/SURFACE command"); int dim = domain->dimension; comm_forward = 2; @@ -75,19 +76,19 @@ ComputeRHEOSurface::~ComputeRHEOSurface() void ComputeRHEOSurface::init() { compute_kernel = fix_rheo->compute_kernel; - compute_solids = fix_rheo->compute_solids; + compute_interface = fix_rheo->compute_interface; cut = fix_rheo->cut; rho0 = fix_rheo->rho0; threshold_style = fix_rheo->surface_style; - threshold_divr = fix_rheo->divrsurface; - threshold_z = fix_rheo->zminsurface; + threshold_divr = fix_rheo->divr_surface; + threshold_z = fix_rheo->zmin_surface; cutsq = cut * cut; // Create rsurface, divr, nsurface arrays if they don't already exist // Create a custom atom property so it works with compute property/atom // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded + // Manually grow if nmax_store exceeded // For B and gradC, create a local array since they are unlikely to be printed int tmp1, tmp2; @@ -103,12 +104,13 @@ void ComputeRHEOSurface::init() if (index == -1) index = atom->add_custom("rheo_nsurface", 1, 3); nsurface = atom->darray[index]; - nmax_old = atom->nmax; - memory->create(B, nmax_old, dim * dim, "rheo/surface:B"); - memory->create(gradC, nmax_old, dim * dim, "rheo/surface:gradC"); + nmax_store = atom->nmax; + int dim = domain->dimension; + memory->create(B, nmax_store, dim * dim, "rheo/surface:B"); + memory->create(gradC, nmax_store, dim * dim, "rheo/surface:gradC"); // need an occasional half neighbor list - neighbor->add_request(this, NeighConst::REQ_HALF); + neighbor->add_request(this, NeighConst::REQ_DEFAULT); } /* ---------------------------------------------------------------------- */ @@ -123,9 +125,8 @@ void ComputeRHEOSurface::init_list(int /*id*/, NeighList *ptr) void ComputeRHEOSurface::compute_peratom() { int i, j, ii, jj, inum, jnum, a, b, itype, jtype, fluidi, fluidj; - double xtmp, ytmp, ztmp, rsq, Voli, Volj, rhoi, rhoj; - double *dWij, *dWji; - double dx[3]; + double xtmp, ytmp, ztmp, rsq, Voli, Volj, rhoi, rhoj, wp; + double *dWij, *dWji, dx[3]; int *ilist, *jlist, *numneigh, **firstneigh; int nlocal = atom->nlocal; @@ -146,7 +147,7 @@ void ComputeRHEOSurface::compute_peratom() firstneigh = list->firstneigh; int nmax = atom->nmax; - if (nmax_old <= nmax) { + if (nmax_store <= nmax) { memory->grow(divr, nmax, "atom:rheo_divr"); memory->grow(rsurface, nmax, "atom:rheo_rsurface"); memory->grow(nsurface, nmax, 3, "atom:rheo_nsurface"); @@ -154,7 +155,7 @@ void ComputeRHEOSurface::compute_peratom() memory->grow(B, nmax, dim * dim, "rheo/surface:B"); memory->grow(gradC, nmax, dim * dim, "rheo/surface:gradC"); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } int nall = nlocal + atom->nghost; @@ -169,7 +170,7 @@ void ComputeRHEOSurface::compute_peratom() divr[i] = 0.0; // Remove surface settings - status[i] &= FixRHEO::surfacemask; + status[i] &= SURFACEMASK; } // loop over neighbors to calculate the average orientation of neighbors @@ -182,7 +183,7 @@ void ComputeRHEOSurface::compute_peratom() jlist = firstneigh[i]; jnum = numneigh[i]; itype = type[i]; - fluidi = status[i] & FixRHEO::STATUS_FLUID; + fluidi = status[i] & STATUS_FLUID; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -192,19 +193,19 @@ void ComputeRHEOSurface::compute_peratom() dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; - rsq = lensq(dx); + rsq = lensq3(dx); if (rsq < cutsq) { jtype = type[j]; - fluidj = status[j] & FixRHEO::STATUS_FLUID; + fluidj = status[j] & STATUS_FLUID; rhoi = rho[i]; rhoj = rho[j]; // Add corrections for walls if (fluidi && (!fluidj)) { - rhoj = compute_solids->correct_rho(j, i); + rhoj = compute_interface->correct_rho(j, i); } else if ((!fluidi) && fluidj) { - rhoi = compute_solids->correct_rho(i, j); + rhoi = compute_interface->correct_rho(i, j); } else if ((!fluidi) && (!fluidj)) { rhoi = rho0; rhoj = rho0; @@ -253,29 +254,29 @@ void ComputeRHEOSurface::compute_peratom() } // Find the free-surface - if (threshold_style == FixRHEO::DIVR) { + if (threshold_style == DIVR) { for (i = 0; i < nall; i++) { if (mask[i] & groupbit) { - status[i] |= FixRHEO::STATUS_BULK; + status[i] |= STATUS_BULK; rsurface[i] = cut; if (divr[i] < threshold_divr) { - status[i] |= FixRHEO::STATUS_SURFACE; + status[i] |= STATUS_SURFACE; rsurface[i] = 0.0; if (coordination[i] < threshold_z) - status[i] |= FixRHEO::STATUS_SPLASH; + status[i] |= STATUS_SPLASH; } } } } else { for (i = 0; i < nall; i++) { if (mask[i] & groupbit) { - status[i] |= FixRHEO::STATUS_BULK; + status[i] |= STATUS_BULK; rsurface[i] = cut; - if (coordination[i] < divR_limit) { - status[i] |= FixRHEO::STATUS_SURFACE; + if (coordination[i] < threshold_divr) { + status[i] |= STATUS_SURFACE; rsurface[i] = 0.0; if (coordination[i] < threshold_z) - status[i] |= FixRHEO::STATUS_SPLASH; + status[i] |= STATUS_SPLASH; } } } @@ -297,23 +298,23 @@ void ComputeRHEOSurface::compute_peratom() dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; - rsq = lensq(dx); + rsq = lensq3(dx); if (rsq < cutsq) { - if ((status[i] & FixRHEO::STATUS_BULK) && (status[j] & FixRHEO::STATUS_SURFACE)) { - status[i] &= FixRHEO::surfacemask; - status[i] |= FixRHEO::STATUS_LAYER; + if ((status[i] & STATUS_BULK) && (status[j] & STATUS_SURFACE)) { + status[i] &= SURFACEMASK; + status[i] |= STATUS_LAYER; } - if (status[j] & FixRHEO::STATUS_SURFACE) rsurface[i] = MIN(rsurface[i], sqrt(rsq)); + if (status[j] & STATUS_SURFACE) rsurface[i] = MIN(rsurface[i], sqrt(rsq)); if (j < nlocal || newton) { - if ((status[j] & FixRHEO::STATUS_BULK) && (status[i] & FixRHEO::STATUS_SURFACE)) { - status[j] &= FixRHEO::surfacemask; - status[j] |= FixRHEO::STATUS_LAYER; + if ((status[j] & STATUS_BULK) && (status[i] & STATUS_SURFACE)) { + status[j] &= SURFACEMASK; + status[j] |= STATUS_LAYER; } - if (status[i] & FixRHEO::STATUS_SURFACE) rsurface[j] = MIN(rsurface[j], sqrt(rsq)); + if (status[i] & STATUS_SURFACE) rsurface[j] = MIN(rsurface[j], sqrt(rsq)); } } } @@ -371,7 +372,7 @@ void ComputeRHEOSurface::unpack_reverse_comm(int n, int *list, double *buf) } else if (comm_stage == 1) { temp = (int) buf[m++]; - if ((status[j] & FixRHEO::STATUS_BULK) && (temp & FixRHEO::STATUS_LAYER)) + if ((status[j] & STATUS_BULK) && (temp & STATUS_LAYER)) status[j] = temp; rsurface[j] = MIN(rsurface[j], buf[m++]); diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index 224b2594a1..58a3e3b9c4 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -17,8 +17,8 @@ ComputeStyle(RHEO/SURFACE,ComputeRHEOSurface) // clang-format on #else -#ifndef LMP_COMPUTE_RHEO_INTERFACE_H -#define LMP_COMPUTE_RHEO_INTERFACE_H +#ifndef LMP_COMPUTE_RHEO_SURFACE_H +#define LMP_COMPUTE_RHEO_SURFACE_H #include "compute.h" @@ -36,18 +36,18 @@ class ComputeRHEOSurface : public Compute { int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; - double **nsurface, **rsurface; + double **nsurface, *rsurface; class FixRHEO *fix_rheo; private: double cut, cutsq, rho0, threshold_divr; - int surface_style, nmax_old, threshold_z; + int surface_style, nmax_store, threshold_z; double **B, **gradC, *divr; int threshold_style, comm_stage; class NeighList *list; class ComputeRHEOKernel *compute_kernel; - class ComputeRHEOSolids *compute_solids; + class ComputeRHEOInterface *compute_interface; }; } // namespace LAMMPS_NS diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 1b3edcffd8..440bfc7fc7 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -32,6 +32,7 @@ #include "neigh_request.h" using namespace LAMMPS_NS; +using namespace RHEO_NS; /* ---------------------------------------------------------------------- */ @@ -47,15 +48,15 @@ ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) : // Create vshift array if it doesn't already exist // Create a custom atom property so it works with compute property/atom // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded + // Manually grow if nmax_store exceeded int tmp1, tmp2; int index = atom->find_custom("rheo_vshift", tmp1, tmp2); if (index == -1) { index = atom->add_custom("rheo_vshift", 1, 3); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } - vshift = atom->dvector[index]; + vshift = atom->darray[index]; } /* ---------------------------------------------------------------------- */ @@ -108,16 +109,17 @@ void ComputeRHEOVShift::compute_peratom() int *jlist; int inum, *ilist, *numneigh, **firstneigh; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - double **x = atom->x; - double **v = atom->v; int *type = atom->type; int *status = atom->status; - int *surface = atom->surface; + int *mask = atom->mask; + double **x = atom->x; + double **v = atom->v; double *rho = atom->rho; double *mass = atom->mass; + + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; int newton_pair = force->newton_pair; inum = list->inum; @@ -125,9 +127,9 @@ void ComputeRHEOVShift::compute_peratom() numneigh = list->numneigh; firstneigh = list->firstneigh; - if (nmax_old < atom->nmax) { + if (nmax_store < atom->nmax) { memory->grow(vshift, atom->nmax, 3, "atom:rheo_vshift"); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } for (i = 0; i < nall; i++) @@ -143,15 +145,15 @@ void ComputeRHEOVShift::compute_peratom() jlist = firstneigh[i]; jnum = numneigh[i]; imass = mass[itype]; - fluidi = status[i] & FixRHEO::STATUS_FLUID; + fluidi = status[i] & STATUS_FLUID; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; - fluidj = status[j] & FixRHEO::STATUS_FLUID; + fluidj = status[j] & STATUS_FLUID; if ((!fluidi) && (!fluidj)) continue; - if (!(status[i] & FixRHEO::STATUS_SHIFT) && !(status[j] & FixRHEO::STATUS_SHIFT)) continue; + if (!(status[i] & STATUS_SHIFT) && !(status[j] & STATUS_SHIFT)) continue; dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; @@ -175,10 +177,10 @@ void ComputeRHEOVShift::compute_peratom() // Add corrections for walls if (fluidi && (!fluidj)) { - compute_interface->correct_v(v[i], v[j], vi, i, j); + compute_interface->correct_v(vi, vj, i, j); rhoj = compute_interface->correct_rho(j,i); } else if ((!fluidi) && fluidj) { - compute_interface->correct_v(v[j], v[i], vj, j, i); + compute_interface->correct_v(vj, vi, j, i); rhoi = compute_interface->correct_rho(i,j); } else if ((!fluidi) && (!fluidj)) { rhoi = 1.0; @@ -215,7 +217,7 @@ void ComputeRHEOVShift::compute_peratom() } } - if (newton_pair) comm->reverse_comm_compute(this); + if (newton_pair) comm->reverse_comm(this); } @@ -239,7 +241,7 @@ void ComputeRHEOVShift::correct_surfaces() double nx,ny,nz,vx,vy,vz; for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if ((status[i] & FixRHEO::STATUS_SURFACE) || (status[i] & FixRHEO::STATUS_LAYER)) { + if ((status[i] & STATUS_SURFACE) || (status[i] & STATUS_LAYER)) { nx = nsurf[i][0]; ny = nsurf[i][1]; vx = vshift[i][0]; @@ -297,6 +299,6 @@ void ComputeRHEOVShift::unpack_reverse_comm(int n, int *list, double *buf) double ComputeRHEOVShift::memory_usage() { - double bytes = 3 * nmax_old * sizeof(double); + double bytes = 3 * nmax_store * sizeof(double); return bytes; } diff --git a/src/RHEO/compute_rheo_vshift.h b/src/RHEO/compute_rheo_vshift.h index 88a9cdcd1d..8611e177d1 100644 --- a/src/RHEO/compute_rheo_vshift.h +++ b/src/RHEO/compute_rheo_vshift.h @@ -40,7 +40,7 @@ class ComputeRHEOVShift : public Compute { class FixRHEO *fix_rheo; private: - int nmax_old; + int nmax_store; double dtv, cut, cutsq, cutthird; int surface_flag; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 2b55320c4e..ff804fe007 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -33,6 +33,7 @@ #include "utils.h" using namespace LAMMPS_NS; +using namespace RHEO_NS; using namespace FixConst; /* ---------------------------------------------------------------------- */ @@ -68,6 +69,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Insufficient arguments for fix rheo command"); h = utils::numeric(FLERR,arg[3],false,lmp); + cut = h; if (strcmp(arg[4],"Quintic") == 0) { kernel_style = QUINTIC; } else if (strcmp(arg[4],"CRK0") == 0) { @@ -101,7 +103,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"interface/reconstruction") == 0) { interface_flag = 1; - } else if (strcmp(arg[iarg],"rhosum") == 0) { + } else if (strcmp(arg[iarg],"rho/sum") == 0) { rhosum_flag = 1; } else if (strcmp(arg[iarg],"rho0") == 0) { if(iarg + 1 >= narg) error->all(FLERR,"Illegal rho0 option in fix rheo"); @@ -137,7 +139,8 @@ FixRHEO::~FixRHEO() void FixRHEO::post_constructor() { - compute_kernel = dynamic_cast(modify->add_compute("rheo_kernel all RHEO/KERNEL {}", kernel_style)); + compute_kernel = dynamic_cast(modify->add_compute( + fmt::format("rheo_kernel all RHEO/KERNEL {}", kernel_style))); compute_kernel->fix_rheo = this; std::string cmd = "rheo_grad all RHEO/GRAD velocity rho viscosity"; @@ -146,22 +149,26 @@ void FixRHEO::post_constructor() compute_grad->fix_rheo = this; if (rhosum_flag) { - compute_rhosum = dynamic_cast(modify->add_compute("rheo_rho_sum all RHEO/RHO/SUM")); + compute_rhosum = dynamic_cast(modify->add_compute( + "rheo_rho_sum all RHEO/RHO/SUM")); compute_rhosum->fix_rheo = this; } if (shift_flag) { - compute_vshift = dynamic_cast(modify->add_compute("rheo_vshift all RHEO/VSHIFT")); + compute_vshift = dynamic_cast(modify->add_compute( + "rheo_vshift all RHEO/VSHIFT")); compute_vshift->fix_rheo = this; } if (interface_flag) { - compute_interface = dynamic_cast(modify->add_compute(fmt::format("rheo_interface all RHEO/INTERFACE"))); + compute_interface = dynamic_cast(modify->add_compute( + "rheo_interface all RHEO/INTERFACE")); compute_interface->fix_rheo = this; } if (surface_flag) { - compute_surface = dynamic_cast(modify->add_compute(fmt::format("rheo_surface all RHEO/SURFACE"))); + compute_surface = dynamic_cast(modify->add_compute( + "rheo_surface all RHEO/SURFACE")); compute_surface->fix_rheo = this; } } @@ -193,7 +200,7 @@ void FixRHEO::init() void FixRHEO::setup_pre_force(int /*vflag*/) { // Check to confirm accessory fixes do not preceed FixRHEO - // Note: these fixes set this flag in setup_pre_force() + // Note: fixes set this flag in setup_pre_force() if (viscosity_fix_defined || pressure_fix_defined || thermal_fix_defined) error->all(FLERR, "Fix RHEO must be defined before all other RHEO fixes"); @@ -206,23 +213,23 @@ void FixRHEO::setup_pre_force(int /*vflag*/) void FixRHEO::setup(int /*vflag*/) { // Confirm all accessory fixes are defined - // Note: these fixes set this flag in setup_pre_force() + // Note: fixes set this flag in setup_pre_force() if (!viscosity_fix_defined) error->all(FLERR, "Missing fix rheo/viscosity"); if (!pressure_fix_defined) error->all(FLERR, "Missing fix rheo/pressure"); - if(!thermal_fix_defined && thermal_flag) + if((!thermal_fix_defined) && thermal_flag) error->all(FLERR, "Missing fix rheo/thermal"); - // Reset to zero for next run + // Reset to zero for future runs thermal_fix_defined = 0; viscosity_fix_defined = 0; pressure_fix_defined = 0; - // Check fixes cover all atoms (doesnt ensure user covers atoms created midrun) - // (pressure is currently required to be group all) + // Check fixes cover all atoms (may still fail if atoms are created) + // FixRHEOPressure currently requires group all auto visc_fixes = modify->get_fix_by_style("rheo/viscosity"); auto therm_fixes = modify->get_fix_by_style("rheo/thermal"); @@ -232,12 +239,12 @@ void FixRHEO::setup(int /*vflag*/) int covered; for (int i = 0; i < atom->nlocal; i++) { covered = 0; - for (auto fix in visc_fixes) + for (auto fix : visc_fixes) if (mask[i] & fix->groupbit) covered = 1; if (!covered) v_coverage_flag = 0; if (thermal_flag) { covered = 0; - for (auto fix in therm_fixes) + for (auto fix : therm_fixes) if (mask[i] & fix->groupbit) covered = 1; if (!covered) v_coverage_flag = 0; } @@ -253,11 +260,12 @@ void FixRHEO::setup(int /*vflag*/) void FixRHEO::initial_integrate(int /*vflag*/) { - // update v and x and rho of atoms in group + // update v, x and rho of atoms in group int i, a, b; double dtfm, divu; - int dim = domain->dimension; + int *type = atom->type; + int *mask = atom->mask; int *status = atom->status; double **x = atom->x; double **v = atom->v; @@ -266,16 +274,14 @@ void FixRHEO::initial_integrate(int /*vflag*/) double *drho = atom->drho; double *mass = atom->mass; double *rmass = atom->rmass; - int rmass_flag = atom->rmass_flag; - double **gradr = compute_grad->gradr; double **gradv = compute_grad->gradv; double **vshift; if (shift_flag) compute_vshift->vshift; - int *type = atom->type; - int *mask = atom->mask; int nlocal = atom->nlocal; + int rmass_flag = atom->rmass_flag; + int dim = domain->dimension; if (igroup == atom->firstgroup) nlocal = atom->nfirst; @@ -333,7 +339,7 @@ void FixRHEO::initial_integrate(int /*vflag*/) // Shifting atoms if (shift_flag) { - compute_vshift->correct_surfaces(); // COuld this be moved to preforce after the surface fix runs? + compute_vshift->correct_surfaces(); // Could this be moved to preforce after the surface fix runs? for (i = 0; i < nlocal; i++) { if (!(status[i] & STATUS_SHIFT)) continue; @@ -376,6 +382,7 @@ void FixRHEO::pre_force(int /*vflag*/) compute_vshift->compute_peratom(); // Remove extra shifting/no force options + int *mask = atom->mask; int *status = atom->status; int nall = atom->nlocal + atom->nghost; for (int i = 0; i < nall; i++) { @@ -393,26 +400,28 @@ void FixRHEO::pre_force(int /*vflag*/) /* ---------------------------------------------------------------------- */ -void FixRHEO::final_integrate() { - int *status = atom->status; - double **gradv = compute_grad->gradv; - double **x = atom->x; - double **v = atom->v; - double **f = atom->f; - - double *rho = atom->rho; - double *drho = atom->drho; - int *type = atom->type; - int *mask = atom->mask; - double *mass = atom->mass; +void FixRHEO::final_integrate() +{ int nlocal = atom->nlocal; if (igroup == atom->firstgroup) nlocal = atom->nfirst; + double dtfm, divu; - double *rmass = atom->rmass; - int rmass_flag = atom->rmass_flag; int i, a; + double **x = atom->x; + double **v = atom->v; + double **f = atom->f; + double **gradv = compute_grad->gradv; + double *rho = atom->rho; + double *drho = atom->drho; + double *mass = atom->mass; + double *rmass = atom->rmass; + int *type = atom->type; + int *mask = atom->mask; + int *status = atom->status; + + int rmass_flag = atom->rmass_flag; int dim = domain->dimension; // Update velocity diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 0064f4c90b..1d8ae06159 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -39,33 +39,10 @@ class FixRHEO : public Fix { void reset_dt() override; // Model parameters - double h, rho0, csq; + double h, cut, rho0, csq; int zmin_kernel, zmin_surface; int kernel_style, surface_style; double divr_surface; - enum {QUINTIC, CRK0, CRK1, CRK2}; - enum {COORDINATION, DIVR}; - - // Status variables - enum { - // Phase status - STATUS_FLUID = 1 << 0, - STATUS_REACTIVE = 1 << 1, - STATUS_SOLID = 1 << 2, - STATUS_FREEZING = 1 << 3, - - // Surface status - STATUS_BULK = 1 << 4, - STATUS_LAYER = 1 << 5, - STATUS_SURFACE = 1 << 6, - STATUS_SPLASH = 1 << 7, - - // Temporary status options - reset in preforce - STATUS_SHIFT = 1 << 8, - STATUS_NO_FORCE = 1 << 9 - }; - int phasemask = 0xFFFFFFF0; - int surfacemask = 0xFFFFFF0F; // Accessory fixes/computes int thermal_flag; @@ -89,6 +66,32 @@ class FixRHEO : public Fix { double dtv, dtf; }; +namespace RHEO_NS { + + enum {QUINTIC, CRK0, CRK1, CRK2}; + enum {COORDINATION, DIVR}; + + // Status variables + enum Status{ + // Phase status + STATUS_FLUID = 1 << 0, + STATUS_REACTIVE = 1 << 1, + STATUS_SOLID = 1 << 2, + STATUS_FREEZING = 1 << 3, + // Surface status + STATUS_BULK = 1 << 4, + STATUS_LAYER = 1 << 5, + STATUS_SURFACE = 1 << 6, + STATUS_SPLASH = 1 << 7, + // Temporary status options - reset in preforce + STATUS_SHIFT = 1 << 8, + STATUS_NO_FORCE = 1 << 9 + }; + + int PHASEMASK = 0xFFFFFFF0; + int SURFACEMASK = 0xFFFFFF0F; + +} // namespace RHEO_NS } // namespace LAMMPS_NS #endif diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 726c44c32b..75edf42572 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -33,6 +33,8 @@ using namespace LAMMPS_NS; using namespace FixConst; enum {NONE, LINEAR, CUBIC, TAITWATER}; +static constexpr double SEVENTH = 1.0 / 7.0; + /* ---------------------------------------------------------------------- */ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : @@ -43,7 +45,7 @@ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : pressure_style = NONE; comm_forward = 1; - nmax_old = 0; + nmax_store = 0; // Currently can only have one instance of fix rheo/pressure if (igroup != 0) @@ -112,13 +114,13 @@ void FixRHEOPressure::setup_pre_force(int /*vflag*/) // Create pressure array if it doesn't already exist // Create a custom atom property so it works with compute property/atom // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded + // Manually grow if nmax_store exceeded int tmp1, tmp2; int index = atom->find_custom("rheo_pressure", tmp1, tmp2); if (index == -1) { index = atom->add_custom("rheo_pressure", 1, 0); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } pressure = atom->dvector[index]; @@ -139,13 +141,11 @@ void FixRHEOPressure::pre_force(int /*vflag*/) int nlocal = atom->nlocal; - if (nmax_old < atom->nmax) { + if (nmax_store < atom->nmax) { memory->grow(pressure, atom->nmax, "atom:rheo_pressure"); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } - if (pressure_style == TAITWATER) inv7 = 1.0 / 7.0; - for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (pressure_style == LINEAR) { @@ -156,7 +156,7 @@ void FixRHEOPressure::pre_force(int /*vflag*/) } else if (pressure_style == TAITWATER) { rho_ratio = rho[i] / rho0inv; rr3 = rho_ratio * rho_ratio * rho_ratio; - pressure[i] = csq * rho0 * inv7 * (rr3 * rr3 * rho_ratio - 1.0); + pressure[i] = csq * rho0 * SEVENTH * (rr3 * rr3 * rho_ratio - 1.0); } } } @@ -194,9 +194,10 @@ void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ -double FixRHEOPressure::calculate_p(double rho) +double FixRHEOPressure::calc_pressure(double rho) { - double rho; + double p, dr, rr3, rho_ratio; + if (pressure_style == LINEAR) { p = csq * (rho - rho0); } else if (pressure_style == CUBIC) { @@ -205,7 +206,7 @@ double FixRHEOPressure::calculate_p(double rho) } else if (pressure_style == TAITWATER) { rho_ratio = rho / rho0inv; rr3 = rho_ratio * rho_ratio * rho_ratio; - p = csq * rho0 * inv7 * (rr3 * rr3 * rho_ratio - 1.0); + p = csq * rho0 * SEVENTH * (rr3 * rr3 * rho_ratio - 1.0); } return rho; } @@ -215,6 +216,6 @@ double FixRHEOPressure::calculate_p(double rho) double FixRHEOPressure::memory_usage() { double bytes = 0.0; - bytes += (size_t) nmax_old * sizeof(double); + bytes += (size_t) nmax_store * sizeof(double); return bytes; } diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h index 197cab6e5c..c257f1dbfb 100644 --- a/src/RHEO/fix_rheo_pressure.h +++ b/src/RHEO/fix_rheo_pressure.h @@ -35,13 +35,14 @@ class FixRHEOPressure : public Fix { int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; double memory_usage() override; - double calculate_p(double); + double calc_pressure(double); + private: double c_cubic, csq, rho0, rho0inv; double *pressure; int pressure_style; int first_flag, last_flag; - int nmax_old; + int nmax_store; class FixRHEO *fix_rheo; }; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index fd08f39fd7..5df8c1c506 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -22,6 +22,7 @@ #include "comm.h" #include "compute_rheo_grad.h" #include "compute_rheo_vshift.h" +#include "domain.h" #include "error.h" #include "fix_rheo.h" #include "force.h" @@ -31,14 +32,15 @@ #include "update.h" using namespace LAMMPS_NS; +using namespace RHEO_NS; using namespace FixConst; enum {NONE, CONSTANT, TYPE}; /* ---------------------------------------------------------------------- */ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr), - conductivity(nullptr) + Fix(lmp, narg, arg), fix_rheo(nullptr), compute_grad(nullptr), compute_vshift(nullptr), + Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr), conductivity(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -47,7 +49,7 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : conductivity_style = NONE; comm_forward = 1; - nmax_old = 0; + nmax_store = 0; int ntypes = atom->ntypes; int iarg = 3; @@ -181,13 +183,13 @@ void FixRHEOThermal::setup_pre_force(int /*vflag*/) // Identify whether this is the first/last instance of fix thermal // First will grow arrays, last will communicate - first_flag = 0 + first_flag = 0; last_flag = 0; int i = 0; auto fixlist = modify->get_fix_by_style("rheo/thermal"); - for (const auto &ifix : fixlist) { - if (strcmp(ifix->id, id) == 0) break; + for (const auto &fix : fixlist) { + if (strcmp(fix->id, id) == 0) break; i++; } @@ -197,13 +199,13 @@ void FixRHEOThermal::setup_pre_force(int /*vflag*/) // Create conductivity array if it doesn't already exist // Create a custom atom property so it works with compute property/atom // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded + // Manually grow if nmax_store exceeded int tmp1, tmp2; - index = atom->find_custom("rheo_conductivity", tmp1, tmp2); + int index = atom->find_custom("rheo_conductivity", tmp1, tmp2); if (index== -1) { index = atom->add_custom("rheo_conductivity", 1, 0); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } conductivity = atom->dvector[index]; @@ -217,13 +219,16 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) { // update temperature from shifting if (!fix_rheo->shift_flag) return; - int i; + int i, a; + int *status = atom->status; + int *mask = atom->mask; + double *temperature = atom->temperature; double **gradt = compute_grad->gradt; double **vshift = compute_vshift->array_atom; - int *mask = atom->mask; int nlocal = atom->nlocal; + int dim = domain->dimension; if (igroup == atom->firstgroup) nlocal = atom->nfirst; @@ -248,14 +253,14 @@ void FixRHEOThermal::post_integrate() double *heatflow = atom->heatflow; double *rho = atom->rho; int *mask = atom->mask; - int *type = aotm->type; + int *type = atom->type; double cvi, Tci, Ti; //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - if (status[i] == FixRHEO::FLUID_NO_FORCE) continue; + if (status[i] & STATUS_NO_FORCE) continue; cvi = calc_cv(i); temperature[i] += dtf * heatflow[i] / cvi; @@ -265,15 +270,15 @@ void FixRHEOThermal::post_integrate() if (Tc_style == CONSTANT) { Tci = Tc; } else if (Tc_style == TYPE) { - Tci = Tc_type[type[i]]); + Tci = Tc_type[type[i]]; } if (Ti > Tci) { - status[i] &= FixRHEO::phasemask; - status[i] |= FixRHEO::STATUS_FLUID; - } else if (!(status[i] & FixRHEO::STATUS_SOLID)) - status[i] &= FixRHEO::phasemask; - status[i] |= FixRHEO::STATUS_FREEZING; + status[i] &= PHASEMASK; + status[i] |= STATUS_FLUID; + } else if (!(status[i] & STATUS_SOLID)) { + status[i] &= PHASEMASK; + status[i] |= STATUS_FREEZING; } } } @@ -288,14 +293,13 @@ void FixRHEOThermal::post_neighbor() { int i; int *type = atom->type; - double *conductivity = atom->dvector[index_cond]; int *mask = atom->mask; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - if (first_flag && (nmax_old < atom->nmax)) { + if (first_flag && (nmax_store < atom->nmax)) { memory->grow(conductivity, atom->nmax, "atom:rheo_conductivity"); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } if (conductivity_style == CONSTANT) { @@ -304,7 +308,6 @@ void FixRHEOThermal::post_neighbor() } else if (conductivity_style == TYPE) { for (i = 0; i < nall; i++) if (mask[i] & groupbit) conductivity[i] = kappa_type[type[i]]; - } } } @@ -329,9 +332,9 @@ void FixRHEOThermal::pre_force(int /*vflag*/) //int *mask = atom->mask; //int nlocal = atom->nlocal; - //if (first_flag && (nmax_old < atom->nmax)) { + //if (first_flag && (nmax_store < atom->nmax)) { // memory->grow(conductivity, atom->nmax, "atom:rheo_conductivity"); - // nmax_old = atom->nmax; + // nmax_store = atom->nmax; //} //if (conductivity_style == TBD) { @@ -358,7 +361,7 @@ void FixRHEOThermal::final_integrate() //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - if (status[i] & FixRHEO::STATUS_NO_FORCE) continue; + if (status[i] & STATUS_NO_FORCE) continue; cvi = calc_cv(i); temperature[i] += dtf * heatflow[i] / cvi; @@ -447,6 +450,6 @@ void FixRHEOThermal::unpack_reverse_comm(int n, int *list, double *buf) double FixRHEOThermal::memory_usage() { double bytes = 0.0; - bytes += (size_t) nmax_old * sizeof(double); + bytes += (size_t) nmax_store * sizeof(double); return bytes; } diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index 4f0e89f17c..cf64c0b8d1 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -31,7 +31,7 @@ class FixRHEOThermal : public Fix { int setmask() override; void init() override; void setup_pre_force(int) override; - void initial_integrate() override; + void initial_integrate(int) override; void post_integrate() override; void post_neighbor() override; void pre_force(int) override; @@ -53,9 +53,11 @@ class FixRHEOThermal : public Fix { int cv_style; int conductivity_style; int first_flag, last_flag; - int nmax_old; + int nmax_store; class FixRHEO *fix_rheo; + class ComputeRHEOGrad *compute_grad; + class ComputeRHEOVShift *compute_vshift; double calc_cv(int); }; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 5ae1b95529..b15f488370 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -44,7 +44,7 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : viscosity_style = NONE; comm_forward = 0; - nmax_old = 0; + nmax_store = 0; int ntypes = atom->ntypes; int iarg = 3; @@ -89,7 +89,7 @@ FixRHEOViscosity::~FixRHEOViscosity() // Remove custom property if it exists int tmp1, tmp2, index; index = atom->find_custom("rheo_viscosity", tmp1, tmp2); - if (index != -1) atom->remove_custom(index_visc, 1, 0); + if (index != -1) atom->remove_custom(index, 1, 0); memory->destroy(eta_type); } @@ -123,13 +123,13 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) // Identify whether this is the first/last instance of fix viscosity // First will grow arrays, last will communicate - first_flag = 0 + first_flag = 0; last_flag = 0; int i = 0; auto fixlist = modify->get_fix_by_style("rheo/viscosity"); - for (const auto &ifix : fixlist) { - if (strcmp(ifix->id, id) == 0) break; + for (const auto &fix : fixlist) { + if (strcmp(fix->id, id) == 0) break; i++; } @@ -139,13 +139,13 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) // Create viscosity array if it doesn't already exist // Create a custom atom property so it works with compute property/atom // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_old exceeded + // Manually grow if nmax_store exceeded int tmp1, tmp2; int index = atom->find_custom("rheo_viscosity", tmp1, tmp2); - if (index_visc == -1) { + if (index == -1) { index = atom->add_custom("rheo_viscosity", 1, 0); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } viscosity = atom->dvector[index]; @@ -167,9 +167,9 @@ void FixRHEOViscosity::post_neighbor() int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - if (first_flag && (nmax_old < atom->nmax)) { + if (first_flag && (nmax_store < atom->nmax)) { memory->grow(viscosity, atom->nmax, "atom:rheo_viscosity"); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } if (viscosity_style == CONSTANT) { @@ -178,7 +178,6 @@ void FixRHEOViscosity::post_neighbor() } else if (viscosity_style == TYPE) { for (i = 0; i < nall; i++) if (mask[i] & groupbit) viscosity[i] = eta_type[type[i]]; - } } } @@ -197,9 +196,9 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) int nlocal = atom->nlocal; int dim = domain->dimension; - if (first_flag && (nmax_old < atom->nmax)) { + if (first_flag && (nmax_store < atom->nmax)) { memory->grow(viscosity, atom->nmax, "atom:rheo_viscosity"); - nmax_old = atom->nmax; + nmax_store = atom->nmax; } if (viscosity_style == POWER) { @@ -260,6 +259,6 @@ void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) double FixRHEOViscosity::memory_usage() { double bytes = 0.0; - bytes += (size_t) nmax_old * sizeof(double); + bytes += (size_t) nmax_store * sizeof(double); return bytes; } diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h index 14f8b70de9..66df51601e 100644 --- a/src/RHEO/fix_rheo_viscosity.h +++ b/src/RHEO/fix_rheo_viscosity.h @@ -43,7 +43,7 @@ class FixRHEOViscosity : public Fix { double *viscosity; int viscosity_style; int first_flag, last_flag; - int nmax_old; + int nmax_store; class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 5974b9b756..c61d613d82 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -39,9 +39,10 @@ #include using namespace LAMMPS_NS; +using namespace RHEO_NS; using namespace MathExtra; -#define EPSILON 1e-2 +static constexpr double EPSILON = 1e-2; /* ---------------------------------------------------------------------- */ @@ -83,6 +84,10 @@ void PairRHEO::compute(int eflag, int vflag) int *ilist, *jlist, *numneigh, **firstneigh; double imass, jmass, rsq, r, rinv; + int nlocal = atom->nlocal; + int newton_pair = force->newton_pair; + int dim = domain->dimension; + ev_init(eflag, vflag); double **gradv = compute_grad->gradv; @@ -123,11 +128,6 @@ void PairRHEO::compute(int eflag, int vflag) conductivity = atom->dvector[index]; } - int *ilist, *jlist, *numneigh, **firstneigh; - int nlocal = atom->nlocal; - int newton_pair = force->newton_pair; - int dim = domain->dimension; - inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; @@ -145,7 +145,7 @@ void PairRHEO::compute(int eflag, int vflag) jnum = numneigh[i]; imass = mass[itype]; etai = viscosity[i]; - fluidi = status[i] & FixRHEO::STATUS_FLUID; + fluidi = status[i] & STATUS_FLUID; if (thermal_flag) { kappai = conductivity[i]; Ti = temperature[i]; @@ -167,7 +167,7 @@ void PairRHEO::compute(int eflag, int vflag) jmass = mass[jtype]; etaj = viscosity[j]; - fluidj = status[j] & FixRHEO::STATUS_FLUID; + fluidj = status[j] & STATUS_FLUID; if (thermal_flag) { Tj = temperature[j]; kappaj = conductivity[j]; @@ -202,7 +202,7 @@ void PairRHEO::compute(int eflag, int vflag) if (fluidi && (!fluidj)) { compute_interface->correct_v(vi, vj, i, j); rhoj = compute_interface->correct_rho(j, i); - Pj = fix_pressure->calculate_p(rhoj); + Pj = fix_pressure->calc_pressure(rhoj); if ((chi[j] > 0.9) && (r < (h * 0.5))) fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; @@ -210,9 +210,9 @@ void PairRHEO::compute(int eflag, int vflag) } else if ((!fluidi) && fluidj) { compute_interface->correct_v(vj, vi, j, i); rhoi = compute_interface->correct_rho(i, j); - Pi = calc_pressure(rhoi, itype); + Pi = fix_pressure->calc_pressure(rhoi); - if (chi[i] > 0.9 && r < (h * 0.5)) { + if (chi[i] > 0.9 && r < (h * 0.5)) fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; } else if ((!fluidi) && (!fluidj)) { @@ -244,7 +244,7 @@ void PairRHEO::compute(int eflag, int vflag) //Hydrostatic pressure forces fp_prefactor = voli * volj * (Pj + Pi); - sub3(v1, vj, du); + sub3(vi, vj, du); //Add artificial viscous pressure if required if (artificial_visc_flag && pair_avisc_flag){ @@ -423,15 +423,11 @@ void PairRHEO::setup() if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use pair rheo"); fix_rheo = dynamic_cast(fixes[0]); + // Currently only allow one instance of fix rheo/pressure fixes = modify->get_fix_by_style("rheo/pressure"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo/pressure to use pair rheo"); fix_pressure = dynamic_cast(fixes[0]); - int tmp1, tmp2; - index_pressure = atom->find_custom("rheo_pressure", tmp1, tmp2); - if (index_pressure == -1) index_pressure = atom->add_custom("rheo_pressure", 1, 0); - else error->all(FLERR, "Cannot find pressure value in pair rheo"); - compute_kernel = fix_rheo->compute_kernel; compute_grad = fix_rheo->compute_grad; compute_interface = fix_rheo->compute_interface; @@ -449,9 +445,9 @@ void PairRHEO::setup() error->all(FLERR,"Pair RHEO requires ghost atoms store velocity"); if (laplacian_order == -1) { - if (fix_rheo->kernel_type == FixRHEO::CRK2) + if (fix_rheo->kernel_style == CRK2) laplacian_order = 2; - else if (fix_rheo->kernel_type == FixRHEO::CRK1) + else if (fix_rheo->kernel_style == CRK1) laplacian_order = 1; else laplacian_order = 0; @@ -468,8 +464,5 @@ double PairRHEO::init_one(int i, int j) error->all(FLERR,"All pair rheo coeffs are not set"); } - cut[i][j] = h; - cut[j][i] = cut[i][j]; - - return cut[i][j]; + return h; } From 7cfe45c00b9da61a911de193b0c3682cff291357 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 25 Apr 2023 10:29:39 -0600 Subject: [PATCH 028/104] Adding gsl version, cmake options, readme files --- cmake/CMakeLists.txt | 2 +- cmake/Modules/Packages/RHEO.cmake | 2 ++ cmake/presets/mingw-cross.cmake | 1 - cmake/presets/most.cmake | 1 - cmake/presets/windows.cmake | 1 - src/RHEO/README | 7 +++++++ src/RHEO/compute_rheo_kernel.cpp | 2 +- src/RHEO/fix_rheo.h | 4 ++-- 8 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 cmake/Modules/Packages/RHEO.cmake create mode 100644 src/RHEO/README diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f4a8b9c1ef..abcc392263 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -442,7 +442,7 @@ if(BUILD_OMP) target_link_libraries(lmp PRIVATE OpenMP::OpenMP_CXX) endif() -if(PKG_MSCG OR PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_ML-POD OR PKG_LATTE OR PKG_ELECTRODE) +if(PKG_MSCG OR PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_ML-POD OR PKG_LATTE OR PKG_ELECTRODE OR PKG_RHEO) enable_language(C) if (NOT USE_INTERNAL_LINALG) find_package(LAPACK) diff --git a/cmake/Modules/Packages/RHEO.cmake b/cmake/Modules/Packages/RHEO.cmake new file mode 100644 index 0000000000..970a141bbd --- /dev/null +++ b/cmake/Modules/Packages/RHEO.cmake @@ -0,0 +1,2 @@ +find_package(GSL REQUIRED) +target_link_libraries(lammps PRIVATE GSL::gsl) diff --git a/cmake/presets/mingw-cross.cmake b/cmake/presets/mingw-cross.cmake index ec21809edd..6c6170acd3 100644 --- a/cmake/presets/mingw-cross.cmake +++ b/cmake/presets/mingw-cross.cmake @@ -67,7 +67,6 @@ set(WIN_PACKAGES REACTION REAXFF REPLICA - RHEO RIGID SHOCK SMTBQ diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake index 2a2cac2755..00c74c81b8 100644 --- a/cmake/presets/most.cmake +++ b/cmake/presets/most.cmake @@ -58,7 +58,6 @@ set(ALL_PACKAGES REACTION REAXFF REPLICA - RHEO RIGID SHOCK SPH diff --git a/cmake/presets/windows.cmake b/cmake/presets/windows.cmake index 9253d439a8..aa9a4656af 100644 --- a/cmake/presets/windows.cmake +++ b/cmake/presets/windows.cmake @@ -56,7 +56,6 @@ set(WIN_PACKAGES REACTION REAXFF REPLICA - RHEO RIGID SHOCK SMTBQ diff --git a/src/RHEO/README b/src/RHEO/README new file mode 100644 index 0000000000..00fff2d694 --- /dev/null +++ b/src/RHEO/README @@ -0,0 +1,7 @@ +RHEO or Reproducing Hydrodynamics and Elastic Objects is a package to model multiphase fluid +systems. The authors include Joel Clemmer (Sandia), Thomas O'Connor (Carnegie Mellon), and +Eric Palermo (Carnegie Mellon). + +This package requires the GNU scientific library (GSL) version 2.7 or later. To build this +package, one must first separately install GSL in a location that can be found by your +environment. diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index d96d8d234e..b7ad1c9b3f 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -649,7 +649,7 @@ void ComputeRHEOKernel::compute_peratom() // Use gsl to get Minv, use Cholesky decomposition since the // polynomials are independent, M is symmetrix & positive-definite gM = gsl_matrix_view_array(M,Mdim,Mdim); - gsl_error = gsl_linalg_cholesky_decomp(&gM.matrix); + gsl_error = gsl_linalg_cholesky_decomp1(&gM.matrix); if (gsl_error) { //Revert to uncorrected SPH for this particle diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 1d8ae06159..f936206811 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -88,8 +88,8 @@ namespace RHEO_NS { STATUS_NO_FORCE = 1 << 9 }; - int PHASEMASK = 0xFFFFFFF0; - int SURFACEMASK = 0xFFFFFF0F; + #define PHASEMASK 0xFFFFFFF0; + #define SURFACEMASK 0xFFFFFF0F; } // namespace RHEO_NS } // namespace LAMMPS_NS From 7fc916a1d40d547cf1371b515a4c5e22a441db46 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 25 Apr 2023 13:38:37 -0600 Subject: [PATCH 029/104] Prototyping example and accessory commands --- src/RHEO/README | 6 +- src/RHEO/compute_rheo_property_atom.cpp | 162 ++++++++++++++++++++++++ src/RHEO/compute_rheo_property_atom.h | 68 ++++++++++ src/RHEO/fix_rheo.h | 4 +- src/set.cpp | 27 +++- 5 files changed, 261 insertions(+), 6 deletions(-) create mode 100644 src/RHEO/compute_rheo_property_atom.cpp create mode 100644 src/RHEO/compute_rheo_property_atom.h diff --git a/src/RHEO/README b/src/RHEO/README index 00fff2d694..7090fc828c 100644 --- a/src/RHEO/README +++ b/src/RHEO/README @@ -2,6 +2,6 @@ RHEO or Reproducing Hydrodynamics and Elastic Objects is a package to model mult systems. The authors include Joel Clemmer (Sandia), Thomas O'Connor (Carnegie Mellon), and Eric Palermo (Carnegie Mellon). -This package requires the GNU scientific library (GSL) version 2.7 or later. To build this -package, one must first separately install GSL in a location that can be found by your -environment. +This package requires the GNU scientific library (GSL). We recommend version 2.7 or later. To +build this package, one must first separately install GSL in a location that can be found by +your environment. diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp new file mode 100644 index 0000000000..a23ba5a639 --- /dev/null +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -0,0 +1,162 @@ +// 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 authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + +#include "compute_rheo_property_atom.h" + +#include "atom.h" +#include "atom_vec.h" +#include "error.h" +#include "memory.h" +#include "update.h" + +#include +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), + index(nullptr), colindex(nullptr), pack_choice(nullptr) +{ + if (narg < 4) utils::missing_cmd_args(FLERR, "compute property/atom", error); + + peratom_flag = 1; + nvalues = narg - 3; + if (nvalues == 1) size_peratom_cols = 0; + else size_peratom_cols = nvalues; + + // parse input values + // customize a new keyword by adding to if statement + + pack_choice = new FnPtrPack[nvalues]; + + int i; + for (int iarg = 3; iarg < narg; iarg++) { + i = iarg-3; + + if (strcmp(arg[iarg],"id") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_id; + } else if (strcmp(arg[iarg],"mol") == 0) { + if (!atom->molecule_flag) + error->all(FLERR,"Compute property/atom {} is not available", arg[iarg]); + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_molecule; + } else if (strcmp(arg[iarg],"proc") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_proc; + } else if (strcmp(arg[iarg],"type") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_type; + } else if (strcmp(arg[iarg],"mass") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_mass; + + + } else { + error->all(FLERR,"Invalid keyword {} for compute rheo/property/atom command ", arg[iarg]); + } + } + + nmax = 0; +} + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() +{ + delete[] pack_choice; + memory->destroy(vector_atom); + memory->destroy(array_atom); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::compute_peratom() +{ + invoked_peratom = update->ntimestep; + + // grow vector or array if necessary + + if (atom->nmax > nmax) { + nmax = atom->nmax; + if (nvalues == 1) { + memory->destroy(vector_atom); + memory->create(vector_atom,nmax,"rheo/property/atom:vector"); + } else { + memory->destroy(array_atom); + memory->create(array_atom,nmax,nvalues,"rheo/property/atom:array"); + } + } + + // fill vector or array with per-atom values + + if (nvalues == 1) { + buf = vector_atom; + (this->*pack_choice[0])(0); + } else { + if (nmax) buf = &array_atom[0][0]; + else buf = nullptr; + for (int n = 0; n < nvalues; n++) + (this->*pack_choice[n])(n); + } +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based array +------------------------------------------------------------------------- */ + +double ComputeRHEOPropertyAtom::memory_usage() +{ + double bytes = (double)nmax * nvalues * sizeof(double); + return bytes; +} + +/* ---------------------------------------------------------------------- + one method for every keyword compute rheo/property/atom can output + the atom property is packed into buf starting at n with stride nvalues + customize a new keyword by adding a method +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_rho(int n) +{ + double *rho = atom->rho; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = rho[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_status(int n) +{ + int *status = atom->status; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = status[i]; + else buf[n] = 0.0; + n += nvalues; + } +} diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h new file mode 100644 index 0000000000..26ca004da0 --- /dev/null +++ b/src/RHEO/compute_rheo_property_atom.h @@ -0,0 +1,68 @@ +/* -*- 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 COMPUTE_CLASS +// clang-format off +ComputeStyle(rheo/property/atom,ComputeRHEOPropertyAtom); +// clang-format on +#else + +#ifndef LMP_COMPUTE_RHEO_PROPERTY_ATOM_H +#define LMP_COMPUTE_RHEO_PROPERTY_ATOM_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeRHEOPropertyAtom : public Compute { + public: + ComputeRHEOPropertyAtom(class LAMMPS *, int, char **); + ~ComputeRHEOPropertyAtom() override; + void compute_peratom() override; + double memory_usage() override; + + private: + int nvalues; + int nmax; + double *buf; + + typedef void (ComputeRHEOPropertyAtom::*FnPtrPack)(int); + FnPtrPack *pack_choice; // ptrs to pack functions + + void pack_rho(int); + void pack_drho(int); + void pack_temperature(int); + void pack_heatflow(int); + void pack_status(int); + void pack_phase(int); + void pack_surface(int); + void pack_r_surface(int); + void pack_divr_surface(int); + void pack_nx_surface(int); + void pack_ny_surface(int); + void pack_nz_surface(int); + void pack_coordination(int); + void pack_viscosity(int); + void pack_pressure(int); + void pack_conductivity(int); + void pack_cv(int); + void pack_vx_shift(int); + void pack_vy_shift(int); + void pack_vz_shift(int); + +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index f936206811..a74696e68c 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -75,8 +75,8 @@ namespace RHEO_NS { enum Status{ // Phase status STATUS_FLUID = 1 << 0, - STATUS_REACTIVE = 1 << 1, - STATUS_SOLID = 1 << 2, + STATUS_SOLID = 1 << 1, + STATUS_REACTIVE = 1 << 2, STATUS_FREEZING = 1 << 3, // Surface status STATUS_BULK = 1 << 4, diff --git a/src/set.cpp b/src/set.cpp index 3a175cbfe2..92033b772e 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -49,7 +49,7 @@ enum{TYPE,TYPE_FRACTION,TYPE_RATIO,TYPE_SUBSET, DIPOLE,DIPOLE_RANDOM,SPIN_ATOM,SPIN_RANDOM,SPIN_ELECTRON,RADIUS_ELECTRON, QUAT,QUAT_RANDOM,THETA,THETA_RANDOM,ANGMOM,OMEGA,TEMPERATURE, DIAMETER,RADIUS_ATOM,DENSITY,VOLUME,IMAGE,BOND,ANGLE,DIHEDRAL,IMPROPER, - SPH_E,SPH_CV,SPH_RHO,EDPD_TEMP,EDPD_CV,CC,SMD_MASS_DENSITY, + RHEO_STATUS,SPH_E,SPH_CV,SPH_RHO,EDPD_TEMP,EDPD_CV,CC,SMD_MASS_DENSITY, SMD_CONTACT_RADIUS,DPDTHETA,EPSILON,IVEC,DVEC,IARRAY,DARRAY}; #define BIG INT_MAX @@ -515,6 +515,24 @@ void Set::command(int narg, char **arg) topology(IMPROPER); iarg += 2; + } else if (strcmp(arg[iarg],"rheo/rho") == 0) { + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set rheo/rho", error); + if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); + else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); + if (!atom->rho_flag) + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); + set(SPH_RHO); + iarg += 2; + + } else if (strcmp(arg[iarg],"rheo/status") == 0) { + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set rheo/status", error); + if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); + else ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (!atom->status_flag) + error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); + set(RHEO_STATUS); + iarg += 2; + } else if (strcmp(arg[iarg],"sph/e") == 0) { if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set sph/e", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); @@ -881,6 +899,13 @@ void Set::set(int keyword) if (dvalue <= 0.0) error->one(FLERR,"Invalid volume in set command"); atom->vfrac[i] = dvalue; } + + else if (keyword == RHEO_STATUS) { + if (ivalue != 0 && ivalue !=2) + error->one(FLERR,"Invalid value {} in set command for rheo/status", ivalue); + atom->status[i] = ivalue; + } + else if (keyword == SPH_E) atom->esph[i] = dvalue; else if (keyword == SPH_CV) atom->cv[i] = dvalue; else if (keyword == SPH_RHO) atom->rho[i] = dvalue; From be568d257d34a7133a1851adf9fce9ddb7c1184c Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 25 Apr 2023 16:29:29 -0600 Subject: [PATCH 030/104] Adding output option for reorganized peratom values --- src/RHEO/atom_vec_rheo.cpp | 36 ++- src/RHEO/atom_vec_rheo.h | 2 +- src/RHEO/atom_vec_rheo_thermal.cpp | 200 ++++++++++++ src/RHEO/atom_vec_rheo_thermal.h | 46 +++ src/RHEO/compute_rheo_grad.cpp | 85 ++--- src/RHEO/compute_rheo_grad.h | 8 +- src/RHEO/compute_rheo_interface.cpp | 66 ++-- src/RHEO/compute_rheo_kernel.cpp | 53 +-- src/RHEO/compute_rheo_kernel.h | 2 +- src/RHEO/compute_rheo_property_atom.cpp | 293 +++++++++++++++-- src/RHEO/compute_rheo_property_atom.h | 39 +-- src/RHEO/compute_rheo_surface.h | 4 +- src/RHEO/compute_rheo_vshift.cpp | 69 ++-- src/RHEO/compute_rheo_vshift.h | 5 +- src/RHEO/fix_rheo.cpp | 4 + src/RHEO/fix_rheo_pressure.cpp | 2 +- src/RHEO/fix_rheo_thermal.cpp | 141 +------- src/RHEO/fix_rheo_thermal.h | 11 +- src/RHEO/fix_rheo_viscosity.cpp | 54 +--- src/RHEO/fix_rheo_viscosity.h | 6 +- src/RHEO/pair_rheo.cpp | 19 +- src/atom.cpp | 14 +- src/atom.h | 5 +- src/atom_vec_rheo_thermal.cpp | 200 ++++++++++++ src/atom_vec_rheo_thermal.h | 46 +++ src/compute_rheo_property_atom.cpp | 411 ++++++++++++++++++++++++ src/compute_rheo_property_atom.h | 71 ++++ 27 files changed, 1443 insertions(+), 449 deletions(-) create mode 100644 src/RHEO/atom_vec_rheo_thermal.cpp create mode 100644 src/RHEO/atom_vec_rheo_thermal.h create mode 100644 src/atom_vec_rheo_thermal.cpp create mode 100644 src/atom_vec_rheo_thermal.h create mode 100644 src/compute_rheo_property_atom.cpp create mode 100644 src/compute_rheo_property_atom.h diff --git a/src/RHEO/atom_vec_rheo.cpp b/src/RHEO/atom_vec_rheo.cpp index de2e2f77ad..ea9e2a3c10 100644 --- a/src/RHEO/atom_vec_rheo.cpp +++ b/src/RHEO/atom_vec_rheo.cpp @@ -33,15 +33,17 @@ AtomVecRHEO::AtomVecRHEO(LAMMPS *lmp) : AtomVec(lmp) forceclearflag = 1; atom->status_flag = 1; + atom->pressure_flag = 1; atom->rho_flag = 1; + atom->viscosity_flag = 1; // strings with peratom variables to include in each AtomVec method // strings cannot contain fields in corresponding AtomVec default strings // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = {"status", "rho", "drho"}; - fields_copy = {"status", "rho", "drho"}; + fields_grow = {"status", "rho", "drho", "pressure", "viscosity"}; + fields_copy = {"status", "rho", "drho", "pressure", "viscosity"}; fields_comm = {"status", "rho"}; fields_comm_vel = {"status", "rho"}; fields_reverse = {"drho"}; @@ -49,7 +51,7 @@ AtomVecRHEO::AtomVecRHEO(LAMMPS *lmp) : AtomVec(lmp) fields_border_vel = {"status", "rho"}; fields_exchange = {"status", "rho"}; fields_restart = {"status", "rho"}; - fields_create = {"status", "rho", "drho"}; + fields_create = {"status", "rho", "drho", "pressure", "viscosity"}; fields_data_atom = {"id", "type", "status", "rho", "x"}; fields_data_vel = {"id", "v"}; @@ -64,8 +66,10 @@ AtomVecRHEO::AtomVecRHEO(LAMMPS *lmp) : AtomVec(lmp) void AtomVecRHEO::grow_pointers() { status = atom->status; + pressure = atom->pressure; rho = atom->rho; drho = atom->drho; + viscosity = atom->viscosity; } /* ---------------------------------------------------------------------- @@ -86,6 +90,8 @@ void AtomVecRHEO::force_clear(int n, size_t nbytes) void AtomVecRHEO::data_atom_post(int ilocal) { drho[ilocal] = 0.0; + pressure[ilocal] = 0.0; + viscosity[ilocal] = 0.0; } /* ---------------------------------------------------------------------- @@ -96,8 +102,10 @@ void AtomVecRHEO::data_atom_post(int ilocal) int AtomVecRHEO::property_atom(const std::string &name) { if (name == "status") return 0; - if (name == "rho") return 1; - if (name == "drho") return 2; + if (name == "pressure") return 1; + if (name == "rho") return 2; + if (name == "drho") return 3; + if (name == "viscosity") return 4; return -1; } @@ -123,12 +131,20 @@ void AtomVecRHEO::pack_property_atom(int index, double *buf, int nvalues, int gr } else if (index == 1) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) - buf[n] = rho[i]; + buf[n] = pressure[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 2) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = rho[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 3) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = drho[i]; @@ -136,5 +152,13 @@ void AtomVecRHEO::pack_property_atom(int index, double *buf, int nvalues, int gr buf[n] = 0.0; n += nvalues; } + } else if (index == 4) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = viscosity[i]; + else + buf[n] = 0.0; + n += nvalues; + } } } diff --git a/src/RHEO/atom_vec_rheo.h b/src/RHEO/atom_vec_rheo.h index bdd617a01d..68cc224ba5 100644 --- a/src/RHEO/atom_vec_rheo.h +++ b/src/RHEO/atom_vec_rheo.h @@ -36,7 +36,7 @@ class AtomVecRHEO : virtual public AtomVec { private: int *status; - double *rho, *drho; + double *pressure, *rho, *drho, *viscosity; }; } // namespace LAMMPS_NS diff --git a/src/RHEO/atom_vec_rheo_thermal.cpp b/src/RHEO/atom_vec_rheo_thermal.cpp new file mode 100644 index 0000000000..de0c7fa5d7 --- /dev/null +++ b/src/RHEO/atom_vec_rheo_thermal.cpp @@ -0,0 +1,200 @@ +/* ---------------------------------------------------------------------- + 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 authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + +#include "atom_vec_rheo_thermal.h" + +#include "atom.h" + +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +AtomVecRHEOThermal::AtomVecRHEOThermal(LAMMPS *lmp) : AtomVec(lmp) +{ + molecular = Atom::ATOMIC; + mass_type = PER_TYPE; + forceclearflag = 1; + + atom->status_flag = 1; + atom->conductivity_flag = 1; + atom->temperature_flag = 1; + atom->heatflow_flag = 1; + atom->pressure_flag = 1; + atom->rho_flag = 1; + atom->viscosity_flag = 1; + + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file + + fields_grow = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_copy = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_comm = {"status", "rho", "temperature"}; + fields_comm_vel = {"status", "rho", "temperature"}; + fields_reverse = {"drho", "heatflow"}; + fields_border = {"status", "rho", "temperature"}; + fields_border_vel = {"status", "rho", "temperature"}; + fields_exchange = {"status", "rho", "temperature"}; + fields_restart = {"status", "rho", "temperature"}; + fields_create = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_data_atom = {"id", "type", "status", "rho", "temperature", "x"}; + fields_data_vel = {"id", "v"}; + + setup_fields(); +} + +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::grow_pointers() +{ + status = atom->status; + conductivity = atom->conductivity; + temperature = atom->temperature; + heatflow = atom->heatflow; + pressure = atom->pressure; + rho = atom->rho; + drho = atom->drho; + viscosity = atom->viscosity; +} + +/* ---------------------------------------------------------------------- + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::force_clear(int n, size_t nbytes) +{ + memset(&drho[n], 0, nbytes); + memset(&heatflow[n], 0, nbytes); +} + +/* ---------------------------------------------------------------------- + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::data_atom_post(int ilocal) +{ + drho[ilocal] = 0.0; + heatflow[ilocal] = 0.0; + pressure[ilocal] = 0.0; + viscosity[ilocal] = 0.0; + conductivity[ilocal] = 0.0; +} + +/* ---------------------------------------------------------------------- + assign an index to named atom property and return index + return -1 if name is unknown to this atom style +------------------------------------------------------------------------- */ + +int AtomVecRHEOThermal::property_atom(const std::string &name) +{ + if (name == "status") return 0; + if (name == "rho") return 1; + if (name == "drho") return 2; + if (name == "temperature") return 3; + if (name == "heatflow") return 4; + if (name == "conductivity") return 5; + if (name == "pressure") return 6; + if (name == "viscosity") return 7; + return -1; +} + +/* ---------------------------------------------------------------------- + pack per-atom data into buf for ComputePropertyAtom + index maps to data specific to this atom style +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::pack_property_atom(int index, double *buf, int nvalues, int groupbit) +{ + int *mask = atom->mask; + int nlocal = atom->nlocal; + int n = 0; + + if (index == 0) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = status[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 1) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = rho[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 2) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = drho[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 3) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = temperature[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 4) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = heatflow[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 5) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = conductivity[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 6) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = pressure[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 7) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = viscosity[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } +} diff --git a/src/RHEO/atom_vec_rheo_thermal.h b/src/RHEO/atom_vec_rheo_thermal.h new file mode 100644 index 0000000000..27c6c3c9b5 --- /dev/null +++ b/src/RHEO/atom_vec_rheo_thermal.h @@ -0,0 +1,46 @@ +/* -*- 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 ATOM_CLASS +// clang-format off +AtomStyle(rheo/thermal,AtomVecRHEOThermal); +// clang-format on +#else + +#ifndef LMP_ATOM_VEC_RHEO_THERMAL_H +#define LMP_ATOM_VEC_RHEO_THERMAL_H + +#include "atom_vec.h" + +namespace LAMMPS_NS { + +class AtomVecRHEOThermal : virtual public AtomVec { + public: + AtomVecRHEOThermal(class LAMMPS *); + + void grow_pointers() override; + void force_clear(int, size_t) override; + void data_atom_post(int) override; + int property_atom(const std::string &) override; + void pack_property_atom(int, double *, int, int) override; + + private: + int *status; + double *conductivity, *temperature, *heatflow; + double *pressure, *rho, *drho, *viscosity; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 606cec7dfc..b71fb08d78 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -84,69 +84,34 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : } comm_forward = ncomm_grad; + + nmax_store = 0; + grow_arrays(atom->nmax); + } /* ---------------------------------------------------------------------- */ ComputeRHEOGrad::~ComputeRHEOGrad() { - int dim = domain->dimension; - int tmp1, tmp2, index; - - index = atom->find_custom("rheo_grad_v", tmp1, tmp2); - if (index != 1) atom->remove_custom(index, 1, dim * dim); - index = atom->find_custom("rheo_grad_rho", tmp1, tmp2); - if (index != 1) atom->remove_custom(index, 1, dim); - index = atom->find_custom("rheo_grad_t", tmp1, tmp2); - if (index != 1) atom->remove_custom(index, 1, dim); - index = atom->find_custom("rheo_grad_eta", tmp1, tmp2); - if (index != 1) atom->remove_custom(index, 1, dim); + memory->destroy(gradv); + memory->destroy(gradr); + memory->destroy(gradt); + memory->destroy(gradn); } /* ---------------------------------------------------------------------- */ void ComputeRHEOGrad::init() { - neighbor->add_request(this, NeighConst::REQ_DEFAULT); - cut = fix_rheo->cut; cutsq = cut * cut; rho0 = fix_rheo->rho0; + interface_flag = fix_rheo->interface_flag; compute_kernel = fix_rheo->compute_kernel; compute_interface = fix_rheo->compute_interface; - int tmp1, tmp2; - index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); - - // Create coordination array if it doesn't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded - - int index; - int dim = domain->dimension; - if (velocity_flag) { - index = atom->add_custom("rheo_grad_v", 1, dim * dim); - gradv = atom->darray[index]; - } - - if (rho_flag) { - index = atom->add_custom("rheo_grad_rho", 1, dim); - gradr = atom->darray[index]; - } - - if (temperature_flag) { - index= atom->add_custom("rheo_grad_temp", 1, dim); - gradt = atom->darray[index]; - } - - if (eta_flag) { - index = atom->add_custom("rheo_grad_eta", 1, dim); - gradn = atom->darray[index]; - } - - nmax_store = 0; - grow_arrays(atom->nmax); + neighbor->add_request(this, NeighConst::REQ_DEFAULT); } /* ---------------------------------------------------------------------- */ @@ -175,7 +140,7 @@ void ComputeRHEOGrad::compute_peratom() double **v = atom->v; double *rho = atom->rho; double *temperature = atom->temperature; - double *viscosity = atom->dvector[index_visc]; + double *viscosity = atom->viscosity; int *status = atom->status; int *type = atom->type; double *mass = atom->mass; @@ -240,15 +205,17 @@ void ComputeRHEOGrad::compute_peratom() vj[2] = v[j][2]; // Add corrections for walls - if ((status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { - compute_interface->correct_v(vi, vj, i, j); - rhoj = compute_interface->correct_rho(j, i); - } else if (!(status[i] & STATUS_FLUID) && (status[j] & STATUS_FLUID)) { - compute_interface->correct_v(vj, vi, j, i); - rhoi = compute_interface->correct_rho(i, j); - } else if (!(status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { - rhoi = rho0; - rhoj = rho0; + if (interface_flag) { + if ((status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { + compute_interface->correct_v(vi, vj, i, j); + rhoj = compute_interface->correct_rho(j, i); + } else if (!(status[i] & STATUS_FLUID) && (status[j] & STATUS_FLUID)) { + compute_interface->correct_v(vj, vi, j, i); + rhoi = compute_interface->correct_rho(i, j); + } else if (!(status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { + rhoi = rho0; + rhoj = rho0; + } } Voli = mass[itype] / rhoi; @@ -481,16 +448,16 @@ void ComputeRHEOGrad::grow_arrays(int nmax) { int dim = domain->dimension; if (velocity_flag) - memory->grow(gradv, nmax, dim * dim, "atom:rheo_grad_v"); + memory->grow(gradv, nmax, dim * dim, "rheo:grad_v"); if (rho_flag) - memory->grow(gradr, nmax, dim, "atom:rheo_grad_rho"); + memory->grow(gradr, nmax, dim, "rheo:grad_rho"); if (temperature_flag) - memory->grow(gradt, nmax, dim, "atom:rheo_grad_temp"); + memory->grow(gradt, nmax, dim, "rheo:grad_temp"); if (eta_flag) - memory->grow(gradn, nmax, dim, "atom:rheo_grad_eta"); + memory->grow(gradn, nmax, dim, "rheo:grad_eta"); nmax_store = nmax; } diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index 8c7962a978..af4fecdcfb 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -46,14 +46,14 @@ class ComputeRHEOGrad : public Compute { private: int comm_stage, ncomm_grad, ncomm_field, nmax_store; - int index_visc; double cut, cutsq, rho0; - class NeighList *list; + + int velocity_flag, temperature_flag, rho_flag, eta_flag; + int interface_flag; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; - - int velocity_flag, temperature_flag, rho_flag, eta_flag; + class NeighList *list; void grow_arrays(int); }; diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index 72dcdc17d7..a3624f9663 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -46,24 +46,35 @@ ComputeRHEOInterface::ComputeRHEOInterface(LAMMPS *lmp, int narg, char **arg) : { if (narg != 3) error->all(FLERR,"Illegal compute rheo/interface command"); - nmax_store = 0; - comm_forward = 3; comm_reverse = 4; + + nmax_store = atom->nmax; + memory->create(chi, nmax_store, "rheo:chi"); + memory->create(norm, nmax_store, "rheo/interface:norm"); + memory->create(normwf, nmax_store, "rheo/interface:normwf"); + + // For fp_store, create an instance of fix property atom + // Need restarts + exchanging with neighbors since it needs to persist + // between timesteps (fix property atom will handle callbacks) + + int tmp1, tmp2; + int index = atom->find_custom("fp_store", tmp1, tmp2); + if (index == -1) { + id_fix_pa = utils::strdup(id + std::string("_fix_property_atom")); + modify->add_fix(fmt::format("{} all property/atom d2_fp_store 3", id_fix_pa)); + index = atom->find_custom("fp_store", tmp1, tmp2); + } + fp_store = atom->darray[index]; } /* ---------------------------------------------------------------------- */ ComputeRHEOInterface::~ComputeRHEOInterface() { - // Remove custom property if it exists - int tmp1, tmp2, index; - index = atom->find_custom("rheo_chi", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); - if (id_fix_pa && modify->nfix) modify->delete_fix(id_fix_pa); delete[] id_fix_pa; - + memory->destroy(chi); memory->destroy(norm); memory->destroy(normwf); } @@ -80,37 +91,6 @@ void ComputeRHEOInterface::init() cutsq = cut * cut; wall_max = sqrt(3.0) / 12.0 * cut; - // Create chi array if it doesn't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded - - int tmp1, tmp2; - int nmax = atom->nmax; - int index = atom->find_custom("rheo_chi", tmp1, tmp2); - if (index == -1) { - index = atom->add_custom("rheo_chi", 1, 0); - memory->destroy(norm); - memory->destroy(normwf); - memory->create(norm, nmax, "rheo/interface:norm"); - memory->create(normwf, nmax, "rheo/interface:normwf"); - nmax_store = nmax; - } - chi = atom->dvector[index]; - - // For fp_store, go ahead and create an instance of fix property atom - // Need restarts + exchanging with neighbors since it needs to persist - // between timesteps (fix property atom will handle callbacks) - - index = atom->find_custom("fp_store", tmp1, tmp2); - if (index == -1) { - id_fix_pa = utils::strdup(id + std::string("_fix_property_atom")); - modify->add_fix(fmt::format("{} all property/atom d2_fp_store 3", id_fix_pa)); - index = atom->find_custom("fp_store", tmp1, tmp2); - } - fp_store = atom->darray[index]; - - // need an occasional half neighbor list neighbor->add_request(this, NeighConst::REQ_DEFAULT); } @@ -145,11 +125,9 @@ void ComputeRHEOInterface::compute_peratom() if (atom->nmax > nmax_store) { nmax_store = atom->nmax; - memory->destroy(norm); - memory->destroy(normwf); - memory->create(norm, nmax_store, "rheo/interface:norm"); - memory->create(normwf, nmax_store, "rheo/interface:normwf"); - memory->grow(chi, nmax_store, "rheo/interface:chi"); + memory->grow(norm, nmax_store, "rheo/interface:norm"); + memory->grow(normwf, nmax_store, "rheo/interface:normwf"); + memory->grow(chi, nmax_store, "rheo:chi"); } for (i = 0; i < nall; i++) { diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index b7ad1c9b3f..9cfa86df7e 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -68,7 +68,6 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : correction_order = 2; } - solid_flag = 0; dim = domain->dimension; comm_forward = 1; @@ -93,11 +92,7 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : ComputeRHEOKernel::~ComputeRHEOKernel() { - // Remove custom property if it exists - int tmp1, tmp2, index; - index = atom->find_custom("rheo_coordination", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 0, 0); - + memory->destroy(coordination); memory->destroy(C); memory->destroy(C0); } @@ -112,11 +107,8 @@ void ComputeRHEOKernel::init() if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use compute rheo/kernel"); fix_rheo = dynamic_cast(fixes[0]); - int icompute = modify->find_compute("rheo_interface"); - if (icompute != -1) { - compute_interface = ((ComputeRHEOInterface *) modify->compute[icompute]); - solid_flag = 1; - } + interface_flag = fix_rheo->interface_flag; + compute_interface = fix_rheo->compute_interface; zmin = fix_rheo->zmin_kernel; h = fix_rheo->h; @@ -133,22 +125,8 @@ void ComputeRHEOKernel::init() pre_wp = pre_w * 3.0 * hinv; } - // Create coordination array if it doesn't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded - - int tmp1, tmp2; - int nmax = atom->nmax; - int index = atom->find_custom("rheo_coordination", tmp1, tmp2); - if (index == -1) { - index = atom->add_custom("rheo_coordination", 0, 0); - nmax_store = nmax; - } - coordination = atom->ivector[index]; - - // Create local arrays for kernel arrays, I can't foresee a reason to print - + nmax_store = atom->nmax; + memory->create(coordination, nmax_store, "rheo:coordination"); if (kernel_style == CRK0) { memory->create(C0, nmax_store, "rheo/kernel:C0"); } else if (kernel_style == CRK1) { @@ -499,7 +477,7 @@ void ComputeRHEOKernel::compute_peratom() if (kernel_style == QUINTIC) return; int i, j, ii, jj, inum, jnum, itype, g, a, b, gsl_error; - double xtmp, ytmp, ztmp, r, rsq, w, vj; + double xtmp, ytmp, ztmp, r, rsq, w, vj, rhoj; double dx[3]; gsl_matrix_view gM; @@ -549,10 +527,12 @@ void ComputeRHEOKernel::compute_peratom() if (rsq < hsq) { r = sqrt(rsq); w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); - if (!(status[j] & STATUS_FLUID) && solid_flag) { - vj = mass[type[j]] / compute_interface->correct_rho(j,i); - } else vj = mass[type[j]] / rho[j]; + rhoj = rho[j]; + if (interface_flag) + if (!(status[j] & STATUS_FLUID)) + rhoj = compute_interface->correct_rho(j,i); + vj = mass[type[j]] / rhoj; M += w * vj; } } @@ -596,11 +576,12 @@ void ComputeRHEOKernel::compute_peratom() r = sqrt(rsq); w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); - if (solid_flag) + rhoj = rho[j]; + if (interface_flag) if (!(status[j] & STATUS_FLUID)) - vj = mass[type[j]]/compute_interface->correct_rho(j,i); - else - vj = mass[type[j]]/rho[j]; + rhoj = compute_interface->correct_rho(j,i); + + vj = mass[type[j]] / rhoj; //Populate the H-vector of polynomials (2D) if (dim == 2) { @@ -759,7 +740,7 @@ void ComputeRHEOKernel::compute_coordination() void ComputeRHEOKernel::grow_arrays(int nmax) { - memory->grow(coordination, nmax, "atom:rheo_coordination"); + memory->grow(coordination, nmax, "rheo:coordination"); if (kernel_style == CRK0) { memory->grow(C0, nmax, "rheo/kernel:C0"); diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index 1842406977..5324199f76 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -49,7 +49,7 @@ class ComputeRHEOKernel : public Compute { private: int comm_stage, comm_forward_save; - int solid_flag; + int interface_flag; int gsl_error_flag; std::unordered_set gsl_error_tags; diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index a23ba5a639..7682552abe 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -21,20 +21,29 @@ #include "atom.h" #include "atom_vec.h" +#include "compute_rheo_interface.h" +#include "compute_rheo_kernel.h" +#include "compute_rheo_surface.h" +#include "compute_rheo_vshift.h" #include "error.h" +#include "fix_rheo.h" +#include "fix_rheo_thermal.h" #include "memory.h" +#include "modify.h" #include "update.h" #include #include using namespace LAMMPS_NS; +using namespace RHEO_NS; /* ---------------------------------------------------------------------- */ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - index(nullptr), colindex(nullptr), pack_choice(nullptr) + Compute(lmp, narg, arg), fix_rheo(nullptr), fix_thermal(nullptr), compute_interface(nullptr), + compute_kernel(nullptr), compute_surface(nullptr), compute_vshift(nullptr), + index(nullptr), pack_choice(nullptr) { if (narg < 4) utils::missing_cmd_args(FLERR, "compute property/atom", error); @@ -43,31 +52,66 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (nvalues == 1) size_peratom_cols = 0; else size_peratom_cols = nvalues; + thermal_flag, interface_flag, surface_flag, shift_flag = 0; + // parse input values // customize a new keyword by adding to if statement pack_choice = new FnPtrPack[nvalues]; + index = new int[nvalues]; int i; for (int iarg = 3; iarg < narg; iarg++) { i = iarg-3; - if (strcmp(arg[iarg],"id") == 0) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_id; - } else if (strcmp(arg[iarg],"mol") == 0) { - if (!atom->molecule_flag) - error->all(FLERR,"Compute property/atom {} is not available", arg[iarg]); - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_molecule; - } else if (strcmp(arg[iarg],"proc") == 0) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_proc; - } else if (strcmp(arg[iarg],"type") == 0) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_type; - } else if (strcmp(arg[iarg],"mass") == 0) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_mass; - - + if (strcmp(arg[iarg],"phase") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_phase; + } else if (strcmp(arg[iarg],"chi") == 0) { + interface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_chi; + } else if (strcmp(arg[iarg],"surface") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface; + } else if (strcmp(arg[iarg],"surface/r") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_r; + } else if (strcmp(arg[iarg],"surface/divr") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_divr; + } else if (strcmp(arg[iarg],"surface/nx") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_nx; + } else if (strcmp(arg[iarg],"surface/ny") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_ny; + } else if (strcmp(arg[iarg],"surface/nz") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_nz; + } else if (strcmp(arg[iarg],"coordination") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_coordination; + } else if (strcmp(arg[iarg],"cv") == 0) { + thermal_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; + } else if (strcmp(arg[iarg],"shift/vx") == 0) { + shift_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vx; + } else if (strcmp(arg[iarg],"shift/vy") == 0) { + shift_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vy; + } else if (strcmp(arg[iarg],"shift/vz") == 0) { + shift_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vz; } else { - error->all(FLERR,"Invalid keyword {} for compute rheo/property/atom command ", arg[iarg]); + index[i] = atom->avec->property_atom(arg[iarg]); + if (index[i] < 0) + error->all(FLERR, + "Invalid keyword {} for atom style {} in compute rheo/property/atom command ", + atom->get_style(), arg[iarg]); + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_atom_style; + + if (strcmp(arg[iarg],"temperature") == 0) thermal_flag = 1; + if (strcmp(arg[iarg],"heatflow") == 0) thermal_flag = 1; + if (strcmp(arg[iarg],"conductivity") == 0) thermal_flag = 1; } } @@ -79,12 +123,41 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() { delete[] pack_choice; + delete[] index; memory->destroy(vector_atom); memory->destroy(array_atom); } /* ---------------------------------------------------------------------- */ +void ComputeRHEOPropertyAtom::init() +{ + auto fixes = modify->get_fix_by_style("rheo"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); + fix_rheo = dynamic_cast(fixes[0]); + + if (interface_flag && !(fix_rheo->interface_flag)) + error->all(FLERR, "Cannot request interfacial property without corresponding option in fix rheo"); + if (surface_flag && !(fix_rheo->surface_flag)) + error->all(FLERR, "Cannot request surface property without corresponding option in fix rheo"); + if (shift_flag && !(fix_rheo->shift_flag)) + error->all(FLERR, "Cannot request velocity shifting property without corresponding option in fix rheo"); + if (thermal_flag && !(fix_rheo->thermal_flag)) + error->all(FLERR, "Cannot request thermal property without fix rheo/thermal"); + + compute_interface = fix_rheo->compute_interface; + compute_kernel = fix_rheo->compute_kernel; + compute_surface = fix_rheo->compute_surface; + compute_vshift = fix_rheo->compute_vshift; + + if (thermal_flag) { + fixes = modify->get_fix_by_style("rheo/thermal"); + fix_thermal = dynamic_cast(fixes[0]); + } +} + +/* ---------------------------------------------------------------------- */ + void ComputeRHEOPropertyAtom::compute_peratom() { invoked_peratom = update->ntimestep; @@ -133,14 +206,16 @@ double ComputeRHEOPropertyAtom::memory_usage() /* ---------------------------------------------------------------------- */ -void ComputeRHEOPropertyAtom::pack_rho(int n) +void ComputeRHEOPropertyAtom::pack_phase(int n) { - double *rho = atom->rho; + int *status = atom->status; int *mask = atom->mask; int nlocal = atom->nlocal; + int inverse_mask = ~PHASEMASK; + for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = rho[i]; + if (mask[i] & groupbit) buf[n] = (status[i] & inverse_mask); else buf[n] = 0.0; n += nvalues; } @@ -148,15 +223,189 @@ void ComputeRHEOPropertyAtom::pack_rho(int n) /* ---------------------------------------------------------------------- */ -void ComputeRHEOPropertyAtom::pack_status(int n) +void ComputeRHEOPropertyAtom::pack_chi(int n) +{ + double *chi = compute_interface->chi; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = chi[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface(int n) { int *status = atom->status; int *mask = atom->mask; int nlocal = atom->nlocal; + int inverse_mask = ~SURFACEMASK; + for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = status[i]; + if (mask[i] & groupbit) buf[n] = (status[i] & inverse_mask); else buf[n] = 0.0; n += nvalues; } } + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_r(int n) +{ + double *rsurface = compute_surface->rsurface; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = rsurface[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_divr(int n) +{ + double *divr = compute_surface->divr; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = divr[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_nx(int n) +{ + double **nsurface = compute_surface->nsurface; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = nsurface[i][0]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_ny(int n) +{ + double **nsurface = compute_surface->nsurface; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = nsurface[i][1]; + else buf[n] = 0.0; + n += nvalues; + } +} + + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_nz(int n) +{ + double **nsurface = compute_surface->nsurface; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = nsurface[i][2]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_coordination(int n) +{ + int *coordination = compute_kernel->coordination; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = coordination[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_cv(int n) +{ + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = fix_thermal->calc_cv(i); + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_shift_vx(int n) +{ + double **vshift = compute_vshift->vshift; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = vshift[i][0]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_shift_vy(int n) +{ + double **vshift = compute_vshift->vshift; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = vshift[i][1]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_shift_vz(int n) +{ + double **vshift = compute_vshift->vshift; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = vshift[i][2]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_atom_style(int n) +{ + atom->avec->pack_property_atom(index[n],&buf[n],nvalues,groupbit); +} diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index 26ca004da0..accb7e9156 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -28,37 +28,40 @@ class ComputeRHEOPropertyAtom : public Compute { public: ComputeRHEOPropertyAtom(class LAMMPS *, int, char **); ~ComputeRHEOPropertyAtom() override; + void init() override; void compute_peratom() override; double memory_usage() override; private: - int nvalues; - int nmax; + int nvalues, nmax; + int thermal_flag, interface_flag, surface_flag, shift_flag; + int *index; double *buf; typedef void (ComputeRHEOPropertyAtom::*FnPtrPack)(int); FnPtrPack *pack_choice; // ptrs to pack functions - void pack_rho(int); - void pack_drho(int); - void pack_temperature(int); - void pack_heatflow(int); - void pack_status(int); void pack_phase(int); + void pack_chi(int); void pack_surface(int); - void pack_r_surface(int); - void pack_divr_surface(int); - void pack_nx_surface(int); - void pack_ny_surface(int); - void pack_nz_surface(int); + void pack_surface_r(int); + void pack_surface_divr(int); + void pack_surface_nx(int); + void pack_surface_ny(int); + void pack_surface_nz(int); void pack_coordination(int); - void pack_viscosity(int); - void pack_pressure(int); - void pack_conductivity(int); void pack_cv(int); - void pack_vx_shift(int); - void pack_vy_shift(int); - void pack_vz_shift(int); + void pack_shift_vx(int); + void pack_shift_vy(int); + void pack_shift_vz(int); + void pack_atom_style(int); + + class FixRHEO *fix_rheo; + class FixRHEOThermal *fix_thermal; + class ComputeRHEOInterface *compute_interface; + class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOSurface *compute_surface; + class ComputeRHEOVShift *compute_vshift; }; diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index 58a3e3b9c4..220f8beb6d 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -36,13 +36,13 @@ class ComputeRHEOSurface : public Compute { int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; - double **nsurface, *rsurface; + double **nsurface, *rsurface, *divr; class FixRHEO *fix_rheo; private: double cut, cutsq, rho0, threshold_divr; int surface_style, nmax_store, threshold_z; - double **B, **gradC, *divr; + double **B, **gradC; int threshold_style, comm_stage; class NeighList *list; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 440bfc7fc7..3d3914436e 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -22,6 +22,7 @@ #include "comm.h" #include "compute_rheo_interface.h" #include "compute_rheo_kernel.h" +#include "compute_rheo_surface.h" #include "domain.h" #include "error.h" #include "fix_rheo.h" @@ -38,36 +39,22 @@ using namespace RHEO_NS; ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), list(nullptr), vshift(nullptr), fix_rheo(nullptr), - compute_kernel(nullptr), compute_interface(nullptr) + compute_kernel(nullptr), compute_interface(nullptr), compute_surface(nullptr) { if (narg != 3) error->all(FLERR,"Illegal compute RHEO/VShift command"); comm_reverse = 3; surface_flag = 0; - // Create vshift array if it doesn't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded - - int tmp1, tmp2; - int index = atom->find_custom("rheo_vshift", tmp1, tmp2); - if (index == -1) { - index = atom->add_custom("rheo_vshift", 1, 3); - nmax_store = atom->nmax; - } - vshift = atom->darray[index]; + nmax_store = atom->nmax; + memory->create(vshift, nmax_store, 3, "rheo:vshift"); } /* ---------------------------------------------------------------------- */ ComputeRHEOVShift::~ComputeRHEOVShift() { - // Remove custom property if it exists - int tmp1, tmp2, index; - index = atom->find_custom("rheo_vshift", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 3); - + memory->destroy(vshift); } /* ---------------------------------------------------------------------- */ @@ -76,12 +63,12 @@ void ComputeRHEOVShift::init() { neighbor->add_request(this, NeighConst::REQ_DEFAULT); - surface_flag = 0; - if (fix_rheo->surface_flag) - surface_flag = 1; + surface_flag = fix_rheo->surface_flag; + interface_flag = fix_rheo->interface_flag; compute_kernel = fix_rheo->compute_kernel; compute_interface = fix_rheo->compute_interface; + compute_surface = fix_rheo->compute_surface; cut = fix_rheo->cut; cutsq = cut * cut; @@ -128,7 +115,7 @@ void ComputeRHEOVShift::compute_peratom() firstneigh = list->firstneigh; if (nmax_store < atom->nmax) { - memory->grow(vshift, atom->nmax, 3, "atom:rheo_vshift"); + memory->grow(vshift, atom->nmax, 3, "rheo:vshift"); nmax_store = atom->nmax; } @@ -176,15 +163,17 @@ void ComputeRHEOVShift::compute_peratom() rhoj = rho[j]; // Add corrections for walls - if (fluidi && (!fluidj)) { - compute_interface->correct_v(vi, vj, i, j); - rhoj = compute_interface->correct_rho(j,i); - } else if ((!fluidi) && fluidj) { - compute_interface->correct_v(vj, vi, j, i); - rhoi = compute_interface->correct_rho(i,j); - } else if ((!fluidi) && (!fluidj)) { - rhoi = 1.0; - rhoj = 1.0; + if (interface_flag) { + if (fluidi && (!fluidj)) { + compute_interface->correct_v(vi, vj, i, j); + rhoj = compute_interface->correct_rho(j,i); + } else if ((!fluidi) && fluidj) { + compute_interface->correct_v(vj, vi, j, i); + rhoi = compute_interface->correct_rho(i,j); + } else if ((!fluidi) && (!fluidj)) { + rhoi = 1.0; + rhoj = 1.0; + } } voli = imass / rhoi; @@ -227,30 +216,28 @@ void ComputeRHEOVShift::correct_surfaces() { if (!surface_flag) return; + int i, a, b; + int *status = atom->status; int *mask = atom->mask; - int nlocal = atom->nlocal; - int i, a, b; - int dim = domain->dimension; + double **nsurface = compute_surface->nsurface; - int tmp1, tmp2; - int index_nsurf = atom->find_custom("rheo_nsurf", tmp1, tmp2); - if (index_nsurf == -1) error->all(FLERR, "Cannot find rheo nsurf"); - double **nsurf = atom->darray[index_nsurf]; + int nlocal = atom->nlocal; + int dim = domain->dimension; double nx,ny,nz,vx,vy,vz; for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if ((status[i] & STATUS_SURFACE) || (status[i] & STATUS_LAYER)) { - nx = nsurf[i][0]; - ny = nsurf[i][1]; + nx = nsurface[i][0]; + ny = nsurface[i][1]; vx = vshift[i][0]; vy = vshift[i][1]; vz = vshift[i][2]; vshift[i][0] = (1 - nx * nx) * vx - nx * ny * vy; vshift[i][1] = (1 - ny * ny) * vy - nx * ny * vx; if (dim > 2) { - nz = nsurf[i][2]; + nz = nsurface[i][2]; vshift[i][0] -= nx * nz * vz; vshift[i][1] -= ny * nz * vz; vshift[i][2] = (1 - nz * nz) * vz - nz * ny * vy - nx * nz * vx; diff --git a/src/RHEO/compute_rheo_vshift.h b/src/RHEO/compute_rheo_vshift.h index 8611e177d1..9d3a0166d6 100644 --- a/src/RHEO/compute_rheo_vshift.h +++ b/src/RHEO/compute_rheo_vshift.h @@ -42,11 +42,12 @@ class ComputeRHEOVShift : public Compute { private: int nmax_store; double dtv, cut, cutsq, cutthird; - int surface_flag; + int surface_flag, interface_flag; class NeighList *list; - class ComputeRHEOInterface *compute_interface ; + class ComputeRHEOInterface *compute_interface; class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOSurface *compute_surface; }; } // namespace LAMMPS_NS diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index ff804fe007..ac870affd5 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -60,8 +60,12 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : if (igroup != 0) error->all(FLERR,"fix rheo command requires group all"); + if (atom->pressure_flag != 1) + error->all(FLERR,"fix rheo command requires atom_style with pressure"); if (atom->rho_flag != 1) error->all(FLERR,"fix rheo command requires atom_style with density"); + if (atom->viscosity_flag != 1) + error->all(FLERR,"fix rheo command requires atom_style with viscosity"); if (atom->status_flag != 1) error->all(FLERR,"fix rheo command requires atom_style with status"); diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 75edf42572..45557794cd 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -38,7 +38,7 @@ static constexpr double SEVENTH = 1.0 / 7.0; /* ---------------------------------------------------------------------- */ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), fix_rheo(nullptr), pressure(nullptr) + Fix(lmp, narg, arg), fix_rheo(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 5df8c1c506..0d8909b908 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -40,7 +40,7 @@ enum {NONE, CONSTANT, TYPE}; FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), fix_rheo(nullptr), compute_grad(nullptr), compute_vshift(nullptr), - Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr), conductivity(nullptr) + Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -48,9 +48,6 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : cv_style = NONE; conductivity_style = NONE; - comm_forward = 1; - nmax_store = 0; - int ntypes = atom->ntypes; int iarg = 3; while (iarg < narg) { @@ -170,9 +167,11 @@ void FixRHEOThermal::init() dtf = 0.5 * update->dt * force->ftm2v; if (atom->temperature_flag != 1) - error->all(FLERR,"fix rheo/thermal command requires atoms store temperature property"); + error->all(FLERR,"fix rheo/thermal command requires atom property temperature"); if (atom->heatflow_flag != 1) - error->all(FLERR,"fix rheo/thermal command requires atoms store heatflow property"); + error->all(FLERR,"fix rheo/thermal command requires atom property heatflow"); + if (atom->conductivity_flag != 1) + error->all(FLERR,"fix rheo/thermal command requires atom property conductivity"); } /* ---------------------------------------------------------------------- */ @@ -181,34 +180,6 @@ void FixRHEOThermal::setup_pre_force(int /*vflag*/) { fix_rheo->thermal_fix_defined = 1; - // Identify whether this is the first/last instance of fix thermal - // First will grow arrays, last will communicate - first_flag = 0; - last_flag = 0; - - int i = 0; - auto fixlist = modify->get_fix_by_style("rheo/thermal"); - for (const auto &fix : fixlist) { - if (strcmp(fix->id, id) == 0) break; - i++; - } - - if (i == 0) first_flag = 1; - if ((i + 1) == fixlist.size()) last_flag = 1; - - // Create conductivity array if it doesn't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded - - int tmp1, tmp2; - int index = atom->find_custom("rheo_conductivity", tmp1, tmp2); - if (index== -1) { - index = atom->add_custom("rheo_conductivity", 1, 0); - nmax_store = atom->nmax; - } - conductivity = atom->dvector[index]; - post_neighbor(); pre_force(0); } @@ -294,14 +265,10 @@ void FixRHEOThermal::post_neighbor() int i; int *type = atom->type; int *mask = atom->mask; + double *conductivity = atom->conductivity; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - if (first_flag && (nmax_store < atom->nmax)) { - memory->grow(conductivity, atom->nmax, "atom:rheo_conductivity"); - nmax_store = atom->nmax; - } - if (conductivity_style == CONSTANT) { for (i = 0; i < nall; i++) if (mask[i] & groupbit) conductivity[i] = kappa; @@ -312,39 +279,11 @@ void FixRHEOThermal::post_neighbor() } /* ---------------------------------------------------------------------- - Update (and forward) evolving conductivity styles every timestep - Zero heat flow + In the future, update & forward evolving conductivity styles every timestep ------------------------------------------------------------------------- */ void FixRHEOThermal::pre_force(int /*vflag*/) { - // send updated temperatures to ghosts if first instance of fix - // then clear heatflow for next force calculation - double *heatflow = atom->heatflow; - if (first_flag) { - comm->forward_comm(this); - for (int i = 0; i < atom->nmax; i++) heatflow[i] = 0.0; - } - - // Not needed yet, when needed add stage check for (un)pack_forward_comm() methods - //int i; - //double *conductivity = atom->dvector[index_cond]; - //int *mask = atom->mask; - //int nlocal = atom->nlocal; - - //if (first_flag && (nmax_store < atom->nmax)) { - // memory->grow(conductivity, atom->nmax, "atom:rheo_conductivity"); - // nmax_store = atom->nmax; - //} - - //if (conductivity_style == TBD) { - // for (i = 0; i < nlocal; i++) { - // if (mask[i] & groupbit) { - // } - // } - //} - - //if (last_flag && comm_forward) comm->forward_comm(this); } /* ---------------------------------------------------------------------- */ @@ -387,69 +326,3 @@ double FixRHEOThermal::calc_cv(int i) return(cv_type[atom->type[i]]); } } - -/* ---------------------------------------------------------------------- */ - -int FixRHEOThermal::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) -{ - int i, j, m; - - double *temperature = atom->temperature; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = temperature[j]; - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOThermal::unpack_forward_comm(int n, int first, double *buf) -{ - int i, m, last; - - m = 0; - last = first + n; - - double *temperature = atom->temperature; - - for (i = first; i < last; i++) temperature[i] = buf[m++]; -} - -/* ---------------------------------------------------------------------- */ - -int FixRHEOThermal::pack_reverse_comm(int n, int first, double *buf) -{ - int m = 0; - int last = first + n; - double *heatflow = atom->heatflow; - - for (int i = first; i < last; i++) { - buf[m++] = heatflow[i]; - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOThermal::unpack_reverse_comm(int n, int *list, double *buf) -{ - int m = 0; - double *heatflow = atom->heatflow; - - for (int i = 0; i < n; i++) - heatflow[list[i]] += buf[m++]; -} - -/* ---------------------------------------------------------------------- */ - -double FixRHEOThermal::memory_usage() -{ - double bytes = 0.0; - bytes += (size_t) nmax_store * sizeof(double); - return bytes; -} diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index cf64c0b8d1..a27ad98a8c 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -37,29 +37,22 @@ class FixRHEOThermal : public Fix { void pre_force(int) override; void final_integrate() override; void reset_dt() override; - int pack_forward_comm(int, int *, double *, int, int *) override; - void unpack_forward_comm(int, int, double *) override; - int pack_reverse_comm(int, int, double *) override; - void unpack_reverse_comm(int, int *, double *) override; - double memory_usage() override; + double calc_cv(int); private: double *cv_type, cv; double *Tc_type, Tc; double *kappa_type, kappa; double dtf, dtv; - double *conductivity; int Tc_style; int cv_style; int conductivity_style; - int first_flag, last_flag; - int nmax_store; class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; class ComputeRHEOVShift *compute_vshift; - double calc_cv(int); + void grow_array(int); }; } // namespace LAMMPS_NS diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index b15f488370..4d70ffaca3 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -37,14 +37,13 @@ enum {NONE, CONSTANT, TYPE, POWER}; /* ---------------------------------------------------------------------- */ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), fix_rheo(nullptr), eta_type(nullptr), viscosity(nullptr), compute_grad(nullptr) + Fix(lmp, narg, arg), fix_rheo(nullptr), compute_grad(nullptr), eta_type(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); viscosity_style = NONE; comm_forward = 0; - nmax_store = 0; int ntypes = atom->ntypes; int iarg = 3; @@ -86,11 +85,6 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : FixRHEOViscosity::~FixRHEOViscosity() { - // Remove custom property if it exists - int tmp1, tmp2, index; - index = atom->find_custom("rheo_viscosity", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); - memory->destroy(eta_type); } @@ -121,9 +115,7 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) { fix_rheo->viscosity_fix_defined = 1; - // Identify whether this is the first/last instance of fix viscosity - // First will grow arrays, last will communicate - first_flag = 0; + // Identify whether this is the last instance of fix viscosity last_flag = 0; int i = 0; @@ -133,22 +125,8 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) i++; } - if (i == 0) first_flag = 1; if ((i + 1) == fixlist.size()) last_flag = 1; - // Create viscosity array if it doesn't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded - - int tmp1, tmp2; - int index = atom->find_custom("rheo_viscosity", tmp1, tmp2); - if (index == -1) { - index = atom->add_custom("rheo_viscosity", 1, 0); - nmax_store = atom->nmax; - } - viscosity = atom->dvector[index]; - post_neighbor(); pre_force(0); } @@ -163,14 +141,9 @@ void FixRHEOViscosity::post_neighbor() int *type = atom->type; int *mask = atom->mask; + double *viscosity = atom->viscosity; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - - if (first_flag && (nmax_store < atom->nmax)) { - memory->grow(viscosity, atom->nmax, "atom:rheo_viscosity"); - nmax_store = atom->nmax; - } + int nall = atom->nlocal + atom->nghost; if (viscosity_style == CONSTANT) { for (i = 0; i < nall; i++) @@ -191,16 +164,12 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) double tmp, gdot; int *mask = atom->mask; + double *viscosity = atom->viscosity; double **gradv = compute_grad->gradv; int nlocal = atom->nlocal; int dim = domain->dimension; - if (first_flag && (nmax_store < atom->nmax)) { - memory->grow(viscosity, atom->nmax, "atom:rheo_viscosity"); - nmax_store = atom->nmax; - } - if (viscosity_style == POWER) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { @@ -231,7 +200,8 @@ void FixRHEOViscosity::pre_force(int /*vflag*/) int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { - int i,j,k,m; + int i, j, k, m; + double *viscosity = atom->viscosity; m = 0; for (i = 0; i < n; i++) { @@ -246,6 +216,7 @@ int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf, void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; + double *viscosity = atom->viscosity; m = 0; last = first + n; @@ -253,12 +224,3 @@ void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) viscosity[i] = buf[m++]; } } - -/* ---------------------------------------------------------------------- */ - -double FixRHEOViscosity::memory_usage() -{ - double bytes = 0.0; - bytes += (size_t) nmax_store * sizeof(double); - return bytes; -} diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h index 66df51601e..c681d18c00 100644 --- a/src/RHEO/fix_rheo_viscosity.h +++ b/src/RHEO/fix_rheo_viscosity.h @@ -35,15 +35,11 @@ class FixRHEOViscosity : public Fix { void pre_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; - double memory_usage() override; private: double *eta_type, eta; double npow, K, gd0, tau0; - double *viscosity; - int viscosity_style; - int first_flag, last_flag; - int nmax_store; + int viscosity_style, last_flag; class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index c61d613d82..03e859316f 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -99,6 +99,9 @@ void PairRHEO::compute(int eflag, int vflag) double *rho = atom->rho; double *mass = atom->mass; double *drho = atom->drho; + double *pressure = atom->pressure; + double *viscosity = atom->viscosity; + double *conductivity = atom->conductivity; double *temperature = atom->temperature; double *heatflow = atom->heatflow; double *special_lj = force->special_lj; @@ -112,22 +115,6 @@ void PairRHEO::compute(int eflag, int vflag) chi = compute_interface->chi; } - int tmp1, tmp2; - int index = atom->find_custom("rheo_viscosity", tmp1, tmp2); - if (index == -1) error->all(FLERR, "Cannot find rheo viscosity"); - double *viscosity = atom->dvector[index]; - - index = atom->find_custom("rheo_pressure", tmp1, tmp2); - if (index == -1) error->all(FLERR, "Cannot find rheo pressure"); - double *pressure = atom->dvector[index]; - - double *conductivity; - if (thermal_flag) { - index = atom->find_custom("rheo_conductivity", tmp1, tmp2); - if (index == -1) error->all(FLERR, "Cannot find rheo conductivity"); - conductivity = atom->dvector[index]; - } - inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; diff --git a/src/atom.cpp b/src/atom.cpp index 25023e0d49..cf8cb7468a 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -200,6 +200,9 @@ Atom::Atom(LAMMPS *_lmp) : Pointers(_lmp) // RHEO package status = nullptr; + conductivity = nullptr; + pressure = nullptr; + viscosity = nullptr; // SPH package @@ -533,6 +536,9 @@ void Atom::peratom_create() // RHEO package add_peratom("status",&status,INT,0); + add_peratom("conductivity",&conductivity,DOUBLE,0); + add_peratom("pressure",&pressure,DOUBLE,0); + add_peratom("viscosity",&viscosity,DOUBLE,0); // SPH package @@ -639,7 +645,7 @@ void Atom::set_atomflag_defaults() temperature_flag = heatflow_flag = 0; vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; cs_flag = csforce_flag = vforce_flag = ervelforce_flag = etag_flag = 0; - status_flag = 0; + status_flag = conductivity_flag = pressure_flag = viscosity_flag = 0; rho_flag = esph_flag = cv_flag = vest_flag = 0; dpd_flag = edpd_flag = tdpd_flag = 0; sp_flag = 0; @@ -2943,6 +2949,9 @@ void *Atom::extract(const char *name) // RHEO package if (strcmp(name,"status") == 0) return (void *) status; + if (strcmp(name,"conductivity") == 0) return (void *) conductivity; + if (strcmp(name,"pressure") == 0) return (void *) pressure; + if (strcmp(name,"viscosity") == 0) return (void *) viscosity; // SPH package @@ -3069,6 +3078,9 @@ int Atom::extract_datatype(const char *name) // RHEO package if (strcmp(name,"status") == 0) return LAMMPS_INT; + if (strcmp(name,"conductivity") == 0) return LAMMPS_DOUBLE; + if (strcmp(name,"pressure") == 0) return LAMMPS_DOUBLE; + if (strcmp(name,"viscosity") == 0) return LAMMPS_DOUBLE; // SPH package diff --git a/src/atom.h b/src/atom.h index 51665cb0bf..a8ced43b4d 100644 --- a/src/atom.h +++ b/src/atom.h @@ -158,6 +158,9 @@ class Atom : protected Pointers { // RHEO package int *status; + double *conductivity; + double *pressure; + double *viscosity; // SPH package @@ -194,7 +197,7 @@ class Atom : protected Pointers { int temperature_flag, heatflow_flag; int vfrac_flag, spin_flag, eradius_flag, ervel_flag, erforce_flag; int cs_flag, csforce_flag, vforce_flag, ervelforce_flag, etag_flag; - int status_flag; + int status_flag, conductivity_flag, pressure_flag, viscosity_flag; int rho_flag, esph_flag, cv_flag, vest_flag; int dpd_flag, edpd_flag, tdpd_flag; int mesont_flag; diff --git a/src/atom_vec_rheo_thermal.cpp b/src/atom_vec_rheo_thermal.cpp new file mode 100644 index 0000000000..de0c7fa5d7 --- /dev/null +++ b/src/atom_vec_rheo_thermal.cpp @@ -0,0 +1,200 @@ +/* ---------------------------------------------------------------------- + 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 authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + +#include "atom_vec_rheo_thermal.h" + +#include "atom.h" + +#include + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +AtomVecRHEOThermal::AtomVecRHEOThermal(LAMMPS *lmp) : AtomVec(lmp) +{ + molecular = Atom::ATOMIC; + mass_type = PER_TYPE; + forceclearflag = 1; + + atom->status_flag = 1; + atom->conductivity_flag = 1; + atom->temperature_flag = 1; + atom->heatflow_flag = 1; + atom->pressure_flag = 1; + atom->rho_flag = 1; + atom->viscosity_flag = 1; + + // strings with peratom variables to include in each AtomVec method + // strings cannot contain fields in corresponding AtomVec default strings + // order of fields in a string does not matter + // except: fields_data_atom & fields_data_vel must match data file + + fields_grow = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_copy = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_comm = {"status", "rho", "temperature"}; + fields_comm_vel = {"status", "rho", "temperature"}; + fields_reverse = {"drho", "heatflow"}; + fields_border = {"status", "rho", "temperature"}; + fields_border_vel = {"status", "rho", "temperature"}; + fields_exchange = {"status", "rho", "temperature"}; + fields_restart = {"status", "rho", "temperature"}; + fields_create = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_data_atom = {"id", "type", "status", "rho", "temperature", "x"}; + fields_data_vel = {"id", "v"}; + + setup_fields(); +} + +/* ---------------------------------------------------------------------- + set local copies of all grow ptrs used by this class, except defaults + needed in replicate when 2 atom classes exist and it calls pack_restart() +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::grow_pointers() +{ + status = atom->status; + conductivity = atom->conductivity; + temperature = atom->temperature; + heatflow = atom->heatflow; + pressure = atom->pressure; + rho = atom->rho; + drho = atom->drho; + viscosity = atom->viscosity; +} + +/* ---------------------------------------------------------------------- + clear extra forces starting at atom N + nbytes = # of bytes to clear for a per-atom vector +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::force_clear(int n, size_t nbytes) +{ + memset(&drho[n], 0, nbytes); + memset(&heatflow[n], 0, nbytes); +} + +/* ---------------------------------------------------------------------- + modify what AtomVec::data_atom() just unpacked + or initialize other atom quantities +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::data_atom_post(int ilocal) +{ + drho[ilocal] = 0.0; + heatflow[ilocal] = 0.0; + pressure[ilocal] = 0.0; + viscosity[ilocal] = 0.0; + conductivity[ilocal] = 0.0; +} + +/* ---------------------------------------------------------------------- + assign an index to named atom property and return index + return -1 if name is unknown to this atom style +------------------------------------------------------------------------- */ + +int AtomVecRHEOThermal::property_atom(const std::string &name) +{ + if (name == "status") return 0; + if (name == "rho") return 1; + if (name == "drho") return 2; + if (name == "temperature") return 3; + if (name == "heatflow") return 4; + if (name == "conductivity") return 5; + if (name == "pressure") return 6; + if (name == "viscosity") return 7; + return -1; +} + +/* ---------------------------------------------------------------------- + pack per-atom data into buf for ComputePropertyAtom + index maps to data specific to this atom style +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::pack_property_atom(int index, double *buf, int nvalues, int groupbit) +{ + int *mask = atom->mask; + int nlocal = atom->nlocal; + int n = 0; + + if (index == 0) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = status[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 1) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = rho[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 2) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = drho[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 3) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = temperature[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 4) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = heatflow[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 5) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = conductivity[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 6) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = pressure[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 7) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = viscosity[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } +} diff --git a/src/atom_vec_rheo_thermal.h b/src/atom_vec_rheo_thermal.h new file mode 100644 index 0000000000..27c6c3c9b5 --- /dev/null +++ b/src/atom_vec_rheo_thermal.h @@ -0,0 +1,46 @@ +/* -*- 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 ATOM_CLASS +// clang-format off +AtomStyle(rheo/thermal,AtomVecRHEOThermal); +// clang-format on +#else + +#ifndef LMP_ATOM_VEC_RHEO_THERMAL_H +#define LMP_ATOM_VEC_RHEO_THERMAL_H + +#include "atom_vec.h" + +namespace LAMMPS_NS { + +class AtomVecRHEOThermal : virtual public AtomVec { + public: + AtomVecRHEOThermal(class LAMMPS *); + + void grow_pointers() override; + void force_clear(int, size_t) override; + void data_atom_post(int) override; + int property_atom(const std::string &) override; + void pack_property_atom(int, double *, int, int) override; + + private: + int *status; + double *conductivity, *temperature, *heatflow; + double *pressure, *rho, *drho, *viscosity; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/compute_rheo_property_atom.cpp b/src/compute_rheo_property_atom.cpp new file mode 100644 index 0000000000..7682552abe --- /dev/null +++ b/src/compute_rheo_property_atom.cpp @@ -0,0 +1,411 @@ +// 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 authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + +#include "compute_rheo_property_atom.h" + +#include "atom.h" +#include "atom_vec.h" +#include "compute_rheo_interface.h" +#include "compute_rheo_kernel.h" +#include "compute_rheo_surface.h" +#include "compute_rheo_vshift.h" +#include "error.h" +#include "fix_rheo.h" +#include "fix_rheo_thermal.h" +#include "memory.h" +#include "modify.h" +#include "update.h" + +#include +#include + +using namespace LAMMPS_NS; +using namespace RHEO_NS; + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), fix_rheo(nullptr), fix_thermal(nullptr), compute_interface(nullptr), + compute_kernel(nullptr), compute_surface(nullptr), compute_vshift(nullptr), + index(nullptr), pack_choice(nullptr) +{ + if (narg < 4) utils::missing_cmd_args(FLERR, "compute property/atom", error); + + peratom_flag = 1; + nvalues = narg - 3; + if (nvalues == 1) size_peratom_cols = 0; + else size_peratom_cols = nvalues; + + thermal_flag, interface_flag, surface_flag, shift_flag = 0; + + // parse input values + // customize a new keyword by adding to if statement + + pack_choice = new FnPtrPack[nvalues]; + index = new int[nvalues]; + + int i; + for (int iarg = 3; iarg < narg; iarg++) { + i = iarg-3; + + if (strcmp(arg[iarg],"phase") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_phase; + } else if (strcmp(arg[iarg],"chi") == 0) { + interface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_chi; + } else if (strcmp(arg[iarg],"surface") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface; + } else if (strcmp(arg[iarg],"surface/r") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_r; + } else if (strcmp(arg[iarg],"surface/divr") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_divr; + } else if (strcmp(arg[iarg],"surface/nx") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_nx; + } else if (strcmp(arg[iarg],"surface/ny") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_ny; + } else if (strcmp(arg[iarg],"surface/nz") == 0) { + surface_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_nz; + } else if (strcmp(arg[iarg],"coordination") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_coordination; + } else if (strcmp(arg[iarg],"cv") == 0) { + thermal_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; + } else if (strcmp(arg[iarg],"shift/vx") == 0) { + shift_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vx; + } else if (strcmp(arg[iarg],"shift/vy") == 0) { + shift_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vy; + } else if (strcmp(arg[iarg],"shift/vz") == 0) { + shift_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vz; + } else { + index[i] = atom->avec->property_atom(arg[iarg]); + if (index[i] < 0) + error->all(FLERR, + "Invalid keyword {} for atom style {} in compute rheo/property/atom command ", + atom->get_style(), arg[iarg]); + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_atom_style; + + if (strcmp(arg[iarg],"temperature") == 0) thermal_flag = 1; + if (strcmp(arg[iarg],"heatflow") == 0) thermal_flag = 1; + if (strcmp(arg[iarg],"conductivity") == 0) thermal_flag = 1; + } + } + + nmax = 0; +} + +/* ---------------------------------------------------------------------- */ + +ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() +{ + delete[] pack_choice; + delete[] index; + memory->destroy(vector_atom); + memory->destroy(array_atom); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::init() +{ + auto fixes = modify->get_fix_by_style("rheo"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); + fix_rheo = dynamic_cast(fixes[0]); + + if (interface_flag && !(fix_rheo->interface_flag)) + error->all(FLERR, "Cannot request interfacial property without corresponding option in fix rheo"); + if (surface_flag && !(fix_rheo->surface_flag)) + error->all(FLERR, "Cannot request surface property without corresponding option in fix rheo"); + if (shift_flag && !(fix_rheo->shift_flag)) + error->all(FLERR, "Cannot request velocity shifting property without corresponding option in fix rheo"); + if (thermal_flag && !(fix_rheo->thermal_flag)) + error->all(FLERR, "Cannot request thermal property without fix rheo/thermal"); + + compute_interface = fix_rheo->compute_interface; + compute_kernel = fix_rheo->compute_kernel; + compute_surface = fix_rheo->compute_surface; + compute_vshift = fix_rheo->compute_vshift; + + if (thermal_flag) { + fixes = modify->get_fix_by_style("rheo/thermal"); + fix_thermal = dynamic_cast(fixes[0]); + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::compute_peratom() +{ + invoked_peratom = update->ntimestep; + + // grow vector or array if necessary + + if (atom->nmax > nmax) { + nmax = atom->nmax; + if (nvalues == 1) { + memory->destroy(vector_atom); + memory->create(vector_atom,nmax,"rheo/property/atom:vector"); + } else { + memory->destroy(array_atom); + memory->create(array_atom,nmax,nvalues,"rheo/property/atom:array"); + } + } + + // fill vector or array with per-atom values + + if (nvalues == 1) { + buf = vector_atom; + (this->*pack_choice[0])(0); + } else { + if (nmax) buf = &array_atom[0][0]; + else buf = nullptr; + for (int n = 0; n < nvalues; n++) + (this->*pack_choice[n])(n); + } +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based array +------------------------------------------------------------------------- */ + +double ComputeRHEOPropertyAtom::memory_usage() +{ + double bytes = (double)nmax * nvalues * sizeof(double); + return bytes; +} + +/* ---------------------------------------------------------------------- + one method for every keyword compute rheo/property/atom can output + the atom property is packed into buf starting at n with stride nvalues + customize a new keyword by adding a method +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_phase(int n) +{ + int *status = atom->status; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + int inverse_mask = ~PHASEMASK; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = (status[i] & inverse_mask); + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_chi(int n) +{ + double *chi = compute_interface->chi; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = chi[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface(int n) +{ + int *status = atom->status; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + int inverse_mask = ~SURFACEMASK; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = (status[i] & inverse_mask); + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_r(int n) +{ + double *rsurface = compute_surface->rsurface; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = rsurface[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_divr(int n) +{ + double *divr = compute_surface->divr; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = divr[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_nx(int n) +{ + double **nsurface = compute_surface->nsurface; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = nsurface[i][0]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_ny(int n) +{ + double **nsurface = compute_surface->nsurface; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = nsurface[i][1]; + else buf[n] = 0.0; + n += nvalues; + } +} + + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_surface_nz(int n) +{ + double **nsurface = compute_surface->nsurface; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = nsurface[i][2]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_coordination(int n) +{ + int *coordination = compute_kernel->coordination; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = coordination[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_cv(int n) +{ + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = fix_thermal->calc_cv(i); + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_shift_vx(int n) +{ + double **vshift = compute_vshift->vshift; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = vshift[i][0]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_shift_vy(int n) +{ + double **vshift = compute_vshift->vshift; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = vshift[i][1]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_shift_vz(int n) +{ + double **vshift = compute_vshift->vshift; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = vshift[i][2]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_atom_style(int n) +{ + atom->avec->pack_property_atom(index[n],&buf[n],nvalues,groupbit); +} diff --git a/src/compute_rheo_property_atom.h b/src/compute_rheo_property_atom.h new file mode 100644 index 0000000000..accb7e9156 --- /dev/null +++ b/src/compute_rheo_property_atom.h @@ -0,0 +1,71 @@ +/* -*- 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 COMPUTE_CLASS +// clang-format off +ComputeStyle(rheo/property/atom,ComputeRHEOPropertyAtom); +// clang-format on +#else + +#ifndef LMP_COMPUTE_RHEO_PROPERTY_ATOM_H +#define LMP_COMPUTE_RHEO_PROPERTY_ATOM_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeRHEOPropertyAtom : public Compute { + public: + ComputeRHEOPropertyAtom(class LAMMPS *, int, char **); + ~ComputeRHEOPropertyAtom() override; + void init() override; + void compute_peratom() override; + double memory_usage() override; + + private: + int nvalues, nmax; + int thermal_flag, interface_flag, surface_flag, shift_flag; + int *index; + double *buf; + + typedef void (ComputeRHEOPropertyAtom::*FnPtrPack)(int); + FnPtrPack *pack_choice; // ptrs to pack functions + + void pack_phase(int); + void pack_chi(int); + void pack_surface(int); + void pack_surface_r(int); + void pack_surface_divr(int); + void pack_surface_nx(int); + void pack_surface_ny(int); + void pack_surface_nz(int); + void pack_coordination(int); + void pack_cv(int); + void pack_shift_vx(int); + void pack_shift_vy(int); + void pack_shift_vz(int); + void pack_atom_style(int); + + class FixRHEO *fix_rheo; + class FixRHEOThermal *fix_thermal; + class ComputeRHEOInterface *compute_interface; + class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOSurface *compute_surface; + class ComputeRHEOVShift *compute_vshift; + +}; + +} // namespace LAMMPS_NS + +#endif +#endif From 0cd3bd190f9b97507ce953ff6ecdf49283db3c32 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 26 Apr 2023 12:14:40 -0600 Subject: [PATCH 031/104] Fixing various memory issues --- .../rheo/poiseuille/in.rheo.poiseuille | 83 +++++++++++++++++++ src/RHEO/compute_rheo_kernel.cpp | 46 +++++----- src/RHEO/compute_rheo_property_atom.cpp | 4 +- src/RHEO/fix_rheo.cpp | 4 +- src/RHEO/fix_rheo_pressure.cpp | 4 +- src/RHEO/fix_rheo_pressure.h | 1 - src/RHEO/fix_rheo_thermal.cpp | 2 +- src/RHEO/fix_rheo_viscosity.cpp | 2 +- src/RHEO/pair_rheo.cpp | 11 ++- src/compute_rheo_property_atom.cpp | 4 +- 10 files changed, 127 insertions(+), 34 deletions(-) create mode 100644 examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille diff --git a/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille b/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille new file mode 100644 index 0000000000..af5728c1a3 --- /dev/null +++ b/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille @@ -0,0 +1,83 @@ +dimension 2 +units lj +atom_style rheo +boundary p p p +comm_modify vel yes + + +# ------ Particle Lattice/Resolution Parameters ------ # + +variable L equal 10 +variable sf equal 0.2 +variable n equal 1.0/(${sf}^2) +variable cut equal 3.5*${sf} + + +# ------ Create simulation box ------ # + +region box block 0 20 -10 10 -0.01 0.01 units box +create_box 2 box +lattice sq ${n} + +region topwall block INF INF 7 10 INF INF units box +region block block INF INF -6.99 6.99 INF INF units box +region botwall block INF INF -10 -7 INF INF units box + +create_atoms 2 region topwall +create_atoms 2 region botwall +create_atoms 1 region block + +group fluid type 1 +group rig type 2 + +variable dr equal 0.1*${sf} +displace_atoms fluid random $(0.1*v_sf) ${dr} 0 135414 units box + + +# ------ Model parameters ------ # + +variable rho0 equal 1.0 +variable cs equal 1.0 +variable mp equal ${rho0}/${n} +variable zeta equal 1.0 +variable kappa equal 1.0*${rho0}/${mp} +variable fext equal 1e-3/${n} +variable eta equal 0.1 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable Dr equal 0.05*${cut}*${cs} + +mass 1 ${mp} +mass 2 ${mp} +set group all rheo/rho ${rho0} +set group all rheo/status 0 +set group rig rheo/status 2 +timestep ${dt_max} + +pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} +pair_coeff * * + + +# ------ Fixes & computes ------ # + +fix 1 all rheo ${cut} Quintic 0 shift +fix 2 all rheo/viscosity constant ${eta} +fix 3 all rheo/pressure linear +fix 4 rig setforce 0.0 0.0 0.0 +fix 5 fluid addforce ${fext} 0.0 0.0 + +compute 1 all rheo/property/atom rho phase + + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time temp press + +variable skin equal 0.2*${cut} +neighbor ${skin} bin +neigh_modify one 5000 + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_1[*] + +run 20000 + diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 9cfa86df7e..205ae6fb72 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -103,10 +103,6 @@ void ComputeRHEOKernel::init() { neighbor->add_request(this, NeighConst::REQ_FULL); - auto fixes = modify->get_fix_by_style("rheo"); - if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use compute rheo/kernel"); - fix_rheo = dynamic_cast(fixes[0]); - interface_flag = fix_rheo->interface_flag; compute_interface = fix_rheo->compute_interface; @@ -147,17 +143,16 @@ void ComputeRHEOKernel::init_list(int /*id*/, NeighList *ptr) int ComputeRHEOKernel::check_corrections(int i) { - int corrections = 1; - - if (gsl_error_flag) { - // If there were errors, check to see if it occured for this atom + // Skip if there were gsl errors for this atom + if (gsl_error_flag) if (gsl_error_tags.find(atom->tag[i]) != gsl_error_tags.end()) - corrections = 0; - } + return 0; - if (coordination[i] < zmin) corrections = 0; + // Skip if undercoordinated + if (coordination[i] < zmin) + return 0; - return corrections; + return 1; } /* ---------------------------------------------------------------------- */ @@ -165,12 +160,17 @@ int ComputeRHEOKernel::check_corrections(int i) double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double delz, double r) { double w; + int corrections_i, corrections_j, corrections; - int corrections_i = check_corrections(i); - int corrections_j = check_corrections(j); - int corrections = corrections_i & corrections_j; + if (kernel_style != QUINTIC) { + corrections_i = check_corrections(i); + corrections_j = check_corrections(j); + corrections = corrections_i & corrections_j; + } else { + corrections = 0; + } - if (kernel_style == QUINTIC || !corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); + if (!corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); else if (kernel_style == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); else if (kernel_style == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); else if (kernel_style == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); @@ -183,17 +183,21 @@ double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double delz, double r) { double wp; + int corrections_i, corrections_j; - int corrections_i = check_corrections(i); - int corrections_j = check_corrections(j); + if (kernel_style != QUINTIC) { + corrections_i = check_corrections(i); + corrections_j = check_corrections(j); + } // Calc wp and default dW's, a bit inefficient but can redo later wp = calc_dw_quintic(i,j,delx,dely,delz,r,dWij,dWji); - if(kernel_style == CRK1) { - //check if kernel correction calculated successfully. If not, revert to quintic + + // Overwrite if there are corrections + if (kernel_style == CRK1) { if (corrections_i) calc_dw_crk1(i,j,delx,dely,delz,r,dWij); if (corrections_j) calc_dw_crk1(j,i,-delx,-dely,-delz,r,dWji); - } else if(kernel_style == CRK2) { + } else if (kernel_style == CRK2) { if (corrections_i) calc_dw_crk2(i,j,delx,dely,delz,r,dWij); if (corrections_j) calc_dw_crk2(j,i,-delx,-dely,-delz,r,dWji); } diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 7682552abe..3cd5d468b2 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -52,7 +52,7 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (nvalues == 1) size_peratom_cols = 0; else size_peratom_cols = nvalues; - thermal_flag, interface_flag, surface_flag, shift_flag = 0; + thermal_flag = interface_flag = surface_flag = shift_flag = 0; // parse input values // customize a new keyword by adding to if statement @@ -132,7 +132,7 @@ ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() void ComputeRHEOPropertyAtom::init() { - auto fixes = modify->get_fix_by_style("rheo"); + auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); fix_rheo = dynamic_cast(fixes[0]); diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index ac870affd5..48eece239a 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -195,7 +195,7 @@ void FixRHEO::init() dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; - if (modify->get_fix_by_style("rheo").size() > 1) + if (modify->get_fix_by_style("^rheo$").size() > 1) error->all(FLERR,"Can only specify one instance of fix rheo"); } @@ -258,6 +258,8 @@ void FixRHEO::setup(int /*vflag*/) error->one(FLERR, "Fix rheo/viscosity does not fully cover all atoms"); if (!t_coverage_flag) error->one(FLERR, "Fix rheo/thermal does not fully cover all atoms"); + + pre_force(0); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 45557794cd..63a6995646 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -92,7 +92,7 @@ int FixRHEOPressure::setmask() void FixRHEOPressure::init() { - auto fixes = modify->get_fix_by_style("rheo"); + auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/pressure"); fix_rheo = dynamic_cast(fixes[0]); @@ -161,7 +161,7 @@ void FixRHEOPressure::pre_force(int /*vflag*/) } } - if (last_flag && comm_forward) comm->forward_comm(this); + if (comm_forward) comm->forward_comm(this); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h index c257f1dbfb..e8f7f3cb88 100644 --- a/src/RHEO/fix_rheo_pressure.h +++ b/src/RHEO/fix_rheo_pressure.h @@ -41,7 +41,6 @@ class FixRHEOPressure : public Fix { double c_cubic, csq, rho0, rho0inv; double *pressure; int pressure_style; - int first_flag, last_flag; int nmax_store; class FixRHEO *fix_rheo; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 0d8909b908..bd7a22ce1e 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -155,7 +155,7 @@ int FixRHEOThermal::setmask() void FixRHEOThermal::init() { - auto fixes = modify->get_fix_by_style("rheo"); + auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); fix_rheo = dynamic_cast(fixes[0]); diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 4d70ffaca3..7d915c9b93 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -102,7 +102,7 @@ int FixRHEOViscosity::setmask() void FixRHEOViscosity::init() { - auto fixes = modify->get_fix_by_style("rheo"); + auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); fix_rheo = dynamic_cast(fixes[0]); diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 03e859316f..8e76a6d413 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -356,7 +356,9 @@ void PairRHEO::settings(int narg, char **arg) { if (narg < 1) error->all(FLERR,"Illegal pair_style command"); - int iarg = 0; + h = utils::numeric(FLERR,arg[0],false,lmp); +printf("settings\n"); + int iarg = 1; while (iarg < narg) { if (strcmp(arg[iarg], "rho/damp") == 0) { if (iarg + 1 >= narg) error->all(FLERR,"Illegal pair_style command"); @@ -419,10 +421,13 @@ void PairRHEO::setup() compute_grad = fix_rheo->compute_grad; compute_interface = fix_rheo->compute_interface; thermal_flag = fix_rheo->thermal_flag; - h = fix_rheo->h; csq = fix_rheo->csq; rho0 = fix_rheo->rho0; +printf("setup\n"); + if (h != fix_rheo->h) + error->all(FLERR, "Pair rheo cutoff {} does not agree with fix rheo cutoff {}", h, fix_rheo->h); + hsq = h * h; hinv = 1.0 / h; hinv3 = hinv * 3.0; cs = sqrt(csq); @@ -450,6 +455,6 @@ double PairRHEO::init_one(int i, int j) if (setflag[i][j] == 0) { error->all(FLERR,"All pair rheo coeffs are not set"); } - +printf("init one\n"); return h; } diff --git a/src/compute_rheo_property_atom.cpp b/src/compute_rheo_property_atom.cpp index 7682552abe..3cd5d468b2 100644 --- a/src/compute_rheo_property_atom.cpp +++ b/src/compute_rheo_property_atom.cpp @@ -52,7 +52,7 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (nvalues == 1) size_peratom_cols = 0; else size_peratom_cols = nvalues; - thermal_flag, interface_flag, surface_flag, shift_flag = 0; + thermal_flag = interface_flag = surface_flag = shift_flag = 0; // parse input values // customize a new keyword by adding to if statement @@ -132,7 +132,7 @@ ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() void ComputeRHEOPropertyAtom::init() { - auto fixes = modify->get_fix_by_style("rheo"); + auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); fix_rheo = dynamic_cast(fixes[0]); From 0cd22dd0d2d6c309e75e99470e5035e78a98d098 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 27 Apr 2023 21:04:04 -0600 Subject: [PATCH 032/104] Creating doc pages and links for rheo --- doc/src/Howto.rst | 1 + doc/src/Howto_rheo.rst | 3 + doc/src/atom_style.rst | 114 +++++++++++++++++---------------- doc/src/compute.rst | 1 + doc/src/fix.rst | 4 ++ doc/src/fix_rheo.rst | 59 +++++++++++++++++ doc/src/fix_rheo_pressure.rst | 59 +++++++++++++++++ doc/src/fix_rheo_thermal.rst | 59 +++++++++++++++++ doc/src/fix_rheo_viscosity.rst | 59 +++++++++++++++++ doc/src/pair_rheo.rst | 86 +++++++++++++++++++++++++ doc/src/read_data.rst | 4 ++ doc/src/set.rst | 6 ++ 12 files changed, 400 insertions(+), 55 deletions(-) create mode 100644 doc/src/Howto_rheo.rst create mode 100644 doc/src/fix_rheo.rst create mode 100644 doc/src/fix_rheo_pressure.rst create mode 100644 doc/src/fix_rheo_thermal.rst create mode 100644 doc/src/fix_rheo_viscosity.rst create mode 100644 doc/src/pair_rheo.rst diff --git a/doc/src/Howto.rst b/doc/src/Howto.rst index 1366ecb839..94a465e6fd 100644 --- a/doc/src/Howto.rst +++ b/doc/src/Howto.rst @@ -89,6 +89,7 @@ Packages howto Howto_drude2 Howto_peri Howto_manifold + Howto_rheo Howto_spins Tutorials howto diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst new file mode 100644 index 0000000000..9dac90549c --- /dev/null +++ b/doc/src/Howto_rheo.rst @@ -0,0 +1,3 @@ +Reproducing hydrodynamics and elastic objects (RHEO) +====================== + diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index b5ee0f07ff..98d465a6f3 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -78,61 +78,65 @@ coordinates, velocities, atom IDs and types. See the :doc:`set ` commands for info on how to set these various quantities. -+--------------+-----------------------------------------------------+--------------------------------------+ -| *amoeba* | molecular + charge + 1/5 neighbors | AMOEBA/HIPPO polarized force fields | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *angle* | bonds and angles | bead-spring polymers with stiffness | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *atomic* | only the default values | coarse-grain liquids, solids, metals | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *body* | mass, inertia moments, quaternion, angular momentum | arbitrary bodies | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *bond* | bonds | bead-spring polymers | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *charge* | charge | atomic system with charges | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *dielectric* | normx normy normz area/patch ed em epsilon curv | system with surface polarization | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *dipole* | charge and dipole moment | system with dipolar particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *dpd* | internal temperature and internal energies | DPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *edpd* | temperature and heat capacity | eDPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *electron* | charge and spin and eradius | electronic force field | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *ellipsoid* | shape, quaternion, angular momentum | aspherical particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *full* | molecular + charge | bio-molecules | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *line* | end points, angular velocity | rigid bodies | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *mdpd* | density | mDPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *molecular* | bonds, angles, dihedrals, impropers | uncharged molecules | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *oxdna* | nucleotide polarity | coarse-grained DNA and RNA models | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *peri* | mass, volume | mesoscopic Peridynamic models | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *smd* | volume, kernel diameter, contact radius, mass | solid and fluid SPH particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *sph* | rho, esph, cv | SPH particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *sphere* | diameter, mass, angular velocity | granular models | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *bpm/sphere* | diameter, mass, angular velocity, quaternion | granular bonded particle models (BPM)| -+--------------+-----------------------------------------------------+--------------------------------------+ -| *spin* | magnetic moment | system with magnetic particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *tdpd* | chemical concentration | tDPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *template* | template index, template atom | small molecules with fixed topology | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *tri* | corner points, angular momentum | rigid bodies | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *wavepacket* | charge, spin, eradius, etag, cs_re, cs_im | AWPMD | -+--------------+-----------------------------------------------------+--------------------------------------+ ++----------------+-----------------------------------------------------+--------------------------------------+ +| *amoeba* | molecular + charge + 1/5 neighbors | AMOEBA/HIPPO polarized force fields | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *angle* | bonds and angles | bead-spring polymers with stiffness | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *atomic* | only the default values | coarse-grain liquids, solids, metals | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *body* | mass, inertia moments, quaternion, angular momentum | arbitrary bodies | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *bond* | bonds | bead-spring polymers | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *charge* | charge | atomic system with charges | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *dielectric* | normx normy normz area/patch ed em epsilon curv | system with surface polarization | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *dipole* | charge and dipole moment | system with dipolar particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *dpd* | internal temperature and internal energies | DPD particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *edpd* | temperature and heat capacity | eDPD particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *electron* | charge and spin and eradius | electronic force field | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *ellipsoid* | shape, quaternion, angular momentum | aspherical particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *full* | molecular + charge | bio-molecules | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *line* | end points, angular velocity | rigid bodies | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *mdpd* | density | mDPD particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *molecular* | bonds, angles, dihedrals, impropers | uncharged molecules | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *oxdna* | nucleotide polarity | coarse-grained DNA and RNA models | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *peri* | mass, volume | mesoscopic Peridynamic models | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *rheo* | rho, status | solid and fluid RHEO particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *rheo/thermal* | rho, status, temperature | RHEO particles with temperature | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *smd* | volume, kernel diameter, contact radius, mass | solid and fluid SPH particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *sph* | rho, esph, cv | SPH particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *sphere* | diameter, mass, angular velocity | granular models | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *bpm/sphere* | diameter, mass, angular velocity, quaternion | granular bonded particle models (BPM)| ++----------------+-----------------------------------------------------+--------------------------------------+ +| *spin* | magnetic moment | system with magnetic particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *tdpd* | chemical concentration | tDPD particles | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *template* | template index, template atom | small molecules with fixed topology | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *tri* | corner points, angular momentum | rigid bodies | ++----------------+-----------------------------------------------------+--------------------------------------+ +| *wavepacket* | charge, spin, eradius, etag, cs_re, cs_im | AWPMD | ++----------------+-----------------------------------------------------+--------------------------------------+ .. note:: diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 880f60a8a6..5e90d78e83 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -271,6 +271,7 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`reduce ` - combine per-atom quantities into a single global value * :doc:`reduce/chunk ` - reduce per-atom quantities within each chunk * :doc:`reduce/region ` - same as compute reduce, within a region +* :doc:`rheo/property/atom ` - convert atom attributes in RHEO package to per-atom vectors/arrays * :doc:`rigid/local ` - extract rigid body attributes * :doc:`saed ` - electron diffraction intensity on a mesh of reciprocal lattice nodes * :doc:`slice ` - extract values from global vector or array diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 56c7cde464..8ab202ab38 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -353,6 +353,10 @@ accelerated styles exist. * :doc:`reaxff/species ` - write out ReaxFF molecule information * :doc:`recenter ` - constrain the center-of-mass position of a group of atoms * :doc:`restrain ` - constrain a bond, angle, dihedral +* :doc:`rheo ` - integrator for the RHEO package +* :doc:`rheo/thermal ` - thermal integrator for the RHEO package +* :doc:`rheo/pressure ` - pressure derivation for the RHEO package +* :doc:`rheo/viscosity ` - viscosity derivation for the RHEO package * :doc:`rhok ` - add bias potential for long-range ordered systems * :doc:`rigid ` - constrain one or more clusters of atoms to move as a rigid body with NVE integration * :doc:`rigid/meso ` - constrain clusters of mesoscopic SPH/SDPD particles to move as a rigid body diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst new file mode 100644 index 0000000000..7200d456dd --- /dev/null +++ b/doc/src/fix_rheo.rst @@ -0,0 +1,59 @@ +.. index:: fix rheo + +fix rheo command +=============== + +Syntax +"""""" + +.. parsed-literal:: + + fix ID group-ID rheo + +* ID, group-ID are documented in :doc:`fix ` command +* rheo = style name of this fix command + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all rheo 1.0 CRK1 shift + +Description +""""""""""" + +Perform time integration to update position, velocity, internal energy +and local density for atoms in the group each timestep. This fix is +needed to time-integrate SPH systems where particles carry internal +variables such as internal energy. SPH stands for Smoothed Particle +Hydrodynamics. + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +are relevant to this fix. No global or per-atom quantities are stored +by this fix for access by various :doc:`output commands `. +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 fix is part of the RHEO 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 rheo/viscosity `, +:doc:`fix rheo/pressure `, +:doc:`fix rheo/thermal `, +:doc:`pair rheo `, +:doc:`compute rheo/property/atom ` + +Default +""""""" + +none diff --git a/doc/src/fix_rheo_pressure.rst b/doc/src/fix_rheo_pressure.rst new file mode 100644 index 0000000000..7200d456dd --- /dev/null +++ b/doc/src/fix_rheo_pressure.rst @@ -0,0 +1,59 @@ +.. index:: fix rheo + +fix rheo command +=============== + +Syntax +"""""" + +.. parsed-literal:: + + fix ID group-ID rheo + +* ID, group-ID are documented in :doc:`fix ` command +* rheo = style name of this fix command + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all rheo 1.0 CRK1 shift + +Description +""""""""""" + +Perform time integration to update position, velocity, internal energy +and local density for atoms in the group each timestep. This fix is +needed to time-integrate SPH systems where particles carry internal +variables such as internal energy. SPH stands for Smoothed Particle +Hydrodynamics. + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +are relevant to this fix. No global or per-atom quantities are stored +by this fix for access by various :doc:`output commands `. +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 fix is part of the RHEO 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 rheo/viscosity `, +:doc:`fix rheo/pressure `, +:doc:`fix rheo/thermal `, +:doc:`pair rheo `, +:doc:`compute rheo/property/atom ` + +Default +""""""" + +none diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst new file mode 100644 index 0000000000..7200d456dd --- /dev/null +++ b/doc/src/fix_rheo_thermal.rst @@ -0,0 +1,59 @@ +.. index:: fix rheo + +fix rheo command +=============== + +Syntax +"""""" + +.. parsed-literal:: + + fix ID group-ID rheo + +* ID, group-ID are documented in :doc:`fix ` command +* rheo = style name of this fix command + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all rheo 1.0 CRK1 shift + +Description +""""""""""" + +Perform time integration to update position, velocity, internal energy +and local density for atoms in the group each timestep. This fix is +needed to time-integrate SPH systems where particles carry internal +variables such as internal energy. SPH stands for Smoothed Particle +Hydrodynamics. + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +are relevant to this fix. No global or per-atom quantities are stored +by this fix for access by various :doc:`output commands `. +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 fix is part of the RHEO 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 rheo/viscosity `, +:doc:`fix rheo/pressure `, +:doc:`fix rheo/thermal `, +:doc:`pair rheo `, +:doc:`compute rheo/property/atom ` + +Default +""""""" + +none diff --git a/doc/src/fix_rheo_viscosity.rst b/doc/src/fix_rheo_viscosity.rst new file mode 100644 index 0000000000..7200d456dd --- /dev/null +++ b/doc/src/fix_rheo_viscosity.rst @@ -0,0 +1,59 @@ +.. index:: fix rheo + +fix rheo command +=============== + +Syntax +"""""" + +.. parsed-literal:: + + fix ID group-ID rheo + +* ID, group-ID are documented in :doc:`fix ` command +* rheo = style name of this fix command + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all rheo 1.0 CRK1 shift + +Description +""""""""""" + +Perform time integration to update position, velocity, internal energy +and local density for atoms in the group each timestep. This fix is +needed to time-integrate SPH systems where particles carry internal +variables such as internal energy. SPH stands for Smoothed Particle +Hydrodynamics. + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +are relevant to this fix. No global or per-atom quantities are stored +by this fix for access by various :doc:`output commands `. +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 fix is part of the RHEO 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 rheo/viscosity `, +:doc:`fix rheo/pressure `, +:doc:`fix rheo/thermal `, +:doc:`pair rheo `, +:doc:`compute rheo/property/atom ` + +Default +""""""" + +none diff --git a/doc/src/pair_rheo.rst b/doc/src/pair_rheo.rst new file mode 100644 index 0000000000..b5c02c41ff --- /dev/null +++ b/doc/src/pair_rheo.rst @@ -0,0 +1,86 @@ +.. index:: pair_style sph/lj + +pair_style sph/lj command +========================= + +Syntax +"""""" + +.. code-block:: LAMMPS + + pair_style sph/lj + +Examples +"""""""" + +.. code-block:: LAMMPS + + pair_style sph/lj + pair_coeff * * 1.0 2.4 + +Description +""""""""""" + +The sph/lj style computes pressure forces between particles according +to the Lennard-Jones equation of state, which is computed according to +Ree's 1980 polynomial fit :ref:`(Ree) `. The Lennard-Jones parameters +epsilon and sigma are set to unity. This pair style also computes +Monaghan's artificial viscosity to prevent particles from +interpenetrating :ref:`(Monaghan) `. + +See `this PDF guide `_ to using SPH in +LAMMPS. + +The following coefficients must be defined for each pair of atoms +types via the :doc:`pair_coeff ` command as in the examples +above. + +* :math:`\nu` artificial viscosity (no units) +* h kernel function cutoff (distance units) + +---------- + +Mixing, shift, table, tail correction, restart, rRESPA info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +This style does not support mixing. Thus, coefficients for all +I,J pairs must be specified explicitly. + +This style does not support the :doc:`pair_modify ` +shift, table, and tail options. + +This style does not write information to :doc:`binary restart files `. Thus, you need to re-specify the pair_style and +pair_coeff commands in an input script that reads a restart file. + +This style can only be used via the *pair* keyword of the :doc:`run_style respa ` command. It does not support the *inner*, +*middle*, *outer* keywords. + +Restrictions +"""""""""""" + +As noted above, the Lennard-Jones parameters epsilon and sigma are set +to unity. + +This pair style is part of the SPH package. It is only enabled +if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. + +Related commands +"""""""""""""""" + +:doc:`pair_coeff `, pair_sph/rhosum + +Default +""""""" + +none + +---------- + +.. _Ree: + +**(Ree)** Ree, Journal of Chemical Physics, 73, 5401 (1980). + +.. _Monoghan: + +**(Monaghan)** Monaghan and Gingold, Journal of Computational Physics, +52, 374-389 (1983). diff --git a/doc/src/read_data.rst b/doc/src/read_data.rst index 0ecd2b6fa2..4950d8bc25 100644 --- a/doc/src/read_data.rst +++ b/doc/src/read_data.rst @@ -714,6 +714,10 @@ of analysis. - atom-ID molecule-ID atom-type x y z * - peri - atom-ID atom-type volume density x y z + * - rheo + - atom-ID atom-type status rho x y z + * - rheo/thermal + - atom-ID atom-type status rho temperature x y z * - smd - atom-ID atom-type molecule volume mass kradius cradius x0 y0 z0 x y z * - sph diff --git a/doc/src/set.rst b/doc/src/set.rst index 0073e44bf8..96e48a8893 100644 --- a/doc/src/set.rst +++ b/doc/src/set.rst @@ -111,6 +111,8 @@ Syntax *angle* value = angle type for all angles between selected atoms *dihedral* value = dihedral type for all dihedrals between selected atoms *improper* value = improper type for all impropers between selected atoms + *rheo/rho* value = density of RHEO particles (mass/distance\^3) + *rheo/status* value = status or phase of RHEO particles (unitless) *sph/e* value = energy of SPH particles (need units) value can be an atom-style variable (see below) *sph/cv* value = heat capacity of SPH particles (need units) @@ -472,6 +474,10 @@ the *bond types* (\ *angle types*, etc) field in the header of the data file read by the :doc:`read_data ` command. These keywords do not allow use of an atom-style variable. +Keywords *rheo/rho* and *rheo/status* set the density and the status of +rheo particles. In particular, one can only set the phase in the status +as described by the :doc:`RHEO howto page `. + Keywords *sph/e*, *sph/cv*, and *sph/rho* set the energy, heat capacity, and density of smoothed particle hydrodynamics (SPH) particles. See `this PDF guide `_ to using SPH in LAMMPS. From 0b1d393d7817c40d4df9735e96dbdec1093e741b Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 1 May 2023 14:05:47 -0600 Subject: [PATCH 033/104] Adding arguments to doc page --- doc/src/Howto_rheo.rst | 1 + doc/src/fix_rheo.rst | 36 ++++++++++++++----- doc/src/fix_rheo_pressure.rst | 33 +++++++++++------ doc/src/fix_rheo_thermal.rst | 50 ++++++++++++++++++++------ doc/src/fix_rheo_viscosity.rst | 43 ++++++++++++++++------ doc/src/pair_rheo.rst | 66 +++++++++++++--------------------- src/RHEO/fix_rheo.cpp | 6 ++-- src/RHEO/fix_rheo_thermal.cpp | 2 +- src/RHEO/pair_rheo.cpp | 6 ++-- 9 files changed, 154 insertions(+), 89 deletions(-) diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index 9dac90549c..c55631455b 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -1,3 +1,4 @@ Reproducing hydrodynamics and elastic objects (RHEO) ====================== +Text diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index 7200d456dd..e9613e4838 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -8,26 +8,38 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo + fix ID group-ID rheo cut kstyle keyword values... * ID, group-ID are documented in :doc:`fix ` command * rheo = style name of this fix command +* cut = *quintic* or *CRK0* or *CRK1* or *CRK2* +* zero or more keyword/value pairs may be appended to args +* keyword = *shift* or *thermal* or *surface/detection* or *interface/reconstruction* or *rho/sum* or *density* or *sound/squared* + + .. parsed-literal:: + + *shift* values = none, turns on velocity shifting + *thermal* values = none, turns on thermal evolution + *surface/detection* values = *sdstyle* *limit* + *sdstyle* = *coordination* or *divergence* + *limit* = threshold for surface particles (unitless) + *interface/reconstruction* values = none, reconstructs interfaces with solid particles + *rho/sum* values = none, uses the kernel to compute the density of particles + *density* values = *rho0* (density) + *sound/squared* values = *csq* (velocity\^2) Examples """""""" .. code-block:: LAMMPS - fix 1 all rheo 1.0 CRK1 shift + fix 1 all rheo 1.0 quintic thermal density 0.1 sound/squared 10.0 + fix 1 all rheo 1.0 CRK1 shift surface/detection coordination 40 Description """"""""""" -Perform time integration to update position, velocity, internal energy -and local density for atoms in the group each timestep. This fix is -needed to time-integrate SPH systems where particles carry internal -variables such as internal energy. SPH stands for Smoothed Particle -Hydrodynamics. +Fix description... Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -41,6 +53,14 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" +This fix must be used with an atom style that includes density +such as atom_style rheo or rheo/thermal. This fix must be used in +conjuction with :doc:`fix rheo/pressure `. and +:doc:`fix rheo/viscosity `, If the *thermal* +setting is used, there must also be an instance of +:doc:`fix rheo/thermal `. The fix group must be +set to all. + This fix is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. @@ -56,4 +76,4 @@ Related commands Default """"""" -none +*rho0* and *csq* are set to 1.0. diff --git a/doc/src/fix_rheo_pressure.rst b/doc/src/fix_rheo_pressure.rst index 7200d456dd..ceb402501a 100644 --- a/doc/src/fix_rheo_pressure.rst +++ b/doc/src/fix_rheo_pressure.rst @@ -1,6 +1,6 @@ -.. index:: fix rheo +.. index:: fix rheo/pressure -fix rheo command +fix rheo/pressure command =============== Syntax @@ -8,26 +8,33 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo + fix ID group-ID rheo/pressure pstyle args * ID, group-ID are documented in :doc:`fix ` command -* rheo = style name of this fix command +* rheo/pressure = style name of this fix command +* pstyle = *linear* or *taitwater* or *cubic* + + .. parsed-literal:: + + *linear* args = none + *taitwater* args = none + *cubic* args = cubic term prefactor :math:`A_3` (pressure/density\^2) Examples """""""" .. code-block:: LAMMPS - fix 1 all rheo 1.0 CRK1 shift + fix 1 all rheo/pressure linear + fix 1 all rheo/pressure cubic 10.0 Description """"""""""" -Perform time integration to update position, velocity, internal energy -and local density for atoms in the group each timestep. This fix is -needed to time-integrate SPH systems where particles carry internal -variables such as internal energy. SPH stands for Smoothed Particle -Hydrodynamics. +This fix... + +Only one instance of fix rheo/pressure can be defined and the fix group must be set to all. + Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -41,6 +48,11 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" +This fix must be used with an atom style that includes density +such as atom_style rheo or rheo/thermal. This fix must be used in +conjuction with :doc:`fix rheo `. The fix group must be +set to all. + This fix is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. @@ -48,7 +60,6 @@ Related commands """""""""""""""" :doc:`fix rheo/viscosity `, -:doc:`fix rheo/pressure `, :doc:`fix rheo/thermal `, :doc:`pair rheo `, :doc:`compute rheo/property/atom ` diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst index 7200d456dd..01b4820a39 100644 --- a/doc/src/fix_rheo_thermal.rst +++ b/doc/src/fix_rheo_thermal.rst @@ -1,6 +1,6 @@ -.. index:: fix rheo +.. index:: fix rheo/thermal -fix rheo command +fix rheo/thermal command =============== Syntax @@ -8,26 +8,49 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo + fix ID group-ID rheo/thermal keyword values ... * ID, group-ID are documented in :doc:`fix ` command -* rheo = style name of this fix command +* rheo/viscosity = style name of this fix command +* one or more attributes may be appended +* attribute = *conductivity* or *specific/heat* or *Tfreeze* + + .. parsed-literal:: + + *conductivity* args = style param + style = *constant* or *type* + *constant* arg = conductivity (power/temperature) + *type* args = list of conductivity values, one per type (power/temperature) + *specific/heat* args = style param + style = *constant* or *type* + *constant* arg = specific heat (energy/(mass*temperature)) + *type* args = list of specific heat values, one per atom type (energy/(mass*temperature)) + *Tfreeze* args = style param + style = *constant* or *type* + *constant* arg = freezing temperature (temperature) + *type* args = list of freezing temperature values, one per type (temperature) Examples """""""" .. code-block:: LAMMPS - fix 1 all rheo 1.0 CRK1 shift + fix 1 all rheo/thermal conductivity constant 1.0 specific/heat constant 1.0 Tfreeze constant 1.0 + fix 1 all rheo/pressure conductivity constant 1.0 specific/heat type 1.0 2.0 Description """"""""""" -Perform time integration to update position, velocity, internal energy -and local density for atoms in the group each timestep. This fix is -needed to time-integrate SPH systems where particles carry internal -variables such as internal energy. SPH stands for Smoothed Particle -Hydrodynamics. +This fix... + +While the *Tfreeze* keyword is optional, the *conducitivity* and +*specific/heat* keywords are mandatory. + +Multiple instances of this fix may be defined to apply different +properties to different groups. However, the union of fix groups +across all instances of fix rheo/thermal must cover all atoms. +If there are multiple instances of this fix, any intersections in +the fix groups will lead to incorrect thermal integration. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -41,15 +64,20 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" +This fix must be used with an atom style that includes temperature, +heatflow, and conductivity such as atom_tyle rheo/thermal This fix +must be used in conjuction with :doc:`fix rheo ` with the +*thermal* setting. + This fix is part of the RHEO 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 rheo `, :doc:`fix rheo/viscosity `, :doc:`fix rheo/pressure `, -:doc:`fix rheo/thermal `, :doc:`pair rheo `, :doc:`compute rheo/property/atom ` diff --git a/doc/src/fix_rheo_viscosity.rst b/doc/src/fix_rheo_viscosity.rst index 7200d456dd..278c621216 100644 --- a/doc/src/fix_rheo_viscosity.rst +++ b/doc/src/fix_rheo_viscosity.rst @@ -1,6 +1,6 @@ -.. index:: fix rheo +.. index:: fix rheo/viscosity -fix rheo command +fix rheo/viscosity command =============== Syntax @@ -8,26 +8,43 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo + fix ID group-ID rheo/viscosity vstyle args * ID, group-ID are documented in :doc:`fix ` command -* rheo = style name of this fix command +* rheo/viscosity = style name of this fix command +* vstyle = *constant* or *type* or *power* + + .. parsed-literal:: + + *constant* arg = viscosity (mass/(length*time)) + *type* args = list of viscosity values, one per atom type (mass/(length*time)) + *power* args = *eta* *gd0* *K* *npow* *tau0* + *eta* = (units) + *gd0* = (units) + *K* = (units) + *npow* = (units) + *tau0* = (units) Examples """""""" .. code-block:: LAMMPS - fix 1 all rheo 1.0 CRK1 shift + fix 1 all rheo/viscosity constant 1.0 + fix 1 all rheo/viscosity power 0.1 1e-2 0.5 0.01 Description """"""""""" -Perform time integration to update position, velocity, internal energy -and local density for atoms in the group each timestep. This fix is -needed to time-integrate SPH systems where particles carry internal -variables such as internal energy. SPH stands for Smoothed Particle -Hydrodynamics. +This fix... + +Multiple instances of this fix may be defined to apply different +properties to different groups. However, the union of fix groups +across all instances of fix rheo/viscosity must cover all atoms. +If there are multiple instances of this fix, any intersection +between fix groups will cause the viscosity for the affected atoms +to be calculated multiple times. Any such affected atoms will enabled +up with a viscosity calculated by the latest defined fix. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -41,13 +58,17 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" +This fix must be used with an atom style that includes viscosity +such as atom_style rheo or rheo/thermal. This fix must be used in +conjuction with :doc:`fix rheo `. + This fix is part of the RHEO 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 rheo/viscosity `, +:doc:`fix rheo `, :doc:`fix rheo/pressure `, :doc:`fix rheo/thermal `, :doc:`pair rheo `, diff --git a/doc/src/pair_rheo.rst b/doc/src/pair_rheo.rst index b5c02c41ff..7a26755780 100644 --- a/doc/src/pair_rheo.rst +++ b/doc/src/pair_rheo.rst @@ -1,6 +1,6 @@ .. index:: pair_style sph/lj -pair_style sph/lj command +pair_style rheo command ========================= Syntax @@ -8,79 +8,63 @@ Syntax .. code-block:: LAMMPS - pair_style sph/lj + pair_style rheo cut keyword values + +* cut = *quintic* or *CRK0* or *CRK1* or *CRK2* +* zero or more keyword/value pairs may be appended to args +* keyword = *rho/damp* or *artificial/visc* + +.. parsed-literal:: + + *rho/damp* args = density damping prefactor :math:`\xi` (units?) + *artificial/visc* args = artificial viscosity prefactor :math:`\zeta` (units?) Examples """""""" .. code-block:: LAMMPS - pair_style sph/lj - pair_coeff * * 1.0 2.4 + pair_style rheo 1.0 quintic rho/damp 1.0 artificial/visc 2.0 + pair_coeff * * Description """"""""""" -The sph/lj style computes pressure forces between particles according -to the Lennard-Jones equation of state, which is computed according to -Ree's 1980 polynomial fit :ref:`(Ree) `. The Lennard-Jones parameters -epsilon and sigma are set to unity. This pair style also computes -Monaghan's artificial viscosity to prevent particles from -interpenetrating :ref:`(Monaghan) `. +pair style... -See `this PDF guide `_ to using SPH in -LAMMPS. - -The following coefficients must be defined for each pair of atoms -types via the :doc:`pair_coeff ` command as in the examples +No coefficients are defined for each pair of atoms types via the +:doc:`pair_coeff ` command as in the examples above. -* :math:`\nu` artificial viscosity (no units) -* h kernel function cutoff (distance units) - ---------- Mixing, shift, table, tail correction, restart, rRESPA info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -This style does not support mixing. Thus, coefficients for all -I,J pairs must be specified explicitly. - This style does not support the :doc:`pair_modify ` shift, table, and tail options. This style does not write information to :doc:`binary restart files `. Thus, you need to re-specify the pair_style and pair_coeff commands in an input script that reads a restart file. -This style can only be used via the *pair* keyword of the :doc:`run_style respa ` command. It does not support the *inner*, -*middle*, *outer* keywords. +This style can only be used via the *pair* keyword of the :doc:`run_style respa ` command. It does not support the *inner*, *middle*, *outer* keywords. Restrictions """""""""""" -As noted above, the Lennard-Jones parameters epsilon and sigma are set -to unity. - -This pair style is part of the SPH package. It is only enabled -if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. +This fix is part of the RHEO package. It is only enabled if +LAMMPS was built with that package. See the :doc:`Build package ` page for more info. Related commands """""""""""""""" -:doc:`pair_coeff `, pair_sph/rhosum +:doc:`fix rheo `, +:doc:`fix rheo/pressure `, +:doc:`fix rheo/thermal `, +:doc:`fix rheo/viscosity `, +:doc:`compute rheo/property/atom ` Default """"""" -none - ----------- - -.. _Ree: - -**(Ree)** Ree, Journal of Chemical Physics, 73, 5401 (1980). - -.. _Monoghan: - -**(Monaghan)** Monaghan and Gingold, Journal of Computational Physics, -52, 374-389 (1983). +No density damping or artificial viscous forces are calculated. diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 48eece239a..bacaae074d 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -74,7 +74,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : h = utils::numeric(FLERR,arg[3],false,lmp); cut = h; - if (strcmp(arg[4],"Quintic") == 0) { + if (strcmp(arg[4],"quintic") == 0) { kernel_style = QUINTIC; } else if (strcmp(arg[4],"CRK0") == 0) { kernel_style = CRK0; @@ -109,11 +109,11 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : interface_flag = 1; } else if (strcmp(arg[iarg],"rho/sum") == 0) { rhosum_flag = 1; - } else if (strcmp(arg[iarg],"rho0") == 0) { + } else if (strcmp(arg[iarg],"density") == 0) { if(iarg + 1 >= narg) error->all(FLERR,"Illegal rho0 option in fix rheo"); rho0 = utils::numeric(FLERR,arg[iarg + 1],false,lmp); iarg += 1; - } else if (strcmp(arg[iarg],"csq") == 0) { + } else if (strcmp(arg[iarg],"sound/squared") == 0) { if(iarg+1 >= narg) error->all(FLERR,"Illegal csq option in fix rheo"); csq = utils::numeric(FLERR,arg[iarg + 1],false,lmp); iarg += 1; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index bd7a22ce1e..ec39a13311 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -72,7 +72,7 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); } - } else if (strcmp(arg[iarg],"cv") == 0) { + } else if (strcmp(arg[iarg],"specific/heat") == 0) { // Cv arguments if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for cv option"); if (strcmp(arg[iarg + 1],"constant") == 0) { diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 8e76a6d413..b8b8e5a809 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -357,7 +357,7 @@ void PairRHEO::settings(int narg, char **arg) if (narg < 1) error->all(FLERR,"Illegal pair_style command"); h = utils::numeric(FLERR,arg[0],false,lmp); -printf("settings\n"); + int iarg = 1; while (iarg < narg) { if (strcmp(arg[iarg], "rho/damp") == 0) { @@ -423,7 +423,7 @@ void PairRHEO::setup() thermal_flag = fix_rheo->thermal_flag; csq = fix_rheo->csq; rho0 = fix_rheo->rho0; -printf("setup\n"); + if (h != fix_rheo->h) error->all(FLERR, "Pair rheo cutoff {} does not agree with fix rheo cutoff {}", h, fix_rheo->h); @@ -455,6 +455,6 @@ double PairRHEO::init_one(int i, int j) if (setflag[i][j] == 0) { error->all(FLERR,"All pair rheo coeffs are not set"); } -printf("init one\n"); + return h; } From c81c4cefc07fa0c131a03d497ac58737f7864af8 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 1 May 2023 14:32:14 -0600 Subject: [PATCH 034/104] Fixing pair label --- doc/src/pair_rheo.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/pair_rheo.rst b/doc/src/pair_rheo.rst index 7a26755780..d168f79785 100644 --- a/doc/src/pair_rheo.rst +++ b/doc/src/pair_rheo.rst @@ -1,4 +1,4 @@ -.. index:: pair_style sph/lj +.. index:: pair_style rheo pair_style rheo command ========================= From 4a419b2f006acac80c316b4c216134cb31ae5189 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 1 May 2023 14:47:52 -0600 Subject: [PATCH 035/104] Adding rheo property/atom compute odc --- doc/src/compute_rheo_property_atom.rst | 101 +++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 doc/src/compute_rheo_property_atom.rst diff --git a/doc/src/compute_rheo_property_atom.rst b/doc/src/compute_rheo_property_atom.rst new file mode 100644 index 0000000000..5476f7f709 --- /dev/null +++ b/doc/src/compute_rheo_property_atom.rst @@ -0,0 +1,101 @@ +.. index:: compute rheo/property/atom + +compute rheo/property/atom command +============================= + +Syntax +"""""" + +.. code-block:: LAMMPS + + compute ID group-ID rheo/property/atom input1 input2 ... + +* ID, group-ID are documented in :doc:`compute ` command +* rheo/property/atom = style name of this compute command +* input = one or more atom attributes + + .. parsed-literal:: + + possible attributes = phase, chi, surface, surface/r, + surface/divr, surface/nx, surface/ny, + surface/nz, coordination, cv, shift/vx, + shift/vy, shift/vz, temperature, heatflow, + conductivity, viscosity, pressure, status, + rho + + .. parsed-literal:: + + *phase* = atom phase status + *chi* = atom phase neighborhood metric + *surface* = atom surface status + *surface/r* = atom distance from the surface + *surface/divr* = divergence of position at atom position + *surface/nx, surface/ny, surface/nz* = surface normal vector + *coordination* = coordination number + *shift/vx, shift/vy, shift/vz* = atom shifting velocity + *temperature* = atom temperature + *heatflow* = atom heat flow + *conductivity* = atom conductivity + *viscosity* = atom viscosity + *pressure* = atom pressure + *status* = atom full status + *rho* = atom density + +Examples +"""""""" + +.. code-block:: LAMMPS + + compute 1 all rheo/property/atom phase surface/r pressure + +Description +""""""""""" + +Define a computation that simply stores atom attributes specific to the +RHEO package for each atom in the group. This is useful so that the +values can be used by other :doc:`output commands ` that +take computes as inputs. See for example, the :doc:`compute reduce +`, :doc:`fix ave/atom `, :doc:`fix +ave/histo `, :doc:`fix ave/chunk `, +and :doc:`atom-style variable ` commands. + +The possible attributes are described in more detail in other RHEO doc +pages include :doc:`fix rheo `, :doc:`pair rheo `, +and :doc:`the RHEO howto page `. + +The values are stored in a per-atom vector or array as discussed +below. Zeroes are stored for atoms not in the specified group or for +quantities that are not defined for a particular particle in the group + +Output info +""""""""""" + +This compute calculates a per-atom vector or per-atom array depending +on the number of input values. If a single input is specified, a +per-atom vector is produced. If two or more inputs are specified, a +per-atom array is produced where the number of columns = the number of +inputs. The vector or array can be accessed by any command that uses +per-atom values from a compute as input. See the :doc:`Howto output +` page for an overview of LAMMPS output options. + +The vector or array values will be in whatever :doc:`units ` the +corresponding attribute is in (e.g., density units for *rho*). + +Restrictions +"""""""""""" + none + +Related commands +"""""""""""""""" + +:doc:`dump custom `, :doc:`compute reduce `, +:doc:`fix ave/atom `, :doc:`fix ave/chunk `, +:doc:`fix rheo/viscosity `, +:doc:`fix rheo/pressure `, +:doc:`fix rheo/thermal `, +:doc:`pair rheo ` + +Default +""""""" + +none From 35418afd6b186eaa1be26a09ea5740573a8a53b1 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 11 May 2023 14:19:32 -0600 Subject: [PATCH 036/104] Rename CRK -> RK --- doc/src/fix_rheo.rst | 4 +-- src/RHEO/compute_rheo_kernel.cpp | 60 ++++++++++++++++---------------- src/RHEO/compute_rheo_kernel.h | 10 +++--- src/RHEO/fix_rheo.cpp | 12 +++---- src/RHEO/fix_rheo.h | 2 +- src/RHEO/pair_rheo.cpp | 4 +-- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index e9613e4838..7aaab48f54 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -12,7 +12,7 @@ Syntax * ID, group-ID are documented in :doc:`fix ` command * rheo = style name of this fix command -* cut = *quintic* or *CRK0* or *CRK1* or *CRK2* +* cut = *quintic* or *RK0* or *RK1* or *RK2* * zero or more keyword/value pairs may be appended to args * keyword = *shift* or *thermal* or *surface/detection* or *interface/reconstruction* or *rho/sum* or *density* or *sound/squared* @@ -34,7 +34,7 @@ Examples .. code-block:: LAMMPS fix 1 all rheo 1.0 quintic thermal density 0.1 sound/squared 10.0 - fix 1 all rheo 1.0 CRK1 shift surface/detection coordination 40 + fix 1 all rheo 1.0 RK1 shift surface/detection coordination 40 Description """"""""""" diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 205ae6fb72..09d807d50d 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -60,11 +60,11 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : if (kernel_style == QUINTIC) { correction_order = -1; - } else if (kernel_style == CRK0) { + } else if (kernel_style == RK0) { correction_order = 0; - } else if (kernel_style == CRK1) { + } else if (kernel_style == RK1) { correction_order = 1; - } else if (kernel_style == CRK2) { + } else if (kernel_style == RK2) { correction_order = 2; } @@ -73,11 +73,11 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : comm_forward = 1; ncor = 0; Mdim = 0; - if (kernel_style == CRK1) { + if (kernel_style == RK1) { Mdim = 1 + dim; ncor = 1 + dim; comm_forward = ncor * Mdim; - } else if (kernel_style == CRK2) { + } else if (kernel_style == RK2) { //Polynomial basis size (up to quadratic order) Mdim = 1 + dim + dim * (dim + 1) / 2; //Number of sets of correction coefficients (1 x y xx yy) + z zz (3D) @@ -123,11 +123,11 @@ void ComputeRHEOKernel::init() nmax_store = atom->nmax; memory->create(coordination, nmax_store, "rheo:coordination"); - if (kernel_style == CRK0) { + if (kernel_style == RK0) { memory->create(C0, nmax_store, "rheo/kernel:C0"); - } else if (kernel_style == CRK1) { + } else if (kernel_style == RK1) { memory->create(C, nmax_store, ncor, Mdim, "rheo/kernel:C"); - } else if (kernel_style == CRK2) { + } else if (kernel_style == RK2) { memory->create(C, nmax_store, ncor, Mdim, "rheo/kernel:C"); } } @@ -171,9 +171,9 @@ double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double } if (!corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); - else if (kernel_style == CRK0) w = calc_w_crk0(i,j,delx,dely,delz,r); - else if (kernel_style == CRK1) w = calc_w_crk1(i,j,delx,dely,delz,r); - else if (kernel_style == CRK2) w = calc_w_crk2(i,j,delx,dely,delz,r); + else if (kernel_style == RK0) w = calc_w_rk0(i,j,delx,dely,delz,r); + else if (kernel_style == RK1) w = calc_w_rk1(i,j,delx,dely,delz,r); + else if (kernel_style == RK2) w = calc_w_rk2(i,j,delx,dely,delz,r); return w; } @@ -194,12 +194,12 @@ double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double wp = calc_dw_quintic(i,j,delx,dely,delz,r,dWij,dWji); // Overwrite if there are corrections - if (kernel_style == CRK1) { - if (corrections_i) calc_dw_crk1(i,j,delx,dely,delz,r,dWij); - if (corrections_j) calc_dw_crk1(j,i,-delx,-dely,-delz,r,dWji); - } else if (kernel_style == CRK2) { - if (corrections_i) calc_dw_crk2(i,j,delx,dely,delz,r,dWij); - if (corrections_j) calc_dw_crk2(j,i,-delx,-dely,-delz,r,dWji); + if (kernel_style == RK1) { + if (corrections_i) calc_dw_rk1(i,j,delx,dely,delz,r,dWij); + if (corrections_j) calc_dw_rk1(j,i,-delx,-dely,-delz,r,dWji); + } else if (kernel_style == RK2) { + if (corrections_i) calc_dw_rk2(i,j,delx,dely,delz,r,dWij); + if (corrections_j) calc_dw_rk2(j,i,-delx,-dely,-delz,r,dWji); } return wp; @@ -285,7 +285,7 @@ double ComputeRHEOKernel::calc_dw_quintic(int i, int j, double delx, double dely /* ---------------------------------------------------------------------- */ -double ComputeRHEOKernel::calc_w_crk0(int i, int j, double delx, double dely, double delz, double r) +double ComputeRHEOKernel::calc_w_rk0(int i, int j, double delx, double dely, double delz, double r) { double w; @@ -299,7 +299,7 @@ double ComputeRHEOKernel::calc_w_crk0(int i, int j, double delx, double dely, do /* ---------------------------------------------------------------------- */ -double ComputeRHEOKernel::calc_w_crk1(int i, int j, double delx, double dely, double delz, double r) +double ComputeRHEOKernel::calc_w_rk1(int i, int j, double delx, double dely, double delz, double r) { int b; double w, wR, dx[3], H[Mdim]; @@ -341,7 +341,7 @@ double ComputeRHEOKernel::calc_w_crk1(int i, int j, double delx, double dely, do /* ---------------------------------------------------------------------- */ -double ComputeRHEOKernel::calc_w_crk2(int i, int j, double delx, double dely, double delz, double r) +double ComputeRHEOKernel::calc_w_rk2(int i, int j, double delx, double dely, double delz, double r) { int b; double w, wR, dx[3], H[Mdim]; @@ -391,7 +391,7 @@ double ComputeRHEOKernel::calc_w_crk2(int i, int j, double delx, double dely, do /* ---------------------------------------------------------------------- */ -void ComputeRHEOKernel::calc_dw_crk1(int i, int j, double delx, double dely, double delz, double r, double *dW) +void ComputeRHEOKernel::calc_dw_rk1(int i, int j, double delx, double dely, double delz, double r, double *dW) { int a, b; double w, dx[3], H[Mdim]; @@ -428,7 +428,7 @@ void ComputeRHEOKernel::calc_dw_crk1(int i, int j, double delx, double dely, dou /* ---------------------------------------------------------------------- */ -void ComputeRHEOKernel::calc_dw_crk2(int i, int j, double delx, double dely, double delz, double r, double *dW) +void ComputeRHEOKernel::calc_dw_rk2(int i, int j, double delx, double dely, double delz, double r, double *dW) { int a, b; double w, dx[3], H[Mdim]; @@ -504,7 +504,7 @@ void ComputeRHEOKernel::compute_peratom() // Grow arrays if necessary if (nmax_store < atom->nmax) grow_arrays(atom->nmax); - if (kernel_style == CRK0) { + if (kernel_style == RK0) { double M; for (ii = 0; ii < inum; ii++) { @@ -592,7 +592,7 @@ void ComputeRHEOKernel::compute_peratom() H[0] = 1.0; H[1] = dx[0] * hinv; H[2] = dx[1] * hinv; - if (kernel_style == CRK2) { + if (kernel_style == RK2) { H[3] = 0.5 * dx[0] * dx[0] * hsqinv; H[4] = 0.5 * dx[1] * dx[1] * hsqinv; H[5] = dx[0] * dx[1] * hsqinv; @@ -602,7 +602,7 @@ void ComputeRHEOKernel::compute_peratom() H[1] = dx[0] * hinv; H[2] = dx[1] * hinv; H[3] = dx[2] * hinv; - if (kernel_style == CRK2) { + if (kernel_style == RK2) { H[4] = 0.5 * dx[0] * dx[0] * hsqinv; H[5] = 0.5 * dx[1] * dx[1] * hsqinv; H[6] = 0.5 * dx[2] * dx[2] * hsqinv; @@ -676,7 +676,7 @@ void ComputeRHEOKernel::compute_peratom() // columns 1-2 (2D) or 1-3 (3D) //Second derivatives - if (kernel_style == CRK2) + if (kernel_style == RK2) C[i][1 + dim + b][a] = M[a * Mdim + b + 1 + dim] * hsqinv; // columns 3-4 (2D) or 4-6 (3D) } @@ -746,7 +746,7 @@ void ComputeRHEOKernel::grow_arrays(int nmax) { memory->grow(coordination, nmax, "rheo:coordination"); - if (kernel_style == CRK0) { + if (kernel_style == RK0) { memory->grow(C0, nmax, "rheo/kernel:C0"); } else if (correction_order > 0) { memory->grow(C, nmax, ncor, Mdim, "rheo/kernel:C"); @@ -768,7 +768,7 @@ int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf, if (comm_stage == 0) { buf[m++] = coordination[j]; } else { - if (kernel_style == CRK0) { + if (kernel_style == RK0) { buf[m++] = C0[j]; } else { for (a = 0; a < ncor; a++) @@ -792,7 +792,7 @@ void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) if (comm_stage == 0) { coordination[i] = buf[m++]; } else { - if (kernel_style == CRK0) { + if (kernel_style == RK0) { C0[i] = buf[m++]; } else { for (a = 0; a < ncor; a++) @@ -810,7 +810,7 @@ double ComputeRHEOKernel::memory_usage() double bytes = 0.0; bytes = (size_t) nmax_store * sizeof(int); - if (kernel_style == CRK0) { + if (kernel_style == RK0) { bytes += (size_t) nmax_store * sizeof(double); } else if (correction_order > 0) { bytes += (size_t) nmax_store * ncor * Mdim * sizeof(double); diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index 5324199f76..2c9f4768e1 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -64,11 +64,11 @@ class ComputeRHEOKernel : public Compute { int check_corrections(int); - double calc_w_crk0(int,int,double,double,double,double); - double calc_w_crk1(int,int,double,double,double,double); - double calc_w_crk2(int,int,double,double,double,double); - void calc_dw_crk1(int,int,double,double,double,double,double *); - void calc_dw_crk2(int,int,double,double,double,double,double *); + double calc_w_rk0(int,int,double,double,double,double); + double calc_w_rk1(int,int,double,double,double,double); + double calc_w_rk2(int,int,double,double,double,double); + void calc_dw_rk1(int,int,double,double,double,double,double *); + void calc_dw_rk2(int,int,double,double,double,double,double *); }; } // namespace LAMMPS_NS diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index bacaae074d..04e6c08917 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -76,12 +76,12 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : cut = h; if (strcmp(arg[4],"quintic") == 0) { kernel_style = QUINTIC; - } else if (strcmp(arg[4],"CRK0") == 0) { - kernel_style = CRK0; - } else if (strcmp(arg[4],"CRK1") == 0) { - kernel_style = CRK1; - } else if (strcmp(arg[4],"CRK2") == 0) { - kernel_style = CRK2; + } else if (strcmp(arg[4],"RK0") == 0) { + kernel_style = RK0; + } else if (strcmp(arg[4],"RK1") == 0) { + kernel_style = RK1; + } else if (strcmp(arg[4],"RK2") == 0) { + kernel_style = RK2; } else error->all(FLERR,"Unknown kernel style {} in fix rheo", arg[4]); zmin_kernel = utils::numeric(FLERR,arg[5],false,lmp); diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index a74696e68c..743e418f9a 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -68,7 +68,7 @@ class FixRHEO : public Fix { namespace RHEO_NS { - enum {QUINTIC, CRK0, CRK1, CRK2}; + enum {QUINTIC, RK0, RK1, RK2}; enum {COORDINATION, DIVR}; // Status variables diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index b8b8e5a809..0d041b1e30 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -437,9 +437,9 @@ void PairRHEO::setup() error->all(FLERR,"Pair RHEO requires ghost atoms store velocity"); if (laplacian_order == -1) { - if (fix_rheo->kernel_style == CRK2) + if (fix_rheo->kernel_style == RK2) laplacian_order = 2; - else if (fix_rheo->kernel_style == CRK1) + else if (fix_rheo->kernel_style == RK1) laplacian_order = 1; else laplacian_order = 0; From dfc47a55010a896c99c661f3e13b525f52242eef Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 12 May 2023 23:33:02 -0600 Subject: [PATCH 037/104] Fixing various errors, reorganizing status variable --- .../rheo/poiseuille/in.rheo.poiseuille | 2 +- src/.gitignore | 2 + src/RHEO/compute_rheo_grad.cpp | 11 ++-- src/RHEO/compute_rheo_interface.cpp | 10 ++-- src/RHEO/compute_rheo_kernel.cpp | 4 +- src/RHEO/compute_rheo_property_atom.cpp | 8 +-- src/RHEO/compute_rheo_rho_sum.cpp | 1 - src/RHEO/compute_rheo_surface.cpp | 4 +- src/RHEO/compute_rheo_vshift.cpp | 15 ++++-- src/RHEO/fix_rheo.cpp | 34 ++++++------- src/RHEO/fix_rheo.h | 29 ++++++----- src/RHEO/fix_rheo_pressure.cpp | 37 ++------------ src/RHEO/fix_rheo_pressure.h | 3 -- src/RHEO/fix_rheo_thermal.cpp | 22 +++++--- src/RHEO/pair_rheo.cpp | 50 ++++++++++++------- src/RHEO/pair_rheo.h | 1 + 16 files changed, 113 insertions(+), 120 deletions(-) diff --git a/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille b/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille index af5728c1a3..d0f966c2ce 100644 --- a/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille +++ b/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille @@ -59,7 +59,7 @@ pair_coeff * * # ------ Fixes & computes ------ # -fix 1 all rheo ${cut} Quintic 0 shift +fix 1 all rheo ${cut} quintic 0 shift fix 2 all rheo/viscosity constant ${eta} fix 3 all rheo/pressure linear fix 4 rig setforce 0.0 0.0 0.0 diff --git a/src/.gitignore b/src/.gitignore index d0fcaf495c..f9794ddb82 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -205,6 +205,8 @@ /compute_rheo_interface.h /compute_rheo_kernel.cpp /compute_rheo_kernel.h +/compute_rheo_property_atom.cpp +/compute_rheo_property_atom.h /compute_rheo_rho_sum.cpp /compute_rheo_rho_sum.h /compute_rheo_surface.cpp diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index b71fb08d78..92ac108377 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -125,7 +125,7 @@ void ComputeRHEOGrad::init_list(int /*id*/, NeighList *ptr) void ComputeRHEOGrad::compute_peratom() { - int i, j, k, ii, jj, jnum, itype, jtype, a, b; + int i, j, k, ii, jj, jnum, itype, jtype, a, b, fluidi, fluidj; double xtmp, ytmp, ztmp, delx, dely, delz; double rsq, imass, jmass; double rhoi, rhoj, Voli, Volj, drho, dT, deta; @@ -183,6 +183,7 @@ void ComputeRHEOGrad::compute_peratom() vi[1] = v[i][1]; vi[2] = v[i][2]; itype = type[i]; + fluidi = !(status[i] & PHASECHECK); jlist = firstneigh[i]; jnum = numneigh[i]; @@ -197,6 +198,8 @@ void ComputeRHEOGrad::compute_peratom() rsq = delx * delx + dely * dely + delz * delz; if (rsq < cutsq) { + fluidj = !(status[j] & PHASECHECK); + rhoi = rho[i]; rhoj = rho[j]; @@ -206,13 +209,13 @@ void ComputeRHEOGrad::compute_peratom() // Add corrections for walls if (interface_flag) { - if ((status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { + if (fluidi && (!fluidj)) { compute_interface->correct_v(vi, vj, i, j); rhoj = compute_interface->correct_rho(j, i); - } else if (!(status[i] & STATUS_FLUID) && (status[j] & STATUS_FLUID)) { + } else if ((!fluidi) && fluidj) { compute_interface->correct_v(vj, vi, j, i); rhoi = compute_interface->correct_rho(i, j); - } else if (!(status[i] & STATUS_FLUID) && !(status[j] & STATUS_FLUID)) { + } else if ((!fluidi) && (!fluidj)) { rhoi = rho0; rhoj = rho0; } diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index a3624f9663..ea4916087f 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -131,7 +131,7 @@ void ComputeRHEOInterface::compute_peratom() } for (i = 0; i < nall; i++) { - if (!(status[i] & STATUS_FLUID)) rho[i] = 0.0; + if (status[i] & PHASECHECK) rho[i] = 0.0; normwf[i] = 0.0; norm[i] = 0.0; chi[i] = 0.0; @@ -143,7 +143,7 @@ void ComputeRHEOInterface::compute_peratom() ytmp = x[i][1]; ztmp = x[i][2]; itype = type[i]; - fluidi = status[i] & STATUS_FLUID; + fluidi = !(status[i] & PHASECHECK); jlist = firstneigh[i]; jnum = numneigh[i]; @@ -158,7 +158,7 @@ void ComputeRHEOInterface::compute_peratom() if (rsq < cutsq) { jtype = type[j]; - fluidj = status[j] & STATUS_FLUID; + fluidj = !(status[j] & PHASECHECK); w = compute_kernel->calc_w_quintic(i, j, delx, dely, delz, sqrt(rsq)); status_match = 0; @@ -202,7 +202,7 @@ void ComputeRHEOInterface::compute_peratom() if (norm[i] != 0.0) chi[i] /= norm[i]; // Recalculate rho for non-fluid particles - if (!(status[i] & STATUS_FLUID)) { + if (status[i] & PHASECHECK) { if (normwf[i] != 0.0) { // Stores rho for solid particles 1+Pw in Adami Adams 2012 rho[i] = MAX(EPSILON, rho0 + (rho[i] / normwf[i]) * csq_inv); @@ -289,7 +289,7 @@ void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf) j = list[i]; norm[j] += buf[m++]; chi[j] += buf[m++]; - if (!(status[j] & STATUS_FLUID)){ + if (status[j] & PHASECHECK){ normwf[j] += buf[m++]; rho[j] += buf[m++]; } else { diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 09d807d50d..52380a4337 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -533,7 +533,7 @@ void ComputeRHEOKernel::compute_peratom() w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); rhoj = rho[j]; if (interface_flag) - if (!(status[j] & STATUS_FLUID)) + if (status[j] & PHASECHECK) rhoj = compute_interface->correct_rho(j,i); vj = mass[type[j]] / rhoj; @@ -582,7 +582,7 @@ void ComputeRHEOKernel::compute_peratom() rhoj = rho[j]; if (interface_flag) - if (!(status[j] & STATUS_FLUID)) + if (status[j] & PHASECHECK) rhoj = compute_interface->correct_rho(j,i); vj = mass[type[j]] / rhoj; diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 3cd5d468b2..880ae5d64f 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -212,10 +212,8 @@ void ComputeRHEOPropertyAtom::pack_phase(int n) int *mask = atom->mask; int nlocal = atom->nlocal; - int inverse_mask = ~PHASEMASK; - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = (status[i] & inverse_mask); + if (mask[i] & groupbit) buf[n] = (status[i] & PHASECHECK); else buf[n] = 0.0; n += nvalues; } @@ -244,10 +242,8 @@ void ComputeRHEOPropertyAtom::pack_surface(int n) int *mask = atom->mask; int nlocal = atom->nlocal; - int inverse_mask = ~SURFACEMASK; - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = (status[i] & inverse_mask); + if (mask[i] & groupbit) buf[n] = (status[i] & SURFACECHECK); else buf[n] = 0.0; n += nvalues; } diff --git a/src/RHEO/compute_rheo_rho_sum.cpp b/src/RHEO/compute_rheo_rho_sum.cpp index 726d876ea1..0a2096a2b9 100644 --- a/src/RHEO/compute_rheo_rho_sum.cpp +++ b/src/RHEO/compute_rheo_rho_sum.cpp @@ -74,7 +74,6 @@ void ComputeRHEORhoSum::compute_peratom() double **x = atom->x; double *rho = atom->rho; int *type = atom->type; - int *status = atom->status; double *mass = atom->mass; int newton = force->newton; diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 180c430dd1..f6b93ee551 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -183,7 +183,7 @@ void ComputeRHEOSurface::compute_peratom() jlist = firstneigh[i]; jnum = numneigh[i]; itype = type[i]; - fluidi = status[i] & STATUS_FLUID; + fluidi = !(status[i] & PHASECHECK); for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -196,7 +196,7 @@ void ComputeRHEOSurface::compute_peratom() rsq = lensq3(dx); if (rsq < cutsq) { jtype = type[j]; - fluidj = status[j] & STATUS_FLUID; + fluidj = !(status[j] & PHASECHECK); rhoi = rho[i]; rhoj = rho[j]; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 3d3914436e..0521ff16c0 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -91,7 +91,7 @@ void ComputeRHEOVShift::compute_peratom() double xtmp, ytmp, ztmp, rsq, r, rinv; double w, wp, dr, w0, w4, vmag, prefactor; double imass, jmass, voli, volj, rhoi, rhoj; - double dx[3], vi[3], vj[3] = {0}; + double dx[3], vi[3], vj[3]; int dim = domain->dimension; int *jlist; @@ -123,6 +123,11 @@ void ComputeRHEOVShift::compute_peratom() for (a = 0; a < dim; a++) vshift[i][a] = 0.0; + for (a = 0; a < 3; a++) { + vi[a] = 0.0; + vj[a] = 0.0; + } + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; xtmp = x[i][0]; @@ -132,15 +137,15 @@ void ComputeRHEOVShift::compute_peratom() jlist = firstneigh[i]; jnum = numneigh[i]; imass = mass[itype]; - fluidi = status[i] & STATUS_FLUID; + fluidi = !(status[i] & PHASECHECK); for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; - fluidj = status[j] & STATUS_FLUID; + fluidj = !(status[j] & PHASECHECK); if ((!fluidi) && (!fluidj)) continue; - if (!(status[i] & STATUS_SHIFT) && !(status[j] & STATUS_SHIFT)) continue; + if ((status[i] & STATUS_NO_SHIFT) && (status[j] & STATUS_NO_SHIFT)) continue; dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; @@ -154,7 +159,7 @@ void ComputeRHEOVShift::compute_peratom() r = sqrt(rsq); rinv = 1 / r; - for (a = 0; a < dim; a ++) { + for (a = 0; a < dim; a++) { vi[a] = v[i][a]; vj[a] = v[j][a]; } diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 04e6c08917..fd436cab6e 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -210,6 +210,8 @@ void FixRHEO::setup_pre_force(int /*vflag*/) // Calculate surfaces if (surface_flag) compute_surface->compute_peratom(); + + pre_force(0); } /* ---------------------------------------------------------------------- */ @@ -258,8 +260,6 @@ void FixRHEO::setup(int /*vflag*/) error->one(FLERR, "Fix rheo/viscosity does not fully cover all atoms"); if (!t_coverage_flag) error->one(FLERR, "Fix rheo/thermal does not fully cover all atoms"); - - pre_force(0); } /* ---------------------------------------------------------------------- */ @@ -283,7 +283,8 @@ void FixRHEO::initial_integrate(int /*vflag*/) double **gradr = compute_grad->gradr; double **gradv = compute_grad->gradv; double **vshift; - if (shift_flag) compute_vshift->vshift; + if (shift_flag) + vshift = compute_vshift->vshift; int nlocal = atom->nlocal; int rmass_flag = atom->rmass_flag; @@ -294,7 +295,7 @@ void FixRHEO::initial_integrate(int /*vflag*/) //Density Half-step for (i = 0; i < nlocal; i++) { - if (status[i] & STATUS_NO_FORCE) continue; + if (status[i] & STATUS_NO_INTEGRATION) continue; if (mask[i] & groupbit) { if (rmass_flag) { @@ -331,8 +332,8 @@ void FixRHEO::initial_integrate(int /*vflag*/) if (!rhosum_flag) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if (status[i] & STATUS_NO_FORCE) continue; - if (!(status[i] & STATUS_FLUID)) continue; + if (status[i] & STATUS_NO_INTEGRATION) continue; + if (status[i] & PHASECHECK) continue; divu = 0; for (a = 0; a < dim; a++) { @@ -348,7 +349,7 @@ void FixRHEO::initial_integrate(int /*vflag*/) compute_vshift->correct_surfaces(); // Could this be moved to preforce after the surface fix runs? for (i = 0; i < nlocal; i++) { - if (!(status[i] & STATUS_SHIFT)) continue; + if (status[i] & STATUS_NO_SHIFT) continue; if (mask[i] & groupbit) { for (a = 0; a < dim; a++) { @@ -387,18 +388,13 @@ void FixRHEO::pre_force(int /*vflag*/) if (shift_flag) compute_vshift->compute_peratom(); - // Remove extra shifting/no force options + // Remove temporary options int *mask = atom->mask; int *status = atom->status; int nall = atom->nlocal + atom->nghost; - for (int i = 0; i < nall; i++) { - if (mask[i] & groupbit) { - status[i] &= ~STATUS_NO_FORCE; - - if (status[i] & STATUS_FLUID) - status[i] &= ~STATUS_SHIFT; - } - } + for (int i = 0; i < nall; i++) + if (mask[i] & groupbit) + status[i] &= OPTIONSMASK; // Calculate surfaces, update status if (surface_flag) compute_surface->compute_peratom(); @@ -433,7 +429,7 @@ void FixRHEO::final_integrate() // Update velocity for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if (status[i] & STATUS_NO_FORCE) continue; + if (status[i] & STATUS_NO_INTEGRATION) continue; if (rmass_flag) { dtfm = dtf / rmass[i]; @@ -451,8 +447,8 @@ void FixRHEO::final_integrate() if (!rhosum_flag) { for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if (status[i] & STATUS_NO_FORCE) continue; - if (!(status[i] & STATUS_FLUID)) continue; + if (status[i] & STATUS_NO_INTEGRATION) continue; + if (status[i] & PHASECHECK) continue; divu = 0; for (a = 0; a < dim; a++) { diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 743e418f9a..0dbc8db78b 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -74,22 +74,27 @@ namespace RHEO_NS { // Status variables enum Status{ // Phase status - STATUS_FLUID = 1 << 0, - STATUS_SOLID = 1 << 1, - STATUS_REACTIVE = 1 << 2, - STATUS_FREEZING = 1 << 3, + STATUS_SOLID = 1 << 0, + STATUS_REACTIVE = 1 << 1, + // Surface status - STATUS_BULK = 1 << 4, - STATUS_LAYER = 1 << 5, - STATUS_SURFACE = 1 << 6, - STATUS_SPLASH = 1 << 7, + STATUS_BULK = 1 << 2, + STATUS_LAYER = 1 << 3, + STATUS_SURFACE = 1 << 4, + STATUS_SPLASH = 1 << 5, + // Temporary status options - reset in preforce - STATUS_SHIFT = 1 << 8, - STATUS_NO_FORCE = 1 << 9 + STATUS_NO_SHIFT = 1 << 6, + STATUS_NO_INTEGRATION = 1 << 7, + STATUS_FREEZING = 1 << 8 }; - #define PHASEMASK 0xFFFFFFF0; - #define SURFACEMASK 0xFFFFFF0F; + // Masks and their inverses + #define PHASEMASK 0xFFFFFFFC + #define PHASECHECK 0x00000003 + #define SURFACEMASK 0xFFFFFFC3 + #define SURFACECHECK 0x0000003C + #define OPTIONSMASK 0xFFFFFE3F } // namespace RHEO_NS } // namespace LAMMPS_NS diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 63a6995646..ff206937f4 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -43,9 +43,7 @@ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : if (narg < 4) error->all(FLERR,"Illegal fix command"); pressure_style = NONE; - comm_forward = 1; - nmax_store = 0; // Currently can only have one instance of fix rheo/pressure if (igroup != 0) @@ -73,10 +71,6 @@ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : FixRHEOPressure::~FixRHEOPressure() { - // Remove custom property if it exists - int tmp1, tmp2, index; - index = atom->find_custom("rheo_pressure", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); } /* ---------------------------------------------------------------------- */ @@ -110,20 +104,6 @@ void FixRHEOPressure::init() void FixRHEOPressure::setup_pre_force(int /*vflag*/) { fix_rheo->pressure_fix_defined = 1; - - // Create pressure array if it doesn't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded - - int tmp1, tmp2; - int index = atom->find_custom("rheo_pressure", tmp1, tmp2); - if (index == -1) { - index = atom->add_custom("rheo_pressure", 1, 0); - nmax_store = atom->nmax; - } - pressure = atom->dvector[index]; - pre_force(0); } @@ -138,14 +118,10 @@ void FixRHEOPressure::pre_force(int /*vflag*/) int *mask = atom->mask; double *rho = atom->rho; + double *pressure = atom->pressure; int nlocal = atom->nlocal; - if (nmax_store < atom->nmax) { - memory->grow(pressure, atom->nmax, "atom:rheo_pressure"); - nmax_store = atom->nmax; - } - for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if (pressure_style == LINEAR) { @@ -170,6 +146,7 @@ int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,k,m; + double *pressure = atom->pressure; m = 0; for (i = 0; i < n; i++) { @@ -184,6 +161,7 @@ int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf, void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; + double *pressure = atom->pressure; m = 0; last = first + n; @@ -210,12 +188,3 @@ double FixRHEOPressure::calc_pressure(double rho) } return rho; } - -/* ---------------------------------------------------------------------- */ - -double FixRHEOPressure::memory_usage() -{ - double bytes = 0.0; - bytes += (size_t) nmax_store * sizeof(double); - return bytes; -} diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h index e8f7f3cb88..cbcb495244 100644 --- a/src/RHEO/fix_rheo_pressure.h +++ b/src/RHEO/fix_rheo_pressure.h @@ -34,14 +34,11 @@ class FixRHEOPressure : public Fix { void pre_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; - double memory_usage() override; double calc_pressure(double); private: double c_cubic, csq, rho0, rho0inv; - double *pressure; int pressure_style; - int nmax_store; class FixRHEO *fix_rheo; }; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index ec39a13311..de88b4f8d0 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -205,7 +205,7 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) nlocal = atom->nfirst; for (i = 0; i < nlocal; i++) { - if (!(status[i] & STATUS_SHIFT)) continue; + if (status[i] & STATUS_NO_SHIFT) continue; if (mask[i] & groupbit) { for (a = 0; a < dim; a++) { @@ -231,7 +231,7 @@ void FixRHEOThermal::post_integrate() //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - if (status[i] & STATUS_NO_FORCE) continue; + if (status[i] & STATUS_NO_INTEGRATION) continue; cvi = calc_cv(i); temperature[i] += dtf * heatflow[i] / cvi; @@ -245,11 +245,17 @@ void FixRHEOThermal::post_integrate() } if (Ti > Tci) { - status[i] &= PHASEMASK; - status[i] |= STATUS_FLUID; - } else if (!(status[i] & STATUS_SOLID)) { - status[i] &= PHASEMASK; - status[i] |= STATUS_FREEZING; + // If solid, melt + if (status[i] & STATUS_SOLID) { + status[i] &= PHASEMASK; + } + } else { + // If fluid, freeze + if (!(status[i] & STATUS_SOLID)) { + status[i] &= PHASEMASK; + status[i] |= STATUS_SOLID; + status[i] |= STATUS_FREEZING; + } } } } @@ -300,7 +306,7 @@ void FixRHEOThermal::final_integrate() //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { - if (status[i] & STATUS_NO_FORCE) continue; + if (status[i] & STATUS_NO_INTEGRATION) continue; cvi = calc_cv(i); temperature[i] += dtf * heatflow[i] / cvi; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 0d041b1e30..0930f28f98 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -120,6 +120,16 @@ void PairRHEO::compute(int eflag, int vflag) numneigh = list->numneigh; firstneigh = list->firstneigh; + for (a = 0; a < 3; a++) { + vi[a] = 0.0; + vj[a] = 0.0; + du[a] = 0.0; + fv[a] = 0.0; + dfp[a] = 0.0; + fsolid[a] = 0.0; + ft[0] = 0.0; + } + // loop over neighbors of my atoms for (ii = 0; ii < inum; ii++) { @@ -132,7 +142,7 @@ void PairRHEO::compute(int eflag, int vflag) jnum = numneigh[i]; imass = mass[itype]; etai = viscosity[i]; - fluidi = status[i] & STATUS_FLUID; + fluidi = !(status[i] & PHASECHECK); if (thermal_flag) { kappai = conductivity[i]; Ti = temperature[i]; @@ -154,7 +164,7 @@ void PairRHEO::compute(int eflag, int vflag) jmass = mass[jtype]; etaj = viscosity[j]; - fluidj = status[j] & STATUS_FLUID; + fluidj = !(status[j] & PHASECHECK); if (thermal_flag) { Tj = temperature[j]; kappaj = conductivity[j]; @@ -186,25 +196,27 @@ void PairRHEO::compute(int eflag, int vflag) Pi = pressure[i]; Pj = pressure[j]; fmag = 0; - if (fluidi && (!fluidj)) { - compute_interface->correct_v(vi, vj, i, j); - rhoj = compute_interface->correct_rho(j, i); - Pj = fix_pressure->calc_pressure(rhoj); + if (interface_flag) { + if (fluidi && (!fluidj)) { + compute_interface->correct_v(vi, vj, i, j); + rhoj = compute_interface->correct_rho(j, i); + Pj = fix_pressure->calc_pressure(rhoj); - if ((chi[j] > 0.9) && (r < (h * 0.5))) - fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; + if ((chi[j] > 0.9) && (r < (h * 0.5))) + fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; - } else if ((!fluidi) && fluidj) { - compute_interface->correct_v(vj, vi, j, i); - rhoi = compute_interface->correct_rho(i, j); - Pi = fix_pressure->calc_pressure(rhoi); + } else if ((!fluidi) && fluidj) { + compute_interface->correct_v(vj, vi, j, i); + rhoi = compute_interface->correct_rho(i, j); + Pi = fix_pressure->calc_pressure(rhoi); - if (chi[i] > 0.9 && r < (h * 0.5)) - fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; + if (chi[i] > 0.9 && r < (h * 0.5)) + fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; - } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0; - rhoj = rho0; + } else if ((!fluidi) && (!fluidj)) { + rhoi = rho0; + rhoj = rho0; + } } // Repel if close to inner solid particle @@ -234,7 +246,7 @@ void PairRHEO::compute(int eflag, int vflag) sub3(vi, vj, du); //Add artificial viscous pressure if required - if (artificial_visc_flag && pair_avisc_flag){ + if (artificial_visc_flag && pair_avisc_flag) { //Interpolate velocities to midpoint and use this difference for artificial viscosity for (a = 0; a < dim; a++) for (b = 0; b < dim; b++) @@ -328,6 +340,7 @@ void PairRHEO::compute(int eflag, int vflag) } } } + if (vflag_fdotr) virial_fdotr_compute(); } @@ -421,6 +434,7 @@ void PairRHEO::setup() compute_grad = fix_rheo->compute_grad; compute_interface = fix_rheo->compute_interface; thermal_flag = fix_rheo->thermal_flag; + interface_flag = fix_rheo->interface_flag; csq = fix_rheo->csq; rho0 = fix_rheo->rho0; diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index 49aa1ad025..b30b0c3c04 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -42,6 +42,7 @@ class PairRHEO : public Pair { int artificial_visc_flag; int rho_damp_flag; int thermal_flag; + int interface_flag; void allocate(); From 55f7e9271c2049a27909858d61a357ee42ddc484 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 12 May 2023 23:34:26 -0600 Subject: [PATCH 038/104] removing old files --- src/compute_rheo_property_atom.cpp | 411 ----------------------------- src/compute_rheo_property_atom.h | 71 ----- 2 files changed, 482 deletions(-) delete mode 100644 src/compute_rheo_property_atom.cpp delete mode 100644 src/compute_rheo_property_atom.h diff --git a/src/compute_rheo_property_atom.cpp b/src/compute_rheo_property_atom.cpp deleted file mode 100644 index 3cd5d468b2..0000000000 --- a/src/compute_rheo_property_atom.cpp +++ /dev/null @@ -1,411 +0,0 @@ -// 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 authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) ------------------------------------------------------------------------ */ - -#include "compute_rheo_property_atom.h" - -#include "atom.h" -#include "atom_vec.h" -#include "compute_rheo_interface.h" -#include "compute_rheo_kernel.h" -#include "compute_rheo_surface.h" -#include "compute_rheo_vshift.h" -#include "error.h" -#include "fix_rheo.h" -#include "fix_rheo_thermal.h" -#include "memory.h" -#include "modify.h" -#include "update.h" - -#include -#include - -using namespace LAMMPS_NS; -using namespace RHEO_NS; - -/* ---------------------------------------------------------------------- */ - -ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), fix_rheo(nullptr), fix_thermal(nullptr), compute_interface(nullptr), - compute_kernel(nullptr), compute_surface(nullptr), compute_vshift(nullptr), - index(nullptr), pack_choice(nullptr) -{ - if (narg < 4) utils::missing_cmd_args(FLERR, "compute property/atom", error); - - peratom_flag = 1; - nvalues = narg - 3; - if (nvalues == 1) size_peratom_cols = 0; - else size_peratom_cols = nvalues; - - thermal_flag = interface_flag = surface_flag = shift_flag = 0; - - // parse input values - // customize a new keyword by adding to if statement - - pack_choice = new FnPtrPack[nvalues]; - index = new int[nvalues]; - - int i; - for (int iarg = 3; iarg < narg; iarg++) { - i = iarg-3; - - if (strcmp(arg[iarg],"phase") == 0) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_phase; - } else if (strcmp(arg[iarg],"chi") == 0) { - interface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_chi; - } else if (strcmp(arg[iarg],"surface") == 0) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface; - } else if (strcmp(arg[iarg],"surface/r") == 0) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_r; - } else if (strcmp(arg[iarg],"surface/divr") == 0) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_divr; - } else if (strcmp(arg[iarg],"surface/nx") == 0) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_nx; - } else if (strcmp(arg[iarg],"surface/ny") == 0) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_ny; - } else if (strcmp(arg[iarg],"surface/nz") == 0) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_nz; - } else if (strcmp(arg[iarg],"coordination") == 0) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_coordination; - } else if (strcmp(arg[iarg],"cv") == 0) { - thermal_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; - } else if (strcmp(arg[iarg],"shift/vx") == 0) { - shift_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vx; - } else if (strcmp(arg[iarg],"shift/vy") == 0) { - shift_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vy; - } else if (strcmp(arg[iarg],"shift/vz") == 0) { - shift_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vz; - } else { - index[i] = atom->avec->property_atom(arg[iarg]); - if (index[i] < 0) - error->all(FLERR, - "Invalid keyword {} for atom style {} in compute rheo/property/atom command ", - atom->get_style(), arg[iarg]); - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_atom_style; - - if (strcmp(arg[iarg],"temperature") == 0) thermal_flag = 1; - if (strcmp(arg[iarg],"heatflow") == 0) thermal_flag = 1; - if (strcmp(arg[iarg],"conductivity") == 0) thermal_flag = 1; - } - } - - nmax = 0; -} - -/* ---------------------------------------------------------------------- */ - -ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() -{ - delete[] pack_choice; - delete[] index; - memory->destroy(vector_atom); - memory->destroy(array_atom); -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::init() -{ - auto fixes = modify->get_fix_by_style("^rheo$"); - if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); - fix_rheo = dynamic_cast(fixes[0]); - - if (interface_flag && !(fix_rheo->interface_flag)) - error->all(FLERR, "Cannot request interfacial property without corresponding option in fix rheo"); - if (surface_flag && !(fix_rheo->surface_flag)) - error->all(FLERR, "Cannot request surface property without corresponding option in fix rheo"); - if (shift_flag && !(fix_rheo->shift_flag)) - error->all(FLERR, "Cannot request velocity shifting property without corresponding option in fix rheo"); - if (thermal_flag && !(fix_rheo->thermal_flag)) - error->all(FLERR, "Cannot request thermal property without fix rheo/thermal"); - - compute_interface = fix_rheo->compute_interface; - compute_kernel = fix_rheo->compute_kernel; - compute_surface = fix_rheo->compute_surface; - compute_vshift = fix_rheo->compute_vshift; - - if (thermal_flag) { - fixes = modify->get_fix_by_style("rheo/thermal"); - fix_thermal = dynamic_cast(fixes[0]); - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::compute_peratom() -{ - invoked_peratom = update->ntimestep; - - // grow vector or array if necessary - - if (atom->nmax > nmax) { - nmax = atom->nmax; - if (nvalues == 1) { - memory->destroy(vector_atom); - memory->create(vector_atom,nmax,"rheo/property/atom:vector"); - } else { - memory->destroy(array_atom); - memory->create(array_atom,nmax,nvalues,"rheo/property/atom:array"); - } - } - - // fill vector or array with per-atom values - - if (nvalues == 1) { - buf = vector_atom; - (this->*pack_choice[0])(0); - } else { - if (nmax) buf = &array_atom[0][0]; - else buf = nullptr; - for (int n = 0; n < nvalues; n++) - (this->*pack_choice[n])(n); - } -} - -/* ---------------------------------------------------------------------- - memory usage of local atom-based array -------------------------------------------------------------------------- */ - -double ComputeRHEOPropertyAtom::memory_usage() -{ - double bytes = (double)nmax * nvalues * sizeof(double); - return bytes; -} - -/* ---------------------------------------------------------------------- - one method for every keyword compute rheo/property/atom can output - the atom property is packed into buf starting at n with stride nvalues - customize a new keyword by adding a method -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_phase(int n) -{ - int *status = atom->status; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - int inverse_mask = ~PHASEMASK; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = (status[i] & inverse_mask); - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_chi(int n) -{ - double *chi = compute_interface->chi; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = chi[i]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_surface(int n) -{ - int *status = atom->status; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - int inverse_mask = ~SURFACEMASK; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = (status[i] & inverse_mask); - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_surface_r(int n) -{ - double *rsurface = compute_surface->rsurface; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = rsurface[i]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_surface_divr(int n) -{ - double *divr = compute_surface->divr; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = divr[i]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_surface_nx(int n) -{ - double **nsurface = compute_surface->nsurface; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = nsurface[i][0]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_surface_ny(int n) -{ - double **nsurface = compute_surface->nsurface; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = nsurface[i][1]; - else buf[n] = 0.0; - n += nvalues; - } -} - - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_surface_nz(int n) -{ - double **nsurface = compute_surface->nsurface; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = nsurface[i][2]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_coordination(int n) -{ - int *coordination = compute_kernel->coordination; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = coordination[i]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_cv(int n) -{ - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = fix_thermal->calc_cv(i); - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_shift_vx(int n) -{ - double **vshift = compute_vshift->vshift; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = vshift[i][0]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_shift_vy(int n) -{ - double **vshift = compute_vshift->vshift; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = vshift[i][1]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_shift_vz(int n) -{ - double **vshift = compute_vshift->vshift; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = vshift[i][2]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_atom_style(int n) -{ - atom->avec->pack_property_atom(index[n],&buf[n],nvalues,groupbit); -} diff --git a/src/compute_rheo_property_atom.h b/src/compute_rheo_property_atom.h deleted file mode 100644 index accb7e9156..0000000000 --- a/src/compute_rheo_property_atom.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- 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 COMPUTE_CLASS -// clang-format off -ComputeStyle(rheo/property/atom,ComputeRHEOPropertyAtom); -// clang-format on -#else - -#ifndef LMP_COMPUTE_RHEO_PROPERTY_ATOM_H -#define LMP_COMPUTE_RHEO_PROPERTY_ATOM_H - -#include "compute.h" - -namespace LAMMPS_NS { - -class ComputeRHEOPropertyAtom : public Compute { - public: - ComputeRHEOPropertyAtom(class LAMMPS *, int, char **); - ~ComputeRHEOPropertyAtom() override; - void init() override; - void compute_peratom() override; - double memory_usage() override; - - private: - int nvalues, nmax; - int thermal_flag, interface_flag, surface_flag, shift_flag; - int *index; - double *buf; - - typedef void (ComputeRHEOPropertyAtom::*FnPtrPack)(int); - FnPtrPack *pack_choice; // ptrs to pack functions - - void pack_phase(int); - void pack_chi(int); - void pack_surface(int); - void pack_surface_r(int); - void pack_surface_divr(int); - void pack_surface_nx(int); - void pack_surface_ny(int); - void pack_surface_nz(int); - void pack_coordination(int); - void pack_cv(int); - void pack_shift_vx(int); - void pack_shift_vy(int); - void pack_shift_vz(int); - void pack_atom_style(int); - - class FixRHEO *fix_rheo; - class FixRHEOThermal *fix_thermal; - class ComputeRHEOInterface *compute_interface; - class ComputeRHEOKernel *compute_kernel; - class ComputeRHEOSurface *compute_surface; - class ComputeRHEOVShift *compute_vshift; - -}; - -} // namespace LAMMPS_NS - -#endif -#endif From b4e1effe5f6e11b1d8d758991cf92ad52e522a2d Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 19 May 2023 13:10:39 -0600 Subject: [PATCH 039/104] Improving options for outputting gradients --- src/RHEO/compute_rheo_grad.cpp | 6 +- src/RHEO/compute_rheo_property_atom.cpp | 171 +++++++++++++----------- src/RHEO/compute_rheo_property_atom.h | 17 ++- src/RHEO/pair_rheo.cpp | 4 + 4 files changed, 112 insertions(+), 86 deletions(-) diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 92ac108377..d71e7a24ac 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -224,9 +224,9 @@ void ComputeRHEOGrad::compute_peratom() Voli = mass[itype] / rhoi; Volj = mass[jtype] / rhoj; - vij[0] = v[i][0] - v[j][0]; - vij[1] = v[i][1] - v[j][1]; - vij[2] = v[i][2] - v[j][2]; + vij[0] = vi[0] - vj[0]; + vij[1] = vi[1] - vj[1]; + vij[2] = vi[2] - vj[2]; if (rho_flag) drho = rhoi - rhoj; if (temperature_flag) dT = temperature[i] - temperature[j]; diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 880ae5d64f..3afeb03e43 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -25,12 +25,15 @@ #include "compute_rheo_kernel.h" #include "compute_rheo_surface.h" #include "compute_rheo_vshift.h" +#include "compute_rheo_grad.h" +#include "domain.h" #include "error.h" #include "fix_rheo.h" #include "fix_rheo_thermal.h" #include "memory.h" #include "modify.h" #include "update.h" +#include "utils.h" #include #include @@ -42,8 +45,8 @@ using namespace RHEO_NS; ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), fix_rheo(nullptr), fix_thermal(nullptr), compute_interface(nullptr), - compute_kernel(nullptr), compute_surface(nullptr), compute_vshift(nullptr), - index(nullptr), pack_choice(nullptr) + compute_kernel(nullptr), compute_surface(nullptr), compute_vshift(nullptr), compute_grad(nullptr), + avec_index(nullptr), pack_choice(nullptr), col_index(nullptr) { if (narg < 4) utils::missing_cmd_args(FLERR, "compute property/atom", error); @@ -58,7 +61,8 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a // customize a new keyword by adding to if statement pack_choice = new FnPtrPack[nvalues]; - index = new int[nvalues]; + avec_index = new int[nvalues]; + col_index = new int[nvalues]; int i; for (int iarg = 3; iarg < narg; iarg++) { @@ -78,32 +82,25 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a } else if (strcmp(arg[iarg],"surface/divr") == 0) { surface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_divr; - } else if (strcmp(arg[iarg],"surface/nx") == 0) { + } else if (strcmp(arg[iarg],"^surface/n") == 0) { surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_nx; - } else if (strcmp(arg[iarg],"surface/ny") == 0) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_ny; - } else if (strcmp(arg[iarg],"surface/nz") == 0) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_nz; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_n; + col_index[i] = get_vector_index(arg[iarg]); } else if (strcmp(arg[iarg],"coordination") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_coordination; } else if (strcmp(arg[iarg],"cv") == 0) { thermal_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; - } else if (strcmp(arg[iarg],"shift/vx") == 0) { + } else if (strcmp(arg[iarg],"^shift/v") == 0) { shift_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vx; - } else if (strcmp(arg[iarg],"shift/vy") == 0) { - shift_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vy; - } else if (strcmp(arg[iarg],"shift/vz") == 0) { - shift_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_vz; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_v; + col_index[i] = get_vector_index(arg[iarg]); + } else if (utils::strmatch(arg[iarg],"^gradv")) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_gradv; + col_index[i] = get_tensor_index(arg[iarg]); } else { - index[i] = atom->avec->property_atom(arg[iarg]); - if (index[i] < 0) + avec_index[i] = atom->avec->property_atom(arg[iarg]); + if (avec_index[i] < 0) error->all(FLERR, "Invalid keyword {} for atom style {} in compute rheo/property/atom command ", atom->get_style(), arg[iarg]); @@ -123,7 +120,8 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() { delete[] pack_choice; - delete[] index; + delete[] avec_index; + delete[] col_index; memory->destroy(vector_atom); memory->destroy(array_atom); } @@ -149,6 +147,7 @@ void ComputeRHEOPropertyAtom::init() compute_kernel = fix_rheo->compute_kernel; compute_surface = fix_rheo->compute_surface; compute_vshift = fix_rheo->compute_vshift; + compute_grad = fix_rheo->compute_grad; if (thermal_flag) { fixes = modify->get_fix_by_style("rheo/thermal"); @@ -281,45 +280,15 @@ void ComputeRHEOPropertyAtom::pack_surface_divr(int n) /* ---------------------------------------------------------------------- */ -void ComputeRHEOPropertyAtom::pack_surface_nx(int n) +void ComputeRHEOPropertyAtom::pack_surface_n(int n) { double **nsurface = compute_surface->nsurface; int *mask = atom->mask; int nlocal = atom->nlocal; + int index = col_index[n]; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = nsurface[i][0]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_surface_ny(int n) -{ - double **nsurface = compute_surface->nsurface; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = nsurface[i][1]; - else buf[n] = 0.0; - n += nvalues; - } -} - - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_surface_nz(int n) -{ - double **nsurface = compute_surface->nsurface; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = nsurface[i][2]; + if (mask[i] & groupbit) buf[n] = nsurface[i][index]; else buf[n] = 0.0; n += nvalues; } @@ -356,14 +325,15 @@ void ComputeRHEOPropertyAtom::pack_cv(int n) /* ---------------------------------------------------------------------- */ -void ComputeRHEOPropertyAtom::pack_shift_vx(int n) +void ComputeRHEOPropertyAtom::pack_shift_v(int n) { double **vshift = compute_vshift->vshift; int *mask = atom->mask; int nlocal = atom->nlocal; + int index = col_index[n]; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = vshift[i][0]; + if (mask[i] & groupbit) buf[n] = vshift[i][index]; else buf[n] = 0.0; n += nvalues; } @@ -371,29 +341,15 @@ void ComputeRHEOPropertyAtom::pack_shift_vx(int n) /* ---------------------------------------------------------------------- */ -void ComputeRHEOPropertyAtom::pack_shift_vy(int n) +void ComputeRHEOPropertyAtom::pack_gradv(int n) { - double **vshift = compute_vshift->vshift; + double **gradv = compute_grad->gradv; int *mask = atom->mask; int nlocal = atom->nlocal; + int index = col_index[n]; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = vshift[i][1]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - -void ComputeRHEOPropertyAtom::pack_shift_vz(int n) -{ - double **vshift = compute_vshift->vshift; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = vshift[i][2]; + if (mask[i] & groupbit) buf[n] = gradv[i][index]; else buf[n] = 0.0; n += nvalues; } @@ -403,5 +359,68 @@ void ComputeRHEOPropertyAtom::pack_shift_vz(int n) void ComputeRHEOPropertyAtom::pack_atom_style(int n) { - atom->avec->pack_property_atom(index[n],&buf[n],nvalues,groupbit); + atom->avec->pack_property_atom(avec_index[n],&buf[n],nvalues,groupbit); +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOPropertyAtom::get_tensor_index(char* option) +{ + int index; + int dim = domain->dimension; + int dim_error = 0; + + if (utils::strmatch(option,"xx$")) { + index = 0; + } else if (utils::strmatch(option,"xy$")) { + index = 1; + } else if (utils::strmatch(option,"xz$")) { + index = 2; + if (dim == 2) dim_error = 1; + } else if (utils::strmatch(option,"yx$")) { + if (dim == 2) index = 2; + else index = 3; + } else if (utils::strmatch(option,"yy$")) { + if (dim == 2) index = 3; + else index = 4; + } else if (utils::strmatch(option,"yz$")) { + index = 5; + if (dim == 2) dim_error = 1; + } else if (utils::strmatch(option,"zx$")) { + index = 6; + if (dim == 2) dim_error = 1; + } else if (utils::strmatch(option,"zy$")) { + index = 7; + if (dim == 2) dim_error = 1; + } else if (utils::strmatch(option,"zz$")) { + index = 8; + if (dim == 2) dim_error = 1; + } else { + error->all(FLERR, "Invalid compute rheo/property/atom property {}", option); + } + + if (dim_error) + error->all(FLERR, "Invalid compute rheo/property/atom property {} in 2D", option); + + return index; +} + +/* ---------------------------------------------------------------------- */ + +int ComputeRHEOPropertyAtom::get_vector_index(char* option) +{ + int index; + if (utils::strmatch(option,"x$")) { + index = 0; + } else if (utils::strmatch(option,"y$")) { + index = 1; + } else if (utils::strmatch(option,"z$")) { + if (domain->dimension == 2) + error->all(FLERR, "Invalid compute rheo/property/atom property {} in 2D", option); + index = 2; + } else { + error->all(FLERR, "Invalid compute rheo/property/atom property {}", option); + } + + return index; } diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index accb7e9156..344e249d11 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -35,7 +35,8 @@ class ComputeRHEOPropertyAtom : public Compute { private: int nvalues, nmax; int thermal_flag, interface_flag, surface_flag, shift_flag; - int *index; + int *avec_index; + int *col_index; double *buf; typedef void (ComputeRHEOPropertyAtom::*FnPtrPack)(int); @@ -46,22 +47,23 @@ class ComputeRHEOPropertyAtom : public Compute { void pack_surface(int); void pack_surface_r(int); void pack_surface_divr(int); - void pack_surface_nx(int); - void pack_surface_ny(int); - void pack_surface_nz(int); + void pack_surface_n(int); void pack_coordination(int); void pack_cv(int); - void pack_shift_vx(int); - void pack_shift_vy(int); - void pack_shift_vz(int); + void pack_shift_v(int); + void pack_gradv(int); void pack_atom_style(int); + int get_vector_index(char*); + int get_tensor_index(char*); + class FixRHEO *fix_rheo; class FixRHEOThermal *fix_thermal; class ComputeRHEOInterface *compute_interface; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOSurface *compute_surface; class ComputeRHEOVShift *compute_vshift; + class ComputeRHEOGrad *compute_grad; }; @@ -69,3 +71,4 @@ class ComputeRHEOPropertyAtom : public Compute { #endif #endif + diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 0930f28f98..8b0e2c2df6 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -257,6 +257,10 @@ void PairRHEO::compute(int eflag, int vflag) mu = MIN(0.0, mu); q = av * (-2.0 * cs * mu + mu * mu); fp_prefactor += voli * volj * q * (rhoj + rhoi); + + if (fabs(fp_prefactor*dWij[0]) > 1e-9) + if (atom->tag[i] == 643 or atom->tag[j] == 643 or atom->tag[i] == 963 or atom->tag[j] == 963) + printf("%d-%d (%d %d) fp_prefactor %g %g %g\n", atom->tag[i], atom->tag[j], i, j, fp_prefactor, dWij[0], -fp_prefactor*dWij[0]); } // -Grad[P + Q] From 6f59b7c5e081e2750dafed7530dad62a09e99fdc Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 23 May 2023 22:12:34 -0600 Subject: [PATCH 040/104] Fixing misc bugs with interfaces --- doc/src/fix_rheo.rst | 2 +- src/RHEO/compute_rheo_grad.cpp | 7 ++-- src/RHEO/compute_rheo_interface.cpp | 16 ++++---- src/RHEO/fix_rheo.cpp | 8 +++- src/RHEO/fix_rheo_pressure.cpp | 19 ++-------- src/RHEO/pair_rheo.cpp | 58 +++++++++++++++++++++++++---- src/RHEO/pair_rheo.h | 2 + 7 files changed, 77 insertions(+), 35 deletions(-) diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index 7aaab48f54..5eae617419 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -23,7 +23,7 @@ Syntax *surface/detection* values = *sdstyle* *limit* *sdstyle* = *coordination* or *divergence* *limit* = threshold for surface particles (unitless) - *interface/reconstruction* values = none, reconstructs interfaces with solid particles + *interface/reconstruct* values = none, reconstructs interfaces with solid particles *rho/sum* values = none, uses the kernel to compute the density of particles *density* values = *rho0* (density) *sound/squared* values = *csq* (velocity\^2) diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index d71e7a24ac..7d0b1d5b14 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -179,9 +179,6 @@ void ComputeRHEOGrad::compute_peratom() xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; - vi[0] = v[i][0]; - vi[1] = v[i][1]; - vi[2] = v[i][2]; itype = type[i]; fluidi = !(status[i] & PHASECHECK); jlist = firstneigh[i]; @@ -203,6 +200,10 @@ void ComputeRHEOGrad::compute_peratom() rhoi = rho[i]; rhoj = rho[j]; + vi[0] = v[i][0]; + vi[1] = v[i][1]; + vi[2] = v[i][2]; + vj[0] = v[j][0]; vj[1] = v[j][1]; vj[2] = v[j][2]; diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index ea4916087f..8cd69b49e3 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -170,9 +170,10 @@ void ComputeRHEOInterface::compute_peratom() chi[i] += w; } else { if (!fluidi) { - dot = (-fp_store[0][j] + fp_store[0][i]) * delx; - dot += (-fp_store[1][j] + fp_store[1][i]) * dely; - dot += (-fp_store[2][j] + fp_store[2][i]) * delz; + dot = (-fp_store[j][0] + fp_store[i][0]) * delx; + dot += (-fp_store[j][1] + fp_store[i][1]) * dely; + dot += (-fp_store[j][2] + fp_store[i][2]) * delz; + rho[i] += w * (csq * (rho[j] - rho0) - rho[j] * dot); normwf[i] += w; } @@ -184,9 +185,10 @@ void ComputeRHEOInterface::compute_peratom() chi[j] += w; } else { if (!fluidj) { - dot = (-fp_store[0][i] + fp_store[0][j]) * delx; - dot += (-fp_store[1][i] + fp_store[1][j]) * dely; - dot += (-fp_store[2][i] + fp_store[2][j]) * delz; + dot = (-fp_store[i][0] + fp_store[j][0]) * delx; + dot += (-fp_store[i][1] + fp_store[j][1]) * dely; + dot += (-fp_store[i][2] + fp_store[j][2]) * delz; + rho[j] += w * (csq * (rho[i] - rho0) + rho[i] * dot); normwf[j] += w; } @@ -342,7 +344,7 @@ void ComputeRHEOInterface::store_forces() // If forces are overwritten by a fix, there are no pressure forces // so just normalize auto fixlist = modify->get_fix_by_style("setforce"); - if (fixlist.size() == 0) { + if (fixlist.size() != 0) { for (const auto &fix : fixlist) { for (int i = 0; i < atom->nlocal; i++) { minv = 1.0 / mass[type[i]]; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index fd436cab6e..cecd3183fd 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -105,7 +105,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : } iarg += 2; - } else if (strcmp(arg[iarg],"interface/reconstruction") == 0) { + } else if (strcmp(arg[iarg],"interface/reconstruct") == 0) { interface_flag = 1; } else if (strcmp(arg[iarg],"rho/sum") == 0) { rhosum_flag = 1; @@ -360,6 +360,7 @@ void FixRHEO::initial_integrate(int /*vflag*/) } if (!rhosum_flag) { + if (status[i] & PHASECHECK) continue; for (a = 0; a < dim; a++) { rho[i] += dtv * vshift[i][a] * gradr[i][a]; } @@ -380,7 +381,10 @@ void FixRHEO::pre_force(int /*vflag*/) compute_grad->forward_fields(); // also forwards v and rho for chi compute_kernel->compute_peratom(); - if (interface_flag) compute_interface->compute_peratom(); + if (interface_flag) { + // Note on first setup, have no forces for pressure to reference + compute_interface->compute_peratom(); + } compute_grad->compute_peratom(); compute_grad->forward_gradients(); diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index ff206937f4..84d21ee872 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -122,20 +122,9 @@ void FixRHEOPressure::pre_force(int /*vflag*/) int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - if (pressure_style == LINEAR) { - pressure[i] = csq * (rho[i] - rho0); - } else if (pressure_style == CUBIC) { - dr = rho[i] - rho0; - pressure[i] = csq * (dr + c_cubic * dr * dr * dr); - } else if (pressure_style == TAITWATER) { - rho_ratio = rho[i] / rho0inv; - rr3 = rho_ratio * rho_ratio * rho_ratio; - pressure[i] = csq * rho0 * SEVENTH * (rr3 * rr3 * rho_ratio - 1.0); - } - } - } + for (i = 0; i < nlocal; i++) + if (mask[i] & groupbit) + pressure[i] = calc_pressure(rho[i]); if (comm_forward) comm->forward_comm(this); } @@ -186,5 +175,5 @@ double FixRHEOPressure::calc_pressure(double rho) rr3 = rho_ratio * rho_ratio * rho_ratio; p = csq * rho0 * SEVENTH * (rr3 * rr3 * rho_ratio - 1.0); } - return rho; + return p; } diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 8b0e2c2df6..0feb6af445 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -56,6 +56,8 @@ PairRHEO::PairRHEO(LAMMPS *lmp) : artificial_visc_flag = 0; rho_damp_flag = 0; thermal_flag = 0; + + comm_reverse = 3; } /* ---------------------------------------------------------------------- */ @@ -79,7 +81,7 @@ void PairRHEO::compute(int eflag, int vflag) double rhoi, rhoj, voli, volj, Pi, Pj, etai, etaj, kappai, kappaj; double mu, q, fp_prefactor, drho_damp, fmag, psi_ij, Fij; double *dWij, *dWji, *dW1ij, *dW1ji; - double dx[3], du[3], fv[3], dfp[3], fsolid[3], ft[3], vi[3], vj[3]; + double dx[3], du[3], dv[3], fv[3], dfp[3], fsolid[3], ft[3], vi[3], vj[3]; int *ilist, *jlist, *numneigh, **firstneigh; double imass, jmass, rsq, r, rinv; @@ -113,6 +115,12 @@ void PairRHEO::compute(int eflag, int vflag) if (compute_interface) { fp_store = compute_interface->fp_store; chi = compute_interface->chi; + + for (i = 0; i < atom->nmax; i++) { + fp_store[i][0] = 0.0; + fp_store[i][1] = 0.0; + fp_store[i][2] = 0.0; + } } inum = list->inum; @@ -243,11 +251,12 @@ void PairRHEO::compute(int eflag, int vflag) //Hydrostatic pressure forces fp_prefactor = voli * volj * (Pj + Pi); - sub3(vi, vj, du); + sub3(vi, vj, dv); //Add artificial viscous pressure if required if (artificial_visc_flag && pair_avisc_flag) { //Interpolate velocities to midpoint and use this difference for artificial viscosity + copy3(dv, du); for (a = 0; a < dim; a++) for (b = 0; b < dim; b++) du[a] -= 0.5 * (gradv[i][a * dim + b] + gradv[j][a * dim + b]) * dx[b]; @@ -257,10 +266,6 @@ void PairRHEO::compute(int eflag, int vflag) mu = MIN(0.0, mu); q = av * (-2.0 * cs * mu + mu * mu); fp_prefactor += voli * volj * q * (rhoj + rhoi); - - if (fabs(fp_prefactor*dWij[0]) > 1e-9) - if (atom->tag[i] == 643 or atom->tag[j] == 643 or atom->tag[i] == 963 or atom->tag[j] == 963) - printf("%d-%d (%d %d) fp_prefactor %g %g %g\n", atom->tag[i], atom->tag[j], i, j, fp_prefactor, dWij[0], -fp_prefactor*dWij[0]); } // -Grad[P + Q] @@ -270,7 +275,7 @@ void PairRHEO::compute(int eflag, int vflag) for (a = 0; a < dim; a++) { fv[a] = 0.0; for (b = 0; b < dim; b++) - fv[a] += du[a] * dx[b] * dWij[b]; + fv[a] += dv[a] * dx[b] * dWij[b]; fv[a] *= (etai + etaj) * voli * volj * rinv * rinv; } @@ -346,6 +351,11 @@ void PairRHEO::compute(int eflag, int vflag) } if (vflag_fdotr) virial_fdotr_compute(); + + if (compute_interface) { + comm->reverse_comm(this); + comm->forward_comm(this); + } } /* ---------------------------------------------------------------------- @@ -476,3 +486,37 @@ double PairRHEO::init_one(int i, int j) return h; } + +/* ---------------------------------------------------------------------- */ + +int PairRHEO::pack_reverse_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double **fp_store = compute_interface->fp_store; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = fp_store[i][0]; + buf[m++] = fp_store[i][1]; + buf[m++] = fp_store[i][2]; + } + + return m; +} + +/* ---------------------------------------------------------------------- */ + +void PairRHEO::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i, j, k, m; + double **fp_store = compute_interface->fp_store; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + fp_store[j][0] += buf[m++]; + fp_store[j][1] += buf[m++]; + fp_store[j][2] += buf[m++]; + } +} diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index b30b0c3c04..cb2227c8d6 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -33,6 +33,8 @@ class PairRHEO : public Pair { void coeff(int, char **) override; void setup() override; double init_one(int, int) override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; protected: double h, csq, rho0; // From fix RHEO From 4ae41edee791755613786a91b4058084af5b4332 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 23 Jun 2023 14:12:59 -0600 Subject: [PATCH 041/104] Fixing order of correct_v --- .../PACKAGES/rheo/dam-break/in.rheo.dam.break | 87 +++++++++++++++++++ .../rheo/poiseuille/in.rheo.poiseuille | 16 ++-- .../rheo/taylor-green/in.rheo.taylor.green | 74 ++++++++++++++++ src/RHEO/compute_rheo_grad.cpp | 2 + src/RHEO/compute_rheo_surface.cpp | 4 +- src/RHEO/compute_rheo_vshift.cpp | 2 + src/RHEO/fix_rheo.cpp | 2 +- src/RHEO/pair_rheo.cpp | 2 + 8 files changed, 177 insertions(+), 12 deletions(-) create mode 100644 examples/PACKAGES/rheo/dam-break/in.rheo.dam.break create mode 100644 examples/PACKAGES/rheo/taylor-green/in.rheo.taylor.green diff --git a/examples/PACKAGES/rheo/dam-break/in.rheo.dam.break b/examples/PACKAGES/rheo/dam-break/in.rheo.dam.break new file mode 100644 index 0000000000..207fd6885e --- /dev/null +++ b/examples/PACKAGES/rheo/dam-break/in.rheo.dam.break @@ -0,0 +1,87 @@ +# ------ 2D dam break ------ # + +dimension 2 +units lj +atom_style rheo +boundary f s p +comm_modify vel yes +newton off +comm_style tiled + + +# ------ Create simulation box ------ # + +variable sf equal 0.05 +variable n equal 1.0/(${sf}^2) +variable cut equal 3.0*${sf} + +region box block -1 55 -1 20 -0.01 0.01 units box +create_box 2 box +lattice sq ${n} + +region left_wall block -1 0 EDGE EDGE -0.01 0.01 units box +region right_wall block 53.66 EDGE EDGE EDGE -0.01 0.01 units box +region bot_wall block 0.01 53.65 -1 0 -0.01 0.01 units box +region interior block 0.01 10 0.01 20 -0.01 0.01 units box + +create_atoms 1 region interior +create_atoms 2 region left_wall +create_atoms 2 region right_wall +create_atoms 2 region bot_wall + +group fluid type 1 +group static_wall type 2 +group dyn_wall type 3 +group rig union static_wall dyn_wall + + +# ------ Model parameters ------ # + +variable rho0 equal 1.0 +variable mp equal ${rho0}/${n} +variable cs equal 10 +variable zeta equal 1 +variable Dr equal 0.1*${cut}*${cs} +variable dt_max equal 0.1*${cut}/${cs}/3 +variable g equal 0.0245 +variable fext equal ${g}/${n} +variable eta equal 0.05 + +mass * ${mp} +variable d0 atom (${rho0}*${g}*(20-y)/${cs}/${cs})+${rho0} +set group all rheo/rho ${rho0} +set group fluid rheo/rho v_d0 + +set group all rheo/status 0 +set group rig rheo/status 2 + +timestep ${dt_max} + +pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} +pair_coeff * * + + +# ------ Fixes & computes ------ # + +fix 1 all rheo ${cut} RK1 32 shift surface/detection coordination 26 +fix 2 all rheo/viscosity constant ${eta} +fix 3 all rheo/pressure linear +fix 4 rig setforce 0.0 0.0 0.0 +fix 5 fluid addforce 0.0 -${fext} 0.0 +fix 6 all balance 1000 1.1 rcb + +compute 1 all rheo/property/atom rho phase surface + + +# ------ Output & Run ------ # + +thermo 10 +thermo_style custom step time ke press + +variable skin equal 0.2*${cut} +neighbor ${skin} bin +neigh_modify one 5000 + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_1[*] + +run 400000 diff --git a/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille b/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille index d0f966c2ce..6f5ad91e73 100644 --- a/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille +++ b/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille @@ -1,3 +1,5 @@ +# ------ 2D Poiseuille flow ------ # + dimension 2 units lj atom_style rheo @@ -5,16 +7,12 @@ boundary p p p comm_modify vel yes -# ------ Particle Lattice/Resolution Parameters ------ # +# ------ Create simulation box ------ # -variable L equal 10 variable sf equal 0.2 variable n equal 1.0/(${sf}^2) variable cut equal 3.5*${sf} - -# ------ Create simulation box ------ # - region box block 0 20 -10 10 -0.01 0.01 units box create_box 2 box lattice sq ${n} @@ -46,11 +44,11 @@ variable eta equal 0.1 variable dt_max equal 0.1*${cut}/${cs}/3 variable Dr equal 0.05*${cut}*${cs} -mass 1 ${mp} -mass 2 ${mp} +mass * ${mp} set group all rheo/rho ${rho0} set group all rheo/status 0 set group rig rheo/status 2 + timestep ${dt_max} pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} @@ -71,13 +69,13 @@ compute 1 all rheo/property/atom rho phase # ------ Output & Run ------ # thermo 200 -thermo_style custom step time temp press +thermo_style custom step time ke press variable skin equal 0.2*${cut} neighbor ${skin} bin neigh_modify one 5000 -dump 1 all custom 200 atomDump id type x y vx vy fx fy c_1[*] +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_1[*] run 20000 diff --git a/examples/PACKAGES/rheo/taylor-green/in.rheo.taylor.green b/examples/PACKAGES/rheo/taylor-green/in.rheo.taylor.green new file mode 100644 index 0000000000..5367ceef13 --- /dev/null +++ b/examples/PACKAGES/rheo/taylor-green/in.rheo.taylor.green @@ -0,0 +1,74 @@ +# ------ 2D Taylor Green vortex ------ # + +dimension 2 +units lj +atom_style rheo +boundary p p p +comm_modify vel yes +newton off + + +# ------ Create simulation box ------ # + +variable sf equal 0.1 +variable n equal 1.0/(${sf}^2) +variable cut equal 3.5*${sf} + +region box block 0 10 0 10 -0.01 0.01 units box +create_box 1 box +lattice sq ${n} + +create_atoms 1 region box + +variable dr equal 0.1*${sf} +displace_atoms all random ${dr} ${dr} 0 135414 units box + + +# ------ Model parameters ------ # + +variable rho0 equal 1.0 +variable mp equal ${rho0}/${n} +variable cs equal 1.0 +variable eta equal 0.05 +variable zeta equal 1 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable Dr equal 0.1*${cut}*${cs} + +mass * ${mp} +set group all rheo/rho ${rho0} +set group all rheo/status 0 + +variable u0 equal 0.05 +variable uy atom ${u0}*sin(2*PI*x/lx)*cos(2*PI*y/ly) +variable ux atom -${u0}*sin(2*PI*y/ly)*cos(2*PI*x/ly) +variable d0 atom ${rho0}-${u0}*${u0}*${rho0}*0.25*(cos(4*PI*x/lx)+cos(4*PI*y/ly))/${cs}/${cs} + +velocity all set v_ux v_uy 0.0 units box + +timestep ${dt_max} + +pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} +pair_coeff * * + + +# ------ Fixes & computes ------ # + +fix 1 all rheo ${cut} quintic 0 shift +fix 2 all rheo/viscosity constant ${eta} +fix 3 all rheo/pressure linear + +compute 1 all rheo/property/atom rho phase + + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press + +variable skin equal 0.2*${cut} +neighbor ${skin} bin +neigh_modify one 10000 #increase number of allowed neighbors + +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_1[*] + +run 10000 \ No newline at end of file diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 7d0b1d5b14..369bf11e0d 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -212,9 +212,11 @@ void ComputeRHEOGrad::compute_peratom() if (interface_flag) { if (fluidi && (!fluidj)) { compute_interface->correct_v(vi, vj, i, j); + //compute_interface->correct_v(vj, vi, j, i); rhoj = compute_interface->correct_rho(j, i); } else if ((!fluidi) && fluidj) { compute_interface->correct_v(vj, vi, j, i); + //compute_interface->correct_v(vi, vj, i, j); rhoi = compute_interface->correct_rho(i, j); } else if ((!fluidi) && (!fluidj)) { rhoi = rho0; diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index f6b93ee551..4b0745abd3 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -126,7 +126,7 @@ void ComputeRHEOSurface::compute_peratom() { int i, j, ii, jj, inum, jnum, a, b, itype, jtype, fluidi, fluidj; double xtmp, ytmp, ztmp, rsq, Voli, Volj, rhoi, rhoj, wp; - double *dWij, *dWji, dx[3]; + double dWij[3], dWji[3], dx[3]; int *ilist, *jlist, *numneigh, **firstneigh; int nlocal = atom->nlocal; @@ -214,7 +214,7 @@ void ComputeRHEOSurface::compute_peratom() Voli = mass[itype] / rhoi; Volj = mass[jtype] / rhoj; - wp = compute_kernel->calc_dw_quintic(i, j, dx[0], dx[1], dx[2], sqrt(rsq),dWij, dWji); + wp = compute_kernel->calc_dw_quintic(i, j, dx[0], dx[1], dx[2], sqrt(rsq), dWij, dWji); for (a = 0; a < dim; a++){ divr[i] -= dWij[a] * dx[a] * Volj; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 0521ff16c0..9741026324 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -171,9 +171,11 @@ void ComputeRHEOVShift::compute_peratom() if (interface_flag) { if (fluidi && (!fluidj)) { compute_interface->correct_v(vi, vj, i, j); + //compute_interface->correct_v(vj, vi, j, i); rhoj = compute_interface->correct_rho(j,i); } else if ((!fluidi) && fluidj) { compute_interface->correct_v(vj, vi, j, i); + //compute_interface->correct_v(vi, vj, i, j); rhoi = compute_interface->correct_rho(i,j); } else if ((!fluidi) && (!fluidj)) { rhoi = 1.0; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index cecd3183fd..0420a0f23f 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -154,7 +154,7 @@ void FixRHEO::post_constructor() if (rhosum_flag) { compute_rhosum = dynamic_cast(modify->add_compute( - "rheo_rho_sum all RHEO/RHO/SUM")); + "rheo_rhosum all RHEO/RHO/SUM")); compute_rhosum->fix_rheo = this; } diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 0feb6af445..e22715eab1 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -207,6 +207,7 @@ void PairRHEO::compute(int eflag, int vflag) if (interface_flag) { if (fluidi && (!fluidj)) { compute_interface->correct_v(vi, vj, i, j); + //compute_interface->correct_v(vj, vi, j, i); rhoj = compute_interface->correct_rho(j, i); Pj = fix_pressure->calc_pressure(rhoj); @@ -215,6 +216,7 @@ void PairRHEO::compute(int eflag, int vflag) } else if ((!fluidi) && fluidj) { compute_interface->correct_v(vj, vi, j, i); + //compute_interface->correct_v(vi, vj, i, j); rhoi = compute_interface->correct_rho(i, j); Pi = fix_pressure->calc_pressure(rhoi); From 71abebb1d7173a5fe0b1c38903f65a3ebc4b7905 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 16 Jul 2023 16:26:57 -0600 Subject: [PATCH 042/104] debugging surface compute --- doc/src/fix_rheo.rst | 3 ++- src/RHEO/compute_rheo_surface.cpp | 24 ++++++++++++++---------- src/RHEO/compute_rheo_surface.h | 2 +- src/RHEO/fix_rheo.cpp | 4 +++- src/RHEO/fix_rheo.h | 2 +- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index 5eae617419..25e171a1b9 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -20,9 +20,10 @@ Syntax *shift* values = none, turns on velocity shifting *thermal* values = none, turns on thermal evolution - *surface/detection* values = *sdstyle* *limit* + *surface/detection* values = *sdstyle* *limit* *limit/splash* *sdstyle* = *coordination* or *divergence* *limit* = threshold for surface particles (unitless) + *limit/splash* = threshold for splash particles (unitless) *interface/reconstruct* values = none, reconstructs interfaces with solid particles *rho/sum* values = none, uses the kernel to compute the density of particles *density* values = *rho0* (density) diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 4b0745abd3..230bca8219 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -82,6 +82,8 @@ void ComputeRHEOSurface::init() threshold_style = fix_rheo->surface_style; threshold_divr = fix_rheo->divr_surface; threshold_z = fix_rheo->zmin_surface; + threshold_splash = fix_rheo->zmin_splash; + interface_flag = fix_rheo->interface_flag; cutsq = cut * cut; @@ -202,13 +204,15 @@ void ComputeRHEOSurface::compute_peratom() rhoj = rho[j]; // Add corrections for walls - if (fluidi && (!fluidj)) { - rhoj = compute_interface->correct_rho(j, i); - } else if ((!fluidi) && fluidj) { - rhoi = compute_interface->correct_rho(i, j); - } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0; - rhoj = rho0; + if (interface_flag) { + if (fluidi && (!fluidj)) { + rhoj = compute_interface->correct_rho(j, i); + } else if ((!fluidi) && fluidj) { + rhoi = compute_interface->correct_rho(i, j); + } else if ((!fluidi) && (!fluidj)) { + rhoi = rho0; + rhoj = rho0; + } } Voli = mass[itype] / rhoi; @@ -262,7 +266,7 @@ void ComputeRHEOSurface::compute_peratom() if (divr[i] < threshold_divr) { status[i] |= STATUS_SURFACE; rsurface[i] = 0.0; - if (coordination[i] < threshold_z) + if (coordination[i] < threshold_splash) status[i] |= STATUS_SPLASH; } } @@ -272,10 +276,10 @@ void ComputeRHEOSurface::compute_peratom() if (mask[i] & groupbit) { status[i] |= STATUS_BULK; rsurface[i] = cut; - if (coordination[i] < threshold_divr) { + if (coordination[i] < threshold_z) { status[i] |= STATUS_SURFACE; rsurface[i] = 0.0; - if (coordination[i] < threshold_z) + if (coordination[i] < threshold_splash) status[i] |= STATUS_SPLASH; } } diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index 220f8beb6d..1d1cdba3fa 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -41,7 +41,7 @@ class ComputeRHEOSurface : public Compute { private: double cut, cutsq, rho0, threshold_divr; - int surface_style, nmax_store, threshold_z; + int surface_style, nmax_store, threshold_z, threshold_splash, interface_flag; double **B, **gradC; int threshold_style, comm_stage; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 0420a0f23f..339d7f5ac8 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -97,14 +97,16 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg + 1], "coordination")) { surface_style = COORDINATION; zmin_surface = utils::inumeric(FLERR,arg[iarg + 2],false,lmp); + zmin_splash = utils::inumeric(FLERR,arg[iarg + 3],false,lmp); } else if (strcmp(arg[iarg + 1], "divergence")) { surface_style = DIVR; divr_surface = utils::numeric(FLERR,arg[iarg + 2],false,lmp); + zmin_splash = utils::inumeric(FLERR,arg[iarg + 3],false,lmp); } else { error->all(FLERR,"Illegal surface/detection option in fix rheo, {}", arg[iarg + 1]); } - iarg += 2; + iarg += 3; } else if (strcmp(arg[iarg],"interface/reconstruct") == 0) { interface_flag = 1; } else if (strcmp(arg[iarg],"rho/sum") == 0) { diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 0dbc8db78b..96f4b6f502 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -40,7 +40,7 @@ class FixRHEO : public Fix { // Model parameters double h, cut, rho0, csq; - int zmin_kernel, zmin_surface; + int zmin_kernel, zmin_surface, zmin_splash; int kernel_style, surface_style; double divr_surface; From 583917b194a50effe37047db10de2346be9b0562 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 25 Sep 2023 09:39:29 -0600 Subject: [PATCH 043/104] Drafting structure of solidification bond creation --- src/RHEO/fix_rheo.h | 3 +- src/RHEO/fix_rheo_thermal.cpp | 118 +++++++++++++++++++++++++++++++++- src/RHEO/fix_rheo_thermal.h | 10 +++ 3 files changed, 128 insertions(+), 3 deletions(-) diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 0dbc8db78b..9acf30e4fc 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -86,7 +86,8 @@ namespace RHEO_NS { // Temporary status options - reset in preforce STATUS_NO_SHIFT = 1 << 6, STATUS_NO_INTEGRATION = 1 << 7, - STATUS_FREEZING = 1 << 8 + STATUS_FREEZING = 1 << 8, + STATUS_MELTING = 1 << 9 }; // Masks and their inverses diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index de88b4f8d0..837cea6de4 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -29,6 +29,8 @@ #include "math_extra.h" #include "memory.h" #include "modify.h" +#include "neigh_list.h" +#include "pair.h" #include "update.h" using namespace LAMMPS_NS; @@ -47,6 +49,8 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : Tc_style = NONE; cv_style = NONE; conductivity_style = NONE; + cut_bond = 0; + comm_forward = 0; int ntypes = atom->ntypes; int iarg = 3; @@ -95,7 +99,7 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : } } else if (strcmp(arg[iarg],"Tfreeze") == 0) { // T freeze arguments - if (iarg+1 >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); + if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); if (strcmp(arg[iarg + 1],"constant") == 0) { if (iarg + 2 >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); Tc_style = CONSTANT; @@ -105,7 +109,7 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg + 1],"type") == 0) { if (iarg + 1 + ntypes >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); Tc_style = TYPE; - memory->create(Tc_type,ntypes + 1,"rheo_thermal:Tc_type"); + memory->create(Tc_type, ntypes + 1, "rheo_thermal:Tc_type"); for (int i = 1; i <= ntypes; i++) { Tc_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i],false,lmp); if (Tc_type[i] < 0.0) error->all(FLERR,"The melting temperature must be positive"); @@ -114,6 +118,12 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); } + } else if (strcmp(arg[iarg],"react") == 0) { + if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for react option"); + cut_bond = utils::numeric(FLERR, arg[iarg + 1], false, lmp); + comm_forward = 1; + if (cut_bond <= 0.0) error->all(FLERR, "Illegal value for bond lengths"); + iarg += 1; } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg]); } @@ -172,6 +182,31 @@ void FixRHEOThermal::init() error->all(FLERR,"fix rheo/thermal command requires atom property heatflow"); if (atom->conductivity_flag != 1) error->all(FLERR,"fix rheo/thermal command requires atom property conductivity"); + + + if (cut_bond > 0.0) { + if (!force->bond) error->all(FLERR,"Must define a bond style to use reactive bond generation with fix rheo/thermal"); + if (!atom->avec->bonds_allow) error->all(FLERR, "Reactive bond generation in fix rheo/thermal requires atom bonds"); + + // all special weights must be 1.0, RHEO pair styles filter by status + if (force->special_lj[0] != 1.0 || force->special_lj[1] != 1.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0) + error->all(FLERR, "Reactive bond generation in fix rheo/thermal requires special weights of 1.0"); + + // need a half neighbor list, built only when particles freeze + auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); + req->set_cutoff(cut_bond); + + // find instances of bond history to delete data + histories = modify->get_fix_by_style("BOND_HISTORY"); + n_histories = histories.size(); + } +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; } /* ---------------------------------------------------------------------- */ @@ -180,6 +215,9 @@ void FixRHEOThermal::setup_pre_force(int /*vflag*/) { fix_rheo->thermal_fix_defined = 1; + if (modify->get_fix_by_style("rheo/thermal").size() > 1) + error->all(FLERR, "More than one fix rheo/thermal defined"); + post_neighbor(); pre_force(0); } @@ -228,6 +266,8 @@ void FixRHEOThermal::post_integrate() double cvi, Tci, Ti; + int phase_changes = 0; + //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { if (mask[i] & groupbit) { @@ -248,6 +288,8 @@ void FixRHEOThermal::post_integrate() // If solid, melt if (status[i] & STATUS_SOLID) { status[i] &= PHASEMASK; + status[i] |= STATUS_MELTING; + phase_changes += 1; } } else { // If fluid, freeze @@ -255,11 +297,22 @@ void FixRHEOThermal::post_integrate() status[i] &= PHASEMASK; status[i] |= STATUS_SOLID; status[i] |= STATUS_FREEZING; + phase_changes += 1; } } } } } + + if (cut_bond > 0 && phase_changes != 0) { + // Forward status then delete/create bonds + comm->forward_comm(this); + + for (int i = 0; i < atom->nlocal; i++) { + if (status[i] & STATUS_MELTING) delete_bonds(i); + if (status[i] & STATUS_FREEZING) create_bonds(i); + } + } } /* ---------------------------------------------------------------------- @@ -324,6 +377,36 @@ void FixRHEOThermal::reset_dt() /* ---------------------------------------------------------------------- */ +void FixRHEOThermal::break_bonds(int i) +{ + int m, k, j; + + int *status = atom->status; + int **bond_type = atom->bond_type; + tagint **bond_atom = atom->bond_atom; + int *num_bond = atom->num_bond; + + for (m = 0; m < num_bond[i]; m++) { + j = bond_atom[i][k]; + if (n_histories > 0) + for (auto &ihistory: histories) + dynamic_cast(ihistory)->delete_history(i,num_bond[i]-1); + + Search for bond in js list and delete + } + + num_bond[i] = 0; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::create_bonds(int i) +{ + +} + +/* ---------------------------------------------------------------------- */ + double FixRHEOThermal::calc_cv(int i) { if (cv_style == CONSTANT) { @@ -332,3 +415,34 @@ double FixRHEOThermal::calc_cv(int i) return(cv_type[atom->type[i]]); } } + + +/* ---------------------------------------------------------------------- */ + +int FixRHEOThermal::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i, j, k, m; + int *status = atom->status; + m = 0; + + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = ubuf(status[j]).d; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last; + int *status = atom->status; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + status[i] = (int) ubuf(buf[m++]).i + } +} diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index a27ad98a8c..f732a2d728 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -30,12 +30,15 @@ class FixRHEOThermal : public Fix { ~FixRHEOThermal() override; int setmask() override; void init() override; + void init_list(int, class NeighList *) override; void setup_pre_force(int) override; void initial_integrate(int) override; void post_integrate() override; void post_neighbor() override; void pre_force(int) override; void final_integrate() override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; void reset_dt() override; double calc_cv(int); @@ -44,15 +47,22 @@ class FixRHEOThermal : public Fix { double *Tc_type, Tc; double *kappa_type, kappa; double dtf, dtv; + double cut_bond; int Tc_style; int cv_style; int conductivity_style; + class NeighList *list; + + int n_histories; + const std::vector histories; class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; class ComputeRHEOVShift *compute_vshift; void grow_array(int); + void break_bonds(int); + void create_bonds(int); }; } // namespace LAMMPS_NS From 3cae238eb5bdc26ade047a4789c7e157fbf33cfa Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 26 Sep 2023 09:07:44 -0600 Subject: [PATCH 044/104] Finish drafting bond creation/deletion --- src/RHEO/fix_rheo_thermal.cpp | 82 ++++++++++++++++++++++++++++++++--- src/RHEO/fix_rheo_thermal.h | 1 + 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 837cea6de4..f6fa95b3b7 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -25,6 +25,8 @@ #include "domain.h" #include "error.h" #include "fix_rheo.h" +#include "fix_bond_history.h" +#include "fix_update_special_bonds.h" #include "force.h" #include "math_extra.h" #include "memory.h" @@ -42,7 +44,7 @@ enum {NONE, CONSTANT, TYPE}; FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), fix_rheo(nullptr), compute_grad(nullptr), compute_vshift(nullptr), - Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr) + Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr), fix_update_special_bonds(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -188,9 +190,12 @@ void FixRHEOThermal::init() if (!force->bond) error->all(FLERR,"Must define a bond style to use reactive bond generation with fix rheo/thermal"); if (!atom->avec->bonds_allow) error->all(FLERR, "Reactive bond generation in fix rheo/thermal requires atom bonds"); - // all special weights must be 1.0, RHEO pair styles filter by status - if (force->special_lj[0] != 1.0 || force->special_lj[1] != 1.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0) - error->all(FLERR, "Reactive bond generation in fix rheo/thermal requires special weights of 1.0"); + // all special weights must be 1.0 (no special neighbors) or there must be an instance of fix update/special/bonds + if (force->special_lj[0] != 1.0 || force->special_lj[1] != 1.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0) { + auto fixes = modify->get_fix_by_style("UPDATE_SPECIAL_BONDS"); + if (fixes.size == 0) error->all(FLERR, "Without fix update/special/bonds, reactive bond generation in fix rheo/thermal requires special weights of 1.0"); + fix_update_special_bonds = dynamic_cast(fixes[0]); + } // need a half neighbor list, built only when particles freeze auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); @@ -379,20 +384,40 @@ void FixRHEOThermal::reset_dt() void FixRHEOThermal::break_bonds(int i) { - int m, k, j; + int m, n, nmax, j; + tagint *tag = atom->tag; int *status = atom->status; int **bond_type = atom->bond_type; tagint **bond_atom = atom->bond_atom; int *num_bond = atom->num_bond; for (m = 0; m < num_bond[i]; m++) { - j = bond_atom[i][k]; + j = bond_atom[i][m]; if (n_histories > 0) for (auto &ihistory: histories) dynamic_cast(ihistory)->delete_history(i,num_bond[i]-1); - Search for bond in js list and delete + if (fix_update_special_bonds) fix_update_special_bonds->add_broken_bond(i,j); + + if (j >= atom->nlocal) continue; + + for (n = 0; n < num_bond[j]; n++) { + if (bond_atom[j][n] == tag[i]) { + bond_type[j][n] = 0; + nmax = num_bond[j] - 1; + bond_type[j][n] = bond_type[j][nmax]; + bond_atom[j][n] = bond_atom[j][nmax]; + if (n_histories > 0) { + for (auto &ihistory: histories) { + dynamic_cast(ihistory)->shift_history(j, n, nmax); + dynamic_cast(ihistory)->delete_history(j, nmax); + } + } + num_bond[j]--; + break; + } + } } num_bond[i] = 0; @@ -402,7 +427,50 @@ void FixRHEOThermal::break_bonds(int i) void FixRHEOThermal::create_bonds(int i) { + int i1, i2, j, jj, jnum; + int *jlist, *numneigh, **firstneigh; + double rsq; + int nlocal = atom->nlocal; + + tagint *tag = atom->tag; + double *x = atom->x; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + int *status = atom->status; + int **bond_type = atom->bond_type; + tagint **bond_atom = atom->bond_atom; + int *num_bond = atom->num_bond; + + double xtmp = x[i][0]; + double ytmp = x[i][1]; + double ztmp = x[i][2]; + double delx, dely, delz; + + // Loop through atoms of owned atoms + jlist = firstneigh[i]; + jnum = numneigh[i]; + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= SPECIALMASK; + if (status[j] & STATUS_SOLID) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cut_bond) continue; + + if (!newton_bond || tag[i] < tag[j]) { + if (num_bond[i] == atom->bond_per_atom) + error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/thermal"); + if (fix_update_special_bonds) fix_update_special_bonds->add_created_bond(i,j); + bond_type[i][num_bond[i]] = btype; + bond_atom[i][num_bond[i]] = tag[j]; + num_bond[i]++; + } + } + } } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index f732a2d728..13b743b939 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -59,6 +59,7 @@ class FixRHEOThermal : public Fix { class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; class ComputeRHEOVShift *compute_vshift; + class FixUpdateSpecialBonds *fix_update_special_bonds; void grow_array(int); void break_bonds(int); From 1cbe59c254989631df6bffde3a767c98896e3b2a Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 5 Oct 2023 21:19:50 -0600 Subject: [PATCH 045/104] Fixing compile errors --- src/RHEO/fix_rheo_thermal.cpp | 20 +++++++++++++------- src/RHEO/fix_rheo_thermal.h | 8 +++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index f6fa95b3b7..48a22a5419 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -19,6 +19,7 @@ #include "fix_rheo_thermal.h" #include "atom.h" +#include "atom_vec.h" #include "comm.h" #include "compute_rheo_grad.h" #include "compute_rheo_vshift.h" @@ -31,7 +32,9 @@ #include "math_extra.h" #include "memory.h" #include "modify.h" +#include "neighbor.h" #include "neigh_list.h" +#include "neigh_request.h" #include "pair.h" #include "update.h" @@ -121,11 +124,13 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); } } else if (strcmp(arg[iarg],"react") == 0) { - if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for react option"); + if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for react option"); cut_bond = utils::numeric(FLERR, arg[iarg + 1], false, lmp); + btype = utils::numeric(FLERR, arg[iarg + 2], false, lmp); comm_forward = 1; - if (cut_bond <= 0.0) error->all(FLERR, "Illegal value for bond lengths"); - iarg += 1; + if (cut_bond <= 0.0) error->all(FLERR, "Illegal value for bond lengths");\ + if (btype < 1 || btype > atom->nbondtypes) error->all(FLERR, "Illegal value for bond type"); + iarg += 2; } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg]); } @@ -193,7 +198,7 @@ void FixRHEOThermal::init() // all special weights must be 1.0 (no special neighbors) or there must be an instance of fix update/special/bonds if (force->special_lj[0] != 1.0 || force->special_lj[1] != 1.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0) { auto fixes = modify->get_fix_by_style("UPDATE_SPECIAL_BONDS"); - if (fixes.size == 0) error->all(FLERR, "Without fix update/special/bonds, reactive bond generation in fix rheo/thermal requires special weights of 1.0"); + if (fixes.size() == 0) error->all(FLERR, "Without fix update/special/bonds, reactive bond generation in fix rheo/thermal requires special weights of 1.0"); fix_update_special_bonds = dynamic_cast(fixes[0]); } @@ -314,7 +319,7 @@ void FixRHEOThermal::post_integrate() comm->forward_comm(this); for (int i = 0; i < atom->nlocal; i++) { - if (status[i] & STATUS_MELTING) delete_bonds(i); + if (status[i] & STATUS_MELTING) break_bonds(i); if (status[i] & STATUS_FREEZING) create_bonds(i); } } @@ -434,7 +439,7 @@ void FixRHEOThermal::create_bonds(int i) int nlocal = atom->nlocal; tagint *tag = atom->tag; - double *x = atom->x; + double **x = atom->x; numneigh = list->numneigh; firstneigh = list->firstneigh; @@ -442,6 +447,7 @@ void FixRHEOThermal::create_bonds(int i) int **bond_type = atom->bond_type; tagint **bond_atom = atom->bond_atom; int *num_bond = atom->num_bond; + int newton_bond = force->newton_bond; double xtmp = x[i][0]; double ytmp = x[i][1]; @@ -511,6 +517,6 @@ void FixRHEOThermal::unpack_forward_comm(int n, int first, double *buf) m = 0; last = first + n; for (i = first; i < last; i++) { - status[i] = (int) ubuf(buf[m++]).i + status[i] = (int) ubuf(buf[m++]).i; } } diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index 13b743b939..75d32b7bc1 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -22,6 +22,8 @@ FixStyle(rheo/thermal,FixRHEOThermal) #include "fix.h" +#include + namespace LAMMPS_NS { class FixRHEOThermal : public Fix { @@ -48,13 +50,13 @@ class FixRHEOThermal : public Fix { double *kappa_type, kappa; double dtf, dtv; double cut_bond; - int Tc_style; - int cv_style; + int Tc_style, cv_style; + int btype; int conductivity_style; class NeighList *list; int n_histories; - const std::vector histories; + std::vector histories; class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; From 63eed5e2301f53848a52557ebb6864cb68e19c3a Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 6 Oct 2023 17:43:54 -0600 Subject: [PATCH 046/104] Drafting tension model --- src/.gitignore | 2 + src/RHEO/pair_rheo_tension.cpp | 369 +++++++++++++++++++++++++++++++++ src/RHEO/pair_rheo_tension.h | 56 +++++ 3 files changed, 427 insertions(+) create mode 100644 src/RHEO/pair_rheo_tension.cpp create mode 100644 src/RHEO/pair_rheo_tension.h diff --git a/src/.gitignore b/src/.gitignore index f9794ddb82..7b645ee347 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -223,6 +223,8 @@ /fix_rheo_viscosity.h /pair_rheo.cpp /pair_rheo.h +/pair_rheo_tension.cpp +/pair_rheo_tension.h /compute_grid.cpp /compute_grid.h diff --git a/src/RHEO/pair_rheo_tension.cpp b/src/RHEO/pair_rheo_tension.cpp new file mode 100644 index 0000000000..5899c87e3e --- /dev/null +++ b/src/RHEO/pair_rheo_tension.cpp @@ -0,0 +1,369 @@ +/* ---------------------------------------------------------------------- + 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 authors: + Joel Clemmer (SNL) +----------------------------------------------------------------------- */ + +#include "pair_rheo_tension.h" + +#include "atom.h" +#include "comm.h" +#include "compute_rheo_kernel.h" +#include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "math_extra.h" +#include "memory.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "update.h" +#include "utils.h" + +#include + +using namespace LAMMPS_NS; +using namespace RHEO_NS; +using namespace MathExtra; + +static constexpr double EPSILON = 1e-2; + +/* ---------------------------------------------------------------------- */ + +PairRHEOTension::PairRHEOTension(LAMMPS *lmp) : + Pair(lmp), compute_kernel(nullptr), fix_rheo(nullptr) +{ + restartinfo = 0; + single_enable = 0; + + comm_forward = 3; + comm_reverse = 3; +} + +/* ---------------------------------------------------------------------- */ + +PairRHEOTension::~PairRHEOTension() +{ + // Remove custom property if it exists + int tmp1, tmp2, index; + + index = atom->find_custom("rheo_c_tension", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 0); + + index = atom->find_custom("rheo_n_tension", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 3); + + if (allocated) { + memory->destroy(alpha); + memory->destroy(setflag); + memory->destroy(cutsq); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairRHEOTension::compute(int eflag, int vflag) +{ + int i, j, a, b, ii, jj, inum, jnum, itype, jtype; + int fluidi, fluidj; + double xtmp, ytmp, ztmp, w, wp; + double rhoi, rhoj, voli, volj; + double *dWij, *dWji; + double dx[3], ft[3]; + + int *ilist, *jlist, *numneigh, **firstneigh; + double imass, jmass, rsq, r, rinv; + + int nlocal = atom->nlocal; + int newton_pair = force->newton_pair; + int dim = domain->dimension; + + ev_init(eflag, vflag); + + double **x = atom->x; + double **f = atom->f; + double *rho = atom->rho; + double *mass = atom->mass; + double *special_lj = force->special_lj; + int *type = atom->type; + int *status = atom->status; + tagint *tag = atom->tag; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + int nmax = atom->nmax; + if (nmax_store <= nmax) { + memory->grow(c_tension, nmax, "atom:rheo_c_tension"); + memory->grow(n_tension, nmax, 3, "atom:rheo_n_tension"); + nmax_store = atom->nmax; + } + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + imass = mass[itype]; + rhoi = rho[i]; + voli = imass / rhoi; + fluidi = !(status[i] & PHASECHECK); + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = lensq3(dx); + jtype = type[j]; + + if (rsq > hsq) continue; + + r = sqrt(rsq); + rinv = 1 / r; + + jmass = mass[jtype]; + rhoj = rho[j]; + volj = jmass / rhoj; + fluidj = !(status[j] & PHASECHECK); + + wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2],r); + dWij = compute_kernel->dWij; + dWji = compute_kernel->dWji; + + + + f[i][0] += ft[0]; + f[i][1] += ft[1]; + f[i][2] += ft[2]; + + if (evflag) // Does not account for unbalanced forces + ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], dx[0], dx[1], dx[2]); + + if (newton_pair || j < nlocal) { + + f[j][0] -= ft[0]; + f[j][1] -= ft[1]; + f[j][2] -= ft[2]; + } + } + } + + if (vflag_fdotr) virial_fdotr_compute(); + + if (compute_interface) { + comm->reverse_comm(this); + comm->forward_comm(this); + } +} + +/* ---------------------------------------------------------------------- + allocate all arrays + ------------------------------------------------------------------------- */ + +void PairRHEOTension::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag, n + 1, n + 1, "pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(alpha, n + 1, n + 1, "pair:alpha"); + memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs + ------------------------------------------------------------------------- */ + +void PairRHEOTension::coeff(int narg, char **arg) +{ + if (narg != 3) + error->all(FLERR,"Incorrect number of args for pair_style rheo coefficients"); + if (!allocated) + allocate(); + + int ilo, ihi, jlo, jhi; + utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi,error); + utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi,error); + + alpha_one = utils::numeric(FLERR, arg[2], false, lmp); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = 0; j <= atom->ntypes; j++) { + alpha[i][j] = alpha_one; + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) + error->all(FLERR,"Incorrect args for pair rheo/tension coefficients"); +} + +/* ---------------------------------------------------------------------- + setup specific to this pair style + ------------------------------------------------------------------------- */ + +void PairRHEOTension::setup() +{ + auto fixes = modify->get_fix_by_style("rheo"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use pair rheo"); + fix_rheo = dynamic_cast(fixes[0]); + + compute_kernel = fix_rheo->compute_kernel; + compute_grad = fix_rheo->compute_grad; + compute_interface = fix_rheo->compute_interface; + h = fix_rheo->h; + csq = fix_rheo->csq; + rho0 = fix_rheo->rho0; + + hsq = h * h; + hinv = 1.0 / h; + hinv3 = hinv * 3.0; +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairRHEOTension::init_style() +{ + neighbor->add_request(this); + + + // Create c_tension arrays n_tension arrays if they don't already exist + // Create a custom atom property so it works with compute property/atom + // Do not create grow callback as there's no reason to copy/exchange data + // Manually grow if nmax_store exceeded + // For B and gradC, create a local array since they are unlikely to be printed + + int tmp1, tmp2; + int index = atom->find_custom("rheo_c_tension", tmp1, tmp2); + if (index == -1) index = atom->add_custom("rheo_c_tension", 1, 0); + ct = atom->dvector[index]; + + index = atom->find_custom("rheo_n_tension", tmp1, tmp2); + if (index == -1) index = atom->add_custom("rheo_n_tension", 1, 3); + nt = atom->darray[index]; + + nmax_store = atom->nmax; +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i + ------------------------------------------------------------------------- */ + +double PairRHEOTension::init_one(int i, int j) +{ + if (setflag[i][j] == 0) + error->all(FLERR,"All pair rheo/tension coeffs are not set"); + + alpha[j][i] = alpha[i][j]; + + return h; +} + + +/* ---------------------------------------------------------------------- */ + +int PairRHEOTension::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) +{ + int i,j,k,m; + m = 0; + double *rho = atom->rho; + + for (i = 0; i < n; i++) { + j = list[i]; + if (comm_stage == 0) { + buf[m++] = fp_store[j][0]; + buf[m++] = fp_store[j][1]; + buf[m++] = fp_store[j][2]; + } else { + buf[m++] = chi[j]; + buf[m++] = rho[j]; + } + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void PairRHEOTension::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double *rho = atom->rho; + m = 0; + last = first + n; + for (i = first; i < last; i++) { + if (comm_stage == 0) { + fp_store[i][0] = buf[m++]; + fp_store[i][1] = buf[m++]; + fp_store[i][2] = buf[m++]; + } else { + chi[i] = buf[m++]; + rho[i] = buf[m++]; + } + } +} + + +/* ---------------------------------------------------------------------- */ + +int PairRHEOTension::pack_reverse_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double **fp_store = compute_interface->fp_store; + + m = 0; + last = first + n; + for (i = first; i < last; i++) { + buf[m++] = fp_store[i][0]; + buf[m++] = fp_store[i][1]; + buf[m++] = fp_store[i][2]; + } + + return m; +} + +/* ---------------------------------------------------------------------- */ + +void PairRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i, j, k, m; + double **fp_store = compute_interface->fp_store; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + fp_store[j][0] += buf[m++]; + fp_store[j][1] += buf[m++]; + fp_store[j][2] += buf[m++]; + } +} diff --git a/src/RHEO/pair_rheo_tension.h b/src/RHEO/pair_rheo_tension.h new file mode 100644 index 0000000000..9b75b05ebd --- /dev/null +++ b/src/RHEO/pair_rheo_tension.h @@ -0,0 +1,56 @@ +/* -*- 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 PAIR_CLASS +// clang-format off +PairStyle(rheo/tension,PairRHEOTension) +// clang-format on +#else + +#ifndef LMP_PAIR_RHEO_TENSION_H +#define LMP_PAIR_RHEO_TENSION_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairRHEOTension : public Pair { + public: + PairRHEOTension(class LAMMPS *); + ~PairRHEOTension() override; + void compute(int, int) override; + void coeff(int, char **) override; + void setup() override; + void init_style() override; + double init_one(int, int) override; + void unpack_forward_comm(int, int, double *) override; + int pack_reverse_comm(int, int, double *) override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; + + protected: + int nmax_store; + double **nt, *ct; + double *alpha; + double hsq, hinv, hinv3; + + void allocate(); + + class ComputeRHEOKernel *compute_kernel; + class FixRHEO *fix_rheo; +}; + +} // namespace LAMMPS_NS + +#endif +#endif From f28e46d40e5ad5e883849a7412faccd2d58b1d6f Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 19 Oct 2023 11:57:07 -0600 Subject: [PATCH 047/104] Adding support for remap v --- src/RHEO/compute_rheo_grad.cpp | 28 ++++++++++++++++++++++++---- src/RHEO/compute_rheo_grad.h | 2 +- src/RHEO/fix_rheo.cpp | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 369bf11e0d..7fdff41403 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -111,6 +111,8 @@ void ComputeRHEOGrad::init() compute_kernel = fix_rheo->compute_kernel; compute_interface = fix_rheo->compute_interface; + remap_v_flag = domain->deform_vremap; + neighbor->add_request(this, NeighConst::REQ_DEFAULT); } @@ -301,13 +303,23 @@ void ComputeRHEOGrad::forward_fields() /* ---------------------------------------------------------------------- */ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, - int /*pbc_flag*/, int * /*pbc*/) + int pbc_flag, int *pbc) { int i,j,k,m; + int *mask = atom->mask; double *rho = atom->rho; double *temperature = atom->temperature; double **v = atom->v; int dim = domain->dimension; + double *h_rate = domain->h_rate; + int deform_groupbit = domain->deform_groupbit; + double dv[3]; + + if (remap_v_flag) { + dv[0] = pbc[0] * h_rate[0] + pbc[5] * h_rate[5] + pbc[4] * h_rate[4]; + dv[1] = pbc[1] * h_rate[1] + pbc[3] * h_rate[3]; + dv[2] = pbc[2] * h_rate[2]; + } m = 0; @@ -333,9 +345,17 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, } else if (comm_stage == COMMFIELD) { - if (velocity_flag) - for (k = 0; k < dim; k++) - buf[m++] = v[j][k]; + if (velocity_flag) { + if (remap_v_flag & pbc_flag & (mask[j] & deform_groupbit)) { + for (k = 0; k < dim; k++) + buf[m++] = v[j][k] + dv[k]; + } else { + for (k = 0; k < dim; k++) + buf[m++] = v[j][k]; + } + } + + if (rho_flag) buf[m++] = rho[j]; diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index af4fecdcfb..db5e84d32a 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -49,7 +49,7 @@ class ComputeRHEOGrad : public Compute { double cut, cutsq, rho0; int velocity_flag, temperature_flag, rho_flag, eta_flag; - int interface_flag; + int interface_flag, remap_v_flag; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 339d7f5ac8..e26ce8744b 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -381,13 +381,13 @@ void FixRHEO::pre_force(int /*vflag*/) if (rhosum_flag) compute_rhosum->compute_peratom(); - compute_grad->forward_fields(); // also forwards v and rho for chi compute_kernel->compute_peratom(); if (interface_flag) { // Note on first setup, have no forces for pressure to reference compute_interface->compute_peratom(); } + // No need to forward v, rho, or T for compute_grad since already done compute_grad->compute_peratom(); compute_grad->forward_gradients(); From 5986fb90b93c00b11318ec69e96bdeafe83ce55a Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 19 Oct 2023 12:37:59 -0600 Subject: [PATCH 048/104] Few updates to surface tension, add stress fix --- src/.gitignore | 2 + src/RHEO/fix_rheo_stress.cpp | 137 +++++++++++++++++++++++++++++++++ src/RHEO/fix_rheo_stress.h | 48 ++++++++++++ src/RHEO/pair_rheo_tension.cpp | 12 +-- src/RHEO/pair_rheo_tension.h | 2 +- 5 files changed, 192 insertions(+), 9 deletions(-) create mode 100644 src/RHEO/fix_rheo_stress.cpp create mode 100644 src/RHEO/fix_rheo_stress.h diff --git a/src/.gitignore b/src/.gitignore index 7b645ee347..cc792388a6 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -217,6 +217,8 @@ /fix_rheo.h /fix_rheo_pressure.cpp /fix_rheo_pressure.h +/fix_rheo_stress.cpp +/fix_rheo_stress.h /fix_rheo_thermal.cpp /fix_rheo_thermal.h /fix_rheo_viscosity.cpp diff --git a/src/RHEO/fix_rheo_stress.cpp b/src/RHEO/fix_rheo_stress.cpp new file mode 100644 index 0000000000..b391527f1c --- /dev/null +++ b/src/RHEO/fix_rheo_stress.cpp @@ -0,0 +1,137 @@ +/* ---------------------------------------------------------------------- + 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 authors: Joel Clemmer (SNL) +----------------------------------------------------------------------- */ + +#include "fix_rheo_stress.h" + +#include "atom.h" +#include "comm.h" +#include "compute.h" +#include "domain.h" +#include "fix_store_atom.h" +#include "group.h" +#include "error.h" +#include "modify.h" +#include "update.h" + +#include +#include + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +FixRHEOStress::FixRHEOStress(LAMMPS *lmp, int narg, char **arg) : + id_compute(nullptr), id_fix(nullptr), stress_compute(nullptr), store_fix(nullptr), Fix(lmp, narg, arg) +{ + if (narg != 3) error->all(FLERR,"Illegal fix rheo/stress command"); + comm_forward = 6; +} + +/* ---------------------------------------------------------------------- */ + +FixRHEOStress::~FixRHEOStress() +{ + modify->delete_compute(id_compute); + modify->delete_fix(id_fix); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOStress::post_constructor() +{ + id_fix = utils::strdup(std::string(id) + "_store"); + store_fix = dynamic_cast(modify->add_fix(fmt::format("{} {} STORE/ATOM d_pxx d_pyy d_pzz d_pxy d_pxz d_pyz", id_fix, group->names[igroup]))); + array_atom = store_fix->astore; + + id_compute = utils::strdup(std::string(id) + "_compute"); + stress_compute = modify->add_compute(fmt::format("{} {} stress/atom NULL ke pair bond", id_compute, group->names[igroup])); +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOStress::setmask() +{ + int mask = 0; + mask |= PRE_FORCE; + mask |= END_OF_STEP; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOStress::init() +{ + stress_compute->addstep(update->ntimestep+1); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOStress::pre_force(int vflag) +{ + // add pre-force and forward to ghosts (not done in store/atom) + comm->forward_comm(this); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOStress::end_of_step() +{ + stress_compute->compute_peratom(); + + // copy compute to fix property atom + double **saved_stress = store_fix->astore; + double **stress = stress_compute->array_atom; + + int ntotal = atom->nlocal+atom->nghost; + for (int i = 0; i < ntotal; i++) + for (int a = 0; a < 6; a++) + saved_stress[i][a] = stress[i][a]; + + stress_compute->addstep(update->ntimestep + 1); +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOStress::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i, j, a, m; + double **saved_stress = store_fix->astore; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + for (a = 0; a < 6; a++) + buf[m++] = saved_stress[j][a]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOStress::unpack_forward_comm(int n, int first, double *buf) +{ + int i, a, m, last; + double **saved_stress = store_fix->astore; + + m = 0; + last = first + n; + for (i = first; i < last; i++) + for (a = 0; a < 6; a++) + saved_stress[i][a] = buf[m++]; +} diff --git a/src/RHEO/fix_rheo_stress.h b/src/RHEO/fix_rheo_stress.h new file mode 100644 index 0000000000..4bf522793f --- /dev/null +++ b/src/RHEO/fix_rheo_stress.h @@ -0,0 +1,48 @@ +/* -*- 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(rheo/stress,FixRHEOStress); +// clang-format on +#else + +#ifndef LMP_FIX_RHEO_STRESS_H +#define LMP_FIX_RHEO_STRESS_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixRHEOStress : public Fix { + public: + FixRHEOStress(class LAMMPS *, int, char **); + ~FixRHEOStress() override; + void post_constructor() override; + int setmask() override; + void init() override; + void pre_force(int) override; + void end_of_step() override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; + + private: + char *id_compute, *id_fix; + class Compute *stress_compute; + class FixStoreAtom *store_fix; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/pair_rheo_tension.cpp b/src/RHEO/pair_rheo_tension.cpp index 5899c87e3e..824f496161 100644 --- a/src/RHEO/pair_rheo_tension.cpp +++ b/src/RHEO/pair_rheo_tension.cpp @@ -109,8 +109,8 @@ void PairRHEOTension::compute(int eflag, int vflag) int nmax = atom->nmax; if (nmax_store <= nmax) { - memory->grow(c_tension, nmax, "atom:rheo_c_tension"); - memory->grow(n_tension, nmax, 3, "atom:rheo_n_tension"); + memory->grow(ct, nmax, "atom:rheo_c_tension"); + memory->grow(nnt_tension, nmax, 3, "atom:rheo_n_tension"); nmax_store = atom->nmax; } @@ -153,8 +153,6 @@ void PairRHEOTension::compute(int eflag, int vflag) dWij = compute_kernel->dWij; dWji = compute_kernel->dWji; - - f[i][0] += ft[0]; f[i][1] += ft[1]; f[i][2] += ft[2]; @@ -173,10 +171,8 @@ void PairRHEOTension::compute(int eflag, int vflag) if (vflag_fdotr) virial_fdotr_compute(); - if (compute_interface) { - comm->reverse_comm(this); - comm->forward_comm(this); - } + comm->reverse_comm(this); + comm->forward_comm(this); } /* ---------------------------------------------------------------------- diff --git a/src/RHEO/pair_rheo_tension.h b/src/RHEO/pair_rheo_tension.h index 9b75b05ebd..d1799b65e7 100644 --- a/src/RHEO/pair_rheo_tension.h +++ b/src/RHEO/pair_rheo_tension.h @@ -33,9 +33,9 @@ class PairRHEOTension : public Pair { void setup() override; void init_style() override; double init_one(int, int) override; + int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; int pack_reverse_comm(int, int, double *) override; - int pack_reverse_comm(int, int, double *) override; void unpack_reverse_comm(int, int *, double *) override; protected: From 0d2b3dc51e1bc4c478723a29bb653f0036a92205 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 22 Oct 2023 14:54:27 -0600 Subject: [PATCH 049/104] Drafting oxide model --- src/.gitignore | 2 + src/RHEO/pair_rheo_react.cpp | 587 +++++++++++++++++++++++++++++++++++ src/RHEO/pair_rheo_react.h | 60 ++++ 3 files changed, 649 insertions(+) create mode 100644 src/RHEO/pair_rheo_react.cpp create mode 100644 src/RHEO/pair_rheo_react.h diff --git a/src/.gitignore b/src/.gitignore index f9794ddb82..099b905eb2 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -223,6 +223,8 @@ /fix_rheo_viscosity.h /pair_rheo.cpp /pair_rheo.h +/pair_rheo_react.cpp +/pair_rheo_react.h /compute_grid.cpp /compute_grid.h diff --git a/src/RHEO/pair_rheo_react.cpp b/src/RHEO/pair_rheo_react.cpp new file mode 100644 index 0000000000..49c24cf501 --- /dev/null +++ b/src/RHEO/pair_rheo_react.cpp @@ -0,0 +1,587 @@ +/* ---------------------------------------------------------------------- + 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 authors: + Joel Clemmer (SNL) +----------------------------------------------------------------------- */ + +#include "pair_rheo_react.h" + +#include "atom.h" +#include "comm.h" +#include "error.h" +#include "fix.h" +#include "fix_dummy.h" +#include "fix_neigh_history.h" +#include "fix_rheo.h" +#include "force.h" +#include "memory.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "update.h" +#include "utils.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +PairRHEOReact::PairRHEOReact(LAMMPS *lmp) : Pair(lmp), + dbond(NULL) +{ + single_enable = 0; + size_history = 2; + beyond_contact = 1; + comm_reverse = 1; + + // create dummy fix as placeholder for FixNeighHistory + // this is so final order of Modify:fix will conform to input script + + fix_history = nullptr; + fix_dummy = dynamic_cast( + modify->add_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY" + std::to_string(instance_me) + " all DUMMY")); + + // For nbond, create an instance of fix property atom + // Need restarts + exchanging with neighbors since it needs to persist + // between timesteps (fix property atom will handle callbacks) + + int tmp1, tmp2; + int index = atom->find_custom("react_nbond", tmp1, tmp2); + if (index == -1) { + id_fix_pa = utils::strdup("pair_rheo_react_fix_property_atom"); + modify->add_fix(fmt::format("{} all property/atom i_react_nbond", id_fix_pa)); + index = atom->find_custom("nbond", tmp1, tmp2); + } + nbond = atom->ivector[index]; + + //Store non-persistent per atom quantities, intermediate + + nmax_store = atom->nmax; + memory->create(dbond, nmax_store, "rheo/react:dbond"); +} + +/* ---------------------------------------------------------------------- */ + +PairRHEOReact::~PairRHEOReact() +{ + if (modify->nfix && fix_history) modify->delete_fix("NEIGH_HISTORY_RHEO_REACT"); + if (modify->nfix && fix_dummy) modify->delete_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY"); + if (modify->nfix) modify->delete_fix("PROPERTY_ATOM_RHEO_REACT"); + + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + memory->destroy(cutbsq); + + memory->destroy(cut); + memory->destroy(cutbond); + memory->destroy(k); + memory->destroy(eps); + memory->destroy(gamma); + memory->destroy(t_form); + memory->destroy(rlimit); + memory->destroy(sigma); + memory->destroy(krepel); + } + + memory->destroy(dbond); +} + +/* ---------------------------------------------------------------------- */ + +void PairRHEOReact::compute(int eflag, int vflag) +{ + int i,j,ii,jj,inum,jnum; + double xtmp,ytmp,ztmp,delx,dely,delz; + double rsq,r,rinv,r0; + double vxtmp,vytmp,vztmp,delvx,delvy,delvz; + double fpair,dot,evdwl,smooth; + int itype, jtype; + + int *ilist,*jlist,*numneigh,**firstneigh; + int *saved,**firstsaved; + double *data,*alldata,**firstdata; + + ev_init(eflag,vflag); + + int bondupdate = 1; + if (update->setupflag) bondupdate = 0; + + dt = update->dt; + + double **x = atom->x; + double **v = atom->v; + double **f = atom->f; + int *type = atom->type; + int *phase = atom->phase; + int *mask = atom->mask; + int *nbond = atom->ivector[index_nb]; + int *surface = atom->surface; + double *rsurf = atom->dvector[index_rsurf]; + + int nlocal = atom->nlocal; + int newton_pair = force->newton_pair; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + firstsaved = fix_history->firstflag; + firstdata = fix_history->firstvalue; + + if (atom->nmax > nmax){ + nmax = atom->nmax; + memory->destroy(dbond); + memory->create(dbond, nmax, "rheo/react:dbond"); + } + + // Switch to no shift if it has bonds (could have just been changed from reactive) + for(i = 0; i < nmax; i++) { + dbond[i] = 0; + } + + // loop over neighbors of my atoms + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + itype = type[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + vxtmp = v[i][0]; + vytmp = v[i][1]; + vztmp = v[i][2]; + saved = firstsaved[i]; + alldata = firstdata[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + jtype = type[j]; + data = &alldata[2*jj]; + + // If not bonded and there's an internal fluid particle, unsave any data and skip + if (!(saved[jj] == 1 && data[0] > 0)) { + if ((phase[i] <= FixRHEO::FLUID_MAX && rsurf[i] > rlimit[itype][jtype]) || (phase[j] <= FixRHEO::FLUID_MAX && rsurf[j] > rlimit[itype][jtype])) { + saved[jj] = 0; + continue; + } + } + + // If both are solid, unbond and skip + if ((phase[i] == FixRHEO::SOLID || phase[i] == FixRHEO::FREEZING) && + (phase[j] == FixRHEO::SOLID || phase[j] == FixRHEO::FREEZING)) { + //If bonded, deincrement + if (saved[jj] == 1 && data[0] > 0) { + dbond[i] --; + dbond[j] --; + } + saved[jj] = 0; + continue; + } + + // Remaining options are react+sold, react+react, react+surf/fluid, or surf/fluid+surf/fluid + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + + // If unbonded and beyond bond distance, unsave and skip + if (data[0] == -1 && rsq > cutbsq[itype][jtype]) { + saved[jj] = 0; + continue; + } + + r = sqrt(rsq); + // Initialize data if not currently saved since all could bond if they are on the surface + if (saved[jj] == 0) { + data[0] = -1; + data[1] = 0; + saved[jj] = 1; + } + + // Check for bond formation (unbonded) or breakage (bonded) + if (data[0] == -1) { + // If unbonded, check if we count down to bonding if both on surface (not given for r or s) + if (bondupdate && rsurf[i] <= rlimit[itype][jtype] && rsurf[j] <= rlimit[itype][jtype]) { + data[1] += dt; + if (data[1] >= t_form[itype][jtype]) { + data[0] = r; + dbond[i] ++; + dbond[j] ++; + data[1] = 0; + } + } + } else { + // If bonded, check if breaks in tension + r0 = data[0]; + if (r > ((1.0+eps[itype][jtype])*r0)) { + saved[jj] = 0; + dbond[i] --; + dbond[j] --; + data[0] = -1; + } + } + + // Apply forces + delvx = vxtmp - v[j][0]; + delvy = vytmp - v[j][1]; + delvz = vztmp - v[j][2]; + rinv = 1.0/r; + + if (data[0] <= 0) { + // Skip if either is fluid (only include r+s or r+r since already skipped s+s) + if (phase[i] <= FixRHEO::FLUID_MAX || phase[j] <= FixRHEO::FLUID_MAX) continue; + + // Skip if out of contact + if (rsq > sigma[itype][jtype]*sigma[itype][jtype]) continue; + + fpair = krepel[itype][jtype]*(sigma[itype][jtype]-r); + if (eflag) + evdwl = -0.5*krepel[itype][jtype]*(sigma[itype][jtype]-r)*(sigma[itype][jtype]-r); + + smooth = rsq/(sigma[itype][jtype]*sigma[itype][jtype]); + smooth *= smooth; + smooth = 1.0 - smooth; + dot = delx*delvx + dely*delvy + delz*delvz; + fpair -= gamma[itype][jtype]*dot*smooth*rinv; + + fpair *= rinv; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); + } else { + // Bonded + r0 = data[0]; + + fpair = k[itype][jtype]*(r0-r); + if (evflag) evdwl = -0.5*fpair*(r0-r); + + dot = delx*delvx + dely*delvy + delz*delvz; + fpair -= gamma[itype][jtype]*dot*rinv; + + smooth = 1.0; + if (r > r0) { + smooth = (r-r0)/(r0*eps[itype][jtype]); + smooth *= smooth; + smooth *= smooth; + smooth = 1 - smooth; + } + + fpair *= rinv*smooth; + + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + } + + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); + } + } + } + + // Communicate changes in nbond + if(newton_pair) comm->reverse_comm_pair(this); + + for(i = 0; i < nlocal; i++) { + nbond[i] += dbond[i]; + + // If it has bonds it is reactive (no shifting) + // If a reactive particle breaks all bonds, return to fluid + // Keep it non-shifting for this timestep to be safe + if (nbond[i] != 0 && phase[i] <= FixRHEO::FLUID_MAX) phase[i] = FixRHEO::FLUID_NO_SHIFT; + } + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairRHEOReact::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag,n+1,n+1,"pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cut,n+1,n+1,"pair:cut"); + memory->create(cutbond,n+1,n+1,"pair:cutbond"); + memory->create(cutsq,n+1,n+1,"pair:cutsq"); + memory->create(cutbsq,n+1,n+1,"pair:cutbsq"); + memory->create(k,n+1,n+1,"pair:k"); + memory->create(eps,n+1,n+1,"pair:eps"); + memory->create(gamma,n+1,n+1,"pair:gamma"); + memory->create(t_form,n+1,n+1,"pair:t_form"); + memory->create(rlimit,n+1,n+1,"pair:rlimit"); + memory->create(sigma,n+1,n+1,"pair:sigma"); + memory->create(krepel,n+1,n+1,"pair:krepel"); +} + +/* ---------------------------------------------------------------------- + global settings + ------------------------------------------------------------------------- */ + +void PairRHEOReact::settings(int narg, char **arg) +{ +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairRHEOReact::coeff(int narg, char **arg) +{ + if (narg != 11) error->all(FLERR,"Incorrect args for pair coefficients"); + if (!allocated) allocate(); + + int ilo,ihi,jlo,jhi; + utils::bounds(FLERR,arg[0],1, atom->ntypes, ilo, ihi,error); + utils::bounds(FLERR,arg[1],1, atom->ntypes, jlo, jhi,error); + + double cut_one = utils::numeric(FLERR,arg[2],false,lmp); + double cutb_one = utils::numeric(FLERR,arg[3],false,lmp); + double k_one = utils::numeric(FLERR,arg[4],false,lmp); + double eps_one = utils::numeric(FLERR,arg[5],false,lmp); + double gamma_one = utils::numeric(FLERR,arg[6],false,lmp); + double t_form_one = utils::numeric(FLERR,arg[7],false,lmp); + double rlimit_one = utils::numeric(FLERR,arg[8],false,lmp); + double sigma_one = utils::numeric(FLERR,arg[9],false,lmp); + double krepel_one = utils::numeric(FLERR,arg[10],false,lmp); + + if (k_one < 0.0 || eps_one < 0.0 || + t_form_one < 0.0 || (1.0+eps_one)*cutb_one > cut_one) + error->all(FLERR,"Illegal pair_style command"); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo,i); j <= jhi; j++) { + cut[i][j] = cut_one; + cutbond[i][j] = cutb_one; + k[i][j] = k_one; + eps[i][j] = eps_one; + gamma[i][j] = gamma_one; + t_form[i][j] = t_form_one; + rlimit[i][j] = rlimit_one; + sigma[i][j] = sigma_one; + krepel[i][j] = krepel_one; + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairRHEOReact::init_style() +{ + int irequest = neighbor->request(this,instance_me); + neighbor->requests[irequest]->history = 1; + + if (fix_history == nullptr) { + + // Don't want history[i][j] = -history[j][i] + nondefault_history_transfer = 1; + + char dnumstr[16]; + sprintf(dnumstr,"%d",size_history); + char **fixarg = new char*[4]; + fixarg[0] = (char *) "NEIGH_HISTORY_RHEO_REACT"; + fixarg[1] = (char *) "all"; + fixarg[2] = (char *) "NEIGH_HISTORY"; + fixarg[3] = dnumstr; + modify->replace_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY",4,fixarg,1); + delete [] fixarg; + int ifix = modify->find_fix("NEIGH_HISTORY_RHEO_REACT"); + fix_history = (FixNeighHistory *) modify->fix[ifix]; + fix_history->pair = this; + fix_dummy = nullptr; + } + + int temp_flag; + index_rsurf = atom->find_custom("rsurf", temp_flag); + if ((index_rsurf < 0) || (temp_flag != 1)) + error->all(FLERR, "Pair rheo/react can't find fix property/atom rsurf"); +} + +/* ---------------------------------------------------------------------- + setup specific to this pair style + ------------------------------------------------------------------------- */ + +void PairRHEOReact::setup() { + int ifix = modify->find_fix_by_style("rheo"); + if (ifix == -1) error->all(FLERR, "Using pair rheo/react without fix rheo"); + fix_rheo = ((FixRHEO *) modify->fix[ifix]); + + ifix = modify->find_fix_by_style("rheo/surface"); + if (ifix == -1) error->all(FLERR, "Using pair rheo/react without fix rheo/surface"); + + if (force->newton_pair == 0) error->all(FLERR, + "Pair rheo/react needs newton pair on for bond changes to be consistent"); +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairRHEOReact::init_one(int i, int j) +{ + if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); + + double einv = 1/eps[i][j]; + + cutbsq[i][j] = cutbond[i][j]*cutbond[i][j]; + + cutbsq[j][i] = cutbsq[i][j]; + cut[j][i] = cut[i][j]; + cutbond[j][i] = cutbond[i][j]; + k[j][i] = k[i][j]; + eps[j][i] = eps[i][j]; + gamma[j][i] = gamma[i][j]; + t_form[j][i] = t_form[i][j]; + rlimit[j][i] = rlimit[i][j]; + sigma[j][i] = sigma[i][j]; + krepel[j][i] = krepel[i][j]; + + return cut[i][j]; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairRHEOReact::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + int i,j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) + fwrite(&setflag[i][j],sizeof(int),1,fp); + if (setflag[i][j]) { + fwrite(&cut[i][j],sizeof(double),1,fp); + fwrite(&cutbond[i][j],sizeof(double),1,fp); + fwrite(&k[i][j],sizeof(double),1,fp); + fwrite(&eps[i][j],sizeof(double),1,fp); + fwrite(&gamma[i][j],sizeof(double),1,fp); + fwrite(&t_form[i][j],sizeof(double),1,fp); + fwrite(&rlimit[i][j],sizeof(double),1,fp); + fwrite(&sigma[i][j],sizeof(double),1,fp); + fwrite(&krepel[i][j],sizeof(double),1,fp); + } +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairRHEOReact::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i,j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); + MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + if (setflag[i][j]) { + if (me == 0) { + fread(&cut[i][j],sizeof(double),1,fp); + fread(&cutbond[i][j],sizeof(double),1,fp); + fread(&k[i][j],sizeof(double),1,fp); + fread(&eps[i][j],sizeof(double),1,fp); + fread(&gamma[i][j],sizeof(double),1,fp); + fread(&t_form[i][j],sizeof(double),1,fp); + fread(&rlimit[i][j],sizeof(double),1,fp); + fread(&sigma[i][j],sizeof(double),1,fp); + fread(&krepel[i][j],sizeof(double),1,fp); + } + MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&cutbond[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&k[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&eps[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&gamma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&t_form[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&rlimit[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&krepel[i][j],1,MPI_DOUBLE,0,world); + } + } +} + + + + +/* ---------------------------------------------------------------------- + transfer history during fix/neigh/history exchange - transfer same sign +------------------------------------------------------------------------- */ + +void PairRHEOReact::transfer_history(double* source, double* target) +{ + for (int i = 0; i < size_history; i++) + target[i] = source[i]; +} + +/* ---------------------------------------------------------------------- */ + +int PairRHEOReact::pack_reverse_comm(int n, int first, double *buf) +{ + int i,m,last; + + m = 0; + last = first + n; + + for (i = first; i < last; i++) { + buf[m++] = dbond[i]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void PairRHEOReact::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i,j,m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + dbond[j] += buf[m++]; + } +} diff --git a/src/RHEO/pair_rheo_react.h b/src/RHEO/pair_rheo_react.h new file mode 100644 index 0000000000..c2a7f26f03 --- /dev/null +++ b/src/RHEO/pair_rheo_react.h @@ -0,0 +1,60 @@ +/* -*- 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 PAIR_CLASS +// clang-format off +PairStyle(rheo/react,PairRHEOReact) +// clang-format on +#else + +#ifndef LMP_PAIR_RHEO_REACT_H +#define LMP_PAIR_RHEO_REACT_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairRHEOReact : public Pair { + public: + PairRHEOReact(class LAMMPS *); + virtual ~PairRHEOReact() override; + virtual void compute(int, int) override; + void settings(int, char **) override; + void coeff(int, char **) override; + void init_style() override; + void setup() override; + double init_one(int, int) override; + void write_restart(FILE *) override; + void read_restart(FILE *) override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; + + protected: + double **cut,**cutbond,**cutbsq, **k, **eps, **gamma, **t_form, **rlimit, **sigma, **krepel; + + void allocate(); + void transfer_history(double*, double*); + + int size_history, nmax_store; + int *dbond, *nbond; + double dt; + + class FixDummy *fix_dummy; + class FixNeighHistory *fix_history; + class FixRHEO *fix_rheo; +}; + +} // namespace LAMMPS_NS + +#endif +#endif From 0945c3dda850aa6635be7f5aa7124c24ce992a23 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 30 Oct 2023 20:22:14 -0600 Subject: [PATCH 050/104] Bug in rheo, cleaning up old files --- src/RHEO/fix_rheo.cpp | 4 +- src/atom_vec_rheo_thermal.cpp | 200 ---------------------------------- src/atom_vec_rheo_thermal.h | 46 -------- 3 files changed, 2 insertions(+), 248 deletions(-) delete mode 100644 src/atom_vec_rheo_thermal.cpp delete mode 100644 src/atom_vec_rheo_thermal.h diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index e26ce8744b..c8dca74d32 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -94,11 +94,11 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"surface/detection") == 0) { surface_flag = 1; if(iarg + 2 >= narg) error->all(FLERR,"Illegal surface/detection option in fix rheo"); - if (strcmp(arg[iarg + 1], "coordination")) { + if (strcmp(arg[iarg + 1], "coordination") == 0) { surface_style = COORDINATION; zmin_surface = utils::inumeric(FLERR,arg[iarg + 2],false,lmp); zmin_splash = utils::inumeric(FLERR,arg[iarg + 3],false,lmp); - } else if (strcmp(arg[iarg + 1], "divergence")) { + } else if (strcmp(arg[iarg + 1], "divergence") == 0) { surface_style = DIVR; divr_surface = utils::numeric(FLERR,arg[iarg + 2],false,lmp); zmin_splash = utils::inumeric(FLERR,arg[iarg + 3],false,lmp); diff --git a/src/atom_vec_rheo_thermal.cpp b/src/atom_vec_rheo_thermal.cpp deleted file mode 100644 index de0c7fa5d7..0000000000 --- a/src/atom_vec_rheo_thermal.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* ---------------------------------------------------------------------- - 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 authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) ------------------------------------------------------------------------ */ - -#include "atom_vec_rheo_thermal.h" - -#include "atom.h" - -#include - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -AtomVecRHEOThermal::AtomVecRHEOThermal(LAMMPS *lmp) : AtomVec(lmp) -{ - molecular = Atom::ATOMIC; - mass_type = PER_TYPE; - forceclearflag = 1; - - atom->status_flag = 1; - atom->conductivity_flag = 1; - atom->temperature_flag = 1; - atom->heatflow_flag = 1; - atom->pressure_flag = 1; - atom->rho_flag = 1; - atom->viscosity_flag = 1; - - // strings with peratom variables to include in each AtomVec method - // strings cannot contain fields in corresponding AtomVec default strings - // order of fields in a string does not matter - // except: fields_data_atom & fields_data_vel must match data file - - fields_grow = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_copy = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_comm = {"status", "rho", "temperature"}; - fields_comm_vel = {"status", "rho", "temperature"}; - fields_reverse = {"drho", "heatflow"}; - fields_border = {"status", "rho", "temperature"}; - fields_border_vel = {"status", "rho", "temperature"}; - fields_exchange = {"status", "rho", "temperature"}; - fields_restart = {"status", "rho", "temperature"}; - fields_create = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_data_atom = {"id", "type", "status", "rho", "temperature", "x"}; - fields_data_vel = {"id", "v"}; - - setup_fields(); -} - -/* ---------------------------------------------------------------------- - set local copies of all grow ptrs used by this class, except defaults - needed in replicate when 2 atom classes exist and it calls pack_restart() -------------------------------------------------------------------------- */ - -void AtomVecRHEOThermal::grow_pointers() -{ - status = atom->status; - conductivity = atom->conductivity; - temperature = atom->temperature; - heatflow = atom->heatflow; - pressure = atom->pressure; - rho = atom->rho; - drho = atom->drho; - viscosity = atom->viscosity; -} - -/* ---------------------------------------------------------------------- - clear extra forces starting at atom N - nbytes = # of bytes to clear for a per-atom vector -------------------------------------------------------------------------- */ - -void AtomVecRHEOThermal::force_clear(int n, size_t nbytes) -{ - memset(&drho[n], 0, nbytes); - memset(&heatflow[n], 0, nbytes); -} - -/* ---------------------------------------------------------------------- - modify what AtomVec::data_atom() just unpacked - or initialize other atom quantities -------------------------------------------------------------------------- */ - -void AtomVecRHEOThermal::data_atom_post(int ilocal) -{ - drho[ilocal] = 0.0; - heatflow[ilocal] = 0.0; - pressure[ilocal] = 0.0; - viscosity[ilocal] = 0.0; - conductivity[ilocal] = 0.0; -} - -/* ---------------------------------------------------------------------- - assign an index to named atom property and return index - return -1 if name is unknown to this atom style -------------------------------------------------------------------------- */ - -int AtomVecRHEOThermal::property_atom(const std::string &name) -{ - if (name == "status") return 0; - if (name == "rho") return 1; - if (name == "drho") return 2; - if (name == "temperature") return 3; - if (name == "heatflow") return 4; - if (name == "conductivity") return 5; - if (name == "pressure") return 6; - if (name == "viscosity") return 7; - return -1; -} - -/* ---------------------------------------------------------------------- - pack per-atom data into buf for ComputePropertyAtom - index maps to data specific to this atom style -------------------------------------------------------------------------- */ - -void AtomVecRHEOThermal::pack_property_atom(int index, double *buf, int nvalues, int groupbit) -{ - int *mask = atom->mask; - int nlocal = atom->nlocal; - int n = 0; - - if (index == 0) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) - buf[n] = status[i]; - else - buf[n] = 0.0; - n += nvalues; - } - } else if (index == 1) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) - buf[n] = rho[i]; - else - buf[n] = 0.0; - n += nvalues; - } - } else if (index == 2) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) - buf[n] = drho[i]; - else - buf[n] = 0.0; - n += nvalues; - } - } else if (index == 3) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) - buf[n] = temperature[i]; - else - buf[n] = 0.0; - n += nvalues; - } - } else if (index == 4) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) - buf[n] = heatflow[i]; - else - buf[n] = 0.0; - n += nvalues; - } - } else if (index == 5) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) - buf[n] = conductivity[i]; - else - buf[n] = 0.0; - n += nvalues; - } - } else if (index == 6) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) - buf[n] = pressure[i]; - else - buf[n] = 0.0; - n += nvalues; - } - } else if (index == 7) { - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) - buf[n] = viscosity[i]; - else - buf[n] = 0.0; - n += nvalues; - } - } -} diff --git a/src/atom_vec_rheo_thermal.h b/src/atom_vec_rheo_thermal.h deleted file mode 100644 index 27c6c3c9b5..0000000000 --- a/src/atom_vec_rheo_thermal.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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 ATOM_CLASS -// clang-format off -AtomStyle(rheo/thermal,AtomVecRHEOThermal); -// clang-format on -#else - -#ifndef LMP_ATOM_VEC_RHEO_THERMAL_H -#define LMP_ATOM_VEC_RHEO_THERMAL_H - -#include "atom_vec.h" - -namespace LAMMPS_NS { - -class AtomVecRHEOThermal : virtual public AtomVec { - public: - AtomVecRHEOThermal(class LAMMPS *); - - void grow_pointers() override; - void force_clear(int, size_t) override; - void data_atom_post(int) override; - int property_atom(const std::string &) override; - void pack_property_atom(int, double *, int, int) override; - - private: - int *status; - double *conductivity, *temperature, *heatflow; - double *pressure, *rho, *drho, *viscosity; -}; - -} // namespace LAMMPS_NS - -#endif -#endif From 89150877a22976808cbd9eeb8ffcddf61aafb44f Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 30 Oct 2023 20:48:20 -0600 Subject: [PATCH 051/104] Hiding compile bugs in temporary files --- src/RHEO/pair_rheo_react.cpp | 35 ++++++++++++++++++---------------- src/RHEO/pair_rheo_react.h | 7 +++++-- src/RHEO/pair_rheo_tension.cpp | 24 ++++++++++++++++++++--- src/RHEO/pair_rheo_tension.h | 5 +++-- 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/RHEO/pair_rheo_react.cpp b/src/RHEO/pair_rheo_react.cpp index 49c24cf501..7ec63bb2a9 100644 --- a/src/RHEO/pair_rheo_react.cpp +++ b/src/RHEO/pair_rheo_react.cpp @@ -60,8 +60,8 @@ PairRHEOReact::PairRHEOReact(LAMMPS *lmp) : Pair(lmp), int tmp1, tmp2; int index = atom->find_custom("react_nbond", tmp1, tmp2); if (index == -1) { - id_fix_pa = utils::strdup("pair_rheo_react_fix_property_atom"); - modify->add_fix(fmt::format("{} all property/atom i_react_nbond", id_fix_pa)); + id_fix = utils::strdup("pair_rheo_react_fix_property_atom"); + modify->add_fix(fmt::format("{} all property/atom i_react_nbond", id_fix)); index = atom->find_custom("nbond", tmp1, tmp2); } nbond = atom->ivector[index]; @@ -125,11 +125,9 @@ void PairRHEOReact::compute(int eflag, int vflag) double **v = atom->v; double **f = atom->f; int *type = atom->type; - int *phase = atom->phase; + int *status = atom->status; int *mask = atom->mask; int *nbond = atom->ivector[index_nb]; - int *surface = atom->surface; - double *rsurf = atom->dvector[index_rsurf]; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; @@ -151,7 +149,7 @@ void PairRHEOReact::compute(int eflag, int vflag) for(i = 0; i < nmax; i++) { dbond[i] = 0; } - +/* // loop over neighbors of my atoms for (ii = 0; ii < inum; ii++) { i = ilist[ii]; @@ -167,23 +165,25 @@ void PairRHEOReact::compute(int eflag, int vflag) jlist = firstneigh[i]; jnum = numneigh[i]; + for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; jtype = type[j]; data = &alldata[2*jj]; + // If not bonded and there's an internal fluid particle, unsave any data and skip if (!(saved[jj] == 1 && data[0] > 0)) { - if ((phase[i] <= FixRHEO::FLUID_MAX && rsurf[i] > rlimit[itype][jtype]) || (phase[j] <= FixRHEO::FLUID_MAX && rsurf[j] > rlimit[itype][jtype])) { + if ((status[i] <= FixRHEO::FLUID_MAX && rsurf[i] > rlimit[itype][jtype]) || (status[j] <= FixRHEO::FLUID_MAX && rsurf[j] > rlimit[itype][jtype])) { saved[jj] = 0; continue; } } // If both are solid, unbond and skip - if ((phase[i] == FixRHEO::SOLID || phase[i] == FixRHEO::FREEZING) && - (phase[j] == FixRHEO::SOLID || phase[j] == FixRHEO::FREEZING)) { + if ((status[i] == FixRHEO::SOLID || status[i] == FixRHEO::FREEZING) && + (status[j] == FixRHEO::SOLID || status[j] == FixRHEO::FREEZING)) { //If bonded, deincrement if (saved[jj] == 1 && data[0] > 0) { dbond[i] --; @@ -245,7 +245,7 @@ void PairRHEOReact::compute(int eflag, int vflag) if (data[0] <= 0) { // Skip if either is fluid (only include r+s or r+r since already skipped s+s) - if (phase[i] <= FixRHEO::FLUID_MAX || phase[j] <= FixRHEO::FLUID_MAX) continue; + if (status[i] <= FixRHEO::FLUID_MAX || status[j] <= FixRHEO::FLUID_MAX) continue; // Skip if out of contact if (rsq > sigma[itype][jtype]*sigma[itype][jtype]) continue; @@ -315,10 +315,11 @@ void PairRHEOReact::compute(int eflag, int vflag) // If it has bonds it is reactive (no shifting) // If a reactive particle breaks all bonds, return to fluid // Keep it non-shifting for this timestep to be safe - if (nbond[i] != 0 && phase[i] <= FixRHEO::FLUID_MAX) phase[i] = FixRHEO::FLUID_NO_SHIFT; + if (nbond[i] != 0 && status[i] <= FixRHEO::FLUID_MAX) status[i] = FixRHEO::FLUID_NO_SHIFT; } if (vflag_fdotr) virial_fdotr_compute(); + */ } /* ---------------------------------------------------------------------- @@ -410,7 +411,7 @@ void PairRHEOReact::coeff(int narg, char **arg) void PairRHEOReact::init_style() { int irequest = neighbor->request(this,instance_me); - neighbor->requests[irequest]->history = 1; + //neighbor->requests[irequest]->history = 1; if (fix_history == nullptr) { @@ -432,10 +433,10 @@ void PairRHEOReact::init_style() fix_dummy = nullptr; } - int temp_flag; - index_rsurf = atom->find_custom("rsurf", temp_flag); - if ((index_rsurf < 0) || (temp_flag != 1)) - error->all(FLERR, "Pair rheo/react can't find fix property/atom rsurf"); + //int temp_flag; + //index_rsurf = atom->find_custom("rsurf", temp_flag); + //if ((index_rsurf < 0) || (temp_flag != 1)) + // error->all(FLERR, "Pair rheo/react can't find fix property/atom rsurf"); } /* ---------------------------------------------------------------------- @@ -443,6 +444,7 @@ void PairRHEOReact::init_style() ------------------------------------------------------------------------- */ void PairRHEOReact::setup() { + /* int ifix = modify->find_fix_by_style("rheo"); if (ifix == -1) error->all(FLERR, "Using pair rheo/react without fix rheo"); fix_rheo = ((FixRHEO *) modify->fix[ifix]); @@ -452,6 +454,7 @@ void PairRHEOReact::setup() { if (force->newton_pair == 0) error->all(FLERR, "Pair rheo/react needs newton pair on for bond changes to be consistent"); + */ } /* ---------------------------------------------------------------------- diff --git a/src/RHEO/pair_rheo_react.h b/src/RHEO/pair_rheo_react.h index c2a7f26f03..b349300f27 100644 --- a/src/RHEO/pair_rheo_react.h +++ b/src/RHEO/pair_rheo_react.h @@ -27,8 +27,8 @@ namespace LAMMPS_NS { class PairRHEOReact : public Pair { public: PairRHEOReact(class LAMMPS *); - virtual ~PairRHEOReact() override; - virtual void compute(int, int) override; + ~PairRHEOReact() override; + void compute(int, int) override; void settings(int, char **) override; void coeff(int, char **) override; void init_style() override; @@ -49,6 +49,9 @@ class PairRHEOReact : public Pair { int *dbond, *nbond; double dt; + int index_nb, nmax; + char *id_fix; + class FixDummy *fix_dummy; class FixNeighHistory *fix_history; class FixRHEO *fix_rheo; diff --git a/src/RHEO/pair_rheo_tension.cpp b/src/RHEO/pair_rheo_tension.cpp index 824f496161..ef0d0b60b4 100644 --- a/src/RHEO/pair_rheo_tension.cpp +++ b/src/RHEO/pair_rheo_tension.cpp @@ -106,7 +106,7 @@ void PairRHEOTension::compute(int eflag, int vflag) ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; - +/* int nmax = atom->nmax; if (nmax_store <= nmax) { memory->grow(ct, nmax, "atom:rheo_c_tension"); @@ -173,6 +173,7 @@ void PairRHEOTension::compute(int eflag, int vflag) comm->reverse_comm(this); comm->forward_comm(this); +*/ } /* ---------------------------------------------------------------------- @@ -193,6 +194,14 @@ void PairRHEOTension::allocate() memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); } +/* ---------------------------------------------------------------------- + global settings + ------------------------------------------------------------------------- */ + +void PairRHEOTension::settings(int narg, char **arg) +{ +} + /* ---------------------------------------------------------------------- set coeffs for one or more type pairs ------------------------------------------------------------------------- */ @@ -208,7 +217,7 @@ void PairRHEOTension::coeff(int narg, char **arg) utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi,error); utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi,error); - alpha_one = utils::numeric(FLERR, arg[2], false, lmp); + double alpha_one = utils::numeric(FLERR, arg[2], false, lmp); int count = 0; for (int i = ilo; i <= ihi; i++) { @@ -232,7 +241,7 @@ void PairRHEOTension::setup() auto fixes = modify->get_fix_by_style("rheo"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use pair rheo"); fix_rheo = dynamic_cast(fixes[0]); - + /* compute_kernel = fix_rheo->compute_kernel; compute_grad = fix_rheo->compute_grad; compute_interface = fix_rheo->compute_interface; @@ -243,6 +252,7 @@ void PairRHEOTension::setup() hsq = h * h; hinv = 1.0 / h; hinv3 = hinv * 3.0; + */ } /* ---------------------------------------------------------------------- @@ -291,6 +301,7 @@ double PairRHEOTension::init_one(int i, int j) int PairRHEOTension::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { + /* int i,j,k,m; m = 0; double *rho = atom->rho; @@ -307,12 +318,14 @@ int PairRHEOTension::pack_forward_comm(int n, int *list, double *buf, int /*pbc_ } } return m; + */ } /* ---------------------------------------------------------------------- */ void PairRHEOTension::unpack_forward_comm(int n, int first, double *buf) { + /* int i, k, m, last; double *rho = atom->rho; m = 0; @@ -327,6 +340,7 @@ void PairRHEOTension::unpack_forward_comm(int n, int first, double *buf) rho[i] = buf[m++]; } } + */ } @@ -334,6 +348,7 @@ void PairRHEOTension::unpack_forward_comm(int n, int first, double *buf) int PairRHEOTension::pack_reverse_comm(int n, int first, double *buf) { + /* int i, k, m, last; double **fp_store = compute_interface->fp_store; @@ -346,12 +361,14 @@ int PairRHEOTension::pack_reverse_comm(int n, int first, double *buf) } return m; + */ } /* ---------------------------------------------------------------------- */ void PairRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) { + /* int i, j, k, m; double **fp_store = compute_interface->fp_store; @@ -362,4 +379,5 @@ void PairRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) fp_store[j][1] += buf[m++]; fp_store[j][2] += buf[m++]; } + */ } diff --git a/src/RHEO/pair_rheo_tension.h b/src/RHEO/pair_rheo_tension.h index d1799b65e7..2a046ff324 100644 --- a/src/RHEO/pair_rheo_tension.h +++ b/src/RHEO/pair_rheo_tension.h @@ -29,6 +29,7 @@ class PairRHEOTension : public Pair { PairRHEOTension(class LAMMPS *); ~PairRHEOTension() override; void compute(int, int) override; + void settings(int, char **) override; void coeff(int, char **) override; void setup() override; void init_style() override; @@ -41,8 +42,8 @@ class PairRHEOTension : public Pair { protected: int nmax_store; double **nt, *ct; - double *alpha; - double hsq, hinv, hinv3; + double **alpha; + double h, hsq, hinv, hinv3; void allocate(); From bf115e5df4718d8e8bb45d639a10c03aa5f3e3ba Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 1 Nov 2023 11:55:07 -0600 Subject: [PATCH 052/104] Fix compiler/memory errors in tension, update properties in surface --- src/.gitignore | 4 +- src/RHEO/compute_rheo_grad.cpp | 2 - src/RHEO/compute_rheo_surface.cpp | 82 ++-- src/RHEO/compute_rheo_surface.h | 8 +- src/RHEO/fix_rheo_tension.cpp | 452 ++++++++++++++++++ ...pair_rheo_tension.h => fix_rheo_tension.h} | 41 +- src/RHEO/pair_rheo_tension.cpp | 383 --------------- 7 files changed, 527 insertions(+), 445 deletions(-) create mode 100644 src/RHEO/fix_rheo_tension.cpp rename src/RHEO/{pair_rheo_tension.h => fix_rheo_tension.h} (60%) delete mode 100644 src/RHEO/pair_rheo_tension.cpp diff --git a/src/.gitignore b/src/.gitignore index ef74318fc7..c7e022797f 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -219,6 +219,8 @@ /fix_rheo_pressure.h /fix_rheo_stress.cpp /fix_rheo_stress.h +/fix_rheo_tension.cpp +/fix_rheo_tension.h /fix_rheo_thermal.cpp /fix_rheo_thermal.h /fix_rheo_viscosity.cpp @@ -227,8 +229,6 @@ /pair_rheo.h /pair_rheo_react.cpp /pair_rheo_react.h -/pair_rheo_tension.cpp -/pair_rheo_tension.h /compute_grid.cpp /compute_grid.h diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 7fdff41403..46c1500556 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -355,8 +355,6 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, } } - - if (rho_flag) buf[m++] = rho[j]; diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 230bca8219..88b33c09af 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -87,27 +87,26 @@ void ComputeRHEOSurface::init() cutsq = cut * cut; - // Create rsurface, divr, nsurface arrays if they don't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded + // Create rsurface, divr, nsurface arrays as custom atom properties, + // can print with compute property/atom + // no grow callback as there's no reason to copy/exchange data, manually grow // For B and gradC, create a local array since they are unlikely to be printed + int dim = domain->dimension; int tmp1, tmp2; - int index = atom->find_custom("rheo_divr", tmp1, tmp2); - if (index == -1) index = atom->add_custom("rheo_divr", 1, 0); - divr = atom->dvector[index]; + index_divr = atom->find_custom("rheo_divr", tmp1, tmp2); + if (index_divr == -1) index_divr = atom->add_custom("rheo_divr", 1, 0); + divr = atom->dvector[index_divr]; - index = atom->find_custom("rheo_rsurface", tmp1, tmp2); - if (index == -1) index = atom->add_custom("rheo_rsurface", 1, 0); - rsurface = atom->dvector[index]; + index_rsurf = atom->find_custom("rheo_rsurface", tmp1, tmp2); + if (index_rsurf == -1) index_rsurf = atom->add_custom("rheo_rsurface", 1, 0); + rsurface = atom->dvector[index_rsurf]; - index = atom->find_custom("rheo_nsurface", tmp1, tmp2); - if (index == -1) index = atom->add_custom("rheo_nsurface", 1, 3); - nsurface = atom->darray[index]; + index_nsurf = atom->find_custom("rheo_nsurface", tmp1, tmp2); + if (index_nsurf == -1) index_nsurf = atom->add_custom("rheo_nsurface", 1, dim); + nsurface = atom->darray[index_nsurf]; nmax_store = atom->nmax; - int dim = domain->dimension; memory->create(B, nmax_store, dim * dim, "rheo/surface:B"); memory->create(gradC, nmax_store, dim * dim, "rheo/surface:gradC"); @@ -148,32 +147,21 @@ void ComputeRHEOSurface::compute_peratom() numneigh = list->numneigh; firstneigh = list->firstneigh; - int nmax = atom->nmax; - if (nmax_store <= nmax) { - memory->grow(divr, nmax, "atom:rheo_divr"); - memory->grow(rsurface, nmax, "atom:rheo_rsurface"); - memory->grow(nsurface, nmax, 3, "atom:rheo_nsurface"); + // Grow and zero arrays + if (nmax_store <= atom->nmax) + grow_arrays(atom->nmax); - memory->grow(B, nmax, dim * dim, "rheo/surface:B"); - memory->grow(gradC, nmax, dim * dim, "rheo/surface:gradC"); - - nmax_store = atom->nmax; - } + size_t nbytes = nmax_store * sizeof(double); + memset(&divr, 0, nbytes); + memset(&rsurface, 0, nbytes); + memset(&nsurface, 0, 3 * nbytes); + memset(&gradC, 0, 3 * 3 * nbytes); + memset(&B, 0, 3 * 3 * nbytes); + // Remove surface settings int nall = nlocal + atom->nghost; - for (i = 0; i < nall; i++) { - for (a = 0; a < dim; a++) { - for (b = 0; b < dim; b++) { - B[i][a * dim + b] = 0.0; - gradC[i][a * dim + b] = 0.0; - } - nsurface[i][a] = 0.0; - } - divr[i] = 0.0; - - // Remove surface settings + for (i = 0; i < nall; i++) status[i] &= SURFACEMASK; - } // loop over neighbors to calculate the average orientation of neighbors for (ii = 0; ii < inum; ii++) { @@ -424,3 +412,25 @@ void ComputeRHEOSurface::unpack_forward_comm(int n, int first, double *buf) } } } + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOSurface::grow_arrays(int nmax) +{ + int dim = domain->dimension; + + // Grow atom variables and reassign pointers + memory->grow(atom->dvector[index_divr], nmax, "atom:rheo_divr"); + memory->grow(atom->dvector[index_rsurf], nmax, "atom:rheo_rsurface"); + memory->grow(atom->darray[index_nsurf], nmax, dim, "atom:rheo_nsurface"); + + divr = atom->dvector[index_divr]; + rsurface = atom->dvector[index_rsurf]; + nsurface = atom->darray[index_nsurf]; + + // Grow local variables + memory->grow(B, nmax, dim * dim, "rheo/surface:B"); + memory->grow(gradC, nmax, dim * dim, "rheo/surface:gradC"); + + nmax_store = atom->nmax; +} diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index 1d1cdba3fa..f1b1af7742 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -40,14 +40,18 @@ class ComputeRHEOSurface : public Compute { class FixRHEO *fix_rheo; private: - double cut, cutsq, rho0, threshold_divr; int surface_style, nmax_store, threshold_z, threshold_splash, interface_flag; - double **B, **gradC; int threshold_style, comm_stage; + int index_divr, index_rsurf, index_nsurf; + + double cut, cutsq, rho0, threshold_divr; + double **B, **gradC; class NeighList *list; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; + + void grow_arrays(int); }; } // namespace LAMMPS_NS diff --git a/src/RHEO/fix_rheo_tension.cpp b/src/RHEO/fix_rheo_tension.cpp new file mode 100644 index 0000000000..44bc3bf580 --- /dev/null +++ b/src/RHEO/fix_rheo_tension.cpp @@ -0,0 +1,452 @@ +/* ---------------------------------------------------------------------- + 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 authors: + Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) +----------------------------------------------------------------------- */ + +#include "fix_rheo_tension.h" + +#include "atom.h" +#include "comm.h" +#include "compute_rheo_kernel.h" +#include "compute_rheo_interface.h" +#include "domain.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "math_extra.h" +#include "memory.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "update.h" +#include "utils.h" + +#include + +using namespace LAMMPS_NS; +using namespace RHEO_NS; +using namespace MathExtra; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +FixRHEOTension::FixRHEOTension(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), compute_kernel(nullptr), compute_interface(nullptr), fix_rheo(nullptr) +{ + if (narg != 4) error->all(FLERR,"Illegal fix command"); + alpha = utils::numeric(FLERR,arg[3],false,lmp); + + comm_forward = 3; + comm_reverse = 3; + + // Create cgrad, n, and divr arrays as custom atom properties, + // can print with compute property/atom + // no grow callback as there's no reason to copy/exchange data, manually grow + // For norm, create a local array since they are unlikely to be printed + + int tmp1, tmp2; + index_cgradt = atom->find_custom("cgrad_rheo_tension", tmp1, tmp2); + if (index_cgradt == -1) index_cgradt = atom->add_custom("cgrad_rheo_tension", 1, 3); + cgradt = atom->darray[index_cgradt]; + + index_nt = atom->find_custom("n_rheo_tension", tmp1, tmp2); + if (index_nt == -1) index_nt = atom->add_custom("n_rheo_tension", 1, 3); + nt = atom->darray[index_nt]; + + index_divnt = atom->find_custom("divn_rheo_tension", tmp1, tmp2); + if (index_divnt == -1) index_divnt = atom->add_custom("divn_rheo_tension", 1, 0); + divnt = atom->dvector[index_divnt]; + + norm = nullptr; + nmax_store = 0; +} + +/* ---------------------------------------------------------------------- */ + +FixRHEOTension::~FixRHEOTension() +{ + // Remove custom property if it exists + int tmp1, tmp2, index; + + index = atom->find_custom("cgrad_rheo_tension", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 3); + + index = atom->find_custom("n_rheo_tension", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 3); + + index = atom->find_custom("divn_rheo_tension", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 0); + + memory->destroy(norm); +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOTension::setmask() +{ + int mask = 0; + mask |= POST_FORCE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOTension::init() +{ + auto fixes = modify->get_fix_by_style("^rheo$"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/tension"); + fix_rheo = dynamic_cast(fixes[0]); + + compute_kernel = fix_rheo->compute_kernel; + compute_interface = fix_rheo->compute_interface; + interface_flag = fix_rheo->interface_flag; + h = fix_rheo->h; + rho0 = fix_rheo->rho0; + + hsq = h * h; + + neighbor->add_request(this, NeighConst::REQ_DEFAULT); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOTension::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + + +/* ---------------------------------------------------------------------- */ + +void FixRHEOTension::setup(int vflag) +{ + // Grow and populate arrays + post_force(vflag); +} + +/* ---------------------------------------------------------------------- + Calculate and apply tension forces +------------------------------------------------------------------------- */ + +void FixRHEOTension::post_force(int vflag) +{ + int i, j, a, ii, jj, inum, jnum, itype, jtype; + int fluidi, fluidj; + double xtmp, ytmp, ztmp, w, wp, c; + double rhoi, rhoj, Voli, Volj; + double *dWij, *dWji; + double dx[3], ft[3]; + + int *ilist, *jlist, *numneigh, **firstneigh; + double imass, jmass, rsq, r, rinv; + + int nlocal = atom->nlocal; + int newton = force->newton; + int dim = domain->dimension; + + v_init(vflag); + + double **x = atom->x; + double **f = atom->f; + double *rho = atom->rho; + double *mass = atom->mass; + imageint *image = atom->image; + int *type = atom->type; + int *status = atom->status; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + if (nmax_store <= atom->nmax) + grow_arrays(atom->nmax); + + for (i = 0; i < nlocal+atom->nghost; i++) { + cgradt[i][0] = 0.0; + cgradt[i][1] = 0.0; + cgradt[i][2] = 0.0; + norm[i] = 0.0; + divnt[i] = 0.0; + } + + // Calculate color gradient + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + fluidi = !(status[i] & PHASECHECK); + jlist = firstneigh[i]; + jnum = numneigh[i]; + imass = mass[itype]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = lensq3(dx); + + if (rsq > hsq) continue; + + fluidj = !(status[j] & PHASECHECK); + jtype = type[j]; + r = sqrt(rsq); + rinv = 1 / r; + + rhoi = rho[i]; + rhoj = rho[j]; + + // Add corrections for walls + if (interface_flag) { + if (fluidi && (!fluidj)) { + rhoj = compute_interface->correct_rho(j, i); + } else if ((!fluidi) && fluidj) { + rhoi = compute_interface->correct_rho(i, j); + } else if ((!fluidi) && (!fluidj)) { + rhoi = rho0; + rhoj = rho0; + } + } + + Voli = mass[itype] / rhoi; + Volj = mass[jtype] / rhoj; + + wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2],r); + dWij = compute_kernel->dWij; + dWji = compute_kernel->dWji; + + c = 0; + if (itype == jtype) c += rhoi; + c /= (rhoi + rhoj); + + for (a = 0; a < 3; a++) { + cgradt[i][a] -= c * Volj * dWij[a]; + if (newton || j < nlocal) + cgradt[j][a] -= c * Voli * dWji[a]; + } + } + } + + comm_stage = 0; + comm_reverse = 3; + if (newton) comm->reverse_comm(this); + + // Calculate normal direction + double minv; + for (i = 0; i < nlocal; i++) { + minv = 1.0 / sqrt(cgradt[i][0] * cgradt[i][0] + cgradt[i][1] * cgradt[i][1] + cgradt[i][2] * cgradt[i][2]); + + for (a = 0; a < 3; a++) + nt[i][a] = cgradt[i][a] * minv; + } + + comm->forward_comm(this); + + // Calculate divergence + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + fluidi = !(status[i] & PHASECHECK); + jlist = firstneigh[i]; + jnum = numneigh[i]; + imass = mass[itype]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = lensq3(dx); + + if (rsq > hsq) continue; + + fluidj = !(status[j] & PHASECHECK); + jtype = type[j]; + r = sqrt(rsq); + rinv = 1 / r; + + rhoi = rho[i]; + rhoj = rho[j]; + + // Add corrections for walls + if (interface_flag) { + if (fluidi && (!fluidj)) { + rhoj = compute_interface->correct_rho(j, i); + } else if ((!fluidi) && fluidj) { + rhoi = compute_interface->correct_rho(i, j); + } else if ((!fluidi) && (!fluidj)) { + rhoi = rho0; + rhoj = rho0; + } + } + + Voli = mass[itype] / rhoi; + Volj = mass[jtype] / rhoj; + + wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2],r); + dWij = compute_kernel->dWij; + dWji = compute_kernel->dWji; + + for (a = 0; a < 3; a++) { + divnt[i] -= nt[i][a] * Volj * dWij[a]; + norm[i] -= dx[a] * Volj * dWij[a]; + if (newton || j < nlocal) { + divnt[j] -= nt[j][a] * Voli * dWji[a]; + norm[j] += dx[a] * Voli * dWji[a]; + } + } + } + } + + comm_stage = 1; + comm_reverse = 2; + if (newton) comm->reverse_comm(this); + + // Skip forces if it's setup + if (update->setupflag) return; + + // apply force + int prefactor; + double unwrap[3]; + double v[6]; + for (i = 0; i < nlocal; i++) { + itype = type[i]; + divnt[i] /= norm[i]; + + prefactor *= -alpha * divnt[i] / mass[itype]; + + for (a = 0; a < 3; a++) + f[i][a] += prefactor * cgradt[i][a]; + + if (evflag) { + domain->unmap(x[i], image[i], unwrap); + v[0] = prefactor * cgradt[i][0] * unwrap[0]; + v[1] = prefactor * cgradt[i][1] * unwrap[1]; + v[2] = prefactor * cgradt[i][2] * unwrap[2]; + v[3] = prefactor * cgradt[i][0] * unwrap[1]; + v[4] = prefactor * cgradt[i][0] * unwrap[2]; + v[5] = prefactor * cgradt[i][1] * unwrap[2]; + v_tally(i, v); + } + } + + + + if (evflag) { + + } + +} + + +/* ---------------------------------------------------------------------- */ + +int FixRHEOTension::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) +{ + int i, j, a, m; + m = 0; + + for (i = 0; i < n; i++) { + j = list[i]; + for (a = 0; a < 3; a++) + buf[m++] = nt[j][a]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOTension::unpack_forward_comm(int n, int first, double *buf) +{ + int i, a, m, last; + + m = 0; + last = first + n; + for (i = first; i < last; i++) + for (a = 0; a < 3; a++) + nt[i][a] = buf[m++]; +} + + +/* ---------------------------------------------------------------------- */ + +int FixRHEOTension::pack_reverse_comm(int n, int first, double *buf) +{ + int i, a, m, last; + + m = 0; + last = first + n; + if (comm_stage == 0) + for (i = first; i < last; i++) + for (a = 0; a < 3; a++) + buf[m++] = cgradt[i][a]; + else + for (i = first; i < last; i++) { + buf[m++] = norm[i]; + buf[m++] = divnt[i]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i, j, a, m; + + m = 0; + if (comm_stage == 0) + for (i = 0; i < n; i++) { + j = list[i]; + for (a = 0; a < 3; a++) + cgradt[j][a] += buf[m++]; + } + else + for (i = 0; i < n; i++) { + j = list[i]; + norm[j] += buf[m++]; + divnt[j] += buf[m++]; + } +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOTension::grow_arrays(int nmax) +{ + // Grow atom variables and reassign pointers + memory->grow(atom->darray[index_cgradt], nmax, 3, "atom:rheo_cgradt"); + memory->grow(atom->darray[index_nt], nmax, 3, "atom:rheo_nt"); + memory->grow(atom->dvector[index_divnt], nmax, "atom:rheo_divnt"); + + cgradt = atom->darray[index_cgradt]; + nt = atom->darray[index_nt]; + divnt = atom->dvector[index_divnt]; + + // Grow local variables + memory->grow(norm, nmax, "rheo/tension:norm"); + + nmax_store = atom->nmax; +} \ No newline at end of file diff --git a/src/RHEO/pair_rheo_tension.h b/src/RHEO/fix_rheo_tension.h similarity index 60% rename from src/RHEO/pair_rheo_tension.h rename to src/RHEO/fix_rheo_tension.h index 2a046ff324..74b8b71436 100644 --- a/src/RHEO/pair_rheo_tension.h +++ b/src/RHEO/fix_rheo_tension.h @@ -11,44 +11,45 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#ifdef PAIR_CLASS +#ifdef FIX_CLASS // clang-format off -PairStyle(rheo/tension,PairRHEOTension) +FixStyle(rheo/tension,FixRHEOTension) // clang-format on #else -#ifndef LMP_PAIR_RHEO_TENSION_H -#define LMP_PAIR_RHEO_TENSION_H +#ifndef LMP_FIX_RHEO_TENSION_H +#define LMP_FIX_RHEO_TENSION_H -#include "pair.h" +#include "fix.h" namespace LAMMPS_NS { -class PairRHEOTension : public Pair { +class FixRHEOTension : public Fix { public: - PairRHEOTension(class LAMMPS *); - ~PairRHEOTension() override; - void compute(int, int) override; - void settings(int, char **) override; - void coeff(int, char **) override; - void setup() override; - void init_style() override; - double init_one(int, int) override; + FixRHEOTension(class LAMMPS *, int, char **); + ~FixRHEOTension() override; + int setmask() override; + void init() override; + void init_list(int, class NeighList *) override; + void setup(int) override; + void post_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; int pack_reverse_comm(int, int, double *) override; void unpack_reverse_comm(int, int *, double *) override; + void grow_arrays(int) override; - protected: - int nmax_store; - double **nt, *ct; - double **alpha; - double h, hsq, hinv, hinv3; + private: + int nmax_store, comm_stage, interface_flag; + int index_nt, index_cgradt, index_divnt; - void allocate(); + double **nt, **cgradt, *divnt, *norm; + double alpha, h, hsq, hinv, hinv3, rho0; class ComputeRHEOKernel *compute_kernel; + class ComputeRHEOInterface *compute_interface; class FixRHEO *fix_rheo; + class NeighList *list; }; } // namespace LAMMPS_NS diff --git a/src/RHEO/pair_rheo_tension.cpp b/src/RHEO/pair_rheo_tension.cpp deleted file mode 100644 index ef0d0b60b4..0000000000 --- a/src/RHEO/pair_rheo_tension.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* ---------------------------------------------------------------------- - 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 authors: - Joel Clemmer (SNL) ------------------------------------------------------------------------ */ - -#include "pair_rheo_tension.h" - -#include "atom.h" -#include "comm.h" -#include "compute_rheo_kernel.h" -#include "domain.h" -#include "error.h" -#include "fix_rheo.h" -#include "force.h" -#include "math_extra.h" -#include "memory.h" -#include "modify.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "update.h" -#include "utils.h" - -#include - -using namespace LAMMPS_NS; -using namespace RHEO_NS; -using namespace MathExtra; - -static constexpr double EPSILON = 1e-2; - -/* ---------------------------------------------------------------------- */ - -PairRHEOTension::PairRHEOTension(LAMMPS *lmp) : - Pair(lmp), compute_kernel(nullptr), fix_rheo(nullptr) -{ - restartinfo = 0; - single_enable = 0; - - comm_forward = 3; - comm_reverse = 3; -} - -/* ---------------------------------------------------------------------- */ - -PairRHEOTension::~PairRHEOTension() -{ - // Remove custom property if it exists - int tmp1, tmp2, index; - - index = atom->find_custom("rheo_c_tension", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); - - index = atom->find_custom("rheo_n_tension", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 3); - - if (allocated) { - memory->destroy(alpha); - memory->destroy(setflag); - memory->destroy(cutsq); - } -} - -/* ---------------------------------------------------------------------- */ - -void PairRHEOTension::compute(int eflag, int vflag) -{ - int i, j, a, b, ii, jj, inum, jnum, itype, jtype; - int fluidi, fluidj; - double xtmp, ytmp, ztmp, w, wp; - double rhoi, rhoj, voli, volj; - double *dWij, *dWji; - double dx[3], ft[3]; - - int *ilist, *jlist, *numneigh, **firstneigh; - double imass, jmass, rsq, r, rinv; - - int nlocal = atom->nlocal; - int newton_pair = force->newton_pair; - int dim = domain->dimension; - - ev_init(eflag, vflag); - - double **x = atom->x; - double **f = atom->f; - double *rho = atom->rho; - double *mass = atom->mass; - double *special_lj = force->special_lj; - int *type = atom->type; - int *status = atom->status; - tagint *tag = atom->tag; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; -/* - int nmax = atom->nmax; - if (nmax_store <= nmax) { - memory->grow(ct, nmax, "atom:rheo_c_tension"); - memory->grow(nnt_tension, nmax, 3, "atom:rheo_n_tension"); - nmax_store = atom->nmax; - } - - // loop over neighbors of my atoms - - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - imass = mass[itype]; - rhoi = rho[i]; - voli = imass / rhoi; - fluidi = !(status[i] & PHASECHECK); - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - dx[0] = xtmp - x[j][0]; - dx[1] = ytmp - x[j][1]; - dx[2] = ztmp - x[j][2]; - rsq = lensq3(dx); - jtype = type[j]; - - if (rsq > hsq) continue; - - r = sqrt(rsq); - rinv = 1 / r; - - jmass = mass[jtype]; - rhoj = rho[j]; - volj = jmass / rhoj; - fluidj = !(status[j] & PHASECHECK); - - wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2],r); - dWij = compute_kernel->dWij; - dWji = compute_kernel->dWji; - - f[i][0] += ft[0]; - f[i][1] += ft[1]; - f[i][2] += ft[2]; - - if (evflag) // Does not account for unbalanced forces - ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], dx[0], dx[1], dx[2]); - - if (newton_pair || j < nlocal) { - - f[j][0] -= ft[0]; - f[j][1] -= ft[1]; - f[j][2] -= ft[2]; - } - } - } - - if (vflag_fdotr) virial_fdotr_compute(); - - comm->reverse_comm(this); - comm->forward_comm(this); -*/ -} - -/* ---------------------------------------------------------------------- - allocate all arrays - ------------------------------------------------------------------------- */ - -void PairRHEOTension::allocate() -{ - allocated = 1; - int n = atom->ntypes; - - memory->create(setflag, n + 1, n + 1, "pair:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - memory->create(alpha, n + 1, n + 1, "pair:alpha"); - memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); -} - -/* ---------------------------------------------------------------------- - global settings - ------------------------------------------------------------------------- */ - -void PairRHEOTension::settings(int narg, char **arg) -{ -} - -/* ---------------------------------------------------------------------- - set coeffs for one or more type pairs - ------------------------------------------------------------------------- */ - -void PairRHEOTension::coeff(int narg, char **arg) -{ - if (narg != 3) - error->all(FLERR,"Incorrect number of args for pair_style rheo coefficients"); - if (!allocated) - allocate(); - - int ilo, ihi, jlo, jhi; - utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi,error); - utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi,error); - - double alpha_one = utils::numeric(FLERR, arg[2], false, lmp); - - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = 0; j <= atom->ntypes; j++) { - alpha[i][j] = alpha_one; - setflag[i][j] = 1; - count++; - } - } - - if (count == 0) - error->all(FLERR,"Incorrect args for pair rheo/tension coefficients"); -} - -/* ---------------------------------------------------------------------- - setup specific to this pair style - ------------------------------------------------------------------------- */ - -void PairRHEOTension::setup() -{ - auto fixes = modify->get_fix_by_style("rheo"); - if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use pair rheo"); - fix_rheo = dynamic_cast(fixes[0]); - /* - compute_kernel = fix_rheo->compute_kernel; - compute_grad = fix_rheo->compute_grad; - compute_interface = fix_rheo->compute_interface; - h = fix_rheo->h; - csq = fix_rheo->csq; - rho0 = fix_rheo->rho0; - - hsq = h * h; - hinv = 1.0 / h; - hinv3 = hinv * 3.0; - */ -} - -/* ---------------------------------------------------------------------- - init specific to this pair style -------------------------------------------------------------------------- */ - -void PairRHEOTension::init_style() -{ - neighbor->add_request(this); - - - // Create c_tension arrays n_tension arrays if they don't already exist - // Create a custom atom property so it works with compute property/atom - // Do not create grow callback as there's no reason to copy/exchange data - // Manually grow if nmax_store exceeded - // For B and gradC, create a local array since they are unlikely to be printed - - int tmp1, tmp2; - int index = atom->find_custom("rheo_c_tension", tmp1, tmp2); - if (index == -1) index = atom->add_custom("rheo_c_tension", 1, 0); - ct = atom->dvector[index]; - - index = atom->find_custom("rheo_n_tension", tmp1, tmp2); - if (index == -1) index = atom->add_custom("rheo_n_tension", 1, 3); - nt = atom->darray[index]; - - nmax_store = atom->nmax; -} - -/* ---------------------------------------------------------------------- - init for one type pair i,j and corresponding j,i - ------------------------------------------------------------------------- */ - -double PairRHEOTension::init_one(int i, int j) -{ - if (setflag[i][j] == 0) - error->all(FLERR,"All pair rheo/tension coeffs are not set"); - - alpha[j][i] = alpha[i][j]; - - return h; -} - - -/* ---------------------------------------------------------------------- */ - -int PairRHEOTension::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) -{ - /* - int i,j,k,m; - m = 0; - double *rho = atom->rho; - - for (i = 0; i < n; i++) { - j = list[i]; - if (comm_stage == 0) { - buf[m++] = fp_store[j][0]; - buf[m++] = fp_store[j][1]; - buf[m++] = fp_store[j][2]; - } else { - buf[m++] = chi[j]; - buf[m++] = rho[j]; - } - } - return m; - */ -} - -/* ---------------------------------------------------------------------- */ - -void PairRHEOTension::unpack_forward_comm(int n, int first, double *buf) -{ - /* - int i, k, m, last; - double *rho = atom->rho; - m = 0; - last = first + n; - for (i = first; i < last; i++) { - if (comm_stage == 0) { - fp_store[i][0] = buf[m++]; - fp_store[i][1] = buf[m++]; - fp_store[i][2] = buf[m++]; - } else { - chi[i] = buf[m++]; - rho[i] = buf[m++]; - } - } - */ -} - - -/* ---------------------------------------------------------------------- */ - -int PairRHEOTension::pack_reverse_comm(int n, int first, double *buf) -{ - /* - int i, k, m, last; - double **fp_store = compute_interface->fp_store; - - m = 0; - last = first + n; - for (i = first; i < last; i++) { - buf[m++] = fp_store[i][0]; - buf[m++] = fp_store[i][1]; - buf[m++] = fp_store[i][2]; - } - - return m; - */ -} - -/* ---------------------------------------------------------------------- */ - -void PairRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) -{ - /* - int i, j, k, m; - double **fp_store = compute_interface->fp_store; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - fp_store[j][0] += buf[m++]; - fp_store[j][1] += buf[m++]; - fp_store[j][2] += buf[m++]; - } - */ -} From 5b14b7c86c25d3ff5d522d101f69b998752df486 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 1 Nov 2023 13:42:33 -0600 Subject: [PATCH 053/104] Fixing gitignore --- src/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/.gitignore b/src/.gitignore index c7e022797f..1e634782dc 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -199,6 +199,8 @@ /atom_vec_rheo.cpp /atom_vec_rheo.h +/atom_vec_rheo_thermal.cpp +/atom_vec_rheo_thermal.h /compute_rheo_grad.cpp /compute_rheo_grad.h /compute_rheo_interface.cpp From 16a3abdadd53f2e6ec2bd50118db4dfe70a9fb53 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 3 Nov 2023 13:33:03 -0600 Subject: [PATCH 054/104] Filling in tension and react --- src/RHEO/fix_rheo_tension.cpp | 44 +++-- src/RHEO/fix_rheo_tension.h | 4 +- src/RHEO/pair_rheo_react.cpp | 301 +++++++++++++--------------------- src/RHEO/pair_rheo_react.h | 8 +- 4 files changed, 150 insertions(+), 207 deletions(-) diff --git a/src/RHEO/fix_rheo_tension.cpp b/src/RHEO/fix_rheo_tension.cpp index 44bc3bf580..047f1d217e 100644 --- a/src/RHEO/fix_rheo_tension.cpp +++ b/src/RHEO/fix_rheo_tension.cpp @@ -70,6 +70,10 @@ FixRHEOTension::FixRHEOTension(LAMMPS *lmp, int narg, char **arg) : if (index_divnt == -1) index_divnt = atom->add_custom("divn_rheo_tension", 1, 0); divnt = atom->dvector[index_divnt]; + index_ft = atom->find_custom("f_rheo_tension", tmp1, tmp2); + if (index_ft == -1) index_ft = atom->add_custom("f_rheo_tension", 1, 3); + ft = atom->darray[index_ft]; + norm = nullptr; nmax_store = 0; } @@ -90,6 +94,9 @@ FixRHEOTension::~FixRHEOTension() index = atom->find_custom("divn_rheo_tension", tmp1, tmp2); if (index != -1) atom->remove_custom(index, 1, 0); + index = atom->find_custom("f_rheo_tension", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 3); + memory->destroy(norm); } @@ -148,7 +155,7 @@ void FixRHEOTension::post_force(int vflag) double xtmp, ytmp, ztmp, w, wp, c; double rhoi, rhoj, Voli, Volj; double *dWij, *dWji; - double dx[3], ft[3]; + double dx[3]; int *ilist, *jlist, *numneigh, **firstneigh; double imass, jmass, rsq, r, rinv; @@ -234,7 +241,7 @@ void FixRHEOTension::post_force(int vflag) dWji = compute_kernel->dWji; c = 0; - if (itype == jtype) c += rhoi; + if (itype != jtype) c += rhoi; c /= (rhoi + rhoj); for (a = 0; a < 3; a++) { @@ -252,7 +259,9 @@ void FixRHEOTension::post_force(int vflag) // Calculate normal direction double minv; for (i = 0; i < nlocal; i++) { - minv = 1.0 / sqrt(cgradt[i][0] * cgradt[i][0] + cgradt[i][1] * cgradt[i][1] + cgradt[i][2] * cgradt[i][2]); + minv = sqrt(cgradt[i][0] * cgradt[i][0] + cgradt[i][1] * cgradt[i][1] + cgradt[i][2] * cgradt[i][2]); + + if (minv != 0) minv = 1 / minv; for (a = 0; a < 3; a++) nt[i][a] = cgradt[i][a] * minv; @@ -310,11 +319,13 @@ void FixRHEOTension::post_force(int vflag) dWij = compute_kernel->dWij; dWji = compute_kernel->dWji; + if (itype != jtype) continue; // have to think about this... + for (a = 0; a < 3; a++) { - divnt[i] -= nt[i][a] * Volj * dWij[a]; + divnt[i] -= (nt[i][a]-nt[j][a]) * Volj * dWij[a]; norm[i] -= dx[a] * Volj * dWij[a]; if (newton || j < nlocal) { - divnt[j] -= nt[j][a] * Voli * dWji[a]; + divnt[j] += (nt[i][a]-nt[j][a]) * Voli * dWji[a]; norm[j] += dx[a] * Voli * dWji[a]; } } @@ -329,17 +340,23 @@ void FixRHEOTension::post_force(int vflag) if (update->setupflag) return; // apply force - int prefactor; + double prefactor; double unwrap[3]; double v[6]; for (i = 0; i < nlocal; i++) { itype = type[i]; - divnt[i] /= norm[i]; - prefactor *= -alpha * divnt[i] / mass[itype]; + if (norm[i] != 0) + divnt[i] /= norm[i]; + else + divnt[i] = 0.0; - for (a = 0; a < 3; a++) + prefactor = -alpha * divnt[i]; + + for (a = 0; a < 3; a++) { f[i][a] += prefactor * cgradt[i][a]; + ft[i][a] = prefactor * cgradt[i][a]; + } if (evflag) { domain->unmap(x[i], image[i], unwrap); @@ -352,13 +369,6 @@ void FixRHEOTension::post_force(int vflag) v_tally(i, v); } } - - - - if (evflag) { - - } - } @@ -440,10 +450,12 @@ void FixRHEOTension::grow_arrays(int nmax) memory->grow(atom->darray[index_cgradt], nmax, 3, "atom:rheo_cgradt"); memory->grow(atom->darray[index_nt], nmax, 3, "atom:rheo_nt"); memory->grow(atom->dvector[index_divnt], nmax, "atom:rheo_divnt"); + memory->grow(atom->darray[index_ft], nmax, 3, "atom:rheo_ft"); cgradt = atom->darray[index_cgradt]; nt = atom->darray[index_nt]; divnt = atom->dvector[index_divnt]; + ft = atom->darray[index_ft]; // Grow local variables memory->grow(norm, nmax, "rheo/tension:norm"); diff --git a/src/RHEO/fix_rheo_tension.h b/src/RHEO/fix_rheo_tension.h index 74b8b71436..11bc209d88 100644 --- a/src/RHEO/fix_rheo_tension.h +++ b/src/RHEO/fix_rheo_tension.h @@ -41,9 +41,9 @@ class FixRHEOTension : public Fix { private: int nmax_store, comm_stage, interface_flag; - int index_nt, index_cgradt, index_divnt; + int index_nt, index_cgradt, index_divnt, index_ft; - double **nt, **cgradt, *divnt, *norm; + double **nt, **cgradt, *divnt, *norm, **ft; double alpha, h, hsq, hinv, hinv3, rho0; class ComputeRHEOKernel *compute_kernel; diff --git a/src/RHEO/pair_rheo_react.cpp b/src/RHEO/pair_rheo_react.cpp index 7ec63bb2a9..4846e077f6 100644 --- a/src/RHEO/pair_rheo_react.cpp +++ b/src/RHEO/pair_rheo_react.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "comm.h" +#include "compute_rheo_surface.h" #include "error.h" #include "fix.h" #include "fix_dummy.h" @@ -35,6 +36,7 @@ #include "utils.h" using namespace LAMMPS_NS; +using namespace RHEO_NS; /* ---------------------------------------------------------------------- */ @@ -45,6 +47,7 @@ PairRHEOReact::PairRHEOReact(LAMMPS *lmp) : Pair(lmp), size_history = 2; beyond_contact = 1; comm_reverse = 1; + nondefault_history_transfer = 1; // create dummy fix as placeholder for FixNeighHistory // this is so final order of Modify:fix will conform to input script @@ -92,8 +95,6 @@ PairRHEOReact::~PairRHEOReact() memory->destroy(gamma); memory->destroy(t_form); memory->destroy(rlimit); - memory->destroy(sigma); - memory->destroy(krepel); } memory->destroy(dbond); @@ -103,23 +104,21 @@ PairRHEOReact::~PairRHEOReact() void PairRHEOReact::compute(int eflag, int vflag) { - int i,j,ii,jj,inum,jnum; - double xtmp,ytmp,ztmp,delx,dely,delz; - double rsq,r,rinv,r0; - double vxtmp,vytmp,vztmp,delvx,delvy,delvz; - double fpair,dot,evdwl,smooth; + int i, j, ii, jj, inum, jnum, fluidi, fluidj; + double xtmp, ytmp, ztmp, delx, dely, delz; + double vxtmp, vytmp, vztmp, delvx, delvy, delvz; + double rsq, r, rinv, r0, fpair, dot, smooth; int itype, jtype; - int *ilist,*jlist,*numneigh,**firstneigh; - int *saved,**firstsaved; - double *data,*alldata,**firstdata; + int *ilist, *jlist, *numneigh, **firstneigh; + int *saved, **firstsaved; + double *data, *alldata, **firstdata; ev_init(eflag,vflag); int bondupdate = 1; if (update->setupflag) bondupdate = 0; - - dt = update->dt; + double dt = update->dt; double **x = atom->x; double **v = atom->v; @@ -128,6 +127,7 @@ void PairRHEOReact::compute(int eflag, int vflag) int *status = atom->status; int *mask = atom->mask; int *nbond = atom->ivector[index_nb]; + double *rsurf = compute_surface->rsurface; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; @@ -139,17 +139,15 @@ void PairRHEOReact::compute(int eflag, int vflag) firstsaved = fix_history->firstflag; firstdata = fix_history->firstvalue; - if (atom->nmax > nmax){ - nmax = atom->nmax; + if (atom->nmax > nmax_store){ + nmax_store = atom->nmax; memory->destroy(dbond); - memory->create(dbond, nmax, "rheo/react:dbond"); + memory->create(dbond, nmax_store, "rheo/react:dbond"); } - // Switch to no shift if it has bonds (could have just been changed from reactive) - for(i = 0; i < nmax; i++) { - dbond[i] = 0; - } -/* + size_t nbytes = nmax_store * sizeof(int); + memset(&dbond, 0, nbytes); + // loop over neighbors of my atoms for (ii = 0; ii < inum; ii++) { i = ilist[ii]; @@ -160,30 +158,30 @@ void PairRHEOReact::compute(int eflag, int vflag) vxtmp = v[i][0]; vytmp = v[i][1]; vztmp = v[i][2]; + fluidi = !(status[i] & PHASECHECK); + saved = firstsaved[i]; alldata = firstdata[i]; jlist = firstneigh[i]; jnum = numneigh[i]; - for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; jtype = type[j]; + fluidj = !(status[j] & PHASECHECK); data = &alldata[2*jj]; - // If not bonded and there's an internal fluid particle, unsave any data and skip if (!(saved[jj] == 1 && data[0] > 0)) { - if ((status[i] <= FixRHEO::FLUID_MAX && rsurf[i] > rlimit[itype][jtype]) || (status[j] <= FixRHEO::FLUID_MAX && rsurf[j] > rlimit[itype][jtype])) { + if ((fluidi && (rsurf[i] > rlimit[itype][jtype])) || (fluidj && (rsurf[j] > rlimit[itype][jtype]))) { saved[jj] = 0; continue; } } // If both are solid, unbond and skip - if ((status[i] == FixRHEO::SOLID || status[i] == FixRHEO::FREEZING) && - (status[j] == FixRHEO::SOLID || status[j] == FixRHEO::FREEZING)) { + if (!fluidi && !fluidj) { //If bonded, deincrement if (saved[jj] == 1 && data[0] > 0) { dbond[i] --; @@ -193,12 +191,10 @@ void PairRHEOReact::compute(int eflag, int vflag) continue; } - // Remaining options are react+sold, react+react, react+surf/fluid, or surf/fluid+surf/fluid - delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; - rsq = delx*delx + dely*dely + delz*delz; + rsq = delx * delx + dely * dely + delz * delz; // If unbonded and beyond bond distance, unsave and skip if (data[0] == -1 && rsq > cutbsq[itype][jtype]) { @@ -217,7 +213,7 @@ void PairRHEOReact::compute(int eflag, int vflag) // Check for bond formation (unbonded) or breakage (bonded) if (data[0] == -1) { // If unbonded, check if we count down to bonding if both on surface (not given for r or s) - if (bondupdate && rsurf[i] <= rlimit[itype][jtype] && rsurf[j] <= rlimit[itype][jtype]) { + if (bondupdate && (rsurf[i] <= rlimit[itype][jtype]) && (rsurf[j] <= rlimit[itype][jtype])) { data[1] += dt; if (data[1] >= t_form[itype][jtype]) { data[0] = r; @@ -229,7 +225,7 @@ void PairRHEOReact::compute(int eflag, int vflag) } else { // If bonded, check if breaks in tension r0 = data[0]; - if (r > ((1.0+eps[itype][jtype])*r0)) { + if (r > ((1.0 + eps[itype][jtype]) * r0)) { saved[jj] = 0; dbond[i] --; dbond[j] --; @@ -237,89 +233,57 @@ void PairRHEOReact::compute(int eflag, int vflag) } } - // Apply forces + // Skip if unbonded + if (data[0] <= 0) continue; + delvx = vxtmp - v[j][0]; delvy = vytmp - v[j][1]; delvz = vztmp - v[j][2]; - rinv = 1.0/r; + rinv = 1.0 / r; + r0 = data[0]; - if (data[0] <= 0) { - // Skip if either is fluid (only include r+s or r+r since already skipped s+s) - if (status[i] <= FixRHEO::FLUID_MAX || status[j] <= FixRHEO::FLUID_MAX) continue; + fpair = k[itype][jtype] * (r0 - r); - // Skip if out of contact - if (rsq > sigma[itype][jtype]*sigma[itype][jtype]) continue; + dot = delx * delvx + dely * delvy + delz * delvz; + fpair -= gamma[itype][jtype] * dot * rinv; - fpair = krepel[itype][jtype]*(sigma[itype][jtype]-r); - if (eflag) - evdwl = -0.5*krepel[itype][jtype]*(sigma[itype][jtype]-r)*(sigma[itype][jtype]-r); - - smooth = rsq/(sigma[itype][jtype]*sigma[itype][jtype]); + smooth = 1.0; + if (r > r0) { + smooth = (r - r0) / (r0 * eps[itype][jtype]); smooth *= smooth; - smooth = 1.0 - smooth; - dot = delx*delvx + dely*delvy + delz*delvz; - fpair -= gamma[itype][jtype]*dot*smooth*rinv; - - fpair *= rinv; - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - - if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); - } else { - // Bonded - r0 = data[0]; - - fpair = k[itype][jtype]*(r0-r); - if (evflag) evdwl = -0.5*fpair*(r0-r); - - dot = delx*delvx + dely*delvy + delz*delvz; - fpair -= gamma[itype][jtype]*dot*rinv; - - smooth = 1.0; - if (r > r0) { - smooth = (r-r0)/(r0*eps[itype][jtype]); - smooth *= smooth; - smooth *= smooth; - smooth = 1 - smooth; - } - - fpair *= rinv*smooth; - - f[i][0] += delx*fpair; - f[i][1] += dely*fpair; - f[i][2] += delz*fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx*fpair; - f[j][1] -= dely*fpair; - f[j][2] -= delz*fpair; - } - - if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); + smooth *= smooth; + smooth = 1 - smooth; } + + fpair *= rinv * smooth; + + f[i][0] += delx * fpair; + f[i][1] += dely * fpair; + f[i][2] += delz * fpair; + if (newton_pair || j < nlocal) { + f[j][0] -= delx * fpair; + f[j][1] -= dely * fpair; + f[j][2] -= delz * fpair; + } + + if (evflag) ev_tally(i, j, nlocal, newton_pair, 0.0, 0.0, fpair, delx, dely, delz); } } // Communicate changes in nbond - if(newton_pair) comm->reverse_comm_pair(this); + if (newton_pair) comm->reverse_comm(this); for(i = 0; i < nlocal; i++) { + fluidi = !(status[i] & PHASECHECK); nbond[i] += dbond[i]; // If it has bonds it is reactive (no shifting) // If a reactive particle breaks all bonds, return to fluid // Keep it non-shifting for this timestep to be safe - if (nbond[i] != 0 && status[i] <= FixRHEO::FLUID_MAX) status[i] = FixRHEO::FLUID_NO_SHIFT; + if (nbond[i] != 0 && fluidi) status[i] |= STATUS_NO_SHIFT; } if (vflag_fdotr) virial_fdotr_compute(); - */ } /* ---------------------------------------------------------------------- @@ -331,22 +295,20 @@ void PairRHEOReact::allocate() allocated = 1; int n = atom->ntypes; - memory->create(setflag,n+1,n+1,"pair:setflag"); + memory->create(setflag, n+1, n+1,"pair:setflag"); for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) setflag[i][j] = 0; - memory->create(cut,n+1,n+1,"pair:cut"); - memory->create(cutbond,n+1,n+1,"pair:cutbond"); - memory->create(cutsq,n+1,n+1,"pair:cutsq"); - memory->create(cutbsq,n+1,n+1,"pair:cutbsq"); - memory->create(k,n+1,n+1,"pair:k"); - memory->create(eps,n+1,n+1,"pair:eps"); - memory->create(gamma,n+1,n+1,"pair:gamma"); - memory->create(t_form,n+1,n+1,"pair:t_form"); - memory->create(rlimit,n+1,n+1,"pair:rlimit"); - memory->create(sigma,n+1,n+1,"pair:sigma"); - memory->create(krepel,n+1,n+1,"pair:krepel"); + memory->create(cut, n+1, n+1,"pair:cut"); + memory->create(cutbond, n+1, n+1,"pair:cutbond"); + memory->create(cutsq, n+1, n+1,"pair:cutsq"); + memory->create(cutbsq, n+1, n+1,"pair:cutbsq"); + memory->create(k, n+1, n+1,"pair:k"); + memory->create(eps, n+1, n+1,"pair:eps"); + memory->create(gamma, n+1, n+1,"pair:gamma"); + memory->create(t_form, n+1, n+1,"pair:t_form"); + memory->create(rlimit, n+1, n+1,"pair:rlimit"); } /* ---------------------------------------------------------------------- @@ -363,25 +325,23 @@ void PairRHEOReact::settings(int narg, char **arg) void PairRHEOReact::coeff(int narg, char **arg) { - if (narg != 11) error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg != 9) error->all(FLERR,"Incorrect args for pair coefficients"); if (!allocated) allocate(); - int ilo,ihi,jlo,jhi; - utils::bounds(FLERR,arg[0],1, atom->ntypes, ilo, ihi,error); - utils::bounds(FLERR,arg[1],1, atom->ntypes, jlo, jhi,error); + int ilo, ihi, jlo, jhi; + utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi,error); + utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi,error); - double cut_one = utils::numeric(FLERR,arg[2],false,lmp); - double cutb_one = utils::numeric(FLERR,arg[3],false,lmp); - double k_one = utils::numeric(FLERR,arg[4],false,lmp); - double eps_one = utils::numeric(FLERR,arg[5],false,lmp); - double gamma_one = utils::numeric(FLERR,arg[6],false,lmp); - double t_form_one = utils::numeric(FLERR,arg[7],false,lmp); - double rlimit_one = utils::numeric(FLERR,arg[8],false,lmp); - double sigma_one = utils::numeric(FLERR,arg[9],false,lmp); - double krepel_one = utils::numeric(FLERR,arg[10],false,lmp); + double cut_one = utils::numeric(FLERR, arg[2], false, lmp); + double cutb_one = utils::numeric(FLERR, arg[3], false, lmp); + double k_one = utils::numeric(FLERR, arg[4], false, lmp); + double eps_one = utils::numeric(FLERR, arg[5], false, lmp); + double gamma_one = utils::numeric(FLERR, arg[6], false, lmp); + double t_form_one = utils::numeric(FLERR, arg[7], false, lmp); + double rlimit_one = utils::numeric(FLERR, arg[8], false, lmp); if (k_one < 0.0 || eps_one < 0.0 || - t_form_one < 0.0 || (1.0+eps_one)*cutb_one > cut_one) + t_form_one < 0.0 || (1.0 + eps_one) * cutb_one > cut_one) error->all(FLERR,"Illegal pair_style command"); int count = 0; @@ -394,8 +354,6 @@ void PairRHEOReact::coeff(int narg, char **arg) gamma[i][j] = gamma_one; t_form[i][j] = t_form_one; rlimit[i][j] = rlimit_one; - sigma[i][j] = sigma_one; - krepel[i][j] = krepel_one; setflag[i][j] = 1; count++; } @@ -414,47 +372,31 @@ void PairRHEOReact::init_style() //neighbor->requests[irequest]->history = 1; if (fix_history == nullptr) { - - // Don't want history[i][j] = -history[j][i] - nondefault_history_transfer = 1; - - char dnumstr[16]; - sprintf(dnumstr,"%d",size_history); - char **fixarg = new char*[4]; - fixarg[0] = (char *) "NEIGH_HISTORY_RHEO_REACT"; - fixarg[1] = (char *) "all"; - fixarg[2] = (char *) "NEIGH_HISTORY"; - fixarg[3] = dnumstr; - modify->replace_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY",4,fixarg,1); - delete [] fixarg; - int ifix = modify->find_fix("NEIGH_HISTORY_RHEO_REACT"); - fix_history = (FixNeighHistory *) modify->fix[ifix]; + auto cmd = fmt::format("NEIGH_HISTORY_RHEO_REACT {} all NEIGH_HISTORY {}", instance_me, size_history); + fix_history = dynamic_cast( + modify->replace_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY" + std::to_string(instance_me), cmd, 1)); fix_history->pair = this; fix_dummy = nullptr; } - - //int temp_flag; - //index_rsurf = atom->find_custom("rsurf", temp_flag); - //if ((index_rsurf < 0) || (temp_flag != 1)) - // error->all(FLERR, "Pair rheo/react can't find fix property/atom rsurf"); } /* ---------------------------------------------------------------------- setup specific to this pair style ------------------------------------------------------------------------- */ -void PairRHEOReact::setup() { - /* - int ifix = modify->find_fix_by_style("rheo"); - if (ifix == -1) error->all(FLERR, "Using pair rheo/react without fix rheo"); - fix_rheo = ((FixRHEO *) modify->fix[ifix]); +void PairRHEOReact::setup() +{ + auto fixes = modify->get_fix_by_style("^rheo$"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/tension"); + fix_rheo = dynamic_cast(fixes[0]); - ifix = modify->find_fix_by_style("rheo/surface"); - if (ifix == -1) error->all(FLERR, "Using pair rheo/react without fix rheo/surface"); + if (!fix_rheo->surface_flag) error->all(FLERR, + "Pair rheo/react requires surface calculation in fix rheo"); + + compute_surface = fix_rheo->compute_surface; if (force->newton_pair == 0) error->all(FLERR, "Pair rheo/react needs newton pair on for bond changes to be consistent"); - */ } /* ---------------------------------------------------------------------- @@ -465,9 +407,7 @@ double PairRHEOReact::init_one(int i, int j) { if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); - double einv = 1/eps[i][j]; - - cutbsq[i][j] = cutbond[i][j]*cutbond[i][j]; + cutbsq[i][j] = cutbond[i][j] * cutbond[i][j]; cutbsq[j][i] = cutbsq[i][j]; cut[j][i] = cut[i][j]; @@ -477,8 +417,6 @@ double PairRHEOReact::init_one(int i, int j) gamma[j][i] = gamma[i][j]; t_form[j][i] = t_form[i][j]; rlimit[j][i] = rlimit[i][j]; - sigma[j][i] = sigma[i][j]; - krepel[j][i] = krepel[i][j]; return cut[i][j]; } @@ -494,17 +432,15 @@ void PairRHEOReact::write_restart(FILE *fp) int i,j; for (i = 1; i <= atom->ntypes; i++) for (j = i; j <= atom->ntypes; j++) - fwrite(&setflag[i][j],sizeof(int),1,fp); + fwrite(&setflag[i][j], sizeof(int), 1, fp); if (setflag[i][j]) { - fwrite(&cut[i][j],sizeof(double),1,fp); - fwrite(&cutbond[i][j],sizeof(double),1,fp); - fwrite(&k[i][j],sizeof(double),1,fp); - fwrite(&eps[i][j],sizeof(double),1,fp); - fwrite(&gamma[i][j],sizeof(double),1,fp); - fwrite(&t_form[i][j],sizeof(double),1,fp); - fwrite(&rlimit[i][j],sizeof(double),1,fp); - fwrite(&sigma[i][j],sizeof(double),1,fp); - fwrite(&krepel[i][j],sizeof(double),1,fp); + fwrite(&cut[i][j], sizeof(double), 1, fp); + fwrite(&cutbond[i][j], sizeof(double), 1, fp); + fwrite(&k[i][j], sizeof(double), 1, fp); + fwrite(&eps[i][j], sizeof(double), 1, fp); + fwrite(&gamma[i][j], sizeof(double), 1, fp); + fwrite(&t_form[i][j], sizeof(double), 1, fp); + fwrite(&rlimit[i][j], sizeof(double), 1, fp); } } @@ -521,29 +457,25 @@ void PairRHEOReact::read_restart(FILE *fp) int me = comm->me; for (i = 1; i <= atom->ntypes; i++) for (j = i; j <= atom->ntypes; j++) { - if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp); - MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world); + if (me == 0) fread(&setflag[i][j], sizeof(int), 1, fp); + MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world); if (setflag[i][j]) { if (me == 0) { - fread(&cut[i][j],sizeof(double),1,fp); - fread(&cutbond[i][j],sizeof(double),1,fp); - fread(&k[i][j],sizeof(double),1,fp); - fread(&eps[i][j],sizeof(double),1,fp); - fread(&gamma[i][j],sizeof(double),1,fp); - fread(&t_form[i][j],sizeof(double),1,fp); - fread(&rlimit[i][j],sizeof(double),1,fp); - fread(&sigma[i][j],sizeof(double),1,fp); - fread(&krepel[i][j],sizeof(double),1,fp); + fread(&cut[i][j], sizeof(double), 1, fp); + fread(&cutbond[i][j], sizeof(double), 1, fp); + fread(&k[i][j], sizeof(double), 1, fp); + fread(&eps[i][j], sizeof(double), 1, fp); + fread(&gamma[i][j], sizeof(double), 1, fp); + fread(&t_form[i][j], sizeof(double), 1, fp); + fread(&rlimit[i][j], sizeof(double), 1, fp); } - MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&cutbond[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&k[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&eps[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&gamma[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&t_form[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&rlimit[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&sigma[i][j],1,MPI_DOUBLE,0,world); - MPI_Bcast(&krepel[i][j],1,MPI_DOUBLE,0,world); + MPI_Bcast(&cut[i][j], 1,MPI_DOUBLE, 0, world); + MPI_Bcast(&cutbond[i][j], 1,MPI_DOUBLE, 0, world); + MPI_Bcast(&k[i][j], 1,MPI_DOUBLE, 0, world); + MPI_Bcast(&eps[i][j], 1,MPI_DOUBLE, 0, world); + MPI_Bcast(&gamma[i][j], 1,MPI_DOUBLE, 0, world); + MPI_Bcast(&t_form[i][j], 1,MPI_DOUBLE, 0, world); + MPI_Bcast(&rlimit[i][j], 1,MPI_DOUBLE, 0, world); } } } @@ -565,8 +497,7 @@ void PairRHEOReact::transfer_history(double* source, double* target) int PairRHEOReact::pack_reverse_comm(int n, int first, double *buf) { - int i,m,last; - + int i, m, last; m = 0; last = first + n; @@ -580,7 +511,7 @@ int PairRHEOReact::pack_reverse_comm(int n, int first, double *buf) void PairRHEOReact::unpack_reverse_comm(int n, int *list, double *buf) { - int i,j,m; + int i, j, m; m = 0; for (i = 0; i < n; i++) { diff --git a/src/RHEO/pair_rheo_react.h b/src/RHEO/pair_rheo_react.h index b349300f27..144859e68b 100644 --- a/src/RHEO/pair_rheo_react.h +++ b/src/RHEO/pair_rheo_react.h @@ -40,21 +40,21 @@ class PairRHEOReact : public Pair { void unpack_reverse_comm(int, int *, double *) override; protected: - double **cut,**cutbond,**cutbsq, **k, **eps, **gamma, **t_form, **rlimit, **sigma, **krepel; + double **cut, **cutbond, **cutbsq, **k, **eps, **gamma, **t_form, **rlimit; void allocate(); void transfer_history(double*, double*); - int size_history, nmax_store; + int size_history; int *dbond, *nbond; - double dt; - int index_nb, nmax; + int index_nb, nmax_store; char *id_fix; class FixDummy *fix_dummy; class FixNeighHistory *fix_history; class FixRHEO *fix_rheo; + class ComputeRHEOSurface *compute_surface; }; } // namespace LAMMPS_NS From 92ff79af0810209c5ac96a31148f79a6e3693b29 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 6 Nov 2023 16:22:02 -0700 Subject: [PATCH 055/104] Debugging BPM coupling --- src/RHEO/fix_rheo.cpp | 4 +- src/RHEO/fix_rheo.h | 2 +- src/RHEO/fix_rheo_thermal.cpp | 150 +++++++++++++++++++++------------- src/RHEO/fix_rheo_thermal.h | 6 +- src/set.cpp | 2 +- 5 files changed, 101 insertions(+), 63 deletions(-) diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index c8dca74d32..97b867179e 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -150,7 +150,7 @@ void FixRHEO::post_constructor() compute_kernel->fix_rheo = this; std::string cmd = "rheo_grad all RHEO/GRAD velocity rho viscosity"; - if (thermal_flag) cmd += "temperature"; + if (thermal_flag) cmd += " temperature"; compute_grad = dynamic_cast(modify->add_compute(cmd)); compute_grad->fix_rheo = this; @@ -254,7 +254,7 @@ void FixRHEO::setup(int /*vflag*/) covered = 0; for (auto fix : therm_fixes) if (mask[i] & fix->groupbit) covered = 1; - if (!covered) v_coverage_flag = 0; + if (!covered) t_coverage_flag = 0; } } diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 0b864bb602..da98f3d09a 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -75,7 +75,7 @@ namespace RHEO_NS { enum Status{ // Phase status STATUS_SOLID = 1 << 0, - STATUS_REACTIVE = 1 << 1, + // STATUS_REACTIVE = 1 << 1, // Surface status STATUS_BULK = 1 << 2, diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 48a22a5419..ba61619594 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -51,6 +51,9 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : { if (narg < 4) error->all(FLERR,"Illegal fix command"); + force_reneighbor = 1; + next_reneighbor = -1; + Tc_style = NONE; cv_style = NONE; conductivity_style = NONE; @@ -109,7 +112,6 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : if (iarg + 2 >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); Tc_style = CONSTANT; Tc = utils::numeric(FLERR,arg[iarg + 2],false,lmp); - if (Tc < 0.0) error->all(FLERR,"The melting temperature must be positive"); iarg += 2; } else if (strcmp(arg[iarg + 1],"type") == 0) { if (iarg + 1 + ntypes >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); @@ -130,6 +132,8 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : comm_forward = 1; if (cut_bond <= 0.0) error->all(FLERR, "Illegal value for bond lengths");\ if (btype < 1 || btype > atom->nbondtypes) error->all(FLERR, "Illegal value for bond type"); + + cutsq_bond = cut_bond * cut_bond; iarg += 2; } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg]); @@ -175,6 +179,10 @@ void FixRHEOThermal::init() auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); fix_rheo = dynamic_cast(fixes[0]); + cut_kernel = fix_rheo->h; + + if (cut_bond > cut_kernel) + error->all(FLERR, "Bonding length exceeds kernel cutoff"); if (!fix_rheo->thermal_flag) error->all(FLERR, "Need to define thermal setting in fix rheo"); @@ -204,7 +212,7 @@ void FixRHEOThermal::init() // need a half neighbor list, built only when particles freeze auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); - req->set_cutoff(cut_bond); + req->set_cutoff(cut_kernel); // find instances of bond history to delete data histories = modify->get_fix_by_style("BOND_HISTORY"); @@ -276,7 +284,8 @@ void FixRHEOThermal::post_integrate() double cvi, Tci, Ti; - int phase_changes = 0; + int n_melt = 0; + int n_freeze = 0; //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { @@ -299,7 +308,7 @@ void FixRHEOThermal::post_integrate() if (status[i] & STATUS_SOLID) { status[i] &= PHASEMASK; status[i] |= STATUS_MELTING; - phase_changes += 1; + n_melt += 1; } } else { // If fluid, freeze @@ -307,21 +316,21 @@ void FixRHEOThermal::post_integrate() status[i] &= PHASEMASK; status[i] |= STATUS_SOLID; status[i] |= STATUS_FREEZING; - phase_changes += 1; + n_freeze += 1; } } } } } - if (cut_bond > 0 && phase_changes != 0) { + if (cut_bond > 0 && (n_melt || n_freeze)) { // Forward status then delete/create bonds comm->forward_comm(this); - for (int i = 0; i < atom->nlocal; i++) { - if (status[i] & STATUS_MELTING) break_bonds(i); - if (status[i] & STATUS_FREEZING) create_bonds(i); - } + if (n_freeze) create_bonds(); + if (n_melt) break_bonds(); + + next_reneighbor = update->ntimestep; } } @@ -387,9 +396,9 @@ void FixRHEOThermal::reset_dt() /* ---------------------------------------------------------------------- */ -void FixRHEOThermal::break_bonds(int i) +void FixRHEOThermal::break_bonds() { - int m, n, nmax, j; + int m, n, nmax, i, j; tagint *tag = atom->tag; int *status = atom->status; @@ -397,84 +406,113 @@ void FixRHEOThermal::break_bonds(int i) tagint **bond_atom = atom->bond_atom; int *num_bond = atom->num_bond; - for (m = 0; m < num_bond[i]; m++) { - j = bond_atom[i][m]; - if (n_histories > 0) - for (auto &ihistory: histories) - dynamic_cast(ihistory)->delete_history(i,num_bond[i]-1); + int nlocal = atom->nlocal; - if (fix_update_special_bonds) fix_update_special_bonds->add_broken_bond(i,j); + for (int i = 0; i < nlocal; i++) { + if (!(status[i] & STATUS_MELTING)) continue; - if (j >= atom->nlocal) continue; + for (m = 0; m < num_bond[i]; m++) { + j = atom->map(bond_atom[i][m]); + if (n_histories > 0) + for (auto &ihistory: histories) + dynamic_cast(ihistory)->delete_history(i, num_bond[i] - 1); - for (n = 0; n < num_bond[j]; n++) { - if (bond_atom[j][n] == tag[i]) { - bond_type[j][n] = 0; - nmax = num_bond[j] - 1; - bond_type[j][n] = bond_type[j][nmax]; - bond_atom[j][n] = bond_atom[j][nmax]; - if (n_histories > 0) { - for (auto &ihistory: histories) { - dynamic_cast(ihistory)->shift_history(j, n, nmax); - dynamic_cast(ihistory)->delete_history(j, nmax); + if (fix_update_special_bonds) fix_update_special_bonds->add_broken_bond(i, j); + + // For non-melting neighbors, selectively delete bond if necessary + if (j >= nlocal || (status[j] & STATUS_MELTING)) continue; + for (n = 0; n < num_bond[j]; n++) { + if (bond_atom[j][n] == tag[i]) { + bond_type[j][n] = 0; + nmax = num_bond[j] - 1; + bond_type[j][n] = bond_type[j][nmax]; + bond_atom[j][n] = bond_atom[j][nmax]; + if (n_histories > 0) { + for (auto &ihistory: histories) { + dynamic_cast(ihistory)->shift_history(j, n, nmax); + dynamic_cast(ihistory)->delete_history(j, nmax); + } } + num_bond[j]--; + break; } - num_bond[j]--; - break; } } + num_bond[i] = 0; } - - num_bond[i] = 0; } /* ---------------------------------------------------------------------- */ -void FixRHEOThermal::create_bonds(int i) +void FixRHEOThermal::create_bonds() { - int i1, i2, j, jj, jnum; - int *jlist, *numneigh, **firstneigh; - double rsq; + int i, j, ii, jj, inum, jnum; + int *ilist, *jlist, *numneigh, **firstneigh; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq; int nlocal = atom->nlocal; + int newton_bond = force->newton_bond; tagint *tag = atom->tag; + tagint **bond_atom = atom->bond_atom; + int *status = atom->status; + int **bond_type = atom->bond_type; + int *num_bond = atom->num_bond; double **x = atom->x; + + neighbor->build_one(list, 1); + + + inum = list->inum; + ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; - int *status = atom->status; - int **bond_type = atom->bond_type; - tagint **bond_atom = atom->bond_atom; - int *num_bond = atom->num_bond; - int newton_bond = force->newton_bond; + // loop over neighbors of my atoms + // might be faster to do a full list and just act on the atom that freezes + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + if (!(status[i] & STATUS_SOLID)) continue; - double xtmp = x[i][0]; - double ytmp = x[i][1]; - double ztmp = x[i][2]; - double delx, dely, delz; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= SPECIALMASK; + + if (!(status[j] & STATUS_SOLID)) continue; + if (!(status[i] & STATUS_FREEZING) && !(status[j] & STATUS_FREEZING)) continue; - // Loop through atoms of owned atoms - jlist = firstneigh[i]; - jnum = numneigh[i]; - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= SPECIALMASK; - if (status[j] & STATUS_SOLID) { delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; rsq = delx * delx + dely * dely + delz * delz; - if (rsq > cut_bond) continue; + if (rsq > cutsq_bond) continue; - if (!newton_bond || tag[i] < tag[j]) { + // Add bonds to owned atoms + // If newton bond, add to both, otherwise add to whichever has a smaller tag + if (i < nlocal && (!newton_bond || tag[i] < tag[j])) { if (num_bond[i] == atom->bond_per_atom) error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/thermal"); - if (fix_update_special_bonds) fix_update_special_bonds->add_created_bond(i,j); + if (fix_update_special_bonds) fix_update_special_bonds->add_created_bond(i, j); bond_type[i][num_bond[i]] = btype; bond_atom[i][num_bond[i]] = tag[j]; num_bond[i]++; } + + if (j < nlocal && (!newton_bond || tag[j] < tag[i])) { + if (num_bond[j] == atom->bond_per_atom) + error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/thermal"); + if (fix_update_special_bonds) fix_update_special_bonds->add_created_bond(i, j); + bond_type[j][num_bond[j]] = btype; + bond_atom[j][num_bond[j]] = tag[i]; + num_bond[j]++; + } } } } diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index 75d32b7bc1..da48a59e22 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -49,7 +49,7 @@ class FixRHEOThermal : public Fix { double *Tc_type, Tc; double *kappa_type, kappa; double dtf, dtv; - double cut_bond; + double cut_kernel, cut_bond, cutsq_bond; int Tc_style, cv_style; int btype; int conductivity_style; @@ -64,8 +64,8 @@ class FixRHEOThermal : public Fix { class FixUpdateSpecialBonds *fix_update_special_bonds; void grow_array(int); - void break_bonds(int); - void create_bonds(int); + void break_bonds(); + void create_bonds(); }; } // namespace LAMMPS_NS diff --git a/src/set.cpp b/src/set.cpp index 92033b772e..3e1058b048 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -1105,7 +1105,7 @@ void Set::set(int keyword) // set temperature of particle - else if (keyword == ANGMOM) { + else if (keyword == TEMPERATURE) { if (dvalue < 0.0) error->one(FLERR,"Invalid temperature in set command"); atom->temperature[i] = dvalue; } From 44ae758bf5257e1594c59b9bd512371d5929b1bc Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 6 Nov 2023 20:27:18 -0700 Subject: [PATCH 056/104] Parallel support for bond creation/deletion --- src/RHEO/fix_rheo_thermal.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index ba61619594..7c29e17f93 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -323,12 +323,16 @@ void FixRHEOThermal::post_integrate() } } - if (cut_bond > 0 && (n_melt || n_freeze)) { + int n_melt_all, n_freeze_all; + MPI_Allreduce(&n_melt, &n_melt_all, 1, MPI_INT, MPI_SUM, world); + MPI_Allreduce(&n_freeze, &n_freeze_all, 1, MPI_INT, MPI_SUM, world); + + if (cut_bond > 0 && (n_melt_all || n_freeze_all)) { // Forward status then delete/create bonds comm->forward_comm(this); - if (n_freeze) create_bonds(); - if (n_melt) break_bonds(); + if (n_freeze_all) create_bonds(); + if (n_melt_all) break_bonds(); next_reneighbor = update->ntimestep; } @@ -409,10 +413,10 @@ void FixRHEOThermal::break_bonds() int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (!(status[i] & STATUS_MELTING)) continue; - for (m = 0; m < num_bond[i]; m++) { j = atom->map(bond_atom[i][m]); + if (!(status[i] & STATUS_MELTING) && !(status[j] & STATUS_MELTING)) continue; + if (n_histories > 0) for (auto &ihistory: histories) dynamic_cast(ihistory)->delete_history(i, num_bond[i] - 1); @@ -462,7 +466,6 @@ void FixRHEOThermal::create_bonds() neighbor->build_one(list, 1); - inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; From b8b2141993ecdf6383150f512a2223f431f1d21f Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 7 Nov 2023 14:47:46 -0700 Subject: [PATCH 057/104] Fixing errors in oxide model --- src/RHEO/compute_rheo_property_atom.cpp | 2 +- src/RHEO/compute_rheo_surface.cpp | 81 ++++++++++++------------- src/RHEO/fix_rheo.cpp | 7 ++- src/RHEO/pair_rheo_react.cpp | 21 ++++--- 4 files changed, 56 insertions(+), 55 deletions(-) diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 3afeb03e43..615d5ea740 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -103,7 +103,7 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (avec_index[i] < 0) error->all(FLERR, "Invalid keyword {} for atom style {} in compute rheo/property/atom command ", - atom->get_style(), arg[iarg]); + arg[iarg], atom->get_style()); pack_choice[i] = &ComputeRHEOPropertyAtom::pack_atom_style; if (strcmp(arg[iarg],"temperature") == 0) thermal_flag = 1; diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 88b33c09af..882977f3e9 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -152,16 +152,12 @@ void ComputeRHEOSurface::compute_peratom() grow_arrays(atom->nmax); size_t nbytes = nmax_store * sizeof(double); - memset(&divr, 0, nbytes); - memset(&rsurface, 0, nbytes); - memset(&nsurface, 0, 3 * nbytes); - memset(&gradC, 0, 3 * 3 * nbytes); - memset(&B, 0, 3 * 3 * nbytes); + memset(&divr[0], 0, nbytes); + memset(&rsurface[0], 0, nbytes); + memset(&nsurface[0][0], 0, dim * nbytes); + memset(&gradC[0][0], 0, dim * dim * nbytes); + memset(&B[0][0], 0, dim * dim * nbytes); - // Remove surface settings - int nall = nlocal + atom->nghost; - for (i = 0; i < nall; i++) - status[i] &= SURFACEMASK; // loop over neighbors to calculate the average orientation of neighbors for (ii = 0; ii < inum; ii++) { @@ -208,7 +204,7 @@ void ComputeRHEOSurface::compute_peratom() wp = compute_kernel->calc_dw_quintic(i, j, dx[0], dx[1], dx[2], sqrt(rsq), dWij, dWji); - for (a = 0; a < dim; a++){ + for (a = 0; a < dim; a++) { divr[i] -= dWij[a] * dx[a] * Volj; gradC[i][a] += dWij[a] * Volj; } @@ -245,35 +241,32 @@ void ComputeRHEOSurface::compute_peratom() } } - // Find the free-surface - if (threshold_style == DIVR) { - for (i = 0; i < nall; i++) { - if (mask[i] & groupbit) { + // Remove surface settings and assign new values + int nall = nlocal + atom->nghost; + int test; + + for (i = 0; i < nall; i++) { + status[i] &= SURFACEMASK; + if (mask[i] & groupbit) { + if (threshold_style == DIVR) + test = divr[i] < threshold_divr; + else + test = coordination[i] < threshold_z; + + if (test) { + if (coordination[i] < threshold_splash) + status[i] |= STATUS_SPLASH; + else + status[i] |= STATUS_SURFACE; + rsurface[i] = 0.0; + } else { status[i] |= STATUS_BULK; rsurface[i] = cut; - if (divr[i] < threshold_divr) { - status[i] |= STATUS_SURFACE; - rsurface[i] = 0.0; - if (coordination[i] < threshold_splash) - status[i] |= STATUS_SPLASH; - } - } - } - } else { - for (i = 0; i < nall; i++) { - if (mask[i] & groupbit) { - status[i] |= STATUS_BULK; - rsurface[i] = cut; - if (coordination[i] < threshold_z) { - status[i] |= STATUS_SURFACE; - rsurface[i] = 0.0; - if (coordination[i] < threshold_splash) - status[i] |= STATUS_SPLASH; - } } } } + for (ii = 0; ii < inum; ii++) { i = ilist[ii]; xtmp = x[i][0]; @@ -297,7 +290,8 @@ void ComputeRHEOSurface::compute_peratom() status[i] |= STATUS_LAYER; } - if (status[j] & STATUS_SURFACE) rsurface[i] = MIN(rsurface[i], sqrt(rsq)); + if (status[j] & STATUS_SURFACE) + rsurface[i] = MIN(rsurface[i], sqrt(rsq)); if (j < nlocal || newton) { @@ -306,7 +300,8 @@ void ComputeRHEOSurface::compute_peratom() status[j] |= STATUS_LAYER; } - if (status[i] & STATUS_SURFACE) rsurface[j] = MIN(rsurface[j], sqrt(rsq)); + if (status[i] & STATUS_SURFACE) + rsurface[j] = MIN(rsurface[j], sqrt(rsq)); } } } @@ -351,7 +346,8 @@ void ComputeRHEOSurface::unpack_reverse_comm(int n, int *list, double *buf) int i,a,b,k,j,m; int dim = domain->dimension; int *status = atom->status; - int temp; + int tmp1; + double tmp2; m = 0; for (i = 0; i < n; i++) { @@ -362,12 +358,13 @@ void ComputeRHEOSurface::unpack_reverse_comm(int n, int *list, double *buf) for (b = 0; b < dim; b ++) gradC[j][a * dim + b] += buf[m++]; } else if (comm_stage == 1) { - - temp = (int) buf[m++]; - if ((status[j] & STATUS_BULK) && (temp & STATUS_LAYER)) - status[j] = temp; - - rsurface[j] = MIN(rsurface[j], buf[m++]); + tmp1 = (int) buf[m++]; + if ((status[j] & STATUS_BULK) && (tmp1 & STATUS_LAYER)) { + status[j] &= SURFACEMASK; + status[j] |= STATUS_LAYER; + } + tmp2 = buf[m++]; + rsurface[j] = MIN(rsurface[j], tmp2); } } } diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 97b867179e..b1bc0fe0c0 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -133,7 +133,7 @@ FixRHEO::~FixRHEO() if (compute_kernel) modify->delete_compute("rheo_kernel"); if (compute_grad) modify->delete_compute("rheo_grad"); if (compute_interface) modify->delete_compute("rheo_interface"); - if (compute_surface) modify->delete_compute("compute_surface"); + if (compute_surface) modify->delete_compute("rheo_surface"); if (compute_rhosum) modify->delete_compute("rheo_rhosum"); if (compute_vshift) modify->delete_compute("rheo_vshift"); } @@ -211,7 +211,10 @@ void FixRHEO::setup_pre_force(int /*vflag*/) error->all(FLERR, "Fix RHEO must be defined before all other RHEO fixes"); // Calculate surfaces - if (surface_flag) compute_surface->compute_peratom(); + if (surface_flag) { + compute_kernel->compute_coordination(); + compute_surface->compute_peratom(); + } pre_force(0); } diff --git a/src/RHEO/pair_rheo_react.cpp b/src/RHEO/pair_rheo_react.cpp index 4846e077f6..d7412d5d0e 100644 --- a/src/RHEO/pair_rheo_react.cpp +++ b/src/RHEO/pair_rheo_react.cpp @@ -61,13 +61,13 @@ PairRHEOReact::PairRHEOReact(LAMMPS *lmp) : Pair(lmp), // between timesteps (fix property atom will handle callbacks) int tmp1, tmp2; - int index = atom->find_custom("react_nbond", tmp1, tmp2); - if (index == -1) { + index_nb = atom->find_custom("react_nbond", tmp1, tmp2); + if (index_nb == -1) { id_fix = utils::strdup("pair_rheo_react_fix_property_atom"); modify->add_fix(fmt::format("{} all property/atom i_react_nbond", id_fix)); - index = atom->find_custom("nbond", tmp1, tmp2); + index_nb = atom->find_custom("react_nbond", tmp1, tmp2); } - nbond = atom->ivector[index]; + nbond = atom->ivector[index_nb]; //Store non-persistent per atom quantities, intermediate @@ -79,9 +79,10 @@ PairRHEOReact::PairRHEOReact(LAMMPS *lmp) : Pair(lmp), PairRHEOReact::~PairRHEOReact() { - if (modify->nfix && fix_history) modify->delete_fix("NEIGH_HISTORY_RHEO_REACT"); - if (modify->nfix && fix_dummy) modify->delete_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY"); - if (modify->nfix) modify->delete_fix("PROPERTY_ATOM_RHEO_REACT"); + if (modify->nfix && fix_history) modify->delete_fix("NEIGH_HISTORY_RHEO_REACT" + std::to_string(instance_me)); + if (modify->nfix && fix_dummy) modify->delete_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY" + std::to_string(instance_me)); + if (modify->nfix) modify->delete_fix(id_fix); + delete[] id_fix; if (allocated) { memory->destroy(setflag); @@ -146,7 +147,7 @@ void PairRHEOReact::compute(int eflag, int vflag) } size_t nbytes = nmax_store * sizeof(int); - memset(&dbond, 0, nbytes); + memset(&dbond[0], 0, nbytes); // loop over neighbors of my atoms for (ii = 0; ii < inum; ii++) { @@ -368,11 +369,11 @@ void PairRHEOReact::coeff(int narg, char **arg) void PairRHEOReact::init_style() { - int irequest = neighbor->request(this,instance_me); + int irequest = neighbor->request(this, instance_me); //neighbor->requests[irequest]->history = 1; if (fix_history == nullptr) { - auto cmd = fmt::format("NEIGH_HISTORY_RHEO_REACT {} all NEIGH_HISTORY {}", instance_me, size_history); + auto cmd = fmt::format("NEIGH_HISTORY_RHEO_REACT{} all NEIGH_HISTORY {}", instance_me, size_history); fix_history = dynamic_cast( modify->replace_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY" + std::to_string(instance_me), cmd, 1)); fix_history->pair = this; From c922fcef5a7849cc930f4057973e7460ecb5a7c6 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 8 Nov 2023 14:30:37 -0700 Subject: [PATCH 058/104] prototyping limit on tension --- src/RHEO/compute_rheo_vshift.cpp | 2 +- src/RHEO/fix_rheo_pressure.cpp | 12 ++-- src/RHEO/fix_rheo_tension.cpp | 112 +++++++++++++++++++++++++------ src/RHEO/fix_rheo_tension.h | 4 +- src/RHEO/fix_rheo_thermal.cpp | 64 +++++++++--------- src/RHEO/fix_rheo_viscosity.cpp | 2 +- 6 files changed, 134 insertions(+), 62 deletions(-) diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 9741026324..aa59f80ff2 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -232,7 +232,7 @@ void ComputeRHEOVShift::correct_surfaces() int nlocal = atom->nlocal; int dim = domain->dimension; - double nx,ny,nz,vx,vy,vz; + double nx, ny, nz, vx, vy, vz; for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if ((status[i] & STATUS_SURFACE) || (status[i] & STATUS_LAYER)) { diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 84d21ee872..5049ab0a4e 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -51,14 +51,14 @@ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : int ntypes = atom->ntypes; int iarg = 3; - if (strcmp(arg[iarg],"linear") == 0) { + if (strcmp(arg[iarg], "linear") == 0) { pressure_style = LINEAR; - } else if (strcmp(arg[iarg],"taitwater") == 0) { + } else if (strcmp(arg[iarg], "taitwater") == 0) { pressure_style = TAITWATER; - } else if (strcmp(arg[iarg],"cubic") == 0) { + } else if (strcmp(arg[iarg], "cubic") == 0) { pressure_style = CUBIC; - if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for pressure option"); - c_cubic = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for pressure option"); + c_cubic = utils::numeric(FLERR, arg[iarg + 1], false, lmp); } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg]); } @@ -96,7 +96,7 @@ void FixRHEOPressure::init() // Cannot define multiple as pair rheo cannot currently distinguish if (modify->get_fix_by_style("rheo/pressure").size() > 1) - error->all(FLERR,"Can only specify one instance of fix rheo/pressure"); + error->all(FLERR, "Can only specify one instance of fix rheo/pressure"); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_tension.cpp b/src/RHEO/fix_rheo_tension.cpp index 047f1d217e..8b79fcebd6 100644 --- a/src/RHEO/fix_rheo_tension.cpp +++ b/src/RHEO/fix_rheo_tension.cpp @@ -46,8 +46,10 @@ using namespace FixConst; FixRHEOTension::FixRHEOTension(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), compute_kernel(nullptr), compute_interface(nullptr), fix_rheo(nullptr) { - if (narg != 4) error->all(FLERR,"Illegal fix command"); - alpha = utils::numeric(FLERR,arg[3],false,lmp); + if (narg != 6) error->all(FLERR,"Illegal fix command"); + alpha = utils::numeric(FLERR, arg[3], false, lmp); + alpha = utils::numeric(FLERR, arg[4], false, lmp); + wmin = utils::numeric(FLERR, arg[5], false, lmp); comm_forward = 3; comm_reverse = 3; @@ -75,6 +77,7 @@ FixRHEOTension::FixRHEOTension(LAMMPS *lmp, int narg, char **arg) : ft = atom->darray[index_ft]; norm = nullptr; + wsame = nullptr; nmax_store = 0; } @@ -98,6 +101,7 @@ FixRHEOTension::~FixRHEOTension() if (index != -1) atom->remove_custom(index, 1, 3); memory->destroy(norm); + memory->destroy(wsame); } /* ---------------------------------------------------------------------- */ @@ -182,13 +186,11 @@ void FixRHEOTension::post_force(int vflag) if (nmax_store <= atom->nmax) grow_arrays(atom->nmax); - for (i = 0; i < nlocal+atom->nghost; i++) { - cgradt[i][0] = 0.0; - cgradt[i][1] = 0.0; - cgradt[i][2] = 0.0; - norm[i] = 0.0; - divnt[i] = 0.0; - } + size_t nbytes = nmax_store * sizeof(double); + memset(&norm[0], 0, nbytes); + memset(&wsame[0], 0, nbytes); + memset(&divnt[0], 0, nbytes); + memset(&cgradt[0][0], 0, 3 * nbytes); // Calculate color gradient for (ii = 0; ii < inum; ii++) { @@ -315,17 +317,26 @@ void FixRHEOTension::post_force(int vflag) Voli = mass[itype] / rhoi; Volj = mass[jtype] / rhoj; + w = compute_kernel->calc_w(i, j, dx[0], dx[1], dx[2],r); wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2],r); dWij = compute_kernel->dWij; dWji = compute_kernel->dWji; - if (itype != jtype) continue; // have to think about this... - for (a = 0; a < 3; a++) { - divnt[i] -= (nt[i][a]-nt[j][a]) * Volj * dWij[a]; + if (itype != jtype) + divnt[i] -= (nt[i][a]+nt[j][a]) * Volj * dWij[a]; + else { + divnt[i] -= (nt[i][a]-nt[j][a]) * Volj * dWij[a]; + wsame[i] += w; + } norm[i] -= dx[a] * Volj * dWij[a]; if (newton || j < nlocal) { - divnt[j] += (nt[i][a]-nt[j][a]) * Voli * dWji[a]; + if (itype != jtype) + divnt[j] -= (nt[j][a]+nt[i][a]) * Voli * dWji[a]; + else { + divnt[j] -= (nt[j][a]-nt[i][a]) * Voli * dWji[a]; + wsame[j] += w; + } norm[j] += dx[a] * Voli * dWji[a]; } } @@ -333,26 +344,28 @@ void FixRHEOTension::post_force(int vflag) } comm_stage = 1; - comm_reverse = 2; + comm_reverse = 3; if (newton) comm->reverse_comm(this); // Skip forces if it's setup if (update->setupflag) return; // apply force - double prefactor; - double unwrap[3]; - double v[6]; + double weight, prefactor, unwrap[3], v[6]; + double wmin_inv = 1.0 / wmin; for (i = 0; i < nlocal; i++) { + + weight = MAX(1.0, (wsame[i] - wmin) * wmin_inv); + //if (wsame[i] < wmin) continue; + itype = type[i]; if (norm[i] != 0) - divnt[i] /= norm[i]; + divnt[i] *= dim * norm[i]; else divnt[i] = 0.0; - prefactor = -alpha * divnt[i]; - + prefactor = -alpha * divnt[i] * weight; for (a = 0; a < 3; a++) { f[i][a] += prefactor * cgradt[i][a]; ft[i][a] = prefactor * cgradt[i][a]; @@ -369,6 +382,62 @@ void FixRHEOTension::post_force(int vflag) v_tally(i, v); } } + + // If there is no lower limit, apply optional pairwise forces + if (wmin == 0 || beta == 0.0) return; + + double fpair, wi, wj; + double cut_two_thirds = 2.0 * h / 3.0; + double h_third_squared = (h / 3.0) * (h / 3.0); + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + imass = mass[itype]; + + wi = MIN(1.0, (wsame[i] - wmin) * wmin_inv); + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + if (wsame[i] >= wmin && wsame[j] >= wmin) continue; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = lensq3(dx); + + if (rsq > hsq) continue; + + wj = MIN(1.0, (wsame[j] - wmin) * wmin_inv); + r = sqrt(rsq); + rinv = 1.0 / r; + + fpair = (r - cut_two_thirds); + fpair *= fpair; + fpair -= h_third_squared; + fpair *= wi * wj * beta * rinv; + + f[i][0] += dx[0] * fpair; + f[i][1] += dx[1] * fpair; + f[i][2] += dx[2] * fpair; + + if (newton || j < nlocal) { + f[j][0] -= dx[0] * fpair; + f[j][1] -= dx[1] * fpair; + f[j][2] -= dx[2] * fpair; + } + + if (evflag) { + // In progress + } + } + } } @@ -417,6 +486,7 @@ int FixRHEOTension::pack_reverse_comm(int n, int first, double *buf) for (i = first; i < last; i++) { buf[m++] = norm[i]; buf[m++] = divnt[i]; + buf[m++] = wsame[i]; } return m; } @@ -439,6 +509,7 @@ void FixRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) j = list[i]; norm[j] += buf[m++]; divnt[j] += buf[m++]; + wsame[j] += buf[m++]; } } @@ -459,6 +530,7 @@ void FixRHEOTension::grow_arrays(int nmax) // Grow local variables memory->grow(norm, nmax, "rheo/tension:norm"); + memory->grow(wsame, nmax, "rheo/tension:wsame"); nmax_store = atom->nmax; } \ No newline at end of file diff --git a/src/RHEO/fix_rheo_tension.h b/src/RHEO/fix_rheo_tension.h index 11bc209d88..f56a61e688 100644 --- a/src/RHEO/fix_rheo_tension.h +++ b/src/RHEO/fix_rheo_tension.h @@ -43,8 +43,8 @@ class FixRHEOTension : public Fix { int nmax_store, comm_stage, interface_flag; int index_nt, index_cgradt, index_divnt, index_ft; - double **nt, **cgradt, *divnt, *norm, **ft; - double alpha, h, hsq, hinv, hinv3, rho0; + double **nt, **cgradt, *divnt, *norm, **ft, *wsame; + double alpha, beta, wmin, h, hsq, hinv, hinv3, rho0; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 7c29e17f93..3b38089fad 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -65,67 +65,67 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"conductivity") == 0) { // Conductivity arguments - if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for conductivity option"); - if (strcmp(arg[iarg + 1],"constant") == 0) { - if (iarg + 2 >= narg) error->all(FLERR,"Insufficient arguments for conductivity option"); + if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for conductivity option"); + if (strcmp(arg[iarg + 1], "constant") == 0) { + if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for conductivity option"); conductivity_style = CONSTANT; - kappa = utils::numeric(FLERR,arg[iarg + 2],false,lmp); - if (kappa < 0.0) error->all(FLERR,"The conductivity must be positive"); + kappa = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + if (kappa < 0.0) error->all(FLERR, "The conductivity must be positive"); iarg += 2; - } else if (strcmp(arg[iarg + 1],"type") == 0) { - if (iarg + 1 + ntypes >= narg) error->all(FLERR,"Insufficient arguments for conductivity option"); + } else if (strcmp(arg[iarg + 1], "type") == 0) { + if (iarg + 1 + ntypes >= narg) error->all(FLERR, "Insufficient arguments for conductivity option"); conductivity_style = TYPE; - memory->create(kappa_type,ntypes+1,"rheo_thermal:kappa_type"); + memory->create(kappa_type, ntypes+1, "rheo_thermal:kappa_type"); for (int i = 1; i <= ntypes; i++) { - kappa_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i],false,lmp); - if (kappa_type[i] < 0.0) error->all(FLERR,"The conductivity must be positive"); + kappa_type[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); + if (kappa_type[i] < 0.0) error->all(FLERR, "The conductivity must be positive"); } iarg += 1 + ntypes; } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); } - } else if (strcmp(arg[iarg],"specific/heat") == 0) { + } else if (strcmp(arg[iarg], "specific/heat") == 0) { // Cv arguments - if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for cv option"); - if (strcmp(arg[iarg + 1],"constant") == 0) { - if (iarg + 2 >= narg) error->all(FLERR,"Insufficient arguments for cv option"); + if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for cv option"); + if (strcmp(arg[iarg + 1], "constant") == 0) { + if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for cv option"); cv_style = CONSTANT; - cv = utils::numeric(FLERR,arg[iarg + 2],false,lmp); - if (cv < 0.0) error->all(FLERR,"The specific heat must be positive"); + cv = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + if (cv < 0.0) error->all(FLERR, "The specific heat must be positive"); iarg += 2; - } else if (strcmp(arg[iarg + 1],"type") == 0) { - if (iarg + 1 + ntypes >= narg) error->all(FLERR,"Insufficient arguments for cv option"); + } else if (strcmp(arg[iarg + 1], "type") == 0) { + if (iarg + 1 + ntypes >= narg) error->all(FLERR, "Insufficient arguments for cv option"); cv_style = TYPE; - memory->create(cv_type,ntypes + 1,"rheo_thermal:cv_type"); + memory->create(cv_type,ntypes + 1, "rheo_thermal:cv_type"); for (int i = 1; i <= ntypes; i++) { - cv_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i],false,lmp); - if (cv_type[i] < 0.0) error->all(FLERR,"The specific heat must be positive"); + cv_type[i] = utils::numeric(FLERR, arg[iarg + 1 + i], false, lmp); + if (cv_type[i] < 0.0) error->all(FLERR, "The specific heat must be positive"); } iarg += 1 + ntypes; } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); } - } else if (strcmp(arg[iarg],"Tfreeze") == 0) { + } else if (strcmp(arg[iarg], "Tfreeze") == 0) { // T freeze arguments - if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); - if (strcmp(arg[iarg + 1],"constant") == 0) { - if (iarg + 2 >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); + if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for Tfreeze option"); + if (strcmp(arg[iarg + 1], "constant") == 0) { + if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for Tfreeze option"); Tc_style = CONSTANT; - Tc = utils::numeric(FLERR,arg[iarg + 2],false,lmp); + Tc = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 2; - } else if (strcmp(arg[iarg + 1],"type") == 0) { - if (iarg + 1 + ntypes >= narg) error->all(FLERR,"Insufficient arguments for Tfreeze option"); + } else if (strcmp(arg[iarg + 1], "type") == 0) { + if (iarg + 1 + ntypes >= narg) error->all(FLERR, "Insufficient arguments for Tfreeze option"); Tc_style = TYPE; memory->create(Tc_type, ntypes + 1, "rheo_thermal:Tc_type"); for (int i = 1; i <= ntypes; i++) { - Tc_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i],false,lmp); - if (Tc_type[i] < 0.0) error->all(FLERR,"The melting temperature must be positive"); + Tc_type[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); + if (Tc_type[i] < 0.0) error->all(FLERR, "The melting temperature must be positive"); } iarg += 1 + ntypes; } else { - error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); + error->all(FLERR, "Illegal fix command, {}", arg[iarg + 1]); } - } else if (strcmp(arg[iarg],"react") == 0) { + } else if (strcmp(arg[iarg], "react") == 0) { if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for react option"); cut_bond = utils::numeric(FLERR, arg[iarg + 1], false, lmp); btype = utils::numeric(FLERR, arg[iarg + 2], false, lmp); diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 7d915c9b93..e33bd43244 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -58,7 +58,7 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : viscosity_style = TYPE; memory->create(eta_type, ntypes + 1, "rheo_thermal:eta_type"); for (int i = 1; i <= ntypes; i++) { - eta_type[i] = utils::numeric(FLERR,arg[iarg + 1 + i], false, lmp); + eta_type[i] = utils::numeric(FLERR,arg[iarg + i], false, lmp); if (eta_type[i] < 0.0) error->all(FLERR,"The viscosity must be positive"); } iarg += ntypes; From 73a3ae7602bb16b0308223f46d0ecf99633e9963 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 8 Nov 2023 15:57:42 -0700 Subject: [PATCH 059/104] Debugging some compute property items, allow surface shifting inward --- src/RHEO/compute_rheo_property_atom.cpp | 45 +++++++++++++++++-------- src/RHEO/compute_rheo_property_atom.h | 1 + src/RHEO/compute_rheo_vshift.cpp | 17 +++++++--- src/RHEO/fix_rheo.cpp | 4 ++- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 615d5ea740..ed35484bd5 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -70,6 +70,8 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (strcmp(arg[iarg],"phase") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_phase; + } else if (strcmp(arg[iarg],"rho") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_rho; } else if (strcmp(arg[iarg],"chi") == 0) { interface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_chi; @@ -82,7 +84,7 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a } else if (strcmp(arg[iarg],"surface/divr") == 0) { surface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_divr; - } else if (strcmp(arg[iarg],"^surface/n") == 0) { + } else if (utils::strmatch(arg[iarg], "^surface/n")) { surface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_n; col_index[i] = get_vector_index(arg[iarg]); @@ -91,11 +93,11 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a } else if (strcmp(arg[iarg],"cv") == 0) { thermal_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; - } else if (strcmp(arg[iarg],"^shift/v") == 0) { + } else if (utils::strmatch(arg[iarg], "^shift/v")) { shift_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_v; col_index[i] = get_vector_index(arg[iarg]); - } else if (utils::strmatch(arg[iarg],"^gradv")) { + } else if (utils::strmatch(arg[iarg], "^grad/v")) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_gradv; col_index[i] = get_tensor_index(arg[iarg]); } else { @@ -167,10 +169,10 @@ void ComputeRHEOPropertyAtom::compute_peratom() nmax = atom->nmax; if (nvalues == 1) { memory->destroy(vector_atom); - memory->create(vector_atom,nmax,"rheo/property/atom:vector"); + memory->create(vector_atom, nmax, "rheo/property/atom:vector"); } else { memory->destroy(array_atom); - memory->create(array_atom,nmax,nvalues,"rheo/property/atom:array"); + memory->create(array_atom, nmax, nvalues, "rheo/property/atom:array"); } } @@ -220,6 +222,21 @@ void ComputeRHEOPropertyAtom::pack_phase(int n) /* ---------------------------------------------------------------------- */ +void ComputeRHEOPropertyAtom::pack_rho(int n) +{ + double *rho = atom->rho; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = rho[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + void ComputeRHEOPropertyAtom::pack_chi(int n) { double *chi = compute_interface->chi; @@ -370,29 +387,29 @@ int ComputeRHEOPropertyAtom::get_tensor_index(char* option) int dim = domain->dimension; int dim_error = 0; - if (utils::strmatch(option,"xx$")) { + if (utils::strmatch(option, "xx$")) { index = 0; - } else if (utils::strmatch(option,"xy$")) { + } else if (utils::strmatch(option, "xy$")) { index = 1; - } else if (utils::strmatch(option,"xz$")) { + } else if (utils::strmatch(option, "xz$")) { index = 2; if (dim == 2) dim_error = 1; - } else if (utils::strmatch(option,"yx$")) { + } else if (utils::strmatch(option, "yx$")) { if (dim == 2) index = 2; else index = 3; - } else if (utils::strmatch(option,"yy$")) { + } else if (utils::strmatch(option, "yy$")) { if (dim == 2) index = 3; else index = 4; - } else if (utils::strmatch(option,"yz$")) { + } else if (utils::strmatch(option, "yz$")) { index = 5; if (dim == 2) dim_error = 1; - } else if (utils::strmatch(option,"zx$")) { + } else if (utils::strmatch(option, "zx$")) { index = 6; if (dim == 2) dim_error = 1; - } else if (utils::strmatch(option,"zy$")) { + } else if (utils::strmatch(option, "zy$")) { index = 7; if (dim == 2) dim_error = 1; - } else if (utils::strmatch(option,"zz$")) { + } else if (utils::strmatch(option, "zz$")) { index = 8; if (dim == 2) dim_error = 1; } else { diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index 344e249d11..bfae870ee5 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -43,6 +43,7 @@ class ComputeRHEOPropertyAtom : public Compute { FnPtrPack *pack_choice; // ptrs to pack functions void pack_phase(int); + void pack_rho(int); void pack_chi(int); void pack_surface(int); void pack_surface_r(int); diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index aa59f80ff2..1f9314e99b 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -232,7 +232,7 @@ void ComputeRHEOVShift::correct_surfaces() int nlocal = atom->nlocal; int dim = domain->dimension; - double nx, ny, nz, vx, vy, vz; + double nx, ny, nz, vx, vy, vz, dot; for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { if ((status[i] & STATUS_SURFACE) || (status[i] & STATUS_LAYER)) { @@ -240,11 +240,20 @@ void ComputeRHEOVShift::correct_surfaces() ny = nsurface[i][1]; vx = vshift[i][0]; vy = vshift[i][1]; - vz = vshift[i][2]; + + dot = nx * vx + ny * vy; + if (dim == 3) { + nz = nsurface[i][2]; + vz = vshift[i][2]; + dot += nz * vz; + } + + // Allowing shifting into the bulk + if (dot < 0.0) continue; + vshift[i][0] = (1 - nx * nx) * vx - nx * ny * vy; vshift[i][1] = (1 - ny * ny) * vy - nx * ny * vx; - if (dim > 2) { - nz = nsurface[i][2]; + if (dim == 3) { vshift[i][0] -= nx * nz * vz; vshift[i][1] -= ny * nz * vz; vshift[i][2] = (1 - nz * nz) * vz - nz * ny * vy - nx * nz * vx; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index b1bc0fe0c0..f1f1a1bc4b 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -351,7 +351,6 @@ void FixRHEO::initial_integrate(int /*vflag*/) // Shifting atoms if (shift_flag) { - compute_vshift->correct_surfaces(); // Could this be moved to preforce after the surface fix runs? for (i = 0; i < nlocal; i++) { if (status[i] & STATUS_NO_SHIFT) continue; @@ -407,6 +406,9 @@ void FixRHEO::pre_force(int /*vflag*/) // Calculate surfaces, update status if (surface_flag) compute_surface->compute_peratom(); + + if (shift_flag) + compute_vshift->correct_surfaces(); } /* ---------------------------------------------------------------------- */ From f9b385061b0d2017aec568109f984045c7de8088 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 14 Nov 2023 12:33:51 -0700 Subject: [PATCH 060/104] Multiphase support --- src/RHEO/compute_rheo_grad.cpp | 6 +- src/RHEO/compute_rheo_grad.h | 2 +- src/RHEO/compute_rheo_interface.cpp | 16 +- src/RHEO/compute_rheo_interface.h | 3 +- src/RHEO/compute_rheo_property_atom.cpp | 3 +- src/RHEO/compute_rheo_surface.cpp | 6 +- src/RHEO/compute_rheo_surface.h | 2 +- src/RHEO/fix_rheo.cpp | 86 +++++---- src/RHEO/fix_rheo.h | 3 +- src/RHEO/fix_rheo_pressure.cpp | 102 +++++++--- src/RHEO/fix_rheo_pressure.h | 7 +- src/RHEO/fix_rheo_thermal.cpp | 246 ++++++++++++------------ src/RHEO/fix_rheo_thermal.h | 9 +- src/RHEO/fix_rheo_viscosity.cpp | 168 ++++++++-------- src/RHEO/fix_rheo_viscosity.h | 5 +- src/RHEO/pair_rheo.cpp | 71 ++++--- src/RHEO/pair_rheo.h | 4 +- src/RHEO/pair_rheo_react.cpp | 28 +-- 18 files changed, 430 insertions(+), 337 deletions(-) diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 46c1500556..b2ca0c9dc4 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -41,7 +41,7 @@ enum{COMMGRAD, COMMFIELD}; /* ---------------------------------------------------------------------- */ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), compute_interface(nullptr), compute_kernel(nullptr), + Compute(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), rho0(nullptr), compute_interface(nullptr), compute_kernel(nullptr), gradv(nullptr), gradr(nullptr), gradt(nullptr), gradn(nullptr) { if (narg < 4) error->all(FLERR,"Illegal compute rheo/grad command"); @@ -221,8 +221,8 @@ void ComputeRHEOGrad::compute_peratom() //compute_interface->correct_v(vi, vj, i, j); rhoi = compute_interface->correct_rho(i, j); } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0; - rhoj = rho0; + rhoi = rho0[itype]; + rhoj = rho0[jtype]; } } diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index db5e84d32a..489f3c641d 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -46,7 +46,7 @@ class ComputeRHEOGrad : public Compute { private: int comm_stage, ncomm_grad, ncomm_field, nmax_store; - double cut, cutsq, rho0; + double cut, cutsq, *rho0; int velocity_flag, temperature_flag, rho_flag, eta_flag; int interface_flag, remap_v_flag; diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index 8cd69b49e3..001f15a472 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -25,6 +25,7 @@ #include "error.h" #include "force.h" #include "fix_rheo.h" +#include "fix_rheo_pressure.h" #include "memory.h" #include "modify.h" #include "neighbor.h" @@ -42,7 +43,7 @@ static constexpr double EPSILON = 1e-1; ComputeRHEOInterface::ComputeRHEOInterface(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr), fp_store(nullptr), - norm(nullptr), normwf(nullptr), chi(nullptr), id_fix_pa(nullptr) + rho0(nullptr), norm(nullptr), normwf(nullptr), chi(nullptr), id_fix_pa(nullptr) { if (narg != 3) error->all(FLERR,"Illegal compute rheo/interface command"); @@ -86,11 +87,12 @@ void ComputeRHEOInterface::init() compute_kernel = fix_rheo->compute_kernel; rho0 = fix_rheo->rho0; cut = fix_rheo->cut; - csq = fix_rheo->csq; - csq_inv = 1.0 / csq; cutsq = cut * cut; wall_max = sqrt(3.0) / 12.0 * cut; + auto fixes = modify->get_fix_by_style("rheo/pressure"); + fix_pressure = dynamic_cast(fixes[0]); + neighbor->add_request(this, NeighConst::REQ_DEFAULT); } @@ -174,7 +176,7 @@ void ComputeRHEOInterface::compute_peratom() dot += (-fp_store[j][1] + fp_store[i][1]) * dely; dot += (-fp_store[j][2] + fp_store[i][2]) * delz; - rho[i] += w * (csq * (rho[j] - rho0) - rho[j] * dot); + rho[i] += w * (fix_pressure->calc_pressure(rho[j], jtype) - rho[j] * dot); normwf[i] += w; } } @@ -189,7 +191,7 @@ void ComputeRHEOInterface::compute_peratom() dot += (-fp_store[i][1] + fp_store[j][1]) * dely; dot += (-fp_store[i][2] + fp_store[j][2]) * delz; - rho[j] += w * (csq * (rho[i] - rho0) + rho[i] * dot); + rho[j] += w * (fix_pressure->calc_pressure(rho[i], itype) + rho[i] * dot); normwf[j] += w; } } @@ -207,9 +209,9 @@ void ComputeRHEOInterface::compute_peratom() if (status[i] & PHASECHECK) { if (normwf[i] != 0.0) { // Stores rho for solid particles 1+Pw in Adami Adams 2012 - rho[i] = MAX(EPSILON, rho0 + (rho[i] / normwf[i]) * csq_inv); + rho[i] = MAX(EPSILON, fix_pressure->calc_rho(rho[i] / normwf[i], type[i])); } else { - rho[i] = rho0; + rho[i] = rho0[itype]; } } } diff --git a/src/RHEO/compute_rheo_interface.h b/src/RHEO/compute_rheo_interface.h index 50cec97790..a8cd448822 100644 --- a/src/RHEO/compute_rheo_interface.h +++ b/src/RHEO/compute_rheo_interface.h @@ -45,13 +45,14 @@ class ComputeRHEOInterface : public Compute { private: int nmax_store, comm_stage; - double rho0, cut, cutsq, csq, csq_inv, wall_max; + double *rho0, cut, cutsq, wall_max; double *norm, *normwf; char *id_fix_pa; class NeighList *list; class ComputeRHEOKernel *compute_kernel; + class FixRHEOPressure *fix_pressure; }; } // namespace LAMMPS_NS diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index ed35484bd5..50bcb2a2d0 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -330,11 +330,12 @@ void ComputeRHEOPropertyAtom::pack_coordination(int n) void ComputeRHEOPropertyAtom::pack_cv(int n) { + int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = fix_thermal->calc_cv(i); + if (mask[i] & groupbit) buf[n] = fix_thermal->calc_cv(i, type[i]); else buf[n] = 0.0; n += nvalues; } diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 882977f3e9..1ef69bb6f0 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -42,7 +42,7 @@ static constexpr double EPSILON = 1e-10; /* ---------------------------------------------------------------------- */ ComputeRHEOSurface::ComputeRHEOSurface(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), compute_kernel(nullptr), compute_interface(nullptr), + Compute(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), rho0(nullptr), compute_kernel(nullptr), compute_interface(nullptr), B(nullptr), gradC(nullptr), nsurface(nullptr), divr(nullptr), rsurface(nullptr) { if (narg != 3) error->all(FLERR,"Illegal compute RHEO/SURFACE command"); @@ -194,8 +194,8 @@ void ComputeRHEOSurface::compute_peratom() } else if ((!fluidi) && fluidj) { rhoi = compute_interface->correct_rho(i, j); } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0; - rhoj = rho0; + rhoi = rho0[itype]; + rhoj = rho0[jtype]; } } diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index f1b1af7742..6ef2428499 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -44,7 +44,7 @@ class ComputeRHEOSurface : public Compute { int threshold_style, comm_stage; int index_divr, index_rsurf, index_nsurf; - double cut, cutsq, rho0, threshold_divr; + double cut, cutsq, *rho0, threshold_divr; double **B, **gradC; class NeighList *list; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index f1f1a1bc4b..d07f0d1a1f 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -28,6 +28,7 @@ #include "domain.h" #include "error.h" #include "force.h" +#include "memory.h" #include "modify.h" #include "update.h" #include "utils.h" @@ -40,7 +41,7 @@ using namespace FixConst; FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), compute_grad(nullptr), compute_kernel(nullptr), compute_surface(nullptr), - compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr) + compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr), rho0(nullptr), csq(nullptr) { time_integrate = 1; @@ -54,71 +55,81 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : interface_flag = 0; surface_flag = 0; - rho0 = 1.0; - csq = 1.0; + int i; + int n = atom->ntypes; + memory->create(rho0, n + 1, "rheo:rho0"); + memory->create(csq, n + 1, "rheo:csq"); + for (i = 1; i <= n; i++) { + rho0[i] = 1.0; + csq[i] = 1.0; + } if (igroup != 0) - error->all(FLERR,"fix rheo command requires group all"); + error->all(FLERR, "fix rheo command requires group all"); if (atom->pressure_flag != 1) - error->all(FLERR,"fix rheo command requires atom_style with pressure"); + error->all(FLERR, "fix rheo command requires atom_style with pressure"); if (atom->rho_flag != 1) - error->all(FLERR,"fix rheo command requires atom_style with density"); + error->all(FLERR, "fix rheo command requires atom_style with density"); if (atom->viscosity_flag != 1) - error->all(FLERR,"fix rheo command requires atom_style with viscosity"); + error->all(FLERR, "fix rheo command requires atom_style with viscosity"); if (atom->status_flag != 1) - error->all(FLERR,"fix rheo command requires atom_style with status"); + error->all(FLERR, "fix rheo command requires atom_style with status"); if (narg < 5) - error->all(FLERR,"Insufficient arguments for fix rheo command"); + error->all(FLERR, "Insufficient arguments for fix rheo command"); - h = utils::numeric(FLERR,arg[3],false,lmp); + h = utils::numeric(FLERR, arg[3], false, lmp); cut = h; - if (strcmp(arg[4],"quintic") == 0) { + if (strcmp(arg[4], "quintic") == 0) { kernel_style = QUINTIC; - } else if (strcmp(arg[4],"RK0") == 0) { + } else if (strcmp(arg[4], "RK0") == 0) { kernel_style = RK0; - } else if (strcmp(arg[4],"RK1") == 0) { + } else if (strcmp(arg[4], "RK1") == 0) { kernel_style = RK1; - } else if (strcmp(arg[4],"RK2") == 0) { + } else if (strcmp(arg[4], "RK2") == 0) { kernel_style = RK2; - } else error->all(FLERR,"Unknown kernel style {} in fix rheo", arg[4]); - zmin_kernel = utils::numeric(FLERR,arg[5],false,lmp); + } else error->all(FLERR, "Unknown kernel style {} in fix rheo", arg[4]); + zmin_kernel = utils::numeric(FLERR, arg[5], false, lmp); int iarg = 6; while (iarg < narg){ - if (strcmp(arg[iarg],"shift") == 0) { + if (strcmp(arg[iarg], "shift") == 0) { shift_flag = 1; - } else if (strcmp(arg[iarg],"thermal") == 0) { + } else if (strcmp(arg[iarg], "thermal") == 0) { thermal_flag = 1; - } else if (strcmp(arg[iarg],"surface/detection") == 0) { + } else if (strcmp(arg[iarg], "surface/detection") == 0) { surface_flag = 1; - if(iarg + 2 >= narg) error->all(FLERR,"Illegal surface/detection option in fix rheo"); + if(iarg + 2 >= narg) error->all(FLERR, "Illegal surface/detection option in fix rheo"); if (strcmp(arg[iarg + 1], "coordination") == 0) { surface_style = COORDINATION; - zmin_surface = utils::inumeric(FLERR,arg[iarg + 2],false,lmp); - zmin_splash = utils::inumeric(FLERR,arg[iarg + 3],false,lmp); + zmin_surface = utils::inumeric(FLERR, arg[iarg + 2], false, lmp); + zmin_splash = utils::inumeric(FLERR, arg[iarg + 3], false, lmp); } else if (strcmp(arg[iarg + 1], "divergence") == 0) { surface_style = DIVR; - divr_surface = utils::numeric(FLERR,arg[iarg + 2],false,lmp); - zmin_splash = utils::inumeric(FLERR,arg[iarg + 3],false,lmp); + divr_surface = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + zmin_splash = utils::inumeric(FLERR, arg[iarg + 3], false, lmp); } else { - error->all(FLERR,"Illegal surface/detection option in fix rheo, {}", arg[iarg + 1]); + error->all(FLERR, "Illegal surface/detection option in fix rheo, {}", arg[iarg + 1]); } iarg += 3; - } else if (strcmp(arg[iarg],"interface/reconstruct") == 0) { + } else if (strcmp(arg[iarg], "interface/reconstruct") == 0) { interface_flag = 1; - } else if (strcmp(arg[iarg],"rho/sum") == 0) { + } else if (strcmp(arg[iarg], "rho/sum") == 0) { rhosum_flag = 1; - } else if (strcmp(arg[iarg],"density") == 0) { - if(iarg + 1 >= narg) error->all(FLERR,"Illegal rho0 option in fix rheo"); - rho0 = utils::numeric(FLERR,arg[iarg + 1],false,lmp); - iarg += 1; - } else if (strcmp(arg[iarg],"sound/squared") == 0) { - if(iarg+1 >= narg) error->all(FLERR,"Illegal csq option in fix rheo"); - csq = utils::numeric(FLERR,arg[iarg + 1],false,lmp); - iarg += 1; + } else if (strcmp(arg[iarg], "density") == 0) { + if (iarg + n >= narg) error->all(FLERR, "Illegal rho0 option in fix rheo"); + for (i = 1; i <= n; i++) + rho0[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); + iarg += n; + } else if (strcmp(arg[iarg], "speed/sound") == 0) { + if (iarg + n >= narg) error->all(FLERR, "Illegal csq option in fix rheo"); + for (i = 1; i <= n; i++) { + csq[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); + csq[i] *= csq[i]; + } + iarg += n; } else { error->all(FLERR, "Illegal fix rheo command: {}", arg[iarg]); } @@ -136,6 +147,9 @@ FixRHEO::~FixRHEO() if (compute_surface) modify->delete_compute("rheo_surface"); if (compute_rhosum) modify->delete_compute("rheo_rhosum"); if (compute_vshift) modify->delete_compute("rheo_vshift"); + + memory->destroy(csq); + memory->destroy(rho0); } @@ -198,7 +212,7 @@ void FixRHEO::init() dtf = 0.5 * update->dt * force->ftm2v; if (modify->get_fix_by_style("^rheo$").size() > 1) - error->all(FLERR,"Can only specify one instance of fix rheo"); + error->all(FLERR, "Can only specify one instance of fix rheo"); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index da98f3d09a..8ec28c7d0e 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -39,7 +39,8 @@ class FixRHEO : public Fix { void reset_dt() override; // Model parameters - double h, cut, rho0, csq; + double h, cut; + double *rho0, *csq; int zmin_kernel, zmin_surface, zmin_splash; int kernel_style, surface_style; double divr_surface; diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 5049ab0a4e..eac4b34046 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -38,39 +38,62 @@ static constexpr double SEVENTH = 1.0 / 7.0; /* ---------------------------------------------------------------------- */ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), fix_rheo(nullptr) + Fix(lmp, narg, arg), fix_rheo(nullptr), rho0(nullptr), csq(nullptr), rho0inv(nullptr), csqinv(nullptr), c_cubic(nullptr), pressure_style(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); - pressure_style = NONE; comm_forward = 1; // Currently can only have one instance of fix rheo/pressure if (igroup != 0) error->all(FLERR,"fix rheo/pressure command requires group all"); - int ntypes = atom->ntypes; + int i, nlo, nhi; + int n = atom->ntypes; + memory->create(pressure_style, n + 1, "rheo:pressure_style"); + for (i = 1; i <= n; i++) pressure_style[i] = NONE; + int iarg = 3; - if (strcmp(arg[iarg], "linear") == 0) { - pressure_style = LINEAR; - } else if (strcmp(arg[iarg], "taitwater") == 0) { - pressure_style = TAITWATER; - } else if (strcmp(arg[iarg], "cubic") == 0) { - pressure_style = CUBIC; - if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for pressure option"); - c_cubic = utils::numeric(FLERR, arg[iarg + 1], false, lmp); - } else { - error->all(FLERR,"Illegal fix command, {}", arg[iarg]); + while (iarg < narg) { + utils::bounds(FLERR, arg[iarg], 1, n, nlo, nhi, error); + + if (iarg + 1 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/pressure", error); + + if (strcmp(arg[iarg + 1], "linear") == 0) { + for (i = nlo; i <= nhi; i++) + pressure_style[i] = LINEAR; + } else if (strcmp(arg[iarg + 1], "taitwater") == 0) { + for (i = nlo; i <= nhi; i++) + pressure_style[i] = TAITWATER; + } else if (strcmp(arg[iarg + 1], "cubic") == 0) { + if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/pressure cubic", error); + + double c_cubic_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + iarg += 1; + + for (i = nlo; i <= nhi; i++) { + pressure_style[i] = CUBIC; + c_cubic[i] = c_cubic_one; + } + } else { + error->all(FLERR,"Illegal fix command, {}", arg[iarg]); + } + iarg += 2; } - if (pressure_style == NONE) - error->all(FLERR,"Must specify pressure style for fix/rheo/pressure"); + for (i = 1; i <= n; i++) + if (pressure_style[i] == NONE) + error->all(FLERR,"Must specify pressure for atom type {} in fix/rheo/pressure", i); } /* ---------------------------------------------------------------------- */ FixRHEOPressure::~FixRHEOPressure() { + memory->destroy(pressure_style); + memory->destroy(csqinv); + memory->destroy(rho0inv); + memory->destroy(c_cubic); } /* ---------------------------------------------------------------------- */ @@ -92,9 +115,15 @@ void FixRHEOPressure::init() csq = fix_rheo->csq; rho0 = fix_rheo->rho0; - rho0inv = 1.0 / rho0; - // Cannot define multiple as pair rheo cannot currently distinguish + int n = atom->ntypes; + memory->create(csqinv, n + 1, "rheo:rho0inv"); + memory->create(rho0inv, n + 1, "rheo:rho0inv"); + for (int i = 0; i <= n; i++) { + csqinv[i] = 1.0 / csq[i]; + rho0inv[i] = 1.0 / rho0[i]; + } + if (modify->get_fix_by_style("rheo/pressure").size() > 1) error->all(FLERR, "Can only specify one instance of fix rheo/pressure"); } @@ -117,6 +146,7 @@ void FixRHEOPressure::pre_force(int /*vflag*/) double dr, rr3, rho_ratio; int *mask = atom->mask; + int *type = atom->type; double *rho = atom->rho; double *pressure = atom->pressure; @@ -124,7 +154,7 @@ void FixRHEOPressure::pre_force(int /*vflag*/) for (i = 0; i < nlocal; i++) if (mask[i] & groupbit) - pressure[i] = calc_pressure(rho[i]); + pressure[i] = calc_pressure(rho[i], type[i]); if (comm_forward) comm->forward_comm(this); } @@ -161,19 +191,37 @@ void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ -double FixRHEOPressure::calc_pressure(double rho) +double FixRHEOPressure::calc_pressure(double rho, int type) { double p, dr, rr3, rho_ratio; - if (pressure_style == LINEAR) { - p = csq * (rho - rho0); - } else if (pressure_style == CUBIC) { - dr = rho - rho0; - p = csq * (dr + c_cubic * dr * dr * dr); - } else if (pressure_style == TAITWATER) { - rho_ratio = rho / rho0inv; + if (pressure_style[type] == LINEAR) { + p = csq[type] * (rho - rho0[type]); + } else if (pressure_style[type] == CUBIC) { + dr = rho - rho0[type]; + p = csq[type] * (dr + c_cubic[type] * dr * dr * dr); + } else if (pressure_style[type] == TAITWATER) { + rho_ratio = rho * rho0inv[type]; rr3 = rho_ratio * rho_ratio * rho_ratio; - p = csq * rho0 * SEVENTH * (rr3 * rr3 * rho_ratio - 1.0); + p = csq[type] * rho0[type] * SEVENTH * (rr3 * rr3 * rho_ratio - 1.0); } return p; } + +/* ---------------------------------------------------------------------- */ + +double FixRHEOPressure::calc_rho(double p, int type) +{ + double rho, dr, rr3, rho_ratio; + + if (pressure_style[type] == LINEAR) { + rho = csqinv[type] * p + rho0[type]; + } else if (pressure_style[type] == CUBIC) { + error->one(FLERR, "Rho calculation from pressure not yet supported for cubic pressure equation"); + } else if (pressure_style[type] == TAITWATER) { + rho = pow(7.0 * p + csq[type] * rho0[type], SEVENTH); + rho *= pow(rho0[type], 6.0 * SEVENTH); + rho *= pow(csq[type], -SEVENTH); + } + return rho; +} diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h index cbcb495244..ee86c5e184 100644 --- a/src/RHEO/fix_rheo_pressure.h +++ b/src/RHEO/fix_rheo_pressure.h @@ -34,11 +34,12 @@ class FixRHEOPressure : public Fix { void pre_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; - double calc_pressure(double); + double calc_pressure(double, int); + double calc_rho(double, int); private: - double c_cubic, csq, rho0, rho0inv; - int pressure_style; + double *c_cubic, *csq, *csqinv, *rho0, *rho0inv; + int *pressure_style; class FixRHEO *fix_rheo; }; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 3b38089fad..dd2c6eddbd 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -41,108 +41,124 @@ using namespace LAMMPS_NS; using namespace RHEO_NS; using namespace FixConst; -enum {NONE, CONSTANT, TYPE}; +enum {NONE, CONSTANT}; /* ---------------------------------------------------------------------- */ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), fix_rheo(nullptr), compute_grad(nullptr), compute_vshift(nullptr), - Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr), fix_update_special_bonds(nullptr) + Tc(nullptr), kappa(nullptr), cv(nullptr), Tc_style(nullptr), kappa_style(nullptr), cv_style(nullptr), + fix_update_special_bonds(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); force_reneighbor = 1; next_reneighbor = -1; - - Tc_style = NONE; - cv_style = NONE; - conductivity_style = NONE; cut_bond = 0; comm_forward = 0; - int ntypes = atom->ntypes; + if (igroup != 0) + error->all(FLERR,"fix rheo/thermal command requires group all"); + + int i, nlo, nhi; + int n = atom->ntypes; + memory->create(Tc_style, n + 1, "rheo:Tc_style"); + memory->create(kappa_style, n + 1, "rheo:kappa_style"); + memory->create(cv_style, n + 1, "rheo:cv_style"); + for (i = 1; i <= n; i++) { + Tc_style[i] = NONE; + kappa_style[i] = NONE; + cv_style[i] = NONE; + } + int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"conductivity") == 0) { + if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal conductivity", error); + utils::bounds(FLERR, arg[iarg + 1], 1, n, nlo, nhi, error); + // Conductivity arguments - if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for conductivity option"); - if (strcmp(arg[iarg + 1], "constant") == 0) { - if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for conductivity option"); - conductivity_style = CONSTANT; - kappa = utils::numeric(FLERR, arg[iarg + 2], false, lmp); - if (kappa < 0.0) error->all(FLERR, "The conductivity must be positive"); - iarg += 2; - } else if (strcmp(arg[iarg + 1], "type") == 0) { - if (iarg + 1 + ntypes >= narg) error->all(FLERR, "Insufficient arguments for conductivity option"); - conductivity_style = TYPE; - memory->create(kappa_type, ntypes+1, "rheo_thermal:kappa_type"); - for (int i = 1; i <= ntypes; i++) { - kappa_type[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); - if (kappa_type[i] < 0.0) error->all(FLERR, "The conductivity must be positive"); + if (strcmp(arg[iarg + 2], "constant") == 0) { + if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal conductivity constant", error); + + double kappa_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + if (kappa_one < 0.0) error->all(FLERR, "The conductivity must be positive"); + iarg += 1; + + for (i = nlo; i <= nhi; i++) { + kappa_style[i] = CONSTANT; + kappa[i] = kappa_one; } - iarg += 1 + ntypes; } else { - error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); + error->all(FLERR,"Illegal fix command, {}", arg[iarg + 2]); } + + iarg += 2; } else if (strcmp(arg[iarg], "specific/heat") == 0) { + if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal specific/heat", error); + utils::bounds(FLERR, arg[iarg + 1], 1, n, nlo, nhi, error); + // Cv arguments - if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for cv option"); - if (strcmp(arg[iarg + 1], "constant") == 0) { - if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for cv option"); - cv_style = CONSTANT; - cv = utils::numeric(FLERR, arg[iarg + 2], false, lmp); - if (cv < 0.0) error->all(FLERR, "The specific heat must be positive"); - iarg += 2; - } else if (strcmp(arg[iarg + 1], "type") == 0) { - if (iarg + 1 + ntypes >= narg) error->all(FLERR, "Insufficient arguments for cv option"); - cv_style = TYPE; - memory->create(cv_type,ntypes + 1, "rheo_thermal:cv_type"); - for (int i = 1; i <= ntypes; i++) { - cv_type[i] = utils::numeric(FLERR, arg[iarg + 1 + i], false, lmp); - if (cv_type[i] < 0.0) error->all(FLERR, "The specific heat must be positive"); + if (strcmp(arg[iarg + 2], "constant") == 0) { + if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal specific/heat constant", error); + + double cv_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + if (cv_one < 0.0) error->all(FLERR, "The specific heat must be positive"); + iarg += 1; + + for (i = nlo; i <= nhi; i++) { + cv_style[i] = CONSTANT; + cv[i] = cv_one; } - iarg += 1 + ntypes; + } else { - error->all(FLERR,"Illegal fix command, {}", arg[iarg + 1]); + error->all(FLERR,"Illegal fix command, {}", arg[iarg + 2]); } + + iarg += 2; } else if (strcmp(arg[iarg], "Tfreeze") == 0) { + if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal Tfreeze", error); + utils::bounds(FLERR, arg[iarg + 1], 1, n, nlo, nhi, error); + // T freeze arguments - if (iarg + 1 >= narg) error->all(FLERR, "Insufficient arguments for Tfreeze option"); - if (strcmp(arg[iarg + 1], "constant") == 0) { - if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for Tfreeze option"); - Tc_style = CONSTANT; - Tc = utils::numeric(FLERR, arg[iarg + 2], false, lmp); - iarg += 2; - } else if (strcmp(arg[iarg + 1], "type") == 0) { - if (iarg + 1 + ntypes >= narg) error->all(FLERR, "Insufficient arguments for Tfreeze option"); - Tc_style = TYPE; - memory->create(Tc_type, ntypes + 1, "rheo_thermal:Tc_type"); - for (int i = 1; i <= ntypes; i++) { - Tc_type[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); - if (Tc_type[i] < 0.0) error->all(FLERR, "The melting temperature must be positive"); + if (strcmp(arg[iarg + 2], "constant") == 0) { + if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal Tfreeze constant", error); + + double Tc_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + iarg += 1; + + for (i = nlo; i <= nhi; i++) { + Tc_style[i] = CONSTANT; + Tc[i] = Tc_one; } - iarg += 1 + ntypes; + } else { - error->all(FLERR, "Illegal fix command, {}", arg[iarg + 1]); + error->all(FLERR, "Illegal fix command, {}", arg[iarg + 2]); } + + iarg += 2; } else if (strcmp(arg[iarg], "react") == 0) { - if (iarg + 2 >= narg) error->all(FLERR, "Insufficient arguments for react option"); + if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal react", error); cut_bond = utils::numeric(FLERR, arg[iarg + 1], false, lmp); btype = utils::numeric(FLERR, arg[iarg + 2], false, lmp); comm_forward = 1; - if (cut_bond <= 0.0) error->all(FLERR, "Illegal value for bond lengths");\ + if (cut_bond <= 0.0) error->all(FLERR, "Illegal max bond length must be greater than zero");\ if (btype < 1 || btype > atom->nbondtypes) error->all(FLERR, "Illegal value for bond type"); cutsq_bond = cut_bond * cut_bond; - iarg += 2; + iarg += 3; } else { error->all(FLERR,"Illegal fix command, {}", arg[iarg]); } - iarg += 1; } - if (cv_style == NONE || conductivity_style == NONE) - error->all(FLERR, "Must specify specific heat and conductivity styles\n"); + + for (i = 1; i <= n; i++) { + if (cv_style[i] == NONE) + error->all(FLERR,"Must specify specific/heat for atom type {} in fix/rheo/thermal", i); + if (kappa_style[i] == NONE) + error->all(FLERR,"Must specify conductivity for atom type {} in fix/rheo/thermal", i); + } } /* ---------------------------------------------------------------------- */ @@ -154,9 +170,12 @@ FixRHEOThermal::~FixRHEOThermal() index = atom->find_custom("rheo_conductivity", tmp1, tmp2); if (index != -1) atom->remove_custom(index, 1, 0); - memory->destroy(cv_type); - memory->destroy(Tc_type); - memory->destroy(kappa_type); + memory->destroy(cv_style); + memory->destroy(Tc_style); + memory->destroy(kappa_style); + memory->destroy(cv); + memory->destroy(Tc); + memory->destroy(kappa); } /* ---------------------------------------------------------------------- */ @@ -198,7 +217,6 @@ void FixRHEOThermal::init() if (atom->conductivity_flag != 1) error->all(FLERR,"fix rheo/thermal command requires atom property conductivity"); - if (cut_bond > 0.0) { if (!force->bond) error->all(FLERR,"Must define a bond style to use reactive bond generation with fix rheo/thermal"); if (!atom->avec->bonds_allow) error->all(FLERR, "Reactive bond generation in fix rheo/thermal requires atom bonds"); @@ -249,7 +267,6 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) int i, a; int *status = atom->status; - int *mask = atom->mask; double *temperature = atom->temperature; double **gradt = compute_grad->gradt; double **vshift = compute_vshift->array_atom; @@ -263,11 +280,8 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) for (i = 0; i < nlocal; i++) { if (status[i] & STATUS_NO_SHIFT) continue; - if (mask[i] & groupbit) { - for (a = 0; a < dim; a++) { - temperature[i] += dtv * vshift[i][a] * gradt[i][a]; - } - } + for (a = 0; a < dim; a++) + temperature[i] += dtv * vshift[i][a] * gradt[i][a]; } } @@ -275,52 +289,50 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) void FixRHEOThermal::post_integrate() { + int i, itype; + double cvi, Tci, Ti; + int *status = atom->status; double *temperature = atom->temperature; double *heatflow = atom->heatflow; double *rho = atom->rho; - int *mask = atom->mask; int *type = atom->type; - double cvi, Tci, Ti; - int n_melt = 0; int n_freeze = 0; //Integrate temperature and check status - for (int i = 0; i < atom->nlocal; i++) { - if (mask[i] & groupbit) { - if (status[i] & STATUS_NO_INTEGRATION) continue; + for (i = 0; i < atom->nlocal; i++) { + if (status[i] & STATUS_NO_INTEGRATION) continue; - cvi = calc_cv(i); - temperature[i] += dtf * heatflow[i] / cvi; + itype = type[i]; + cvi = calc_cv(i, type[i]); + temperature[i] += dtf * heatflow[i] / cvi; - if (Tc_style != NONE) { - Ti = temperature[i]; - if (Tc_style == CONSTANT) { - Tci = Tc; - } else if (Tc_style == TYPE) { - Tci = Tc_type[type[i]]; + if (Tc_style[itype] != NONE) { + Ti = temperature[i]; + if (Tc_style[itype] == CONSTANT) { + Tci = Tc[itype]; + } + + if (Ti > Tci) { + // If solid, melt + if (status[i] & STATUS_SOLID) { + status[i] &= PHASEMASK; + status[i] |= STATUS_MELTING; + n_melt += 1; } - - if (Ti > Tci) { - // If solid, melt - if (status[i] & STATUS_SOLID) { - status[i] &= PHASEMASK; - status[i] |= STATUS_MELTING; - n_melt += 1; - } - } else { - // If fluid, freeze - if (!(status[i] & STATUS_SOLID)) { - status[i] &= PHASEMASK; - status[i] |= STATUS_SOLID; - status[i] |= STATUS_FREEZING; - n_freeze += 1; - } + } else { + // If fluid, freeze + if (!(status[i] & STATUS_SOLID)) { + status[i] &= PHASEMASK; + status[i] |= STATUS_SOLID; + status[i] |= STATUS_FREEZING; + n_freeze += 1; } } } + } int n_melt_all, n_freeze_all; @@ -344,19 +356,16 @@ void FixRHEOThermal::post_integrate() void FixRHEOThermal::post_neighbor() { - int i; + int i, itype; int *type = atom->type; - int *mask = atom->mask; double *conductivity = atom->conductivity; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - if (conductivity_style == CONSTANT) { - for (i = 0; i < nall; i++) - if (mask[i] & groupbit) conductivity[i] = kappa; - } else if (conductivity_style == TYPE) { - for (i = 0; i < nall; i++) - if (mask[i] & groupbit) conductivity[i] = kappa_type[type[i]]; + for (i = 0; i < nall; i++) { + itype = type[i]; + if (kappa_style[itype] == CONSTANT) + conductivity[i] = kappa[itype]; } } @@ -372,21 +381,18 @@ void FixRHEOThermal::pre_force(int /*vflag*/) void FixRHEOThermal::final_integrate() { + int *status = atom->status; + int *type = atom->type; double *temperature = atom->temperature; double *heatflow = atom->heatflow; - int *status = atom->status; - int *mask = atom->mask; - double cvi; //Integrate temperature and check status for (int i = 0; i < atom->nlocal; i++) { - if (mask[i] & groupbit) { - if (status[i] & STATUS_NO_INTEGRATION) continue; + if (status[i] & STATUS_NO_INTEGRATION) continue; - cvi = calc_cv(i); - temperature[i] += dtf * heatflow[i] / cvi; - } + cvi = calc_cv(i, type[i]); + temperature[i] += dtf * heatflow[i] / cvi; } } @@ -522,12 +528,10 @@ void FixRHEOThermal::create_bonds() /* ---------------------------------------------------------------------- */ -double FixRHEOThermal::calc_cv(int i) +double FixRHEOThermal::calc_cv(int i, int itype) { - if (cv_style == CONSTANT) { - return cv; - } else if (cv_style == TYPE) { - return(cv_type[atom->type[i]]); + if (cv_style[itype] == CONSTANT) { + return cv[itype]; } } diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index da48a59e22..dc412d20b9 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -42,17 +42,14 @@ class FixRHEOThermal : public Fix { int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; void reset_dt() override; - double calc_cv(int); + double calc_cv(int, int); private: - double *cv_type, cv; - double *Tc_type, Tc; - double *kappa_type, kappa; + double *cv, *Tc, *kappa; double dtf, dtv; double cut_kernel, cut_bond, cutsq_bond; - int Tc_style, cv_style; + int *cv_style, *Tc_style, *kappa_style; int btype; - int conductivity_style; class NeighList *list; int n_histories; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index e33bd43244..91799ccfd0 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -32,60 +32,87 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum {NONE, CONSTANT, TYPE, POWER}; +enum {NONE, CONSTANT, POWER}; /* ---------------------------------------------------------------------- */ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), fix_rheo(nullptr), compute_grad(nullptr), eta_type(nullptr) + Fix(lmp, narg, arg), fix_rheo(nullptr), compute_grad(nullptr), eta(nullptr), + npow(nullptr), K(nullptr), gd0(nullptr), tau0(nullptr), viscosity_style(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix command"); - - viscosity_style = NONE; + if (narg < 4) error->all(FLERR, "Illegal fix command"); comm_forward = 0; + constant_flag = 0; + evolve_flag = 0; + + if (igroup != 0) + error->all(FLERR,"fix rheo/viscosity command requires group all"); + + int i, nlo, nhi; + int n = atom->ntypes; + memory->create(viscosity_style, n + 1, "rheo:viscosity_style"); + for (i = 1; i <= n; i++) viscosity_style[i] = NONE; - int ntypes = atom->ntypes; int iarg = 3; - if (strcmp(arg[iarg],"constant") == 0) { - if (iarg + 1 >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); - viscosity_style = CONSTANT; - eta = utils::numeric(FLERR,arg[iarg + 1],false,lmp); - if (eta < 0.0) error->all(FLERR,"The viscosity must be positive"); - iarg += 1; - } else if (strcmp(arg[iarg],"type") == 0) { - if (iarg + ntypes >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); - viscosity_style = TYPE; - memory->create(eta_type, ntypes + 1, "rheo_thermal:eta_type"); - for (int i = 1; i <= ntypes; i++) { - eta_type[i] = utils::numeric(FLERR,arg[iarg + i], false, lmp); - if (eta_type[i] < 0.0) error->all(FLERR,"The viscosity must be positive"); + while (iarg < narg) { + utils::bounds(FLERR, arg[iarg], 1, n, nlo, nhi, error); + + if (iarg + 1 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/viscosity", error); + + if (strcmp(arg[iarg + 1], "constant") == 0) { + if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/viscosity constant", error); + + constant_flag = 1; + double eta_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + if (eta_one < 0.0) error->all(FLERR, "The viscosity must be positive"); + iarg += 1; + + for (i = nlo; i <= nhi; i++) { + viscosity_style[i] = CONSTANT; + eta[i] = eta_one; + } + } else if (strcmp(arg[iarg], "power") == 0) { + if (iarg + 5 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/viscosity power", error); + + comm_forward = 1; + evolve_flag = 1; + double eta_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + double gd0_one = utils::numeric(FLERR, arg[iarg + 3], false, lmp); + double K_one = utils::numeric(FLERR, arg[iarg + 4], false, lmp); + double npow_one = utils::numeric(FLERR, arg[iarg + 5], false, lmp); + if (eta_one < 0.0) error->all(FLERR, "The viscosity must be positive"); + iarg += 4; + + for (i = nlo; i <= nhi; i++) { + viscosity_style[i] = POWER; + eta[i] = eta_one; + gd0[i] = gd0_one; + K[i] = K_one; + npow[i] = npow_one; + tau0[i] = eta[i] * gd0[i] - K[i] * pow(gd0[i], npow[i]); + } + } else { + error->all(FLERR, "Illegal fix command, {}", arg[iarg]); } - iarg += ntypes; - } else if (strcmp(arg[iarg],"power") == 0) { - if (iarg + 4 >= narg) error->all(FLERR,"Insufficient arguments for viscosity option"); - viscosity_style = POWER; - comm_forward = 1; - eta = utils::numeric(FLERR,arg[iarg + 1],false,lmp); - gd0 = utils::numeric(FLERR,arg[iarg + 2],false,lmp); - K = utils::numeric(FLERR,arg[iarg + 3],false,lmp); - npow = utils::numeric(FLERR,arg[iarg + 4],false,lmp); - tau0 = eta * gd0 - K * pow(gd0, npow); - if (eta < 0.0) error->all(FLERR,"The viscosity must be positive"); - iarg += 5; - } else { - error->all(FLERR,"Illegal fix command, {}", arg[iarg]); + iarg += 2; } - if (viscosity_style == NONE) - error->all(FLERR,"Must specify viscosity style for fix/rheo/viscosity"); + for (i = 1; i <= n; i++) + if (viscosity_style[i] == NONE) + error->all(FLERR,"Must specify viscosity for atom type {} in fix/rheo/viscosity", i); } /* ---------------------------------------------------------------------- */ FixRHEOViscosity::~FixRHEOViscosity() { - memory->destroy(eta_type); + memory->destroy(viscosity_style); + memory->destroy(eta); + memory->destroy(gd0); + memory->destroy(K); + memory->destroy(npow); + memory->destroy(tau0); } /* ---------------------------------------------------------------------- */ @@ -115,17 +142,8 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) { fix_rheo->viscosity_fix_defined = 1; - // Identify whether this is the last instance of fix viscosity - last_flag = 0; - - int i = 0; - auto fixlist = modify->get_fix_by_style("rheo/viscosity"); - for (const auto &fix : fixlist) { - if (strcmp(fix->id, id) == 0) break; - i++; - } - - if ((i + 1) == fixlist.size()) last_flag = 1; + if (modify->get_fix_by_style("rheo/viscosity").size() > 1) + error->all(FLERR, "More than one fix rheo/viscosity defined"); post_neighbor(); pre_force(0); @@ -137,20 +155,18 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/) void FixRHEOViscosity::post_neighbor() { - int i; + if (!constant_flag) return; + int i, itype; int *type = atom->type; - int *mask = atom->mask; double *viscosity = atom->viscosity; int nall = atom->nlocal + atom->nghost; - if (viscosity_style == CONSTANT) { - for (i = 0; i < nall; i++) - if (mask[i] & groupbit) viscosity[i] = eta; - } else if (viscosity_style == TYPE) { - for (i = 0; i < nall; i++) - if (mask[i] & groupbit) viscosity[i] = eta_type[type[i]]; + for (i = 0; i < nall; i++) { + itype = type[i]; + if (viscosity_style[itype]) + viscosity[i] = eta[itype]; } } @@ -160,39 +176,41 @@ void FixRHEOViscosity::post_neighbor() void FixRHEOViscosity::pre_force(int /*vflag*/) { - int i, a, b; + if (!evolve_flag) return; + + int i, itype, a, b; double tmp, gdot; - int *mask = atom->mask; + int *type = atom->type; double *viscosity = atom->viscosity; double **gradv = compute_grad->gradv; int nlocal = atom->nlocal; int dim = domain->dimension; - if (viscosity_style == POWER) { - for (i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - gdot = 0.0; - for (a = 0; a < dim; a++) { - for (b = a; b < dim; b++) { - tmp = gradv[i][a * dim + b] + gradv[i][b * dim + a]; - tmp = tmp * tmp; - if (a == b) tmp *= 0.5; - gdot += tmp; - } - } - gdot = sqrt(gdot); - if (gdot <= gd0) { - viscosity[i] = eta; - } else { - viscosity[i] = K * pow(gdot, npow - 1) + tau0 / gdot; + + for (i = 0; i < nlocal; i++) { + itype = type[i]; + if (viscosity_style[itype] == POWER) { + gdot = 0.0; + for (a = 0; a < dim; a++) { + for (b = a; b < dim; b++) { + tmp = gradv[i][a * dim + b] + gradv[i][b * dim + a]; + tmp = tmp * tmp; + if (a == b) tmp *= 0.5; + gdot += tmp; } } + gdot = sqrt(gdot); + if (gdot <= gd0[itype]) { + viscosity[i] = eta[itype]; + } else { + viscosity[i] = K[itype] * pow(gdot, npow[itype] - 1) + tau0[itype] / gdot; + } } } - if (last_flag && comm_forward) comm->forward_comm(this); + if (comm_forward) comm->forward_comm(this); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_viscosity.h b/src/RHEO/fix_rheo_viscosity.h index c681d18c00..f81feb74b2 100644 --- a/src/RHEO/fix_rheo_viscosity.h +++ b/src/RHEO/fix_rheo_viscosity.h @@ -37,9 +37,8 @@ class FixRHEOViscosity : public Fix { void unpack_forward_comm(int, int, double *) override; private: - double *eta_type, eta; - double npow, K, gd0, tau0; - int viscosity_style, last_flag; + double *eta, *npow, *K, *gd0, *tau0; + int *viscosity_style, constant_flag, evolve_flag; class FixRHEO *fix_rheo; class ComputeRHEOGrad *compute_grad; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index e22715eab1..bb3d5c3fda 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -47,8 +47,8 @@ static constexpr double EPSILON = 1e-2; /* ---------------------------------------------------------------------- */ PairRHEO::PairRHEO(LAMMPS *lmp) : - Pair(lmp), compute_kernel(nullptr), compute_grad(nullptr), - compute_interface(nullptr), fix_rheo(nullptr), fix_pressure(nullptr) + Pair(lmp), compute_kernel(nullptr), compute_grad(nullptr), compute_interface(nullptr), fix_rheo(nullptr), + fix_pressure(nullptr), rho0(nullptr), csq(nullptr), cs(nullptr) { restartinfo = 0; single_enable = 0; @@ -68,6 +68,8 @@ PairRHEO::~PairRHEO() memory->destroy(setflag); memory->destroy(cutsq); } + + memory->destroy(cs); } /* ---------------------------------------------------------------------- */ @@ -77,8 +79,8 @@ void PairRHEO::compute(int eflag, int vflag) int i, j, a, b, ii, jj, inum, jnum, itype, jtype; int pair_force_flag, pair_rho_flag, pair_avisc_flag; int fluidi, fluidj; - double xtmp, ytmp, ztmp, w, wp, Ti, Tj, dT; - double rhoi, rhoj, voli, volj, Pi, Pj, etai, etaj, kappai, kappaj; + double xtmp, ytmp, ztmp, w, wp, Ti, Tj, dT, csq_ave, cs_ave; + double rhoi, rhoj, rho0i, rho0j, voli, volj, Pi, Pj, etai, etaj, kappai, kappaj; double mu, q, fp_prefactor, drho_damp, fmag, psi_ij, Fij; double *dWij, *dWji, *dW1ij, *dW1ji; double dx[3], du[3], dv[3], fv[3], dfp[3], fsolid[3], ft[3], vi[3], vj[3]; @@ -178,6 +180,9 @@ void PairRHEO::compute(int eflag, int vflag) kappaj = conductivity[j]; } + cs_ave = 0.5 * (cs[itype] + cs[jtype]); + csq_ave = cs_ave * cs_ave; + pair_rho_flag = 0; pair_force_flag = 0; pair_avisc_flag = 0; @@ -201,31 +206,31 @@ void PairRHEO::compute(int eflag, int vflag) // Add corrections for walls rhoi = rho[i]; rhoj = rho[j]; + rho0i = rho[itype]; + rho0j = rho[jtype]; Pi = pressure[i]; Pj = pressure[j]; fmag = 0; if (interface_flag) { if (fluidi && (!fluidj)) { compute_interface->correct_v(vi, vj, i, j); - //compute_interface->correct_v(vj, vi, j, i); rhoj = compute_interface->correct_rho(j, i); - Pj = fix_pressure->calc_pressure(rhoj); + Pj = fix_pressure->calc_pressure(rhoj, jtype); if ((chi[j] > 0.9) && (r < (h * 0.5))) - fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; + fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0j * csq_ave * h * rinv; } else if ((!fluidi) && fluidj) { compute_interface->correct_v(vj, vi, j, i); - //compute_interface->correct_v(vi, vj, i, j); rhoi = compute_interface->correct_rho(i, j); - Pi = fix_pressure->calc_pressure(rhoi); + Pi = fix_pressure->calc_pressure(rhoi, itype); if (chi[i] > 0.9 && r < (h * 0.5)) - fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; + fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0i * csq_ave * h * rinv; } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0; - rhoj = rho0; + rhoi = rho0i; + rhoj = rho0j; } } @@ -239,12 +244,12 @@ void PairRHEO::compute(int eflag, int vflag) // Thermal Evolution if (thermal_flag) { dT = dot3(dx, dWij); - dT *= (kappai + kappaj) * (Ti - Tj) * rinv * rinv * voli * volj / rho0; + dT *= (kappai + kappaj) * (Ti - Tj) * rinv * rinv * voli * volj * 2.0 / (rhoi + rhoj); heatflow[i] += dT; if (newton_pair || j < nlocal) { dT = dot3(dx, dWji); - dT *= (kappai + kappaj) * (Tj - Ti) * rinv * rinv * voli * volj / rho0; + dT *= (kappai + kappaj) * (Tj - Ti) * rinv * rinv * voli * volj * 2.0 / (rhoi + rhoj); heatflow[j] -= dT; } } @@ -266,7 +271,7 @@ void PairRHEO::compute(int eflag, int vflag) mu = dot3(du, dx) * hinv3; mu /= (rsq * hinv3 * hinv3 + EPSILON); mu = MIN(0.0, mu); - q = av * (-2.0 * cs * mu + mu * mu); + q = av * (-2.0 * cs_ave * mu + mu * mu); fp_prefactor += voli * volj * q * (rhoj + rhoi); } @@ -334,7 +339,7 @@ void PairRHEO::compute(int eflag, int vflag) psi_ij += 0.5 * (gradr[i][a] + gradr[j][a]) * dx[a]; drho[i] += 2 * rho_damp * psi_ij * Fij * volj; } else { - drho_damp = 2 * rho_damp * (rhoj - rhoi) * rinv * wp; + drho_damp = 2 * rho_damp * ((rhoj - rho0[jtype]) - (rhoi - rho0[itype])) * rinv * wp; drho[i] -= drho_damp * volj; } @@ -383,23 +388,23 @@ void PairRHEO::allocate() void PairRHEO::settings(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal pair_style command"); + if (narg < 1) error->all(FLERR, "Illegal pair_style command"); - h = utils::numeric(FLERR,arg[0],false,lmp); + h = utils::numeric(FLERR, arg[0], false, lmp); int iarg = 1; while (iarg < narg) { if (strcmp(arg[iarg], "rho/damp") == 0) { - if (iarg + 1 >= narg) error->all(FLERR,"Illegal pair_style command"); + if (iarg + 1 >= narg) error->all(FLERR, "Illegal pair_style command"); rho_damp_flag = 1; - rho_damp = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + rho_damp = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg++; } else if (strcmp(arg[iarg], "artificial/visc") == 0) { - if (iarg + 1 >= narg) error->all(FLERR,"Illegal pair_style command"); + if (iarg + 1 >= narg) error->all(FLERR, "Illegal pair_style command"); artificial_visc_flag = 1; - av = utils::numeric(FLERR,arg[iarg + 1],false,lmp); + av = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg++; - } else error->all(FLERR,"Illegal pair_style command, {}", arg[iarg]); + } else error->all(FLERR, "Illegal pair_style command, {}", arg[iarg]); iarg++; } } @@ -411,13 +416,13 @@ void PairRHEO::settings(int narg, char **arg) void PairRHEO::coeff(int narg, char **arg) { if (narg != 2) - error->all(FLERR,"Incorrect number of args for pair_style rheo coefficients"); + error->all(FLERR, "Incorrect number of args for pair_style rheo coefficients"); if (!allocated) allocate(); int ilo, ihi, jlo, jhi; - utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi,error); - utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi,error); + utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error); + utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error); int count = 0; for (int i = ilo; i <= ihi; i++) { @@ -428,7 +433,7 @@ void PairRHEO::coeff(int narg, char **arg) } if (count == 0) - error->all(FLERR,"Incorrect args for pair rheo coefficients"); + error->all(FLERR, "Incorrect args for pair rheo coefficients"); } /* ---------------------------------------------------------------------- @@ -460,11 +465,14 @@ void PairRHEO::setup() hsq = h * h; hinv = 1.0 / h; hinv3 = hinv * 3.0; - cs = sqrt(csq); laplacian_order = -1; + int n = atom->ntypes; + memory->create(cs, n + 1, "rheo:cs"); + for (int i = 0; i <= n; i++) cs[i] = sqrt(csq[i]); + if (comm->ghost_velocity == 0) - error->all(FLERR,"Pair RHEO requires ghost atoms store velocity"); + error->all(FLERR, "Pair RHEO requires ghost atoms store velocity"); if (laplacian_order == -1) { if (fix_rheo->kernel_style == RK2) @@ -482,9 +490,8 @@ void PairRHEO::setup() double PairRHEO::init_one(int i, int j) { - if (setflag[i][j] == 0) { - error->all(FLERR,"All pair rheo coeffs are not set"); - } + if (setflag[i][j] == 0) + error->all(FLERR, "All pair rheo coeffs are not set"); return h; } diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index cb2227c8d6..c43d450b8b 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -37,8 +37,8 @@ class PairRHEO : public Pair { void unpack_reverse_comm(int, int *, double *) override; protected: - double h, csq, rho0; // From fix RHEO - double cs, hsq, hinv, hinv3, av, rho_damp; + double h, *csq, *rho0; // From fix RHEO + double *cs, hsq, hinv, hinv3, av, rho_damp; int laplacian_order; int artificial_visc_flag; diff --git a/src/RHEO/pair_rheo_react.cpp b/src/RHEO/pair_rheo_react.cpp index d7412d5d0e..1d54208792 100644 --- a/src/RHEO/pair_rheo_react.cpp +++ b/src/RHEO/pair_rheo_react.cpp @@ -296,20 +296,20 @@ void PairRHEOReact::allocate() allocated = 1; int n = atom->ntypes; - memory->create(setflag, n+1, n+1,"pair:setflag"); + memory->create(setflag, n + 1, n + 1, "pair:setflag"); for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) setflag[i][j] = 0; - memory->create(cut, n+1, n+1,"pair:cut"); - memory->create(cutbond, n+1, n+1,"pair:cutbond"); - memory->create(cutsq, n+1, n+1,"pair:cutsq"); - memory->create(cutbsq, n+1, n+1,"pair:cutbsq"); - memory->create(k, n+1, n+1,"pair:k"); - memory->create(eps, n+1, n+1,"pair:eps"); - memory->create(gamma, n+1, n+1,"pair:gamma"); - memory->create(t_form, n+1, n+1,"pair:t_form"); - memory->create(rlimit, n+1, n+1,"pair:rlimit"); + memory->create(cut, n + 1, n + 1, "pair:cut"); + memory->create(cutbond, n + 1, n + 1, "pair:cutbond"); + memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); + memory->create(cutbsq, n + 1, n + 1, "pair:cutbsq"); + memory->create(k, n + 1, n + 1, "pair:k"); + memory->create(eps, n + 1, n + 1, "pair:eps"); + memory->create(gamma, n + 1, n + 1, "pair:gamma"); + memory->create(t_form, n + 1, n + 1, "pair:t_form"); + memory->create(rlimit, n + 1, n + 1, "pair:rlimit"); } /* ---------------------------------------------------------------------- @@ -326,7 +326,7 @@ void PairRHEOReact::settings(int narg, char **arg) void PairRHEOReact::coeff(int narg, char **arg) { - if (narg != 9) error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg != 9) error->all(FLERR, "Incorrect args for pair coefficients"); if (!allocated) allocate(); int ilo, ihi, jlo, jhi; @@ -343,7 +343,7 @@ void PairRHEOReact::coeff(int narg, char **arg) if (k_one < 0.0 || eps_one < 0.0 || t_form_one < 0.0 || (1.0 + eps_one) * cutb_one > cut_one) - error->all(FLERR,"Illegal pair_style command"); + error->all(FLERR, "Illegal pair_style command"); int count = 0; for (int i = ilo; i <= ihi; i++) { @@ -360,7 +360,7 @@ void PairRHEOReact::coeff(int narg, char **arg) } } - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -406,7 +406,7 @@ void PairRHEOReact::setup() double PairRHEOReact::init_one(int i, int j) { - if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); + if (setflag[i][j] == 0) error->all(FLERR, "All pair coeffs are not set"); cutbsq[i][j] = cutbond[i][j] * cutbond[i][j]; From 1e26c6d0c5c344cbb69dea7ca9b24774b6a090c6 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 27 Nov 2023 15:53:19 -0700 Subject: [PATCH 061/104] Adding multiphase support, new stress --- src/RHEO/compute_rheo_property_atom.cpp | 31 ++++++- src/RHEO/compute_rheo_property_atom.h | 4 +- src/RHEO/compute_rheo_rho_sum.cpp | 5 +- src/RHEO/fix_rheo.cpp | 12 ++- src/RHEO/fix_rheo_pressure.cpp | 32 +++++++- src/RHEO/fix_rheo_pressure.h | 2 +- src/RHEO/fix_rheo_thermal.cpp | 2 +- src/RHEO/fix_rheo_viscosity.cpp | 4 + src/RHEO/pair_rheo.cpp | 52 +++++++++--- src/RHEO/pair_rheo.h | 2 + src/pair.cpp | 102 ++++++++++++++++++++++++ src/pair.h | 2 + 12 files changed, 222 insertions(+), 28 deletions(-) diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 50bcb2a2d0..e450eaaf0b 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -14,7 +14,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL) ----------------------------------------------------------------------- */ #include "compute_rheo_property_atom.h" @@ -29,6 +29,7 @@ #include "domain.h" #include "error.h" #include "fix_rheo.h" +#include "fix_rheo_pressure.h" #include "fix_rheo_thermal.h" #include "memory.h" #include "modify.h" @@ -44,7 +45,7 @@ using namespace RHEO_NS; /* ---------------------------------------------------------------------- */ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), fix_rheo(nullptr), fix_thermal(nullptr), compute_interface(nullptr), + Compute(lmp, narg, arg), fix_rheo(nullptr), fix_pressure(nullptr), fix_thermal(nullptr), compute_interface(nullptr), compute_kernel(nullptr), compute_surface(nullptr), compute_vshift(nullptr), compute_grad(nullptr), avec_index(nullptr), pack_choice(nullptr), col_index(nullptr) { @@ -55,7 +56,7 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (nvalues == 1) size_peratom_cols = 0; else size_peratom_cols = nvalues; - thermal_flag = interface_flag = surface_flag = shift_flag = 0; + pressure_flag = thermal_flag = interface_flag = surface_flag = shift_flag = 0; // parse input values // customize a new keyword by adding to if statement @@ -90,6 +91,9 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a col_index[i] = get_vector_index(arg[iarg]); } else if (strcmp(arg[iarg],"coordination") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_coordination; + } else if (strcmp(arg[iarg],"pressure") == 0) { + pressure_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_pressure; } else if (strcmp(arg[iarg],"cv") == 0) { thermal_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; @@ -155,6 +159,11 @@ void ComputeRHEOPropertyAtom::init() fixes = modify->get_fix_by_style("rheo/thermal"); fix_thermal = dynamic_cast(fixes[0]); } + + if (pressure_flag) { + fixes = modify->get_fix_by_style("rheo/pressure"); + fix_pressure = dynamic_cast(fixes[0]); + } } /* ---------------------------------------------------------------------- */ @@ -343,6 +352,22 @@ void ComputeRHEOPropertyAtom::pack_cv(int n) /* ---------------------------------------------------------------------- */ +void ComputeRHEOPropertyAtom::pack_pressure(int n) +{ + int *type = atom->type; + int *mask = atom->mask; + double *rho = atom->rho; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = fix_pressure->calc_pressure(rho[i], type[i]); + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + void ComputeRHEOPropertyAtom::pack_shift_v(int n) { double **vshift = compute_vshift->vshift; diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index bfae870ee5..f3596fbbf9 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -34,7 +34,7 @@ class ComputeRHEOPropertyAtom : public Compute { private: int nvalues, nmax; - int thermal_flag, interface_flag, surface_flag, shift_flag; + int pressure_flag, thermal_flag, interface_flag, surface_flag, shift_flag; int *avec_index; int *col_index; double *buf; @@ -53,12 +53,14 @@ class ComputeRHEOPropertyAtom : public Compute { void pack_cv(int); void pack_shift_v(int); void pack_gradv(int); + void pack_pressure(int); void pack_atom_style(int); int get_vector_index(char*); int get_tensor_index(char*); class FixRHEO *fix_rheo; + class FixRHEOPressure *fix_pressure; class FixRHEOThermal *fix_thermal; class ComputeRHEOInterface *compute_interface; class ComputeRHEOKernel *compute_kernel; diff --git a/src/RHEO/compute_rheo_rho_sum.cpp b/src/RHEO/compute_rheo_rho_sum.cpp index 0a2096a2b9..82d3aa4bc6 100644 --- a/src/RHEO/compute_rheo_rho_sum.cpp +++ b/src/RHEO/compute_rheo_rho_sum.cpp @@ -88,7 +88,7 @@ void ComputeRHEORhoSum::compute_peratom() // initialize arrays, local with quintic self-contribution, ghosts are zeroed for (i = 0; i < nlocal; i++) { w = compute_kernel->calc_w_quintic(i, i, 0.0, 0.0, 0.0, 0.0); - rho[i] += w * mass[type[i]]; + rho[i] = w * mass[type[i]]; } for (i = nlocal; i < nall; i++) rho[i] = 0.0; @@ -131,12 +131,11 @@ int ComputeRHEORhoSum::pack_forward_comm(int n, int *list, double *buf, { int i, j, k, m; double *rho = atom->rho; - int *coordination = compute_kernel->coordination; m = 0; for (i = 0; i < n; i++) { j = list[i]; - buf[m++] = coordination[j]; + buf[m++] = rho[j]; } return m; } diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index d07f0d1a1f..f0f380f23a 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -279,6 +279,9 @@ void FixRHEO::setup(int /*vflag*/) error->one(FLERR, "Fix rheo/viscosity does not fully cover all atoms"); if (!t_coverage_flag) error->one(FLERR, "Fix rheo/thermal does not fully cover all atoms"); + + if (rhosum_flag) + compute_rhosum->compute_peratom(); } /* ---------------------------------------------------------------------- */ @@ -419,10 +422,11 @@ void FixRHEO::pre_force(int /*vflag*/) status[i] &= OPTIONSMASK; // Calculate surfaces, update status - if (surface_flag) compute_surface->compute_peratom(); - - if (shift_flag) - compute_vshift->correct_surfaces(); + if (surface_flag) { + compute_surface->compute_peratom(); + if (shift_flag) + compute_vshift->correct_surfaces(); + } } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index eac4b34046..8c523b2b35 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -31,14 +31,14 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum {NONE, LINEAR, CUBIC, TAITWATER}; +enum {NONE, LINEAR, CUBIC, TAITWATER, TAITGENERAL}; static constexpr double SEVENTH = 1.0 / 7.0; /* ---------------------------------------------------------------------- */ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), fix_rheo(nullptr), rho0(nullptr), csq(nullptr), rho0inv(nullptr), csqinv(nullptr), c_cubic(nullptr), pressure_style(nullptr) + Fix(lmp, narg, arg), fix_rheo(nullptr), rho0(nullptr), csq(nullptr), rho0inv(nullptr), csqinv(nullptr), c_cubic(nullptr), tpower(nullptr), pbackground(nullptr), pressure_style(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -51,6 +51,9 @@ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : int i, nlo, nhi; int n = atom->ntypes; memory->create(pressure_style, n + 1, "rheo:pressure_style"); + memory->create(c_cubic, n + 1, "rheo:c_cubic"); + memory->create(tpower, n + 1, "rheo:tpower"); + memory->create(pbackground, n + 1, "rheo:pbackground"); for (i = 1; i <= n; i++) pressure_style[i] = NONE; int iarg = 3; @@ -62,9 +65,21 @@ FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg + 1], "linear") == 0) { for (i = nlo; i <= nhi; i++) pressure_style[i] = LINEAR; - } else if (strcmp(arg[iarg + 1], "taitwater") == 0) { + } else if (strcmp(arg[iarg + 1], "tait/water") == 0) { for (i = nlo; i <= nhi; i++) pressure_style[i] = TAITWATER; + } else if (strcmp(arg[iarg + 1], "tait/general") == 0) { + if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/pressure tait", error); + + double tpower_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + double pbackground_one = utils::numeric(FLERR, arg[iarg + 3], false, lmp); + iarg += 2; + + for (i = nlo; i <= nhi; i++) { + pressure_style[i] = TAITGENERAL; + tpower[i] = tpower_one; + pbackground[i] = pbackground_one; + } } else if (strcmp(arg[iarg + 1], "cubic") == 0) { if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/pressure cubic", error); @@ -94,6 +109,8 @@ FixRHEOPressure::~FixRHEOPressure() memory->destroy(csqinv); memory->destroy(rho0inv); memory->destroy(c_cubic); + memory->destroy(tpower); + memory->destroy(pbackground); } /* ---------------------------------------------------------------------- */ @@ -204,6 +221,10 @@ double FixRHEOPressure::calc_pressure(double rho, int type) rho_ratio = rho * rho0inv[type]; rr3 = rho_ratio * rho_ratio * rho_ratio; p = csq[type] * rho0[type] * SEVENTH * (rr3 * rr3 * rho_ratio - 1.0); + } else if (pressure_style[type] == TAITGENERAL) { + rho_ratio = rho * rho0inv[type]; + p = csq[type] * rho0[type] * (pow(rho_ratio, tpower[type]) - 1.0) / tpower[type]; + p += pbackground[type]; } return p; } @@ -222,6 +243,11 @@ double FixRHEOPressure::calc_rho(double p, int type) rho = pow(7.0 * p + csq[type] * rho0[type], SEVENTH); rho *= pow(rho0[type], 6.0 * SEVENTH); rho *= pow(csq[type], -SEVENTH); + } else if (pressure_style[type] == TAITGENERAL) { + p -= pbackground[type]; + rho = pow(tpower[type] * p + csq[type] * rho0[type], 1.0 / tpower[type]); + rho *= pow(rho0[type], 1.0 - 1.0 / tpower[type]); + rho *= pow(csq[type], -1.0 / tpower[type]); } return rho; } diff --git a/src/RHEO/fix_rheo_pressure.h b/src/RHEO/fix_rheo_pressure.h index ee86c5e184..ca165b1ed5 100644 --- a/src/RHEO/fix_rheo_pressure.h +++ b/src/RHEO/fix_rheo_pressure.h @@ -38,7 +38,7 @@ class FixRHEOPressure : public Fix { double calc_rho(double, int); private: - double *c_cubic, *csq, *csqinv, *rho0, *rho0inv; + double *c_cubic, *csq, *csqinv, *rho0, *rho0inv, *tpower, *pbackground; int *pressure_style; class FixRHEO *fix_rheo; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index dd2c6eddbd..e6c598418b 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL) ----------------------------------------------------------------------- */ #include "fix_rheo_thermal.h" diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 91799ccfd0..2fffa8b29c 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -52,6 +52,10 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : int i, nlo, nhi; int n = atom->ntypes; memory->create(viscosity_style, n + 1, "rheo:viscosity_style"); + memory->create(eta, n + 1, "rheo:eta"); + memory->create(gd0, n + 1, "rheo:gd0"); + memory->create(K, n + 1, "rheo:K"); + memory->create(npow, n + 1, "rheo:npow"); for (i = 1; i <= n; i++) viscosity_style[i] = NONE; int iarg = 3; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index bb3d5c3fda..339efed866 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -56,6 +56,7 @@ PairRHEO::PairRHEO(LAMMPS *lmp) : artificial_visc_flag = 0; rho_damp_flag = 0; thermal_flag = 0; + harmonic_means_flag = 0; comm_reverse = 3; } @@ -80,7 +81,7 @@ void PairRHEO::compute(int eflag, int vflag) int pair_force_flag, pair_rho_flag, pair_avisc_flag; int fluidi, fluidj; double xtmp, ytmp, ztmp, w, wp, Ti, Tj, dT, csq_ave, cs_ave; - double rhoi, rhoj, rho0i, rho0j, voli, volj, Pi, Pj, etai, etaj, kappai, kappaj; + double rhoi, rhoj, rho0i, rho0j, voli, volj, Pi, Pj, etai, etaj, kappai, kappaj, eta_ave, kappa_ave,dT_prefactor; double mu, q, fp_prefactor, drho_damp, fmag, psi_ij, Fij; double *dWij, *dWji, *dW1ij, *dW1ji; double dx[3], du[3], dv[3], fv[3], dfp[3], fsolid[3], ft[3], vi[3], vj[3]; @@ -112,6 +113,7 @@ void PairRHEO::compute(int eflag, int vflag) int *type = atom->type; int *status = atom->status; tagint *tag = atom->tag; + double fnorm, ftang[3]; double **fp_store, *chi; if (compute_interface) { @@ -243,14 +245,19 @@ void PairRHEO::compute(int eflag, int vflag) // Thermal Evolution if (thermal_flag) { + if (harmonic_means_flag) { + kappa_ave = 2.0 * kappai * kappaj / (kappai + kappaj); + } else { + kappa_ave = 0.5 * (kappai * kappaj); + } + dT_prefactor = 2.0 * kappa_ave * (Ti - Tj) * rinv * rinv * voli * volj * 2.0 / (rhoi + rhoj); + dT = dot3(dx, dWij); - dT *= (kappai + kappaj) * (Ti - Tj) * rinv * rinv * voli * volj * 2.0 / (rhoi + rhoj); - heatflow[i] += dT; + heatflow[i] += dT * dT_prefactor; if (newton_pair || j < nlocal) { dT = dot3(dx, dWji); - dT *= (kappai + kappaj) * (Tj - Ti) * rinv * rinv * voli * volj * 2.0 / (rhoi + rhoj); - heatflow[j] -= dT; + heatflow[j] += dT * dT_prefactor; } } @@ -260,6 +267,12 @@ void PairRHEO::compute(int eflag, int vflag) fp_prefactor = voli * volj * (Pj + Pi); sub3(vi, vj, dv); + if (harmonic_means_flag) { + eta_ave = 2.0 * etai * etaj / (etai + etaj); + } else { + eta_ave = 0.5 * (etai * etaj); + } + //Add artificial viscous pressure if required if (artificial_visc_flag && pair_avisc_flag) { //Interpolate velocities to midpoint and use this difference for artificial viscosity @@ -283,7 +296,7 @@ void PairRHEO::compute(int eflag, int vflag) fv[a] = 0.0; for (b = 0; b < dim; b++) fv[a] += dv[a] * dx[b] * dWij[b]; - fv[a] *= (etai + etaj) * voli * volj * rinv * rinv; + fv[a] *= 2.0 * eta_ave * voli * volj * rinv * rinv; } add3(fv, dfp, ft); @@ -293,26 +306,38 @@ void PairRHEO::compute(int eflag, int vflag) f[i][1] += ft[1]; f[i][2] += ft[2]; - if (evflag) // Does not account for unbalanced forces - ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], dx[0], dx[1], dx[2]); + if (evflag) { + fnorm = dot3(ft, dx) * rinv * rinv * 0.5; + ftang[0] = ft[0] * 0.5 - dx[0] * fnorm; + ftang[1] = ft[1] * 0.5 - dx[1] * fnorm; + ftang[2] = ft[2] * 0.5 - dx[2] * fnorm; + ev_tally_nt(i, j, nlocal, newton_pair, 0.0, 0.0, fnorm, ftang[0], ftang[1], ftang[2], dx[0], dx[1], dx[2]); + } if (newton_pair || j < nlocal) { for (a = 0; a < dim; a ++) { fv[a] = 0.0; for (b = 0; b < dim; b++) fv[a] += (vi[a] - vj[a]) * dx[b] * dWji[b]; - fv[a] *= -(etai + etaj) * voli * volj * rinv * rinv; + fv[a] *= -2.0 * eta_ave * voli * volj * rinv * rinv; // flip sign here b/c -= at accummulator } scale3(fp_prefactor, dWji, dfp); - add3(fv, dfp, ft); add3(fsolid, ft, ft); f[j][0] -= ft[0]; f[j][1] -= ft[1]; f[j][2] -= ft[2]; + + if (evflag) { + fnorm = - dot3(ft, dx) * rinv * rinv * 0.5; + ftang[0] = ft[0] * 0.5 + dx[0] * fnorm; + ftang[1] = ft[1] * 0.5 + dx[1] * fnorm; + ftang[2] = ft[2] * 0.5 + dx[2] * fnorm; + ev_tally_nt(i, j, nlocal, newton_pair, 0.0, 0.0, fnorm, ftang[0], ftang[1], ftang[2], -dx[0], -dx[1], -dx[2]); + } } if (compute_interface) { @@ -360,7 +385,7 @@ void PairRHEO::compute(int eflag, int vflag) if (vflag_fdotr) virial_fdotr_compute(); if (compute_interface) { - comm->reverse_comm(this); + if (newton_pair) comm->reverse_comm(this); comm->forward_comm(this); } } @@ -404,6 +429,8 @@ void PairRHEO::settings(int narg, char **arg) artificial_visc_flag = 1; av = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg++; + } else if (strcmp(arg[iarg], "harmonic/means") == 0) { + harmonic_means_flag = 1; } else error->all(FLERR, "Illegal pair_style command, {}", arg[iarg]); iarg++; } @@ -469,7 +496,8 @@ void PairRHEO::setup() int n = atom->ntypes; memory->create(cs, n + 1, "rheo:cs"); - for (int i = 0; i <= n; i++) cs[i] = sqrt(csq[i]); + for (int i = 1; i <= n; i++) + cs[i] = sqrt(csq[i]); if (comm->ghost_velocity == 0) error->all(FLERR, "Pair RHEO requires ghost atoms store velocity"); diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index c43d450b8b..7a47927962 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -46,6 +46,8 @@ class PairRHEO : public Pair { int thermal_flag; int interface_flag; + int harmonic_means_flag; + void allocate(); class ComputeRHEOKernel *compute_kernel; diff --git a/src/pair.cpp b/src/pair.cpp index 5d789fbb9b..56a6283afa 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -1246,6 +1246,108 @@ void Pair::ev_tally_xyz(int i, int j, int nlocal, int newton_pair, } } + +/* ---------------------------------------------------------------------- + tally eng_vdwl and virial into global or per-atom accumulators + for virial, have delx,dely,delz and fnormal and ftangential +------------------------------------------------------------------------- */ + +void Pair::ev_tally_nt(int i, int j, int nlocal, int newton_pair, + double evdwl, double ecoul, double fn, + double ftx, double fty, double ftz, + double delx, double dely, double delz) +{ + double evdwlhalf,ecoulhalf,epairhalf,v[6]; + + if (eflag_either) { + if (eflag_global) { + if (newton_pair) { + eng_vdwl += evdwl; + eng_coul += ecoul; + } else { + evdwlhalf = 0.5*evdwl; + ecoulhalf = 0.5*ecoul; + if (i < nlocal) { + eng_vdwl += evdwlhalf; + eng_coul += ecoulhalf; + } + if (j < nlocal) { + eng_vdwl += evdwlhalf; + eng_coul += ecoulhalf; + } + } + } + if (eflag_atom) { + epairhalf = 0.5 * (evdwl + ecoul); + if (newton_pair || i < nlocal) eatom[i] += epairhalf; + if (newton_pair || j < nlocal) eatom[j] += epairhalf; + } + } + + if (vflag_either) { + v[0] = delx*delx*fn; + v[1] = dely*dely*fn; + v[2] = delz*delz*fn; + v[3] = delx*dely*fn; + v[4] = delx*delz*fn; + v[5] = dely*delz*fn; + + v[0] += delx*ftx; + v[1] += dely*fty; + v[2] += delz*ftz; + v[3] += delx*fty + dely*ftx; + v[4] += delx*ftz + delz*ftx; + v[5] += dely*ftz + delz*fty; + + if (vflag_global) { + if (newton_pair) { + virial[0] += v[0]; + virial[1] += v[1]; + virial[2] += v[2]; + virial[3] += v[3]; + virial[4] += v[4]; + virial[5] += v[5]; + } else { + if (i < nlocal) { + virial[0] += 0.5*v[0]; + virial[1] += 0.5*v[1]; + virial[2] += 0.5*v[2]; + virial[3] += 0.5*v[3]; + virial[4] += 0.5*v[4]; + virial[5] += 0.5*v[5]; + } + if (j < nlocal) { + virial[0] += 0.5*v[0]; + virial[1] += 0.5*v[1]; + virial[2] += 0.5*v[2]; + virial[3] += 0.5*v[3]; + virial[4] += 0.5*v[4]; + virial[5] += 0.5*v[5]; + } + } + } + + if (vflag_atom) { + if (newton_pair || i < nlocal) { + vatom[i][0] += 0.5*v[0]; + vatom[i][1] += 0.5*v[1]; + vatom[i][2] += 0.5*v[2]; + vatom[i][3] += 0.5*v[3]; + vatom[i][4] += 0.5*v[4]; + vatom[i][5] += 0.5*v[5]; + } + if (newton_pair || j < nlocal) { + vatom[j][0] += 0.5*v[0]; + vatom[j][1] += 0.5*v[1]; + vatom[j][2] += 0.5*v[2]; + vatom[j][3] += 0.5*v[3]; + vatom[j][4] += 0.5*v[4]; + vatom[j][5] += 0.5*v[5]; + } + } + } +} + /* ---------------------------------------------------------------------- tally eng_vdwl and virial into global or per-atom accumulators for virial, have delx,dely,delz and fx,fy,fz diff --git a/src/pair.h b/src/pair.h index 885a2c45ff..6533c7b124 100644 --- a/src/pair.h +++ b/src/pair.h @@ -295,6 +295,8 @@ class Pair : protected Pointers { void ev_tally_tip4p(int, int *, double *, double, double); void ev_tally_xyz(int, int, int, int, double, double, double, double, double, double, double, double); + void ev_tally_nt(int, int, int, int, double, double, double, double, double, double, double, + double, double); void v_tally2(int, int, double, double *); void v_tally_tensor(int, int, int, int, double, double, double, double, double, double); void virial_fdotr_compute(); From f7aeecd3be03f98182d91d0a8ed50b94a6e9a46e Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 1 Dec 2023 09:58:40 -0700 Subject: [PATCH 062/104] Fixing error in averaging --- src/RHEO/pair_rheo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 339efed866..4ef0066e93 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -248,7 +248,7 @@ void PairRHEO::compute(int eflag, int vflag) if (harmonic_means_flag) { kappa_ave = 2.0 * kappai * kappaj / (kappai + kappaj); } else { - kappa_ave = 0.5 * (kappai * kappaj); + kappa_ave = 0.5 * (kappai + kappaj); } dT_prefactor = 2.0 * kappa_ave * (Ti - Tj) * rinv * rinv * voli * volj * 2.0 / (rhoi + rhoj); @@ -270,7 +270,7 @@ void PairRHEO::compute(int eflag, int vflag) if (harmonic_means_flag) { eta_ave = 2.0 * etai * etaj / (etai + etaj); } else { - eta_ave = 0.5 * (etai * etaj); + eta_ave = 0.5 * (etai + etaj); } //Add artificial viscous pressure if required From 7403426046c013a1f5c5b17fd4a50bcf59e2714e Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 19 Dec 2023 13:58:22 -0700 Subject: [PATCH 063/104] Argument error in fix rheo --- src/RHEO/fix_rheo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index f0f380f23a..0c74b2bad1 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -100,7 +100,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : thermal_flag = 1; } else if (strcmp(arg[iarg], "surface/detection") == 0) { surface_flag = 1; - if(iarg + 2 >= narg) error->all(FLERR, "Illegal surface/detection option in fix rheo"); + if(iarg + 3 >= narg) error->all(FLERR, "Illegal surface/detection option in fix rheo"); if (strcmp(arg[iarg + 1], "coordination") == 0) { surface_style = COORDINATION; zmin_surface = utils::inumeric(FLERR, arg[iarg + 2], false, lmp); From 08d2dd26991dce65f9beee61039952bd3f81ca37 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 22 Dec 2023 10:46:44 -0700 Subject: [PATCH 064/104] Prototyping latent heat, other misc fixes --- src/.gitignore | 35 +-- src/RHEO/atom_vec_rheo_thermal.cpp | 46 ++-- src/RHEO/atom_vec_rheo_thermal.h | 2 +- src/RHEO/compute_rheo_grad.cpp | 69 +++-- src/RHEO/compute_rheo_grad.h | 4 +- src/RHEO/compute_rheo_kernel.cpp | 15 +- src/RHEO/compute_rheo_kernel.h | 1 + src/RHEO/compute_rheo_property_atom.cpp | 8 + src/RHEO/compute_rheo_vshift.cpp | 4 + src/RHEO/fix_rheo.cpp | 3 +- src/RHEO/fix_rheo_thermal.cpp | 139 ++++++++-- src/RHEO/fix_rheo_thermal.h | 6 +- src/RHEO/pair_rheo.cpp | 1 - src/RHEO/pair_rheo_solid.cpp | 351 ++++++++++++++++++++++++ src/RHEO/pair_rheo_solid.h | 51 ++++ src/set.cpp | 2 +- 16 files changed, 611 insertions(+), 126 deletions(-) create mode 100644 src/RHEO/pair_rheo_solid.cpp create mode 100644 src/RHEO/pair_rheo_solid.h diff --git a/src/.gitignore b/src/.gitignore index 1e634782dc..ccf8072922 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -197,40 +197,7 @@ /pair_tdpd.cpp /pair_tdpd.h -/atom_vec_rheo.cpp -/atom_vec_rheo.h -/atom_vec_rheo_thermal.cpp -/atom_vec_rheo_thermal.h -/compute_rheo_grad.cpp -/compute_rheo_grad.h -/compute_rheo_interface.cpp -/compute_rheo_interface.h -/compute_rheo_kernel.cpp -/compute_rheo_kernel.h -/compute_rheo_property_atom.cpp -/compute_rheo_property_atom.h -/compute_rheo_rho_sum.cpp -/compute_rheo_rho_sum.h -/compute_rheo_surface.cpp -/compute_rheo_surface.h -/compute_rheo_vshift.cpp -/compute_rheo_vshift.h -/fix_rheo.cpp -/fix_rheo.h -/fix_rheo_pressure.cpp -/fix_rheo_pressure.h -/fix_rheo_stress.cpp -/fix_rheo_stress.h -/fix_rheo_tension.cpp -/fix_rheo_tension.h -/fix_rheo_thermal.cpp -/fix_rheo_thermal.h -/fix_rheo_viscosity.cpp -/fix_rheo_viscosity.h -/pair_rheo.cpp -/pair_rheo.h -/pair_rheo_react.cpp -/pair_rheo_react.h +/*rheo* /compute_grid.cpp /compute_grid.h diff --git a/src/RHEO/atom_vec_rheo_thermal.cpp b/src/RHEO/atom_vec_rheo_thermal.cpp index de0c7fa5d7..4ecb7136a8 100644 --- a/src/RHEO/atom_vec_rheo_thermal.cpp +++ b/src/RHEO/atom_vec_rheo_thermal.cpp @@ -35,6 +35,7 @@ AtomVecRHEOThermal::AtomVecRHEOThermal(LAMMPS *lmp) : AtomVec(lmp) atom->status_flag = 1; atom->conductivity_flag = 1; atom->temperature_flag = 1; + atom->esph_flag = 1; atom->heatflow_flag = 1; atom->pressure_flag = 1; atom->rho_flag = 1; @@ -45,17 +46,17 @@ AtomVecRHEOThermal::AtomVecRHEOThermal(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_copy = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_comm = {"status", "rho", "temperature"}; - fields_comm_vel = {"status", "rho", "temperature"}; + fields_grow = {"status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_copy = {"status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_comm = {"status", "rho", "esph"}; + fields_comm_vel = {"status", "rho", "esph"}; fields_reverse = {"drho", "heatflow"}; - fields_border = {"status", "rho", "temperature"}; - fields_border_vel = {"status", "rho", "temperature"}; - fields_exchange = {"status", "rho", "temperature"}; - fields_restart = {"status", "rho", "temperature"}; - fields_create = {"status", "rho", "drho", "temperature", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_data_atom = {"id", "type", "status", "rho", "temperature", "x"}; + fields_border = {"status", "rho", "esph"}; + fields_border_vel = {"status", "rho", "esph"}; + fields_exchange = {"status", "rho", "esph"}; + fields_restart = {"status", "rho", "esph"}; + fields_create = {"status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_data_atom = {"id", "type", "status", "rho", "esph", "x"}; fields_data_vel = {"id", "v"}; setup_fields(); @@ -71,6 +72,7 @@ void AtomVecRHEOThermal::grow_pointers() status = atom->status; conductivity = atom->conductivity; temperature = atom->temperature; + esph = atom->esph; heatflow = atom->heatflow; pressure = atom->pressure; rho = atom->rho; @@ -98,6 +100,7 @@ void AtomVecRHEOThermal::data_atom_post(int ilocal) { drho[ilocal] = 0.0; heatflow[ilocal] = 0.0; + temperature[ilocal] = 0.0; pressure[ilocal] = 0.0; viscosity[ilocal] = 0.0; conductivity[ilocal] = 0.0; @@ -114,10 +117,11 @@ int AtomVecRHEOThermal::property_atom(const std::string &name) if (name == "rho") return 1; if (name == "drho") return 2; if (name == "temperature") return 3; - if (name == "heatflow") return 4; - if (name == "conductivity") return 5; - if (name == "pressure") return 6; - if (name == "viscosity") return 7; + if (name == "esph") return 4; + if (name == "heatflow") return 5; + if (name == "conductivity") return 6; + if (name == "pressure") return 7; + if (name == "viscosity") return 8; return -1; } @@ -167,7 +171,7 @@ void AtomVecRHEOThermal::pack_property_atom(int index, double *buf, int nvalues, } else if (index == 4) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) - buf[n] = heatflow[i]; + buf[n] = esph[i]; else buf[n] = 0.0; n += nvalues; @@ -175,7 +179,7 @@ void AtomVecRHEOThermal::pack_property_atom(int index, double *buf, int nvalues, } else if (index == 5) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) - buf[n] = conductivity[i]; + buf[n] = heatflow[i]; else buf[n] = 0.0; n += nvalues; @@ -183,12 +187,20 @@ void AtomVecRHEOThermal::pack_property_atom(int index, double *buf, int nvalues, } else if (index == 6) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) - buf[n] = pressure[i]; + buf[n] = conductivity[i]; else buf[n] = 0.0; n += nvalues; } } else if (index == 7) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) + buf[n] = pressure[i]; + else + buf[n] = 0.0; + n += nvalues; + } + } else if (index == 8) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) buf[n] = viscosity[i]; diff --git a/src/RHEO/atom_vec_rheo_thermal.h b/src/RHEO/atom_vec_rheo_thermal.h index 27c6c3c9b5..ad467f9de7 100644 --- a/src/RHEO/atom_vec_rheo_thermal.h +++ b/src/RHEO/atom_vec_rheo_thermal.h @@ -36,7 +36,7 @@ class AtomVecRHEOThermal : virtual public AtomVec { private: int *status; - double *conductivity, *temperature, *heatflow; + double *conductivity, *temperature, *heatflow, *esph; double *pressure, *rho, *drho, *viscosity; }; diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index b2ca0c9dc4..acfc01d793 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -42,16 +42,16 @@ enum{COMMGRAD, COMMFIELD}; ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), fix_rheo(nullptr), list(nullptr), rho0(nullptr), compute_interface(nullptr), compute_kernel(nullptr), - gradv(nullptr), gradr(nullptr), gradt(nullptr), gradn(nullptr) + gradv(nullptr), gradr(nullptr), grade(nullptr), gradn(nullptr) { if (narg < 4) error->all(FLERR,"Illegal compute rheo/grad command"); - velocity_flag = temperature_flag = rho_flag = eta_flag = 0; + velocity_flag = energy_flag = rho_flag = eta_flag = 0; for (int iarg = 3; iarg < narg; iarg++) { - if (strcmp(arg[iarg],"velocity") == 0) velocity_flag = 1; - else if (strcmp(arg[iarg],"rho") == 0) rho_flag = 1; - else if (strcmp(arg[iarg],"temperature") == 0) temperature_flag = 1; - else if (strcmp(arg[iarg],"viscosity") == 0) eta_flag = 1; + if (strcmp(arg[iarg], "velocity") == 0) velocity_flag = 1; + else if (strcmp(arg[iarg], "rho") == 0) rho_flag = 1; + else if (strcmp(arg[iarg], "energy") == 0) energy_flag = 1; + else if (strcmp(arg[iarg], "viscosity") == 0) eta_flag = 1; else error->all(FLERR, "Illegal compute rheo/grad command, {}", arg[iarg]); } @@ -72,7 +72,7 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : comm_reverse += dim; } - if (temperature_flag) { + if (energy_flag) { ncomm_grad += dim; ncomm_field += 1; comm_reverse += dim; @@ -96,7 +96,7 @@ ComputeRHEOGrad::~ComputeRHEOGrad() { memory->destroy(gradv); memory->destroy(gradr); - memory->destroy(gradt); + memory->destroy(grade); memory->destroy(gradn); } @@ -130,7 +130,7 @@ void ComputeRHEOGrad::compute_peratom() int i, j, k, ii, jj, jnum, itype, jtype, a, b, fluidi, fluidj; double xtmp, ytmp, ztmp, delx, dely, delz; double rsq, imass, jmass; - double rhoi, rhoj, Voli, Volj, drho, dT, deta; + double rhoi, rhoj, Voli, Volj, drho, de, deta; double vi[3], vj[3], vij[3]; double wp, *dWij, *dWji; @@ -141,7 +141,7 @@ void ComputeRHEOGrad::compute_peratom() double **x = atom->x; double **v = atom->v; double *rho = atom->rho; - double *temperature = atom->temperature; + double *energy = atom->esph; double *viscosity = atom->viscosity; int *status = atom->status; int *type = atom->type; @@ -166,9 +166,9 @@ void ComputeRHEOGrad::compute_peratom() for (k = 0; k < dim; k++) gradr[i][k] = 0.0; } - if (temperature_flag) { + if (energy_flag) { for (k = 0; k < dim; k++) - gradt[i][k] = 0.0; + grade[i][k] = 0.0; } if (eta_flag) { for (k = 0; k < dim; k++) @@ -234,7 +234,7 @@ void ComputeRHEOGrad::compute_peratom() vij[2] = vi[2] - vj[2]; if (rho_flag) drho = rhoi - rhoj; - if (temperature_flag) dT = temperature[i] - temperature[j]; + if (energy_flag) de = energy[i] - energy[j]; if (eta_flag) deta = viscosity[i] - viscosity[j]; wp = compute_kernel->calc_dw(i, j, delx, dely, delz, sqrt(rsq)); @@ -250,8 +250,8 @@ void ComputeRHEOGrad::compute_peratom() if (rho_flag) // P,x P,y P,z gradr[i][a] -= drho * Volj * dWij[a]; - if (temperature_flag) // T,x T,y T,z - gradt[i][a] -= dT * Volj * dWij[a]; + if (energy_flag) // e,x e,y e,z + grade[i][a] -= de * Volj * dWij[a]; if (eta_flag) // n,x n,y n,z gradn[i][a] -= deta * Volj * dWij[a]; @@ -267,8 +267,8 @@ void ComputeRHEOGrad::compute_peratom() if (rho_flag) // P,x P,y P,z gradr[j][a] += drho * Voli * dWji[a]; - if (temperature_flag) // T,x T,y T,z - gradt[j][a] += dT * Voli * dWji[a]; + if (energy_flag) // e,x e,y e,z + grade[j][a] += de * Voli * dWji[a]; if (eta_flag) // n,x n,y n,z gradn[j][a] += deta * Voli * dWji[a]; @@ -308,7 +308,7 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, int i,j,k,m; int *mask = atom->mask; double *rho = atom->rho; - double *temperature = atom->temperature; + double *energy = atom->esph; double **v = atom->v; int dim = domain->dimension; double *h_rate = domain->h_rate; @@ -335,9 +335,9 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, for (k = 0; k < dim; k++) buf[m++] = gradr[j][k]; - if (temperature_flag) + if (energy_flag) for (k = 0; k < dim; k++) - buf[m++] = gradt[j][k]; + buf[m++] = grade[j][k]; if (eta_flag) for (k = 0; k < dim; k++) @@ -358,8 +358,8 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, if (rho_flag) buf[m++] = rho[j]; - if (temperature_flag) - buf[m++] = temperature[j]; + if (energy_flag) + buf[m++] = energy[j]; } } return m; @@ -371,8 +371,7 @@ void ComputeRHEOGrad::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; double *rho = atom->rho; - double *temperature = atom->temperature; - double **v = atom->v; + double *energy = atom->esph; double **v = atom->v; int dim = domain->dimension; m = 0; @@ -387,9 +386,9 @@ void ComputeRHEOGrad::unpack_forward_comm(int n, int first, double *buf) for (k = 0; k < dim; k++) gradr[i][k] = buf[m++]; - if (temperature_flag) + if (energy_flag) for (k = 0; k < dim; k++) - gradt[i][k] = buf[m++]; + grade[i][k] = buf[m++]; if (eta_flag) for (k = 0; k < dim; k++) @@ -403,8 +402,8 @@ void ComputeRHEOGrad::unpack_forward_comm(int n, int first, double *buf) if (rho_flag) rho[i] = buf[m++]; - if (temperature_flag) - temperature[i] = buf[m++]; + if (energy_flag) + energy[i] = buf[m++]; } } } @@ -427,9 +426,9 @@ int ComputeRHEOGrad::pack_reverse_comm(int n, int first, double *buf) for (k = 0; k < dim; k++) buf[m++] = gradr[i][k]; - if (temperature_flag) + if (energy_flag) for (k = 0; k < dim; k++) - buf[m++] = gradt[i][k]; + buf[m++] = grade[i][k]; if (eta_flag) for (k = 0; k < dim; k++) @@ -456,9 +455,9 @@ void ComputeRHEOGrad::unpack_reverse_comm(int n, int *list, double *buf) for (k = 0; k < dim; k++) gradr[j][k] += buf[m++]; - if (temperature_flag) + if (energy_flag) for (k = 0; k < dim; k++) - gradt[j][k] += buf[m++]; + grade[j][k] += buf[m++]; if (eta_flag) for (k = 0; k < dim; k++) @@ -477,8 +476,8 @@ void ComputeRHEOGrad::grow_arrays(int nmax) if (rho_flag) memory->grow(gradr, nmax, dim, "rheo:grad_rho"); - if (temperature_flag) - memory->grow(gradt, nmax, dim, "rheo:grad_temp"); + if (energy_flag) + memory->grow(grade, nmax, dim, "rheo:grad_energy"); if (eta_flag) memory->grow(gradn, nmax, dim, "rheo:grad_eta"); @@ -498,7 +497,7 @@ double ComputeRHEOGrad::memory_usage() if (rho_flag) bytes = (size_t) nmax_store * dim * sizeof(double); - if (temperature_flag) + if (energy_flag) bytes = (size_t) nmax_store * dim * sizeof(double); if (eta_flag) diff --git a/src/RHEO/compute_rheo_grad.h b/src/RHEO/compute_rheo_grad.h index 489f3c641d..2d663a5b07 100644 --- a/src/RHEO/compute_rheo_grad.h +++ b/src/RHEO/compute_rheo_grad.h @@ -40,7 +40,7 @@ class ComputeRHEOGrad : public Compute { void forward_fields(); double **gradv; double **gradr; - double **gradt; + double **grade; double **gradn; class FixRHEO *fix_rheo; @@ -48,7 +48,7 @@ class ComputeRHEOGrad : public Compute { int comm_stage, ncomm_grad, ncomm_field, nmax_store; double cut, cutsq, *rho0; - int velocity_flag, temperature_flag, rho_flag, eta_flag; + int velocity_flag, energy_flag, rho_flag, eta_flag; int interface_flag, remap_v_flag; class ComputeRHEOKernel *compute_kernel; diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 52380a4337..6f58d79243 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -86,6 +86,8 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : } comm_forward_save = comm_forward; + corrections_calculated = 0; + gsl_error_flag = 0; } /* ---------------------------------------------------------------------- */ @@ -152,6 +154,10 @@ int ComputeRHEOKernel::check_corrections(int i) if (coordination[i] < zmin) return 0; + // Skip if corrections not yet calculated + if (!corrections_calculated) + return 0; + return 1; } @@ -479,6 +485,7 @@ void ComputeRHEOKernel::compute_peratom() gsl_error_tags.clear(); if (kernel_style == QUINTIC) return; + corrections_calculated = 1; int i, j, ii, jj, inum, jnum, itype, g, a, b, gsl_error; double xtmp, ytmp, ztmp, r, rsq, w, vj, rhoj; @@ -530,11 +537,11 @@ void ComputeRHEOKernel::compute_peratom() if (rsq < hsq) { r = sqrt(rsq); - w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); + w = calc_w_quintic(i, j, dx[0], dx[1], dx[2], r); rhoj = rho[j]; if (interface_flag) if (status[j] & PHASECHECK) - rhoj = compute_interface->correct_rho(j,i); + rhoj = compute_interface->correct_rho(j, i); vj = mass[type[j]] / rhoj; M += w * vj; @@ -578,12 +585,12 @@ void ComputeRHEOKernel::compute_peratom() if (rsq < hsq) { r = sqrt(rsq); - w = calc_w_quintic(i,j,dx[0],dx[1],dx[2],r); + w = calc_w_quintic(i, j, dx[0], dx[1], dx[2], r); rhoj = rho[j]; if (interface_flag) if (status[j] & PHASECHECK) - rhoj = compute_interface->correct_rho(j,i); + rhoj = compute_interface->correct_rho(j, i); vj = mass[type[j]] / rhoj; diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index 2c9f4768e1..ed190c19ce 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -53,6 +53,7 @@ class ComputeRHEOKernel : public Compute { int gsl_error_flag; std::unordered_set gsl_error_tags; + int corrections_calculated; int kernel_style, zmin, dim, Mdim, ncor; int nmax_store; double h, hsq, hinv, hsqinv, pre_w, pre_wp; diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index e450eaaf0b..380ff398d8 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -104,6 +104,14 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a } else if (utils::strmatch(arg[iarg], "^grad/v")) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_gradv; col_index[i] = get_tensor_index(arg[iarg]); + } else if (strcmp(arg[iarg], "energy") == 0) { + avec_index[i] = atom->avec->property_atom("esph"); + if (avec_index[i] < 0) + error->all(FLERR, + "Invalid keyword {} for atom style {} in compute rheo/property/atom command ", + arg[iarg], atom->get_style()); + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_atom_style; + thermal_flag = 1; } else { avec_index[i] = atom->avec->property_atom(arg[iarg]); if (avec_index[i] < 0) diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 1f9314e99b..569c8569f7 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -32,6 +32,8 @@ #include "neigh_list.h" #include "neigh_request.h" +#include "update.h" + using namespace LAMMPS_NS; using namespace RHEO_NS; @@ -195,6 +197,7 @@ void ComputeRHEOVShift::compute_peratom() if (mask[i] & groupbit) { vmag = sqrt(vi[0] * vi[0] + vi[1] * vi[1] + vi[2] * vi[2]); prefactor = vmag * volj * dr; + vshift[i][0] += prefactor * dx[0]; vshift[i][1] += prefactor * dx[1]; vshift[i][2] += prefactor * dx[2]; @@ -204,6 +207,7 @@ void ComputeRHEOVShift::compute_peratom() if (mask[j] & groupbit) { vmag = sqrt(vj[0] * vj[0] + vj[1] * vj[1] + vj[2] * vj[2]); prefactor = vmag * voli * dr; + vshift[j][0] -= prefactor * dx[0]; vshift[j][1] -= prefactor * dx[1]; vshift[j][2] -= prefactor * dx[2]; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 0c74b2bad1..beba940174 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -164,7 +164,7 @@ void FixRHEO::post_constructor() compute_kernel->fix_rheo = this; std::string cmd = "rheo_grad all RHEO/GRAD velocity rho viscosity"; - if (thermal_flag) cmd += " temperature"; + if (thermal_flag) cmd += " energy"; compute_grad = dynamic_cast(modify->add_compute(cmd)); compute_grad->fix_rheo = this; @@ -401,6 +401,7 @@ void FixRHEO::pre_force(int /*vflag*/) compute_rhosum->compute_peratom(); compute_kernel->compute_peratom(); + if (interface_flag) { // Note on first setup, have no forces for pressure to reference compute_interface->compute_peratom(); diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index e6c598418b..7b61b9821e 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -47,7 +47,8 @@ enum {NONE, CONSTANT}; FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), fix_rheo(nullptr), compute_grad(nullptr), compute_vshift(nullptr), - Tc(nullptr), kappa(nullptr), cv(nullptr), Tc_style(nullptr), kappa_style(nullptr), cv_style(nullptr), + Tc(nullptr), kappa(nullptr), cv(nullptr), L(nullptr), + Tc_style(nullptr), kappa_style(nullptr), cv_style(nullptr), L_style(nullptr), fix_update_special_bonds(nullptr) { if (narg < 4) error->all(FLERR,"Illegal fix command"); @@ -62,13 +63,22 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : int i, nlo, nhi; int n = atom->ntypes; + memory->create(Tc_style, n + 1, "rheo:Tc_style"); memory->create(kappa_style, n + 1, "rheo:kappa_style"); memory->create(cv_style, n + 1, "rheo:cv_style"); + memory->create(L_style, n + 1, "rheo:L_style"); + + memory->create(Tc, n + 1, "rheo:Tc"); + memory->create(kappa, n + 1, "rheo:kappa"); + memory->create(cv, n + 1, "rheo:cv"); + memory->create(L, n + 1, "rheo:L"); + for (i = 1; i <= n; i++) { Tc_style[i] = NONE; kappa_style[i] = NONE; cv_style[i] = NONE; + L_style[i] = NONE; } int iarg = 3; @@ -81,9 +91,9 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg + 2], "constant") == 0) { if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal conductivity constant", error); - double kappa_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + double kappa_one = utils::numeric(FLERR, arg[iarg + 3], false, lmp); if (kappa_one < 0.0) error->all(FLERR, "The conductivity must be positive"); - iarg += 1; + iarg += 2; for (i = nlo; i <= nhi; i++) { kappa_style[i] = CONSTANT; @@ -102,9 +112,9 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg + 2], "constant") == 0) { if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal specific/heat constant", error); - double cv_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + double cv_one = utils::numeric(FLERR, arg[iarg + 3], false, lmp); if (cv_one < 0.0) error->all(FLERR, "The specific heat must be positive"); - iarg += 1; + iarg += 2; for (i = nlo; i <= nhi; i++) { cv_style[i] = CONSTANT; @@ -124,8 +134,8 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg + 2], "constant") == 0) { if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal Tfreeze constant", error); - double Tc_one = utils::numeric(FLERR, arg[iarg + 2], false, lmp); - iarg += 1; + double Tc_one = utils::numeric(FLERR, arg[iarg + 3], false, lmp); + iarg += 2; for (i = nlo; i <= nhi; i++) { Tc_style[i] = CONSTANT; @@ -136,6 +146,28 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR, "Illegal fix command, {}", arg[iarg + 2]); } + iarg += 2; + } else if (strcmp(arg[iarg], "latent/heat") == 0) { + if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal latent/heat", error); + utils::bounds(FLERR, arg[iarg + 1], 1, n, nlo, nhi, error); + + // Cv arguments + if (strcmp(arg[iarg + 2], "constant") == 0) { + if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal latent/heat constant", error); + + double L_one = utils::numeric(FLERR, arg[iarg + 3], false, lmp); + if (L_one < 0.0) error->all(FLERR, "The latent heat must be positive"); + iarg += 2; + + for (i = nlo; i <= nhi; i++) { + L_style[i] = CONSTANT; + L[i] = L_one; + } + + } else { + error->all(FLERR,"Illegal fix command, {}", arg[iarg + 2]); + } + iarg += 2; } else if (strcmp(arg[iarg], "react") == 0) { if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal react", error); @@ -155,9 +187,11 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : for (i = 1; i <= n; i++) { if (cv_style[i] == NONE) - error->all(FLERR,"Must specify specific/heat for atom type {} in fix/rheo/thermal", i); + error->all(FLERR, "Must specify specific/heat for atom type {} in fix/rheo/thermal", i); if (kappa_style[i] == NONE) - error->all(FLERR,"Must specify conductivity for atom type {} in fix/rheo/thermal", i); + error->all(FLERR, "Must specify conductivity for atom type {} in fix/rheo/thermal", i); + if (Tc_style[i] == NONE && L_style[i] != NONE) + error->all(FLERR, "Must specify critical temperature for atom type {} to use latent heat in fix rheo/thermal", i); } } @@ -173,9 +207,11 @@ FixRHEOThermal::~FixRHEOThermal() memory->destroy(cv_style); memory->destroy(Tc_style); memory->destroy(kappa_style); + memory->destroy(L_style); memory->destroy(cv); memory->destroy(Tc); memory->destroy(kappa); + memory->destroy(L); } /* ---------------------------------------------------------------------- */ @@ -210,6 +246,8 @@ void FixRHEOThermal::init() dtf = 0.5 * update->dt * force->ftm2v; + if (atom->esph_flag != 1) + error->all(FLERR,"fix rheo/thermal command requires atom property esph"); if (atom->temperature_flag != 1) error->all(FLERR,"fix rheo/thermal command requires atom property temperature"); if (atom->heatflow_flag != 1) @@ -267,9 +305,9 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) int i, a; int *status = atom->status; - double *temperature = atom->temperature; - double **gradt = compute_grad->gradt; - double **vshift = compute_vshift->array_atom; + double *energy = atom->esph; + double **grade = compute_grad->grade; + double **vshift = compute_vshift->vshift; int nlocal = atom->nlocal; int dim = domain->dimension; @@ -279,9 +317,8 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) for (i = 0; i < nlocal; i++) { if (status[i] & STATUS_NO_SHIFT) continue; - for (a = 0; a < dim; a++) - temperature[i] += dtv * vshift[i][a] * gradt[i][a]; + energy[i] += dtv * vshift[i][a] * grade[i][a]; } } @@ -290,29 +327,34 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) void FixRHEOThermal::post_integrate() { int i, itype; - double cvi, Tci, Ti; + double cvi, Tci, Ti, Li; int *status = atom->status; + double *energy = atom->esph; double *temperature = atom->temperature; double *heatflow = atom->heatflow; - double *rho = atom->rho; int *type = atom->type; int n_melt = 0; int n_freeze = 0; - //Integrate temperature and check status + //Integrate energy and check status for (i = 0; i < atom->nlocal; i++) { if (status[i] & STATUS_NO_INTEGRATION) continue; itype = type[i]; - cvi = calc_cv(i, type[i]); - temperature[i] += dtf * heatflow[i] / cvi; + cvi = calc_cv(i, itype); + energy[i] += dtf * heatflow[i]; + temperature[i] = energy[i] / cvi; if (Tc_style[itype] != NONE) { Ti = temperature[i]; - if (Tc_style[itype] == CONSTANT) { - Tci = Tc[itype]; + Tci = calc_Tc(i, itype); + + if (L_style[itype] != NONE) { + Li = calc_L(i, itype); + if (Ti > Tci) Ti = MAX(Tci, (energy[i] - Li) / cvi); + temperature[i] = Ti; } if (Ti > Tci) { @@ -370,11 +412,39 @@ void FixRHEOThermal::post_neighbor() } /* ---------------------------------------------------------------------- + Calculate temperature In the future, update & forward evolving conductivity styles every timestep ------------------------------------------------------------------------- */ void FixRHEOThermal::pre_force(int /*vflag*/) { + int i, itype; + double cvi, Tci, Ti, Li; + + double *energy = atom->esph; + double *temperature = atom->temperature; + int *type = atom->type; + + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + + // Calculate temperature + for (i = 0; i < nall; i++) { + itype = type[i]; + cvi = calc_cv(i, itype); + temperature[i] = energy[i] / cvi; + + if (Tc_style[itype] != NONE) { + Ti = temperature[i]; + Tci = calc_Tc(i, itype); + + if (L_style[itype] != NONE) { + Li = calc_L(i, itype); + if (Ti > Tci) Ti = MAX(Tci, (energy[i] - Li) / cvi); + temperature[i] = Ti; + } + } + } } /* ---------------------------------------------------------------------- */ @@ -382,17 +452,13 @@ void FixRHEOThermal::pre_force(int /*vflag*/) void FixRHEOThermal::final_integrate() { int *status = atom->status; - int *type = atom->type; - double *temperature = atom->temperature; + double *energy = atom->esph; double *heatflow = atom->heatflow; - double cvi; - //Integrate temperature and check status + //Integrate energy for (int i = 0; i < atom->nlocal; i++) { if (status[i] & STATUS_NO_INTEGRATION) continue; - - cvi = calc_cv(i, type[i]); - temperature[i] += dtf * heatflow[i] / cvi; + energy[i] += dtf * heatflow[i]; } } @@ -535,6 +601,23 @@ double FixRHEOThermal::calc_cv(int i, int itype) } } +/* ---------------------------------------------------------------------- */ + +double FixRHEOThermal::calc_Tc(int i, int itype) +{ + if (Tc_style[itype] == CONSTANT) { + return Tc[itype]; + } +} + +/* ---------------------------------------------------------------------- */ + +double FixRHEOThermal::calc_L(int i, int itype) +{ + if (L_style[itype] == CONSTANT) { + return L[itype]; + } +} /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index dc412d20b9..c4c26eef6a 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -43,12 +43,14 @@ class FixRHEOThermal : public Fix { void unpack_forward_comm(int, int, double *) override; void reset_dt() override; double calc_cv(int, int); + double calc_Tc(int, int); + double calc_L(int, int); private: - double *cv, *Tc, *kappa; + double *cv, *Tc, *kappa, *L; double dtf, dtv; double cut_kernel, cut_bond, cutsq_bond; - int *cv_style, *Tc_style, *kappa_style; + int *cv_style, *Tc_style, *kappa_style, *L_style; int btype; class NeighList *list; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 4ef0066e93..b07e914af1 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -96,7 +96,6 @@ void PairRHEO::compute(int eflag, int vflag) ev_init(eflag, vflag); double **gradv = compute_grad->gradv; - double **gradt = compute_grad->gradt; double **gradr = compute_grad->gradr; double **v = atom->v; double **x = atom->x; diff --git a/src/RHEO/pair_rheo_solid.cpp b/src/RHEO/pair_rheo_solid.cpp new file mode 100644 index 0000000000..1068e9b329 --- /dev/null +++ b/src/RHEO/pair_rheo_solid.cpp @@ -0,0 +1,351 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "pair_rheo_solid.h" + +#include "atom.h" +#include "comm.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "memory.h" +#include "neigh_list.h" +#include "neighbor.h" + +#include + +using namespace LAMMPS_NS; +using namespace RHEO_NS; + +/* ---------------------------------------------------------------------- */ + +PairRHEOSolid::PairRHEOSolid(LAMMPS *_lmp) : Pair(_lmp) +{ + writedata = 1; +} + +/* ---------------------------------------------------------------------- */ + +PairRHEOSolid::~PairRHEOSolid() +{ + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + + memory->destroy(k); + memory->destroy(cut); + memory->destroy(gamma); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairRHEOSolid::compute(int eflag, int vflag) +{ + int i, j, ii, jj, inum, jnum, itype, jtype; + double xtmp, ytmp, ztmp, delx, dely, delz, evdwl, fpair; + double r, rsq, rinv, factor_lj; + int *ilist, *jlist, *numneigh, **firstneigh; + double vxtmp, vytmp, vztmp, delvx, delvy, delvz, dot, smooth; + + evdwl = 0.0; + if (eflag || vflag) + ev_setup(eflag, vflag); + else + evflag = vflag_fdotr = 0; + + double **x = atom->x; + double **v = atom->v; + double **f = atom->f; + int *type = atom->type; + int *status = atom->status; + int nlocal = atom->nlocal; + int newton_pair = force->newton_pair; + double *special_lj = force->special_lj; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + if (!(status[i] & STATUS_SOLID)) continue; + + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + vxtmp = v[i][0]; + vytmp = v[i][1]; + vztmp = v[i][2]; + itype = type[i]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + if (!(status[j] & STATUS_SOLID)) continue; + + factor_lj = special_lj[sbmask(j)]; + + if (factor_lj == 0) continue; + + j &= NEIGHMASK; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + jtype = type[j]; + + if (rsq < cutsq[itype][jtype]) { + r = sqrt(rsq); + + rinv = 1.0 / r; + fpair = k[itype][jtype] * (cut[itype][jtype] - r); + + smooth = rsq / cutsq[itype][jtype]; + smooth *= smooth; + smooth *= smooth; + smooth = 1.0 - smooth; + delvx = vxtmp - v[j][0]; + delvy = vytmp - v[j][1]; + delvz = vztmp - v[j][2]; + dot = delx * delvx + dely * delvy + delz * delvz; + fpair -= gamma[itype][jtype] * dot * smooth * rinv; + + fpair *= factor_lj * rinv; + if (eflag) evdwl = 0.0; + + f[i][0] += delx * fpair; + f[i][1] += dely * fpair; + f[i][2] += delz * fpair; + + if (newton_pair || j < nlocal) { + f[j][0] -= delx * fpair; + f[j][1] -= dely * fpair; + f[j][2] -= delz * fpair; + } + + if (evflag) ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely, delz); + } + } + } + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairRHEOSolid::allocate() +{ + allocated = 1; + const int np1 = atom->ntypes + 1; + + memory->create(setflag, np1, np1, "pair:setflag"); + for (int i = 1; i < np1; i++) + for (int j = i; j < np1; j++) setflag[i][j] = 0; + + memory->create(cutsq, np1, np1, "pair:cutsq"); + + memory->create(k, np1, np1, "pair:k"); + memory->create(cut, np1, np1, "pair:cut"); + memory->create(gamma, np1, np1, "pair:gamma"); +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairRHEOSolid::settings(int narg, char ** /*arg*/) +{ + if (narg != 0) error->all(FLERR, "Illegal pair_style command"); +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairRHEOSolid::coeff(int narg, char **arg) +{ + if (narg != 5) error->all(FLERR, "Incorrect args for pair coefficients"); + if (!allocated) allocate(); + + int ilo, ihi, jlo, jhi; + utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error); + utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error); + + double k_one = utils::numeric(FLERR, arg[2], false, lmp); + double cut_one = utils::numeric(FLERR, arg[3], false, lmp); + double gamma_one = utils::numeric(FLERR, arg[4], false, lmp); + + if (cut_one <= 0.0) error->all(FLERR, "Incorrect args for pair coefficients"); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo, i); j <= jhi; j++) { + k[i][j] = k_one; + cut[i][j] = cut_one; + gamma[i][j] = gamma_one; + + setflag[i][j] = 1; + count++; + } + } + + if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairRHEOSolid::init_style() +{ + if (comm->ghost_velocity == 0) + error->all(FLERR,"Pair rheo/solid requires ghost atoms store velocity"); + + if (!atom->status_flag) + error->all(FLERR,"Pair rheo/solid requires atom_style rheo"); + + neighbor->add_request(this); +} + + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairRHEOSolid::init_one(int i, int j) +{ + if (setflag[i][j] == 0) { + cut[i][j] = mix_distance(cut[i][i], cut[j][j]); + k[i][j] = mix_energy(k[i][i], k[j][j], cut[i][i], cut[j][j]); + gamma[i][j] = mix_energy(gamma[i][i], gamma[j][j], cut[i][i], cut[j][j]); + } + + cut[j][i] = cut[i][j]; + k[j][i] = k[i][j]; + gamma[j][i] = gamma[i][j]; + + return cut[i][j]; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairRHEOSolid::write_restart(FILE *fp) +{ + write_restart_settings(fp); + + int i, j; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + fwrite(&setflag[i][j], sizeof(int), 1, fp); + if (setflag[i][j]) { + fwrite(&k[i][j], sizeof(double), 1, fp); + fwrite(&cut[i][j], sizeof(double), 1, fp); + fwrite(&gamma[i][j], sizeof(double), 1, fp); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairRHEOSolid::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); + + int i, j; + int me = comm->me; + for (i = 1; i <= atom->ntypes; i++) + for (j = i; j <= atom->ntypes; j++) { + if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error); + MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world); + if (setflag[i][j]) { + if (me == 0) { + utils::sfread(FLERR, &k[i][j], sizeof(double), 1, fp, nullptr, error); + utils::sfread(FLERR, &cut[i][j], sizeof(double), 1, fp, nullptr, error); + utils::sfread(FLERR, &gamma[i][j], sizeof(double), 1, fp, nullptr, error); + } + MPI_Bcast(&k[i][j], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&gamma[i][j], 1, MPI_DOUBLE, 0, world); + } + } +} + +/* ---------------------------------------------------------------------- + proc 0 writes to data file +------------------------------------------------------------------------- */ + +void PairRHEOSolid::write_data(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + fprintf(fp, "%d %g %g %g\n", i, k[i][i], cut[i][i], gamma[i][i]); +} + +/* ---------------------------------------------------------------------- + proc 0 writes all pairs to data file +------------------------------------------------------------------------- */ + +void PairRHEOSolid::write_data_all(FILE *fp) +{ + for (int i = 1; i <= atom->ntypes; i++) + for (int j = i; j <= atom->ntypes; j++) + fprintf(fp, "%d %d %g %g %g\n", i, j, k[i][j], cut[i][j], gamma[i][j]); +} + +/* ---------------------------------------------------------------------- */ + +double PairRHEOSolid::single(int i, int j, int itype, int jtype, double rsq, double /*factor_coul*/, + double factor_lj, double &fforce) +{ + double fpair, r, rinv; + double delx, dely, delz, delvx, delvy, delvz, dot, smooth; + + if (rsq > cutsq[itype][jtype]) return 0.0; + + double **x = atom->x; + double **v = atom->v; + + r = sqrt(rsq); + rinv = 1.0 / r; + + fpair = k[itype][jtype] * (cut[itype][jtype] - r); + + smooth = rsq / cutsq[itype][jtype]; + smooth *= smooth; + smooth = 1.0 - smooth; + delx = x[i][0] - x[j][0]; + dely = x[i][1] - x[j][1]; + delz = x[i][2] - x[j][2]; + delvx = v[i][0] - v[j][0]; + delvy = v[i][1] - v[j][1]; + delvz = v[i][2] - v[j][2]; + dot = delx * delvx + dely * delvy + delz * delvz; + fpair -= gamma[itype][jtype] * dot * rinv * smooth; + + fpair *= factor_lj; + fforce = fpair; + + return 0.0; +} diff --git a/src/RHEO/pair_rheo_solid.h b/src/RHEO/pair_rheo_solid.h new file mode 100644 index 0000000000..66c2ac4bf1 --- /dev/null +++ b/src/RHEO/pair_rheo_solid.h @@ -0,0 +1,51 @@ +/* -*- 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 PAIR_CLASS +// clang-format off +PairStyle(rheo/solid,PairRHEOSolid); +// clang-format on +#else + +#ifndef LMP_PAIR_RHEO_SOLID_H +#define LMP_PAIR_RHEO_SOLID_H + +#include "pair.h" + +namespace LAMMPS_NS { + +class PairRHEOSolid : public Pair { + public: + PairRHEOSolid(class LAMMPS *); + ~PairRHEOSolid() override; + void compute(int, int) override; + void settings(int, char **) override; + void coeff(int, char **) override; + void init_style() override; + double init_one(int, int) override; + void write_restart(FILE *) override; + void read_restart(FILE *) override; + void write_data(FILE *) override; + void write_data_all(FILE *) override; + double single(int, int, int, int, double, double, double, double &) override; + + protected: + double **k, **cut, **gamma; + + void allocate(); +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/set.cpp b/src/set.cpp index 3e1058b048..e0d20f1dc7 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -901,7 +901,7 @@ void Set::set(int keyword) } else if (keyword == RHEO_STATUS) { - if (ivalue != 0 && ivalue !=2) + if (ivalue != 0 && ivalue != 2) error->one(FLERR,"Invalid value {} in set command for rheo/status", ivalue); atom->status[i] = ivalue; } From 3f677f798ad965e2a875f85f940ee23122e59c10 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 22 Dec 2023 17:04:56 -0700 Subject: [PATCH 065/104] Fleshing out tension model --- src/RHEO/fix_rheo_tension.cpp | 322 ++++++++++++++++++++++++++-------- src/RHEO/fix_rheo_tension.h | 11 +- 2 files changed, 258 insertions(+), 75 deletions(-) diff --git a/src/RHEO/fix_rheo_tension.cpp b/src/RHEO/fix_rheo_tension.cpp index 8b79fcebd6..8d00c8b988 100644 --- a/src/RHEO/fix_rheo_tension.cpp +++ b/src/RHEO/fix_rheo_tension.cpp @@ -13,15 +13,21 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL) ----------------------------------------------------------------------- */ +// Todo: +// add citations +// remove (or fix) pairwise forces on undercoordinated atoms +// add option for vacuum tension (Frustenau 2020?) + #include "fix_rheo_tension.h" #include "atom.h" #include "comm.h" #include "compute_rheo_kernel.h" #include "compute_rheo_interface.h" +#include "compute_rheo_vshift.h" #include "domain.h" #include "error.h" #include "fix_rheo.h" @@ -44,12 +50,14 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixRHEOTension::FixRHEOTension(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), compute_kernel(nullptr), compute_interface(nullptr), fix_rheo(nullptr) + Fix(lmp, narg, arg), compute_kernel(nullptr), compute_interface(nullptr), compute_vshift(nullptr), fix_rheo(nullptr), rho0(nullptr) { - if (narg != 6) error->all(FLERR,"Illegal fix command"); + if (narg != 8) error->all(FLERR,"Illegal fix command"); alpha = utils::numeric(FLERR, arg[3], false, lmp); - alpha = utils::numeric(FLERR, arg[4], false, lmp); + beta = utils::numeric(FLERR, arg[4], false, lmp); wmin = utils::numeric(FLERR, arg[5], false, lmp); + cmin = utils::numeric(FLERR, arg[6], false, lmp); + vshift_strength = utils::numeric(FLERR, arg[7], false, lmp); comm_forward = 3; comm_reverse = 3; @@ -60,6 +68,10 @@ FixRHEOTension::FixRHEOTension(LAMMPS *lmp, int narg, char **arg) : // For norm, create a local array since they are unlikely to be printed int tmp1, tmp2; + index_ct = atom->find_custom("c_rheo_tension", tmp1, tmp2); + if (index_ct == -1) index_ct = atom->add_custom("c_rheo_tension", 1, 0); + ct = atom->dvector[index_ct]; + index_cgradt = atom->find_custom("cgrad_rheo_tension", tmp1, tmp2); if (index_cgradt == -1) index_cgradt = atom->add_custom("cgrad_rheo_tension", 1, 3); cgradt = atom->darray[index_cgradt]; @@ -72,12 +84,15 @@ FixRHEOTension::FixRHEOTension(LAMMPS *lmp, int narg, char **arg) : if (index_divnt == -1) index_divnt = atom->add_custom("divn_rheo_tension", 1, 0); divnt = atom->dvector[index_divnt]; + index_wsame = atom->find_custom("wsame_rheo_tension", tmp1, tmp2); + if (index_wsame == -1) index_wsame = atom->add_custom("wsame_rheo_tension", 1, 0); + wsame = atom->dvector[index_wsame]; + index_ft = atom->find_custom("f_rheo_tension", tmp1, tmp2); if (index_ft == -1) index_ft = atom->add_custom("f_rheo_tension", 1, 3); ft = atom->darray[index_ft]; norm = nullptr; - wsame = nullptr; nmax_store = 0; } @@ -88,6 +103,9 @@ FixRHEOTension::~FixRHEOTension() // Remove custom property if it exists int tmp1, tmp2, index; + index = atom->find_custom("c_rheo_tension", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 0); + index = atom->find_custom("cgrad_rheo_tension", tmp1, tmp2); if (index != -1) atom->remove_custom(index, 1, 3); @@ -97,11 +115,13 @@ FixRHEOTension::~FixRHEOTension() index = atom->find_custom("divn_rheo_tension", tmp1, tmp2); if (index != -1) atom->remove_custom(index, 1, 0); + index = atom->find_custom("wsame_rheo_tension", tmp1, tmp2); + if (index != -1) atom->remove_custom(index, 1, 0); + index = atom->find_custom("f_rheo_tension", tmp1, tmp2); if (index != -1) atom->remove_custom(index, 1, 3); memory->destroy(norm); - memory->destroy(wsame); } /* ---------------------------------------------------------------------- */ @@ -109,7 +129,7 @@ FixRHEOTension::~FixRHEOTension() int FixRHEOTension::setmask() { int mask = 0; - mask |= POST_FORCE; + mask |= PRE_FORCE; return mask; } @@ -123,7 +143,9 @@ void FixRHEOTension::init() compute_kernel = fix_rheo->compute_kernel; compute_interface = fix_rheo->compute_interface; + compute_vshift = fix_rheo->compute_vshift; interface_flag = fix_rheo->interface_flag; + shift_flag = fix_rheo->shift_flag; h = fix_rheo->h; rho0 = fix_rheo->rho0; @@ -144,19 +166,29 @@ void FixRHEOTension::init_list(int /*id*/, NeighList *ptr) void FixRHEOTension::setup(int vflag) { - // Grow and populate arrays - post_force(vflag); + // Grow and populate arrays for dump files + if (nmax_store <= atom->nmax) + grow_arrays(atom->nmax); + + size_t nbytes = nmax_store * sizeof(double); + memset(&ct[0], 0, nbytes); + memset(&norm[0], 0, nbytes); + memset(&wsame[0], 0, nbytes); + memset(&divnt[0], 0, nbytes); + memset(&cgradt[0][0], 0, 3 * nbytes); + memset(&ft[0][0], 0, 3 * nbytes); + memset(&nt[0][0], 0, 3 * nbytes); } /* ---------------------------------------------------------------------- Calculate and apply tension forces ------------------------------------------------------------------------- */ -void FixRHEOTension::post_force(int vflag) +void FixRHEOTension::pre_force(int vflag) { int i, j, a, ii, jj, inum, jnum, itype, jtype; int fluidi, fluidj; - double xtmp, ytmp, ztmp, w, wp, c; + double xtmp, ytmp, ztmp, w, wp, ctmp; double rhoi, rhoj, Voli, Volj; double *dWij, *dWji; double dx[3]; @@ -187,10 +219,73 @@ void FixRHEOTension::post_force(int vflag) grow_arrays(atom->nmax); size_t nbytes = nmax_store * sizeof(double); + memset(&ct[0], 0, nbytes); memset(&norm[0], 0, nbytes); memset(&wsame[0], 0, nbytes); memset(&divnt[0], 0, nbytes); memset(&cgradt[0][0], 0, 3 * nbytes); + memset(&ft[0][0], 0, 3 * nbytes); + + // Calculate color gradient + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = type[i]; + fluidi = !(status[i] & PHASECHECK); + jlist = firstneigh[i]; + jnum = numneigh[i]; + imass = mass[itype]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + + rsq = lensq3(dx); + + if (rsq > hsq) continue; + + fluidj = !(status[j] & PHASECHECK); + jtype = type[j]; + r = sqrt(rsq); + + rhoi = rho[i]; + rhoj = rho[j]; + + // Add corrections for walls + if (interface_flag) { + if (fluidi && (!fluidj)) { + rhoj = compute_interface->correct_rho(j, i); + } else if ((!fluidi) && fluidj) { + rhoi = compute_interface->correct_rho(i, j); + } else if ((!fluidi) && (!fluidj)) { + rhoi = rho0[itype]; + rhoj = rho0[jtype]; + } + } + + Voli = mass[itype] / rhoi; + Volj = mass[jtype] / rhoj; + + w = compute_kernel->calc_w(i, j, dx[0], dx[1], dx[2], r); + + if (itype != jtype) ctmp = 1; + else ctmp = 0; + + ct[i] += ctmp * Volj * w; + if (newton || j < nlocal) + ct[j] += ctmp * Voli * w; + } + } + + comm_stage = 0; + comm_reverse = 1; + if (newton) comm->reverse_comm(this); // Calculate color gradient for (ii = 0; ii < inum; ii++) { @@ -218,7 +313,6 @@ void FixRHEOTension::post_force(int vflag) fluidj = !(status[j] & PHASECHECK); jtype = type[j]; r = sqrt(rsq); - rinv = 1 / r; rhoi = rho[i]; rhoj = rho[j]; @@ -230,45 +324,50 @@ void FixRHEOTension::post_force(int vflag) } else if ((!fluidi) && fluidj) { rhoi = compute_interface->correct_rho(i, j); } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0; - rhoj = rho0; + rhoi = rho0[itype]; + rhoj = rho0[jtype]; } } Voli = mass[itype] / rhoi; Volj = mass[jtype] / rhoj; - wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2],r); + wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2], r); dWij = compute_kernel->dWij; dWji = compute_kernel->dWji; - c = 0; - if (itype != jtype) c += rhoi; - c /= (rhoi + rhoj); + //c = 0; + //if (itype != jtype) c += rhoi; + //c /= (rhoi + rhoj); - for (a = 0; a < 3; a++) { - cgradt[i][a] -= c * Volj * dWij[a]; + if (itype != jtype) ctmp = 1; + else ctmp = 0; + + for (a = 0; a < dim; a++) { + cgradt[i][a] -= ctmp * Volj * dWij[a]; if (newton || j < nlocal) - cgradt[j][a] -= c * Voli * dWji[a]; + cgradt[j][a] -= ctmp * Voli * dWji[a]; } } } - comm_stage = 0; + comm_stage = 1; comm_reverse = 3; if (newton) comm->reverse_comm(this); // Calculate normal direction double minv; for (i = 0; i < nlocal; i++) { - minv = sqrt(cgradt[i][0] * cgradt[i][0] + cgradt[i][1] * cgradt[i][1] + cgradt[i][2] * cgradt[i][2]); - + minv = cgradt[i][0] * cgradt[i][0] + cgradt[i][1] * cgradt[i][1]; + if (dim == 3) minv += cgradt[i][2] * cgradt[i][2]; + minv = sqrt(minv); if (minv != 0) minv = 1 / minv; - for (a = 0; a < 3; a++) + for (a = 0; a < dim; a++) nt[i][a] = cgradt[i][a] * minv; } + comm_forward = 3; comm->forward_comm(this); // Calculate divergence @@ -309,33 +408,33 @@ void FixRHEOTension::post_force(int vflag) } else if ((!fluidi) && fluidj) { rhoi = compute_interface->correct_rho(i, j); } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0; - rhoj = rho0; + rhoi = rho0[itype]; + rhoj = rho0[jtype]; } } Voli = mass[itype] / rhoi; Volj = mass[jtype] / rhoj; - w = compute_kernel->calc_w(i, j, dx[0], dx[1], dx[2],r); - wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2],r); + w = compute_kernel->calc_w(i, j, dx[0], dx[1], dx[2], r); + wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2], r); dWij = compute_kernel->dWij; dWji = compute_kernel->dWji; - for (a = 0; a < 3; a++) { - if (itype != jtype) - divnt[i] -= (nt[i][a]+nt[j][a]) * Volj * dWij[a]; - else { - divnt[i] -= (nt[i][a]-nt[j][a]) * Volj * dWij[a]; - wsame[i] += w; + for (a = 0; a < dim; a++) { + if (itype != jtype) { + divnt[i] -= (nt[i][a] + nt[j][a]) * Volj * dWij[a]; + } else { + divnt[i] -= (nt[i][a] - nt[j][a]) * Volj * dWij[a]; + wsame[i] += w * r; } norm[i] -= dx[a] * Volj * dWij[a]; if (newton || j < nlocal) { - if (itype != jtype) - divnt[j] -= (nt[j][a]+nt[i][a]) * Voli * dWji[a]; - else { - divnt[j] -= (nt[j][a]-nt[i][a]) * Voli * dWji[a]; - wsame[j] += w; + if (itype != jtype) { + divnt[j] -= (nt[j][a] + nt[i][a]) * Voli * dWji[a]; + } else { + divnt[j] -= (nt[j][a] - nt[i][a]) * Voli * dWji[a]; + wsame[j] += w * r; } norm[j] += dx[a] * Voli * dWji[a]; } @@ -343,21 +442,32 @@ void FixRHEOTension::post_force(int vflag) } } - comm_stage = 1; + comm_stage = 2; comm_reverse = 3; if (newton) comm->reverse_comm(this); + comm_forward = 1; + comm->forward_comm(this); + // Skip forces if it's setup if (update->setupflag) return; - // apply force - double weight, prefactor, unwrap[3], v[6]; - double wmin_inv = 1.0 / wmin; + // apply force, remove normal vshift + + double **vshift; + if (shift_flag) + vshift = compute_vshift->vshift; + double nx, ny, nz, vx, vy, vz, dot; + double wmin_inv, weight, prefactor, unwrap[3], v[6]; + + if (wmin > 0) wmin_inv = 1.0 / wmin; + else wmin_inv = 0.0; + for (i = 0; i < nlocal; i++) { - weight = MAX(1.0, (wsame[i] - wmin) * wmin_inv); - //if (wsame[i] < wmin) continue; + if (wsame[i] < wmin) continue; + weight = MAX(1.0, wsame[i] * wmin_inv); itype = type[i]; if (norm[i] != 0) @@ -365,10 +475,38 @@ void FixRHEOTension::post_force(int vflag) else divnt[i] = 0.0; + // Tension force from Adami, Hu, Adams 2010 prefactor = -alpha * divnt[i] * weight; - for (a = 0; a < 3; a++) { + for (a = 0; a < dim; a++) { f[i][a] += prefactor * cgradt[i][a]; - ft[i][a] = prefactor * cgradt[i][a]; + ft[i][a] += prefactor * cgradt[i][a]; + } + + // remove normal shifting component for interfacial particles + // Based on Yang, Rakhsha, Hu, & Negrut 2022 + if (shift_flag && (vshift_strength != 1.0)) { + if (ct[i] > cmin) { + nx = nt[i][0]; + ny = nt[i][1]; + vx = vshift[i][0]; + vy = vshift[i][1]; + + dot = nx * vx + ny * vy; + if (dim == 3) { + nz = nt[i][2]; + vz = vshift[i][2]; + dot += nz * vz; + } + + // Allowing shifting into the bulk + //if (dot > 0.0) continue; + + vshift[i][0] -= (1.0 - vshift_strength) * nx * dot; + vshift[i][1] -= (1.0 - vshift_strength) * ny * dot; + if (dim == 3) { + vshift[i][2] -= (1.0 - vshift_strength) * nz * dot; + } + } } if (evflag) { @@ -384,11 +522,16 @@ void FixRHEOTension::post_force(int vflag) } // If there is no lower limit, apply optional pairwise forces - if (wmin == 0 || beta == 0.0) return; + // This is totally ad hoc, needs some work + // Attempts to deal with stray single particles + if (wmin <= 0 || beta == 0.0) return; + int newton_pair = force->newton_pair; double fpair, wi, wj; double cut_two_thirds = 2.0 * h / 3.0; - double h_third_squared = (h / 3.0) * (h / 3.0); + double cut_five_sixths = 5.0 * h / 6.0; + double cut_sixth_sq = (h / 6.0) * (h / 6.0); + double cut_third_sq = (h / 3.0) * (h / 3.0); for (ii = 0; ii < inum; ii++) { i = ilist[ii]; xtmp = x[i][0]; @@ -397,9 +540,8 @@ void FixRHEOTension::post_force(int vflag) itype = type[i]; jlist = firstneigh[i]; jnum = numneigh[i]; - imass = mass[itype]; - wi = MIN(1.0, (wsame[i] - wmin) * wmin_inv); + wi = MAX(MIN(1.0, (wmin - wsame[i]) * wmin_inv), 0.0); for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; @@ -414,20 +556,38 @@ void FixRHEOTension::post_force(int vflag) if (rsq > hsq) continue; - wj = MIN(1.0, (wsame[j] - wmin) * wmin_inv); r = sqrt(rsq); - rinv = 1.0 / r; + jtype = type[j]; - fpair = (r - cut_two_thirds); - fpair *= fpair; - fpair -= h_third_squared; - fpair *= wi * wj * beta * rinv; + if (itype == jtype) { + fpair = (r - cut_two_thirds); + fpair *= fpair; + fpair -= cut_third_sq; + } else { + //fpair = 0.0; + + if (r > (0.5*cut_two_thirds)) continue; + fpair = (r - cut_two_thirds); + fpair *= fpair; + fpair -= cut_third_sq; + + //if (r > cut_two_thirds) continue; + //fpair = (r - cut_five_sixths); + //fpair *= fpair; + //fpair -= cut_sixth_sq; + + //fpair = (h - r) * 0.66666666666666; + } + + wj = MAX(MIN(1.0, (wmin - wsame[j]) * wmin_inv), 0.0); + rinv = 1.0 / r; + fpair *= MAX(wi, wj) * beta * rinv; f[i][0] += dx[0] * fpair; f[i][1] += dx[1] * fpair; f[i][2] += dx[2] * fpair; - if (newton || j < nlocal) { + if (newton_pair || j < nlocal) { f[j][0] -= dx[0] * fpair; f[j][1] -= dx[1] * fpair; f[j][2] -= dx[2] * fpair; @@ -448,11 +608,18 @@ int FixRHEOTension::pack_forward_comm(int n, int *list, double *buf, int /*pbc_f int i, j, a, m; m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - for (a = 0; a < 3; a++) - buf[m++] = nt[j][a]; - } + if (comm_stage == 1) + for (i = 0; i < n; i++) { + j = list[i]; + for (a = 0; a < 3; a++) + buf[m++] = nt[j][a]; + } + else if (comm_stage == 2) + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = wsame[j]; + } + return m; } @@ -464,9 +631,13 @@ void FixRHEOTension::unpack_forward_comm(int n, int first, double *buf) m = 0; last = first + n; - for (i = first; i < last; i++) - for (a = 0; a < 3; a++) - nt[i][a] = buf[m++]; + if (comm_stage == 1) + for (i = first; i < last; i++) + for (a = 0; a < 3; a++) + nt[i][a] = buf[m++]; + else if (comm_stage == 2) + for (i = first; i < last; i++) + wsame[i] = buf[m++]; } @@ -479,10 +650,13 @@ int FixRHEOTension::pack_reverse_comm(int n, int first, double *buf) m = 0; last = first + n; if (comm_stage == 0) + for (i = first; i < last; i++) + buf[m++] = ct[i]; + else if (comm_stage == 1) for (i = first; i < last; i++) for (a = 0; a < 3; a++) buf[m++] = cgradt[i][a]; - else + else if (comm_stage == 2) for (i = first; i < last; i++) { buf[m++] = norm[i]; buf[m++] = divnt[i]; @@ -499,12 +673,17 @@ void FixRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) m = 0; if (comm_stage == 0) + for (i = 0; i < n; i++) { + j = list[i]; + ct[j] += buf[m++]; + } + else if (comm_stage == 1) for (i = 0; i < n; i++) { j = list[i]; for (a = 0; a < 3; a++) cgradt[j][a] += buf[m++]; } - else + else if (comm_stage == 2) for (i = 0; i < n; i++) { j = list[i]; norm[j] += buf[m++]; @@ -518,19 +697,22 @@ void FixRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) void FixRHEOTension::grow_arrays(int nmax) { // Grow atom variables and reassign pointers + memory->grow(atom->dvector[index_ct], nmax, "atom:rheo_ct"); memory->grow(atom->darray[index_cgradt], nmax, 3, "atom:rheo_cgradt"); memory->grow(atom->darray[index_nt], nmax, 3, "atom:rheo_nt"); memory->grow(atom->dvector[index_divnt], nmax, "atom:rheo_divnt"); + memory->grow(atom->dvector[index_wsame], nmax, "atom:rheo_wsame"); memory->grow(atom->darray[index_ft], nmax, 3, "atom:rheo_ft"); + ct = atom->dvector[index_ct]; cgradt = atom->darray[index_cgradt]; nt = atom->darray[index_nt]; divnt = atom->dvector[index_divnt]; + wsame = atom->dvector[index_wsame]; ft = atom->darray[index_ft]; // Grow local variables memory->grow(norm, nmax, "rheo/tension:norm"); - memory->grow(wsame, nmax, "rheo/tension:wsame"); nmax_store = atom->nmax; } \ No newline at end of file diff --git a/src/RHEO/fix_rheo_tension.h b/src/RHEO/fix_rheo_tension.h index f56a61e688..52d368531f 100644 --- a/src/RHEO/fix_rheo_tension.h +++ b/src/RHEO/fix_rheo_tension.h @@ -32,7 +32,7 @@ class FixRHEOTension : public Fix { void init() override; void init_list(int, class NeighList *) override; void setup(int) override; - void post_force(int) override; + void pre_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; int pack_reverse_comm(int, int, double *) override; @@ -40,14 +40,15 @@ class FixRHEOTension : public Fix { void grow_arrays(int) override; private: - int nmax_store, comm_stage, interface_flag; - int index_nt, index_cgradt, index_divnt, index_ft; + int nmax_store, comm_stage, interface_flag, shift_flag; + int index_ct, index_nt, index_cgradt, index_divnt, index_ft, index_wsame; - double **nt, **cgradt, *divnt, *norm, **ft, *wsame; - double alpha, beta, wmin, h, hsq, hinv, hinv3, rho0; + double *ct, **nt, **cgradt, *divnt, *norm, **ft, *wsame; + double alpha, beta, wmin, cmin, vshift_strength, h, hsq, hinv, hinv3, *rho0; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOInterface *compute_interface; + class ComputeRHEOVShift *compute_vshift; class FixRHEO *fix_rheo; class NeighList *list; }; From a0cf5191c28054354fd9de7613771d267568d7ca Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 12 Jan 2024 17:00:12 -0700 Subject: [PATCH 066/104] Adding nonzero starting rhos --- src/RHEO/atom_vec_rheo.cpp | 9 +++++++++ src/RHEO/atom_vec_rheo.h | 1 + src/RHEO/atom_vec_rheo_thermal.cpp | 9 +++++++++ src/RHEO/atom_vec_rheo_thermal.h | 1 + 4 files changed, 20 insertions(+) diff --git a/src/RHEO/atom_vec_rheo.cpp b/src/RHEO/atom_vec_rheo.cpp index ea9e2a3c10..ec44a230ec 100644 --- a/src/RHEO/atom_vec_rheo.cpp +++ b/src/RHEO/atom_vec_rheo.cpp @@ -82,6 +82,15 @@ void AtomVecRHEO::force_clear(int n, size_t nbytes) memset(&drho[n], 0, nbytes); } +/* ---------------------------------------------------------------------- + initialize non-zero atom quantities +------------------------------------------------------------------------- */ + +void AtomVecRHEO::create_atom_post(int ilocal) +{ + rho[ilocal] = 1.0; +} + /* ---------------------------------------------------------------------- modify what AtomVec::data_atom() just unpacked or initialize other atom quantities diff --git a/src/RHEO/atom_vec_rheo.h b/src/RHEO/atom_vec_rheo.h index 68cc224ba5..62a7b1a630 100644 --- a/src/RHEO/atom_vec_rheo.h +++ b/src/RHEO/atom_vec_rheo.h @@ -30,6 +30,7 @@ class AtomVecRHEO : virtual public AtomVec { void grow_pointers() override; void force_clear(int, size_t) override; + void create_atom_post(int) override; void data_atom_post(int) override; int property_atom(const std::string &) override; void pack_property_atom(int, double *, int, int) override; diff --git a/src/RHEO/atom_vec_rheo_thermal.cpp b/src/RHEO/atom_vec_rheo_thermal.cpp index 4ecb7136a8..26394c9175 100644 --- a/src/RHEO/atom_vec_rheo_thermal.cpp +++ b/src/RHEO/atom_vec_rheo_thermal.cpp @@ -91,6 +91,15 @@ void AtomVecRHEOThermal::force_clear(int n, size_t nbytes) memset(&heatflow[n], 0, nbytes); } +/* ---------------------------------------------------------------------- + initialize non-zero atom quantities +------------------------------------------------------------------------- */ + +void AtomVecRHEOThermal::create_atom_post(int ilocal) +{ + rho[ilocal] = 1.0; +} + /* ---------------------------------------------------------------------- modify what AtomVec::data_atom() just unpacked or initialize other atom quantities diff --git a/src/RHEO/atom_vec_rheo_thermal.h b/src/RHEO/atom_vec_rheo_thermal.h index ad467f9de7..29a764bea9 100644 --- a/src/RHEO/atom_vec_rheo_thermal.h +++ b/src/RHEO/atom_vec_rheo_thermal.h @@ -30,6 +30,7 @@ class AtomVecRHEOThermal : virtual public AtomVec { void grow_pointers() override; void force_clear(int, size_t) override; + void create_atom_post(int) override; void data_atom_post(int) override; int property_atom(const std::string &) override; void pack_property_atom(int, double *, int, int) override; From 67f06097ee1d71babd2a3edd5654dcd8a3cc6108 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 15 Jan 2024 22:04:26 -0700 Subject: [PATCH 067/104] Updating utils functions for pair rheo/react --- src/RHEO/pair_rheo_react.cpp | 47 +++++++++++++++--------------------- src/RHEO/pair_rheo_react.h | 2 +- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/RHEO/pair_rheo_react.cpp b/src/RHEO/pair_rheo_react.cpp index 1d54208792..4709ea169e 100644 --- a/src/RHEO/pair_rheo_react.cpp +++ b/src/RHEO/pair_rheo_react.cpp @@ -89,7 +89,6 @@ PairRHEOReact::~PairRHEOReact() memory->destroy(cutsq); memory->destroy(cutbsq); - memory->destroy(cut); memory->destroy(cutbond); memory->destroy(k); memory->destroy(eps); @@ -301,10 +300,9 @@ void PairRHEOReact::allocate() for (int j = i; j <= n; j++) setflag[i][j] = 0; - memory->create(cut, n + 1, n + 1, "pair:cut"); memory->create(cutbond, n + 1, n + 1, "pair:cutbond"); - memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); memory->create(cutbsq, n + 1, n + 1, "pair:cutbsq"); + memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); memory->create(k, n + 1, n + 1, "pair:k"); memory->create(eps, n + 1, n + 1, "pair:eps"); memory->create(gamma, n + 1, n + 1, "pair:gamma"); @@ -333,24 +331,21 @@ void PairRHEOReact::coeff(int narg, char **arg) utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi,error); utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi,error); - double cut_one = utils::numeric(FLERR, arg[2], false, lmp); + double k_one = utils::numeric(FLERR, arg[2], false, lmp); double cutb_one = utils::numeric(FLERR, arg[3], false, lmp); - double k_one = utils::numeric(FLERR, arg[4], false, lmp); - double eps_one = utils::numeric(FLERR, arg[5], false, lmp); - double gamma_one = utils::numeric(FLERR, arg[6], false, lmp); - double t_form_one = utils::numeric(FLERR, arg[7], false, lmp); - double rlimit_one = utils::numeric(FLERR, arg[8], false, lmp); + double eps_one = utils::numeric(FLERR, arg[4], false, lmp); + double gamma_one = utils::numeric(FLERR, arg[5], false, lmp); + double t_form_one = utils::numeric(FLERR, arg[6], false, lmp); + double rlimit_one = utils::numeric(FLERR, arg[7], false, lmp); - if (k_one < 0.0 || eps_one < 0.0 || - t_form_one < 0.0 || (1.0 + eps_one) * cutb_one > cut_one) + if (k_one < 0.0 || eps_one < 0.0 || t_form_one < 0.0) error->all(FLERR, "Illegal pair_style command"); int count = 0; for (int i = ilo; i <= ihi; i++) { for (int j = MAX(jlo,i); j <= jhi; j++) { - cut[i][j] = cut_one; - cutbond[i][j] = cutb_one; k[i][j] = k_one; + cutbond[i][j] = cutb_one; eps[i][j] = eps_one; gamma[i][j] = gamma_one; t_form[i][j] = t_form_one; @@ -411,7 +406,6 @@ double PairRHEOReact::init_one(int i, int j) cutbsq[i][j] = cutbond[i][j] * cutbond[i][j]; cutbsq[j][i] = cutbsq[i][j]; - cut[j][i] = cut[i][j]; cutbond[j][i] = cutbond[i][j]; k[j][i] = k[i][j]; eps[j][i] = eps[i][j]; @@ -419,7 +413,9 @@ double PairRHEOReact::init_one(int i, int j) t_form[j][i] = t_form[i][j]; rlimit[j][i] = rlimit[i][j]; - return cut[i][j]; + double cut = cutbond[i][j] * (1.0 + eps[i][j]); + + return cut; } /* ---------------------------------------------------------------------- @@ -435,9 +431,8 @@ void PairRHEOReact::write_restart(FILE *fp) for (j = i; j <= atom->ntypes; j++) fwrite(&setflag[i][j], sizeof(int), 1, fp); if (setflag[i][j]) { - fwrite(&cut[i][j], sizeof(double), 1, fp); - fwrite(&cutbond[i][j], sizeof(double), 1, fp); fwrite(&k[i][j], sizeof(double), 1, fp); + fwrite(&cutbond[i][j], sizeof(double), 1, fp); fwrite(&eps[i][j], sizeof(double), 1, fp); fwrite(&gamma[i][j], sizeof(double), 1, fp); fwrite(&t_form[i][j], sizeof(double), 1, fp); @@ -458,21 +453,19 @@ void PairRHEOReact::read_restart(FILE *fp) int me = comm->me; for (i = 1; i <= atom->ntypes; i++) for (j = i; j <= atom->ntypes; j++) { - if (me == 0) fread(&setflag[i][j], sizeof(int), 1, fp); + if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error); MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world); if (setflag[i][j]) { if (me == 0) { - fread(&cut[i][j], sizeof(double), 1, fp); - fread(&cutbond[i][j], sizeof(double), 1, fp); - fread(&k[i][j], sizeof(double), 1, fp); - fread(&eps[i][j], sizeof(double), 1, fp); - fread(&gamma[i][j], sizeof(double), 1, fp); - fread(&t_form[i][j], sizeof(double), 1, fp); - fread(&rlimit[i][j], sizeof(double), 1, fp); + utils::sfread(FLERR, &k[i][j], sizeof(double), 1, fp, nullptr, error); + utils::sfread(FLERR, &cutbond[i][j], sizeof(double), 1, fp, nullptr, error); + utils::sfread(FLERR, &eps[i][j], sizeof(double), 1, fp, nullptr, error); + utils::sfread(FLERR, &gamma[i][j], sizeof(double), 1, fp, nullptr, error); + utils::sfread(FLERR, &t_form[i][j], sizeof(double), 1, fp, nullptr, error); + utils::sfread(FLERR, &rlimit[i][j], sizeof(double), 1, fp, nullptr, error); } - MPI_Bcast(&cut[i][j], 1,MPI_DOUBLE, 0, world); - MPI_Bcast(&cutbond[i][j], 1,MPI_DOUBLE, 0, world); MPI_Bcast(&k[i][j], 1,MPI_DOUBLE, 0, world); + MPI_Bcast(&cutbond[i][j], 1,MPI_DOUBLE, 0, world); MPI_Bcast(&eps[i][j], 1,MPI_DOUBLE, 0, world); MPI_Bcast(&gamma[i][j], 1,MPI_DOUBLE, 0, world); MPI_Bcast(&t_form[i][j], 1,MPI_DOUBLE, 0, world); diff --git a/src/RHEO/pair_rheo_react.h b/src/RHEO/pair_rheo_react.h index 144859e68b..88d5dbeb0e 100644 --- a/src/RHEO/pair_rheo_react.h +++ b/src/RHEO/pair_rheo_react.h @@ -40,7 +40,7 @@ class PairRHEOReact : public Pair { void unpack_reverse_comm(int, int *, double *) override; protected: - double **cut, **cutbond, **cutbsq, **k, **eps, **gamma, **t_form, **rlimit; + double **cutbond, **cutbsq, **k, **eps, **gamma, **t_form, **rlimit; void allocate(); void transfer_history(double*, double*); From 80861fe1ff0f6ce4e1a00acd2dd3a0b1603fae05 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 19 Jan 2024 21:24:27 -0700 Subject: [PATCH 068/104] New syntax in doc files --- doc/src/compute_rheo_property_atom.rst | 19 +++++--- doc/src/fix_rheo.rst | 3 +- doc/src/fix_rheo_pressure.rst | 9 ++-- doc/src/fix_rheo_thermal.rst | 47 ++++++++++++------ doc/src/fix_rheo_viscosity.rst | 12 ++--- doc/src/pair_rheo.rst | 9 ++-- doc/src/pair_rheo_react.rst | 67 ++++++++++++++++++++++++++ doc/src/pair_rheo_solid.rst | 58 ++++++++++++++++++++++ 8 files changed, 187 insertions(+), 37 deletions(-) create mode 100644 doc/src/pair_rheo_react.rst create mode 100644 doc/src/pair_rheo_solid.rst diff --git a/doc/src/compute_rheo_property_atom.rst b/doc/src/compute_rheo_property_atom.rst index 5476f7f709..7f5de17c3b 100644 --- a/doc/src/compute_rheo_property_atom.rst +++ b/doc/src/compute_rheo_property_atom.rst @@ -17,11 +17,13 @@ Syntax .. parsed-literal:: possible attributes = phase, chi, surface, surface/r, - surface/divr, surface/nx, surface/ny, - surface/nz, coordination, cv, shift/vx, - shift/vy, shift/vz, temperature, heatflow, - conductivity, viscosity, pressure, status, - rho + surface/divr, surface/n/x, surface/n/y, + surface/n/z, coordination, cv, shift/v/x, + shift/v/y, shift/v/z, energy, temperature, heatflow, + conductivity, cv, viscosity, pressure, + status, rho, grad/v/xx, grad/v/xy, grad/v/xz, + grad/v/yx, grad/v/yy/, grad/v/yz, grad/v/zx, + grad/v/zy, grad/v/zz .. parsed-literal:: @@ -30,16 +32,19 @@ Syntax *surface* = atom surface status *surface/r* = atom distance from the surface *surface/divr* = divergence of position at atom position - *surface/nx, surface/ny, surface/nz* = surface normal vector + *surface/n/\** = surface normal vector *coordination* = coordination number - *shift/vx, shift/vy, shift/vz* = atom shifting velocity + *shift/v/\** = atom shifting velocity + *energy* = atom energy *temperature* = atom temperature *heatflow* = atom heat flow *conductivity* = atom conductivity + *cv* = atom specific heat *viscosity* = atom viscosity *pressure* = atom pressure *status* = atom full status *rho* = atom density + *grad/v/\** = atom velocity gradient Examples """""""" diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index 25e171a1b9..c61d1939db 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -14,7 +14,8 @@ Syntax * rheo = style name of this fix command * cut = *quintic* or *RK0* or *RK1* or *RK2* * zero or more keyword/value pairs may be appended to args -* keyword = *shift* or *thermal* or *surface/detection* or *interface/reconstruction* or *rho/sum* or *density* or *sound/squared* +* keyword = *shift* or *thermal* or *surface/detection* or *interface/reconstruction* or + *rho/sum* or *density* or *sound/squared* .. parsed-literal:: diff --git a/doc/src/fix_rheo_pressure.rst b/doc/src/fix_rheo_pressure.rst index ceb402501a..d31c305c20 100644 --- a/doc/src/fix_rheo_pressure.rst +++ b/doc/src/fix_rheo_pressure.rst @@ -8,11 +8,12 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo/pressure pstyle args + fix ID group-ID rheo/pressure style args * ID, group-ID are documented in :doc:`fix ` command * rheo/pressure = style name of this fix command -* pstyle = *linear* or *taitwater* or *cubic* +* types = lists of types (see below) +* style = *linear* or *taitwater* or *cubic* .. parsed-literal:: @@ -25,8 +26,8 @@ Examples .. code-block:: LAMMPS - fix 1 all rheo/pressure linear - fix 1 all rheo/pressure cubic 10.0 + fix 1 all rheo/pressure * linear + fix 1 all rheo/pressure 1 linear 2 cubic 10.0 Description """"""""""" diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst index 01b4820a39..b73aeb248e 100644 --- a/doc/src/fix_rheo_thermal.rst +++ b/doc/src/fix_rheo_thermal.rst @@ -8,42 +8,59 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo/thermal keyword values ... + fix ID group-ID rheo/thermal attribute values ... * ID, group-ID are documented in :doc:`fix ` command -* rheo/viscosity = style name of this fix command +* rheo/thermal = style name of this fix command * one or more attributes may be appended -* attribute = *conductivity* or *specific/heat* or *Tfreeze* +* attribute = *conductivity* or *specific/heat* or *latent/heat* or *Tfreeze* or *react* .. parsed-literal:: - *conductivity* args = style param - style = *constant* or *type* + *conductivity* args = types style args + types = lists of types (see below) + style = *constant* *constant* arg = conductivity (power/temperature) - *type* args = list of conductivity values, one per type (power/temperature) - *specific/heat* args = style param - style = *constant* or *type* + *specific/heat* args = types style args + types = lists of types (see below) + style = *constant* *constant* arg = specific heat (energy/(mass*temperature)) - *type* args = list of specific heat values, one per atom type (energy/(mass*temperature)) - *Tfreeze* args = style param - style = *constant* or *type* + *latent/heat* args = types style args + types = lists of types (see below) + style = *constant* + *constant* arg = latent heat (energy/mass) + *Tfreeze* args = types style args + types = lists of types (see below) + style = *constant* *constant* arg = freezing temperature (temperature) - *type* args = list of freezing temperature values, one per type (temperature) + *react* args = cut type + cut = maximum bond distance + type = bond type Examples """""""" .. code-block:: LAMMPS - fix 1 all rheo/thermal conductivity constant 1.0 specific/heat constant 1.0 Tfreeze constant 1.0 - fix 1 all rheo/pressure conductivity constant 1.0 specific/heat type 1.0 2.0 + fix 1 all rheo/thermal conductivity * constant 1.0 specific/heat * constant 1.0 Tfreeze * constant 1.0 + fix 1 all rheo/pressure conductivity 1*2 constant 1.0 conductivity 3*4 constant 2.0 specific/heat * constant 1.0 Description """"""""""" This fix... -While the *Tfreeze* keyword is optional, the *conducitivity* and +Each list consists of a series of type +ranges separated by commas. The range can be specified as a +single numeric value, or a wildcard asterisk can be used to specify a range +of values. This takes the form "\*" or "\*n" or "n\*" or "m\*n". For +example, if M = the number of atom types, then an asterisk with no numeric +values means all types from 1 to M. A leading asterisk means all types +from 1 to n (inclusive). A trailing asterisk means all types from n to M +(inclusive). A middle asterisk means all types from m to n (inclusive). +Note that all atom types must be included in exactly one of the N collections. + +While the *Tfreeze* keyword is optional, the *conductivity* and *specific/heat* keywords are mandatory. Multiple instances of this fix may be defined to apply different diff --git a/doc/src/fix_rheo_viscosity.rst b/doc/src/fix_rheo_viscosity.rst index 278c621216..379b002de1 100644 --- a/doc/src/fix_rheo_viscosity.rst +++ b/doc/src/fix_rheo_viscosity.rst @@ -8,16 +8,16 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo/viscosity vstyle args + fix ID group-ID rheo/viscosity types style args ... * ID, group-ID are documented in :doc:`fix ` command * rheo/viscosity = style name of this fix command -* vstyle = *constant* or *type* or *power* +* types = lists of types (see below) +* style = *constant* or *power* .. parsed-literal:: - *constant* arg = viscosity (mass/(length*time)) - *type* args = list of viscosity values, one per atom type (mass/(length*time)) + *constant* args = viscosity (mass/(length*time)) *power* args = *eta* *gd0* *K* *npow* *tau0* *eta* = (units) *gd0* = (units) @@ -30,8 +30,8 @@ Examples .. code-block:: LAMMPS - fix 1 all rheo/viscosity constant 1.0 - fix 1 all rheo/viscosity power 0.1 1e-2 0.5 0.01 + fix 1 all rheo/viscosity * constant 1.0 + fix 1 all rheo/viscosity 1 constant 1.0 2 power 0.1 1e-2 0.5 0.01 Description """"""""""" diff --git a/doc/src/pair_rheo.rst b/doc/src/pair_rheo.rst index d168f79785..6f706a77ac 100644 --- a/doc/src/pair_rheo.rst +++ b/doc/src/pair_rheo.rst @@ -8,16 +8,17 @@ Syntax .. code-block:: LAMMPS - pair_style rheo cut keyword values + pair_style rheo cutoff keyword values -* cut = *quintic* or *CRK0* or *CRK1* or *CRK2* +* cutoff = global cutoff for kernel (distance units) * zero or more keyword/value pairs may be appended to args -* keyword = *rho/damp* or *artificial/visc* +* keyword = *rho/damp* or *artificial/visc* or *harmonic/means* .. parsed-literal:: *rho/damp* args = density damping prefactor :math:`\xi` (units?) *artificial/visc* args = artificial viscosity prefactor :math:`\zeta` (units?) + *harmonic/means* args = none Examples """""""" @@ -67,4 +68,4 @@ Related commands Default """"""" -No density damping or artificial viscous forces are calculated. +Density damping and artificial viscous forces are not calculated. Arithmetic means are used for mixing particle properties. diff --git a/doc/src/pair_rheo_react.rst b/doc/src/pair_rheo_react.rst new file mode 100644 index 0000000000..6e7eb49c9d --- /dev/null +++ b/doc/src/pair_rheo_react.rst @@ -0,0 +1,67 @@ +.. index:: pair_style rheo/react + +pair_style rheo/react command +========================= + +Syntax +"""""" + +.. code-block:: LAMMPS + + pair_style rheo/react + +Examples +"""""""" + +.. code-block:: LAMMPS + + pair_style rheo/react + pair_coeff * * 1.0 1.5 1.0 0.05 1.0 100 2.0 + +Description +""""""""""" + +pair style... + +The following coefficients must be defined for each pair of atom types +via the :doc:`pair_coeff ` command as in the example above, +or in the data file or restart files read by the +:doc:`read_data ` or :doc:`read_restart ` +commands, or by mixing as described below: + +* :math:`k` (force/distance units) +* :math:`r_max` (distance units) +* :math:`\epsilon` (unitless) +* :math:`\gamma` (force/velocity units) +* :math:`t_form` (time units) +* :math:`r_from_surface` (distance units) + +---------- + +Mixing, shift, table, tail correction, restart, rRESPA info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +This style does not support the :doc:`pair_modify ` +shift, table, and tail options. + +This style does not write information to :doc:`binary restart files `. Thus, you need to re-specify the pair_style and +pair_coeff commands in an input script that reads a restart file. + +This style can only be used via the *pair* keyword of the :doc:`run_style respa ` command. It does not support the *inner*, *middle*, *outer* keywords. + +Restrictions +"""""""""""" + +This fix is part of the RHEO 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 rheo `, +:doc:`compute rheo/property/atom ` + +Default +""""""" + +none diff --git a/doc/src/pair_rheo_solid.rst b/doc/src/pair_rheo_solid.rst new file mode 100644 index 0000000000..b6ff6d809d --- /dev/null +++ b/doc/src/pair_rheo_solid.rst @@ -0,0 +1,58 @@ +.. index:: pair_style rheo/solid + +pair_style rheo/solid command +========================= + +Syntax +"""""" + +.. code-block:: LAMMPS + + pair_style rheo/solid + +Examples +"""""""" + +.. code-block:: LAMMPS + + pair_style rheo/solid + pair_coeff * * 1.0 1.5 1.0 + +Description +""""""""""" + +pair style... + +* :math:`k` (force/distance units) +* :math:`\sigma` (distance units) +* :math:`\gamma` (force/velocity units) + +---------- + +Mixing, shift, table, tail correction, restart, rRESPA info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +This style does not support the :doc:`pair_modify ` +shift, table, and tail options. + +This style does not write information to :doc:`binary restart files `. Thus, you need to re-specify the pair_style and +pair_coeff commands in an input script that reads a restart file. + +This style can only be used via the *pair* keyword of the :doc:`run_style respa ` command. It does not support the *inner*, *middle*, *outer* keywords. + +Restrictions +"""""""""""" + +This fix is part of the RHEO 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 rheo `, +:doc:`pair bpm/spring `, + +Default +""""""" + +none From 574ccc64ebb03a3a13b648a05b8f3e637b0eb7e9 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 23 Jan 2024 14:04:10 -0700 Subject: [PATCH 069/104] Fixing bugs for solid particles --- src/RHEO/pair_rheo_solid.cpp | 6 ++---- src/set.cpp | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/RHEO/pair_rheo_solid.cpp b/src/RHEO/pair_rheo_solid.cpp index 1068e9b329..d0a68d5230 100644 --- a/src/RHEO/pair_rheo_solid.cpp +++ b/src/RHEO/pair_rheo_solid.cpp @@ -96,14 +96,12 @@ void PairRHEOSolid::compute(int eflag, int vflag) for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; - if (!(status[j] & STATUS_SOLID)) continue; - factor_lj = special_lj[sbmask(j)]; - if (factor_lj == 0) continue; - j &= NEIGHMASK; + if (!(status[j] & STATUS_SOLID)) continue; + delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; diff --git a/src/set.cpp b/src/set.cpp index 735d3bc831..cf2a053fab 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -923,7 +923,7 @@ void Set::set(int keyword) } else if (keyword == RHEO_STATUS) { - if (ivalue != 0 && ivalue != 2) + if (ivalue != 0 && ivalue != 1) error->one(FLERR,"Invalid value {} in set command for rheo/status", ivalue); atom->status[i] = ivalue; } From 70ea1dd3525e1decbb1430b65267a2d71a2abffa Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 23 Jan 2024 14:58:31 -0700 Subject: [PATCH 070/104] Refreshing no shift flag for solid particles --- src/RHEO/fix_rheo.cpp | 6 ++++++ src/RHEO/fix_rheo_thermal.cpp | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index beba940174..3a999e12dd 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -422,6 +422,12 @@ void FixRHEO::pre_force(int /*vflag*/) if (mask[i] & groupbit) status[i] &= OPTIONSMASK; + // Reinstate temporary options + for (int i = 0; i < nall; i++) + if (mask[i] & groupbit) + if (status[i] & STATUS_SOLID) + status[i] |= STATUS_NO_SHIFT; + // Calculate surfaces, update status if (surface_flag) { compute_surface->compute_peratom(); diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 7b61b9821e..635cf78c85 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -374,7 +374,6 @@ void FixRHEOThermal::post_integrate() } } } - } int n_melt_all, n_freeze_all; @@ -558,7 +557,7 @@ void FixRHEOThermal::create_bonds() for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; - j &= SPECIALMASK; + j &= NEIGHMASK; if (!(status[j] & STATUS_SOLID)) continue; if (!(status[i] & STATUS_FREEZING) && !(status[j] & STATUS_FREEZING)) continue; From b3de75da971382b79d8c5b585bb58ace365d48ee Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 23 Feb 2024 13:26:28 -0700 Subject: [PATCH 071/104] Cleaning up math, fixing tension bug, patching bond creation --- src/RHEO/compute_rheo_interface.cpp | 54 ++++++++++--------- src/RHEO/fix_rheo.cpp | 6 --- src/RHEO/fix_rheo_tension.cpp | 2 +- src/RHEO/fix_rheo_thermal.cpp | 80 +++++++++++++++++++++++------ 4 files changed, 90 insertions(+), 52 deletions(-) diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index 001f15a472..3cb2fcf058 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -26,6 +26,7 @@ #include "force.h" #include "fix_rheo.h" #include "fix_rheo_pressure.h" +#include "math_extra.h" #include "memory.h" #include "modify.h" #include "neighbor.h" @@ -36,6 +37,7 @@ using namespace LAMMPS_NS; using namespace RHEO_NS; +using namespace MathExtra; static constexpr double EPSILON = 1e-1; @@ -107,8 +109,8 @@ void ComputeRHEOInterface::init_list(int /*id*/, NeighList *ptr) void ComputeRHEOInterface::compute_peratom() { - int i, j, ii, jj, jnum, itype, jtype, fluidi, fluidj, status_match; - double xtmp, ytmp, ztmp, delx, dely, delz, rsq, w, dot; + int a, i, j, ii, jj, jnum, itype, jtype, fluidi, fluidj, status_match; + double xtmp, ytmp, ztmp, rsq, w, dot, dx[3]; int inum, *ilist, *jlist, *numneigh, **firstneigh; int nlocal = atom->nlocal; @@ -153,15 +155,15 @@ void ComputeRHEOInterface::compute_peratom() 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; + dx[0] = xtmp - x[j][0]; + dx[1] = ytmp - x[j][1]; + dx[2] = ztmp - x[j][2]; + rsq = lensq3(dx); if (rsq < cutsq) { jtype = type[j]; fluidj = !(status[j] & PHASECHECK); - w = compute_kernel->calc_w_quintic(i, j, delx, dely, delz, sqrt(rsq)); + w = compute_kernel->calc_w_quintic(i, j, dx[0], dx[1], dx[2], sqrt(rsq)); status_match = 0; norm[i] += w; @@ -172,9 +174,9 @@ void ComputeRHEOInterface::compute_peratom() chi[i] += w; } else { if (!fluidi) { - dot = (-fp_store[j][0] + fp_store[i][0]) * delx; - dot += (-fp_store[j][1] + fp_store[i][1]) * dely; - dot += (-fp_store[j][2] + fp_store[i][2]) * delz; + dot = 0; + for (a = 0; a < 3; a++) + dot += (-fp_store[j][a] + fp_store[i][a]) * dx[a]; rho[i] += w * (fix_pressure->calc_pressure(rho[j], jtype) - rho[j] * dot); normwf[i] += w; @@ -187,9 +189,9 @@ void ComputeRHEOInterface::compute_peratom() chi[j] += w; } else { if (!fluidj) { - dot = (-fp_store[i][0] + fp_store[j][0]) * delx; - dot += (-fp_store[i][1] + fp_store[j][1]) * dely; - dot += (-fp_store[i][2] + fp_store[j][2]) * delz; + dot = 0; + for (a = 0; a < 3; a++) + dot += (-fp_store[i][a] + fp_store[j][a]) * dx[a]; rho[j] += w * (fix_pressure->calc_pressure(rho[i], itype) + rho[i] * dot); normwf[j] += w; @@ -225,7 +227,7 @@ void ComputeRHEOInterface::compute_peratom() int ComputeRHEOInterface::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { - int i,j,k,m; + int i, j, k, m; m = 0; double *rho = atom->rho; @@ -267,7 +269,7 @@ void ComputeRHEOInterface::unpack_forward_comm(int n, int first, double *buf) int ComputeRHEOInterface::pack_reverse_comm(int n, int first, double *buf) { - int i,k,m,last; + int i, k, m, last; double *rho = atom->rho; m = 0; @@ -285,7 +287,7 @@ int ComputeRHEOInterface::pack_reverse_comm(int n, int first, double *buf) void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf) { - int i,k,j,m; + int i, k, j, m; double *rho = atom->rho; int *status = atom->status; m = 0; @@ -350,23 +352,19 @@ void ComputeRHEOInterface::store_forces() for (const auto &fix : fixlist) { for (int i = 0; i < atom->nlocal; i++) { minv = 1.0 / mass[type[i]]; - if (mask[i] & fix->groupbit) { - fp_store[i][0] = f[i][0] * minv; - fp_store[i][1] = f[i][1] * minv; - fp_store[i][2] = f[i][2] * minv; - } else { - fp_store[i][0] = (f[i][0] - fp_store[i][0]) * minv; - fp_store[i][1] = (f[i][1] - fp_store[i][1]) * minv; - fp_store[i][2] = (f[i][2] - fp_store[i][2]) * minv; - } + if (mask[i] & fix->groupbit) + for (int a = 0; a < 3; a++) + fp_store[i][a] = f[i][a] * minv; + else + for (int a = 0; a < 3; a++) + fp_store[i][a] = (f[i][a] - fp_store[i][a]) * minv; } } } else { for (int i = 0; i < atom->nlocal; i++) { minv = 1.0 / mass[type[i]]; - fp_store[i][0] = (f[i][0] - fp_store[i][0]) * minv; - fp_store[i][1] = (f[i][1] - fp_store[i][1]) * minv; - fp_store[i][2] = (f[i][2] - fp_store[i][2]) * minv; + for (int a = 0; a < 3; a++) + fp_store[i][a] = (f[i][a] - fp_store[i][a]) * minv; } } diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 3a999e12dd..beba940174 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -422,12 +422,6 @@ void FixRHEO::pre_force(int /*vflag*/) if (mask[i] & groupbit) status[i] &= OPTIONSMASK; - // Reinstate temporary options - for (int i = 0; i < nall; i++) - if (mask[i] & groupbit) - if (status[i] & STATUS_SOLID) - status[i] |= STATUS_NO_SHIFT; - // Calculate surfaces, update status if (surface_flag) { compute_surface->compute_peratom(); diff --git a/src/RHEO/fix_rheo_tension.cpp b/src/RHEO/fix_rheo_tension.cpp index 8d00c8b988..388b574365 100644 --- a/src/RHEO/fix_rheo_tension.cpp +++ b/src/RHEO/fix_rheo_tension.cpp @@ -467,7 +467,7 @@ void FixRHEOTension::pre_force(int vflag) if (wsame[i] < wmin) continue; - weight = MAX(1.0, wsame[i] * wmin_inv); + weight = MIN(1.0, wsame[i] * wmin_inv); //MAX -> MIN 2/14/24 itype = type[i]; if (norm[i] != 0) diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 635cf78c85..0640dd6827 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -423,6 +423,7 @@ void FixRHEOThermal::pre_force(int /*vflag*/) double *energy = atom->esph; double *temperature = atom->temperature; int *type = atom->type; + int *status = atom->status; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; @@ -444,6 +445,11 @@ void FixRHEOThermal::pre_force(int /*vflag*/) } } } + + // Add temporary options, wiped by preceding fix rheo preforce + for (int i = 0; i < nall; i++) + if (status[i] & STATUS_SOLID) + status[i] |= STATUS_NO_SHIFT; } /* ---------------------------------------------------------------------- */ @@ -481,39 +487,79 @@ void FixRHEOThermal::break_bonds() tagint **bond_atom = atom->bond_atom; int *num_bond = atom->num_bond; - int nlocal = atom->nlocal; + int **bondlist = neighbor->bondlist; + int nbondlist = neighbor->nbondlist; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + + // Rapidly delete all bonds for local atoms that melt (no shifting) for (int i = 0; i < nlocal; i++) { + if (!(status[i] & STATUS_MELTING)) continue; for (m = 0; m < num_bond[i]; m++) { j = atom->map(bond_atom[i][m]); - if (!(status[i] & STATUS_MELTING) && !(status[j] & STATUS_MELTING)) continue; + bond_type[i][m] = 0; if (n_histories > 0) for (auto &ihistory: histories) - dynamic_cast(ihistory)->delete_history(i, num_bond[i] - 1); + dynamic_cast(ihistory)->delete_history(i, m); - if (fix_update_special_bonds) fix_update_special_bonds->add_broken_bond(i, j); + if (fix_update_special_bonds) + fix_update_special_bonds->add_broken_bond(i, j); + } + num_bond[i] = 0; + } - // For non-melting neighbors, selectively delete bond if necessary - if (j >= nlocal || (status[j] & STATUS_MELTING)) continue; - for (n = 0; n < num_bond[j]; n++) { - if (bond_atom[j][n] == tag[i]) { - bond_type[j][n] = 0; - nmax = num_bond[j] - 1; - bond_type[j][n] = bond_type[j][nmax]; - bond_atom[j][n] = bond_atom[j][nmax]; - if (n_histories > 0) { + // Update bond list and break solid-melted bonds + for (n = 0; n < nbondlist; n++) { + + // skip bond if already broken + if (bondlist[n][2] <= 0) continue; + i = bondlist[n][0]; + j = bondlist[n][1]; + + if (!(status[i] & STATUS_MELTING) && !(status[j] & STATUS_MELTING)) continue; + + bondlist[n][2] = 0; + + // Delete bonds for non-melted local atoms (shifting) + if (i < nlocal) { + for (m = 0; m < num_bond[i]; m++) { + if (bond_atom[i][m] == tag[j]) { + nmax = num_bond[i] - 1; + bond_type[i][m] = bond_type[i][nmax]; + bond_atom[i][m] = bond_atom[i][nmax]; + if (n_histories > 0) for (auto &ihistory: histories) { - dynamic_cast(ihistory)->shift_history(j, n, nmax); - dynamic_cast(ihistory)->delete_history(j, nmax); + auto fix_bond_history = dynamic_cast (ihistory); + fix_bond_history->shift_history(i, m, nmax); + fix_bond_history->delete_history(i, nmax); } - } + bond_type[i][nmax] = 0; + num_bond[i]--; + break; + } + } + } + + if (j < nlocal) { + for (m = 0; m < num_bond[j]; m++) { + if (bond_atom[j][m] == tag[i]) { + nmax = num_bond[j] - 1; + bond_type[j][m] = bond_type[j][nmax]; + bond_atom[j][m] = bond_atom[j][nmax]; + if (n_histories > 0) + for (auto &ihistory: histories) { + auto fix_bond_history = dynamic_cast (ihistory); + fix_bond_history->shift_history(j, m, nmax); + fix_bond_history->delete_history(j, nmax); + } + bond_type[j][nmax] = 0; num_bond[j]--; break; } } } - num_bond[i] = 0; } } From 010a4c076bf72e5e546d7e9ffc11a62bbaa1b2bb Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 28 Mar 2024 11:31:21 -0600 Subject: [PATCH 072/104] Prototyping oxidation --- doc/src/Commands_bond.rst | 1 + doc/src/Commands_compute.rst | 1 + doc/src/Commands_fix.rst | 5 + doc/src/Commands_pair.rst | 2 + doc/src/bond_rheo_shell.rst | 226 +++++++++++++ doc/src/fix_rheo_oxidation.rst | 81 +++++ src/BPM/bond_bpm.cpp | 4 +- src/RHEO/bond_rheo_shell.cpp | 507 ++++++++++++++++++++++++++++ src/RHEO/bond_rheo_shell.h | 55 +++ src/RHEO/compute_rheo_interface.cpp | 3 +- src/RHEO/fix_rheo_oxidation.cpp | 190 +++++++++++ src/RHEO/fix_rheo_oxidation.h | 49 +++ src/RHEO/fix_rheo_thermal.cpp | 11 + src/bond_hybrid.cpp | 5 + 14 files changed, 1137 insertions(+), 3 deletions(-) create mode 100644 doc/src/bond_rheo_shell.rst create mode 100644 doc/src/fix_rheo_oxidation.rst create mode 100644 src/RHEO/bond_rheo_shell.cpp create mode 100644 src/RHEO/bond_rheo_shell.h create mode 100644 src/RHEO/fix_rheo_oxidation.cpp create mode 100644 src/RHEO/fix_rheo_oxidation.h diff --git a/doc/src/Commands_bond.rst b/doc/src/Commands_bond.rst index aaf706b5df..ee03b7e245 100644 --- a/doc/src/Commands_bond.rst +++ b/doc/src/Commands_bond.rst @@ -54,6 +54,7 @@ OPT. * :doc:`oxdna2/fene ` * :doc:`oxrna2/fene ` * :doc:`quartic (o) ` + * :doc:`rheo/shell ` * :doc:`special ` * :doc:`table (o) ` diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index 0352ad5374..394a5bee3a 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -122,6 +122,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`reduce ` * :doc:`reduce/chunk ` * :doc:`reduce/region ` + * :doc:`rheo/property/atom ` * :doc:`rigid/local ` * :doc:`saed ` * :doc:`slcsa/atom ` diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index e89e302673..7053c4809a 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -203,6 +203,11 @@ OPT. * :doc:`reaxff/species (k) ` * :doc:`recenter ` * :doc:`restrain ` + * :doc:`rheo ` + * :doc:`rheo/oxidation ` + * :doc:`rheo/pressure ` + * :doc:`rheo/thermal ` + * :doc:`rheo/viscosity ` * :doc:`rhok ` * :doc:`rigid (o) ` * :doc:`rigid/meso ` diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index e7761e7bee..9b56e92819 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -257,6 +257,8 @@ OPT. * :doc:`reaxff (ko) ` * :doc:`rebo (io) ` * :doc:`resquared (go) ` + * :doc:`rheo ` + * :doc:`rheo/solid ` * :doc:`saip/metal (t) ` * :doc:`sdpd/taitwater/isothermal ` * :doc:`smatb ` diff --git a/doc/src/bond_rheo_shell.rst b/doc/src/bond_rheo_shell.rst new file mode 100644 index 0000000000..7f6bab1eab --- /dev/null +++ b/doc/src/bond_rheo_shell.rst @@ -0,0 +1,226 @@ +.. index:: bond_style rheo/shell + +bond_style rheo/shell command +============================= + +Syntax +"""""" + +.. code-block:: LAMMPS + + bond_style rheo/shell keyword value attribute1 attribute2 ... + +* optional keyword = *overlay/pair* or *store/local* or *smooth* or *break* + + .. parsed-literal:: + + *store/local* values = fix_ID N attributes ... + * fix_ID = ID of associated internal fix to store data + * N = prepare data for output every this many timesteps + * attributes = zero or more of the below attributes may be appended + + *id1, id2* = IDs of 2 atoms in the bond + *time* = the timestep the bond broke + *x, y, z* = the center of mass position of the 2 atoms when the bond broke (distance units) + *x/ref, y/ref, z/ref* = the initial center of mass position of the 2 atoms (distance units) + + *overlay/pair* value = *yes* or *no* + bonded particles will still interact with pair forces + + *smooth* value = *yes* or *no* + smooths bond forces near the breaking point + + *normalize* value = *yes* or *no* + normalizes bond forces by the reference length + + *break* value = *yes* or *no* + indicates whether bonds break during a run + +Examples +"""""""" + +.. code-block:: LAMMPS + + bond_style bpm/spring + bond_coeff 1 1.0 0.05 0.1 + + bond_style bpm/spring myfix 1000 time id1 id2 + dump 1 all local 1000 dump.broken f_myfix[1] f_myfix[2] f_myfix[3] + dump_modify 1 write_header no + +Description +""""""""""" + +.. versionadded:: 4May2022 + +The *bpm/spring* bond style computes forces based on +deviations from the initial reference state of the two atoms. The +reference state is stored by each bond when it is first computed in +the setup of a run. Data is then preserved across run commands and is +written to :doc:`binary restart files ` such that restarting +the system will not reset the reference state of a bond. + +This bond style only applies central-body forces which conserve the +translational and rotational degrees of freedom of a bonded set of +particles based on a model described by Clemmer and Robbins +:ref:`(Clemmer) `. The force has a magnitude of + +.. math:: + + F = k (r - r_0) w + +where :math:`k` is a stiffness, :math:`r` is the current distance +and :math:`r_0` is the initial distance between the two particles, and +:math:`w` is an optional smoothing factor discussed below. Bonds will +break at a strain of :math:`\epsilon_c`. This is done by setting +the bond type to 0 such that forces are no longer computed. + +An additional damping force is applied to the bonded +particles. This forces is proportional to the difference in the +normal velocity of particles using a similar construction as +dissipative particle dynamics :ref:`(Groot) `: + +.. math:: + + F_D = - \gamma w (\hat{r} \bullet \vec{v}) + +where :math:`\gamma` is the damping strength, :math:`\hat{r}` is the +radial normal vector, and :math:`\vec{v}` is the velocity difference +between the two particles. + +The smoothing factor :math:`w` can be added or removed by setting the +*smooth* keyword to *yes* or *no*, respectively. It is constructed such +that forces smoothly go to zero, avoiding discontinuities, as bonds +approach the critical strain + +.. math:: + + w = 1.0 - \left( \frac{r - r_0}{r_0 \epsilon_c} \right)^8 . + +The following coefficients must be defined for each bond type via the +:doc:`bond_coeff ` command as in the example above, or in +the data file or restart files read by the :doc:`read_data +` or :doc:`read_restart ` commands: + +* :math:`k` (force/distance units) +* :math:`\epsilon_c` (unit less) +* :math:`\gamma` (force/velocity units) + +If the *normalize* keyword is set to *yes*, the elastic bond force will be +normalized by :math:`r_0` such that :math:`k` must be given in force units. + +By default, pair forces are not calculated between bonded particles. +Pair forces can alternatively be overlaid on top of bond forces by setting +the *overlay/pair* keyword to *yes*. These settings require specific +:doc:`special_bonds ` settings described in the +restrictions. Further details can be found in the :doc:`how to ` +page on BPMs. + +.. versionadded:: 28Mar2023 + +If the *break* keyword is set to *no*, LAMMPS assumes bonds should not break +during a simulation run. This will prevent some unnecessary calculation. +However, if a bond reaches a strain greater than :math:`\epsilon_c`, +it will trigger an error. + +If the *store/local* keyword is used, an internal fix will track bonds that +break during the simulation. Whenever a bond breaks, data is processed +and transferred to an internal fix labeled *fix_ID*. This allows the +local data to be accessed by other LAMMPS commands. Following this optional +keyword, a list of one or more attributes is specified. These include the +IDs of the two atoms in the bond. The other attributes for the two atoms +include the timestep during which the bond broke and the current/initial +center of mass position of the two atoms. + +Data is continuously accumulated over intervals of *N* +timesteps. At the end of each interval, all of the saved accumulated +data is deleted to make room for new data. Individual datum may +therefore persist anywhere between *1* to *N* timesteps depending on +when they are saved. This data can be accessed using the *fix_ID* and a +:doc:`dump local ` command. To ensure all data is output, +the dump frequency should correspond to the same interval of *N* +timesteps. A dump frequency of an integer multiple of *N* can be used +to regularly output a sample of the accumulated data. + +Note that when unbroken bonds are dumped to a file via the +:doc:`dump local ` command, bonds with type 0 (broken bonds) +are not included. +The :doc:`delete_bonds ` command can also be used to +query the status of broken bonds or permanently delete them, e.g.: + +.. code-block:: LAMMPS + + delete_bonds all stats + delete_bonds all bond 0 remove + +---------- + +Restart and other info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +This bond style writes the reference state of each bond to +:doc:`binary restart files `. Loading a restart +file will properly restore bonds. However, the reference state is NOT +written to data files. Therefore reading a data file will not +restore bonds and will cause their reference states to be redefined. + +If the *store/local* option is used, an internal fix will calculate +a local vector or local array depending on the number of input values. +The length of the vector or number of rows in the array is the number +of recorded, broken bonds. If a single input is specified, a local +vector is produced. If two or more inputs are specified, a local array +is produced where the number of columns = the number of inputs. The +vector or array can be accessed by any command that uses local values +from a compute as input. See the :doc:`Howto output ` page +for an overview of LAMMPS output options. + +The vector or array will be floating point values that correspond to +the specified attribute. + +The single() function of this bond style returns 0.0 for the energy +of a bonded interaction, since energy is not conserved in these +dissipative potentials. The single() function also calculates an +extra bond quantity, the initial distance :math:`r_0`. This +extra quantity can be accessed by the +:doc:`compute bond/local ` command as *b1*\ . + +Restrictions +"""""""""""" + +This bond style is part of the BPM package. It is only enabled if +LAMMPS was built with that package. See the :doc:`Build package +` page for more info. + +By default if pair interactions between bonded atoms are to be disabled, +this bond style requires setting + +.. code-block:: LAMMPS + + special_bonds lj 0 1 1 coul 1 1 1 + +and :doc:`newton ` must be set to bond off. If the *overlay/pair* +keyword is set to *yes*, this bond style alternatively requires setting + +.. code-block:: LAMMPS + + special_bonds lj/coul 1 1 1 + +Related commands +"""""""""""""""" + +:doc:`bond_coeff `, :doc:`pair bpm/spring ` + +Default +""""""" + +The option defaults are *overlay/pair* = *no*, *smooth* = *yes*, *normalize* = *no*, and *break* = *yes* + +---------- + +.. _fragment-Clemmer: + +**(Clemmer)** Clemmer and Robbins, Phys. Rev. Lett. (2022). + +.. _Groot4: + +**(Groot)** Groot and Warren, J Chem Phys, 107, 4423-35 (1997). diff --git a/doc/src/fix_rheo_oxidation.rst b/doc/src/fix_rheo_oxidation.rst new file mode 100644 index 0000000000..a747ec582f --- /dev/null +++ b/doc/src/fix_rheo_oxidation.rst @@ -0,0 +1,81 @@ +.. index:: fix rheo/oxidation + +fix rheo/oxidation command +========================== + +Syntax +"""""" + +.. parsed-literal:: + + fix ID group-ID rheo/oxidation cut btype + +* ID, group-ID are documented in :doc:`fix ` command +* rheo/oxidation = style name of this fix command +* cut = maximum bond length (distance units) +* btype = type of bonds created + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all rheo/oxidation 1.5 2 + +Description +""""""""""" + +This fix... + +Each list consists of a series of type +ranges separated by commas. The range can be specified as a +single numeric value, or a wildcard asterisk can be used to specify a range +of values. This takes the form "\*" or "\*n" or "n\*" or "m\*n". For +example, if M = the number of atom types, then an asterisk with no numeric +values means all types from 1 to M. A leading asterisk means all types +from 1 to n (inclusive). A trailing asterisk means all types from n to M +(inclusive). A middle asterisk means all types from m to n (inclusive). +Note that all atom types must be included in exactly one of the N collections. + +While the *Tfreeze* keyword is optional, the *conductivity* and +*specific/heat* keywords are mandatory. + +Multiple instances of this fix may be defined to apply different +properties to different groups. However, the union of fix groups +across all instances of fix rheo/thermal must cover all atoms. +If there are multiple instances of this fix, any intersections in +the fix groups will lead to incorrect thermal integration. + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +are relevant to this fix. No global or per-atom quantities are stored +by this fix for access by various :doc:`output commands `. +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 fix must be used with an atom style that includes temperature, +heatflow, and conductivity such as atom_tyle rheo/thermal This fix +must be used in conjuction with :doc:`fix rheo ` with the +*thermal* setting. + +This fix is part of the RHEO 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 rheo `, +:doc:`fix rheo/viscosity `, +:doc:`fix rheo/pressure `, +:doc:`pair rheo `, +:doc:`compute rheo/property/atom ` + +Default +""""""" + +none diff --git a/src/BPM/bond_bpm.cpp b/src/BPM/bond_bpm.cpp index b484df7fab..34554497ad 100644 --- a/src/BPM/bond_bpm.cpp +++ b/src/BPM/bond_bpm.cpp @@ -50,10 +50,10 @@ BondBPM::BondBPM(LAMMPS *_lmp) : // this is so final order of Modify:fix will conform to input script // BondHistory technically only needs this if updateflag = 1 - id_fix_dummy = utils::strdup("BPM_DUMMY"); + id_fix_dummy = utils::strdup(fmt::format("BPM_DUMMY_{}", instance_total)); modify->add_fix(fmt::format("{} all DUMMY ", id_fix_dummy)); - id_fix_dummy2 = utils::strdup("BPM_DUMMY2"); + id_fix_dummy2 = utils::strdup(fmt::format("BPM_DUMMY2_{}", instance_total)); modify->add_fix(fmt::format("{} all DUMMY ", id_fix_dummy2)); } diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp new file mode 100644 index 0000000000..6a9f99d8b1 --- /dev/null +++ b/src/RHEO/bond_rheo_shell.cpp @@ -0,0 +1,507 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "bond_rheo_shell.h" + +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "error.h" +#include "fix_bond_history.h" +#include "fix_rheo.h" +#include "fix_store_local.h" +#include "force.h" +#include "memory.h" +#include "modify.h" +#include "neighbor.h" +#include "update.h" + +#include +#include + +#define EPSILON 1e-10 + +using namespace LAMMPS_NS; +using namespace RHEO_NS; + +/* ---------------------------------------------------------------------- */ + +BondRHEOShell::BondRHEOShell(LAMMPS *_lmp) : + BondBPM(_lmp), k(nullptr), ecrit(nullptr), gamma(nullptr) +{ + partial_flag = 1; + + tform = rmax = -1; + + single_extra = 1; + svector = new double[1]; +} + +/* ---------------------------------------------------------------------- */ + +BondRHEOShell::~BondRHEOShell() +{ + delete[] svector; + + if (allocated) { + memory->destroy(setflag); + memory->destroy(k); + memory->destroy(ecrit); + memory->destroy(gamma); + } +} + +/* ---------------------------------------------------------------------- + Store data for a single bond - if bond added after LAMMPS init (e.g. pour) +------------------------------------------------------------------------- */ + +double BondRHEOShell::store_bond(int n, int i, int j) +{ + double **bondstore = fix_bond_history->bondstore; + tagint *tag = atom->tag; + + bondstore[n][0] = 0.0; + bondstore[n][1] = 0.0; + + if (i < atom->nlocal) { + for (int m = 0; m < atom->num_bond[i]; m++) { + if (atom->bond_atom[i][m] == tag[j]) { + fix_bond_history->update_atom_value(i, m, 0, 0.0); + fix_bond_history->update_atom_value(i, m, 1, 0.0); + } + } + } + + if (j < atom->nlocal) { + for (int m = 0; m < atom->num_bond[j]; m++) { + if (atom->bond_atom[j][m] == tag[i]) { + fix_bond_history->update_atom_value(j, m, 0, 0.0); + fix_bond_history->update_atom_value(j, m, 1, 0.0); + } + } + } + + return 0.0; +} + +/* ---------------------------------------------------------------------- + Store data for all bonds called once +------------------------------------------------------------------------- */ + +void BondRHEOShell::store_data() +{ + int i, j, m, type; + int **bond_type = atom->bond_type; + + for (i = 0; i < atom->nlocal; i++) { + for (m = 0; m < atom->num_bond[i]; m++) { + type = bond_type[i][m]; + + //Skip if bond was turned off + if (type < 0) continue; + + // map to find index n + j = atom->map(atom->bond_atom[i][m]); + if (j == -1) error->one(FLERR, "Atom missing in BPM bond"); + + fix_bond_history->update_atom_value(i, m, 0, 0.0); + fix_bond_history->update_atom_value(i, m, 1, 0.0); + } + } + + fix_bond_history->post_neighbor(); +} + +/* ---------------------------------------------------------------------- */ + +void BondRHEOShell::compute(int eflag, int vflag) +{ + + if (!fix_bond_history->stored_flag) { + fix_bond_history->stored_flag = true; + store_data(); + } + + int i1, i2, itmp, n, type; + double delx, dely, delz, delvx, delvy, delvz; + double e, rsq, r, r0, rinv, dr, fbond, dot, t; + double dt = update->dt; + + ev_init(eflag, vflag); + + double **x = atom->x; + double **v = atom->v; + double **f = atom->f; + tagint *tag = atom->tag; + int *status = atom->status; + int **bondlist = neighbor->bondlist; + int nbondlist = neighbor->nbondlist; + int nlocal = atom->nlocal; + int newton_bond = force->newton_bond; + + double **bondstore = fix_bond_history->bondstore; + + for (n = 0; n < nbondlist; n++) { + + // skip bond if already broken + if (bondlist[n][2] <= 0) continue; + + i1 = bondlist[n][0]; + i2 = bondlist[n][1]; + type = bondlist[n][2]; + r0 = bondstore[n][0]; + t = bondstore[n][1]; + + // Ensure pair is always ordered to ensure numerical operations + // are identical to minimize the possibility that a bond straddling + // an mpi grid (newton off) doesn't break on one proc but not the other + if (tag[i2] < tag[i1]) { + itmp = i1; + i1 = i2; + i2 = itmp; + } + + // If bond hasn't been set - set timer to zero + if (t < EPSILON || std::isnan(t)) r0 = store_bond(n, i1, i2); + + delx = x[i1][0] - x[i2][0]; + dely = x[i1][1] - x[i2][1]; + delz = x[i1][2] - x[i2][2]; + + rsq = delx * delx + dely * dely + delz * delz; + r = sqrt(rsq); + + // Bond has not yet formed, check if in range + update timer + if (t < tform) { + + // Check if eligible + if (r > rmax || !(status[i1] & STATUS_SURFACE) || !(status[i2] & STATUS_SURFACE)) { + bondlist[n][2] = 0; + process_ineligibility(i1, i2); + continue; + } + + // Check ellapsed time + bondstore[n][1] += dt; + if (bondstore[n][1] >= tform) { + bondstore[n][0] = r; + r0 = r; + } else { + continue; + } + } + + e = (r - r0) / r0; + if (fabs(e) > ecrit[type]) { + bondlist[n][2] = 0; + process_broken(i1, i2); + continue; + } + + rinv = 1.0 / r; + dr = r - r0; + fbond = 2 * k[type] * (-dr + dr * dr * dr / (r0 * r0 * ecrit[type] * ecrit[type])); + + delvx = v[i1][0] - v[i2][0]; + delvy = v[i1][1] - v[i2][1]; + delvz = v[i1][2] - v[i2][2]; + dot = delx * delvx + dely * delvy + delz * delvz; + fbond -= gamma[type] * dot * rinv; + fbond *= rinv; + + if (newton_bond || i1 < nlocal) { + f[i1][0] += delx * fbond; + f[i1][1] += dely * fbond; + f[i1][2] += delz * fbond; + } + + if (newton_bond || i2 < nlocal) { + f[i2][0] -= delx * fbond; + f[i2][1] -= dely * fbond; + f[i2][2] -= delz * fbond; + } + + if (evflag) ev_tally(i1, i2, nlocal, newton_bond, 0.0, fbond, delx, dely, delz); + } +} + +/* ---------------------------------------------------------------------- */ + +void BondRHEOShell::allocate() +{ + allocated = 1; + const int np1 = atom->nbondtypes + 1; + + memory->create(k, np1, "bond:k"); + memory->create(ecrit, np1, "bond:ecrit"); + memory->create(gamma, np1, "bond:gamma"); + + memory->create(setflag, np1, "bond:setflag"); + for (int i = 1; i < np1; i++) setflag[i] = 0; +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more types +------------------------------------------------------------------------- */ + +void BondRHEOShell::coeff(int narg, char **arg) +{ + if (narg != 4) error->all(FLERR, "Incorrect args for bond coefficients"); + if (!allocated) allocate(); + + int ilo, ihi; + utils::bounds(FLERR, arg[0], 1, atom->nbondtypes, ilo, ihi, error); + + double k_one = utils::numeric(FLERR, arg[1], false, lmp); + double ecrit_one = utils::numeric(FLERR, arg[2], false, lmp); + double gamma_one = utils::numeric(FLERR, arg[3], false, lmp); + + int count = 0; + for (int i = ilo; i <= ihi; i++) { + k[i] = k_one; + ecrit[i] = ecrit_one; + gamma[i] = gamma_one; + setflag[i] = 1; + count++; + + if (1.0 + ecrit[i] > max_stretch) max_stretch = 1.0 + ecrit[i]; + } + + if (count == 0) error->all(FLERR, "Incorrect args for bond coefficients"); +} + +/* ---------------------------------------------------------------------- + check for correct settings and create fix +------------------------------------------------------------------------- */ + +void BondRHEOShell::init_style() +{ + if (comm->ghost_velocity == 0) + error->all(FLERR, "Bond rheo/shell requires ghost atoms store velocity"); + + if (!id_fix_bond_history) { + id_fix_bond_history = utils::strdup("HISTORY_RHEO_SHELL"); + fix_bond_history = dynamic_cast(modify->replace_fix( + id_fix_dummy2, fmt::format("{} all BOND_HISTORY 1 2", id_fix_bond_history), 1)); + delete[] id_fix_dummy2; + id_fix_dummy2 = nullptr; + } + + // Reproduce standard functions of BondBPM, removing special restrictions + // Since this bond is intended to be created by fix rheo/oxidation, it + // ignores special statuses + + if (id_fix_store_local) { + auto ifix = modify->get_fix_by_id(id_fix_store_local); + if (!ifix) error->all(FLERR, "Cannot find fix STORE/LOCAL id {}", id_fix_store_local); + if (strcmp(ifix->style, "STORE/LOCAL") != 0) + error->all(FLERR, "Incorrect fix style matched, not STORE/LOCAL: {}", ifix->style); + fix_store_local = dynamic_cast(ifix); + fix_store_local->nvalues = nvalues; + } + + id_fix_update = nullptr; + + if (force->angle || force->dihedral || force->improper) + error->all(FLERR, "Bond style rheo/shell cannot be used with 3,4-body interactions"); + if (atom->molecular == 2) + error->all(FLERR, "Bond style rheo/shell cannot be used with atom style template"); +} + +/* ---------------------------------------------------------------------- */ + +void BondRHEOShell::settings(int narg, char **arg) +{ + BondBPM::settings(narg, arg); + + int iarg; + for (std::size_t i = 0; i < leftover_iarg.size(); i++) { + iarg = leftover_iarg[i]; + if (strcmp(arg[iarg], "t/form") == 0) { + if (iarg + 1 > narg) error->all(FLERR, "Illegal bond rheo/shell command, missing option for t/form"); + tform = utils::numeric(FLERR, arg[iarg + 1], false, lmp); + if (tform < 0.0) error->all(FLERR, "Illegal bond rheo/shell value for t/form, {}", tform); + i += 1; + } else if (strcmp(arg[iarg], "r/max") == 0) { + if (iarg + 1 > narg) error->all(FLERR, "Illegal bond rheo/shell command, missing option for r/max"); + rmax = utils::numeric(FLERR, arg[iarg + 1], false, lmp); + if (rmax < 0.0) error->all(FLERR, "Illegal bond rheo/shell value for r/max, {}", rmax); + i += 1; + } else { + error->all(FLERR, "Illegal bond rheo/shell command, invalid argument {}", arg[iarg]); + } + } + + if (tform < 0.0) + error->all(FLERR, "Illegal bond rheo/shell command, must specify t/form"); + if (rmax < 0.0) + error->all(FLERR, "Illegal bond rheo/shell command, must specify r/max"); +} + + +/* ---------------------------------------------------------------------- + used to check bond communiction cutoff - not perfect, estimates based on local-local only +------------------------------------------------------------------------- */ + +double BondRHEOShell::equilibrium_distance(int /*i*/) +{ + // Divide out heuristic prefactor added in comm class + return max_stretch * rmax / 1.5; +} + +/* ---------------------------------------------------------------------- + proc 0 writes out coeffs to restart file +------------------------------------------------------------------------- */ + +void BondRHEOShell::write_restart(FILE *fp) +{ + BondBPM::write_restart(fp); + write_restart_settings(fp); + + fwrite(&k[1], sizeof(double), atom->nbondtypes, fp); + fwrite(&ecrit[1], sizeof(double), atom->nbondtypes, fp); + fwrite(&gamma[1], sizeof(double), atom->nbondtypes, fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads coeffs from restart file, bcasts them +------------------------------------------------------------------------- */ + +void BondRHEOShell::read_restart(FILE *fp) +{ + BondBPM::read_restart(fp); + read_restart_settings(fp); + allocate(); + + if (comm->me == 0) { + utils::sfread(FLERR, &k[1], sizeof(double), atom->nbondtypes, fp, nullptr, error); + utils::sfread(FLERR, &ecrit[1], sizeof(double), atom->nbondtypes, fp, nullptr, error); + utils::sfread(FLERR, &gamma[1], sizeof(double), atom->nbondtypes, fp, nullptr, error); + } + MPI_Bcast(&k[1], atom->nbondtypes, MPI_DOUBLE, 0, world); + MPI_Bcast(&ecrit[1], atom->nbondtypes, MPI_DOUBLE, 0, world); + MPI_Bcast(&gamma[1], atom->nbondtypes, MPI_DOUBLE, 0, world); + + for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1; +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file + ------------------------------------------------------------------------- */ + +void BondRHEOShell::write_restart_settings(FILE *fp) +{ + fwrite(&tform, sizeof(double), 1, fp); + fwrite(&rmax, sizeof(double), 1, fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts + ------------------------------------------------------------------------- */ + +void BondRHEOShell::read_restart_settings(FILE *fp) +{ + if (comm->me == 0) { + utils::sfread(FLERR, &tform, sizeof(double), 1, fp, nullptr, error); + utils::sfread(FLERR, &rmax, sizeof(double), 1, fp, nullptr, error); + } + MPI_Bcast(&tform, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&rmax, 1, MPI_DOUBLE, 0, world); +} + +/* ---------------------------------------------------------------------- */ + +double BondRHEOShell::single(int type, double rsq, int i, int j, double &fforce) +{ + if (type <= 0) return 0.0; + + double r0, t; + for (int n = 0; n < atom->num_bond[i]; n++) { + if (atom->bond_atom[i][n] == atom->tag[j]) { + r0 = fix_bond_history->get_atom_value(i, n, 0); + t = fix_bond_history->get_atom_value(i, n, 1); + } + } + + svector[1] = t; + if (t < tform) return 0.0; + + double r = sqrt(rsq); + double rinv = 1.0 / r; + double dr = r0 - r; + fforce = 2 * k[type] * (dr + dr * dr * dr / (r0 * r0 * ecrit[type] * ecrit[type])); + + double **x = atom->x; + double **v = atom->v; + double delx = x[i][0] - x[j][0]; + double dely = x[i][1] - x[j][1]; + double delz = x[i][2] - x[j][2]; + double delvx = v[i][0] - v[j][0]; + double delvy = v[i][1] - v[j][1]; + double delvz = v[i][2] - v[j][2]; + double dot = delx * delvx + dely * delvy + delz * delvz; + fforce -= gamma[type] * dot * rinv; + fforce *= rinv; + + // set single_extra quantities + + svector[0] = r0; + + return 0.0; +} + +/* ---------------------------------------------------------------------- + Similar to BondBPM->process_broken(), but don't send to FixStoreLocal + ------------------------------------------------------------------------- */ + +void BondRHEOShell::process_ineligibility(int i, int j) +{ + // Manually search and remove from atom arrays + int m, n; + int nlocal = atom->nlocal; + + tagint *tag = atom->tag; + tagint **bond_atom = atom->bond_atom; + int **bond_type = atom->bond_type; + int *num_bond = atom->num_bond; + + if (i < nlocal) { + for (m = 0; m < num_bond[i]; m++) { + if (bond_atom[i][m] == tag[j]) { + bond_type[i][m] = 0; + n = num_bond[i]; + bond_type[i][m] = bond_type[i][n - 1]; + bond_atom[i][m] = bond_atom[i][n - 1]; + fix_bond_history->shift_history(i, m, n - 1); + fix_bond_history->delete_history(i, n - 1); + num_bond[i]--; + break; + } + } + } + + if (j < nlocal) { + for (m = 0; m < num_bond[j]; m++) { + if (bond_atom[j][m] == tag[i]) { + bond_type[j][m] = 0; + n = num_bond[j]; + bond_type[j][m] = bond_type[j][n - 1]; + bond_atom[j][m] = bond_atom[j][n - 1]; + fix_bond_history->shift_history(j, m, n - 1); + fix_bond_history->delete_history(j, n - 1); + num_bond[j]--; + break; + } + } + } +} diff --git a/src/RHEO/bond_rheo_shell.h b/src/RHEO/bond_rheo_shell.h new file mode 100644 index 0000000000..562be6d9a6 --- /dev/null +++ b/src/RHEO/bond_rheo_shell.h @@ -0,0 +1,55 @@ +/* -*- 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 BOND_CLASS +// clang-format off +BondStyle(rheo/shell,BondRHEOShell); +// clang-format on +#else + +#ifndef LMP_BOND_RHEO_SHELL_H +#define LMP_BOND_RHEO_SHELL_H + +#include "bond_bpm.h" + +namespace LAMMPS_NS { + +class BondRHEOShell : public BondBPM { + public: + BondRHEOShell(class LAMMPS *); + ~BondRHEOShell() override; + void compute(int, int) override; + void coeff(int, char **) override; + void init_style() override; + void settings(int, char **) override; + double equilibrium_distance(int) override; + void write_restart(FILE *) override; + void read_restart(FILE *) override; + void write_restart_settings(FILE *) override; + void read_restart_settings(FILE *) override; + double single(int, double, int, int, double &) override; + + protected: + double *k, *ecrit, *gamma; + double tform, rmax; + + void process_ineligibility(int, int); + void allocate(); + void store_data(); + double store_bond(int, int, int); +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index 3cb2fcf058..31930d655d 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -329,7 +329,8 @@ double ComputeRHEOInterface::correct_rho(int i, int j) { // i is wall, j is fluid //In future may depend on atom type j's pressure equation - return atom->rho[i]; + int itype = atom->type[i]; + return MAX(rho0[itype], atom->rho[i]); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp new file mode 100644 index 0000000000..bd7babedbb --- /dev/null +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -0,0 +1,190 @@ +/* ---------------------------------------------------------------------- + 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 authors: + Joel Clemmer (SNL) +----------------------------------------------------------------------- */ + +#include "fix_rheo_oxidation.h" + +#include "atom.h" +#include "atom_vec.h" +#include "error.h" +#include "fix_rheo.h" +#include "force.h" +#include "modify.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" + +using namespace LAMMPS_NS; +using namespace RHEO_NS; +using namespace FixConst; +enum {NONE, CONSTANT}; + +/* ---------------------------------------------------------------------- */ + +FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg) //, fix_bond_history(nullptr) +{ + if (narg != 5) error->all(FLERR,"Illegal fix command"); + + cut = utils::numeric(FLERR, arg[3], false, lmp); + if (cut <= 0.0) error->all(FLERR, "Illegal bond cutoff {} in fix rheo/oxidation", cut); + + btype = utils::inumeric(FLERR, arg[4], false, lmp); + if (btype < 1 || btype > atom->nbondtypes) error->all(FLERR, "Illegal value {} for bond type in fix rheo/oxidation", btype); + + cutsq = cut * cut; +} + +/* ---------------------------------------------------------------------- */ + +FixRHEOOxidation::~FixRHEOOxidation() +{ +} + +/* ---------------------------------------------------------------------- */ + +int FixRHEOOxidation::setmask() +{ + int mask = 0; + mask |= POST_INTEGRATE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOOxidation::init() +{ + auto fixes = modify->get_fix_by_style("^rheo$"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/oxidation"); + class FixRHEO *fix_rheo = dynamic_cast(fixes[0]); + double cut_kernel = fix_rheo->h; + + if (cut > cut_kernel) + error->all(FLERR, "Bonding length exceeds kernel cutoff"); + + if (!force->bond) error->all(FLERR, "Must define a bond style with fix rheo/oxidation"); + if (!atom->avec->bonds_allow) error->all(FLERR, "Fix rheo/oxidation requires atom bonds"); + + //// find instances of bond history to delete data + //histories = modify->get_fix_by_style("BOND_HISTORY"); + //for (auto &ihistory: histories) + // if (strcmp(histories[i]->id, "HISTORY_RHEO_SHELL") == 0) + // fix_bond_history = dynamic_cast(ihistory); +// + //if (!fix_bond_history) + // error->all(FLERR, "Must define bond style rheo/shell to use fix rheo/oxidation"); + + // need a half neighbor list + auto req = neighbor->add_request(this, NeighConst::REQ_DEFAULT); + req->set_cutoff(cut); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOOxidation::init_list(int /*id*/, NeighList *ptr) +{ + list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOOxidation::post_integrate() +{ + int i, j, n, ii, jj, inum, jnum, bflag; + int *ilist, *jlist, *numneigh, **firstneigh; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + tagint tagi, tagj; + + int nlocal = atom->nlocal; + int newton_bond = force->newton_bond; + + tagint *tag = atom->tag; + tagint **bond_atom = atom->bond_atom; + int *status = atom->status; + int **bond_type = atom->bond_type; + int *num_bond = atom->num_bond; + double **x = atom->x; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // loop over neighbors of my atoms + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + if (!(status[i] & STATUS_SURFACE)) continue; + + tagi = tag[i]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + + if (!(status[j] & STATUS_SURFACE)) continue; + + tagj = tag[j]; + 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) continue; + + // Check if already have an oxide bond + bflag = 0; + for (n = 0; n < num_bond[i]; n++) { + if (bond_type[i][n] == btype && bond_atom[i][n] == tagj) { + bflag = 1; + break; + } + } + if (bflag) continue; + + for (n = 0; n < num_bond[j]; n++) { + if (bond_type[j][n] == btype && bond_atom[j][n] == tagi) { + bflag = 1; + break; + } + } + if (bflag) continue; + + // Add bonds to owned atoms + // If newton bond, add to both, otherwise add to whichever has a smaller tag + if (i < nlocal && (!newton_bond || tagi < tagj)) { + if (num_bond[i] == atom->bond_per_atom) + error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/oxidation for atom {}", tagi); + bond_type[i][num_bond[i]] = btype; + bond_atom[i][num_bond[i]] = tagj; + num_bond[i]++; + } + + if (j < nlocal && (!newton_bond || tagj < tagi)) { + if (num_bond[j] == atom->bond_per_atom) + error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/oxidation for atom {}", tagj); + bond_type[j][num_bond[j]] = btype; + bond_atom[j][num_bond[j]] = tagi; + num_bond[j]++; + } + } + } +} diff --git a/src/RHEO/fix_rheo_oxidation.h b/src/RHEO/fix_rheo_oxidation.h new file mode 100644 index 0000000000..4c81605611 --- /dev/null +++ b/src/RHEO/fix_rheo_oxidation.h @@ -0,0 +1,49 @@ +/* -*- 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(rheo/oxidation,FixRHEOOxidation) +// clang-format on +#else + +#ifndef LMP_FIX_RHEO_OXIDATION_H +#define LMP_FIX_RHEO_OXIDATION_H + +#include "fix.h" + +#include + +namespace LAMMPS_NS { + +class FixRHEOOxidation : public Fix { + public: + FixRHEOOxidation(class LAMMPS *, int, char **); + ~FixRHEOOxidation() override; + int setmask() override; + void init() override; + void init_list(int, class NeighList *) override; + void post_integrate() override; + + private: + int btype; + double cut, cutsq; + class NeighList *list; + + //class FixBondHistory *fix_bond_history; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 0640dd6827..c6d10bcc79 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -271,7 +271,12 @@ void FixRHEOThermal::init() req->set_cutoff(cut_kernel); // find instances of bond history to delete data + // skip history for shell, only exception histories = modify->get_fix_by_style("BOND_HISTORY"); + if (n_histories > 0) + for (int i = 0; i < histories.size(); i++) + if (strcmp(histories[i]->id, "HISTORY_RHEO_SHELL") == 0) + histories.erase(histories.begin() + i); n_histories = histories.size(); } } @@ -644,6 +649,8 @@ double FixRHEOThermal::calc_cv(int i, int itype) if (cv_style[itype] == CONSTANT) { return cv[itype]; } + + return 0.0; } /* ---------------------------------------------------------------------- */ @@ -653,6 +660,8 @@ double FixRHEOThermal::calc_Tc(int i, int itype) if (Tc_style[itype] == CONSTANT) { return Tc[itype]; } + + return 0.0; } /* ---------------------------------------------------------------------- */ @@ -662,6 +671,8 @@ double FixRHEOThermal::calc_L(int i, int itype) if (L_style[itype] == CONSTANT) { return L[itype]; } + + return 0.0; } /* ---------------------------------------------------------------------- */ diff --git a/src/bond_hybrid.cpp b/src/bond_hybrid.cpp index 4e477ab3a6..5f84db1886 100644 --- a/src/bond_hybrid.cpp +++ b/src/bond_hybrid.cpp @@ -259,8 +259,13 @@ void BondHybrid::flags() if (styles[m]) comm_forward = MAX(comm_forward, styles[m]->comm_forward); if (styles[m]) comm_reverse = MAX(comm_reverse, styles[m]->comm_reverse); if (styles[m]) comm_reverse_off = MAX(comm_reverse_off, styles[m]->comm_reverse_off); + if (styles[m]) partial_flag = MAX(partial_flag, styles[m]->partial_flag); } + for (m = 0; m < nstyles; m++) + if (styles[m]->partial_flag != partial_flag) + error->all(FLERR, "Cannot hybridize bond styles with different topology settings"); + init_svector(); } From 7ea0dc3996db3e9315d06fae83162ec2990ad114 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 29 Mar 2024 19:00:14 -0600 Subject: [PATCH 073/104] Adding more oxidation features + doc pages --- doc/src/Howto_rheo.rst | 99 +++++++++++++++++++++- doc/src/Packages_details.rst | 36 ++++++++ doc/src/Packages_list.rst | 5 ++ doc/src/fix_rheo.rst | 108 ++++++++++++++++++++---- doc/src/pair_rheo.rst | 26 +++++- src/RHEO/atom_vec_rheo.cpp | 2 +- src/RHEO/atom_vec_rheo_thermal.cpp | 2 +- src/RHEO/bond_rheo_shell.cpp | 80 ++++++++++++++++++ src/RHEO/bond_rheo_shell.h | 6 ++ src/RHEO/compute_rheo_grad.cpp | 2 +- src/RHEO/compute_rheo_kernel.cpp | 2 +- src/RHEO/compute_rheo_property_atom.cpp | 7 +- src/RHEO/compute_rheo_property_atom.h | 3 +- src/RHEO/compute_rheo_rho_sum.cpp | 5 ++ src/RHEO/compute_rheo_vshift.cpp | 2 + src/RHEO/fix_rheo.cpp | 2 +- src/RHEO/fix_rheo.h | 1 + src/RHEO/fix_rheo_oxidation.cpp | 29 ++++++- src/RHEO/fix_rheo_oxidation.h | 3 + src/RHEO/fix_rheo_pressure.cpp | 2 +- src/RHEO/fix_rheo_thermal.cpp | 35 +++++--- src/RHEO/fix_rheo_viscosity.cpp | 2 +- src/RHEO/pair_rheo.cpp | 2 +- src/RHEO/pair_rheo_solid.cpp | 5 ++ 24 files changed, 423 insertions(+), 43 deletions(-) diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index c55631455b..146716ba18 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -1,4 +1,99 @@ Reproducing hydrodynamics and elastic objects (RHEO) -====================== +==================================================== -Text +The RHEO package is built around an implementation of smoothed particle +hydrodynamics (SPH) coupled to the :doc:`BPM package ` to model +solid elements of a system. The SPH solver supports many advanced options +including reproducing kernels, particle shifting, free surface identification, +and solid surface reconstruction. To model fluid-solid systems, the status of +particles can dynamically change between a fluid and solid state, e.g. during +melting/solidification, which determines how they interact and their physical +behavior. The package is designed with modularity in mind, so one can easily +turn various features on/off, adjust physical details of the system, or +develop new capabilities. Additional numerical details can be found in +:ref:`(Palermo) ` and :ref:`(Clemmer) `. + +---------- + +At the core of the package is :doc:`fix rheo ` which integrates +particle trajectories and controls many optional features (e.g. the use +of reproducing kernels). In conjunction to fix rheo, one must specify an +instance of :doc:`fix rheo/pressure ` and +:doc:`fix rheo/viscosity ` to define a pressure equation +of state and viscosity model, respectively. Optionally, one can model +a heat equation with :doc:`fix rheo/thermal`, which also allows the user +to specify equations for a particle's thermal conductivity, specific heat, +latent heat, and melting temperature. Fix rheo must be defined prior to all +other RHEO fixes. + +Typically, RHEO requires atom style rheo. In addition to typical atom +properties like positions and forces, particles store a local density, +viscosity, pressure, and status. If thermal evolution is modeled, one must +use atom style rheo/thermal which also include a local temperature and +conductivity. The status variable uses bitmasking to track various +properties of a particle such as its current phase (fluid or solid) and its +location relative to a surface. Many of these properties (and others) can +be easily accessed using +:doc:`compute rheo/property/atom `. + +Fluid interactions, including pressure forces, viscous forces, and heat exchange, +are calculated using :doc:`pair rheo `. Unlike typical pair styles, +pair rheo ignores the :doc:`special bond ` settings. Instead, +it determines whether to calculate forces based on the status of particles: +hydrodynamic forces are only calculated if a fluid particle is involved. + +---------- + +To model elastic objects, there are current two mechanisms in RHEO, one designed +for bulk solid bodies and the other for thin shells. Both mechanisms rely on +overlaying bonds and therefore require a hybrid of atom style bond and rheo +(or rheo/thermal). + +To create an elastic solid body, one has to (a) change the status of constituent +particles to solid (e.g. with the :doc:`set ` command), (b) create bpm +bonds between the particles (see the :doc:`bpm howto ` page for +more details), and (c) use :doc:`pair rheo/solid ` to +apply repulsive contact forces between distinct solid bodies. Akin to pair rheo, +looks at a particles fluid/solid status to determine whether to apply forces. +However, unlike pair rheo, pair rheo/solid does obey special bond settings such +that contact forces do not have to be calculated between two bonded solid particles +in the same elastic body. + +In systems with thermal evolution, fix rheo/thermal can optionally set a +melting/solidification temperature allowing particles to dynamically swap their +state between fluid and solid. Using the *react* option, one can specify a maximum +bond length and a bond type. Then, when solidifying, particles will search their +local neighbors and automatically create bonds with any neighboring solid particles +in range. For BPM bond styles, bonds will then use the immediate position of the two +particles to calculate a reference state. When melting, particles will then delete +any bonds of the specified type when reverting to a fluid state. Special bonds are +updated as bonds are created/broken. + +The other option for elastic objects is an elastic shell that is nominally much +thinner than a particle diameter, e.g. a oxide skin which gradually forms over time +on the surface of a fluid. Currently, this is implemented using +:doc:`fix rheo/oxidaton ` and bond style +:doc:`rheo/shell `. Essentially, fix rheo/oxidaton creates candidate +bonds of a specified type between surface fluid particles within a specified distance. +a newly created rheo/shell bond will then start a timer. While the timer is counting +down, the bond will delete itself if particles move too far apart or move away from the +surface. However, if the timer reaches a user-defined threshold, then the bond will +activate and apply additional forces to the fluid particles. Bond style rheo/shell +then operates very similarly to a BPM bond style, storing a reference length and +breaking if stretched too far. Unlike the above method, this option does not remove +the underlying fluid interactions (although particle shifting is turned off) and does +not modify special bond settings of particles. + +While these two options are not expected to be appropriate for every multiphase system, +either framework can be modified to create more suitable models (e.g. by changing the +criteria for creating/deleting a bond or altering force calculations). + +---------- + +.. _howto-howto_rheo_palermo: + +**(Palermo)** Palermo, Clemmer, Wolf, O'Connor, in preparation. + +.. _howto-howto_rheo_clemmer: + +**(Clemmer)** Clemmer, Pierce, O'Connor, Nevins, Jones, Lechman, Tencer, Appl. Math. Model., 130, 310-326 (2024). diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index a3d65d9d65..39a9deef63 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -101,6 +101,7 @@ page gives those details. * :ref:`QEQ ` * :ref:`QMMM ` * :ref:`QTB ` + * :ref:`RHEO ` * :ref:`REACTION ` * :ref:`REAXFF ` * :ref:`REPLICA ` @@ -2571,6 +2572,41 @@ another set. ---------- +.. _PKG-RHEO: + +RHEO package +------------ + +**Contents:** + +Pair styles, bond styles, fixes, and computes for reproducing +hydrodynamics and elastic objects. See the +:doc:`Howto rheo ` page for an overview. + +**Authors:** Joel T. Clemmer (Sandia National Labs), +Thomas C. O'Connor (Carnegie Mellon University) + +.. versionadded:: TBD + +**Supporting info:** + +* src/RHEO filenames -> commands +* :doc:`Howto_rheo ` +* :doc:`atom_style rheo ` +* :doc:`atom_style rheo/thermal ` +* :doc:`bond_style rheo/shell ` +* :doc:`compute rheo/property/atom ` +* :doc:`fix rheo ` +* :doc:`fix rheo/oxidation ` +* :doc:`fix rheo/pressure ` +* :doc:`fix rheo/thermal ` +* :doc:`fix rheo/viscosity ` +* :doc:`pair_style rheo ` +* :doc:`pair_style rheo/solid ` +* examples/rheo + +---------- + .. _PKG-RIGID: RIGID package diff --git a/doc/src/Packages_list.rst b/doc/src/Packages_list.rst index c0a1164513..4e1d32385f 100644 --- a/doc/src/Packages_list.rst +++ b/doc/src/Packages_list.rst @@ -403,6 +403,11 @@ whether an extra library is needed to build and use the package: - :doc:`fix qtb ` :doc:`fix qbmsst ` - qtb - no + * - :ref:`RHEO ` + - reproducing hydrodynamics and elastic objects + - :doc:`Howto rheo ` + - rheo + - no * - :ref:`REACTION ` - chemical reactions in classical MD - :doc:`fix bond/react ` diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index c61d1939db..76d4ae3972 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -8,40 +8,107 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo cut kstyle keyword values... + fix ID group-ID rheo cut kstyle zmin keyword values... * ID, group-ID are documented in :doc:`fix ` command * rheo = style name of this fix command -* cut = *quintic* or *RK0* or *RK1* or *RK2* +* cut = cutoff for the kernel (distance) +* kstyle = *quintic* or *RK0* or *RK1* or *RK2* +* zmin = minimal number of neighbors for reproducing kernels * zero or more keyword/value pairs may be appended to args -* keyword = *shift* or *thermal* or *surface/detection* or *interface/reconstruction* or - *rho/sum* or *density* or *sound/squared* +* keyword = *thermal* or *interface/reconstruct* or *surface/detection* or + *shift* or *rho/sum* or *density* or *speed/sound* .. parsed-literal:: - *shift* values = none, turns on velocity shifting *thermal* values = none, turns on thermal evolution + *interface/reconstruct* values = none, reconstructs interfaces with solid particles *surface/detection* values = *sdstyle* *limit* *limit/splash* *sdstyle* = *coordination* or *divergence* - *limit* = threshold for surface particles (unitless) - *limit/splash* = threshold for splash particles (unitless) - *interface/reconstruct* values = none, reconstructs interfaces with solid particles + *limit* = threshold for surface particles + *limit/splash* = threshold for splash particles + *shift* values = none, turns on velocity shifting *rho/sum* values = none, uses the kernel to compute the density of particles - *density* values = *rho0* (density) - *sound/squared* values = *csq* (velocity\^2) + *density* values = *rho01*, ... *rho0N* (density) + *speed/sound* values = *cs0*, ... *csN* (velocity) Examples """""""" .. code-block:: LAMMPS - fix 1 all rheo 1.0 quintic thermal density 0.1 sound/squared 10.0 + fix 1 all rheo 1.0 quintic thermal density 0.1 speed/sound 10.0 fix 1 all rheo 1.0 RK1 shift surface/detection coordination 40 Description """"""""""" -Fix description... +Perform time integration for RHEO particles, updating positions, velocities, +and densities. For a detailed breakdown of the integration timestep and +numerical details, see :ref:`(Palermo) `. For an +overview of other features available in the RHEO package, see +:doc:`the RHEO howto `. + +The type of kernel is specified using *kstyle* and the cutoff is *cut*. Four +kernels are currently available. The *quintic* kernel is a standard quintic +spline function commonly used in SPH. The other options, *RK0*, *RK1*, and +*RK2*, are zeroth, first, and second order reproducing. To generate a reproducing kernel, a particle must have sufficient neighbors inside the +kernel cutoff distance (a coordination number) to accurately calculate +moments. This threshold is set by *zmin*. If reproducing kernels are +requested but a particle has fewer neighbors, then it will revert to a +non-reproducing quintic kernel until it gains more neighbors. + +To model temperature evolution, one must specify the *thermal* keyword, +define a separate instance of :doc:`fix rheo/thermal `, +and use atom style rheo/thermal. + +By default, the density of solid RHEO particles does not evolve and forces +with fluid particles are calculated using the current velocity of the solid +particle. If the *interface/reconstruct* keyword is used, then the density +and velocity of solid particles are alternatively reconstructed for every +fluid-solid interaction to ensure no-slip and pressure-balanced boundaries. +This is done by estimating the location of the fluid-solid interface and +extrapolating fluid particle properties across the interface to calculate a +temporary apparent density and velocity for a solid particle. The numerical +details are the same as those described in +:ref:`(Palermo) ` except there is an additional +restriction that the reconstructed solid density cannot be less than the +equilibrium density. This prevents fluid particles from sticking to solid +surfaces. + +A modified form of Fickian particle shifting can be enabled with the +*shift* keyword. This effectively shifts particle positions to generate a +more uniform spatial distribution. In systems with free surfaces, the +*surface/detection* keyword can be used to classify the location of +particles as being within the bulk fluid, on a free surface, or isolated +from other particles in a splash or droplet. Shifting is then disabled in +the direction away from the free surface to prevent it from diffusing +particles away from the bulk fluid. Surface detection can also be used +to control surface-nucleated effects like oxidation when used in combination +with :doc:`fix rheo/oxidation `. + +The *surface/detection* keyword takes three arguments: *sdstyle*, *limit*, +and *limi/splash*. The first, *sdstyle*, specifies whether surface particles +are identified using a coordination number (*coordination*) or the divergence +of the local particle positions (*divergence*). The threshold value for a +surface particle for either of these criteria is set by the numerical value +of *limit*. Additionally, if a particle's coordination number is too low, +i.e. if it has separated off from the bulk in a droplet, it is not possible +to define surfaces and a particle is classified as a splash. The coordination +threshold for this classification is set by the numerical value of +*limit/splash*. + +By default, RHEO integrates particles' densities using a mass diffusion +equation. Alternatively, one can update densities every timestep by performing +a kernel summation of the masses of neighboring particles by specifying the *rho/sum* keyword. + +The *density* is used to specify the equilbrium density of each of the N +particle types. It must be followed by N numerical values specifying each +type's equilibrium density *rho0*. + +The *density* is used to specify the speed of sound of each of the N particle +types. It must be followed by N numerical values specifying each type's speed +of sound *cs*. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -55,13 +122,14 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" -This fix must be used with an atom style that includes density -such as atom_style rheo or rheo/thermal. This fix must be used in -conjuction with :doc:`fix rheo/pressure `. and +This fix must be used with atom style rheo or rheo/thermal. +This fix must be used in conjuction with +:doc:`fix rheo/pressure `. and :doc:`fix rheo/viscosity `, If the *thermal* setting is used, there must also be an instance of :doc:`fix rheo/thermal `. The fix group must be -set to all. +set to all. Only one instance of fix rheo may be defined and it +must be defined prior to all other RHEO fixes. This fix is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. @@ -78,4 +146,10 @@ Related commands Default """"""" -*rho0* and *csq* are set to 1.0. +*rho0* and *cs* are set to 1.0 for all atom types. + +---------- + +.. _howto-howto_rheo_palermo: + +**(Palermo)** Palermo, Clemmer, Wolf, O'Connor, in preparation. diff --git a/doc/src/pair_rheo.rst b/doc/src/pair_rheo.rst index 6f706a77ac..f6c3d9e3ba 100644 --- a/doc/src/pair_rheo.rst +++ b/doc/src/pair_rheo.rst @@ -16,8 +16,8 @@ Syntax .. parsed-literal:: - *rho/damp* args = density damping prefactor :math:`\xi` (units?) - *artificial/visc* args = artificial viscosity prefactor :math:`\zeta` (units?) + *rho/damp* args = density damping prefactor :math:`\xi` + *artificial/visc* args = artificial viscosity prefactor :math:`\zeta` *harmonic/means* args = none Examples @@ -31,7 +31,27 @@ Examples Description """"""""""" -pair style... +Pair style *rheo* computes pressure and viscous forces between particles +in the :doc:`rheo package `. If thermal evolution is turned +on in :doc:`fix rheo `, then the pair style also calculates +heat exchanged between particles. + +The *artificial/viscosity* keyword is used to specify the magnitude +:math:`\zeta` of an optional artificial viscosity contribution to forces. +This factor can help stabilize simulations by smoothing out small length +scale variations in velocity fields. + +The *rho/damp* keyword is used to specify the magnitude :math:`\xi` of +an optional pairwise damping term between the density of particles. This +factor can help stabilize simulations by smoothing out small length +scale variations in density fields. + +If particles have different viscosities or conductivities, the +*harmonic/means* keyword changes how they are averaged before calculating +pairwise forces or heat exchanges. By default, an arithmetic averaged is +used, however, a harmonic mean may improve stability in multiphase systems +with large disparities in viscosities. This keyword has no effect on +results if viscosities and conductivities are constant. No coefficients are defined for each pair of atoms types via the :doc:`pair_coeff ` command as in the examples diff --git a/src/RHEO/atom_vec_rheo.cpp b/src/RHEO/atom_vec_rheo.cpp index ec44a230ec..843269a717 100644 --- a/src/RHEO/atom_vec_rheo.cpp +++ b/src/RHEO/atom_vec_rheo.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL) ----------------------------------------------------------------------- */ #include "atom_vec_rheo.h" diff --git a/src/RHEO/atom_vec_rheo_thermal.cpp b/src/RHEO/atom_vec_rheo_thermal.cpp index 26394c9175..7174d4cb66 100644 --- a/src/RHEO/atom_vec_rheo_thermal.cpp +++ b/src/RHEO/atom_vec_rheo_thermal.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL) ----------------------------------------------------------------------- */ #include "atom_vec_rheo_thermal.h" diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp index 6a9f99d8b1..6a71136d9d 100644 --- a/src/RHEO/bond_rheo_shell.cpp +++ b/src/RHEO/bond_rheo_shell.cpp @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL) +----------------------------------------------------------------------- */ + #include "bond_rheo_shell.h" #include "atom.h" @@ -40,17 +45,38 @@ BondRHEOShell::BondRHEOShell(LAMMPS *_lmp) : BondBPM(_lmp), k(nullptr), ecrit(nullptr), gamma(nullptr) { partial_flag = 1; + comm_reverse = 1; tform = rmax = -1; single_extra = 1; svector = new double[1]; + + // For nbond, create an instance of fix property atom + // Need restarts + exchanging with neighbors since it needs to persist + // between timesteps (fix property atom will handle callbacks) + + int tmp1, tmp2; + index_nb = atom->find_custom("shell_nbond", tmp1, tmp2); + if (index_nb == -1) { + id_fix = utils::strdup("bond_rheo_shell_fix_property_atom"); + modify->add_fix(fmt::format("{} all property/atom i_shell_nbond", id_fix)); + index_nb = atom->find_custom("shell_nbond", tmp1, tmp2); + } + nbond = atom->ivector[index_nb]; + + //Store non-persistent per atom quantities, intermediate + + nmax_store = atom->nmax; + memory->create(dbond, nmax_store, "rheo/react:dbond"); } /* ---------------------------------------------------------------------- */ BondRHEOShell::~BondRHEOShell() { + if (modify->nfix) modify->delete_fix(id_fix); + delete[] id_fix; delete[] svector; if (allocated) { @@ -59,6 +85,8 @@ BondRHEOShell::~BondRHEOShell() memory->destroy(ecrit); memory->destroy(gamma); } + + memory->destroy(dbond); } /* ---------------------------------------------------------------------- @@ -151,6 +179,15 @@ void BondRHEOShell::compute(int eflag, int vflag) double **bondstore = fix_bond_history->bondstore; + if (atom->nmax > nmax_store){ + nmax_store = atom->nmax; + memory->destroy(dbond); + memory->create(dbond, nmax_store, "rheo/shell:dbond"); + } + + size_t nbytes = nmax_store * sizeof(int); + memset(&dbond[0], 0, nbytes); + for (n = 0; n < nbondlist; n++) { // skip bond if already broken @@ -196,6 +233,8 @@ void BondRHEOShell::compute(int eflag, int vflag) if (bondstore[n][1] >= tform) { bondstore[n][0] = r; r0 = r; + if (newton_bond || i1 < nlocal) dbond[i1] ++; + if (newton_bond || i2 < nlocal) dbond[i2] ++; } else { continue; } @@ -205,6 +244,8 @@ void BondRHEOShell::compute(int eflag, int vflag) if (fabs(e) > ecrit[type]) { bondlist[n][2] = 0; process_broken(i1, i2); + if (newton_bond || i1 < nlocal) dbond[i1] --; + if (newton_bond || i2 < nlocal) dbond[i2] --; continue; } @@ -233,6 +274,17 @@ void BondRHEOShell::compute(int eflag, int vflag) if (evflag) ev_tally(i1, i2, nlocal, newton_bond, 0.0, fbond, delx, dely, delz); } + + + // Communicate changes in nbond + if (newton_bond) comm->reverse_comm(this); + + for(i = 0; i < nlocal; i++) { + nbond[i] += dbond[i]; + + // If it has bonds, no shifting + if (nbond[i] != 0) status[i] |= STATUS_NO_SHIFT; + } } /* ---------------------------------------------------------------------- */ @@ -419,6 +471,34 @@ void BondRHEOShell::read_restart_settings(FILE *fp) MPI_Bcast(&rmax, 1, MPI_DOUBLE, 0, world); } + +/* ---------------------------------------------------------------------- */ + +int BondRHEOShell::pack_reverse_comm(int n, int first, double *buf) +{ + int i, m, last; + m = 0; + last = first + n; + + for (i = first; i < last; i++) { + buf[m++] = dbond[i]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void BondRHEOShell::unpack_reverse_comm(int n, int *list, double *buf) +{ + int i, j, m; + + m = 0; + for (i = 0; i < n; i++) { + j = list[i]; + dbond[j] += buf[m++]; + } +} + /* ---------------------------------------------------------------------- */ double BondRHEOShell::single(int type, double rsq, int i, int j, double &fforce) diff --git a/src/RHEO/bond_rheo_shell.h b/src/RHEO/bond_rheo_shell.h index 562be6d9a6..513d481eeb 100644 --- a/src/RHEO/bond_rheo_shell.h +++ b/src/RHEO/bond_rheo_shell.h @@ -37,12 +37,18 @@ class BondRHEOShell : public BondBPM { void read_restart(FILE *) override; void write_restart_settings(FILE *) override; void read_restart_settings(FILE *) override; + int pack_reverse_comm(int, int, double *) override; + void unpack_reverse_comm(int, int *, double *) override; double single(int, double, int, int, double &) override; protected: double *k, *ecrit, *gamma; double tform, rmax; + int *dbond, *nbond; + int index_nb, nmax_store; + char *id_fix; + void process_ineligibility(int, int); void allocate(); void store_data(); diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index acfc01d793..5ed43a421a 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL), Thomas O'Connor (CMU) ----------------------------------------------------------------------- */ #include "compute_rheo_grad.h" diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 6f58d79243..bd16a89b6a 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL), Thomas O'Connor (CMU) ----------------------------------------------------------------------- */ #include "compute_rheo_kernel.h" diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 380ff398d8..2d6ff1e55a 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -56,7 +56,7 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (nvalues == 1) size_peratom_cols = 0; else size_peratom_cols = nvalues; - pressure_flag = thermal_flag = interface_flag = surface_flag = shift_flag = 0; + pressure_flag = thermal_flag = interface_flag = surface_flag = shift_flag = shell_flag = 0; // parse input values // customize a new keyword by adding to if statement @@ -112,6 +112,9 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a arg[iarg], atom->get_style()); pack_choice[i] = &ComputeRHEOPropertyAtom::pack_atom_style; thermal_flag = 1; + } else if (strcmp(arg[iarg],"nbond/shell") == 0) { + shell_flag = 1; + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_nbond_shell; } else { avec_index[i] = atom->avec->property_atom(arg[iarg]); if (avec_index[i] < 0) @@ -156,6 +159,8 @@ void ComputeRHEOPropertyAtom::init() error->all(FLERR, "Cannot request velocity shifting property without corresponding option in fix rheo"); if (thermal_flag && !(fix_rheo->thermal_flag)) error->all(FLERR, "Cannot request thermal property without fix rheo/thermal"); + if (shell_flag && !(fix_rheo->oxidation_flag)) + error->all(FLERR, "Cannot request number of shell bonds without fix rheo/oxidation"); compute_interface = fix_rheo->compute_interface; compute_kernel = fix_rheo->compute_kernel; diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index f3596fbbf9..fd73b5883f 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -34,7 +34,7 @@ class ComputeRHEOPropertyAtom : public Compute { private: int nvalues, nmax; - int pressure_flag, thermal_flag, interface_flag, surface_flag, shift_flag; + int pressure_flag, thermal_flag, interface_flag, surface_flag, shift_flag, shell_flag; int *avec_index; int *col_index; double *buf; @@ -54,6 +54,7 @@ class ComputeRHEOPropertyAtom : public Compute { void pack_shift_v(int); void pack_gradv(int); void pack_pressure(int); + void pack_nbond_shell(int); void pack_atom_style(int); int get_vector_index(char*); diff --git a/src/RHEO/compute_rheo_rho_sum.cpp b/src/RHEO/compute_rheo_rho_sum.cpp index 82d3aa4bc6..8322ad4ad4 100644 --- a/src/RHEO/compute_rheo_rho_sum.cpp +++ b/src/RHEO/compute_rheo_rho_sum.cpp @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL) +----------------------------------------------------------------------- */ + #include "compute_rheo_rho_sum.h" #include "atom.h" diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 569c8569f7..533287911a 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -147,6 +147,8 @@ void ComputeRHEOVShift::compute_peratom() fluidj = !(status[j] & PHASECHECK); if ((!fluidi) && (!fluidj)) continue; + + // Will skip shifting in FixRHEO initial integrate, but also skip here to save time if ((status[i] & STATUS_NO_SHIFT) && (status[j] & STATUS_NO_SHIFT)) continue; dx[0] = xtmp - x[j][0]; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index beba940174..b0cb1513fc 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -221,7 +221,7 @@ void FixRHEO::setup_pre_force(int /*vflag*/) { // Check to confirm accessory fixes do not preceed FixRHEO // Note: fixes set this flag in setup_pre_force() - if (viscosity_fix_defined || pressure_fix_defined || thermal_fix_defined) + if (viscosity_fix_defined || pressure_fix_defined || thermal_fix_defined || oxidation_fix_defined) error->all(FLERR, "Fix RHEO must be defined before all other RHEO fixes"); // Calculate surfaces diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 8ec28c7d0e..33fd0084db 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -55,6 +55,7 @@ class FixRHEO : public Fix { int viscosity_fix_defined; int pressure_fix_defined; int thermal_fix_defined; + int oxidation_fix_defined; class ComputeRHEOGrad *compute_grad; class ComputeRHEOKernel *compute_kernel; diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index bd7babedbb..1628cef13f 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -60,6 +60,7 @@ FixRHEOOxidation::~FixRHEOOxidation() int FixRHEOOxidation::setmask() { int mask = 0; + mask |= PRE_FORCE; mask |= POST_INTEGRATE; return mask; } @@ -70,7 +71,7 @@ void FixRHEOOxidation::init() { auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/oxidation"); - class FixRHEO *fix_rheo = dynamic_cast(fixes[0]); + fix_rheo = dynamic_cast(fixes[0]); double cut_kernel = fix_rheo->h; if (cut > cut_kernel) @@ -102,6 +103,26 @@ void FixRHEOOxidation::init_list(int /*id*/, NeighList *ptr) /* ---------------------------------------------------------------------- */ +void FixRHEOOxidation::setup_pre_force(int /*vflag*/) +{ + // Not strictly required that this fix be after FixRHEO, + // but enforce to be consistent with other RHEO fixes + fix_rheo->oxidation_fix_defined = 1; + + if (!fix_rheo->surface_flag) error->all(FLERR, + "fix rheo/oxidation requires surface calculation in fix rheo"); + + pre_force(0); +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOThermal::pre_force(int /*vflag*/) +{ +} + +/* ---------------------------------------------------------------------- */ + void FixRHEOOxidation::post_integrate() { int i, j, n, ii, jj, inum, jnum, bflag; @@ -187,4 +208,10 @@ void FixRHEOOxidation::post_integrate() } } } + + //todo: + // allow option to create near-surface bonds + // extract # of bonds in property/atom + // check bond style shell used, get index to bonds, share with compute property atom + // add type option to compute nbond/atom } diff --git a/src/RHEO/fix_rheo_oxidation.h b/src/RHEO/fix_rheo_oxidation.h index 4c81605611..ca36a6fdf9 100644 --- a/src/RHEO/fix_rheo_oxidation.h +++ b/src/RHEO/fix_rheo_oxidation.h @@ -33,6 +33,8 @@ class FixRHEOOxidation : public Fix { int setmask() override; void init() override; void init_list(int, class NeighList *) override; + void setup_pre_force(int) override; + void pre_force(int) override; void post_integrate() override; private: @@ -40,6 +42,7 @@ class FixRHEOOxidation : public Fix { double cut, cutsq; class NeighList *list; + class FixRHEO *fix_rheo; //class FixBondHistory *fix_bond_history; }; diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index 8c523b2b35..d6dea8aa1a 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL), Thomas O'Connor (CMU) ----------------------------------------------------------------------- */ #include "fix_rheo_pressure.h" diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index c6d10bcc79..7d9aff5424 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -498,21 +498,36 @@ void FixRHEOThermal::break_bonds() int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - // Rapidly delete all bonds for local atoms that melt (no shifting) + // Rapidly delete all bonds for local atoms that melt of a given type for (int i = 0; i < nlocal; i++) { if (!(status[i] & STATUS_MELTING)) continue; - for (m = 0; m < num_bond[i]; m++) { - j = atom->map(bond_atom[i][m]); - bond_type[i][m] = 0; + for (m = (num_bond[i] - 1); m >= 0; m--) { + if (bond_type[i][m] != btype) continue; - if (n_histories > 0) - for (auto &ihistory: histories) - dynamic_cast(ihistory)->delete_history(i, m); + j = atom->map(bond_atom[i][m]); + + nmax = num_bond[i] - 1; + if (m == nmax) { + if (n_histories > 0) + for (auto &ihistory: histories) + dynamic_cast(ihistory)->delete_history(i, m); + } else { + bond_type[i][m] = bond_type[i][nmax]; + bond_atom[i][m] = bond_atom[i][nmax]; + if (n_histories > 0) { + for (auto &ihistory: histories) { + auto fix_bond_history = dynamic_cast (ihistory); + fix_bond_history->shift_history(i, m, nmax); + fix_bond_history->delete_history(i, nmax); + } + } + } + bond_type[i][nmax] = 0; + num_bond[i]--; if (fix_update_special_bonds) fix_update_special_bonds->add_broken_bond(i, j); } - num_bond[i] = 0; } // Update bond list and break solid-melted bonds @@ -530,7 +545,7 @@ void FixRHEOThermal::break_bonds() // Delete bonds for non-melted local atoms (shifting) if (i < nlocal) { for (m = 0; m < num_bond[i]; m++) { - if (bond_atom[i][m] == tag[j]) { + if (bond_atom[i][m] == tag[j] && bond_type[i][m] == btype) { nmax = num_bond[i] - 1; bond_type[i][m] = bond_type[i][nmax]; bond_atom[i][m] = bond_atom[i][nmax]; @@ -549,7 +564,7 @@ void FixRHEOThermal::break_bonds() if (j < nlocal) { for (m = 0; m < num_bond[j]; m++) { - if (bond_atom[j][m] == tag[i]) { + if (bond_atom[j][m] == tag[i] && bond_type[j][m] == btype) { nmax = num_bond[j] - 1; bond_type[j][m] = bond_type[j][nmax]; bond_atom[j][m] = bond_atom[j][nmax]; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 2fffa8b29c..abaa55ca70 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL), Thomas O'Connor (CMU) ----------------------------------------------------------------------- */ #include "fix_rheo_viscosity.h" diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index b07e914af1..fe5a1d6dec 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -13,7 +13,7 @@ /* ---------------------------------------------------------------------- Contributing authors: - Joel Clemmer (SNL), Thomas O'Connor (CMU), Eric Palermo (CMU) + Joel Clemmer (SNL), Thomas O'Connor (CMU) ----------------------------------------------------------------------- */ #include "pair_rheo.h" diff --git a/src/RHEO/pair_rheo_solid.cpp b/src/RHEO/pair_rheo_solid.cpp index d0a68d5230..f6dcd95879 100644 --- a/src/RHEO/pair_rheo_solid.cpp +++ b/src/RHEO/pair_rheo_solid.cpp @@ -11,6 +11,11 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: + Joel Clemmer (SNL) +----------------------------------------------------------------------- */ + #include "pair_rheo_solid.h" #include "atom.h" From 08db64c27fbe30b5dd2ab342f5606cdfeb73697b Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 31 Mar 2024 21:40:34 -0600 Subject: [PATCH 074/104] More updates for oxidation, more doc pages --- doc/src/compute_nbond_atom.rst | 13 ++++++- doc/src/fix_rheo_pressure.rst | 45 ++++++++++++++++++---- doc/src/fix_rheo_thermal.rst | 51 +++++++++++++++---------- doc/src/fix_rheo_viscosity.rst | 44 +++++++++++---------- src/BPM/compute_nbond_atom.cpp | 16 +++++++- src/BPM/compute_nbond_atom.h | 2 +- src/RHEO/bond_rheo_shell.cpp | 17 ++++++++- src/RHEO/bond_rheo_shell.h | 2 + src/RHEO/compute_rheo_property_atom.cpp | 23 ++++++++++- src/RHEO/compute_rheo_property_atom.h | 1 + src/RHEO/fix_rheo.cpp | 3 ++ src/RHEO/fix_rheo.h | 1 + src/RHEO/fix_rheo_oxidation.cpp | 42 ++++++++++---------- src/RHEO/fix_rheo_oxidation.h | 7 ++-- 14 files changed, 188 insertions(+), 79 deletions(-) diff --git a/doc/src/compute_nbond_atom.rst b/doc/src/compute_nbond_atom.rst index f438836534..274d958a10 100644 --- a/doc/src/compute_nbond_atom.rst +++ b/doc/src/compute_nbond_atom.rst @@ -8,10 +8,17 @@ Syntax .. code-block:: LAMMPS - compute ID group-ID nbond/atom + compute ID group-ID nbond/atom keyword value * ID, group-ID are documented in :doc:`compute ` command * nbond/atom = style name of this compute command +* zero or more keyword/value pairs may be appended +* keyword = *bond/type* + + .. parsed-literal:: + + *bond/type* value = *btype* + *btype* = bond type included in count Examples """""""" @@ -19,6 +26,7 @@ Examples .. code-block:: LAMMPS compute 1 all nbond/atom + compute 1 all nbond/atom bond/type 2 Description """"""""""" @@ -31,6 +39,9 @@ the :doc:`Howto broken bonds ` page for more information. The number of bonds will be zero for atoms not in the specified compute group. This compute does not depend on Newton bond settings. +If the keyword *bond/type* is specified, only bonds of *btype* are +counted. + Output info """"""""""" diff --git a/doc/src/fix_rheo_pressure.rst b/doc/src/fix_rheo_pressure.rst index d31c305c20..2edd703299 100644 --- a/doc/src/fix_rheo_pressure.rst +++ b/doc/src/fix_rheo_pressure.rst @@ -8,12 +8,13 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo/pressure style args + fix ID group-ID rheo/pressure type1 pstyle1 args1 ... typeN pstyleN argsN * ID, group-ID are documented in :doc:`fix ` command * rheo/pressure = style name of this fix command +* one or more types and pressure styles must be appended * types = lists of types (see below) -* style = *linear* or *taitwater* or *cubic* +* pstyle = *linear* or *taitwater* or *cubic* .. parsed-literal:: @@ -32,10 +33,41 @@ Examples Description """"""""""" -This fix... +This fix defines a pressure equation of state for RHEO particles. One can +define different equations of state for different atom types, but an +equation must be specified for every atom type. -Only one instance of fix rheo/pressure can be defined and the fix group must be set to all. +One first defines the atom *types*. A wild-card asterisk can be used in place +of or in conjunction with the *types* argument to set the coefficients for +multiple pairs of atom types. This takes the form "\*" or "\*n" or "m\*" +or "m\*n". If :math:`N` is the number of atom types, then an asterisk with +no numeric values means all types from 1 to :math:`N`. A leading asterisk +means all types from 1 to n (inclusive). A trailing asterisk means all types +from m to :math:`N` (inclusive). A middle asterisk means all types from m to n +(inclusive). +The *types* definition is followed by the pressure style, *pstyle*. Current +options *linear*, *taitwater*, and *cubic*. Style *linear* is a linear +equation of state with a particle pressure :math:`P` calculated as + +.. math:: + + P = c (\rho - \rho_0) + +where :math:`c` is the speed of sound, :math:`\rho_0` is the equilibrium density, +and :math:`\rho` is the current density of a particle. The numerical values of +:math:`c` and :math:`\rho_0` are set in :doc:`fix rheo `. Style *cubic* +is a cubic equation of state which has an extra argument :math:`A_3`, + +.. math:: + + P = c ((\rho - \rho_0) + A_3 (\rho - \rho_0)^3) . + +Style *taitwater* is Tait's equation of state: + +.. math:: + + P = \frac{c^2 \rho_0}{7} \biggl[\left(\frac{\rho}{\rho_0}\right)^{7} - 1\biggr]. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -52,7 +84,7 @@ Restrictions This fix must be used with an atom style that includes density such as atom_style rheo or rheo/thermal. This fix must be used in conjuction with :doc:`fix rheo `. The fix group must be -set to all. +set to all. Only one instance of fix rheo/pressure can be defined. This fix is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. @@ -60,8 +92,7 @@ LAMMPS was built with that package. See the :doc:`Build package Related commands """""""""""""""" -:doc:`fix rheo/viscosity `, -:doc:`fix rheo/thermal `, +:doc:`fix rheo `, :doc:`pair rheo `, :doc:`compute rheo/property/atom ` diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst index b73aeb248e..2ece5521bc 100644 --- a/doc/src/fix_rheo_thermal.rst +++ b/doc/src/fix_rheo_thermal.rst @@ -48,26 +48,38 @@ Examples Description """"""""""" -This fix... +This fix performs time integration of temperature evolution for atom style +rheo/thermal. In addition, it defines multiple thermal properties of +particles and handles melting/solidification, if applicable. For more details +on phase transitions in RHEO, see :doc:`the RHEO howto `. -Each list consists of a series of type -ranges separated by commas. The range can be specified as a -single numeric value, or a wildcard asterisk can be used to specify a range -of values. This takes the form "\*" or "\*n" or "n\*" or "m\*n". For -example, if M = the number of atom types, then an asterisk with no numeric -values means all types from 1 to M. A leading asterisk means all types -from 1 to n (inclusive). A trailing asterisk means all types from n to M -(inclusive). A middle asterisk means all types from m to n (inclusive). -Note that all atom types must be included in exactly one of the N collections. +For each atom type, one can define attributes for the *conductivity*, +*specific/heat*, *latent/heat*, and critical temperature (*Tfreeze*). +The conductivity and specific heat must be defined for all atom types. +The latent heat and critical temperature are optional. However, a +critical temperature must be defined to specify a latent heat. -While the *Tfreeze* keyword is optional, the *conductivity* and -*specific/heat* keywords are mandatory. +For each property, one must first define a list of atom types. A wild-card +asterisk can be used in place of or in conjunction with the *types* argument +to set the coefficients for multiple pairs of atom types. This takes the +form "\*" or "\*n" or "m\*" or "m\*n". If :math:`N` is the number of atom +types, then an asterisk with no numeric values means all types from 1 to +:math:`N`. A leading asterisk means all types from 1 to n (inclusive). +A trailing asterisk means all types from m to :math:`N` (inclusive). A +middle asterisk means all types from m to n (inclusive). -Multiple instances of this fix may be defined to apply different -properties to different groups. However, the union of fix groups -across all instances of fix rheo/thermal must cover all atoms. -If there are multiple instances of this fix, any intersections in -the fix groups will lead to incorrect thermal integration. +The *types* definition for each property is followed by the style. Currently, +the only option is *constant*. Style *constant* simply applies a constant value +of respective property to each particle of the assigned type. + +The *react* keyword controls whether bonds are created/deleted when particles +transition between a fluid and solid state. This option only applies to atom +types that have a defined value of *Tfreeze*. When a fluid particle's +temperature drops below *Tfreeze*, bonds of type *btype* are created between +nearby solid particles within a distance of *cut*. The particle's status also +swaps to a solid state. When a solid particle's temperature rises above +*Tfreeze*, all bonds of type *btype* are broken and the particle's tatus swaps +to a fluid state. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -84,7 +96,8 @@ Restrictions This fix must be used with an atom style that includes temperature, heatflow, and conductivity such as atom_tyle rheo/thermal This fix must be used in conjuction with :doc:`fix rheo ` with the -*thermal* setting. +*thermal* setting. The fix group must be set to all. Only one +instance of fix rheo/pressure can be defined. This fix is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. @@ -93,8 +106,6 @@ Related commands """""""""""""""" :doc:`fix rheo `, -:doc:`fix rheo/viscosity `, -:doc:`fix rheo/pressure `, :doc:`pair rheo `, :doc:`compute rheo/property/atom ` diff --git a/doc/src/fix_rheo_viscosity.rst b/doc/src/fix_rheo_viscosity.rst index 379b002de1..64c6539acc 100644 --- a/doc/src/fix_rheo_viscosity.rst +++ b/doc/src/fix_rheo_viscosity.rst @@ -8,22 +8,18 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo/viscosity types style args ... + fix ID group-ID rheo/viscosity type1 pstyle1 args1 ... typeN pstyleN argsN * ID, group-ID are documented in :doc:`fix ` command * rheo/viscosity = style name of this fix command +* one or more types and viscosity styles must be appended * types = lists of types (see below) -* style = *constant* or *power* +* vstyle = *constant* .. parsed-literal:: - *constant* args = viscosity (mass/(length*time)) - *power* args = *eta* *gd0* *K* *npow* *tau0* - *eta* = (units) - *gd0* = (units) - *K* = (units) - *npow* = (units) - *tau0* = (units) + *constant* args = *eta* + *eta* = viscosity Examples """""""" @@ -31,20 +27,27 @@ Examples .. code-block:: LAMMPS fix 1 all rheo/viscosity * constant 1.0 - fix 1 all rheo/viscosity 1 constant 1.0 2 power 0.1 1e-2 0.5 0.01 + fix 1 all rheo/viscosity 1 constant 1.0 2 constant 2.0 Description """"""""""" -This fix... +This fix defines a viscosity for RHEO particles. One can define different +viscosities for different atom types, but a viscosity must be specified for +every atom type. -Multiple instances of this fix may be defined to apply different -properties to different groups. However, the union of fix groups -across all instances of fix rheo/viscosity must cover all atoms. -If there are multiple instances of this fix, any intersection -between fix groups will cause the viscosity for the affected atoms -to be calculated multiple times. Any such affected atoms will enabled -up with a viscosity calculated by the latest defined fix. +One first defines the atom *types*. A wild-card asterisk can be used in place +of or in conjunction with the *types* argument to set the coefficients for +multiple pairs of atom types. This takes the form "\*" or "\*n" or "m\*" +or "m\*n". If :math:`N` is the number of atom types, then an asterisk with +no numeric values means all types from 1 to :math:`N`. A leading asterisk +means all types from 1 to n (inclusive). A trailing asterisk means all types +from m to :math:`N` (inclusive). A middle asterisk means all types from m to n +(inclusive). + +The *types* definition is followed by the viscosity style, *vstyle*. Currently, +the only option is *constant*. Style *constant* simply applies a constant value +of the viscosity *eta* to each particle of the assigned type. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -60,7 +63,8 @@ Restrictions This fix must be used with an atom style that includes viscosity such as atom_style rheo or rheo/thermal. This fix must be used in -conjuction with :doc:`fix rheo `. +conjuction with :doc:`fix rheo `. The fix group must be +set to all. Only one instance of fix rheo/viscosity can be defined. This fix is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. @@ -69,8 +73,6 @@ Related commands """""""""""""""" :doc:`fix rheo `, -:doc:`fix rheo/pressure `, -:doc:`fix rheo/thermal `, :doc:`pair rheo `, :doc:`compute rheo/property/atom ` diff --git a/src/BPM/compute_nbond_atom.cpp b/src/BPM/compute_nbond_atom.cpp index 4f0fc4c3f0..af1cc2b9bc 100644 --- a/src/BPM/compute_nbond_atom.cpp +++ b/src/BPM/compute_nbond_atom.cpp @@ -25,7 +25,20 @@ using namespace LAMMPS_NS; ComputeNBondAtom::ComputeNBondAtom(LAMMPS *_lmp, int narg, char **arg) : Compute(_lmp, narg, arg), nbond(nullptr) { - if (narg < 3) utils::missing_cmd_args(FLERR, "compute nbond/atom", error); + if (narg < 4) utils::missing_cmd_args(FLERR, "compute nbond/atom", error); + + btype = -1; + + iarg = 3; + while (iarg < narg) { + if (strcmp(arg[iarg], "bond/type") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute nbond/atom bond/type", error); + btype = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); + iarg += 2; + } else { + error->all(FLERR, "Unknown compute nbond/type command {}", arg[iarg]); + } + } peratom_flag = 1; size_peratom_cols = 0; @@ -78,6 +91,7 @@ void ComputeNBondAtom::compute_peratom() for (i = 0; i < nlocal; i++) { for (j = 0; j < num_bond[i]; j++) { if (bond_type[i][j] <= 0) continue; + if (btype != -1 && bond_type[i][j] != btype) continue; k = atom->map(bond_atom[i][j]); if (k < 0) continue; diff --git a/src/BPM/compute_nbond_atom.h b/src/BPM/compute_nbond_atom.h index e0c2d7ce01..b55ef91e5d 100644 --- a/src/BPM/compute_nbond_atom.h +++ b/src/BPM/compute_nbond_atom.h @@ -35,7 +35,7 @@ class ComputeNBondAtom : public Compute { double memory_usage() override; private: - int nmax; + int nmax, btype; double *nbond; }; diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp index 6a71136d9d..d366163459 100644 --- a/src/RHEO/bond_rheo_shell.cpp +++ b/src/RHEO/bond_rheo_shell.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "comm.h" +#include "compute_rheo_surface.h" #include "domain.h" #include "error.h" #include "fix_bond_history.h" @@ -42,7 +43,7 @@ using namespace RHEO_NS; /* ---------------------------------------------------------------------- */ BondRHEOShell::BondRHEOShell(LAMMPS *_lmp) : - BondBPM(_lmp), k(nullptr), ecrit(nullptr), gamma(nullptr) + BondBPM(_lmp), compute_surface(nullptr), k(nullptr), ecrit(nullptr), gamma(nullptr) { partial_flag = 1; comm_reverse = 1; @@ -279,7 +280,7 @@ void BondRHEOShell::compute(int eflag, int vflag) // Communicate changes in nbond if (newton_bond) comm->reverse_comm(this); - for(i = 0; i < nlocal; i++) { + for(int i = 0; i < nlocal; i++) { nbond[i] += dbond[i]; // If it has bonds, no shifting @@ -341,6 +342,18 @@ void BondRHEOShell::init_style() if (comm->ghost_velocity == 0) error->all(FLERR, "Bond rheo/shell requires ghost atoms store velocity"); + auto fixes = modify->get_fix_by_style("^rheo$"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use bond rheo/shell"); + class FixRHEO *fix_rheo = dynamic_cast(fixes[0]); + + if (!fix_rheo->surface_flag) error->all(FLERR, + "Bond rheo/shell requires surface calculation in fix rheo"); + compute_surface = fix_rheo->compute_surface; + + if (fix_rheo->oxidation_fix_defined != 1) + error->all(FLERR, "Need to define fix rheo/oxdiation to use bond rheo/shell"); + // check consistency in values (copy?), swap conditions to rsurf + if (!id_fix_bond_history) { id_fix_bond_history = utils::strdup("HISTORY_RHEO_SHELL"); fix_bond_history = dynamic_cast(modify->replace_fix( diff --git a/src/RHEO/bond_rheo_shell.h b/src/RHEO/bond_rheo_shell.h index 513d481eeb..a6a747a3f1 100644 --- a/src/RHEO/bond_rheo_shell.h +++ b/src/RHEO/bond_rheo_shell.h @@ -49,6 +49,8 @@ class BondRHEOShell : public BondBPM { int index_nb, nmax_store; char *id_fix; + class ComputeRHEOSurface *compute_surface; + void process_ineligibility(int, int); void allocate(); void store_data(); diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 2d6ff1e55a..bdc9951f90 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -29,6 +29,7 @@ #include "domain.h" #include "error.h" #include "fix_rheo.h" +#include "fix_rheo_oxidation.h" #include "fix_rheo_pressure.h" #include "fix_rheo_thermal.h" #include "memory.h" @@ -177,6 +178,11 @@ void ComputeRHEOPropertyAtom::init() fixes = modify->get_fix_by_style("rheo/pressure"); fix_pressure = dynamic_cast(fixes[0]); } + + if (shell_flag) { + fixes = modify->get_fix_by_style("rheo/oxidation"); + fix_oxidation = dynamic_cast(fixes[0]); + } } /* ---------------------------------------------------------------------- */ @@ -381,6 +387,21 @@ void ComputeRHEOPropertyAtom::pack_pressure(int n) /* ---------------------------------------------------------------------- */ +void ComputeRHEOPropertyAtom::pack_nbond_shell(int n) +{ + int *nbond = fix_oxidation->nbond; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = nbond[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + void ComputeRHEOPropertyAtom::pack_shift_v(int n) { double **vshift = compute_vshift->vshift; @@ -415,7 +436,7 @@ void ComputeRHEOPropertyAtom::pack_gradv(int n) void ComputeRHEOPropertyAtom::pack_atom_style(int n) { - atom->avec->pack_property_atom(avec_index[n],&buf[n],nvalues,groupbit); + atom->avec->pack_property_atom(avec_index[n], &buf[n], nvalues, groupbit); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index fd73b5883f..a66ef4ece6 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -63,6 +63,7 @@ class ComputeRHEOPropertyAtom : public Compute { class FixRHEO *fix_rheo; class FixRHEOPressure *fix_pressure; class FixRHEOThermal *fix_thermal; + class FixRHEOOxidation *fix_oxidation; class ComputeRHEOInterface *compute_interface; class ComputeRHEOKernel *compute_kernel; class ComputeRHEOSurface *compute_surface; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index b0cb1513fc..04b7d33541 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -48,12 +48,14 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : viscosity_fix_defined = 0; pressure_fix_defined = 0; thermal_fix_defined = 0; + oxidation_fix_defined = 0; thermal_flag = 0; rhosum_flag = 0; shift_flag = 0; interface_flag = 0; surface_flag = 0; + oxidation_flag = 0; int i; int n = atom->ntypes; @@ -252,6 +254,7 @@ void FixRHEO::setup(int /*vflag*/) thermal_fix_defined = 0; viscosity_fix_defined = 0; pressure_fix_defined = 0; + oxidation_fix_defined = 0; // Check fixes cover all atoms (may still fail if atoms are created) // FixRHEOPressure currently requires group all diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 33fd0084db..45f74ed4cd 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -51,6 +51,7 @@ class FixRHEO : public Fix { int shift_flag; int interface_flag; int surface_flag; + int oxidation_flag; int viscosity_fix_defined; int pressure_fix_defined; diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index 1628cef13f..f536df7842 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "atom_vec.h" +#include "compute_rheo_surface.h" #include "error.h" #include "fix_rheo.h" #include "force.h" @@ -36,9 +37,9 @@ enum {NONE, CONSTANT}; /* ---------------------------------------------------------------------- */ FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) //, fix_bond_history(nullptr) + Fix(lmp, narg, arg), compute_surface(nullptr), fix_rheo(nullptr) { - if (narg != 5) error->all(FLERR,"Illegal fix command"); + if (narg != 6) error->all(FLERR,"Illegal fix command"); cut = utils::numeric(FLERR, arg[3], false, lmp); if (cut <= 0.0) error->all(FLERR, "Illegal bond cutoff {} in fix rheo/oxidation", cut); @@ -46,6 +47,9 @@ FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) : btype = utils::inumeric(FLERR, arg[4], false, lmp); if (btype < 1 || btype > atom->nbondtypes) error->all(FLERR, "Illegal value {} for bond type in fix rheo/oxidation", btype); + rsurf = utils::numeric(FLERR, arg[5], false, lmp); + if (rsurf <= 0.0) error->all(FLERR, "Illegal surface distance {} in fix rheo/oxidation", cut); + cutsq = cut * cut; } @@ -72,22 +76,21 @@ void FixRHEOOxidation::init() auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/oxidation"); fix_rheo = dynamic_cast(fixes[0]); - double cut_kernel = fix_rheo->h; - if (cut > cut_kernel) + if (cut > fix_rheo->h) error->all(FLERR, "Bonding length exceeds kernel cutoff"); + if (rsurf >= fix_rheo->h) + error->all(FLERR, "Surface distance must be less than kernel cutoff"); + if (!force->bond) error->all(FLERR, "Must define a bond style with fix rheo/oxidation"); if (!atom->avec->bonds_allow) error->all(FLERR, "Fix rheo/oxidation requires atom bonds"); - //// find instances of bond history to delete data - //histories = modify->get_fix_by_style("BOND_HISTORY"); - //for (auto &ihistory: histories) - // if (strcmp(histories[i]->id, "HISTORY_RHEO_SHELL") == 0) - // fix_bond_history = dynamic_cast(ihistory); -// - //if (!fix_bond_history) - // error->all(FLERR, "Must define bond style rheo/shell to use fix rheo/oxidation"); + int tmp1, tmp2; + index_nb = atom->find_custom("shell_nbond", tmp1, tmp2); + if (index_nb == -1) + error->all(FLERR, "Must use bond style rheo/shell to use fix rheo/oxidation"); + nbond = atom->ivector[index_nb]; // need a half neighbor list auto req = neighbor->add_request(this, NeighConst::REQ_DEFAULT); @@ -111,13 +114,14 @@ void FixRHEOOxidation::setup_pre_force(int /*vflag*/) if (!fix_rheo->surface_flag) error->all(FLERR, "fix rheo/oxidation requires surface calculation in fix rheo"); + compute_surface = fix_rheo->compute_surface; pre_force(0); } /* ---------------------------------------------------------------------- */ -void FixRHEOThermal::pre_force(int /*vflag*/) +void FixRHEOOxidation::pre_force(int /*vflag*/) { } @@ -135,9 +139,9 @@ void FixRHEOOxidation::post_integrate() tagint *tag = atom->tag; tagint **bond_atom = atom->bond_atom; - int *status = atom->status; int **bond_type = atom->bond_type; int *num_bond = atom->num_bond; + double *rsurface = compute_surface->rsurface; double **x = atom->x; inum = list->inum; @@ -148,7 +152,7 @@ void FixRHEOOxidation::post_integrate() // loop over neighbors of my atoms for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - if (!(status[i] & STATUS_SURFACE)) continue; + if (rsurface[i] > rsurf) continue; tagi = tag[i]; xtmp = x[i][0]; @@ -162,7 +166,7 @@ void FixRHEOOxidation::post_integrate() j = jlist[jj]; j &= NEIGHMASK; - if (!(status[j] & STATUS_SURFACE)) continue; + if (rsurface[j] > rsurf) continue; tagj = tag[j]; delx = xtmp - x[j][0]; @@ -208,10 +212,4 @@ void FixRHEOOxidation::post_integrate() } } } - - //todo: - // allow option to create near-surface bonds - // extract # of bonds in property/atom - // check bond style shell used, get index to bonds, share with compute property atom - // add type option to compute nbond/atom } diff --git a/src/RHEO/fix_rheo_oxidation.h b/src/RHEO/fix_rheo_oxidation.h index ca36a6fdf9..5242d24460 100644 --- a/src/RHEO/fix_rheo_oxidation.h +++ b/src/RHEO/fix_rheo_oxidation.h @@ -36,14 +36,15 @@ class FixRHEOOxidation : public Fix { void setup_pre_force(int) override; void pre_force(int) override; void post_integrate() override; + int *nbond; private: - int btype; - double cut, cutsq; + int btype, index_nb; + double rsurf, cut, cutsq; class NeighList *list; + class ComputeRHEOSurface *compute_surface; class FixRHEO *fix_rheo; - //class FixBondHistory *fix_bond_history; }; } // namespace LAMMPS_NS From ceec24d50b353527d8ff52d85e916fcb103a1475 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 4 Apr 2024 09:42:10 -0600 Subject: [PATCH 075/104] Adding hybrid support to BPM, more doc pages --- doc/src/pair_rheo_solid.rst | 76 +++++++++++++--- src/BPM/bond_bpm.cpp | 112 +++++++++++++++--------- src/BPM/bond_bpm.h | 11 ++- src/BPM/bond_bpm_rotational.cpp | 17 ++-- src/BPM/bond_bpm_spring.cpp | 19 ++-- src/BPM/compute_nbond_atom.cpp | 12 ++- src/RHEO/bond_rheo_shell.cpp | 85 ++++++++---------- src/RHEO/bond_rheo_shell.h | 2 +- src/RHEO/compute_rheo_property_atom.cpp | 13 +-- src/RHEO/compute_rheo_property_atom.h | 1 + src/RHEO/fix_rheo_oxidation.h | 5 +- src/RHEO/fix_rheo_thermal.cpp | 13 +-- src/RHEO/pair_rheo_solid.cpp | 4 + src/fix_bond_history.cpp | 96 ++++++++++++++++---- src/fix_bond_history.h | 13 ++- 15 files changed, 322 insertions(+), 157 deletions(-) diff --git a/doc/src/pair_rheo_solid.rst b/doc/src/pair_rheo_solid.rst index b6ff6d809d..ee86992776 100644 --- a/doc/src/pair_rheo_solid.rst +++ b/doc/src/pair_rheo_solid.rst @@ -21,36 +21,88 @@ Examples Description """"""""""" -pair style... +Style *rheo/solid* is effectively a copy of pair style +:doc:`bpm/spring ` except it only applies forces +between solid RHEO particles, determined by checking the status of +each pair of neighboring particles before calculating forces. + +The style computes pairwise forces with the formula + +.. math:: + + F = k (r - r_c) + +where :math:`k` is a stiffness and :math:`r_c` is the cutoff length. +An additional damping force is also applied to interacting +particles. The force is proportional to the difference in the +normal velocity of particles + +.. math:: + + F_D = - \gamma w (\hat{r} \bullet \vec{v}) + +where :math:`\gamma` is the damping strength, :math:`\hat{r}` is the +radial normal vector, :math:`\vec{v}` is the velocity difference +between the two particles, and :math:`w` is a smoothing factor. +This smoothing factor is constructed such that damping forces go to zero +as particles come out of contact to avoid discontinuities. It is +given by + +.. math:: + + w = 1.0 - \left( \frac{r}{r_c} \right)^8 . + +The following coefficients must be defined for each pair of atom types +via the :doc:`pair_coeff ` command as in the examples +above, or in the data file or restart files read by the +:doc:`read_data ` or :doc:`read_restart ` +commands, or by mixing as described below: + +* :math:`k` (force/distance units) +* :math:`r_c` (distance units) +* :math:`\gamma` (force/velocity units) -* :math:`k` (force/distance units) -* :math:`\sigma` (distance units) -* :math:`\gamma` (force/velocity units) ---------- Mixing, shift, table, tail correction, restart, rRESPA info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -This style does not support the :doc:`pair_modify ` -shift, table, and tail options. +For atom type pairs I,J and I != J, the A coefficient and cutoff +distance for this pair style can be mixed. A is always mixed via a +*geometric* rule. The cutoff is mixed according to the pair_modify +mix value. The default mix value is *geometric*\ . See the +"pair_modify" command for details. -This style does not write information to :doc:`binary restart files `. Thus, you need to re-specify the pair_style and -pair_coeff commands in an input script that reads a restart file. +This pair style does not support the :doc:`pair_modify ` +shift option, since the pair interaction goes to 0.0 at the cutoff. -This style can only be used via the *pair* keyword of the :doc:`run_style respa ` command. It does not support the *inner*, *middle*, *outer* keywords. +The :doc:`pair_modify ` table and tail options are not +relevant for this pair style. + +This pair style writes its information to :doc:`binary restart files +`, so pair_style and pair_coeff commands do not need to be +specified in an input script that reads a restart file. + +This pair style can only be used via the *pair* keyword of the +:doc:`run_style respa ` command. It does not support the +*inner*, *middle*, *outer* keywords. + +---------- Restrictions """""""""""" -This fix is part of the RHEO package. It is only enabled if -LAMMPS was built with that package. See the :doc:`Build package ` page for more info. +This pair style is part of the BPM 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 rheo `, -:doc:`pair bpm/spring `, +:doc:`fix rheo/thermal `, +:doc:`pair bpm/spring ` Default """"""" diff --git a/src/BPM/bond_bpm.cpp b/src/BPM/bond_bpm.cpp index 34554497ad..351cff1420 100644 --- a/src/BPM/bond_bpm.cpp +++ b/src/BPM/bond_bpm.cpp @@ -17,6 +17,7 @@ #include "comm.h" #include "domain.h" #include "error.h" +#include "fix.h" #include "fix_bond_history.h" #include "fix_store_local.h" #include "fix_update_special_bonds.h" @@ -39,10 +40,14 @@ BondBPM::BondBPM(LAMMPS *_lmp) : pack_choice(nullptr), output_data(nullptr) { overlay_flag = 0; + ignore_special_flag = 0; prop_atom_flag = 0; break_flag = 1; nvalues = 0; + nhistory = 0; + update_flag = 0; + r0_max_estimate = 0.0; max_stretch = 1.0; @@ -93,39 +98,46 @@ void BondBPM::init_style() fix_store_local->nvalues = nvalues; } - if (overlay_flag) { - if (force->special_lj[1] != 1.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0 || - force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 || force->special_coul[3] != 1.0) - error->all(FLERR, - "With overlay/pair yes, BPM bond styles require a value of 1.0 for all special_bonds weights"); - if (id_fix_update) { - modify->delete_fix(id_fix_update); - delete[] id_fix_update; - id_fix_update = nullptr; - } - } else { - // Require atoms know about all of their bonds and if they break - if (force->newton_bond && break_flag) - error->all(FLERR, "With overlay/pair no, or break yes, BPM bond styles require Newton bond off"); + if (!ignore_special_flag) { + if (overlay_flag) { + if (force->special_lj[1] != 1.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0 || + force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 || force->special_coul[3] != 1.0) + error->all(FLERR, + "With overlay/pair yes, BPM bond styles require a value of 1.0 for all special_bonds weights"); + if (id_fix_update) { + modify->delete_fix(id_fix_update); + delete[] id_fix_update; + id_fix_update = nullptr; + } + } else { + // Require atoms know about all of their bonds and if they break + if (force->newton_bond && break_flag) + error->all(FLERR, "With overlay/pair no, or break yes, BPM bond styles require Newton bond off"); - // special lj must be 0 1 1 to censor pair forces between bonded particles - if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0) - error->all(FLERR, - "With overlay/pair no, BPM bond styles require special LJ weights = 0,1,1"); - // if bonds can break, special coulomb must be 1 1 1 to ensure all pairs are included in the - // neighbor list and 1-3 and 1-4 special bond lists are skipped - if (break_flag && (force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 || - force->special_coul[3] != 1.0)) - error->all(FLERR, - "With overlay/pair no, and break yes, BPM bond styles requires special Coulomb weights = 1,1,1"); + // special lj must be 0 1 1 to censor pair forces between bonded particles + if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0) + error->all(FLERR, + "With overlay/pair no, BPM bond styles require special LJ weights = 0,1,1"); + // if bonds can break, special coulomb must be 1 1 1 to ensure all pairs are included in the + // neighbor list and 1-3 and 1-4 special bond lists are skipped + if (break_flag && (force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 || + force->special_coul[3] != 1.0)) + error->all(FLERR, + "With overlay/pair no, and break yes, BPM bond styles requires special Coulomb weights = 1,1,1"); - if (id_fix_dummy && break_flag) { - id_fix_update = utils::strdup("BPM_UPDATE_SPECIAL_BONDS"); - fix_update_special_bonds = dynamic_cast(modify->replace_fix( - id_fix_dummy, fmt::format("{} all UPDATE_SPECIAL_BONDS", id_fix_update), 1)); - delete[] id_fix_dummy; - id_fix_dummy = nullptr; + if (id_fix_dummy && break_flag) { + id_fix_update = utils::strdup("BPM_UPDATE_SPECIAL_BONDS"); + fix_update_special_bonds = dynamic_cast(modify->replace_fix( + id_fix_dummy, fmt::format("{} all UPDATE_SPECIAL_BONDS", id_fix_update), 1)); + delete[] id_fix_dummy; + id_fix_dummy = nullptr; + } } + + // special 1-3 and 1-4 weights must be 1 to prevent building 1-3 and 1-4 special bond lists + if (force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0 || force->special_coul[2] != 1.0 || + force->special_coul[3] != 1.0) + error->all(FLERR, "Bond style bpm requires 1-3 and 1-4 special weights of 1.0"); } if (force->angle || force->dihedral || force->improper) @@ -133,10 +145,16 @@ void BondBPM::init_style() if (atom->molecular == 2) error->all(FLERR, "Bond style bpm cannot be used with atom style template"); - // special 1-3 and 1-4 weights must be 1 to prevent building 1-3 and 1-4 special bond lists - if (force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0 || force->special_coul[2] != 1.0 || - force->special_coul[3] != 1.0) - error->all(FLERR, "Bond style bpm requires 1-3 and 1-4 special weights of 1.0"); + // find all instances of bond history to delete/shift data + // (bond hybrid may create multiple) + histories = modify->get_fix_by_style("BOND_HISTORY"); + n_histories = histories.size(); + + // If a bond type isn't set, must be using bond style hybrid + hybrid_flag = 0; + for (int i = 1; i <= atom->nbondtypes; i++) + if (!setflag[i]) hybrid_flag = 1; + fix_bond_history->setflag = setflag; } /* ---------------------------------------------------------------------- @@ -253,6 +271,14 @@ void BondBPM::settings(int narg, char **arg) } } } + + // Set up necessary history fix + if (!fix_bond_history) { + fix_bond_history = dynamic_cast(modify->replace_fix( + id_fix_dummy2, fmt::format("{} all BOND_HISTORY {} {}", id_fix_bond_history, update_flag, nhistory), 1)); + delete[] id_fix_dummy2; + id_fix_dummy2 = nullptr; + } } /* ---------------------------------------------------------------------- @@ -356,13 +382,16 @@ void BondBPM::process_broken(int i, int j) if (i < nlocal) { for (m = 0; m < num_bond[i]; m++) { - if (bond_atom[i][m] == tag[j]) { + if (bond_atom[i][m] == tag[j] && setflag[bond_type[i][m]]) { bond_type[i][m] = 0; n = num_bond[i]; bond_type[i][m] = bond_type[i][n - 1]; bond_atom[i][m] = bond_atom[i][n - 1]; - fix_bond_history->shift_history(i, m, n - 1); - fix_bond_history->delete_history(i, n - 1); + for (auto &ihistory: histories) { + auto fix_bond_history2 = dynamic_cast (ihistory); + fix_bond_history2->shift_history(i, m, n - 1); + fix_bond_history2->delete_history(i, n - 1); + } num_bond[i]--; break; } @@ -371,13 +400,16 @@ void BondBPM::process_broken(int i, int j) if (j < nlocal) { for (m = 0; m < num_bond[j]; m++) { - if (bond_atom[j][m] == tag[i]) { + if (bond_atom[j][m] == tag[i] && setflag[bond_type[j][m]]) { bond_type[j][m] = 0; n = num_bond[j]; bond_type[j][m] = bond_type[j][n - 1]; bond_atom[j][m] = bond_atom[j][n - 1]; - fix_bond_history->shift_history(j, m, n - 1); - fix_bond_history->delete_history(j, n - 1); + for (auto &ihistory: histories) { + auto fix_bond_history2 = dynamic_cast (ihistory); + fix_bond_history2->shift_history(j, m, n - 1); + fix_bond_history2->delete_history(j, n - 1); + } num_bond[j]--; break; } diff --git a/src/BPM/bond_bpm.h b/src/BPM/bond_bpm.h index 815b3b751f..28e4e7187e 100644 --- a/src/BPM/bond_bpm.h +++ b/src/BPM/bond_bpm.h @@ -16,8 +16,12 @@ #include "bond.h" +#include + namespace LAMMPS_NS { +class Fix; + class BondBPM : public Bond { public: BondBPM(class LAMMPS *); @@ -34,7 +38,7 @@ class BondBPM : public Bond { protected: double r0_max_estimate; double max_stretch; - int store_local_freq; + int store_local_freq, nhistory, update_flag, hybrid_flag; std::vector leftover_iarg; @@ -50,9 +54,12 @@ class BondBPM : public Bond { FnPtrPack *pack_choice; // ptrs to pack functions double *output_data; - int prop_atom_flag, nvalues, overlay_flag, break_flag; + int prop_atom_flag, nvalues, overlay_flag, break_flag, ignore_special_flag; int index_x_ref, index_y_ref, index_z_ref; + int n_histories; + std::vector histories; + void pack_id1(int, int, int); void pack_id2(int, int, int); void pack_time(int, int, int); diff --git a/src/BPM/bond_bpm_rotational.cpp b/src/BPM/bond_bpm_rotational.cpp index ffb0d9521d..b904a2ac07 100644 --- a/src/BPM/bond_bpm_rotational.cpp +++ b/src/BPM/bond_bpm_rotational.cpp @@ -52,6 +52,9 @@ BondBPMRotational::BondBPMRotational(LAMMPS *_lmp) : smooth_flag = 1; normalize_flag = 0; + nhistory = 4; + id_fix_bond_history = utils::strdup("HISTORY_BPM_ROTATIONAL"); + single_extra = 7; svector = new double[7]; } @@ -458,6 +461,9 @@ void BondBPMRotational::compute(int eflag, int vflag) store_data(); } + if (hybrid_flag) + fix_bond_history->compress_history(); + int i1, i2, itmp, n, type; double r[3], r0[3], rhat[3]; double rsq, r0_mag, r_mag, r_mag_inv; @@ -563,6 +569,9 @@ void BondBPMRotational::compute(int eflag, int vflag) ev_tally_xyz(i1, i2, nlocal, newton_bond, 0.0, -force1on2[0] * smooth, -force1on2[1] * smooth, -force1on2[2] * smooth, r[0], r[1], r[2]); } + + if (hybrid_flag) + fix_bond_history->uncompress_history(); } /* ---------------------------------------------------------------------- */ @@ -652,14 +661,6 @@ void BondBPMRotational::init_style() if (domain->dimension == 2) error->warning(FLERR, "Bond style bpm/rotational not intended for 2d use"); - - if (!id_fix_bond_history) { - id_fix_bond_history = utils::strdup("HISTORY_BPM_ROTATIONAL"); - fix_bond_history = dynamic_cast(modify->replace_fix( - id_fix_dummy2, fmt::format("{} all BOND_HISTORY 0 4", id_fix_bond_history), 1)); - delete[] id_fix_dummy2; - id_fix_dummy2 = nullptr; - } } /* ---------------------------------------------------------------------- */ diff --git a/src/BPM/bond_bpm_spring.cpp b/src/BPM/bond_bpm_spring.cpp index 37b79f93fb..0c882ae6c6 100644 --- a/src/BPM/bond_bpm_spring.cpp +++ b/src/BPM/bond_bpm_spring.cpp @@ -23,6 +23,8 @@ #include "modify.h" #include "neighbor.h" +#include "update.h" + #include #include @@ -39,6 +41,9 @@ BondBPMSpring::BondBPMSpring(LAMMPS *_lmp) : smooth_flag = 1; normalize_flag = 0; + nhistory = 1; + id_fix_bond_history = utils::strdup("HISTORY_BPM_SPRING"); + single_extra = 1; svector = new double[1]; } @@ -137,6 +142,9 @@ void BondBPMSpring::compute(int eflag, int vflag) store_data(); } + if (hybrid_flag) + fix_bond_history->compress_history(); + int i1, i2, itmp, n, type; double delx, dely, delz, delvx, delvy, delvz; double e, rsq, r, r0, rinv, smooth, fbond, dot; @@ -226,6 +234,9 @@ void BondBPMSpring::compute(int eflag, int vflag) if (evflag) ev_tally(i1, i2, nlocal, newton_bond, 0.0, fbond, delx, dely, delz); } + + if (hybrid_flag) + fix_bond_history->uncompress_history(); } /* ---------------------------------------------------------------------- */ @@ -283,14 +294,6 @@ void BondBPMSpring::init_style() if (comm->ghost_velocity == 0) error->all(FLERR, "Bond bpm/spring requires ghost atoms store velocity"); - - if (!id_fix_bond_history) { - id_fix_bond_history = utils::strdup("HISTORY_BPM_SPRING"); - fix_bond_history = dynamic_cast(modify->replace_fix( - id_fix_dummy2, fmt::format("{} all BOND_HISTORY 0 1", id_fix_bond_history), 1)); - delete[] id_fix_dummy2; - id_fix_dummy2 = nullptr; - } } /* ---------------------------------------------------------------------- */ diff --git a/src/BPM/compute_nbond_atom.cpp b/src/BPM/compute_nbond_atom.cpp index af1cc2b9bc..b6e7b0139f 100644 --- a/src/BPM/compute_nbond_atom.cpp +++ b/src/BPM/compute_nbond_atom.cpp @@ -14,7 +14,9 @@ #include "compute_nbond_atom.h" #include "atom.h" +#include "atom_vec.h" #include "comm.h" +#include "error.h" #include "force.h" #include "memory.h" @@ -25,18 +27,20 @@ using namespace LAMMPS_NS; ComputeNBondAtom::ComputeNBondAtom(LAMMPS *_lmp, int narg, char **arg) : Compute(_lmp, narg, arg), nbond(nullptr) { - if (narg < 4) utils::missing_cmd_args(FLERR, "compute nbond/atom", error); + if (narg < 3) utils::missing_cmd_args(FLERR, "compute nbond/atom", error); + + if (atom->avec->bonds_allow == 0) + error->all(FLERR,"Compute nbond/atom used when bonds are not allowed"); btype = -1; - - iarg = 3; + int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg], "bond/type") == 0) { if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute nbond/atom bond/type", error); btype = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else { - error->all(FLERR, "Unknown compute nbond/type command {}", arg[iarg]); + error->all(FLERR, "Unknown compute nbond/atom command {}", arg[iarg]); } } diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp index d366163459..0a3caa1b4f 100644 --- a/src/RHEO/bond_rheo_shell.cpp +++ b/src/RHEO/bond_rheo_shell.cpp @@ -25,6 +25,7 @@ #include "error.h" #include "fix_bond_history.h" #include "fix_rheo.h" +#include "fix_rheo_oxidation.h" #include "fix_store_local.h" #include "force.h" #include "memory.h" @@ -48,7 +49,12 @@ BondRHEOShell::BondRHEOShell(LAMMPS *_lmp) : partial_flag = 1; comm_reverse = 1; - tform = rmax = -1; + nhistory = 2; + update_flag = 1; + id_fix_bond_history = utils::strdup("HISTORY_RHEO_SHELL"); + ignore_special_flag = 1; + + tform = -1; single_extra = 1; svector = new double[1]; @@ -155,12 +161,14 @@ void BondRHEOShell::store_data() void BondRHEOShell::compute(int eflag, int vflag) { - if (!fix_bond_history->stored_flag) { fix_bond_history->stored_flag = true; store_data(); } + if (hybrid_flag) + fix_bond_history->compress_history(); + int i1, i2, itmp, n, type; double delx, dely, delz, delvx, delvy, delvz; double e, rsq, r, r0, rinv, dr, fbond, dot, t; @@ -168,6 +176,7 @@ void BondRHEOShell::compute(int eflag, int vflag) ev_init(eflag, vflag); + double *rsurface = compute_surface->rsurface; double **x = atom->x; double **v = atom->v; double **f = atom->f; @@ -223,7 +232,7 @@ void BondRHEOShell::compute(int eflag, int vflag) if (t < tform) { // Check if eligible - if (r > rmax || !(status[i1] & STATUS_SURFACE) || !(status[i2] & STATUS_SURFACE)) { + if (r > rmax || rsurface[i1] > rsurf || rsurface[i2] > rsurf) { bondlist[n][2] = 0; process_ineligibility(i1, i2); continue; @@ -286,6 +295,9 @@ void BondRHEOShell::compute(int eflag, int vflag) // If it has bonds, no shifting if (nbond[i] != 0) status[i] |= STATUS_NO_SHIFT; } + + if (hybrid_flag) + fix_bond_history->uncompress_history(); } /* ---------------------------------------------------------------------- */ @@ -339,6 +351,8 @@ void BondRHEOShell::coeff(int narg, char **arg) void BondRHEOShell::init_style() { + BondBPM::init_style(); + if (comm->ghost_velocity == 0) error->all(FLERR, "Bond rheo/shell requires ghost atoms store velocity"); @@ -350,37 +364,12 @@ void BondRHEOShell::init_style() "Bond rheo/shell requires surface calculation in fix rheo"); compute_surface = fix_rheo->compute_surface; - if (fix_rheo->oxidation_fix_defined != 1) - error->all(FLERR, "Need to define fix rheo/oxdiation to use bond rheo/shell"); - // check consistency in values (copy?), swap conditions to rsurf + fixes = modify->get_fix_by_style("^rheo/oxidation$"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo/oxidation to use bond rheo/shell"); + class FixRHEOOxidation *fix_rheo_oxidation = dynamic_cast(fixes[0]); - if (!id_fix_bond_history) { - id_fix_bond_history = utils::strdup("HISTORY_RHEO_SHELL"); - fix_bond_history = dynamic_cast(modify->replace_fix( - id_fix_dummy2, fmt::format("{} all BOND_HISTORY 1 2", id_fix_bond_history), 1)); - delete[] id_fix_dummy2; - id_fix_dummy2 = nullptr; - } - - // Reproduce standard functions of BondBPM, removing special restrictions - // Since this bond is intended to be created by fix rheo/oxidation, it - // ignores special statuses - - if (id_fix_store_local) { - auto ifix = modify->get_fix_by_id(id_fix_store_local); - if (!ifix) error->all(FLERR, "Cannot find fix STORE/LOCAL id {}", id_fix_store_local); - if (strcmp(ifix->style, "STORE/LOCAL") != 0) - error->all(FLERR, "Incorrect fix style matched, not STORE/LOCAL: {}", ifix->style); - fix_store_local = dynamic_cast(ifix); - fix_store_local->nvalues = nvalues; - } - - id_fix_update = nullptr; - - if (force->angle || force->dihedral || force->improper) - error->all(FLERR, "Bond style rheo/shell cannot be used with 3,4-body interactions"); - if (atom->molecular == 2) - error->all(FLERR, "Bond style rheo/shell cannot be used with atom style template"); + rsurf = fix_rheo_oxidation->rsurf; + rmax = fix_rheo_oxidation->cut; } /* ---------------------------------------------------------------------- */ @@ -397,20 +386,13 @@ void BondRHEOShell::settings(int narg, char **arg) tform = utils::numeric(FLERR, arg[iarg + 1], false, lmp); if (tform < 0.0) error->all(FLERR, "Illegal bond rheo/shell value for t/form, {}", tform); i += 1; - } else if (strcmp(arg[iarg], "r/max") == 0) { - if (iarg + 1 > narg) error->all(FLERR, "Illegal bond rheo/shell command, missing option for r/max"); - rmax = utils::numeric(FLERR, arg[iarg + 1], false, lmp); - if (rmax < 0.0) error->all(FLERR, "Illegal bond rheo/shell value for r/max, {}", rmax); - i += 1; } else { error->all(FLERR, "Illegal bond rheo/shell command, invalid argument {}", arg[iarg]); } } if (tform < 0.0) - error->all(FLERR, "Illegal bond rheo/shell command, must specify t/form"); - if (rmax < 0.0) - error->all(FLERR, "Illegal bond rheo/shell command, must specify r/max"); + error->all(FLERR, "Illegal bond rheo/shell command, must specify formation time"); } @@ -467,7 +449,6 @@ void BondRHEOShell::read_restart(FILE *fp) void BondRHEOShell::write_restart_settings(FILE *fp) { fwrite(&tform, sizeof(double), 1, fp); - fwrite(&rmax, sizeof(double), 1, fp); } /* ---------------------------------------------------------------------- @@ -478,10 +459,8 @@ void BondRHEOShell::read_restart_settings(FILE *fp) { if (comm->me == 0) { utils::sfread(FLERR, &tform, sizeof(double), 1, fp, nullptr, error); - utils::sfread(FLERR, &rmax, sizeof(double), 1, fp, nullptr, error); } MPI_Bcast(&tform, 1, MPI_DOUBLE, 0, world); - MPI_Bcast(&rmax, 1, MPI_DOUBLE, 0, world); } @@ -570,13 +549,16 @@ void BondRHEOShell::process_ineligibility(int i, int j) if (i < nlocal) { for (m = 0; m < num_bond[i]; m++) { - if (bond_atom[i][m] == tag[j]) { + if (bond_atom[i][m] == tag[j] && setflag[bond_type[i][m]]) { bond_type[i][m] = 0; n = num_bond[i]; bond_type[i][m] = bond_type[i][n - 1]; bond_atom[i][m] = bond_atom[i][n - 1]; - fix_bond_history->shift_history(i, m, n - 1); - fix_bond_history->delete_history(i, n - 1); + for (auto &ihistory: histories) { + auto fix_bond_history2 = dynamic_cast (ihistory); + fix_bond_history2->shift_history(i, m, n - 1); + fix_bond_history2->delete_history(i, n - 1); + } num_bond[i]--; break; } @@ -585,13 +567,16 @@ void BondRHEOShell::process_ineligibility(int i, int j) if (j < nlocal) { for (m = 0; m < num_bond[j]; m++) { - if (bond_atom[j][m] == tag[i]) { + if (bond_atom[j][m] == tag[i] && setflag[bond_type[j][m]]) { bond_type[j][m] = 0; n = num_bond[j]; bond_type[j][m] = bond_type[j][n - 1]; bond_atom[j][m] = bond_atom[j][n - 1]; - fix_bond_history->shift_history(j, m, n - 1); - fix_bond_history->delete_history(j, n - 1); + for (auto &ihistory: histories) { + auto fix_bond_history2 = dynamic_cast (ihistory); + fix_bond_history2->shift_history(j, m, n - 1); + fix_bond_history2->delete_history(j, n - 1); + } num_bond[j]--; break; } diff --git a/src/RHEO/bond_rheo_shell.h b/src/RHEO/bond_rheo_shell.h index a6a747a3f1..828f693ea3 100644 --- a/src/RHEO/bond_rheo_shell.h +++ b/src/RHEO/bond_rheo_shell.h @@ -43,7 +43,7 @@ class BondRHEOShell : public BondBPM { protected: double *k, *ecrit, *gamma; - double tform, rmax; + double tform, rmax, rsurf; int *dbond, *nbond; int index_nb, nmax_store; diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index bdc9951f90..61b83a4542 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -160,27 +160,30 @@ void ComputeRHEOPropertyAtom::init() error->all(FLERR, "Cannot request velocity shifting property without corresponding option in fix rheo"); if (thermal_flag && !(fix_rheo->thermal_flag)) error->all(FLERR, "Cannot request thermal property without fix rheo/thermal"); - if (shell_flag && !(fix_rheo->oxidation_flag)) - error->all(FLERR, "Cannot request number of shell bonds without fix rheo/oxidation"); compute_interface = fix_rheo->compute_interface; compute_kernel = fix_rheo->compute_kernel; compute_surface = fix_rheo->compute_surface; compute_vshift = fix_rheo->compute_vshift; compute_grad = fix_rheo->compute_grad; +} +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::setup() +{ if (thermal_flag) { - fixes = modify->get_fix_by_style("rheo/thermal"); + auto fixes = modify->get_fix_by_style("rheo/thermal"); fix_thermal = dynamic_cast(fixes[0]); } if (pressure_flag) { - fixes = modify->get_fix_by_style("rheo/pressure"); + auto fixes = modify->get_fix_by_style("rheo/pressure"); fix_pressure = dynamic_cast(fixes[0]); } if (shell_flag) { - fixes = modify->get_fix_by_style("rheo/oxidation"); + auto fixes = modify->get_fix_by_style("rheo/oxidation"); fix_oxidation = dynamic_cast(fixes[0]); } } diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index a66ef4ece6..fc5c5d1bd0 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -29,6 +29,7 @@ class ComputeRHEOPropertyAtom : public Compute { ComputeRHEOPropertyAtom(class LAMMPS *, int, char **); ~ComputeRHEOPropertyAtom() override; void init() override; + void setup() override; void compute_peratom() override; double memory_usage() override; diff --git a/src/RHEO/fix_rheo_oxidation.h b/src/RHEO/fix_rheo_oxidation.h index 5242d24460..be95efbf2c 100644 --- a/src/RHEO/fix_rheo_oxidation.h +++ b/src/RHEO/fix_rheo_oxidation.h @@ -37,12 +37,13 @@ class FixRHEOOxidation : public Fix { void pre_force(int) override; void post_integrate() override; int *nbond; + double rsurf, cut; private: int btype, index_nb; - double rsurf, cut, cutsq; - class NeighList *list; + double cutsq; + class NeighList *list; class ComputeRHEOSurface *compute_surface; class FixRHEO *fix_rheo; }; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 7d9aff5424..a133428d4a 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -270,13 +270,8 @@ void FixRHEOThermal::init() auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); req->set_cutoff(cut_kernel); - // find instances of bond history to delete data - // skip history for shell, only exception + // find instances of bond history to delete/shift data histories = modify->get_fix_by_style("BOND_HISTORY"); - if (n_histories > 0) - for (int i = 0; i < histories.size(); i++) - if (strcmp(histories[i]->id, "HISTORY_RHEO_SHELL") == 0) - histories.erase(histories.begin() + i); n_histories = histories.size(); } } @@ -498,7 +493,7 @@ void FixRHEOThermal::break_bonds() int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; - // Rapidly delete all bonds for local atoms that melt of a given type + // Delete all bonds for local atoms that melt of a given type for (int i = 0; i < nlocal; i++) { if (!(status[i] & STATUS_MELTING)) continue; for (m = (num_bond[i] - 1); m >= 0; m--) { @@ -543,7 +538,7 @@ void FixRHEOThermal::break_bonds() bondlist[n][2] = 0; // Delete bonds for non-melted local atoms (shifting) - if (i < nlocal) { + if (i < nlocal && !(status[i] & STATUS_MELTING)) { for (m = 0; m < num_bond[i]; m++) { if (bond_atom[i][m] == tag[j] && bond_type[i][m] == btype) { nmax = num_bond[i] - 1; @@ -562,7 +557,7 @@ void FixRHEOThermal::break_bonds() } } - if (j < nlocal) { + if (j < nlocal && !(status[j] & STATUS_MELTING)) { for (m = 0; m < num_bond[j]; m++) { if (bond_atom[j][m] == tag[i] && bond_type[j][m] == btype) { nmax = num_bond[j] - 1; diff --git a/src/RHEO/pair_rheo_solid.cpp b/src/RHEO/pair_rheo_solid.cpp index f6dcd95879..9b358420d2 100644 --- a/src/RHEO/pair_rheo_solid.cpp +++ b/src/RHEO/pair_rheo_solid.cpp @@ -327,6 +327,10 @@ double PairRHEOSolid::single(int i, int j, int itype, int jtype, double rsq, dou if (rsq > cutsq[itype][jtype]) return 0.0; + int *status = atom->status; + if (!(status[i] & STATUS_SOLID)) return 0.0; + if (!(status[j] & STATUS_SOLID)) return 0.0; + double **x = atom->x; double **v = atom->v; diff --git a/src/fix_bond_history.cpp b/src/fix_bond_history.cpp index 277df75085..461f91bd52 100644 --- a/src/fix_bond_history.cpp +++ b/src/fix_bond_history.cpp @@ -33,7 +33,7 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixBondHistory::FixBondHistory(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), bondstore(nullptr), id_fix(nullptr), id_array(nullptr) + Fix(lmp, narg, arg), bondstore(nullptr), bondtype_orig(nullptr), bondstore_comp(nullptr), bondstore_orig(nullptr), id_fix(nullptr), id_array(nullptr) { if (narg != 5) error->all(FLERR, "Illegal fix bond/history command"); @@ -53,7 +53,6 @@ FixBondHistory::FixBondHistory(LAMMPS *lmp, int narg, char **arg) : updated_bond_flag = 0; maxbond = 0; - allocate(); } /* ---------------------------------------------------------------------- */ @@ -65,6 +64,8 @@ FixBondHistory::~FixBondHistory() delete[] id_array; memory->destroy(bondstore); + memory->destroy(bondstore_comp); + memory->destroy(bondtype_orig); } /* ---------------------------------------------------------------------- */ @@ -135,6 +136,7 @@ void FixBondHistory::pre_exchange() int nlocal = atom->nlocal; tagint **bond_atom = atom->bond_atom; + int **bond_type = atom->bond_type; int *num_bond = atom->num_bond; tagint *tag = atom->tag; @@ -142,12 +144,12 @@ void FixBondHistory::pre_exchange() i1 = bondlist[n][0]; i2 = bondlist[n][1]; - // skip bond if already broken - if (bondlist[n][2] <= 0) { continue; } + // skip bond if already broken or not allocated + if (bondlist[n][2] <= 0 || !setflag[bondlist[n][2]]) { continue; } if (i1 < nlocal) { for (m = 0; m < num_bond[i1]; m++) { - if (bond_atom[i1][m] == tag[i2]) { + if (bond_atom[i1][m] == tag[i2] && setflag[bond_type[i1][m]]) { for (idata = 0; idata < ndata; idata++) { stored[i1][m * ndata + idata] = bondstore[n][idata]; } @@ -157,7 +159,7 @@ void FixBondHistory::pre_exchange() if (i2 < nlocal) { for (m = 0; m < num_bond[i2]; m++) { - if (bond_atom[i2][m] == tag[i1]) { + if (bond_atom[i2][m] == tag[i1] && setflag[bond_type[i2][m]]) { for (idata = 0; idata < ndata; idata++) { stored[i2][m * ndata + idata] = bondstore[n][idata]; } @@ -179,17 +181,21 @@ void FixBondHistory::allocate() else maxbond = static_cast(LB_FACTOR * atom->nbonds / comm->nprocs); memory->create(bondstore, maxbond, ndata, "fix_bond_store:bondstore"); + if (hybrid_flag) { + memory->create(bondstore_comp, maxbond, ndata, "fix_bond_store:bondstore_comp"); + memory->create(bondtype_orig, maxbond, "fix_bond_store:bondtype_orig"); + } } /* ---------------------------------------------------------------------- */ void FixBondHistory::setup_post_neighbor() { - //Grow array if number of bonds has increased - while (neighbor->nbondlist >= maxbond) { - maxbond += DELTA; - memory->grow(bondstore, maxbond, ndata, "fix_bond_store:bondstore"); - } + hybrid_flag = 0; + for (int i = 1; i <= atom->nbondtypes; i++) + if (!setflag[i]) hybrid_flag = 1; + + if (maxbond == 0) allocate(); pre_exchange(); post_neighbor(); @@ -206,6 +212,10 @@ void FixBondHistory::post_neighbor() while (neighbor->nbondlist >= maxbond) { maxbond += DELTA; memory->grow(bondstore, maxbond, ndata, "fix_bond_store:bondstore"); + if (hybrid_flag) { + memory->grow(bondstore_comp, maxbond, ndata, "fix_bond_store:bondstore_comp"); + memory->grow(bondtype_orig, maxbond, "fix_bond_store:bondtype_orig"); + } } int i1, i2, n, m, idata; @@ -215,6 +225,7 @@ void FixBondHistory::post_neighbor() int nlocal = atom->nlocal; tagint **bond_atom = atom->bond_atom; + int **bond_type = atom->bond_type; int *num_bond = atom->num_bond; tagint *tag = atom->tag; @@ -222,12 +233,12 @@ void FixBondHistory::post_neighbor() i1 = bondlist[n][0]; i2 = bondlist[n][1]; - // skip bond if already broken - if (bondlist[n][2] <= 0) { continue; } + // skip bond if already broken or not allocated + if (bondlist[n][2] <= 0 || !setflag[bondlist[n][2]]) { continue; } if (i1 < nlocal) { for (m = 0; m < num_bond[i1]; m++) { - if (bond_atom[i1][m] == tag[i2]) { + if (bond_atom[i1][m] == tag[i2] && setflag[bond_type[i1][m]]) { for (idata = 0; idata < ndata; idata++) { bondstore[n][idata] = stored[i1][m * ndata + idata]; } @@ -237,7 +248,7 @@ void FixBondHistory::post_neighbor() if (i2 < nlocal) { for (m = 0; m < num_bond[i2]; m++) { - if (bond_atom[i2][m] == tag[i1]) { + if (bond_atom[i2][m] == tag[i1] && setflag[bond_type[i2][m]]) { for (idata = 0; idata < ndata; idata++) { bondstore[n][idata] = stored[i2][m * ndata + idata]; } @@ -246,6 +257,12 @@ void FixBondHistory::post_neighbor() } } + if (hybrid_flag) { + nbondlist_orig = nbondlist; + for (n = 0; n < nbondlist; n++) + bondtype_orig[n] = bondlist[n][2]; + } + updated_bond_flag = 1; } @@ -294,6 +311,55 @@ void FixBondHistory::set_arrays(int i) for (int idata = 0; idata < ndata; idata++) stored[i][m * ndata + idata] = 0.0; } +/* ---------------------------------------------------------------------- + Compress history arrays, cutting out unused types, for bond hybrid +------------------------------------------------------------------------- */ + +void FixBondHistory::compress_history() +{ + // if this is a re-neighbor step or updating, compress bondstore + + int type; + int ncomp = 0; + if (update_flag || (neighbor->ago == 0)) { + for (int n = 0; n < nbondlist_orig; n++) { + type = bondtype_orig[n]; + if (type <= 0) continue; + if (setflag[type]) { + for (int m = 0; m < ndata; m++) + bondstore_comp[ncomp][m] = bondstore[n][m]; + ncomp += 1; + } + } + } + + // replace ptr to original array + bondstore_orig = bondstore; + bondstore = bondstore_comp; +} + +/* ---------------------------------------------------------------------- */ + +void FixBondHistory::uncompress_history() +{ + if (update_flag) { + int ncomp = 0; + for (int n = 0; n < nbondlist_orig; n++) { + type = bondtype_orig[n]; + + if (type <= 0) continue; + if (!setflag[type]) continue; + + for (int m = 0; m < ndata; m++) + bondstore[n][m] = bondstore_comp[ncomp][m]; + ncomp += 1; + } + } + + // restore ptr to original array + bondstore = bondstore_orig; +} + /* ---------------------------------------------------------------------- Delete bond by zeroing data ------------------------------------------------------------------------- */ diff --git a/src/fix_bond_history.h b/src/fix_bond_history.h index fafcf52bd9..8ee3132ab1 100644 --- a/src/fix_bond_history.h +++ b/src/fix_bond_history.h @@ -52,18 +52,29 @@ class FixBondHistory : public Fix { void check_cache(int, int); void clear_cache(); + // methods for bond style hybrid + void compress_history(); + void uncompress_history(); + // if data is temporarily stored while the bond_atom array // is being reordered, use map of vectors with pairs for keys // to enable quick look up std::map, std::vector> cached_histories; + int *setflag; // Set by BondBPM, which bond types are used double **bondstore; int stored_flag; protected: void allocate(); - int update_flag; //Flag whether history values can evolve + int hybrid_flag; + int nbondlist_orig; + int *bondtype_orig; + double **bondstore_comp; + double **bondstore_orig; + + int update_flag; // Flag whether history values can evolve int updated_bond_flag; int nbond, maxbond, ndata; int index; From c63c1856ec5c4300cb7e892d035d69c6d03b12ad Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 4 Apr 2024 11:21:42 -0600 Subject: [PATCH 076/104] Fix compilation error, edit artificial visc toggle --- src/RHEO/pair_rheo.cpp | 3 ++- src/fix_bond_history.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index fe5a1d6dec..cb33b20bea 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -189,10 +189,11 @@ void PairRHEO::compute(int eflag, int vflag) pair_avisc_flag = 0; if (fluidi || fluidj) { pair_force_flag = 1; + if (interface_flag) pair_avisc_flag = 1; } if (fluidi && fluidj) { - pair_avisc_flag = 1; pair_rho_flag = 1; + pair_avisc_flag = 1; } wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2], r); diff --git a/src/fix_bond_history.cpp b/src/fix_bond_history.cpp index 461f91bd52..8fa0b3f923 100644 --- a/src/fix_bond_history.cpp +++ b/src/fix_bond_history.cpp @@ -343,6 +343,7 @@ void FixBondHistory::compress_history() void FixBondHistory::uncompress_history() { if (update_flag) { + int type; int ncomp = 0; for (int n = 0; n < nbondlist_orig; n++) { type = bondtype_orig[n]; From 5383bd26139bb0a2584ee96a9f7ff1e9ba1735e5 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 10 Apr 2024 09:47:55 -0600 Subject: [PATCH 077/104] More doc files, misc clean ups --- doc/src/Howto_rheo.rst | 4 +- doc/src/bond_rheo_shell.rst | 119 ++---- doc/src/compute_rheo_property_atom.rst | 39 +- doc/src/fix_rheo.rst | 2 + doc/src/fix_rheo_oxidation.rst | 53 +-- doc/src/fix_rheo_pressure.rst | 2 + doc/src/fix_rheo_thermal.rst | 2 + doc/src/fix_rheo_viscosity.rst | 2 + doc/src/pair_rheo.rst | 2 + doc/src/pair_rheo_react.rst | 67 --- doc/src/pair_rheo_solid.rst | 2 + src/RHEO/compute_rheo_property_atom.cpp | 54 ++- src/RHEO/compute_rheo_property_atom.h | 4 +- src/RHEO/fix_rheo.cpp | 6 + src/RHEO/fix_rheo_oxidation.cpp | 15 + src/RHEO/fix_rheo_stress.cpp | 137 ------- src/RHEO/fix_rheo_stress.h | 48 --- src/RHEO/fix_rheo_thermal.cpp | 15 + src/RHEO/pair_rheo_react.cpp | 515 ------------------------ src/RHEO/pair_rheo_react.h | 63 --- 20 files changed, 187 insertions(+), 964 deletions(-) delete mode 100644 doc/src/pair_rheo_react.rst delete mode 100644 src/RHEO/fix_rheo_stress.cpp delete mode 100644 src/RHEO/fix_rheo_stress.h delete mode 100644 src/RHEO/pair_rheo_react.cpp delete mode 100644 src/RHEO/pair_rheo_react.h diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index 146716ba18..db710d2366 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -90,10 +90,10 @@ criteria for creating/deleting a bond or altering force calculations). ---------- -.. _howto-howto_rheo_palermo: +.. _howto_rheo_palermo: **(Palermo)** Palermo, Clemmer, Wolf, O'Connor, in preparation. -.. _howto-howto_rheo_clemmer: +.. _howto_rheo_clemmer: **(Clemmer)** Clemmer, Pierce, O'Connor, Nevins, Jones, Lechman, Tencer, Appl. Math. Model., 130, 310-326 (2024). diff --git a/doc/src/bond_rheo_shell.rst b/doc/src/bond_rheo_shell.rst index 7f6bab1eab..713bd84136 100644 --- a/doc/src/bond_rheo_shell.rst +++ b/doc/src/bond_rheo_shell.rst @@ -10,10 +10,13 @@ Syntax bond_style rheo/shell keyword value attribute1 attribute2 ... -* optional keyword = *overlay/pair* or *store/local* or *smooth* or *break* +* required keyword = *t/form* +* optional keyword = *store/local* .. parsed-literal:: + *t/form* value = formation time for a bond (time units) + *store/local* values = fix_ID N attributes ... * fix_ID = ID of associated internal fix to store data * N = prepare data for output every this many timesteps @@ -24,56 +27,56 @@ Syntax *x, y, z* = the center of mass position of the 2 atoms when the bond broke (distance units) *x/ref, y/ref, z/ref* = the initial center of mass position of the 2 atoms (distance units) - *overlay/pair* value = *yes* or *no* - bonded particles will still interact with pair forces - - *smooth* value = *yes* or *no* - smooths bond forces near the breaking point - - *normalize* value = *yes* or *no* - normalizes bond forces by the reference length - - *break* value = *yes* or *no* - indicates whether bonds break during a run - Examples """""""" .. code-block:: LAMMPS - bond_style bpm/spring + bond_style rheo/shell t/form 10.0 bond_coeff 1 1.0 0.05 0.1 - bond_style bpm/spring myfix 1000 time id1 id2 - dump 1 all local 1000 dump.broken f_myfix[1] f_myfix[2] f_myfix[3] - dump_modify 1 write_header no - Description """"""""""" -.. versionadded:: 4May2022 +.. versionadded:: TBD -The *bpm/spring* bond style computes forces based on -deviations from the initial reference state of the two atoms. The -reference state is stored by each bond when it is first computed in +The *rheo/shell* bond style is designed to work with +:doc:`fix rheo/oxidation ` which creates candidate +bonds between eligible surface or near-surface particles. When a bond +is first created, it computes no forces and starts a timer. Forces are +not computed until the timer reaches the specified bond formation time +and the bond is fully enabled. If the two particles move outside of the +maximum bond distance or move into the bulk before the timer reaches +the formation time, the bond automatically deletes itself. Not that +this deletion does not generate any broken bond data saved to a +*store/local* fix. + +Before bonds are enabled, they are still treated as regular bonds by +all other parts of LAMMPS. This means they are written to data files +and counted in computes such as :doc:`nbond/atom `. +To only count enabled bonds, use the *nbond/shell* attribute in +:doc:`compute property/atom/rheo `. + +When enabled, the bond then computes forces based on deviations from +the initial reference state of the two atoms much like a BPM style +bond (as further discussed in the :doc:`BPM howto page `). +The reference state is stored by each bond when it is first enabled the setup of a run. Data is then preserved across run commands and is written to :doc:`binary restart files ` such that restarting -the system will not reset the reference state of a bond. +the system will not reset the reference state of a bond or the timer. -This bond style only applies central-body forces which conserve the -translational and rotational degrees of freedom of a bonded set of -particles based on a model described by Clemmer and Robbins -:ref:`(Clemmer) `. The force has a magnitude of +This bond style is based on a model described in Ref. +:ref:`(Clemmer) `. The force has a magnitude of .. math:: - F = k (r - r_0) w + F = 2 k (r - r_0) + \frac{2 * k}{r_0^2 \epsilon_c^2} (r - r_0)^3 where :math:`k` is a stiffness, :math:`r` is the current distance and :math:`r_0` is the initial distance between the two particles, and -:math:`w` is an optional smoothing factor discussed below. Bonds will -break at a strain of :math:`\epsilon_c`. This is done by setting -the bond type to 0 such that forces are no longer computed. +:math:`\epsilon_c` is maximum strain beyond which a bond breaks. This +is done by setting the bond type to 0 such that forces are no longer +computed. An additional damping force is applied to the bonded particles. This forces is proportional to the difference in the @@ -88,15 +91,6 @@ where :math:`\gamma` is the damping strength, :math:`\hat{r}` is the radial normal vector, and :math:`\vec{v}` is the velocity difference between the two particles. -The smoothing factor :math:`w` can be added or removed by setting the -*smooth* keyword to *yes* or *no*, respectively. It is constructed such -that forces smoothly go to zero, avoiding discontinuities, as bonds -approach the critical strain - -.. math:: - - w = 1.0 - \left( \frac{r - r_0}{r_0 \epsilon_c} \right)^8 . - The following coefficients must be defined for each bond type via the :doc:`bond_coeff ` command as in the example above, or in the data file or restart files read by the :doc:`read_data @@ -106,22 +100,11 @@ the data file or restart files read by the :doc:`read_data * :math:`\epsilon_c` (unit less) * :math:`\gamma` (force/velocity units) -If the *normalize* keyword is set to *yes*, the elastic bond force will be -normalized by :math:`r_0` such that :math:`k` must be given in force units. - -By default, pair forces are not calculated between bonded particles. -Pair forces can alternatively be overlaid on top of bond forces by setting -the *overlay/pair* keyword to *yes*. These settings require specific -:doc:`special_bonds ` settings described in the -restrictions. Further details can be found in the :doc:`how to ` -page on BPMs. - -.. versionadded:: 28Mar2023 - -If the *break* keyword is set to *no*, LAMMPS assumes bonds should not break -during a simulation run. This will prevent some unnecessary calculation. -However, if a bond reaches a strain greater than :math:`\epsilon_c`, -it will trigger an error. +Unlike other BPM-style bonds, this bond style does not update special +bond settings when bonds are created or deleted. This bond style also +does not enforce specific :doc:`special_bonds ` settings. +This behavior is purposeful such :doc:`RHEO pair forces ` +and heat flows are still calculated. If the *store/local* keyword is used, an internal fix will track bonds that break during the simulation. Whenever a bond breaks, data is processed @@ -187,39 +170,25 @@ extra quantity can be accessed by the Restrictions """""""""""" -This bond style is part of the BPM package. It is only enabled if +This bond style is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. -By default if pair interactions between bonded atoms are to be disabled, -this bond style requires setting - -.. code-block:: LAMMPS - - special_bonds lj 0 1 1 coul 1 1 1 - -and :doc:`newton ` must be set to bond off. If the *overlay/pair* -keyword is set to *yes*, this bond style alternatively requires setting - -.. code-block:: LAMMPS - - special_bonds lj/coul 1 1 1 - Related commands """""""""""""""" -:doc:`bond_coeff `, :doc:`pair bpm/spring ` +:doc:`bond_coeff `, :doc:`fix rheo/oxidation ` Default """"""" -The option defaults are *overlay/pair* = *no*, *smooth* = *yes*, *normalize* = *no*, and *break* = *yes* +NA ---------- -.. _fragment-Clemmer: +.. _howto_rheo_clemmer: -**(Clemmer)** Clemmer and Robbins, Phys. Rev. Lett. (2022). +**(Clemmer)** Clemmer, Pierce, O'Connor, Nevins, Jones, Lechman, Tencer, Appl. Math. Model., 130, 310-326 (2024). .. _Groot4: diff --git a/doc/src/compute_rheo_property_atom.rst b/doc/src/compute_rheo_property_atom.rst index 7f5de17c3b..8d1cf47f58 100644 --- a/doc/src/compute_rheo_property_atom.rst +++ b/doc/src/compute_rheo_property_atom.rst @@ -27,8 +27,8 @@ Syntax .. parsed-literal:: - *phase* = atom phase status - *chi* = atom phase neighborhood metric + *phase* = atom phase state + *chi* = atom local phase metric *surface* = atom surface status *surface/r* = atom distance from the surface *surface/divr* = divergence of position at atom position @@ -45,6 +45,7 @@ Syntax *status* = atom full status *rho* = atom density *grad/v/\** = atom velocity gradient + *nbond/shell* = number of oxide bonds Examples """""""" @@ -52,21 +53,34 @@ Examples .. code-block:: LAMMPS compute 1 all rheo/property/atom phase surface/r pressure + compute 2 all rheo/property/atom shift/v/x grad/v/xx Description """"""""""" -Define a computation that simply stores atom attributes specific to the -RHEO package for each atom in the group. This is useful so that the -values can be used by other :doc:`output commands ` that -take computes as inputs. See for example, the :doc:`compute reduce -`, :doc:`fix ave/atom `, :doc:`fix -ave/histo `, :doc:`fix ave/chunk `, -and :doc:`atom-style variable ` commands. +.. versionadded:: TBD + +Define a computation that stores atom attributes specific to the RHEO +package for each atom in the group. This is useful so that the values +can be used by other :doc:`output commands ` that take +computes as inputs. See for example, the +:doc:`compute reduce `, +:doc:`fix ave/atom `, +:doc:`fix ave/histo `, +:doc:`fix ave/chunk `, and +:doc:`atom-style variable ` commands. The possible attributes are described in more detail in other RHEO doc -pages include :doc:`fix rheo `, :doc:`pair rheo `, -and :doc:`the RHEO howto page `. +pages including :doc:`the RHEO howto page `. Many +properties require their respective fixes, listed below in related +commands, be defined. + +The *surface/n/\** and *shift/v/\** attributes are vectors that require +specification of the *x*, *y*, or *z* component, e.g. *surface/n/x*. + +The *grad/v/\** attribute is a tensor and requires specification of +the *xx*, *yy*, *zz*, *xy*, *xz*, *yx*, *yz*, *zx*, or *zy* component, +e.g. *grad/v/xy*. The values are stored in a per-atom vector or array as discussed below. Zeroes are stored for atoms not in the specified group or for @@ -98,7 +112,8 @@ Related commands :doc:`fix rheo/viscosity `, :doc:`fix rheo/pressure `, :doc:`fix rheo/thermal `, -:doc:`pair rheo ` +:doc:`fix rheo/oxdiation `, +:doc:`fix rheo ` Default """"""" diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index 76d4ae3972..f48dd3fcde 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -43,6 +43,8 @@ Examples Description """"""""""" +.. versionadded:: TBD + Perform time integration for RHEO particles, updating positions, velocities, and densities. For a detailed breakdown of the integration timestep and numerical details, see :ref:`(Palermo) `. For an diff --git a/doc/src/fix_rheo_oxidation.rst b/doc/src/fix_rheo_oxidation.rst index a747ec582f..42e2b6d59e 100644 --- a/doc/src/fix_rheo_oxidation.rst +++ b/doc/src/fix_rheo_oxidation.rst @@ -8,43 +8,42 @@ Syntax .. parsed-literal:: - fix ID group-ID rheo/oxidation cut btype + fix ID group-ID rheo/oxidation cut btype rsurf * ID, group-ID are documented in :doc:`fix ` command * rheo/oxidation = style name of this fix command * cut = maximum bond length (distance units) * btype = type of bonds created +* rsurf = distance from surface to create bonds (distance units) Examples """""""" .. code-block:: LAMMPS - fix 1 all rheo/oxidation 1.5 2 + fix 1 all rheo/oxidation 1.5 2 0.0 + fix 1 all rheo/oxidation 1.0 1 2.0 Description """"""""""" -This fix... +.. versionadded:: TBD -Each list consists of a series of type -ranges separated by commas. The range can be specified as a -single numeric value, or a wildcard asterisk can be used to specify a range -of values. This takes the form "\*" or "\*n" or "n\*" or "m\*n". For -example, if M = the number of atom types, then an asterisk with no numeric -values means all types from 1 to M. A leading asterisk means all types -from 1 to n (inclusive). A trailing asterisk means all types from n to M -(inclusive). A middle asterisk means all types from m to n (inclusive). -Note that all atom types must be included in exactly one of the N collections. +This fix dynamically creates bonds on the surface of fluids to +represent physical processes such as oxidation. It is intended +for use with bond style :doc:`bond rheo/shell `. -While the *Tfreeze* keyword is optional, the *conductivity* and -*specific/heat* keywords are mandatory. +Every timestep, particles check neighbors within a distance of *cut*. +This distance must be smaller than the kernel length defined in +:doc:`fix rheo `. If both particles are on the fluid surface, +or within a distance of *rsurf* from the surface, a bond of type +*btype* is created between the two particles. This process is +further described in Ref. :ref:`(Clemmer) `. -Multiple instances of this fix may be defined to apply different -properties to different groups. However, the union of fix groups -across all instances of fix rheo/thermal must cover all atoms. -If there are multiple instances of this fix, any intersections in -the fix groups will lead to incorrect thermal integration. +If used in conjunction with solid bodies, such as those generated +by the *react* option of :doc:`fix rheo/thermal `, +it is recommended that one uses a :doc:`hybrid bond style ` +with different bond types for solid and oxide bonds. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -58,10 +57,8 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" -This fix must be used with an atom style that includes temperature, -heatflow, and conductivity such as atom_tyle rheo/thermal This fix -must be used in conjuction with :doc:`fix rheo ` with the -*thermal* setting. +This fix must be used with an bond style :doc:`rheo/shell ` +and :doc:`fix rheo ` with surface detection enabled. This fix is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. @@ -70,12 +67,16 @@ Related commands """""""""""""""" :doc:`fix rheo `, -:doc:`fix rheo/viscosity `, -:doc:`fix rheo/pressure `, -:doc:`pair rheo `, +:doc:`bond rheo/shell `, :doc:`compute rheo/property/atom ` Default """"""" none + +---------- + +.. _howto_rheo_clemmer: + +**(Clemmer)** Clemmer, Pierce, O'Connor, Nevins, Jones, Lechman, Tencer, Appl. Math. Model., 130, 310-326 (2024). diff --git a/doc/src/fix_rheo_pressure.rst b/doc/src/fix_rheo_pressure.rst index 2edd703299..f2a994da88 100644 --- a/doc/src/fix_rheo_pressure.rst +++ b/doc/src/fix_rheo_pressure.rst @@ -33,6 +33,8 @@ Examples Description """"""""""" +.. versionadded:: TBD + This fix defines a pressure equation of state for RHEO particles. One can define different equations of state for different atom types, but an equation must be specified for every atom type. diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst index 2ece5521bc..63d9f817ad 100644 --- a/doc/src/fix_rheo_thermal.rst +++ b/doc/src/fix_rheo_thermal.rst @@ -48,6 +48,8 @@ Examples Description """"""""""" +.. versionadded:: TBD + This fix performs time integration of temperature evolution for atom style rheo/thermal. In addition, it defines multiple thermal properties of particles and handles melting/solidification, if applicable. For more details diff --git a/doc/src/fix_rheo_viscosity.rst b/doc/src/fix_rheo_viscosity.rst index 64c6539acc..8c403f8d0b 100644 --- a/doc/src/fix_rheo_viscosity.rst +++ b/doc/src/fix_rheo_viscosity.rst @@ -32,6 +32,8 @@ Examples Description """"""""""" +.. versionadded:: TBD + This fix defines a viscosity for RHEO particles. One can define different viscosities for different atom types, but a viscosity must be specified for every atom type. diff --git a/doc/src/pair_rheo.rst b/doc/src/pair_rheo.rst index f6c3d9e3ba..9ad5586b97 100644 --- a/doc/src/pair_rheo.rst +++ b/doc/src/pair_rheo.rst @@ -31,6 +31,8 @@ Examples Description """"""""""" +.. versionadded:: TBD + Pair style *rheo* computes pressure and viscous forces between particles in the :doc:`rheo package `. If thermal evolution is turned on in :doc:`fix rheo `, then the pair style also calculates diff --git a/doc/src/pair_rheo_react.rst b/doc/src/pair_rheo_react.rst deleted file mode 100644 index 6e7eb49c9d..0000000000 --- a/doc/src/pair_rheo_react.rst +++ /dev/null @@ -1,67 +0,0 @@ -.. index:: pair_style rheo/react - -pair_style rheo/react command -========================= - -Syntax -"""""" - -.. code-block:: LAMMPS - - pair_style rheo/react - -Examples -"""""""" - -.. code-block:: LAMMPS - - pair_style rheo/react - pair_coeff * * 1.0 1.5 1.0 0.05 1.0 100 2.0 - -Description -""""""""""" - -pair style... - -The following coefficients must be defined for each pair of atom types -via the :doc:`pair_coeff ` command as in the example above, -or in the data file or restart files read by the -:doc:`read_data ` or :doc:`read_restart ` -commands, or by mixing as described below: - -* :math:`k` (force/distance units) -* :math:`r_max` (distance units) -* :math:`\epsilon` (unitless) -* :math:`\gamma` (force/velocity units) -* :math:`t_form` (time units) -* :math:`r_from_surface` (distance units) - ----------- - -Mixing, shift, table, tail correction, restart, rRESPA info -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -This style does not support the :doc:`pair_modify ` -shift, table, and tail options. - -This style does not write information to :doc:`binary restart files `. Thus, you need to re-specify the pair_style and -pair_coeff commands in an input script that reads a restart file. - -This style can only be used via the *pair* keyword of the :doc:`run_style respa ` command. It does not support the *inner*, *middle*, *outer* keywords. - -Restrictions -"""""""""""" - -This fix is part of the RHEO 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 rheo `, -:doc:`compute rheo/property/atom ` - -Default -""""""" - -none diff --git a/doc/src/pair_rheo_solid.rst b/doc/src/pair_rheo_solid.rst index ee86992776..4bac9b726f 100644 --- a/doc/src/pair_rheo_solid.rst +++ b/doc/src/pair_rheo_solid.rst @@ -21,6 +21,8 @@ Examples Description """"""""""" +.. versionadded:: TBD + Style *rheo/solid* is effectively a copy of pair style :doc:`bpm/spring ` except it only applies forces between solid RHEO particles, determined by checking the status of diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 61b83a4542..11b03623b1 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -57,7 +57,8 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (nvalues == 1) size_peratom_cols = 0; else size_peratom_cols = nvalues; - pressure_flag = thermal_flag = interface_flag = surface_flag = shift_flag = shell_flag = 0; + pressure_flag = thermal_flag = interface_flag = 0; + surface_flag = shift_flag = shell_flag = 0; // parse input values // customize a new keyword by adding to if statement @@ -70,32 +71,34 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a for (int iarg = 3; iarg < narg; iarg++) { i = iarg-3; - if (strcmp(arg[iarg],"phase") == 0) { + if (strcmp(arg[iarg], "phase") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_phase; - } else if (strcmp(arg[iarg],"rho") == 0) { + } else if (strcmp(arg[iarg], "rho") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_rho; - } else if (strcmp(arg[iarg],"chi") == 0) { + } else if (strcmp(arg[iarg], "chi") == 0) { interface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_chi; - } else if (strcmp(arg[iarg],"surface") == 0) { + } else if (strcmp(arg[iarg], "surface") == 0) { surface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface; - } else if (strcmp(arg[iarg],"surface/r") == 0) { + } else if (strcmp(arg[iarg], "surface/r") == 0) { surface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_r; - } else if (strcmp(arg[iarg],"surface/divr") == 0) { + } else if (strcmp(arg[iarg], "surface/divr") == 0) { surface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_divr; } else if (utils::strmatch(arg[iarg], "^surface/n")) { surface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_n; col_index[i] = get_vector_index(arg[iarg]); - } else if (strcmp(arg[iarg],"coordination") == 0) { + } else if (strcmp(arg[iarg], "coordination") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_coordination; - } else if (strcmp(arg[iarg],"pressure") == 0) { + } else if (strcmp(arg[iarg], "pressure") == 0) { pressure_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_pressure; - } else if (strcmp(arg[iarg],"cv") == 0) { + } else if (strcmp(arg[iarg], "viscosity") == 0) { + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_viscosity; + } else if (strcmp(arg[iarg], "cv") == 0) { thermal_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; } else if (utils::strmatch(arg[iarg], "^shift/v")) { @@ -113,7 +116,7 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a arg[iarg], atom->get_style()); pack_choice[i] = &ComputeRHEOPropertyAtom::pack_atom_style; thermal_flag = 1; - } else if (strcmp(arg[iarg],"nbond/shell") == 0) { + } else if (strcmp(arg[iarg], "nbond/shell") == 0) { shell_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_nbond_shell; } else { @@ -124,9 +127,9 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a arg[iarg], atom->get_style()); pack_choice[i] = &ComputeRHEOPropertyAtom::pack_atom_style; - if (strcmp(arg[iarg],"temperature") == 0) thermal_flag = 1; - if (strcmp(arg[iarg],"heatflow") == 0) thermal_flag = 1; - if (strcmp(arg[iarg],"conductivity") == 0) thermal_flag = 1; + if (strcmp(arg[iarg], "temperature") == 0) thermal_flag = 1; + if (strcmp(arg[iarg], "heatflow") == 0) thermal_flag = 1; + if (strcmp(arg[iarg], "conductivity") == 0) thermal_flag = 1; } } @@ -149,7 +152,7 @@ ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() void ComputeRHEOPropertyAtom::init() { auto fixes = modify->get_fix_by_style("^rheo$"); - if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); + if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use compute rheo/property/atom"); fix_rheo = dynamic_cast(fixes[0]); if (interface_flag && !(fix_rheo->interface_flag)) @@ -390,6 +393,21 @@ void ComputeRHEOPropertyAtom::pack_pressure(int n) /* ---------------------------------------------------------------------- */ +void ComputeRHEOPropertyAtom::pack_viscosity(int n) +{ + int *mask = atom->mask; + double *viscosity = atom->viscosity; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = viscosity[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + void ComputeRHEOPropertyAtom::pack_nbond_shell(int n) { int *nbond = fix_oxidation->nbond; @@ -490,11 +508,11 @@ int ComputeRHEOPropertyAtom::get_tensor_index(char* option) int ComputeRHEOPropertyAtom::get_vector_index(char* option) { int index; - if (utils::strmatch(option,"x$")) { + if (utils::strmatch(option, "x$")) { index = 0; - } else if (utils::strmatch(option,"y$")) { + } else if (utils::strmatch(option, "y$")) { index = 1; - } else if (utils::strmatch(option,"z$")) { + } else if (utils::strmatch(option, "z$")) { if (domain->dimension == 2) error->all(FLERR, "Invalid compute rheo/property/atom property {} in 2D", option); index = 2; diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index fc5c5d1bd0..a61455f0c5 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -35,7 +35,8 @@ class ComputeRHEOPropertyAtom : public Compute { private: int nvalues, nmax; - int pressure_flag, thermal_flag, interface_flag, surface_flag, shift_flag, shell_flag; + int pressure_flag, thermal_flag, interface_flag; + int surface_flag, shift_flag, shell_flag; int *avec_index; int *col_index; double *buf; @@ -55,6 +56,7 @@ class ComputeRHEOPropertyAtom : public Compute { void pack_shift_v(int); void pack_gradv(int); void pack_pressure(int); + void pack_viscosity(int); void pack_nbond_shell(int); void pack_atom_style(int); diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 04b7d33541..98382b07b5 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -19,6 +19,7 @@ #include "fix_rheo.h" #include "atom.h" +#include "citeme.h" #include "compute_rheo_grad.h" #include "compute_rheo_interface.h" #include "compute_rheo_surface.h" @@ -37,6 +38,9 @@ using namespace LAMMPS_NS; using namespace RHEO_NS; using namespace FixConst; +static const char cite_rheo[] = + "TBD\n\n"; + /* ---------------------------------------------------------------------- */ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : @@ -137,6 +141,8 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : } iarg += 1; } + + if (lmp->citeme) lmp->citeme->add(cite_rheo); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index f536df7842..bc31593653 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "atom_vec.h" +#include "citeme.h" #include "compute_rheo_surface.h" #include "error.h" #include "fix_rheo.h" @@ -34,6 +35,18 @@ using namespace RHEO_NS; using namespace FixConst; enum {NONE, CONSTANT}; +static const char cite_rheo_oxide[] = + "@article{ApplMathModel.130.310,\n" + " title = {A hybrid smoothed-particle hydrodynamics model of oxide skins on molten aluminum},\n" + " journal = {Applied Mathematical Modelling},\n" + " volume = {130},\n" + " pages = {310-326},\n" + " year = {2024},\n" + " issn = {0307-904X},\n" + " doi = {https://doi.org/10.1016/j.apm.2024.02.027},\n" + " author = {Joel T. Clemmer and Flint Pierce and Thomas C. O'Connor and Thomas D. Nevins and Elizabeth M.C. Jones and Jeremy B. Lechman and John Tencer},\n" + "}\n\n"; + /* ---------------------------------------------------------------------- */ FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) : @@ -51,6 +64,8 @@ FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) : if (rsurf <= 0.0) error->all(FLERR, "Illegal surface distance {} in fix rheo/oxidation", cut); cutsq = cut * cut; + + if (lmp->citeme) lmp->citeme->add(cite_rheo_oxide); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_stress.cpp b/src/RHEO/fix_rheo_stress.cpp deleted file mode 100644 index b391527f1c..0000000000 --- a/src/RHEO/fix_rheo_stress.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* ---------------------------------------------------------------------- - 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 authors: Joel Clemmer (SNL) ------------------------------------------------------------------------ */ - -#include "fix_rheo_stress.h" - -#include "atom.h" -#include "comm.h" -#include "compute.h" -#include "domain.h" -#include "fix_store_atom.h" -#include "group.h" -#include "error.h" -#include "modify.h" -#include "update.h" - -#include -#include - -using namespace LAMMPS_NS; -using namespace FixConst; - -/* ---------------------------------------------------------------------- */ - -FixRHEOStress::FixRHEOStress(LAMMPS *lmp, int narg, char **arg) : - id_compute(nullptr), id_fix(nullptr), stress_compute(nullptr), store_fix(nullptr), Fix(lmp, narg, arg) -{ - if (narg != 3) error->all(FLERR,"Illegal fix rheo/stress command"); - comm_forward = 6; -} - -/* ---------------------------------------------------------------------- */ - -FixRHEOStress::~FixRHEOStress() -{ - modify->delete_compute(id_compute); - modify->delete_fix(id_fix); -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOStress::post_constructor() -{ - id_fix = utils::strdup(std::string(id) + "_store"); - store_fix = dynamic_cast(modify->add_fix(fmt::format("{} {} STORE/ATOM d_pxx d_pyy d_pzz d_pxy d_pxz d_pyz", id_fix, group->names[igroup]))); - array_atom = store_fix->astore; - - id_compute = utils::strdup(std::string(id) + "_compute"); - stress_compute = modify->add_compute(fmt::format("{} {} stress/atom NULL ke pair bond", id_compute, group->names[igroup])); -} - -/* ---------------------------------------------------------------------- */ - -int FixRHEOStress::setmask() -{ - int mask = 0; - mask |= PRE_FORCE; - mask |= END_OF_STEP; - return mask; -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOStress::init() -{ - stress_compute->addstep(update->ntimestep+1); -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOStress::pre_force(int vflag) -{ - // add pre-force and forward to ghosts (not done in store/atom) - comm->forward_comm(this); -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOStress::end_of_step() -{ - stress_compute->compute_peratom(); - - // copy compute to fix property atom - double **saved_stress = store_fix->astore; - double **stress = stress_compute->array_atom; - - int ntotal = atom->nlocal+atom->nghost; - for (int i = 0; i < ntotal; i++) - for (int a = 0; a < 6; a++) - saved_stress[i][a] = stress[i][a]; - - stress_compute->addstep(update->ntimestep + 1); -} - -/* ---------------------------------------------------------------------- */ - -int FixRHEOStress::pack_forward_comm(int n, int *list, double *buf, - int /*pbc_flag*/, int * /*pbc*/) -{ - int i, j, a, m; - double **saved_stress = store_fix->astore; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - for (a = 0; a < 6; a++) - buf[m++] = saved_stress[j][a]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOStress::unpack_forward_comm(int n, int first, double *buf) -{ - int i, a, m, last; - double **saved_stress = store_fix->astore; - - m = 0; - last = first + n; - for (i = first; i < last; i++) - for (a = 0; a < 6; a++) - saved_stress[i][a] = buf[m++]; -} diff --git a/src/RHEO/fix_rheo_stress.h b/src/RHEO/fix_rheo_stress.h deleted file mode 100644 index 4bf522793f..0000000000 --- a/src/RHEO/fix_rheo_stress.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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(rheo/stress,FixRHEOStress); -// clang-format on -#else - -#ifndef LMP_FIX_RHEO_STRESS_H -#define LMP_FIX_RHEO_STRESS_H - -#include "fix.h" - -namespace LAMMPS_NS { - -class FixRHEOStress : public Fix { - public: - FixRHEOStress(class LAMMPS *, int, char **); - ~FixRHEOStress() override; - void post_constructor() override; - int setmask() override; - void init() override; - void pre_force(int) override; - void end_of_step() override; - int pack_forward_comm(int, int *, double *, int, int *) override; - void unpack_forward_comm(int, int, double *) override; - - private: - char *id_compute, *id_fix; - class Compute *stress_compute; - class FixStoreAtom *store_fix; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index a133428d4a..9fbdb8c8f6 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "atom_vec.h" +#include "citeme.h" #include "comm.h" #include "compute_rheo_grad.h" #include "compute_rheo_vshift.h" @@ -43,6 +44,18 @@ using namespace RHEO_NS; using namespace FixConst; enum {NONE, CONSTANT}; +static const char cite_rheo_oxide[] = + "@article{ApplMathModel.130.310,\n" + " title = {A hybrid smoothed-particle hydrodynamics model of oxide skins on molten aluminum},\n" + " journal = {Applied Mathematical Modelling},\n" + " volume = {130},\n" + " pages = {310-326},\n" + " year = {2024},\n" + " issn = {0307-904X},\n" + " doi = {https://doi.org/10.1016/j.apm.2024.02.027},\n" + " author = {Joel T. Clemmer and Flint Pierce and Thomas C. O'Connor and Thomas D. Nevins and Elizabeth M.C. Jones and Jeremy B. Lechman and John Tencer},\n" + "}\n\n"; + /* ---------------------------------------------------------------------- */ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : @@ -193,6 +206,8 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : if (Tc_style[i] == NONE && L_style[i] != NONE) error->all(FLERR, "Must specify critical temperature for atom type {} to use latent heat in fix rheo/thermal", i); } + + if (lmp->citeme) lmp->citeme->add(cite_rheo_oxide); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/pair_rheo_react.cpp b/src/RHEO/pair_rheo_react.cpp deleted file mode 100644 index 4709ea169e..0000000000 --- a/src/RHEO/pair_rheo_react.cpp +++ /dev/null @@ -1,515 +0,0 @@ -/* ---------------------------------------------------------------------- - 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 authors: - Joel Clemmer (SNL) ------------------------------------------------------------------------ */ - -#include "pair_rheo_react.h" - -#include "atom.h" -#include "comm.h" -#include "compute_rheo_surface.h" -#include "error.h" -#include "fix.h" -#include "fix_dummy.h" -#include "fix_neigh_history.h" -#include "fix_rheo.h" -#include "force.h" -#include "memory.h" -#include "modify.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "update.h" -#include "utils.h" - -using namespace LAMMPS_NS; -using namespace RHEO_NS; - -/* ---------------------------------------------------------------------- */ - -PairRHEOReact::PairRHEOReact(LAMMPS *lmp) : Pair(lmp), - dbond(NULL) -{ - single_enable = 0; - size_history = 2; - beyond_contact = 1; - comm_reverse = 1; - nondefault_history_transfer = 1; - - // create dummy fix as placeholder for FixNeighHistory - // this is so final order of Modify:fix will conform to input script - - fix_history = nullptr; - fix_dummy = dynamic_cast( - modify->add_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY" + std::to_string(instance_me) + " all DUMMY")); - - // For nbond, create an instance of fix property atom - // Need restarts + exchanging with neighbors since it needs to persist - // between timesteps (fix property atom will handle callbacks) - - int tmp1, tmp2; - index_nb = atom->find_custom("react_nbond", tmp1, tmp2); - if (index_nb == -1) { - id_fix = utils::strdup("pair_rheo_react_fix_property_atom"); - modify->add_fix(fmt::format("{} all property/atom i_react_nbond", id_fix)); - index_nb = atom->find_custom("react_nbond", tmp1, tmp2); - } - nbond = atom->ivector[index_nb]; - - //Store non-persistent per atom quantities, intermediate - - nmax_store = atom->nmax; - memory->create(dbond, nmax_store, "rheo/react:dbond"); -} - -/* ---------------------------------------------------------------------- */ - -PairRHEOReact::~PairRHEOReact() -{ - if (modify->nfix && fix_history) modify->delete_fix("NEIGH_HISTORY_RHEO_REACT" + std::to_string(instance_me)); - if (modify->nfix && fix_dummy) modify->delete_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY" + std::to_string(instance_me)); - if (modify->nfix) modify->delete_fix(id_fix); - delete[] id_fix; - - if (allocated) { - memory->destroy(setflag); - memory->destroy(cutsq); - memory->destroy(cutbsq); - - memory->destroy(cutbond); - memory->destroy(k); - memory->destroy(eps); - memory->destroy(gamma); - memory->destroy(t_form); - memory->destroy(rlimit); - } - - memory->destroy(dbond); -} - -/* ---------------------------------------------------------------------- */ - -void PairRHEOReact::compute(int eflag, int vflag) -{ - int i, j, ii, jj, inum, jnum, fluidi, fluidj; - double xtmp, ytmp, ztmp, delx, dely, delz; - double vxtmp, vytmp, vztmp, delvx, delvy, delvz; - double rsq, r, rinv, r0, fpair, dot, smooth; - int itype, jtype; - - int *ilist, *jlist, *numneigh, **firstneigh; - int *saved, **firstsaved; - double *data, *alldata, **firstdata; - - ev_init(eflag,vflag); - - int bondupdate = 1; - if (update->setupflag) bondupdate = 0; - double dt = update->dt; - - double **x = atom->x; - double **v = atom->v; - double **f = atom->f; - int *type = atom->type; - int *status = atom->status; - int *mask = atom->mask; - int *nbond = atom->ivector[index_nb]; - double *rsurf = compute_surface->rsurface; - - int nlocal = atom->nlocal; - int newton_pair = force->newton_pair; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - firstsaved = fix_history->firstflag; - firstdata = fix_history->firstvalue; - - if (atom->nmax > nmax_store){ - nmax_store = atom->nmax; - memory->destroy(dbond); - memory->create(dbond, nmax_store, "rheo/react:dbond"); - } - - size_t nbytes = nmax_store * sizeof(int); - memset(&dbond[0], 0, nbytes); - - // loop over neighbors of my atoms - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - itype = type[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - vxtmp = v[i][0]; - vytmp = v[i][1]; - vztmp = v[i][2]; - fluidi = !(status[i] & PHASECHECK); - - saved = firstsaved[i]; - alldata = firstdata[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - jtype = type[j]; - fluidj = !(status[j] & PHASECHECK); - data = &alldata[2*jj]; - - // If not bonded and there's an internal fluid particle, unsave any data and skip - if (!(saved[jj] == 1 && data[0] > 0)) { - if ((fluidi && (rsurf[i] > rlimit[itype][jtype])) || (fluidj && (rsurf[j] > rlimit[itype][jtype]))) { - saved[jj] = 0; - continue; - } - } - - // If both are solid, unbond and skip - if (!fluidi && !fluidj) { - //If bonded, deincrement - if (saved[jj] == 1 && data[0] > 0) { - dbond[i] --; - dbond[j] --; - } - saved[jj] = 0; - continue; - } - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - rsq = delx * delx + dely * dely + delz * delz; - - // If unbonded and beyond bond distance, unsave and skip - if (data[0] == -1 && rsq > cutbsq[itype][jtype]) { - saved[jj] = 0; - continue; - } - - r = sqrt(rsq); - // Initialize data if not currently saved since all could bond if they are on the surface - if (saved[jj] == 0) { - data[0] = -1; - data[1] = 0; - saved[jj] = 1; - } - - // Check for bond formation (unbonded) or breakage (bonded) - if (data[0] == -1) { - // If unbonded, check if we count down to bonding if both on surface (not given for r or s) - if (bondupdate && (rsurf[i] <= rlimit[itype][jtype]) && (rsurf[j] <= rlimit[itype][jtype])) { - data[1] += dt; - if (data[1] >= t_form[itype][jtype]) { - data[0] = r; - dbond[i] ++; - dbond[j] ++; - data[1] = 0; - } - } - } else { - // If bonded, check if breaks in tension - r0 = data[0]; - if (r > ((1.0 + eps[itype][jtype]) * r0)) { - saved[jj] = 0; - dbond[i] --; - dbond[j] --; - data[0] = -1; - } - } - - // Skip if unbonded - if (data[0] <= 0) continue; - - delvx = vxtmp - v[j][0]; - delvy = vytmp - v[j][1]; - delvz = vztmp - v[j][2]; - rinv = 1.0 / r; - r0 = data[0]; - - fpair = k[itype][jtype] * (r0 - r); - - dot = delx * delvx + dely * delvy + delz * delvz; - fpair -= gamma[itype][jtype] * dot * rinv; - - smooth = 1.0; - if (r > r0) { - smooth = (r - r0) / (r0 * eps[itype][jtype]); - smooth *= smooth; - smooth *= smooth; - smooth = 1 - smooth; - } - - fpair *= rinv * smooth; - - f[i][0] += delx * fpair; - f[i][1] += dely * fpair; - f[i][2] += delz * fpair; - if (newton_pair || j < nlocal) { - f[j][0] -= delx * fpair; - f[j][1] -= dely * fpair; - f[j][2] -= delz * fpair; - } - - if (evflag) ev_tally(i, j, nlocal, newton_pair, 0.0, 0.0, fpair, delx, dely, delz); - } - } - - // Communicate changes in nbond - if (newton_pair) comm->reverse_comm(this); - - for(i = 0; i < nlocal; i++) { - fluidi = !(status[i] & PHASECHECK); - nbond[i] += dbond[i]; - - // If it has bonds it is reactive (no shifting) - // If a reactive particle breaks all bonds, return to fluid - // Keep it non-shifting for this timestep to be safe - if (nbond[i] != 0 && fluidi) status[i] |= STATUS_NO_SHIFT; - } - - if (vflag_fdotr) virial_fdotr_compute(); -} - -/* ---------------------------------------------------------------------- - allocate all arrays -------------------------------------------------------------------------- */ - -void PairRHEOReact::allocate() -{ - allocated = 1; - int n = atom->ntypes; - - memory->create(setflag, n + 1, n + 1, "pair:setflag"); - for (int i = 1; i <= n; i++) - for (int j = i; j <= n; j++) - setflag[i][j] = 0; - - memory->create(cutbond, n + 1, n + 1, "pair:cutbond"); - memory->create(cutbsq, n + 1, n + 1, "pair:cutbsq"); - memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); - memory->create(k, n + 1, n + 1, "pair:k"); - memory->create(eps, n + 1, n + 1, "pair:eps"); - memory->create(gamma, n + 1, n + 1, "pair:gamma"); - memory->create(t_form, n + 1, n + 1, "pair:t_form"); - memory->create(rlimit, n + 1, n + 1, "pair:rlimit"); -} - -/* ---------------------------------------------------------------------- - global settings - ------------------------------------------------------------------------- */ - -void PairRHEOReact::settings(int narg, char **arg) -{ -} - -/* ---------------------------------------------------------------------- - set coeffs for one or more type pairs -------------------------------------------------------------------------- */ - -void PairRHEOReact::coeff(int narg, char **arg) -{ - if (narg != 9) error->all(FLERR, "Incorrect args for pair coefficients"); - if (!allocated) allocate(); - - int ilo, ihi, jlo, jhi; - utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi,error); - utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi,error); - - double k_one = utils::numeric(FLERR, arg[2], false, lmp); - double cutb_one = utils::numeric(FLERR, arg[3], false, lmp); - double eps_one = utils::numeric(FLERR, arg[4], false, lmp); - double gamma_one = utils::numeric(FLERR, arg[5], false, lmp); - double t_form_one = utils::numeric(FLERR, arg[6], false, lmp); - double rlimit_one = utils::numeric(FLERR, arg[7], false, lmp); - - if (k_one < 0.0 || eps_one < 0.0 || t_form_one < 0.0) - error->all(FLERR, "Illegal pair_style command"); - - int count = 0; - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo,i); j <= jhi; j++) { - k[i][j] = k_one; - cutbond[i][j] = cutb_one; - eps[i][j] = eps_one; - gamma[i][j] = gamma_one; - t_form[i][j] = t_form_one; - rlimit[i][j] = rlimit_one; - setflag[i][j] = 1; - count++; - } - } - - if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients"); -} - -/* ---------------------------------------------------------------------- - init specific to this pair style -------------------------------------------------------------------------- */ - -void PairRHEOReact::init_style() -{ - int irequest = neighbor->request(this, instance_me); - //neighbor->requests[irequest]->history = 1; - - if (fix_history == nullptr) { - auto cmd = fmt::format("NEIGH_HISTORY_RHEO_REACT{} all NEIGH_HISTORY {}", instance_me, size_history); - fix_history = dynamic_cast( - modify->replace_fix("NEIGH_HISTORY_RHEO_REACT_DUMMY" + std::to_string(instance_me), cmd, 1)); - fix_history->pair = this; - fix_dummy = nullptr; - } -} - -/* ---------------------------------------------------------------------- - setup specific to this pair style - ------------------------------------------------------------------------- */ - -void PairRHEOReact::setup() -{ - auto fixes = modify->get_fix_by_style("^rheo$"); - if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/tension"); - fix_rheo = dynamic_cast(fixes[0]); - - if (!fix_rheo->surface_flag) error->all(FLERR, - "Pair rheo/react requires surface calculation in fix rheo"); - - compute_surface = fix_rheo->compute_surface; - - if (force->newton_pair == 0) error->all(FLERR, - "Pair rheo/react needs newton pair on for bond changes to be consistent"); -} - -/* ---------------------------------------------------------------------- - init for one type pair i,j and corresponding j,i -------------------------------------------------------------------------- */ - -double PairRHEOReact::init_one(int i, int j) -{ - if (setflag[i][j] == 0) error->all(FLERR, "All pair coeffs are not set"); - - cutbsq[i][j] = cutbond[i][j] * cutbond[i][j]; - - cutbsq[j][i] = cutbsq[i][j]; - cutbond[j][i] = cutbond[i][j]; - k[j][i] = k[i][j]; - eps[j][i] = eps[i][j]; - gamma[j][i] = gamma[i][j]; - t_form[j][i] = t_form[i][j]; - rlimit[j][i] = rlimit[i][j]; - - double cut = cutbond[i][j] * (1.0 + eps[i][j]); - - return cut; -} - -/* ---------------------------------------------------------------------- - proc 0 writes to restart file -------------------------------------------------------------------------- */ - -void PairRHEOReact::write_restart(FILE *fp) -{ - write_restart_settings(fp); - - int i,j; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) - fwrite(&setflag[i][j], sizeof(int), 1, fp); - if (setflag[i][j]) { - fwrite(&k[i][j], sizeof(double), 1, fp); - fwrite(&cutbond[i][j], sizeof(double), 1, fp); - fwrite(&eps[i][j], sizeof(double), 1, fp); - fwrite(&gamma[i][j], sizeof(double), 1, fp); - fwrite(&t_form[i][j], sizeof(double), 1, fp); - fwrite(&rlimit[i][j], sizeof(double), 1, fp); - } -} - -/* ---------------------------------------------------------------------- - proc 0 reads from restart file, bcasts -------------------------------------------------------------------------- */ - -void PairRHEOReact::read_restart(FILE *fp) -{ - read_restart_settings(fp); - allocate(); - - int i,j; - int me = comm->me; - for (i = 1; i <= atom->ntypes; i++) - for (j = i; j <= atom->ntypes; j++) { - if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error); - MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world); - if (setflag[i][j]) { - if (me == 0) { - utils::sfread(FLERR, &k[i][j], sizeof(double), 1, fp, nullptr, error); - utils::sfread(FLERR, &cutbond[i][j], sizeof(double), 1, fp, nullptr, error); - utils::sfread(FLERR, &eps[i][j], sizeof(double), 1, fp, nullptr, error); - utils::sfread(FLERR, &gamma[i][j], sizeof(double), 1, fp, nullptr, error); - utils::sfread(FLERR, &t_form[i][j], sizeof(double), 1, fp, nullptr, error); - utils::sfread(FLERR, &rlimit[i][j], sizeof(double), 1, fp, nullptr, error); - } - MPI_Bcast(&k[i][j], 1,MPI_DOUBLE, 0, world); - MPI_Bcast(&cutbond[i][j], 1,MPI_DOUBLE, 0, world); - MPI_Bcast(&eps[i][j], 1,MPI_DOUBLE, 0, world); - MPI_Bcast(&gamma[i][j], 1,MPI_DOUBLE, 0, world); - MPI_Bcast(&t_form[i][j], 1,MPI_DOUBLE, 0, world); - MPI_Bcast(&rlimit[i][j], 1,MPI_DOUBLE, 0, world); - } - } -} - - - - -/* ---------------------------------------------------------------------- - transfer history during fix/neigh/history exchange - transfer same sign -------------------------------------------------------------------------- */ - -void PairRHEOReact::transfer_history(double* source, double* target) -{ - for (int i = 0; i < size_history; i++) - target[i] = source[i]; -} - -/* ---------------------------------------------------------------------- */ - -int PairRHEOReact::pack_reverse_comm(int n, int first, double *buf) -{ - int i, m, last; - m = 0; - last = first + n; - - for (i = first; i < last; i++) { - buf[m++] = dbond[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void PairRHEOReact::unpack_reverse_comm(int n, int *list, double *buf) -{ - int i, j, m; - - m = 0; - for (i = 0; i < n; i++) { - j = list[i]; - dbond[j] += buf[m++]; - } -} diff --git a/src/RHEO/pair_rheo_react.h b/src/RHEO/pair_rheo_react.h deleted file mode 100644 index 88d5dbeb0e..0000000000 --- a/src/RHEO/pair_rheo_react.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- 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 PAIR_CLASS -// clang-format off -PairStyle(rheo/react,PairRHEOReact) -// clang-format on -#else - -#ifndef LMP_PAIR_RHEO_REACT_H -#define LMP_PAIR_RHEO_REACT_H - -#include "pair.h" - -namespace LAMMPS_NS { - -class PairRHEOReact : public Pair { - public: - PairRHEOReact(class LAMMPS *); - ~PairRHEOReact() override; - void compute(int, int) override; - void settings(int, char **) override; - void coeff(int, char **) override; - void init_style() override; - void setup() override; - double init_one(int, int) override; - void write_restart(FILE *) override; - void read_restart(FILE *) override; - int pack_reverse_comm(int, int, double *) override; - void unpack_reverse_comm(int, int *, double *) override; - - protected: - double **cutbond, **cutbsq, **k, **eps, **gamma, **t_form, **rlimit; - - void allocate(); - void transfer_history(double*, double*); - - int size_history; - int *dbond, *nbond; - - int index_nb, nmax_store; - char *id_fix; - - class FixDummy *fix_dummy; - class FixNeighHistory *fix_history; - class FixRHEO *fix_rheo; - class ComputeRHEOSurface *compute_surface; -}; - -} // namespace LAMMPS_NS - -#endif -#endif From 1135d6be64b7b2bd2fb1c0ffbebca2f6f7283197 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 10 Apr 2024 10:44:41 -0600 Subject: [PATCH 078/104] Noting artificial/visc exception in doc --- doc/src/pair_rheo.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/src/pair_rheo.rst b/doc/src/pair_rheo.rst index f6c3d9e3ba..be7311c480 100644 --- a/doc/src/pair_rheo.rst +++ b/doc/src/pair_rheo.rst @@ -39,7 +39,10 @@ heat exchanged between particles. The *artificial/viscosity* keyword is used to specify the magnitude :math:`\zeta` of an optional artificial viscosity contribution to forces. This factor can help stabilize simulations by smoothing out small length -scale variations in velocity fields. +scale variations in velocity fields. Artificial viscous forces are only +exchanged by fluid particles unless interfaces are not reconstructed in +fix rheo, in which fluid particles will also exchange artificial viscous +forces with solid particles to improve stability. The *rho/damp* keyword is used to specify the magnitude :math:`\xi` of an optional pairwise damping term between the density of particles. This From 4220be380c3b4aa487dc85710d08d7cafa3dbbbd Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 24 Apr 2024 11:48:44 -0600 Subject: [PATCH 079/104] Finishing oxidation, adding hybrid compatability for BPM --- doc/src/Howto_rheo.rst | 8 +- doc/src/fix_rheo.rst | 20 +++-- src/.gitignore | 2 + src/BPM/bond_bpm.cpp | 2 +- src/GRANULAR/fix_add_heat.cpp | 138 ++++++++++++++++++++++++++++++++ src/GRANULAR/fix_add_heat.h | 45 +++++++++++ src/RHEO/bond_rheo_shell.cpp | 23 ++++-- src/RHEO/fix_rheo_oxidation.cpp | 21 +---- src/RHEO/fix_rheo_thermal.cpp | 6 +- src/RHEO/pair_rheo.cpp | 2 +- src/bond_hybrid.cpp | 26 ++++++ src/bond_hybrid.h | 1 + src/fix_bond_history.cpp | 13 +-- src/fix_bond_history.h | 3 +- 14 files changed, 260 insertions(+), 50 deletions(-) create mode 100644 src/GRANULAR/fix_add_heat.cpp create mode 100644 src/GRANULAR/fix_add_heat.h diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index db710d2366..748c91845b 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -31,9 +31,9 @@ properties like positions and forces, particles store a local density, viscosity, pressure, and status. If thermal evolution is modeled, one must use atom style rheo/thermal which also include a local temperature and conductivity. The status variable uses bitmasking to track various -properties of a particle such as its current phase (fluid or solid) and its -location relative to a surface. Many of these properties (and others) can -be easily accessed using +properties of a particle such as its current state of matter (fluid or solid) +and its location relative to a surface. Many of these properties (and others) +can be easily accessed using :doc:`compute rheo/property/atom `. Fluid interactions, including pressure forces, viscous forces, and heat exchange, @@ -84,7 +84,7 @@ breaking if stretched too far. Unlike the above method, this option does not rem the underlying fluid interactions (although particle shifting is turned off) and does not modify special bond settings of particles. -While these two options are not expected to be appropriate for every multiphase system, +While these two options are not expected to be appropriate for every system, either framework can be modified to create more suitable models (e.g. by changing the criteria for creating/deleting a bond or altering force calculations). diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index f48dd3fcde..5c46ad892e 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -80,14 +80,18 @@ surfaces. A modified form of Fickian particle shifting can be enabled with the *shift* keyword. This effectively shifts particle positions to generate a -more uniform spatial distribution. In systems with free surfaces, the -*surface/detection* keyword can be used to classify the location of -particles as being within the bulk fluid, on a free surface, or isolated -from other particles in a splash or droplet. Shifting is then disabled in -the direction away from the free surface to prevent it from diffusing -particles away from the bulk fluid. Surface detection can also be used -to control surface-nucleated effects like oxidation when used in combination -with :doc:`fix rheo/oxidation `. +more uniform spatial distribution. Shifting currently does consider the +type of a particle and therefore may be inappropriate in systems consisting +of multiple materials. + +In systems with free surfaces, the *surface/detection* keyword can be used +to classify the location of particles as being within the bulk fluid, on a +free surface, or isolated from other particles in a splash or droplet. +Shifting is then disabled in the direction away from the free surface to +prevent it from diffusing particles away from the bulk fluid. Surface +detection can also be used to control surface-nucleated effects like +oxidation when used in combination with +:doc:`fix rheo/oxidation `. The *surface/detection* keyword takes three arguments: *sdstyle*, *limit*, and *limi/splash*. The first, *sdstyle*, specifies whether surface particles diff --git a/src/.gitignore b/src/.gitignore index a77c6c58a6..1bf840cf31 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -765,6 +765,8 @@ /fix_acks2_reaxff.h /fix_adapt_fep.cpp /fix_adapt_fep.h +/fix_add_heat.cpp +/fix_add_heat.h /fix_addtorque.cpp /fix_addtorque.h /fix_append_atoms.cpp diff --git a/src/BPM/bond_bpm.cpp b/src/BPM/bond_bpm.cpp index 351cff1420..b0ebc37257 100644 --- a/src/BPM/bond_bpm.cpp +++ b/src/BPM/bond_bpm.cpp @@ -71,7 +71,7 @@ BondBPM::~BondBPM() if (id_fix_dummy) modify->delete_fix(id_fix_dummy); if (id_fix_dummy2) modify->delete_fix(id_fix_dummy2); if (id_fix_update) modify->delete_fix(id_fix_update); - if (id_fix_bond_history) modify->delete_fix(id_fix_bond_history); + if (fix_bond_history) modify->delete_fix(id_fix_bond_history); if (id_fix_store_local) modify->delete_fix(id_fix_store_local); if (id_fix_prop_atom) modify->delete_fix(id_fix_prop_atom); diff --git a/src/GRANULAR/fix_add_heat.cpp b/src/GRANULAR/fix_add_heat.cpp new file mode 100644 index 0000000000..2db3389560 --- /dev/null +++ b/src/GRANULAR/fix_add_heat.cpp @@ -0,0 +1,138 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Joel Clemmer (SNL) +------------------------------------------------------------------------- */ + +#include "fix_add_heat.h" + +#include "atom.h" +#include "error.h" +#include "input.h" +#include "memory.h" +#include "update.h" +#include "variable.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +enum { NONE, CONSTANT, EQUAL, ATOM }; + +/* ---------------------------------------------------------------------- */ + +FixAddHeat::FixAddHeat(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), varstr(nullptr), qatom(nullptr) +{ + if (narg < 4) utils::missing_cmd_args(FLERR, "fix add/heat", error); + dynamic_group_allow = 1; + overwrite_flag = 0; + + style = NONE; + if (utils::strmatch(arg[3], "^v_")) { + varstr = utils::strdup(arg[3] + 2); + } else { + value = utils::numeric(FLERR, arg[3], false, lmp); + style = CONSTANT; + } + + // optional args + + int iarg = 4; + while (iarg < narg) { + if (strcmp(arg[iarg], "overwrite") == 0) { + overwrite_flag = 1; + iarg += 1; + } else + error->all(FLERR, "Illegal fix viscous command"); + } + + maxatom = -1; +} + +/* ---------------------------------------------------------------------- */ + +FixAddHeat::~FixAddHeat() +{ + delete[] varstr; + memory->destroy(qatom); +} + +/* ---------------------------------------------------------------------- */ + +int FixAddHeat::setmask() +{ + int mask = 0; + mask |= POST_FORCE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixAddHeat::init() +{ + if (!atom->temperature_flag) + error->all(FLERR, "Fix add/heat requires atom style with temperature property"); + if (!atom->heatflow_flag) + error->all(FLERR, "Fix add/heat requires atom style with heatflow property"); + + // check variable + + if (varstr) { + var = input->variable->find(varstr); + if (var < 0) error->all(FLERR, "Variable {} for fix addforce does not exist", varstr); + if (input->variable->equalstyle(var)) + style = EQUAL; + else if (input->variable->atomstyle(var)) + style = ATOM; + else + error->all(FLERR, "Variable {} for fix addforce is invalid style", varstr); + } +} + +/* ---------------------------------------------------------------------- */ + +void FixAddHeat::post_force(int /*vflag*/) +{ + int *mask = atom->mask; + double *heatflow = atom->heatflow; + double dtinv = 1.0 / update->dt; + + if (overwrite_flag) { + for (int i = 0; i < atom->nlocal; i++) + if (mask[i] & groupbit) + heatflow[i] = 0.0; + } + + if (style == CONSTANT) { + for (int i = 0; i < atom->nlocal; i++) + if (mask[i] & groupbit) + heatflow[i] += value * dtinv; + } else if (style == EQUAL) { + value = input->variable->compute_equal(var); + for (int i = 0; i < atom->nlocal; i++) + if (mask[i] & groupbit) + heatflow[i] += value * dtinv; + } else if (style == ATOM) { + + if (atom->nmax > maxatom) { + maxatom = atom->nmax; + memory->destroy(qatom); + memory->create(qatom, maxatom, "addheat:qatom"); + } + input->variable->compute_atom(var, igroup, &qatom[0], 1, 0); + for (int i = 0; i < atom->nlocal; i++) + if (mask[i] & groupbit) + heatflow[i] += qatom[i] * dtinv; + } +} diff --git a/src/GRANULAR/fix_add_heat.h b/src/GRANULAR/fix_add_heat.h new file mode 100644 index 0000000000..8a51f13ee4 --- /dev/null +++ b/src/GRANULAR/fix_add_heat.h @@ -0,0 +1,45 @@ +/* -*- 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(add/heat,FixAddHeat); +// clang-format on +#else + +#ifndef LMP_FIX_ADD_HEAT_H +#define LMP_FIX_ADD_HEAT_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixAddHeat : public Fix { + public: + FixAddHeat(class LAMMPS *, int, char **); + ~FixAddHeat() override; + int setmask() override; + void init() override; + void post_force(int) override; + + protected: + double value; + int var, style, maxatom, overwrite_flag; + char *varstr; + double *qatom; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp index 0a3caa1b4f..6b464c4000 100644 --- a/src/RHEO/bond_rheo_shell.cpp +++ b/src/RHEO/bond_rheo_shell.cpp @@ -199,7 +199,6 @@ void BondRHEOShell::compute(int eflag, int vflag) memset(&dbond[0], 0, nbytes); for (n = 0; n < nbondlist; n++) { - // skip bond if already broken if (bondlist[n][2] <= 0) continue; @@ -218,8 +217,16 @@ void BondRHEOShell::compute(int eflag, int vflag) i2 = itmp; } - // If bond hasn't been set - set timer to zero - if (t < EPSILON || std::isnan(t)) r0 = store_bond(n, i1, i2); + delx = x[i1][0] - x[i2][0]; + dely = x[i1][1] - x[i2][1]; + delz = x[i1][2] - x[i2][2]; + rsq = delx * delx + dely * dely + delz * delz; + r = sqrt(rsq); + + // If bond hasn't been set - zero data + if (t < EPSILON || std::isnan(t)) + t = store_bond(n, i1, i2); + delx = x[i1][0] - x[i2][0]; dely = x[i1][1] - x[i2][1]; @@ -239,8 +246,9 @@ void BondRHEOShell::compute(int eflag, int vflag) } // Check ellapsed time - bondstore[n][1] += dt; - if (bondstore[n][1] >= tform) { + t += dt; + bondstore[n][1] = t; + if (t >= tform) { bondstore[n][0] = r; r0 = r; if (newton_bond || i1 < nlocal) dbond[i1] ++; @@ -285,7 +293,6 @@ void BondRHEOShell::compute(int eflag, int vflag) if (evflag) ev_tally(i1, i2, nlocal, newton_bond, 0.0, fbond, delx, dely, delz); } - // Communicate changes in nbond if (newton_bond) comm->reverse_comm(this); @@ -555,7 +562,7 @@ void BondRHEOShell::process_ineligibility(int i, int j) bond_type[i][m] = bond_type[i][n - 1]; bond_atom[i][m] = bond_atom[i][n - 1]; for (auto &ihistory: histories) { - auto fix_bond_history2 = dynamic_cast (ihistory); + auto fix_bond_history2 = dynamic_cast (ihistory); fix_bond_history2->shift_history(i, m, n - 1); fix_bond_history2->delete_history(i, n - 1); } @@ -573,7 +580,7 @@ void BondRHEOShell::process_ineligibility(int i, int j) bond_type[j][m] = bond_type[j][n - 1]; bond_atom[j][m] = bond_atom[j][n - 1]; for (auto &ihistory: histories) { - auto fix_bond_history2 = dynamic_cast (ihistory); + auto fix_bond_history2 = dynamic_cast (ihistory); fix_bond_history2->shift_history(j, m, n - 1); fix_bond_history2->delete_history(j, n - 1); } diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index bc31593653..46eaab3bf1 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -108,7 +108,7 @@ void FixRHEOOxidation::init() nbond = atom->ivector[index_nb]; // need a half neighbor list - auto req = neighbor->add_request(this, NeighConst::REQ_DEFAULT); + auto req = neighbor->add_request(this, NeighConst::REQ_FULL); req->set_cutoff(cut); } @@ -200,31 +200,16 @@ void FixRHEOOxidation::post_integrate() } if (bflag) continue; - for (n = 0; n < num_bond[j]; n++) { - if (bond_type[j][n] == btype && bond_atom[j][n] == tagi) { - bflag = 1; - break; - } - } - if (bflag) continue; - // Add bonds to owned atoms // If newton bond, add to both, otherwise add to whichever has a smaller tag - if (i < nlocal && (!newton_bond || tagi < tagj)) { + + if (!newton_bond || tagi < tagj) { if (num_bond[i] == atom->bond_per_atom) error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/oxidation for atom {}", tagi); bond_type[i][num_bond[i]] = btype; bond_atom[i][num_bond[i]] = tagj; num_bond[i]++; } - - if (j < nlocal && (!newton_bond || tagj < tagi)) { - if (num_bond[j] == atom->bond_per_atom) - error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/oxidation for atom {}", tagj); - bond_type[j][num_bond[j]] = btype; - bond_atom[j][num_bond[j]] = tagi; - num_bond[j]++; - } } } } diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 9fbdb8c8f6..3a39bbe596 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -543,8 +543,8 @@ void FixRHEOThermal::break_bonds() // Update bond list and break solid-melted bonds for (n = 0; n < nbondlist; n++) { - // skip bond if already broken - if (bondlist[n][2] <= 0) continue; + // skip bond if not correct type + if (bondlist[n][2] != btype) continue; i = bondlist[n][0]; j = bondlist[n][1]; @@ -561,7 +561,7 @@ void FixRHEOThermal::break_bonds() bond_atom[i][m] = bond_atom[i][nmax]; if (n_histories > 0) for (auto &ihistory: histories) { - auto fix_bond_history = dynamic_cast (ihistory); + auto fix_bond_history = dynamic_cast (ihistory); fix_bond_history->shift_history(i, m, nmax); fix_bond_history->delete_history(i, nmax); } diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index cb33b20bea..6e8c20a5d8 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -189,7 +189,7 @@ void PairRHEO::compute(int eflag, int vflag) pair_avisc_flag = 0; if (fluidi || fluidj) { pair_force_flag = 1; - if (interface_flag) pair_avisc_flag = 1; + if (!interface_flag) pair_avisc_flag = 1; } if (fluidi && fluidj) { pair_rho_flag = 1; diff --git a/src/bond_hybrid.cpp b/src/bond_hybrid.cpp index 5f84db1886..910e9a5574 100644 --- a/src/bond_hybrid.cpp +++ b/src/bond_hybrid.cpp @@ -34,6 +34,7 @@ BondHybrid::BondHybrid(LAMMPS *lmp) : Bond(lmp) nstyles = 0; has_quartic = -1; nbondlist = nullptr; + orig_map = nullptr; maxbond = nullptr; bondlist = nullptr; } @@ -55,6 +56,7 @@ BondHybrid::~BondHybrid() memory->destroy(setflag); memory->destroy(map); delete[] nbondlist; + delete[] orig_map; delete[] maxbond; for (int i = 0; i < nstyles; i++) memory->destroy(bondlist[i]); delete[] bondlist; @@ -88,6 +90,10 @@ void BondHybrid::compute(int eflag, int vflag) memory->destroy(bondlist[m]); maxbond[m] = nbondlist[m] + EXTRA; memory->create(bondlist[m], maxbond[m], 3, "bond_hybrid:bondlist"); + if (partial_flag) { + memory->destroy(orig_map[m]); + memory->create(orig_map[m], maxbond[m], "bond_hybrid:orig_map"); + } } nbondlist[m] = 0; } @@ -98,6 +104,8 @@ void BondHybrid::compute(int eflag, int vflag) bondlist[m][n][0] = bondlist_orig[i][0]; bondlist[m][n][1] = bondlist_orig[i][1]; bondlist[m][n][2] = bondlist_orig[i][2]; + if (partial_flag) + orig_map[m][n] = i; nbondlist[m]++; } } @@ -142,6 +150,19 @@ void BondHybrid::compute(int eflag, int vflag) } } + // if bond type can be set to zero and deleted, update bondlist_orig + tagint *tag = atom->tag; + if (partial_flag) { + for (m = 0; m < nstyles; m++) { + for (i = 0; i < nbondlist[m]; i++) { + if (bondlist[m][i][2] <= 0) { + n = orig_map[m][i]; + bondlist_orig[n][2] = bondlist[m][i][2]; + } + } + } + } + // restore ptrs to original bondlist neighbor->nbondlist = nbondlist_orig; @@ -161,9 +182,11 @@ void BondHybrid::allocate() nbondlist = new int[nstyles]; maxbond = new int[nstyles]; + orig_map = new int *[nstyles]; bondlist = new int **[nstyles]; for (int m = 0; m < nstyles; m++) maxbond[m] = 0; for (int m = 0; m < nstyles; m++) bondlist[m] = nullptr; + for (int m = 0; m < nstyles; m++) orig_map[m] = nullptr; } /* ---------------------------------------------------------------------- @@ -191,6 +214,8 @@ void BondHybrid::settings(int narg, char **arg) memory->destroy(map); delete[] nbondlist; delete[] maxbond; + for (i = 0; i < nstyles; i++) memory->destroy(orig_map[i]); + delete[] orig_map; for (i = 0; i < nstyles; i++) memory->destroy(bondlist[i]); delete[] bondlist; } @@ -355,6 +380,7 @@ void BondHybrid::init_style() // to create an entry for it in the bond type to sub-style map if (has_quartic >= 0) map[0] = has_quartic; + else map[0] = -1; } /* ---------------------------------------------------------------------- diff --git a/src/bond_hybrid.h b/src/bond_hybrid.h index df1437c038..282a719be5 100644 --- a/src/bond_hybrid.h +++ b/src/bond_hybrid.h @@ -50,6 +50,7 @@ class BondHybrid : public Bond { int *nbondlist; // # of bonds in sub-style bondlists int *maxbond; // max # of bonds sub-style lists can store int ***bondlist; // bondlist for each sub-style + int **orig_map; // location of substyle bond in original bondlist void allocate(); void flags(); diff --git a/src/fix_bond_history.cpp b/src/fix_bond_history.cpp index 8fa0b3f923..c2be1d481c 100644 --- a/src/fix_bond_history.cpp +++ b/src/fix_bond_history.cpp @@ -324,12 +324,13 @@ void FixBondHistory::compress_history() if (update_flag || (neighbor->ago == 0)) { for (int n = 0; n < nbondlist_orig; n++) { type = bondtype_orig[n]; + if (type <= 0) continue; - if (setflag[type]) { - for (int m = 0; m < ndata; m++) - bondstore_comp[ncomp][m] = bondstore[n][m]; - ncomp += 1; - } + if (!setflag[type]) continue; + + for (int m = 0; m < ndata; m++) + bondstore_comp[ncomp][m] = bondstore[n][m]; + ncomp += 1; } } @@ -352,7 +353,7 @@ void FixBondHistory::uncompress_history() if (!setflag[type]) continue; for (int m = 0; m < ndata; m++) - bondstore[n][m] = bondstore_comp[ncomp][m]; + bondstore_orig[n][m] = bondstore[ncomp][m]; ncomp += 1; } } diff --git a/src/fix_bond_history.h b/src/fix_bond_history.h index 8ee3132ab1..880a31eb35 100644 --- a/src/fix_bond_history.h +++ b/src/fix_bond_history.h @@ -64,6 +64,7 @@ class FixBondHistory : public Fix { int *setflag; // Set by BondBPM, which bond types are used double **bondstore; int stored_flag; + int ndata; protected: void allocate(); @@ -76,7 +77,7 @@ class FixBondHistory : public Fix { int update_flag; // Flag whether history values can evolve int updated_bond_flag; - int nbond, maxbond, ndata; + int nbond, maxbond; int index; char *id_fix; char *id_array; From 21cae39d140c94e08fead15cff6a142c217a81f0 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 24 Apr 2024 13:04:51 -0600 Subject: [PATCH 080/104] Documentation for fix add/heat --- doc/src/fix_add_heat.rst | 87 ++++++++++++++++++++++++++++++++++++ doc/src/fix_heat_flow.rst | 10 ++++- doc/src/fix_rheo_thermal.rst | 3 +- 3 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 doc/src/fix_add_heat.rst diff --git a/doc/src/fix_add_heat.rst b/doc/src/fix_add_heat.rst new file mode 100644 index 0000000000..3964c96b27 --- /dev/null +++ b/doc/src/fix_add_heat.rst @@ -0,0 +1,87 @@ +.. index:: fix add/heat + +fix add/heat command +==================== + +Syntax +"""""" + +.. code-block:: LAMMPS + + fix ID group-ID add/heat rate values ... + +* ID, group-ID are documented in :doc:`fix ` command +* add/heat = style name of this fix command +* rate = rate of heat flow (energy/time units) +* zero or more keyword/value pairs may be appended to args +* keyword = *overwrite* + + .. parsed-literal:: + + *overwrite* = sets the heat flow instead of adding it + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all add/heat v_heat + fix 1 all add/heat 1.0 overwrite + +Description +""""""""""" + +This fix adds heat to particles every timestep at a given rate. The rate +can be can be specified as an equal-style or atom-style +:doc:`variable `. If the value is a variable, it should be +specified as v_name, where name is the variable name. In this case, the +variable will be evaluated each time step, and its value will be used to +determine the rate of heat added. + +Equal-style variables can specify formulas with various mathematical +functions and include :doc:`thermo_style ` command +keywords for the simulation box parameters, time step, and elapsed time. +Thus, it is easy to specify time-dependent heating. + +Atom-style variables can specify the same formulas as equal-style +variables but can also include per-atom values, such as atom +coordinates. Thus, it is easy to specify a spatially-dependent heating +field with optional time-dependence as well. + +If the *overwrite* keyword is specified, this fix will effectively set +the total heat flow on a particle, overwriting contributions from other +pair styles. + +---------- + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +No information about this fix is written to :doc:`binary restart files `. +None of the :doc:`fix_modify ` options are relevant to this fix. +No global or per-atom quantities are stored by this fix for access by various +:doc:`output commands `. 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 pair style is part of the GRANULAR package. It is +only enabled if LAMMPS was built with that package. +See the :doc:`Build package ` page for more info. + +This fix requires that atoms store temperature and heat flow +as defined by the :doc:`fix property/atom ` command. + +Related commands +"""""""""""""""" + +:doc:`fix heat/flow `, +:doc:`fix property/atom `, +:doc:`fix rheo/thermal ` + +Default +""""""" + +none diff --git a/doc/src/fix_heat_flow.rst b/doc/src/fix_heat_flow.rst index 1ca99a1686..aa2b3fbc06 100644 --- a/doc/src/fix_heat_flow.rst +++ b/doc/src/fix_heat_flow.rst @@ -1,7 +1,7 @@ .. index:: fix heat/flow fix heat/flow command -========================== +===================== Syntax """""" @@ -56,13 +56,19 @@ not invoked during :doc:`energy minimization `. Restrictions """""""""""" +This pair style is part of the GRANULAR package. It is +only enabled if LAMMPS was built with that package. +See the :doc:`Build package ` page for more info. + This fix requires that atoms store temperature and heat flow as defined by the :doc:`fix property/atom ` command. Related commands """""""""""""""" -:doc:`pair granular `, :doc:`fix property/atom ` +:doc:`pair granular `, +:doc:`fix add/heat `, +:doc:`fix property/atom ` Default """"""" diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst index 63d9f817ad..2ffb665bb7 100644 --- a/doc/src/fix_rheo_thermal.rst +++ b/doc/src/fix_rheo_thermal.rst @@ -109,7 +109,8 @@ Related commands :doc:`fix rheo `, :doc:`pair rheo `, -:doc:`compute rheo/property/atom ` +:doc:`compute rheo/property/atom `, +:doc:`fix add/heat ` Default """"""" From 7ad74ffbd8eba648d9cbf2cbbb183ea13904ea36 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 24 Apr 2024 13:10:44 -0600 Subject: [PATCH 081/104] Removing unused files --- src/RHEO/fix_rheo_tension.cpp | 718 ---------------------------------- src/RHEO/fix_rheo_tension.h | 59 --- 2 files changed, 777 deletions(-) delete mode 100644 src/RHEO/fix_rheo_tension.cpp delete mode 100644 src/RHEO/fix_rheo_tension.h diff --git a/src/RHEO/fix_rheo_tension.cpp b/src/RHEO/fix_rheo_tension.cpp deleted file mode 100644 index 388b574365..0000000000 --- a/src/RHEO/fix_rheo_tension.cpp +++ /dev/null @@ -1,718 +0,0 @@ -/* ---------------------------------------------------------------------- - 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 authors: - Joel Clemmer (SNL) ------------------------------------------------------------------------ */ - -// Todo: -// add citations -// remove (or fix) pairwise forces on undercoordinated atoms -// add option for vacuum tension (Frustenau 2020?) - -#include "fix_rheo_tension.h" - -#include "atom.h" -#include "comm.h" -#include "compute_rheo_kernel.h" -#include "compute_rheo_interface.h" -#include "compute_rheo_vshift.h" -#include "domain.h" -#include "error.h" -#include "fix_rheo.h" -#include "force.h" -#include "math_extra.h" -#include "memory.h" -#include "modify.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "update.h" -#include "utils.h" - -#include - -using namespace LAMMPS_NS; -using namespace RHEO_NS; -using namespace MathExtra; -using namespace FixConst; - -/* ---------------------------------------------------------------------- */ - -FixRHEOTension::FixRHEOTension(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), compute_kernel(nullptr), compute_interface(nullptr), compute_vshift(nullptr), fix_rheo(nullptr), rho0(nullptr) -{ - if (narg != 8) error->all(FLERR,"Illegal fix command"); - alpha = utils::numeric(FLERR, arg[3], false, lmp); - beta = utils::numeric(FLERR, arg[4], false, lmp); - wmin = utils::numeric(FLERR, arg[5], false, lmp); - cmin = utils::numeric(FLERR, arg[6], false, lmp); - vshift_strength = utils::numeric(FLERR, arg[7], false, lmp); - - comm_forward = 3; - comm_reverse = 3; - - // Create cgrad, n, and divr arrays as custom atom properties, - // can print with compute property/atom - // no grow callback as there's no reason to copy/exchange data, manually grow - // For norm, create a local array since they are unlikely to be printed - - int tmp1, tmp2; - index_ct = atom->find_custom("c_rheo_tension", tmp1, tmp2); - if (index_ct == -1) index_ct = atom->add_custom("c_rheo_tension", 1, 0); - ct = atom->dvector[index_ct]; - - index_cgradt = atom->find_custom("cgrad_rheo_tension", tmp1, tmp2); - if (index_cgradt == -1) index_cgradt = atom->add_custom("cgrad_rheo_tension", 1, 3); - cgradt = atom->darray[index_cgradt]; - - index_nt = atom->find_custom("n_rheo_tension", tmp1, tmp2); - if (index_nt == -1) index_nt = atom->add_custom("n_rheo_tension", 1, 3); - nt = atom->darray[index_nt]; - - index_divnt = atom->find_custom("divn_rheo_tension", tmp1, tmp2); - if (index_divnt == -1) index_divnt = atom->add_custom("divn_rheo_tension", 1, 0); - divnt = atom->dvector[index_divnt]; - - index_wsame = atom->find_custom("wsame_rheo_tension", tmp1, tmp2); - if (index_wsame == -1) index_wsame = atom->add_custom("wsame_rheo_tension", 1, 0); - wsame = atom->dvector[index_wsame]; - - index_ft = atom->find_custom("f_rheo_tension", tmp1, tmp2); - if (index_ft == -1) index_ft = atom->add_custom("f_rheo_tension", 1, 3); - ft = atom->darray[index_ft]; - - norm = nullptr; - nmax_store = 0; -} - -/* ---------------------------------------------------------------------- */ - -FixRHEOTension::~FixRHEOTension() -{ - // Remove custom property if it exists - int tmp1, tmp2, index; - - index = atom->find_custom("c_rheo_tension", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); - - index = atom->find_custom("cgrad_rheo_tension", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 3); - - index = atom->find_custom("n_rheo_tension", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 3); - - index = atom->find_custom("divn_rheo_tension", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); - - index = atom->find_custom("wsame_rheo_tension", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); - - index = atom->find_custom("f_rheo_tension", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 3); - - memory->destroy(norm); -} - -/* ---------------------------------------------------------------------- */ - -int FixRHEOTension::setmask() -{ - int mask = 0; - mask |= PRE_FORCE; - return mask; -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOTension::init() -{ - auto fixes = modify->get_fix_by_style("^rheo$"); - if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/tension"); - fix_rheo = dynamic_cast(fixes[0]); - - compute_kernel = fix_rheo->compute_kernel; - compute_interface = fix_rheo->compute_interface; - compute_vshift = fix_rheo->compute_vshift; - interface_flag = fix_rheo->interface_flag; - shift_flag = fix_rheo->shift_flag; - h = fix_rheo->h; - rho0 = fix_rheo->rho0; - - hsq = h * h; - - neighbor->add_request(this, NeighConst::REQ_DEFAULT); -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOTension::init_list(int /*id*/, NeighList *ptr) -{ - list = ptr; -} - - -/* ---------------------------------------------------------------------- */ - -void FixRHEOTension::setup(int vflag) -{ - // Grow and populate arrays for dump files - if (nmax_store <= atom->nmax) - grow_arrays(atom->nmax); - - size_t nbytes = nmax_store * sizeof(double); - memset(&ct[0], 0, nbytes); - memset(&norm[0], 0, nbytes); - memset(&wsame[0], 0, nbytes); - memset(&divnt[0], 0, nbytes); - memset(&cgradt[0][0], 0, 3 * nbytes); - memset(&ft[0][0], 0, 3 * nbytes); - memset(&nt[0][0], 0, 3 * nbytes); -} - -/* ---------------------------------------------------------------------- - Calculate and apply tension forces -------------------------------------------------------------------------- */ - -void FixRHEOTension::pre_force(int vflag) -{ - int i, j, a, ii, jj, inum, jnum, itype, jtype; - int fluidi, fluidj; - double xtmp, ytmp, ztmp, w, wp, ctmp; - double rhoi, rhoj, Voli, Volj; - double *dWij, *dWji; - double dx[3]; - - int *ilist, *jlist, *numneigh, **firstneigh; - double imass, jmass, rsq, r, rinv; - - int nlocal = atom->nlocal; - int newton = force->newton; - int dim = domain->dimension; - - v_init(vflag); - - double **x = atom->x; - double **f = atom->f; - double *rho = atom->rho; - double *mass = atom->mass; - imageint *image = atom->image; - int *type = atom->type; - int *status = atom->status; - - inum = list->inum; - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - if (nmax_store <= atom->nmax) - grow_arrays(atom->nmax); - - size_t nbytes = nmax_store * sizeof(double); - memset(&ct[0], 0, nbytes); - memset(&norm[0], 0, nbytes); - memset(&wsame[0], 0, nbytes); - memset(&divnt[0], 0, nbytes); - memset(&cgradt[0][0], 0, 3 * nbytes); - memset(&ft[0][0], 0, 3 * nbytes); - - // Calculate color gradient - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - fluidi = !(status[i] & PHASECHECK); - jlist = firstneigh[i]; - jnum = numneigh[i]; - imass = mass[itype]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - dx[0] = xtmp - x[j][0]; - dx[1] = ytmp - x[j][1]; - dx[2] = ztmp - x[j][2]; - - rsq = lensq3(dx); - - if (rsq > hsq) continue; - - fluidj = !(status[j] & PHASECHECK); - jtype = type[j]; - r = sqrt(rsq); - - rhoi = rho[i]; - rhoj = rho[j]; - - // Add corrections for walls - if (interface_flag) { - if (fluidi && (!fluidj)) { - rhoj = compute_interface->correct_rho(j, i); - } else if ((!fluidi) && fluidj) { - rhoi = compute_interface->correct_rho(i, j); - } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0[itype]; - rhoj = rho0[jtype]; - } - } - - Voli = mass[itype] / rhoi; - Volj = mass[jtype] / rhoj; - - w = compute_kernel->calc_w(i, j, dx[0], dx[1], dx[2], r); - - if (itype != jtype) ctmp = 1; - else ctmp = 0; - - ct[i] += ctmp * Volj * w; - if (newton || j < nlocal) - ct[j] += ctmp * Voli * w; - } - } - - comm_stage = 0; - comm_reverse = 1; - if (newton) comm->reverse_comm(this); - - // Calculate color gradient - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - fluidi = !(status[i] & PHASECHECK); - jlist = firstneigh[i]; - jnum = numneigh[i]; - imass = mass[itype]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - dx[0] = xtmp - x[j][0]; - dx[1] = ytmp - x[j][1]; - dx[2] = ztmp - x[j][2]; - rsq = lensq3(dx); - - if (rsq > hsq) continue; - - fluidj = !(status[j] & PHASECHECK); - jtype = type[j]; - r = sqrt(rsq); - - rhoi = rho[i]; - rhoj = rho[j]; - - // Add corrections for walls - if (interface_flag) { - if (fluidi && (!fluidj)) { - rhoj = compute_interface->correct_rho(j, i); - } else if ((!fluidi) && fluidj) { - rhoi = compute_interface->correct_rho(i, j); - } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0[itype]; - rhoj = rho0[jtype]; - } - } - - Voli = mass[itype] / rhoi; - Volj = mass[jtype] / rhoj; - - wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2], r); - dWij = compute_kernel->dWij; - dWji = compute_kernel->dWji; - - //c = 0; - //if (itype != jtype) c += rhoi; - //c /= (rhoi + rhoj); - - if (itype != jtype) ctmp = 1; - else ctmp = 0; - - for (a = 0; a < dim; a++) { - cgradt[i][a] -= ctmp * Volj * dWij[a]; - if (newton || j < nlocal) - cgradt[j][a] -= ctmp * Voli * dWji[a]; - } - } - } - - comm_stage = 1; - comm_reverse = 3; - if (newton) comm->reverse_comm(this); - - // Calculate normal direction - double minv; - for (i = 0; i < nlocal; i++) { - minv = cgradt[i][0] * cgradt[i][0] + cgradt[i][1] * cgradt[i][1]; - if (dim == 3) minv += cgradt[i][2] * cgradt[i][2]; - minv = sqrt(minv); - if (minv != 0) minv = 1 / minv; - - for (a = 0; a < dim; a++) - nt[i][a] = cgradt[i][a] * minv; - } - - comm_forward = 3; - comm->forward_comm(this); - - // Calculate divergence - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - fluidi = !(status[i] & PHASECHECK); - jlist = firstneigh[i]; - jnum = numneigh[i]; - imass = mass[itype]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - dx[0] = xtmp - x[j][0]; - dx[1] = ytmp - x[j][1]; - dx[2] = ztmp - x[j][2]; - rsq = lensq3(dx); - - if (rsq > hsq) continue; - - fluidj = !(status[j] & PHASECHECK); - jtype = type[j]; - r = sqrt(rsq); - rinv = 1 / r; - - rhoi = rho[i]; - rhoj = rho[j]; - - // Add corrections for walls - if (interface_flag) { - if (fluidi && (!fluidj)) { - rhoj = compute_interface->correct_rho(j, i); - } else if ((!fluidi) && fluidj) { - rhoi = compute_interface->correct_rho(i, j); - } else if ((!fluidi) && (!fluidj)) { - rhoi = rho0[itype]; - rhoj = rho0[jtype]; - } - } - - Voli = mass[itype] / rhoi; - Volj = mass[jtype] / rhoj; - - w = compute_kernel->calc_w(i, j, dx[0], dx[1], dx[2], r); - wp = compute_kernel->calc_dw(i, j, dx[0], dx[1], dx[2], r); - dWij = compute_kernel->dWij; - dWji = compute_kernel->dWji; - - for (a = 0; a < dim; a++) { - if (itype != jtype) { - divnt[i] -= (nt[i][a] + nt[j][a]) * Volj * dWij[a]; - } else { - divnt[i] -= (nt[i][a] - nt[j][a]) * Volj * dWij[a]; - wsame[i] += w * r; - } - norm[i] -= dx[a] * Volj * dWij[a]; - if (newton || j < nlocal) { - if (itype != jtype) { - divnt[j] -= (nt[j][a] + nt[i][a]) * Voli * dWji[a]; - } else { - divnt[j] -= (nt[j][a] - nt[i][a]) * Voli * dWji[a]; - wsame[j] += w * r; - } - norm[j] += dx[a] * Voli * dWji[a]; - } - } - } - } - - comm_stage = 2; - comm_reverse = 3; - if (newton) comm->reverse_comm(this); - - comm_forward = 1; - comm->forward_comm(this); - - // Skip forces if it's setup - if (update->setupflag) return; - - // apply force, remove normal vshift - - double **vshift; - if (shift_flag) - vshift = compute_vshift->vshift; - double nx, ny, nz, vx, vy, vz, dot; - double wmin_inv, weight, prefactor, unwrap[3], v[6]; - - if (wmin > 0) wmin_inv = 1.0 / wmin; - else wmin_inv = 0.0; - - for (i = 0; i < nlocal; i++) { - - if (wsame[i] < wmin) continue; - - weight = MIN(1.0, wsame[i] * wmin_inv); //MAX -> MIN 2/14/24 - itype = type[i]; - - if (norm[i] != 0) - divnt[i] *= dim * norm[i]; - else - divnt[i] = 0.0; - - // Tension force from Adami, Hu, Adams 2010 - prefactor = -alpha * divnt[i] * weight; - for (a = 0; a < dim; a++) { - f[i][a] += prefactor * cgradt[i][a]; - ft[i][a] += prefactor * cgradt[i][a]; - } - - // remove normal shifting component for interfacial particles - // Based on Yang, Rakhsha, Hu, & Negrut 2022 - if (shift_flag && (vshift_strength != 1.0)) { - if (ct[i] > cmin) { - nx = nt[i][0]; - ny = nt[i][1]; - vx = vshift[i][0]; - vy = vshift[i][1]; - - dot = nx * vx + ny * vy; - if (dim == 3) { - nz = nt[i][2]; - vz = vshift[i][2]; - dot += nz * vz; - } - - // Allowing shifting into the bulk - //if (dot > 0.0) continue; - - vshift[i][0] -= (1.0 - vshift_strength) * nx * dot; - vshift[i][1] -= (1.0 - vshift_strength) * ny * dot; - if (dim == 3) { - vshift[i][2] -= (1.0 - vshift_strength) * nz * dot; - } - } - } - - if (evflag) { - domain->unmap(x[i], image[i], unwrap); - v[0] = prefactor * cgradt[i][0] * unwrap[0]; - v[1] = prefactor * cgradt[i][1] * unwrap[1]; - v[2] = prefactor * cgradt[i][2] * unwrap[2]; - v[3] = prefactor * cgradt[i][0] * unwrap[1]; - v[4] = prefactor * cgradt[i][0] * unwrap[2]; - v[5] = prefactor * cgradt[i][1] * unwrap[2]; - v_tally(i, v); - } - } - - // If there is no lower limit, apply optional pairwise forces - // This is totally ad hoc, needs some work - // Attempts to deal with stray single particles - if (wmin <= 0 || beta == 0.0) return; - - int newton_pair = force->newton_pair; - double fpair, wi, wj; - double cut_two_thirds = 2.0 * h / 3.0; - double cut_five_sixths = 5.0 * h / 6.0; - double cut_sixth_sq = (h / 6.0) * (h / 6.0); - double cut_third_sq = (h / 3.0) * (h / 3.0); - for (ii = 0; ii < inum; ii++) { - i = ilist[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - wi = MAX(MIN(1.0, (wmin - wsame[i]) * wmin_inv), 0.0); - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - if (wsame[i] >= wmin && wsame[j] >= wmin) continue; - - dx[0] = xtmp - x[j][0]; - dx[1] = ytmp - x[j][1]; - dx[2] = ztmp - x[j][2]; - rsq = lensq3(dx); - - if (rsq > hsq) continue; - - r = sqrt(rsq); - jtype = type[j]; - - if (itype == jtype) { - fpair = (r - cut_two_thirds); - fpair *= fpair; - fpair -= cut_third_sq; - } else { - //fpair = 0.0; - - if (r > (0.5*cut_two_thirds)) continue; - fpair = (r - cut_two_thirds); - fpair *= fpair; - fpair -= cut_third_sq; - - //if (r > cut_two_thirds) continue; - //fpair = (r - cut_five_sixths); - //fpair *= fpair; - //fpair -= cut_sixth_sq; - - //fpair = (h - r) * 0.66666666666666; - } - - wj = MAX(MIN(1.0, (wmin - wsame[j]) * wmin_inv), 0.0); - rinv = 1.0 / r; - fpair *= MAX(wi, wj) * beta * rinv; - - f[i][0] += dx[0] * fpair; - f[i][1] += dx[1] * fpair; - f[i][2] += dx[2] * fpair; - - if (newton_pair || j < nlocal) { - f[j][0] -= dx[0] * fpair; - f[j][1] -= dx[1] * fpair; - f[j][2] -= dx[2] * fpair; - } - - if (evflag) { - // In progress - } - } - } -} - - -/* ---------------------------------------------------------------------- */ - -int FixRHEOTension::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) -{ - int i, j, a, m; - m = 0; - - if (comm_stage == 1) - for (i = 0; i < n; i++) { - j = list[i]; - for (a = 0; a < 3; a++) - buf[m++] = nt[j][a]; - } - else if (comm_stage == 2) - for (i = 0; i < n; i++) { - j = list[i]; - buf[m++] = wsame[j]; - } - - return m; -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOTension::unpack_forward_comm(int n, int first, double *buf) -{ - int i, a, m, last; - - m = 0; - last = first + n; - if (comm_stage == 1) - for (i = first; i < last; i++) - for (a = 0; a < 3; a++) - nt[i][a] = buf[m++]; - else if (comm_stage == 2) - for (i = first; i < last; i++) - wsame[i] = buf[m++]; -} - - -/* ---------------------------------------------------------------------- */ - -int FixRHEOTension::pack_reverse_comm(int n, int first, double *buf) -{ - int i, a, m, last; - - m = 0; - last = first + n; - if (comm_stage == 0) - for (i = first; i < last; i++) - buf[m++] = ct[i]; - else if (comm_stage == 1) - for (i = first; i < last; i++) - for (a = 0; a < 3; a++) - buf[m++] = cgradt[i][a]; - else if (comm_stage == 2) - for (i = first; i < last; i++) { - buf[m++] = norm[i]; - buf[m++] = divnt[i]; - buf[m++] = wsame[i]; - } - return m; -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOTension::unpack_reverse_comm(int n, int *list, double *buf) -{ - int i, j, a, m; - - m = 0; - if (comm_stage == 0) - for (i = 0; i < n; i++) { - j = list[i]; - ct[j] += buf[m++]; - } - else if (comm_stage == 1) - for (i = 0; i < n; i++) { - j = list[i]; - for (a = 0; a < 3; a++) - cgradt[j][a] += buf[m++]; - } - else if (comm_stage == 2) - for (i = 0; i < n; i++) { - j = list[i]; - norm[j] += buf[m++]; - divnt[j] += buf[m++]; - wsame[j] += buf[m++]; - } -} - -/* ---------------------------------------------------------------------- */ - -void FixRHEOTension::grow_arrays(int nmax) -{ - // Grow atom variables and reassign pointers - memory->grow(atom->dvector[index_ct], nmax, "atom:rheo_ct"); - memory->grow(atom->darray[index_cgradt], nmax, 3, "atom:rheo_cgradt"); - memory->grow(atom->darray[index_nt], nmax, 3, "atom:rheo_nt"); - memory->grow(atom->dvector[index_divnt], nmax, "atom:rheo_divnt"); - memory->grow(atom->dvector[index_wsame], nmax, "atom:rheo_wsame"); - memory->grow(atom->darray[index_ft], nmax, 3, "atom:rheo_ft"); - - ct = atom->dvector[index_ct]; - cgradt = atom->darray[index_cgradt]; - nt = atom->darray[index_nt]; - divnt = atom->dvector[index_divnt]; - wsame = atom->dvector[index_wsame]; - ft = atom->darray[index_ft]; - - // Grow local variables - memory->grow(norm, nmax, "rheo/tension:norm"); - - nmax_store = atom->nmax; -} \ No newline at end of file diff --git a/src/RHEO/fix_rheo_tension.h b/src/RHEO/fix_rheo_tension.h deleted file mode 100644 index 52d368531f..0000000000 --- a/src/RHEO/fix_rheo_tension.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- 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(rheo/tension,FixRHEOTension) -// clang-format on -#else - -#ifndef LMP_FIX_RHEO_TENSION_H -#define LMP_FIX_RHEO_TENSION_H - -#include "fix.h" - -namespace LAMMPS_NS { - -class FixRHEOTension : public Fix { - public: - FixRHEOTension(class LAMMPS *, int, char **); - ~FixRHEOTension() override; - int setmask() override; - void init() override; - void init_list(int, class NeighList *) override; - void setup(int) override; - void pre_force(int) override; - int pack_forward_comm(int, int *, double *, int, int *) override; - void unpack_forward_comm(int, int, double *) override; - int pack_reverse_comm(int, int, double *) override; - void unpack_reverse_comm(int, int *, double *) override; - void grow_arrays(int) override; - - private: - int nmax_store, comm_stage, interface_flag, shift_flag; - int index_ct, index_nt, index_cgradt, index_divnt, index_ft, index_wsame; - - double *ct, **nt, **cgradt, *divnt, *norm, **ft, *wsame; - double alpha, beta, wmin, cmin, vshift_strength, h, hsq, hinv, hinv3, *rho0; - - class ComputeRHEOKernel *compute_kernel; - class ComputeRHEOInterface *compute_interface; - class ComputeRHEOVShift *compute_vshift; - class FixRHEO *fix_rheo; - class NeighList *list; -}; - -} // namespace LAMMPS_NS - -#endif -#endif From 4886678619aa9daf9d31346422821a6a69e8072f Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 29 Apr 2024 16:14:53 -0600 Subject: [PATCH 082/104] Updating masks, cleaning up special bond handling --- src/BPM/fix_update_special_bonds.cpp | 33 ++++++++++++++-------- src/RHEO/fix_rheo.h | 10 +++---- src/RHEO/fix_rheo_thermal.cpp | 42 ++++++++++++++++++++++------ 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/src/BPM/fix_update_special_bonds.cpp b/src/BPM/fix_update_special_bonds.cpp index b6bf8b433f..b21de90b52 100644 --- a/src/BPM/fix_update_special_bonds.cpp +++ b/src/BPM/fix_update_special_bonds.cpp @@ -93,16 +93,19 @@ void FixUpdateSpecialBonds::pre_exchange() for (auto const &it : broken_pairs) { tagi = it.first; tagj = it.second; + i = atom->map(tagi); j = atom->map(tagj); // remove i from special bond list for atom j and vice versa // ignore n2, n3 since 1-3, 1-4 special factors required to be 1.0 + // assume ghosts don't need special information if (i < nlocal) { slist = special[i]; n1 = nspecial[i][0]; for (m = 0; m < n1; m++) if (slist[m] == tagj) break; + if (m == n1) error->one(FLERR, "Special bond {} {} not found", tagi, tagj); for (; m < n1 - 1; m++) slist[m] = slist[m + 1]; nspecial[i][0]--; nspecial[i][1] = nspecial[i][2] = nspecial[i][0]; @@ -113,6 +116,7 @@ void FixUpdateSpecialBonds::pre_exchange() n1 = nspecial[j][0]; for (m = 0; m < n1; m++) if (slist[m] == tagi) break; + if (m == n1) error->one(FLERR, "Special bond {} {} not found", tagi, tagj); for (; m < n1 - 1; m++) slist[m] = slist[m + 1]; nspecial[j][0]--; nspecial[j][1] = nspecial[j][2] = nspecial[j][0]; @@ -127,19 +131,24 @@ void FixUpdateSpecialBonds::pre_exchange() // add i to special bond list for atom j and vice versa // ignore n2, n3 since 1-3, 1-4 special factors required to be 1.0 - n1 = nspecial[i][0]; - if (n1 >= atom->maxspecial) - error->one(FLERR, "Special list size exceeded in fix update/special/bond"); - special[i][n1] = tagj; - nspecial[i][0] += 1; - nspecial[i][1] = nspecial[i][2] = nspecial[i][0]; + // assume ghosts don't need special information + if (i < nlocal) { + n1 = nspecial[i][0]; + if (n1 >= atom->maxspecial) + error->one(FLERR, "Special list size exceeded for atom {}", tagi); + special[i][n1] = tagj; + nspecial[i][0] += 1; + nspecial[i][1] = nspecial[i][2] = nspecial[i][0]; + } - n1 = nspecial[j][0]; - if (n1 >= atom->maxspecial) - error->one(FLERR, "Special list size exceeded in fix update/special/bond"); - special[j][n1] = tagi; - nspecial[j][0] += 1; - nspecial[j][1] = nspecial[j][2] = nspecial[j][0]; + if (j < nlocal) { + n1 = nspecial[j][0]; + if (n1 >= atom->maxspecial) + error->one(FLERR, "Special list size exceeded for atom {}", tagj); + special[j][n1] = tagi; + nspecial[j][0] += 1; + nspecial[j][1] = nspecial[j][2] = nspecial[j][0]; + } } broken_pairs.clear(); diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 45f74ed4cd..51e0962000 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -94,11 +94,11 @@ namespace RHEO_NS { }; // Masks and their inverses - #define PHASEMASK 0xFFFFFFFC - #define PHASECHECK 0x00000003 - #define SURFACEMASK 0xFFFFFFC3 - #define SURFACECHECK 0x0000003C - #define OPTIONSMASK 0xFFFFFE3F + #define PHASEMASK 0xFFFFFFFC // 11111111111111111111111111111100 + #define PHASECHECK 0x00000003 // 00000000000000000000000000000011 + #define SURFACEMASK 0xFFFFFFC3 // 11111111111111111111111111000011 + #define SURFACECHECK 0x0000003C // 00000000000000000000000000111100 + #define OPTIONSMASK 0xFFFFFC3F // 11111111111111111111110000111111 } // namespace RHEO_NS } // namespace LAMMPS_NS diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 3a39bbe596..f2dbd6c8bb 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -281,6 +281,10 @@ void FixRHEOThermal::init() fix_update_special_bonds = dynamic_cast(fixes[0]); } + // must have newton off so both processors will search nlist to build bonds + if (force->newton_pair) + error->all(FLERR, "Need Newton off for reactive bond generation"); + // need a half neighbor list, built only when particles freeze auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); req->set_cutoff(cut_kernel); @@ -494,7 +498,7 @@ void FixRHEOThermal::reset_dt() void FixRHEOThermal::break_bonds() { - int m, n, nmax, i, j; + int m, n, nmax, i, j, melti, meltj; tagint *tag = atom->tag; int *status = atom->status; @@ -510,11 +514,13 @@ void FixRHEOThermal::break_bonds() // Delete all bonds for local atoms that melt of a given type for (int i = 0; i < nlocal; i++) { - if (!(status[i] & STATUS_MELTING)) continue; + melti = status[i] & STATUS_MELTING; + if (!melti) continue; for (m = (num_bond[i] - 1); m >= 0; m--) { if (bond_type[i][m] != btype) continue; j = atom->map(bond_atom[i][m]); + meltj = status[j] & STATUS_MELTING; nmax = num_bond[i] - 1; if (m == nmax) { @@ -535,8 +541,17 @@ void FixRHEOThermal::break_bonds() bond_type[i][nmax] = 0; num_bond[i]--; - if (fix_update_special_bonds) - fix_update_special_bonds->add_broken_bond(i, j); + // Update special unless two owned atoms melt simultaneously then + // only update for atom with lower tag + if (fix_update_special_bonds) { + if (i < nlocal && j < nlocal && melti && meltj) { + if (tag[i] < tag[j]) { + fix_update_special_bonds->add_broken_bond(i, j); + } + } else { + fix_update_special_bonds->add_broken_bond(i, j); + } + } } } @@ -548,12 +563,15 @@ void FixRHEOThermal::break_bonds() i = bondlist[n][0]; j = bondlist[n][1]; - if (!(status[i] & STATUS_MELTING) && !(status[j] & STATUS_MELTING)) continue; + melti = status[i] & STATUS_MELTING; + meltj = status[j] & STATUS_MELTING; + + if (!melti && !meltj) continue; bondlist[n][2] = 0; // Delete bonds for non-melted local atoms (shifting) - if (i < nlocal && !(status[i] & STATUS_MELTING)) { + if (i < nlocal && !melti) { for (m = 0; m < num_bond[i]; m++) { if (bond_atom[i][m] == tag[j] && bond_type[i][m] == btype) { nmax = num_bond[i] - 1; @@ -572,7 +590,7 @@ void FixRHEOThermal::break_bonds() } } - if (j < nlocal && !(status[j] & STATUS_MELTING)) { + if (j < nlocal && !meltj) { for (m = 0; m < num_bond[j]; m++) { if (bond_atom[j][m] == tag[i] && bond_type[j][m] == btype) { nmax = num_bond[j] - 1; @@ -590,6 +608,12 @@ void FixRHEOThermal::break_bonds() } } } + + // Unless both atoms melt simultaneously, need to remove special bond if the melted atom is a ghost + if (melti && meltj) continue; + if (fix_update_special_bonds) + if (((i >= nlocal) && melti) || ((j >= nlocal) && meltj)) + fix_update_special_bonds->add_broken_bond(i, j); } } @@ -649,7 +673,6 @@ void FixRHEOThermal::create_bonds() if (i < nlocal && (!newton_bond || tag[i] < tag[j])) { if (num_bond[i] == atom->bond_per_atom) error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/thermal"); - if (fix_update_special_bonds) fix_update_special_bonds->add_created_bond(i, j); bond_type[i][num_bond[i]] = btype; bond_atom[i][num_bond[i]] = tag[j]; num_bond[i]++; @@ -658,11 +681,12 @@ void FixRHEOThermal::create_bonds() if (j < nlocal && (!newton_bond || tag[j] < tag[i])) { if (num_bond[j] == atom->bond_per_atom) error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/thermal"); - if (fix_update_special_bonds) fix_update_special_bonds->add_created_bond(i, j); bond_type[j][num_bond[j]] = btype; bond_atom[j][num_bond[j]] = tag[i]; num_bond[j]++; } + + if (fix_update_special_bonds) fix_update_special_bonds->add_created_bond(i, j); } } } From da7459c80562724e900e82024c9c82db90df89bd Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 3 May 2024 15:13:45 -0600 Subject: [PATCH 083/104] Adding heat options, prevent asynchronous mpi bond creation/deletion --- doc/src/fix_add_heat.rst | 44 +++++++++++---- src/GRANULAR/fix_add_heat.cpp | 95 ++++++++++++++++++++------------- src/GRANULAR/fix_add_heat.h | 6 +-- src/RHEO/fix_rheo_oxidation.cpp | 61 ++++++++++++++++++--- src/RHEO/fix_rheo_oxidation.h | 2 + src/RHEO/fix_rheo_thermal.cpp | 34 ++++++++---- 6 files changed, 174 insertions(+), 68 deletions(-) diff --git a/doc/src/fix_add_heat.rst b/doc/src/fix_add_heat.rst index 3964c96b27..2a2d855927 100644 --- a/doc/src/fix_add_heat.rst +++ b/doc/src/fix_add_heat.rst @@ -8,31 +8,53 @@ Syntax .. code-block:: LAMMPS - fix ID group-ID add/heat rate values ... + fix ID group-ID add/heat style args keyword values ... * ID, group-ID are documented in :doc:`fix ` command * add/heat = style name of this fix command -* rate = rate of heat flow (energy/time units) +* style = *constant* or *linear* or *quartic* + + .. parsed-literal:: + + *constant* args = rate + rate = rate of heat flow (energy/time units) + *linear* args = t_target k + t_target = target temperature (temperature units) + k = prefactor (energy/(time*temperature) units) + *quartic* args = t_target k + t_target = target temperature (temperature units) + k = prefactor (energy/(time*temperature^4) units) + * zero or more keyword/value pairs may be appended to args * keyword = *overwrite* .. parsed-literal:: - *overwrite* = sets the heat flow instead of adding it + *overwrite* value = *yes* or *no* + *yes* = sets current heat flow of particle + *no* = adds to current heat flow of particle Examples """""""" .. code-block:: LAMMPS - fix 1 all add/heat v_heat - fix 1 all add/heat 1.0 overwrite + fix 1 all add/heat constant v_heat + fix 1 all add/heat linear 10.0 1.0 overwrite yes Description """"""""""" -This fix adds heat to particles every timestep at a given rate. The rate -can be can be specified as an equal-style or atom-style +This fix adds heat to particles every timestep. + +For the *constant* style, heat is added at the specified rate. For the *linear* style, +heat is added at a rate of :math:`k (T_{target} - T)` where :math:`k` is the +specified prefactor, :math:`T_{target}` is the specified target temperature, and +:math:`T` is the temperature of the atom. This may be more representative of a +conductive process. For the *quartic* style, heat is added at a rate of +:math:`k (T_{target}^4 - T^4)`, akin to radiative heat transfer. + +The rate or temperature can be can be specified as an equal-style or atom-style :doc:`variable `. If the value is a variable, it should be specified as v_name, where name is the variable name. In this case, the variable will be evaluated each time step, and its value will be used to @@ -48,9 +70,9 @@ variables but can also include per-atom values, such as atom coordinates. Thus, it is easy to specify a spatially-dependent heating field with optional time-dependence as well. -If the *overwrite* keyword is specified, this fix will effectively set -the total heat flow on a particle, overwriting contributions from other -pair styles. +If the *overwrite* keyword is set to *yes*, this fix will effectively set +the total heat flow on a particle, overwriting contributions from pair +styles or other fixes. ---------- @@ -84,4 +106,4 @@ Related commands Default """"""" -none +The default for the *overwrite* keyword is *no* diff --git a/src/GRANULAR/fix_add_heat.cpp b/src/GRANULAR/fix_add_heat.cpp index 2db3389560..7109ffb01c 100644 --- a/src/GRANULAR/fix_add_heat.cpp +++ b/src/GRANULAR/fix_add_heat.cpp @@ -27,34 +27,52 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum { NONE, CONSTANT, EQUAL, ATOM }; +enum { CONSTANT, EQUAL, ATOM }; +enum { ADD, LINEAR, QUARTIC }; /* ---------------------------------------------------------------------- */ FixAddHeat::FixAddHeat(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), varstr(nullptr), qatom(nullptr) + Fix(lmp, narg, arg), varstr(nullptr), vatom(nullptr) { - if (narg < 4) utils::missing_cmd_args(FLERR, "fix add/heat", error); + if (narg < 5) utils::missing_cmd_args(FLERR, "fix add/heat", error); dynamic_group_allow = 1; overwrite_flag = 0; - style = NONE; - if (utils::strmatch(arg[3], "^v_")) { - varstr = utils::strdup(arg[3] + 2); + if (strcmp(arg[3], "constant") == 0) { + style = ADD; + } else if (strcmp(arg[3], "linear") == 0) { + style = LINEAR; + } else if (strcmp(arg[3], "quartic") == 0) { + style = QUARTIC; } else { - value = utils::numeric(FLERR, arg[3], false, lmp); - style = CONSTANT; + error->all(FLERR, "Invalid option {}", arg[3]); + } + + if (utils::strmatch(arg[4], "^v_")) { + varstr = utils::strdup(arg[4] + 2); + } else { + value = utils::numeric(FLERR, arg[4], false, lmp); + vstyle = CONSTANT; + } + + int iarg = 5; + if (style != ADD) { + if (narg != 6) utils::missing_cmd_args(FLERR, "fix add/heat", error); + prefactor = utils::numeric(FLERR, arg[5], false, lmp); + iarg = 6; } // optional args - int iarg = 4; while (iarg < narg) { if (strcmp(arg[iarg], "overwrite") == 0) { - overwrite_flag = 1; - iarg += 1; - } else - error->all(FLERR, "Illegal fix viscous command"); + if (iarg + 1 >= narg) utils::missing_cmd_args(FLERR, "fix add/heat", error); + overwrite_flag = utils::bnumeric(FLERR, arg[iarg + 1], false, lmp); + iarg += 2; + } else { + error->all(FLERR, "Illegal fix add/heat command, invalid argument {}", arg[iarg]); + } } maxatom = -1; @@ -65,7 +83,7 @@ FixAddHeat::FixAddHeat(LAMMPS *lmp, int narg, char **arg) : FixAddHeat::~FixAddHeat() { delete[] varstr; - memory->destroy(qatom); + memory->destroy(vatom); } /* ---------------------------------------------------------------------- */ @@ -92,9 +110,9 @@ void FixAddHeat::init() var = input->variable->find(varstr); if (var < 0) error->all(FLERR, "Variable {} for fix addforce does not exist", varstr); if (input->variable->equalstyle(var)) - style = EQUAL; + vstyle = EQUAL; else if (input->variable->atomstyle(var)) - style = ATOM; + vstyle = ATOM; else error->all(FLERR, "Variable {} for fix addforce is invalid style", varstr); } @@ -106,33 +124,38 @@ void FixAddHeat::post_force(int /*vflag*/) { int *mask = atom->mask; double *heatflow = atom->heatflow; + double *temperature = atom->temperature; double dtinv = 1.0 / update->dt; - if (overwrite_flag) { + if (vstyle == ATOM) { + if (atom->nmax > maxatom) { + maxatom = atom->nmax; + memory->destroy(vatom); + memory->create(vatom, maxatom, "addheat:vatom"); + } + + input->variable->compute_atom(var, igroup, &vatom[0], 1, 0); + } + + if (overwrite_flag) for (int i = 0; i < atom->nlocal; i++) if (mask[i] & groupbit) heatflow[i] = 0.0; - } - if (style == CONSTANT) { - for (int i = 0; i < atom->nlocal; i++) - if (mask[i] & groupbit) - heatflow[i] += value * dtinv; - } else if (style == EQUAL) { - value = input->variable->compute_equal(var); - for (int i = 0; i < atom->nlocal; i++) - if (mask[i] & groupbit) - heatflow[i] += value * dtinv; - } else if (style == ATOM) { + double vtmp, dt; + if (vstyle == CONSTANT) vtmp = value; + if (vstyle == EQUAL) vtmp = input->variable->compute_equal(var); + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + if (vstyle == ATOM) vtmp = vatom[i]; - if (atom->nmax > maxatom) { - maxatom = atom->nmax; - memory->destroy(qatom); - memory->create(qatom, maxatom, "addheat:qatom"); + if (style == ADD) { + heatflow[i] += dtinv * vtmp; + } else if (style == LINEAR) { + heatflow[i] += dtinv * prefactor * (vtmp - temperature[i]); + } else if (style == QUARTIC) { + heatflow[i] += dtinv * prefactor * (pow(vtmp, 4.0) - pow(temperature[i], 4.0)); + } } - input->variable->compute_atom(var, igroup, &qatom[0], 1, 0); - for (int i = 0; i < atom->nlocal; i++) - if (mask[i] & groupbit) - heatflow[i] += qatom[i] * dtinv; } } diff --git a/src/GRANULAR/fix_add_heat.h b/src/GRANULAR/fix_add_heat.h index 8a51f13ee4..4fa8adf42e 100644 --- a/src/GRANULAR/fix_add_heat.h +++ b/src/GRANULAR/fix_add_heat.h @@ -33,10 +33,10 @@ class FixAddHeat : public Fix { void post_force(int) override; protected: - double value; - int var, style, maxatom, overwrite_flag; + double value, prefactor; + int var, vstyle, maxatom, style, overwrite_flag; char *varstr; - double *qatom; + double *vatom; }; } // namespace LAMMPS_NS diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index 46eaab3bf1..8539f04277 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "atom_vec.h" #include "citeme.h" +#include "comm.h" #include "compute_rheo_surface.h" #include "error.h" #include "fix_rheo.h" @@ -54,6 +55,8 @@ FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) : { if (narg != 6) error->all(FLERR,"Illegal fix command"); + comm_forward = 3; + cut = utils::numeric(FLERR, arg[3], false, lmp); if (cut <= 0.0) error->all(FLERR, "Illegal bond cutoff {} in fix rheo/oxidation", cut); @@ -146,7 +149,7 @@ void FixRHEOOxidation::post_integrate() { int i, j, n, ii, jj, inum, jnum, bflag; int *ilist, *jlist, *numneigh, **firstneigh; - double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + double delx, dely, delz, rsq; tagint tagi, tagj; int nlocal = atom->nlocal; @@ -164,15 +167,16 @@ void FixRHEOOxidation::post_integrate() numneigh = list->numneigh; firstneigh = list->firstneigh; + // Forward positions (after inititial integrate, before comm) + // Note: surface designation lags one timestep, acceptable error + comm->forward_comm(this); + // loop over neighbors of my atoms for (ii = 0; ii < inum; ii++) { i = ilist[ii]; if (rsurface[i] > rsurf) continue; tagi = tag[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; jlist = firstneigh[i]; jnum = numneigh[i]; @@ -184,9 +188,19 @@ void FixRHEOOxidation::post_integrate() if (rsurface[j] > rsurf) continue; tagj = tag[j]; - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; + + // Ensure pair is always ordered to ensure numerical operations + // are identical to minimize the possibility that a bond straddling + // an mpi grid (newton off) isn't created on one proc but not the other + if (tagi < tagj) { + delx = x[i][0] - x[j][0]; + dely = x[i][1] - x[j][1]; + delz = x[i][2] - x[j][2]; + } else { + delx = x[j][0] - x[i][0]; + dely = x[j][1] - x[i][1]; + delz = x[j][2] - x[i][2]; + } rsq = delx * delx + dely * dely + delz * delz; if (rsq > cutsq) continue; @@ -213,3 +227,36 @@ void FixRHEOOxidation::post_integrate() } } } + +/* ---------------------------------------------------------------------- */ + +int FixRHEOOxidation::pack_forward_comm(int n, int *list, double *buf, + int /*pbc_flag*/, int * /*pbc*/) +{ + int i, j, k, m; + double **x = atom->x; + m = 0; + + for (i = 0; i < n; i++) { + j = list[i]; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; + } + return m; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOOxidation::unpack_forward_comm(int n, int first, double *buf) +{ + int i, k, m, last; + double **x = atom->x; + m = 0; + last = first + n; + for (i = first; i < last; i++) { + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; + } +} diff --git a/src/RHEO/fix_rheo_oxidation.h b/src/RHEO/fix_rheo_oxidation.h index be95efbf2c..5991a830c0 100644 --- a/src/RHEO/fix_rheo_oxidation.h +++ b/src/RHEO/fix_rheo_oxidation.h @@ -36,6 +36,8 @@ class FixRHEOOxidation : public Fix { void setup_pre_force(int) override; void pre_force(int) override; void post_integrate() override; + int pack_forward_comm(int, int *, double *, int, int *) override; + void unpack_forward_comm(int, int, double *) override; int *nbond; double rsurf, cut; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index f2dbd6c8bb..5d4134a461 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -186,7 +186,7 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : if (iarg + 2 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/thermal react", error); cut_bond = utils::numeric(FLERR, arg[iarg + 1], false, lmp); btype = utils::numeric(FLERR, arg[iarg + 2], false, lmp); - comm_forward = 1; + comm_forward = 4; if (cut_bond <= 0.0) error->all(FLERR, "Illegal max bond length must be greater than zero");\ if (btype < 1 || btype > atom->nbondtypes) error->all(FLERR, "Illegal value for bond type"); @@ -400,7 +400,7 @@ void FixRHEOThermal::post_integrate() MPI_Allreduce(&n_freeze, &n_freeze_all, 1, MPI_INT, MPI_SUM, world); if (cut_bond > 0 && (n_melt_all || n_freeze_all)) { - // Forward status then delete/create bonds + // Forward status + positions (after inititial integrate, before comm) comm->forward_comm(this); if (n_freeze_all) create_bonds(); @@ -623,7 +623,7 @@ void FixRHEOThermal::create_bonds() { int i, j, ii, jj, inum, jnum; int *ilist, *jlist, *numneigh, **firstneigh; - double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + double delx, dely, delz, rsq; int nlocal = atom->nlocal; int newton_bond = force->newton_bond; @@ -648,10 +648,6 @@ void FixRHEOThermal::create_bonds() i = ilist[ii]; if (!(status[i] & STATUS_SOLID)) continue; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - jlist = firstneigh[i]; jnum = numneigh[i]; @@ -662,9 +658,18 @@ void FixRHEOThermal::create_bonds() if (!(status[j] & STATUS_SOLID)) continue; if (!(status[i] & STATUS_FREEZING) && !(status[j] & STATUS_FREEZING)) continue; - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; + // Ensure pair is always ordered to ensure numerical operations + // are identical to minimize the possibility that a bond straddling + // an mpi grid (newton off) isn't created on one proc but not the other + if (tag[i] < tag[j]) { + delx = x[i][0] - x[j][0]; + dely = x[i][1] - x[j][1]; + delz = x[i][2] - x[j][2]; + } else { + delx = x[j][0] - x[i][0]; + dely = x[j][1] - x[i][1]; + delz = x[j][2] - x[i][2]; + } rsq = delx * delx + dely * dely + delz * delz; if (rsq > cutsq_bond) continue; @@ -731,11 +736,15 @@ int FixRHEOThermal::pack_forward_comm(int n, int *list, double *buf, { int i, j, k, m; int *status = atom->status; + double **x = atom->x; m = 0; for (i = 0; i < n; i++) { j = list[i]; buf[m++] = ubuf(status[j]).d; + buf[m++] = x[j][0]; + buf[m++] = x[j][1]; + buf[m++] = x[j][2]; } return m; } @@ -746,10 +755,13 @@ void FixRHEOThermal::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; int *status = atom->status; - + double **x = atom->x; m = 0; last = first + n; for (i = first; i < last; i++) { status[i] = (int) ubuf(buf[m++]).i; + x[i][0] = buf[m++]; + x[i][1] = buf[m++]; + x[i][2] = buf[m++]; } } From e5d687528766a15857bd35b9393c2ca00ab237cc Mon Sep 17 00:00:00 2001 From: Thomas O'Connor Date: Thu, 9 May 2024 11:52:16 -0400 Subject: [PATCH 084/104] Update Howto_rheo.rst Typos and wording. --- doc/src/Howto_rheo.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index 748c91845b..e9e0861dc3 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -1,9 +1,9 @@ Reproducing hydrodynamics and elastic objects (RHEO) ==================================================== -The RHEO package is built around an implementation of smoothed particle -hydrodynamics (SPH) coupled to the :doc:`BPM package ` to model -solid elements of a system. The SPH solver supports many advanced options +The RHEO package is a hybrid implementation of smoothed particle +hydrodynamics (SPH) for fluid flow, coupled to the :doc:`BPM package ` to model +solid elements. RHEO combines these methods to enable mesh-free modeling of multiphase material systems. The SPH solver supports many advanced options including reproducing kernels, particle shifting, free surface identification, and solid surface reconstruction. To model fluid-solid systems, the status of particles can dynamically change between a fluid and solid state, e.g. during @@ -23,14 +23,14 @@ instance of :doc:`fix rheo/pressure ` and of state and viscosity model, respectively. Optionally, one can model a heat equation with :doc:`fix rheo/thermal`, which also allows the user to specify equations for a particle's thermal conductivity, specific heat, -latent heat, and melting temperature. Fix rheo must be defined prior to all +latent heat, and melting temperature. The ordering of these fixes in an an input script matters. Fix rheo must be defined prior to all other RHEO fixes. Typically, RHEO requires atom style rheo. In addition to typical atom properties like positions and forces, particles store a local density, viscosity, pressure, and status. If thermal evolution is modeled, one must use atom style rheo/thermal which also include a local temperature and -conductivity. The status variable uses bitmasking to track various +thermal conductivity. RHEO style atoms also have a status variable which uses bitmasking to track various properties of a particle such as its current state of matter (fluid or solid) and its location relative to a surface. Many of these properties (and others) can be easily accessed using @@ -39,14 +39,14 @@ can be easily accessed using Fluid interactions, including pressure forces, viscous forces, and heat exchange, are calculated using :doc:`pair rheo `. Unlike typical pair styles, pair rheo ignores the :doc:`special bond ` settings. Instead, -it determines whether to calculate forces based on the status of particles: +it determines whether to calculate forces based on the status of particles: e.g., hydrodynamic forces are only calculated if a fluid particle is involved. ---------- -To model elastic objects, there are current two mechanisms in RHEO, one designed +To model elastic objects, there are currently two mechanisms in RHEO, one designed for bulk solid bodies and the other for thin shells. Both mechanisms rely on -overlaying bonds and therefore require a hybrid of atom style bond and rheo +introducing bonded forces between particles and therefore require a hybrid of atom style bond and rheo (or rheo/thermal). To create an elastic solid body, one has to (a) change the status of constituent From 343f8afbf6548e3b454174a5353c9cc17a37ad12 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 14 May 2024 14:47:11 -0600 Subject: [PATCH 085/104] Many minor tweaks, adding self/mass + oxide noshift --- doc/src/fix_rheo.rst | 40 ++++++++++++++++++------- doc/src/fix_rheo_viscosity.rst | 49 ++++++++++++++++++++++++++----- src/RHEO/compute_rheo_rho_sum.cpp | 16 +++++++--- src/RHEO/compute_rheo_rho_sum.h | 1 + src/RHEO/fix_rheo.cpp | 8 ++++- src/RHEO/fix_rheo.h | 1 + src/RHEO/fix_rheo_oxidation.cpp | 6 +++- src/RHEO/fix_rheo_thermal.cpp | 2 +- src/RHEO/fix_rheo_viscosity.cpp | 3 +- 9 files changed, 100 insertions(+), 26 deletions(-) diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index 5c46ad892e..556d683c72 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -17,7 +17,7 @@ Syntax * zmin = minimal number of neighbors for reproducing kernels * zero or more keyword/value pairs may be appended to args * keyword = *thermal* or *interface/reconstruct* or *surface/detection* or - *shift* or *rho/sum* or *density* or *speed/sound* + *shift* or *rho/sum* or *density* or *self/mass* or *speed/sound* .. parsed-literal:: @@ -29,6 +29,7 @@ Syntax *limit/splash* = threshold for splash particles *shift* values = none, turns on velocity shifting *rho/sum* values = none, uses the kernel to compute the density of particles + *self/mass* values = none, a particle uses its own mass in a rho summation *density* values = *rho01*, ... *rho0N* (density) *speed/sound* values = *cs0*, ... *csN* (velocity) @@ -106,24 +107,38 @@ threshold for this classification is set by the numerical value of By default, RHEO integrates particles' densities using a mass diffusion equation. Alternatively, one can update densities every timestep by performing -a kernel summation of the masses of neighboring particles by specifying the *rho/sum* keyword. +a kernel summation of the masses of neighboring particles by specifying the *rho/sum* +keyword. -The *density* is used to specify the equilbrium density of each of the N +The *self/mass* keyword modifies the behavior of the density summation in *rho/sum*. +Typically, the density :math:`\rho` of a particle is calculated as the sum + +.. math:: + \rho_i = \Sum_{j} W_{ij} M_j + +where the summation is over neighbors, :math:`W_{ij}` is the kernel, and :math:`M_j` +is the mass of particle :math:`j`. The *self/mass* keyword augments this expression +by replacing :math:`M_j` with :math:`M_i`. This may be useful in simulations of +multiple fluid phases with large differences in density, :ref:`(Hu) `. + +The *density* keyword is used to specify the equilbrium density of each of the N particle types. It must be followed by N numerical values specifying each type's equilibrium density *rho0*. -The *density* is used to specify the speed of sound of each of the N particle -types. It must be followed by N numerical values specifying each type's speed -of sound *cs*. +The *speed/sound* keyword is used to specify the speed of sound of each of the +N particle types. It must be followed by N numerical values specifying each +type's speed of sound *cs*. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +No information about this fix is written to :doc:`binary restart files `. +None of the :doc:`fix_modify ` options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various :doc:`output commands `. 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 `. +the :doc:`run ` command. This fix is not invoked during +:doc:`energy minimization `. Restrictions """""""""""" @@ -138,7 +153,8 @@ set to all. Only one instance of fix rheo may be defined and it must be defined prior to all other RHEO fixes. This fix is part of the RHEO 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 """""""""""""""" @@ -156,6 +172,10 @@ Default ---------- -.. _howto-howto_rheo_palermo: +.. _howto_rheo_palermo: **(Palermo)** Palermo, Clemmer, Wolf, O'Connor, in preparation. + +.. _fix_rheo_hu: + +**(Hu)** Hu, and Adams J. Comp. Physics, 213, 844-861 (2006). diff --git a/doc/src/fix_rheo_viscosity.rst b/doc/src/fix_rheo_viscosity.rst index 8c403f8d0b..8175178787 100644 --- a/doc/src/fix_rheo_viscosity.rst +++ b/doc/src/fix_rheo_viscosity.rst @@ -14,20 +14,26 @@ Syntax * rheo/viscosity = style name of this fix command * one or more types and viscosity styles must be appended * types = lists of types (see below) -* vstyle = *constant* +* vstyle = *constant* or *power* .. parsed-literal:: *constant* args = *eta* *eta* = viscosity + *power* args = *eta*, *gd0*, *K*, *n* + *eta* = viscosity + *gd0* = critical strain rate + *K* = consistency index + *n* = power-law exponent + Examples """""""" .. code-block:: LAMMPS fix 1 all rheo/viscosity * constant 1.0 - fix 1 all rheo/viscosity 1 constant 1.0 2 constant 2.0 + fix 1 all rheo/viscosity 1 constant 1.0 2 power 0.1 5e-4 0.001 0.5 Description """"""""""" @@ -47,18 +53,38 @@ means all types from 1 to n (inclusive). A trailing asterisk means all types from m to :math:`N` (inclusive). A middle asterisk means all types from m to n (inclusive). -The *types* definition is followed by the viscosity style, *vstyle*. Currently, -the only option is *constant*. Style *constant* simply applies a constant value -of the viscosity *eta* to each particle of the assigned type. +The *types* definition is followed by the viscosity style, *vstyle*. Two +options are available, *constant* and *power*. Style *constant* simply +applies a constant value of the viscosity *eta* to each particle of the +assigned type. Style *power* is a Hershchel-Bulkley constitutive equation +for the stress :math:`\tau` + +.. math:: + + \tau = \left(\frac{\tau_0}{\dot{\gamma}} + K \dot{\gamma}^{n - 1}\right) \dot{\gamma}, \tau \ge \tau_0 + +where :math:`\dot{\gamma}` is the strain rate and :math:`tau_0` is the critical +yield stress, below which :math:`\dot{\gamma} = 0.0`. To avoid divergences, this +expression is regularized by defining a critical strain rate *gd0*. If the local +strain rate on a particle falls below this limit, a constant viscosity of *eta* +is assigned. This implies a value of + +.. math:: + \tau_0 = \eta * \dot{\gamma}_0 - K \dot{\gamma}_0^N + +as further discussed in :ref:`(Palermo) `. + Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +No information about this fix is written to :doc:`binary restart files `. +None of the :doc:`fix_modify ` options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various :doc:`output commands `. 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 `. +the :doc:`run ` command. This fix is not invoked during +:doc:`energy minimization `. Restrictions """""""""""" @@ -69,7 +95,8 @@ conjuction with :doc:`fix rheo `. The fix group must be set to all. Only one instance of fix rheo/viscosity can be defined. This fix is part of the RHEO 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 """""""""""""""" @@ -82,3 +109,9 @@ Default """"""" none + +---------- + +.. _howto_rheo_palermo: + +**(Palermo)** Palermo, Clemmer, Wolf, O'Connor, in preparation. diff --git a/src/RHEO/compute_rheo_rho_sum.cpp b/src/RHEO/compute_rheo_rho_sum.cpp index 8322ad4ad4..c7270897a4 100644 --- a/src/RHEO/compute_rheo_rho_sum.cpp +++ b/src/RHEO/compute_rheo_rho_sum.cpp @@ -35,7 +35,9 @@ using namespace LAMMPS_NS; ComputeRHEORhoSum::ComputeRHEORhoSum(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr) { - if (narg != 3) error->all(FLERR,"Illegal compute RHEO/rho command"); + if (narg != 4) error->all(FLERR,"Illegal compute RHEO/rho command"); + + self_mass_flag = utils::bnumeric(FLERR, arg[3], false, lmp); comm_forward = 1; comm_reverse = 1; @@ -117,9 +119,15 @@ void ComputeRHEORhoSum::compute_peratom() rsq = delx * delx + dely * dely + delz * delz; if (rsq < cutsq) { w = compute_kernel->calc_w(i, j, delx, dely, delz, sqrt(rsq)); - rho[i] += w * mass[type[i]]; - if (newton || j < nlocal) { - rho[j] += w * mass[type[j]]; + + if (self_mass_flag) { + rho[i] += w * mass[type[i]]; + if (newton || j < nlocal) + rho[j] += w * mass[type[j]]; + } else { + rho[i] += w * mass[type[j]]; + if (newton || j < nlocal) + rho[j] += w * mass[type[i]]; } } } diff --git a/src/RHEO/compute_rheo_rho_sum.h b/src/RHEO/compute_rheo_rho_sum.h index 6ec2547b95..491e61ea81 100644 --- a/src/RHEO/compute_rheo_rho_sum.h +++ b/src/RHEO/compute_rheo_rho_sum.h @@ -39,6 +39,7 @@ class ComputeRHEORhoSum : public Compute { class FixRHEO *fix_rheo; private: + int self_mass_flag; double cut, cutsq; class NeighList *list; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index 98382b07b5..a355aee5d8 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -60,6 +60,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : interface_flag = 0; surface_flag = 0; oxidation_flag = 0; + self_mass_flag = 0; int i; int n = atom->ntypes; @@ -124,6 +125,8 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : interface_flag = 1; } else if (strcmp(arg[iarg], "rho/sum") == 0) { rhosum_flag = 1; + } else if (strcmp(arg[iarg], "self/mass")) { + self_mass_flag = 1; } else if (strcmp(arg[iarg], "density") == 0) { if (iarg + n >= narg) error->all(FLERR, "Illegal rho0 option in fix rheo"); for (i = 1; i <= n; i++) @@ -142,6 +145,9 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : iarg += 1; } + if (self_mass_flag && !rhosum_flag) + error->all(FLERR, "Cannot use self/mass setting without rho/sum"); + if (lmp->citeme) lmp->citeme->add(cite_rheo); } @@ -178,7 +184,7 @@ void FixRHEO::post_constructor() if (rhosum_flag) { compute_rhosum = dynamic_cast(modify->add_compute( - "rheo_rhosum all RHEO/RHO/SUM")); + fmt::format("rheo_rhosum all RHEO/RHO/SUM {}", self_mass_flag))); compute_rhosum->fix_rheo = this; } diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 51e0962000..89a0591824 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -41,6 +41,7 @@ class FixRHEO : public Fix { // Model parameters double h, cut; double *rho0, *csq; + int self_mass_flag; int zmin_kernel, zmin_surface, zmin_splash; int kernel_style, surface_style; double divr_surface; diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index 8539f04277..9f19d4f4da 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -141,6 +141,10 @@ void FixRHEOOxidation::setup_pre_force(int /*vflag*/) void FixRHEOOxidation::pre_force(int /*vflag*/) { + int *status = atom->status; + for (int i = 0; i < atom->nlocal; i++) + if (num_bond[i] != 0) + status[i] |= STATUS_NO_SHIFT; } /* ---------------------------------------------------------------------- */ @@ -215,7 +219,7 @@ void FixRHEOOxidation::post_integrate() if (bflag) continue; // Add bonds to owned atoms - // If newton bond, add to both, otherwise add to whichever has a smaller tag + // If newton bond off, add to both, otherwise add to whichever has a smaller tag if (!newton_bond || tagi < tagj) { if (num_bond[i] == atom->bond_per_atom) diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 5d4134a461..24a6a73021 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -674,7 +674,7 @@ void FixRHEOThermal::create_bonds() if (rsq > cutsq_bond) continue; // Add bonds to owned atoms - // If newton bond, add to both, otherwise add to whichever has a smaller tag + // If newton bond off, add to both, otherwise add to whichever has a smaller tag if (i < nlocal && (!newton_bond || tag[i] < tag[j])) { if (num_bond[i] == atom->bond_per_atom) error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/thermal"); diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index abaa55ca70..2d5d58d494 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -56,6 +56,7 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : memory->create(gd0, n + 1, "rheo:gd0"); memory->create(K, n + 1, "rheo:K"); memory->create(npow, n + 1, "rheo:npow"); + memory->create(tau0, n + 1, "rheo:tau0"); for (i = 1; i <= n; i++) viscosity_style[i] = NONE; int iarg = 3; @@ -76,7 +77,7 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : viscosity_style[i] = CONSTANT; eta[i] = eta_one; } - } else if (strcmp(arg[iarg], "power") == 0) { + } else if (strcmp(arg[iarg + 1], "power") == 0) { if (iarg + 5 >= narg) utils::missing_cmd_args(FLERR, "fix rheo/viscosity power", error); comm_forward = 1; From 8d25c510c11cdbd538f8b29d391b5be8b7a7f551 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 19 May 2024 11:22:52 -0600 Subject: [PATCH 086/104] Draft examples, patches, clarify interface reconstruct in RHEO --- doc/src/Examples.rst | 2 + doc/src/Howto_rheo.rst | 28 +- doc/src/bond_rheo_shell.rst | 2 +- doc/src/compute_rheo_property_atom.rst | 32 +- doc/src/fix_rheo.rst | 3 +- doc/src/fix_rheo_oxidation.rst | 10 +- doc/src/fix_rheo_thermal.rst | 8 + doc/src/read_data.rst | 2 +- .../PACKAGES/rheo/dam-break/in.rheo.dam.break | 87 --- examples/rheo/balloon/in.rheo.balloon | 74 ++ examples/rheo/dam-break/in.rheo.dam.break | 81 +++ examples/rheo/ice-cubes/in.rheo.ice.cubes | 80 +++ examples/rheo/ice-cubes/square.mol | 658 ++++++++++++++++++ examples/rheo/oxidation/in.rheo.oxidation | 102 +++ .../rheo/poiseuille/in.rheo.poiseuille | 44 +- .../rheo/taylor-green/in.rheo.taylor.green | 26 +- src/GRANULAR/fix_add_heat.cpp | 2 +- src/RHEO/bond_rheo_shell.cpp | 1 - src/RHEO/compute_rheo_grad.cpp | 8 +- src/RHEO/compute_rheo_interface.cpp | 26 +- src/RHEO/compute_rheo_property_atom.cpp | 9 +- src/RHEO/compute_rheo_surface.cpp | 93 +-- src/RHEO/compute_rheo_surface.h | 1 - src/RHEO/compute_rheo_vshift.cpp | 29 +- src/RHEO/compute_rheo_vshift.h | 1 + src/RHEO/fix_rheo.cpp | 25 +- src/RHEO/fix_rheo.h | 2 +- src/RHEO/fix_rheo_oxidation.cpp | 49 +- src/RHEO/fix_rheo_oxidation.h | 3 +- src/RHEO/fix_rheo_thermal.cpp | 41 +- src/RHEO/fix_rheo_thermal.h | 2 +- src/RHEO/pair_rheo.cpp | 8 +- 32 files changed, 1265 insertions(+), 274 deletions(-) delete mode 100644 examples/PACKAGES/rheo/dam-break/in.rheo.dam.break create mode 100644 examples/rheo/balloon/in.rheo.balloon create mode 100644 examples/rheo/dam-break/in.rheo.dam.break create mode 100644 examples/rheo/ice-cubes/in.rheo.ice.cubes create mode 100644 examples/rheo/ice-cubes/square.mol create mode 100644 examples/rheo/oxidation/in.rheo.oxidation rename examples/{PACKAGES => }/rheo/poiseuille/in.rheo.poiseuille (55%) rename examples/{PACKAGES => }/rheo/taylor-green/in.rheo.taylor.green (68%) diff --git a/doc/src/Examples.rst b/doc/src/Examples.rst index c5da4a498b..3d2103fd6f 100644 --- a/doc/src/Examples.rst +++ b/doc/src/Examples.rst @@ -134,6 +134,8 @@ Lowercase directories +-------------+------------------------------------------------------------------+ | rerun | use of rerun and read_dump commands | +-------------+------------------------------------------------------------------+ +| rheo | RHEO simulations of fluid flows and phase transitions | ++-------------+------------------------------------------------------------------+ | rigid | rigid bodies modeled as independent or coupled | +-------------+------------------------------------------------------------------+ | shear | sideways shear applied to 2d solid, with and without a void | diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index 748c91845b..b09925d6ac 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -10,8 +10,12 @@ particles can dynamically change between a fluid and solid state, e.g. during melting/solidification, which determines how they interact and their physical behavior. The package is designed with modularity in mind, so one can easily turn various features on/off, adjust physical details of the system, or -develop new capabilities. Additional numerical details can be found in -:ref:`(Palermo) ` and :ref:`(Clemmer) `. +develop new capabilities. For instance, the numerics associated with +calculating gradients, reproducing kernels, etc. are separated into distinct +classes to simplify the development of new integration schemes which can call +these calculations. Additional numerical details can be found in +:ref:`(Palermo) ` and +:ref:`(Clemmer) `. ---------- @@ -29,12 +33,17 @@ other RHEO fixes. Typically, RHEO requires atom style rheo. In addition to typical atom properties like positions and forces, particles store a local density, viscosity, pressure, and status. If thermal evolution is modeled, one must -use atom style rheo/thermal which also include a local temperature and -conductivity. The status variable uses bitmasking to track various -properties of a particle such as its current state of matter (fluid or solid) -and its location relative to a surface. Many of these properties (and others) -can be easily accessed using -:doc:`compute rheo/property/atom `. +use atom style rheo/thermal which also includes a local energy, temperature, and +conductivity. Note that the temperature is always derived from the energy. +This implies the *temperature* attribute of :doc:`the set command ` does not +affect particles. Instead, one should use the *sph/e* attribute. + +The status variable uses bitmasking to track various properties of a particle +such as its current state of matter (fluid or solid) and its location relative +to a surface. Some of these properties (and others) can be accessed using +:doc:`compute rheo/property/atom `. The *status* attribute +in :doc:`the set command ` only allows control over the first bit which sets +the state of matter, 0 is fluid and 1 is solid. Fluid interactions, including pressure forces, viscous forces, and heat exchange, are calculated using :doc:`pair rheo `. Unlike typical pair styles, @@ -61,7 +70,8 @@ in the same elastic body. In systems with thermal evolution, fix rheo/thermal can optionally set a melting/solidification temperature allowing particles to dynamically swap their -state between fluid and solid. Using the *react* option, one can specify a maximum +state between fluid and solid when the temperature exceeds or drops below the +critical temperature, respectively. Using the *react* option, one can specify a maximum bond length and a bond type. Then, when solidifying, particles will search their local neighbors and automatically create bonds with any neighboring solid particles in range. For BPM bond styles, bonds will then use the immediate position of the two diff --git a/doc/src/bond_rheo_shell.rst b/doc/src/bond_rheo_shell.rst index 713bd84136..3b5cfa6a49 100644 --- a/doc/src/bond_rheo_shell.rst +++ b/doc/src/bond_rheo_shell.rst @@ -65,7 +65,7 @@ the setup of a run. Data is then preserved across run commands and is written to :doc:`binary restart files ` such that restarting the system will not reset the reference state of a bond or the timer. -This bond style is based on a model described in Ref. +This bond style is based on a model described in :ref:`(Clemmer) `. The force has a magnitude of .. math:: diff --git a/doc/src/compute_rheo_property_atom.rst b/doc/src/compute_rheo_property_atom.rst index 8d1cf47f58..a7e1bff383 100644 --- a/doc/src/compute_rheo_property_atom.rst +++ b/doc/src/compute_rheo_property_atom.rst @@ -16,19 +16,18 @@ Syntax .. parsed-literal:: - possible attributes = phase, chi, surface, surface/r, + possible attributes = phase, surface, surface/r, surface/divr, surface/n/x, surface/n/y, surface/n/z, coordination, cv, shift/v/x, shift/v/y, shift/v/z, energy, temperature, heatflow, conductivity, cv, viscosity, pressure, - status, rho, grad/v/xx, grad/v/xy, grad/v/xz, + rho, grad/v/xx, grad/v/xy, grad/v/xz, grad/v/yx, grad/v/yy/, grad/v/yz, grad/v/zx, grad/v/zy, grad/v/zz .. parsed-literal:: *phase* = atom phase state - *chi* = atom local phase metric *surface* = atom surface status *surface/r* = atom distance from the surface *surface/divr* = divergence of position at atom position @@ -42,7 +41,6 @@ Syntax *cv* = atom specific heat *viscosity* = atom viscosity *pressure* = atom pressure - *status* = atom full status *rho* = atom density *grad/v/\** = atom velocity gradient *nbond/shell* = number of oxide bonds @@ -70,14 +68,32 @@ computes as inputs. See for example, the :doc:`fix ave/chunk `, and :doc:`atom-style variable ` commands. -The possible attributes are described in more detail in other RHEO doc -pages including :doc:`the RHEO howto page `. Many -properties require their respective fixes, listed below in related -commands, be defined. +Many properties require their respective fixes, listed below in related +commands, be defined. For instance, the *viscosity* attribute is the +viscosity of a particle calculated by +:doc:`fix rheo/viscous `. The meaning of less obvious +properties is described below. + +The *phase* property indicates whether the particle is in a fluid state, +a value of 0, or a solid state, a value of 1. + +The *surface* property indicates the surface designation produced by +the *interface/reconstruct* option of :doc:`fix rheo `. Bulk +particles have a value of 0, surface particles have a value of 1, and +splash particles have a value of 2. The *surface/r* property is the +distance from the surface, up to the kernel cutoff length. Surface particles +have a value of 0. The *surface/n* properties are the components of the +surface normal vector. + +The *shift/v* properties are the components of the shifting velocity +produced by the *shift* option of :doc:`fix rheo `. The *surface/n/\** and *shift/v/\** attributes are vectors that require specification of the *x*, *y*, or *z* component, e.g. *surface/n/x*. +The *nbond/shell* property is the number of shell bonds that have been +activated from :doc:`bond style rheo/shell `. + The *grad/v/\** attribute is a tensor and requires specification of the *xx*, *yy*, *zz*, *xy*, *xz*, *yx*, *yz*, *zx*, or *zy* component, e.g. *grad/v/xy*. diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index 556d683c72..978691db41 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -92,7 +92,8 @@ Shifting is then disabled in the direction away from the free surface to prevent it from diffusing particles away from the bulk fluid. Surface detection can also be used to control surface-nucleated effects like oxidation when used in combination with -:doc:`fix rheo/oxidation `. +:doc:`fix rheo/oxidation `. Surface detection is not +performed on solid bodies. The *surface/detection* keyword takes three arguments: *sdstyle*, *limit*, and *limi/splash*. The first, *sdstyle*, specifies whether surface particles diff --git a/doc/src/fix_rheo_oxidation.rst b/doc/src/fix_rheo_oxidation.rst index 42e2b6d59e..3043291c60 100644 --- a/doc/src/fix_rheo_oxidation.rst +++ b/doc/src/fix_rheo_oxidation.rst @@ -35,10 +35,12 @@ for use with bond style :doc:`bond rheo/shell `. Every timestep, particles check neighbors within a distance of *cut*. This distance must be smaller than the kernel length defined in -:doc:`fix rheo `. If both particles are on the fluid surface, -or within a distance of *rsurf* from the surface, a bond of type -*btype* is created between the two particles. This process is -further described in Ref. :ref:`(Clemmer) `. +:doc:`fix rheo `. Bonds of type *btype* are created between +pairs of particles that satisfy one of two conditions. First, if both +particles are on the fluid surface, or within a distance of *rsurf* +from the surface. Secondly, if one particle is on the fluid surface +and the other bond is solid. This process is further described in +:ref:`(Clemmer) `. If used in conjunction with solid bodies, such as those generated by the *react* option of :doc:`fix rheo/thermal `, diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst index 2ffb665bb7..1ceb1259c0 100644 --- a/doc/src/fix_rheo_thermal.rst +++ b/doc/src/fix_rheo_thermal.rst @@ -55,12 +55,20 @@ rheo/thermal. In addition, it defines multiple thermal properties of particles and handles melting/solidification, if applicable. For more details on phase transitions in RHEO, see :doc:`the RHEO howto `. +Note that the temperature of a particle is always derived from the energy. +This implies the *temperature* attribute of :doc:`the set command ` does +not affect particles. Instead, one should use the *sph/e* attribute. + For each atom type, one can define attributes for the *conductivity*, *specific/heat*, *latent/heat*, and critical temperature (*Tfreeze*). The conductivity and specific heat must be defined for all atom types. The latent heat and critical temperature are optional. However, a critical temperature must be defined to specify a latent heat. +Note, if shifting is turned on in :doc:`fix rheo `, the gradient +of the energy is used to shift energies. This may be inappropriate in systems +with multiple atom types with different specific heats. + For each property, one must first define a list of atom types. A wild-card asterisk can be used in place of or in conjunction with the *types* argument to set the coefficients for multiple pairs of atom types. This takes the diff --git a/doc/src/read_data.rst b/doc/src/read_data.rst index 4950d8bc25..5ebb34dcab 100644 --- a/doc/src/read_data.rst +++ b/doc/src/read_data.rst @@ -717,7 +717,7 @@ of analysis. * - rheo - atom-ID atom-type status rho x y z * - rheo/thermal - - atom-ID atom-type status rho temperature x y z + - atom-ID atom-type status rho energy x y z * - smd - atom-ID atom-type molecule volume mass kradius cradius x0 y0 z0 x y z * - sph diff --git a/examples/PACKAGES/rheo/dam-break/in.rheo.dam.break b/examples/PACKAGES/rheo/dam-break/in.rheo.dam.break deleted file mode 100644 index 207fd6885e..0000000000 --- a/examples/PACKAGES/rheo/dam-break/in.rheo.dam.break +++ /dev/null @@ -1,87 +0,0 @@ -# ------ 2D dam break ------ # - -dimension 2 -units lj -atom_style rheo -boundary f s p -comm_modify vel yes -newton off -comm_style tiled - - -# ------ Create simulation box ------ # - -variable sf equal 0.05 -variable n equal 1.0/(${sf}^2) -variable cut equal 3.0*${sf} - -region box block -1 55 -1 20 -0.01 0.01 units box -create_box 2 box -lattice sq ${n} - -region left_wall block -1 0 EDGE EDGE -0.01 0.01 units box -region right_wall block 53.66 EDGE EDGE EDGE -0.01 0.01 units box -region bot_wall block 0.01 53.65 -1 0 -0.01 0.01 units box -region interior block 0.01 10 0.01 20 -0.01 0.01 units box - -create_atoms 1 region interior -create_atoms 2 region left_wall -create_atoms 2 region right_wall -create_atoms 2 region bot_wall - -group fluid type 1 -group static_wall type 2 -group dyn_wall type 3 -group rig union static_wall dyn_wall - - -# ------ Model parameters ------ # - -variable rho0 equal 1.0 -variable mp equal ${rho0}/${n} -variable cs equal 10 -variable zeta equal 1 -variable Dr equal 0.1*${cut}*${cs} -variable dt_max equal 0.1*${cut}/${cs}/3 -variable g equal 0.0245 -variable fext equal ${g}/${n} -variable eta equal 0.05 - -mass * ${mp} -variable d0 atom (${rho0}*${g}*(20-y)/${cs}/${cs})+${rho0} -set group all rheo/rho ${rho0} -set group fluid rheo/rho v_d0 - -set group all rheo/status 0 -set group rig rheo/status 2 - -timestep ${dt_max} - -pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} -pair_coeff * * - - -# ------ Fixes & computes ------ # - -fix 1 all rheo ${cut} RK1 32 shift surface/detection coordination 26 -fix 2 all rheo/viscosity constant ${eta} -fix 3 all rheo/pressure linear -fix 4 rig setforce 0.0 0.0 0.0 -fix 5 fluid addforce 0.0 -${fext} 0.0 -fix 6 all balance 1000 1.1 rcb - -compute 1 all rheo/property/atom rho phase surface - - -# ------ Output & Run ------ # - -thermo 10 -thermo_style custom step time ke press - -variable skin equal 0.2*${cut} -neighbor ${skin} bin -neigh_modify one 5000 - -dump 1 all custom 200 atomDump id type x y vx vy fx fy c_1[*] - -run 400000 diff --git a/examples/rheo/balloon/in.rheo.balloon b/examples/rheo/balloon/in.rheo.balloon new file mode 100644 index 0000000000..d24573b0fb --- /dev/null +++ b/examples/rheo/balloon/in.rheo.balloon @@ -0,0 +1,74 @@ +# ------ 2D water balloon ------ # + +dimension 2 +units lj +atom_style hybrid rheo bond +boundary m m p +comm_modify vel yes +newton off + +region box block -40 40 0 80 -0.01 0.01 units box +create_box 1 box bond/types 1 extra/bond/per/atom 15 extra/special/per/atom 50 + +region fluid sphere -10 40 0 30 units box side in +lattice hex 1.0 +create_atoms 1 region fluid + +region shell sphere -10 40 0 27 units box side out +group shell region shell + +set group shell rheo/status 1 +set group all vx 0.005 vy -0.04 + +# ------ Model parameters ------# + +variable cut equal 3.0 +variable n equal 1.0 +variable rho0 equal 1.0 +variable cs equal 1.0 +variable mp equal ${rho0}/${n} +variable zeta equal 0.05 +variable kappa equal 0.01*${rho0}/${mp} +variable dt_max equal 0.1*${cut}/${cs}/3 +variable eta equal 0.05 +variable Cv equal 1.0 +variable L equal 1.0 +variable Tf equal 1.0 + +mass * ${mp} +timestep 0.1 + +pair_style hybrid/overlay rheo ${cut} artificial/visc ${zeta} rheo/solid +pair_coeff * * rheo +pair_coeff * * rheo/solid 1.0 1.0 1.0 + +special_bonds lj 0.0 1.0 1.0 coul 0.0 1.0 1.0 +create_bonds many shell shell 1 0 1.5 +special_bonds lj 0.0 1.0 1.0 coul 1.0 1.0 1.0 + +bond_style bpm/spring +bond_coeff 1 1.0 1.0 1.0 + +# A lower critical strain allows the balloon to pop +#bond_coeff 1 1.0 0.05 1.0 + +# ------ Drop balloon ------# + +fix 1 all rheo ${cut} quintic 0 & + shift & + surface/detection coordination 22 8 +fix 2 all rheo/viscosity * constant ${eta} +fix 3 all rheo/pressure * linear +fix 4 all wall/harmonic ylo EDGE 2.0 1.0 1.0 + +compute rho all rheo/property/atom rho +compute phase all rheo/property/atom phase +compute nbond all nbond/atom + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press atoms + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_nbond c_rho +run 30000 diff --git a/examples/rheo/dam-break/in.rheo.dam.break b/examples/rheo/dam-break/in.rheo.dam.break new file mode 100644 index 0000000000..b59b710451 --- /dev/null +++ b/examples/rheo/dam-break/in.rheo.dam.break @@ -0,0 +1,81 @@ +# ------ 2D dam break ------ # + +dimension 2 +units lj +atom_style rheo +boundary f f p +comm_modify vel yes +newton off + +# ------ Create simulation box ------ # + +variable n equal 1.0 +variable cut equal 3.0 +variable dx equal 4.0 + +region box block -1 200 -1 80 -0.1 0.1 units box +#region box block -1 100 -1 40 -0.1 0.1 units box +create_box 2 box +lattice hex ${n} + +region fluid block $(xlo+v_dx) $(xlo+44.0) $(ylo+v_dx) $(yhi-16.0) EDGE EDGE units box +#region fluid block $(xlo+v_dx) $(xlo+20.0) $(ylo+v_dx) $(yhi-10.0) EDGE EDGE units box +region walls block $(xlo+v_dx) $(xhi-v_dx) $(ylo+v_dx) $(yhi-v_dx) EDGE EDGE units box side out + +create_atoms 1 region fluid +create_atoms 2 region walls + +group fluid type 1 +group rig type 2 + +# ------ Model parameters ------ # + +variable rho0 equal 1.0 +variable mp equal ${rho0}/${n} +variable cs equal 1.0 +variable zeta equal 0.05 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable eta equal 0.05 +variable Dr equal 0.05 + +mass * ${mp} +set group all rheo/rho ${rho0} + +set group all rheo/status 0 +set group rig rheo/status 1 + +timestep ${dt_max} + +pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} +pair_coeff * * + + +# ------ Fixes & computes ------ # + +fix 1 all rheo ${cut} quintic 10 & + shift & + surface/detection coordination 22 8 & + interface/reconstruct +#fix 1 all rheo ${cut} RK1 10 surface/detection coordination 36 10 interface/reconstruct shift +fix 2 all rheo/viscosity * constant ${eta} +fix 3 all rheo/pressure * linear +fix 4 all gravity 5e-4 vector 0 -1 0 +fix 5 rig setforce 0.0 0.0 0.0 + +compute rho all rheo/property/atom rho +compute phase all rheo/property/atom phase +compute p all rheo/property/atom pressure +compute surf all rheo/property/atom surface +compute sn all rheo/property/atom surface/n/x surface/n/y +compute vshift all rheo/property/atom shift/v/x shift/v/y + + +# ------ Output & Run ------ # + +thermo 100 +thermo_style custom step time ke press + +dump 1 all custom 20 atomDump id type x y vx vy fx fy c_rho c_phase c_surf c_p c_vshift[*] c_sn[*] + +#thermo 1 +run 300000 # 400000 diff --git a/examples/rheo/ice-cubes/in.rheo.ice.cubes b/examples/rheo/ice-cubes/in.rheo.ice.cubes new file mode 100644 index 0000000000..12eb54c32e --- /dev/null +++ b/examples/rheo/ice-cubes/in.rheo.ice.cubes @@ -0,0 +1,80 @@ +# ------ 2D Ice Cube Pour ------ # + +dimension 2 +units lj +atom_style hybrid rheo/thermal bond +boundary m m p +comm_modify vel yes +newton off +special_bonds lj 0.0 1.0 1.0 coul 1.0 1.0 1.0 + +region box block -25 25 0 100 -0.01 0.01 units box +create_box 1 box bond/types 1 extra/bond/per/atom 15 extra/special/per/atom 50 + +region fluid block $(xlo+1) $(xhi-1) $(ylo+1) $(ylo+30) EDGE EDGE units box +lattice sq 1.0 +create_atoms 1 region fluid + +set group all sph/e 8.0 + +# ------ Model parameters ------# + +variable cut equal 3.0 +variable n equal 1.0 +variable rho0 equal 1.0 +variable cs equal 1.0 +variable mp equal ${rho0}/${n} +variable zeta equal 0.05 +variable kappa equal 0.01*${rho0}/${mp} +variable dt_max equal 0.1*${cut}/${cs}/3 +variable eta equal 0.05 +variable Cv equal 1.0 +variable L equal 1.0 +variable Tf equal 1.0 + +mass * ${mp} +timestep 0.1 + +pair_style hybrid/overlay rheo ${cut} artificial/visc ${zeta} rheo/solid +pair_coeff * * rheo +pair_coeff * * rheo/solid 1.0 1.0 1.0 + +bond_style bpm/spring +bond_coeff 1 1.0 1.0 1.0 + +# ------ Pour particles ------# + +molecule my_mol "square.mol" + +# Wall region extends far enough in z to avoid contact +region wall block EDGE EDGE EDGE EDGE -5 5 side in open 4 units box +region drop block -16 16 70 90 EDGE EDGE side in units box + +fix 1 all rheo ${cut} quintic 0 & + thermal & + shift & + surface/detection coordination 22 8 +fix 2 all rheo/viscosity * constant ${eta} +fix 3 all rheo/pressure * linear +fix 4 all rheo/thermal conductivity * constant ${kappa} & + specific/heat * constant ${Cv} & + Tfreeze * constant ${Tf} & + latent/heat * constant ${L} & + react 1.5 1 +fix 5 all wall/region wall harmonic 1.0 1.0 1.0 +fix 6 all gravity 5e-4 vector 0 -1 0 +fix 7 all deposit 8 0 1000 37241459 mol my_mol region drop near 2.0 vy -0.02 -0.02 + +compute rho all rheo/property/atom rho +compute phase all rheo/property/atom phase +compute temp all rheo/property/atom temperature +compute eng all rheo/property/atom energy +compute nbond all nbond/atom + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press atoms + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond c_rho +run 30000 diff --git a/examples/rheo/ice-cubes/square.mol b/examples/rheo/ice-cubes/square.mol new file mode 100644 index 0000000000..0344be7244 --- /dev/null +++ b/examples/rheo/ice-cubes/square.mol @@ -0,0 +1,658 @@ +#Made with create_mol.py + +100 atoms +342 bonds + +Coords +#ID x y z +1 -4 -4 0 +2 -3 -4 0 +3 -2 -4 0 +4 -1 -4 0 +5 0 -4 0 +6 1 -4 0 +7 2 -4 0 +8 3 -4 0 +9 4 -4 0 +10 5 -4 0 +11 -4 -3 0 +12 -3 -3 0 +13 -2 -3 0 +14 -1 -3 0 +15 0 -3 0 +16 1 -3 0 +17 2 -3 0 +18 3 -3 0 +19 4 -3 0 +20 5 -3 0 +21 -4 -2 0 +22 -3 -2 0 +23 -2 -2 0 +24 -1 -2 0 +25 0 -2 0 +26 1 -2 0 +27 2 -2 0 +28 3 -2 0 +29 4 -2 0 +30 5 -2 0 +31 -4 -1 0 +32 -3 -1 0 +33 -2 -1 0 +34 -1 -1 0 +35 0 -1 0 +36 1 -1 0 +37 2 -1 0 +38 3 -1 0 +39 4 -1 0 +40 5 -1 0 +41 -4 0 0 +42 -3 0 0 +43 -2 0 0 +44 -1 0 0 +45 0 0 0 +46 1 0 0 +47 2 0 0 +48 3 0 0 +49 4 0 0 +50 5 0 0 +51 -4 1 0 +52 -3 1 0 +53 -2 1 0 +54 -1 1 0 +55 0 1 0 +56 1 1 0 +57 2 1 0 +58 3 1 0 +59 4 1 0 +60 5 1 0 +61 -4 2 0 +62 -3 2 0 +63 -2 2 0 +64 -1 2 0 +65 0 2 0 +66 1 2 0 +67 2 2 0 +68 3 2 0 +69 4 2 0 +70 5 2 0 +71 -4 3 0 +72 -3 3 0 +73 -2 3 0 +74 -1 3 0 +75 0 3 0 +76 1 3 0 +77 2 3 0 +78 3 3 0 +79 4 3 0 +80 5 3 0 +81 -4 4 0 +82 -3 4 0 +83 -2 4 0 +84 -1 4 0 +85 0 4 0 +86 1 4 0 +87 2 4 0 +88 3 4 0 +89 4 4 0 +90 5 4 0 +91 -4 5 0 +92 -3 5 0 +93 -2 5 0 +94 -1 5 0 +95 0 5 0 +96 1 5 0 +97 2 5 0 +98 3 5 0 +99 4 5 0 +100 5 5 0 + +Types +#ID type +1 1 +2 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +16 1 +17 1 +18 1 +19 1 +20 1 +21 1 +22 1 +23 1 +24 1 +25 1 +26 1 +27 1 +28 1 +29 1 +30 1 +31 1 +32 1 +33 1 +34 1 +35 1 +36 1 +37 1 +38 1 +39 1 +40 1 +41 1 +42 1 +43 1 +44 1 +45 1 +46 1 +47 1 +48 1 +49 1 +50 1 +51 1 +52 1 +53 1 +54 1 +55 1 +56 1 +57 1 +58 1 +59 1 +60 1 +61 1 +62 1 +63 1 +64 1 +65 1 +66 1 +67 1 +68 1 +69 1 +70 1 +71 1 +72 1 +73 1 +74 1 +75 1 +76 1 +77 1 +78 1 +79 1 +80 1 +81 1 +82 1 +83 1 +84 1 +85 1 +86 1 +87 1 +88 1 +89 1 +90 1 +91 1 +92 1 +93 1 +94 1 +95 1 +96 1 +97 1 +98 1 +99 1 +100 1 + +Masses +#ID mass +1 1 +2 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +10 1 +11 1 +12 1 +13 1 +14 1 +15 1 +16 1 +17 1 +18 1 +19 1 +20 1 +21 1 +22 1 +23 1 +24 1 +25 1 +26 1 +27 1 +28 1 +29 1 +30 1 +31 1 +32 1 +33 1 +34 1 +35 1 +36 1 +37 1 +38 1 +39 1 +40 1 +41 1 +42 1 +43 1 +44 1 +45 1 +46 1 +47 1 +48 1 +49 1 +50 1 +51 1 +52 1 +53 1 +54 1 +55 1 +56 1 +57 1 +58 1 +59 1 +60 1 +61 1 +62 1 +63 1 +64 1 +65 1 +66 1 +67 1 +68 1 +69 1 +70 1 +71 1 +72 1 +73 1 +74 1 +75 1 +76 1 +77 1 +78 1 +79 1 +80 1 +81 1 +82 1 +83 1 +84 1 +85 1 +86 1 +87 1 +88 1 +89 1 +90 1 +91 1 +92 1 +93 1 +94 1 +95 1 +96 1 +97 1 +98 1 +99 1 +100 1 + +Bonds +#ID type atom1 atom2 +1 1 1 2 +2 1 1 11 +3 1 1 12 +4 1 2 3 +5 1 2 11 +6 1 2 12 +7 1 2 13 +8 1 3 4 +9 1 3 12 +10 1 3 13 +11 1 3 14 +12 1 4 5 +13 1 4 13 +14 1 4 14 +15 1 4 15 +16 1 5 6 +17 1 5 14 +18 1 5 15 +19 1 5 16 +20 1 6 7 +21 1 6 15 +22 1 6 16 +23 1 6 17 +24 1 7 8 +25 1 7 16 +26 1 7 17 +27 1 7 18 +28 1 8 9 +29 1 8 17 +30 1 8 18 +31 1 8 19 +32 1 9 10 +33 1 9 18 +34 1 9 19 +35 1 9 20 +36 1 10 19 +37 1 10 20 +38 1 11 21 +39 1 11 12 +40 1 11 22 +41 1 12 21 +42 1 12 13 +43 1 12 22 +44 1 12 23 +45 1 13 22 +46 1 13 23 +47 1 13 14 +48 1 13 24 +49 1 14 23 +50 1 14 24 +51 1 14 15 +52 1 14 25 +53 1 15 24 +54 1 15 16 +55 1 15 25 +56 1 15 26 +57 1 16 25 +58 1 16 26 +59 1 16 17 +60 1 16 27 +61 1 17 26 +62 1 17 18 +63 1 17 27 +64 1 17 28 +65 1 18 27 +66 1 18 28 +67 1 18 19 +68 1 18 29 +69 1 19 28 +70 1 19 29 +71 1 19 20 +72 1 19 30 +73 1 20 29 +74 1 20 30 +75 1 21 22 +76 1 21 31 +77 1 21 32 +78 1 22 23 +79 1 22 31 +80 1 22 32 +81 1 22 33 +82 1 23 24 +83 1 23 32 +84 1 23 33 +85 1 23 34 +86 1 24 25 +87 1 24 33 +88 1 24 34 +89 1 24 35 +90 1 25 26 +91 1 25 34 +92 1 25 35 +93 1 25 36 +94 1 26 27 +95 1 26 35 +96 1 26 36 +97 1 26 37 +98 1 27 28 +99 1 27 36 +100 1 27 37 +101 1 27 38 +102 1 28 29 +103 1 28 37 +104 1 28 38 +105 1 28 39 +106 1 29 30 +107 1 29 38 +108 1 29 39 +109 1 29 40 +110 1 30 39 +111 1 30 40 +112 1 31 32 +113 1 31 41 +114 1 31 42 +115 1 32 33 +116 1 32 41 +117 1 32 42 +118 1 32 43 +119 1 33 34 +120 1 33 42 +121 1 33 43 +122 1 33 44 +123 1 34 35 +124 1 34 43 +125 1 34 44 +126 1 34 45 +127 1 35 36 +128 1 35 44 +129 1 35 45 +130 1 35 46 +131 1 36 37 +132 1 36 45 +133 1 36 46 +134 1 36 47 +135 1 37 38 +136 1 37 46 +137 1 37 47 +138 1 37 48 +139 1 38 39 +140 1 38 47 +141 1 38 48 +142 1 38 49 +143 1 39 40 +144 1 39 48 +145 1 39 49 +146 1 39 50 +147 1 40 49 +148 1 40 50 +149 1 41 51 +150 1 41 42 +151 1 41 52 +152 1 42 51 +153 1 42 43 +154 1 42 52 +155 1 42 53 +156 1 43 52 +157 1 43 53 +158 1 43 44 +159 1 43 54 +160 1 44 53 +161 1 44 54 +162 1 44 45 +163 1 44 55 +164 1 45 54 +165 1 45 46 +166 1 45 55 +167 1 45 56 +168 1 46 55 +169 1 46 56 +170 1 46 47 +171 1 46 57 +172 1 47 56 +173 1 47 48 +174 1 47 57 +175 1 47 58 +176 1 48 57 +177 1 48 58 +178 1 48 49 +179 1 48 59 +180 1 49 58 +181 1 49 59 +182 1 49 50 +183 1 49 60 +184 1 50 59 +185 1 50 60 +186 1 51 52 +187 1 51 61 +188 1 51 62 +189 1 52 53 +190 1 52 61 +191 1 52 62 +192 1 52 63 +193 1 53 54 +194 1 53 62 +195 1 53 63 +196 1 53 64 +197 1 54 55 +198 1 54 63 +199 1 54 64 +200 1 54 65 +201 1 55 56 +202 1 55 64 +203 1 55 65 +204 1 55 66 +205 1 56 57 +206 1 56 65 +207 1 56 66 +208 1 56 67 +209 1 57 58 +210 1 57 66 +211 1 57 67 +212 1 57 68 +213 1 58 59 +214 1 58 67 +215 1 58 68 +216 1 58 69 +217 1 59 60 +218 1 59 68 +219 1 59 69 +220 1 59 70 +221 1 60 69 +222 1 60 70 +223 1 61 71 +224 1 61 62 +225 1 61 72 +226 1 62 71 +227 1 62 63 +228 1 62 72 +229 1 62 73 +230 1 63 72 +231 1 63 73 +232 1 63 64 +233 1 63 74 +234 1 64 73 +235 1 64 74 +236 1 64 65 +237 1 64 75 +238 1 65 74 +239 1 65 66 +240 1 65 75 +241 1 65 76 +242 1 66 75 +243 1 66 76 +244 1 66 67 +245 1 66 77 +246 1 67 76 +247 1 67 68 +248 1 67 77 +249 1 67 78 +250 1 68 77 +251 1 68 78 +252 1 68 69 +253 1 68 79 +254 1 69 78 +255 1 69 79 +256 1 69 70 +257 1 69 80 +258 1 70 79 +259 1 70 80 +260 1 71 72 +261 1 71 81 +262 1 71 82 +263 1 72 73 +264 1 72 81 +265 1 72 82 +266 1 72 83 +267 1 73 74 +268 1 73 82 +269 1 73 83 +270 1 73 84 +271 1 74 75 +272 1 74 83 +273 1 74 84 +274 1 74 85 +275 1 75 76 +276 1 75 84 +277 1 75 85 +278 1 75 86 +279 1 76 77 +280 1 76 85 +281 1 76 86 +282 1 76 87 +283 1 77 78 +284 1 77 86 +285 1 77 87 +286 1 77 88 +287 1 78 79 +288 1 78 87 +289 1 78 88 +290 1 78 89 +291 1 79 80 +292 1 79 88 +293 1 79 89 +294 1 79 90 +295 1 80 89 +296 1 80 90 +297 1 81 82 +298 1 81 91 +299 1 81 92 +300 1 82 83 +301 1 82 91 +302 1 82 92 +303 1 82 93 +304 1 83 84 +305 1 83 92 +306 1 83 93 +307 1 83 94 +308 1 84 85 +309 1 84 93 +310 1 84 94 +311 1 84 95 +312 1 85 86 +313 1 85 94 +314 1 85 95 +315 1 85 96 +316 1 86 87 +317 1 86 95 +318 1 86 96 +319 1 86 97 +320 1 87 88 +321 1 87 96 +322 1 87 97 +323 1 87 98 +324 1 88 89 +325 1 88 97 +326 1 88 98 +327 1 88 99 +328 1 89 90 +329 1 89 98 +330 1 89 99 +331 1 89 100 +332 1 90 99 +333 1 90 100 +334 1 91 92 +335 1 92 93 +336 1 93 94 +337 1 94 95 +338 1 95 96 +339 1 96 97 +340 1 97 98 +341 1 98 99 +342 1 99 100 diff --git a/examples/rheo/oxidation/in.rheo.oxidation b/examples/rheo/oxidation/in.rheo.oxidation new file mode 100644 index 0000000000..5c1456ad5a --- /dev/null +++ b/examples/rheo/oxidation/in.rheo.oxidation @@ -0,0 +1,102 @@ +# ------ 2D oxidizing bar ------ # + +dimension 2 +units lj +atom_style hybrid rheo/thermal bond +boundary m m p +comm_modify vel yes +newton off + +region box block -60 60 0 80 -0.01 0.01 units box +create_box 3 box bond/types 2 extra/bond/per/atom 20 extra/special/per/atom 50 + + +region lbar block -15 0 3 80 EDGE EDGE units box +region rbar block 0 15 3 80 EDGE EDGE units box +region bar union 2 lbar rbar +region floor block EDGE EDGE EDGE 3.0 EDGE EDGE units box + +lattice hex 1.0 +create_atoms 1 region bar +create_atoms 3 region floor + +set region rbar type 2 +group bar type 1 2 +group rbar type 2 +group floor type 3 + +set group all sph/e 0.0 +set group all rheo/status 1 + +# ------ Model parameters ------# + +variable cut equal 3.0 +variable n equal 1.0 +variable rho0 equal 1.0 +variable cs equal 1.0 +variable mp equal ${rho0}/${n} +variable zeta equal 0.05 +variable kappa equal 0.1*${rho0}/${mp} +variable dt_max equal 0.1*${cut}/${cs}/3 +variable eta equal 0.05 +variable Cv equal 1.0 +variable L equal 0.1 +variable Tf equal 1.0 + +mass * ${mp} +timestep 0.1 + +pair_style hybrid/overlay rheo ${cut} artificial/visc ${zeta} rheo/solid +pair_coeff * * rheo +pair_coeff * * rheo/solid 1.0 1.0 1.0 + +special_bonds lj 0.0 1.0 1.0 coul 0.0 1.0 1.0 +create_bonds many bar bar 1 0 1.5 +special_bonds lj 0.0 1.0 1.0 coul 1.0 1.0 1.0 + +bond_style hybrid bpm/spring rheo/shell t/form 100 +bond_coeff 1 bpm/spring 1.0 1.0 1.0 +bond_coeff 2 rheo/shell 0.2 0.2 0.1 + +# ------ Apply dynamics ------# + +# Note: surface detection is not performed on solid bodies, so cannot use surface property +compute coord all rheo/property/atom coordination +variable surf atom c_coord<22 +group surf dynamic all var surf every 10 + +fix 1 all rheo ${cut} quintic 0 & + thermal & + shift & + surface/detection coordination 22 8 +fix 2 all rheo/viscosity * constant ${eta} +fix 3 all rheo/pressure * linear +fix 4 all rheo/thermal conductivity * constant ${kappa} & + specific/heat * constant ${Cv} & + Tfreeze * constant ${Tf} & + latent/heat * constant ${L} & + react 1.5 1 + +fix 5 rbar rheo/oxidation 1.5 2 1.0 +fix 6 all wall/harmonic ylo EDGE 2.0 1.0 1.0 +fix 7 all gravity 5e-5 vector 0 -1 0 +fix 8 floor setforce 0.0 0.0 0.0 +fix 9 surf add/heat linear 1.1 0.05 +fix 10 floor add/heat constant 0 overwrite yes # fix the temperature of the floor + +compute surf all rheo/property/atom surface +compute rho all rheo/property/atom rho +compute phase all rheo/property/atom phase +compute status all rheo/property/atom status +compute temp all rheo/property/atom temperature +compute eng all rheo/property/atom energy +compute nbond_shell all rheo/property/atom nbond/shell +compute nbond_solid all nbond/atom bond/type 1 + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press atoms + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond_solid c_nbond_shell c_rho c_surf c_status +run 40000 diff --git a/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille b/examples/rheo/poiseuille/in.rheo.poiseuille similarity index 55% rename from examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille rename to examples/rheo/poiseuille/in.rheo.poiseuille index 6f5ad91e73..ee8ad5523c 100644 --- a/examples/PACKAGES/rheo/poiseuille/in.rheo.poiseuille +++ b/examples/rheo/poiseuille/in.rheo.poiseuille @@ -9,28 +9,23 @@ comm_modify vel yes # ------ Create simulation box ------ # -variable sf equal 0.2 -variable n equal 1.0/(${sf}^2) -variable cut equal 3.5*${sf} +variable n equal 1.0 +variable cut equal 3.0 -region box block 0 20 -10 10 -0.01 0.01 units box +region box block 0 20 -10 10 -0.01 0.01 create_box 2 box lattice sq ${n} -region topwall block INF INF 7 10 INF INF units box -region block block INF INF -6.99 6.99 INF INF units box -region botwall block INF INF -10 -7 INF INF units box +region inner block INF INF -7.5 7.5 INF INF units box +region walls block INF INF -7.5 7.5 INF INF units box side out -create_atoms 2 region topwall -create_atoms 2 region botwall -create_atoms 1 region block +create_atoms 2 region walls +create_atoms 1 region inner group fluid type 1 group rig type 2 -variable dr equal 0.1*${sf} -displace_atoms fluid random $(0.1*v_sf) ${dr} 0 135414 units box - +displace_atoms fluid random 0.1 0.1 0 135414 units box # ------ Model parameters ------ # @@ -39,15 +34,19 @@ variable cs equal 1.0 variable mp equal ${rho0}/${n} variable zeta equal 1.0 variable kappa equal 1.0*${rho0}/${mp} -variable fext equal 1e-3/${n} -variable eta equal 0.1 +variable fext equal 1e-4/${n} variable dt_max equal 0.1*${cut}/${cs}/3 variable Dr equal 0.05*${cut}*${cs} +variable eta equal 0.1 +variable gd0 equal 5e-4 +variable npow equal 0.5 +variable K equal 0.001 + mass * ${mp} set group all rheo/rho ${rho0} set group all rheo/status 0 -set group rig rheo/status 2 +set group rig rheo/status 1 timestep ${dt_max} @@ -58,12 +57,13 @@ pair_coeff * * # ------ Fixes & computes ------ # fix 1 all rheo ${cut} quintic 0 shift -fix 2 all rheo/viscosity constant ${eta} -fix 3 all rheo/pressure linear +fix 2 all rheo/viscosity * constant ${eta} +#fix 2 all rheo/viscosity * power ${eta} ${gd0} ${K} ${npow} +fix 3 all rheo/pressure * linear fix 4 rig setforce 0.0 0.0 0.0 fix 5 fluid addforce ${fext} 0.0 0.0 -compute 1 all rheo/property/atom rho phase +compute rho all rheo/property/atom rho # ------ Output & Run ------ # @@ -71,11 +71,7 @@ compute 1 all rheo/property/atom rho phase thermo 200 thermo_style custom step time ke press -variable skin equal 0.2*${cut} -neighbor ${skin} bin -neigh_modify one 5000 - -#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_1[*] +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_rho run 20000 diff --git a/examples/PACKAGES/rheo/taylor-green/in.rheo.taylor.green b/examples/rheo/taylor-green/in.rheo.taylor.green similarity index 68% rename from examples/PACKAGES/rheo/taylor-green/in.rheo.taylor.green rename to examples/rheo/taylor-green/in.rheo.taylor.green index 5367ceef13..e386d8262c 100644 --- a/examples/PACKAGES/rheo/taylor-green/in.rheo.taylor.green +++ b/examples/rheo/taylor-green/in.rheo.taylor.green @@ -10,19 +10,16 @@ newton off # ------ Create simulation box ------ # -variable sf equal 0.1 -variable n equal 1.0/(${sf}^2) -variable cut equal 3.5*${sf} +variable n equal 1.0 +variable cut equal 3.0 -region box block 0 10 0 10 -0.01 0.01 units box +region box block 0 40 0 40 -0.01 0.01 create_box 1 box lattice sq ${n} create_atoms 1 region box -variable dr equal 0.1*${sf} -displace_atoms all random ${dr} ${dr} 0 135414 units box - +displace_atoms all random 0.1 0.1 0 135414 units box # ------ Model parameters ------ # @@ -53,22 +50,17 @@ pair_coeff * * # ------ Fixes & computes ------ # -fix 1 all rheo ${cut} quintic 0 shift -fix 2 all rheo/viscosity constant ${eta} -fix 3 all rheo/pressure linear - -compute 1 all rheo/property/atom rho phase +fix 1 all rheo ${cut} RK1 8 shift +fix 2 all rheo/viscosity * constant ${eta} +fix 3 all rheo/pressure * linear +compute rho all rheo/property/atom rho # ------ Output & Run ------ # thermo 200 thermo_style custom step time ke press -variable skin equal 0.2*${cut} -neighbor ${skin} bin -neigh_modify one 10000 #increase number of allowed neighbors - -#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_1[*] +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_rho run 10000 \ No newline at end of file diff --git a/src/GRANULAR/fix_add_heat.cpp b/src/GRANULAR/fix_add_heat.cpp index 7109ffb01c..a68c9c2b95 100644 --- a/src/GRANULAR/fix_add_heat.cpp +++ b/src/GRANULAR/fix_add_heat.cpp @@ -68,7 +68,7 @@ FixAddHeat::FixAddHeat(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg], "overwrite") == 0) { if (iarg + 1 >= narg) utils::missing_cmd_args(FLERR, "fix add/heat", error); - overwrite_flag = utils::bnumeric(FLERR, arg[iarg + 1], false, lmp); + overwrite_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else { error->all(FLERR, "Illegal fix add/heat command, invalid argument {}", arg[iarg]); diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp index 6b464c4000..c8eee29438 100644 --- a/src/RHEO/bond_rheo_shell.cpp +++ b/src/RHEO/bond_rheo_shell.cpp @@ -227,7 +227,6 @@ void BondRHEOShell::compute(int eflag, int vflag) if (t < EPSILON || std::isnan(t)) t = store_bond(n, i1, i2); - delx = x[i1][0] - x[i2][0]; dely = x[i1][1] - x[i2][1]; delz = x[i1][2] - x[i2][2]; diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 5ed43a421a..8b618e6e04 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -213,12 +213,10 @@ void ComputeRHEOGrad::compute_peratom() // Add corrections for walls if (interface_flag) { if (fluidi && (!fluidj)) { - compute_interface->correct_v(vi, vj, i, j); - //compute_interface->correct_v(vj, vi, j, i); + compute_interface->correct_v(vj, vi, j, i); rhoj = compute_interface->correct_rho(j, i); } else if ((!fluidi) && fluidj) { - compute_interface->correct_v(vj, vi, j, i); - //compute_interface->correct_v(vi, vj, i, j); + compute_interface->correct_v(vi, vj, i, j); rhoi = compute_interface->correct_rho(i, j); } else if ((!fluidi) && (!fluidj)) { rhoi = rho0[itype]; @@ -346,7 +344,7 @@ int ComputeRHEOGrad::pack_forward_comm(int n, int *list, double *buf, } else if (comm_stage == COMMFIELD) { if (velocity_flag) { - if (remap_v_flag & pbc_flag & (mask[j] & deform_groupbit)) { + if (remap_v_flag && pbc_flag && (mask[j] & deform_groupbit)) { for (k = 0; k < dim; k++) buf[m++] = v[j][k] + dv[k]; } else { diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index 31930d655d..672c63ba29 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -165,11 +165,11 @@ void ComputeRHEOInterface::compute_peratom() fluidj = !(status[j] & PHASECHECK); w = compute_kernel->calc_w_quintic(i, j, dx[0], dx[1], dx[2], sqrt(rsq)); - status_match = 0; norm[i] += w; + + status_match = 0; if ((fluidi && fluidj) || ((!fluidi) && (!fluidj))) status_match = 1; - if (status_match) { chi[i] += w; } else { @@ -307,30 +307,26 @@ void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf) /* ---------------------------------------------------------------------- */ -void ComputeRHEOInterface::correct_v(double *vi, double *vj, int i, int j) +void ComputeRHEOInterface::correct_v(double *v_solid, double *v_fluid, int i_solid, int i_fluid) { double wall_prefactor, wall_denom, wall_numer; - wall_numer = 2.0 * cut * (chi[i] - 0.5); - if (wall_numer < 0) wall_numer = 0; - wall_denom = 2.0 * cut * (chi[j] - 0.5); - if (wall_denom < wall_max) wall_denom = wall_max; + wall_numer = MAX(2.0 * cut * (chi[i_solid] - 0.5), 0.0); + wall_denom = MAX(2.0 * cut * (chi[i_fluid] - 0.5), wall_max); wall_prefactor = wall_numer / wall_denom; - vi[0] = (vi[0] - vj[0]) * wall_prefactor + vi[0]; - vi[1] = (vi[1] - vj[1]) * wall_prefactor + vi[1]; - vi[2] = (vi[2] - vj[2]) * wall_prefactor + vi[2]; + v_solid[0] = (v_solid[0] - v_fluid[0]) * wall_prefactor; + v_solid[1] = (v_solid[1] - v_fluid[1]) * wall_prefactor; + v_solid[2] = (v_solid[2] - v_fluid[2]) * wall_prefactor; } /* ---------------------------------------------------------------------- */ -double ComputeRHEOInterface::correct_rho(int i, int j) +double ComputeRHEOInterface::correct_rho(int i_solid, int i_fluid) { - // i is wall, j is fluid - //In future may depend on atom type j's pressure equation - int itype = atom->type[i]; - return MAX(rho0[itype], atom->rho[i]); + int itype = atom->type[i_solid]; + return MAX(rho0[itype], atom->rho[i_solid]); } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 11b03623b1..d6d8c2a07a 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -292,9 +292,14 @@ void ComputeRHEOPropertyAtom::pack_surface(int n) int *mask = atom->mask; int nlocal = atom->nlocal; + double label; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = (status[i] & SURFACECHECK); - else buf[n] = 0.0; + label = 0; + if (mask[i] & groupbit) { + if (status[i] & STATUS_SURFACE) label = 1.0; + if (status[i] & STATUS_SPLASH) label = 2.0; + } + buf[n] = label; n += nvalues; } } diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 1ef69bb6f0..bf2f2a3297 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -50,23 +50,18 @@ ComputeRHEOSurface::ComputeRHEOSurface(LAMMPS *lmp, int narg, char **arg) : int dim = domain->dimension; comm_forward = 2; comm_reverse = dim * dim + 1; + + nmax_store = 0; + grow_arrays(atom->nmax); } /* ---------------------------------------------------------------------- */ ComputeRHEOSurface::~ComputeRHEOSurface() { - // Remove custom property if it exists - int tmp1, tmp2, index; - index = atom->find_custom("rheo_divr", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); - - index = atom->find_custom("rheo_rsurface", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 0); - - index = atom->find_custom("rheo_nsurface", tmp1, tmp2); - if (index != -1) atom->remove_custom(index, 1, 3); - + memory->destroy(divr); + memory->destroy(rsurface); + memory->destroy(nsurface); memory->destroy(B); memory->destroy(gradC); } @@ -87,29 +82,6 @@ void ComputeRHEOSurface::init() cutsq = cut * cut; - // Create rsurface, divr, nsurface arrays as custom atom properties, - // can print with compute property/atom - // no grow callback as there's no reason to copy/exchange data, manually grow - // For B and gradC, create a local array since they are unlikely to be printed - - int dim = domain->dimension; - int tmp1, tmp2; - index_divr = atom->find_custom("rheo_divr", tmp1, tmp2); - if (index_divr == -1) index_divr = atom->add_custom("rheo_divr", 1, 0); - divr = atom->dvector[index_divr]; - - index_rsurf = atom->find_custom("rheo_rsurface", tmp1, tmp2); - if (index_rsurf == -1) index_rsurf = atom->add_custom("rheo_rsurface", 1, 0); - rsurface = atom->dvector[index_rsurf]; - - index_nsurf = atom->find_custom("rheo_nsurface", tmp1, tmp2); - if (index_nsurf == -1) index_nsurf = atom->add_custom("rheo_nsurface", 1, dim); - nsurface = atom->darray[index_nsurf]; - - nmax_store = atom->nmax; - memory->create(B, nmax_store, dim * dim, "rheo/surface:B"); - memory->create(gradC, nmax_store, dim * dim, "rheo/surface:gradC"); - // need an occasional half neighbor list neighbor->add_request(this, NeighConst::REQ_DEFAULT); } @@ -148,7 +120,7 @@ void ComputeRHEOSurface::compute_peratom() firstneigh = list->firstneigh; // Grow and zero arrays - if (nmax_store <= atom->nmax) + if (nmax_store < atom->nmax) grow_arrays(atom->nmax); size_t nbytes = nmax_store * sizeof(double); @@ -253,6 +225,10 @@ void ComputeRHEOSurface::compute_peratom() else test = coordination[i] < threshold_z; + // Treat nonfluid particles as bulk + if (status[i] & PHASECHECK) + test = 0; + if (test) { if (coordination[i] < threshold_splash) status[i] |= STATUS_SPLASH; @@ -272,6 +248,7 @@ void ComputeRHEOSurface::compute_peratom() xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + fluidi = !(status[i] & PHASECHECK); jlist = firstneigh[i]; jnum = numneigh[i]; @@ -280,22 +257,25 @@ void ComputeRHEOSurface::compute_peratom() j = jlist[jj]; j &= NEIGHMASK; + fluidj = !(status[j] & PHASECHECK); + dx[0] = xtmp - x[j][0]; dx[1] = ytmp - x[j][1]; dx[2] = ztmp - x[j][2]; rsq = lensq3(dx); if (rsq < cutsq) { - if ((status[i] & STATUS_BULK) && (status[j] & STATUS_SURFACE)) { - status[i] &= SURFACEMASK; - status[i] |= STATUS_LAYER; + if (fluidi) { + if ((status[i] & STATUS_BULK) && (status[j] & STATUS_SURFACE)) { + status[i] &= SURFACEMASK; + status[i] |= STATUS_LAYER; + } + + if (status[j] & STATUS_SURFACE) + rsurface[i] = MIN(rsurface[i], sqrt(rsq)); } - if (status[j] & STATUS_SURFACE) - rsurface[i] = MIN(rsurface[i], sqrt(rsq)); - - - if (j < nlocal || newton) { - if ((status[j] & STATUS_BULK) && (status[i] & STATUS_SURFACE)) { + if (fluidj && (j < nlocal || newton)) { + if ((status[j] & STATUS_BULK) && (status[j] & PHASECHECK) && (status[i] & STATUS_SURFACE)) { status[j] &= SURFACEMASK; status[j] |= STATUS_LAYER; } @@ -307,6 +287,16 @@ void ComputeRHEOSurface::compute_peratom() } } + // clear normal vectors for non surface particles + + for (i = 0; i < nall; i++) { + if (mask[i] & groupbit) { + if (!(status[i] & STATUS_SURFACE)) + for (a = 0; a < dim; a++) + nsurface[i][a] = 0.0; + } + } + // forward/reverse status and rsurface comm_stage = 1; comm_reverse = 2; @@ -416,18 +406,11 @@ void ComputeRHEOSurface::grow_arrays(int nmax) { int dim = domain->dimension; - // Grow atom variables and reassign pointers - memory->grow(atom->dvector[index_divr], nmax, "atom:rheo_divr"); - memory->grow(atom->dvector[index_rsurf], nmax, "atom:rheo_rsurface"); - memory->grow(atom->darray[index_nsurf], nmax, dim, "atom:rheo_nsurface"); - - divr = atom->dvector[index_divr]; - rsurface = atom->dvector[index_rsurf]; - nsurface = atom->darray[index_nsurf]; - - // Grow local variables + memory->grow(divr, nmax, "rheo/surface:divr"); + memory->grow(rsurface, nmax, "rheo/surface:rsurface"); + memory->grow(nsurface, nmax, dim, "rheo/surface:nsurface"); memory->grow(B, nmax, dim * dim, "rheo/surface:B"); memory->grow(gradC, nmax, dim * dim, "rheo/surface:gradC"); - nmax_store = atom->nmax; + nmax_store = nmax; } diff --git a/src/RHEO/compute_rheo_surface.h b/src/RHEO/compute_rheo_surface.h index 6ef2428499..044ff470c6 100644 --- a/src/RHEO/compute_rheo_surface.h +++ b/src/RHEO/compute_rheo_surface.h @@ -42,7 +42,6 @@ class ComputeRHEOSurface : public Compute { private: int surface_style, nmax_store, threshold_z, threshold_splash, interface_flag; int threshold_style, comm_stage; - int index_divr, index_rsurf, index_nsurf; double cut, cutsq, *rho0, threshold_divr; double **B, **gradC; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 533287911a..6e858ca207 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -72,6 +72,7 @@ void ComputeRHEOVShift::init() compute_interface = fix_rheo->compute_interface; compute_surface = fix_rheo->compute_surface; + rho0 = fix_rheo->rho0; cut = fix_rheo->cut; cutsq = cut * cut; cutthird = cut / 3.0; @@ -174,16 +175,14 @@ void ComputeRHEOVShift::compute_peratom() // Add corrections for walls if (interface_flag) { if (fluidi && (!fluidj)) { - compute_interface->correct_v(vi, vj, i, j); - //compute_interface->correct_v(vj, vi, j, i); - rhoj = compute_interface->correct_rho(j,i); - } else if ((!fluidi) && fluidj) { compute_interface->correct_v(vj, vi, j, i); - //compute_interface->correct_v(vi, vj, i, j); - rhoi = compute_interface->correct_rho(i,j); + rhoj = compute_interface->correct_rho(j, i); + } else if ((!fluidi) && fluidj) { + compute_interface->correct_v(vi, vj, i, j); + rhoi = compute_interface->correct_rho(i, j); } else if ((!fluidi) && (!fluidj)) { - rhoi = 1.0; - rhoj = 1.0; + rhoi = rho0[itype]; + rhoj = rho0[jtype]; } } @@ -196,7 +195,7 @@ void ComputeRHEOVShift::compute_peratom() w4 = w * w * w * w / (w0 * w0 * w0 * w0); dr = -2 * cutthird * (1 + 0.2 * w4) * wp * rinv; - if (mask[i] & groupbit) { + if ((mask[i] & groupbit) && fluidi) { vmag = sqrt(vi[0] * vi[0] + vi[1] * vi[1] + vi[2] * vi[2]); prefactor = vmag * volj * dr; @@ -206,7 +205,7 @@ void ComputeRHEOVShift::compute_peratom() } if (newton_pair || j < nlocal) { - if (mask[j] & groupbit) { + if ((mask[j] & groupbit) && fluidj) { vmag = sqrt(vj[0] * vj[0] + vj[1] * vj[1] + vj[2] * vj[2]); prefactor = vmag * voli * dr; @@ -241,7 +240,11 @@ void ComputeRHEOVShift::correct_surfaces() double nx, ny, nz, vx, vy, vz, dot; for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if ((status[i] & STATUS_SURFACE) || (status[i] & STATUS_LAYER)) { + + if (status[i] & PHASECHECK) continue; + + //if ((status[i] & STATUS_SURFACE) || (status[i] & STATUS_LAYER)) { + if (status[i] & STATUS_SURFACE) { nx = nsurface[i][0]; ny = nsurface[i][1]; vx = vshift[i][0]; @@ -266,6 +269,10 @@ void ComputeRHEOVShift::correct_surfaces() } else { vshift[i][2] = 0.0; } + } else if (status[i] & STATUS_SPLASH) { + vshift[i][0] = 0.0; + vshift[i][1] = 0.0; + vshift[i][2] = 0.0; } } } diff --git a/src/RHEO/compute_rheo_vshift.h b/src/RHEO/compute_rheo_vshift.h index 9d3a0166d6..485c6525f3 100644 --- a/src/RHEO/compute_rheo_vshift.h +++ b/src/RHEO/compute_rheo_vshift.h @@ -43,6 +43,7 @@ class ComputeRHEOVShift : public Compute { int nmax_store; double dtv, cut, cutsq, cutthird; int surface_flag, interface_flag; + double *rho0; class NeighList *list; class ComputeRHEOInterface *compute_interface; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index a355aee5d8..cb2abfb938 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -125,7 +125,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : interface_flag = 1; } else if (strcmp(arg[iarg], "rho/sum") == 0) { rhosum_flag = 1; - } else if (strcmp(arg[iarg], "self/mass")) { + } else if (strcmp(arg[iarg], "self/mass") == 0) { self_mass_flag = 1; } else if (strcmp(arg[iarg], "density") == 0) { if (iarg + n >= narg) error->all(FLERR, "Illegal rho0 option in fix rheo"); @@ -145,7 +145,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : iarg += 1; } - if (self_mass_flag && !rhosum_flag) + if (self_mass_flag && (!rhosum_flag)) error->all(FLERR, "Cannot use self/mass setting without rho/sum"); if (lmp->citeme) lmp->citeme->add(cite_rheo); @@ -227,6 +227,26 @@ void FixRHEO::init() if (modify->get_fix_by_style("^rheo$").size() > 1) error->all(FLERR, "Can only specify one instance of fix rheo"); + + if (atom->status_flag != 1) + error->all(FLERR,"fix rheo command requires atom property status"); + if (atom->rho_flag != 1) + error->all(FLERR,"fix rheo command requires atom property rho"); + if (atom->pressure_flag != 1) + error->all(FLERR,"fix rheo command requires atom property pressure"); + if (atom->viscosity_flag != 1) + error->all(FLERR,"fix rheo command requires atom property viscosity"); + + if (thermal_flag) { + if (atom->esph_flag != 1) + error->all(FLERR,"fix rheo command requires atom property esph with thermal setting"); + if (atom->temperature_flag != 1) + error->all(FLERR,"fix rheo command requires atom property temperature with thermal setting"); + if (atom->heatflow_flag != 1) + error->all(FLERR,"fix rheo command requires atom property heatflow with thermal setting"); + if (atom->conductivity_flag != 1) + error->all(FLERR,"fix rheo command requires atom property conductivity with thermal setting"); + } } /* ---------------------------------------------------------------------- */ @@ -386,6 +406,7 @@ void FixRHEO::initial_integrate(int /*vflag*/) for (i = 0; i < nlocal; i++) { if (status[i] & STATUS_NO_SHIFT) continue; + if (status[i] & PHASECHECK) continue; if (mask[i] & groupbit) { for (a = 0; a < dim; a++) { diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 89a0591824..0af9fa8d01 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -79,7 +79,7 @@ namespace RHEO_NS { enum Status{ // Phase status STATUS_SOLID = 1 << 0, - // STATUS_REACTIVE = 1 << 1, + // Gap for future phase: STATUS_ = 1 << 1, // Surface status STATUS_BULK = 1 << 2, diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index 9f19d4f4da..5b0a50b4a5 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -30,6 +30,7 @@ #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" +#include "update.h" using namespace LAMMPS_NS; using namespace RHEO_NS; @@ -55,6 +56,8 @@ FixRHEOOxidation::FixRHEOOxidation(LAMMPS *lmp, int narg, char **arg) : { if (narg != 6) error->all(FLERR,"Illegal fix command"); + force_reneighbor = 1; + next_reneighbor = -1; comm_forward = 3; cut = utils::numeric(FLERR, arg[3], false, lmp); @@ -82,8 +85,9 @@ FixRHEOOxidation::~FixRHEOOxidation() int FixRHEOOxidation::setmask() { int mask = 0; - mask |= PRE_FORCE; mask |= POST_INTEGRATE; + mask |= PRE_FORCE; + mask |= POST_FORCE; return mask; } @@ -133,25 +137,19 @@ void FixRHEOOxidation::setup_pre_force(int /*vflag*/) if (!fix_rheo->surface_flag) error->all(FLERR, "fix rheo/oxidation requires surface calculation in fix rheo"); compute_surface = fix_rheo->compute_surface; - - pre_force(0); } /* ---------------------------------------------------------------------- */ void FixRHEOOxidation::pre_force(int /*vflag*/) { - int *status = atom->status; - for (int i = 0; i < atom->nlocal; i++) - if (num_bond[i] != 0) - status[i] |= STATUS_NO_SHIFT; } /* ---------------------------------------------------------------------- */ void FixRHEOOxidation::post_integrate() { - int i, j, n, ii, jj, inum, jnum, bflag; + int i, j, n, ii, jj, inum, jnum, bflag, fluidi, fluidj; int *ilist, *jlist, *numneigh, **firstneigh; double delx, dely, delz, rsq; tagint tagi, tagj; @@ -163,6 +161,8 @@ void FixRHEOOxidation::post_integrate() tagint **bond_atom = atom->bond_atom; int **bond_type = atom->bond_type; int *num_bond = atom->num_bond; + int *mask = atom->mask; + int *status = atom->status; double *rsurface = compute_surface->rsurface; double **x = atom->x; @@ -175,10 +175,15 @@ void FixRHEOOxidation::post_integrate() // Note: surface designation lags one timestep, acceptable error comm->forward_comm(this); + int added_bonds = 0; // loop over neighbors of my atoms for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - if (rsurface[i] > rsurf) continue; + if (!(mask[i] & groupbit)) continue; + + // Exclude particles that aren't solid or surface + fluidi = !(status[i] & PHASECHECK); + if (fluidi && (rsurface[i] > rsurf)) continue; tagi = tag[i]; @@ -188,8 +193,13 @@ void FixRHEOOxidation::post_integrate() for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; j &= NEIGHMASK; + if (!(mask[j] & groupbit)) continue; - if (rsurface[j] > rsurf) continue; + fluidj = !(status[j] & PHASECHECK); + if (fluidj && (rsurface[j] > rsurf)) continue; + + // Skip solid-solid, leaves surface-surface or surface-solid + if ((!fluidi) && (!fluidj)) continue; tagj = tag[j]; @@ -218,6 +228,8 @@ void FixRHEOOxidation::post_integrate() } if (bflag) continue; + added_bonds += 1; + // Add bonds to owned atoms // If newton bond off, add to both, otherwise add to whichever has a smaller tag @@ -230,6 +242,23 @@ void FixRHEOOxidation::post_integrate() } } } + + int added_bonds_all; + MPI_Allreduce(&added_bonds, &added_bonds_all, 1, MPI_INT, MPI_SUM, world); + + if (added_bonds_all > 0) + next_reneighbor = update->ntimestep; +} + +/* ---------------------------------------------------------------------- */ + +void FixRHEOOxidation::post_force(int /*vflag*/) +{ + int *status = atom->status; + int *num_bond = atom->num_bond; + for (int i = 0; i < atom->nlocal; i++) + if (num_bond[i] != 0) + status[i] |= STATUS_NO_SHIFT; } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_oxidation.h b/src/RHEO/fix_rheo_oxidation.h index 5991a830c0..6dddea867a 100644 --- a/src/RHEO/fix_rheo_oxidation.h +++ b/src/RHEO/fix_rheo_oxidation.h @@ -34,8 +34,9 @@ class FixRHEOOxidation : public Fix { void init() override; void init_list(int, class NeighList *) override; void setup_pre_force(int) override; - void pre_force(int) override; void post_integrate() override; + void pre_force(int) override; + void post_force(int) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm(int, int, double *) override; int *nbond; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 24a6a73021..321fee07e7 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -259,7 +259,8 @@ void FixRHEOThermal::init() compute_grad = fix_rheo->compute_grad; compute_vshift = fix_rheo->compute_vshift; - dtf = 0.5 * update->dt * force->ftm2v; + dt = update->dt; + dth = 0.5 * update->dt; if (atom->esph_flag != 1) error->all(FLERR,"fix rheo/thermal command requires atom property esph"); @@ -337,7 +338,7 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) for (i = 0; i < nlocal; i++) { if (status[i] & STATUS_NO_SHIFT) continue; for (a = 0; a < dim; a++) - energy[i] += dtv * vshift[i][a] * grade[i][a]; + energy[i] += dt * vshift[i][a] * grade[i][a]; } } @@ -363,7 +364,7 @@ void FixRHEOThermal::post_integrate() itype = type[i]; cvi = calc_cv(i, itype); - energy[i] += dtf * heatflow[i]; + energy[i] += dth * heatflow[i]; temperature[i] = energy[i] / cvi; if (Tc_style[itype] != NONE) { @@ -376,6 +377,8 @@ void FixRHEOThermal::post_integrate() temperature[i] = Ti; } + // Check phase change if Ti != Tci + if (Ti > Tci) { // If solid, melt if (status[i] & STATUS_SOLID) { @@ -383,7 +386,9 @@ void FixRHEOThermal::post_integrate() status[i] |= STATUS_MELTING; n_melt += 1; } - } else { + } + + if (Ti < Tci) { // If fluid, freeze if (!(status[i] & STATUS_SOLID)) { status[i] &= PHASEMASK; @@ -400,6 +405,23 @@ void FixRHEOThermal::post_integrate() MPI_Allreduce(&n_freeze, &n_freeze_all, 1, MPI_INT, MPI_SUM, world); if (cut_bond > 0 && (n_melt_all || n_freeze_all)) { + + // If a particle freezes, check if it already has bonds of that type + // If so, assume it was inserted as a solid particle + // Note: inserted solid particle may still shift one timestep + int *num_bond = atom->num_bond; + int **bond_type = atom->bond_type; + for (i = 0; i < atom->nlocal; i++) { + if (status[i] & STATUS_FREEZING) { + for (int n = 0; n < num_bond[i]; n++) { + if (bond_type[i][n] == btype) { + status[i] &= ~STATUS_FREEZING; + break; + } + } + } + } + // Forward status + positions (after inititial integrate, before comm) comm->forward_comm(this); @@ -464,11 +486,6 @@ void FixRHEOThermal::pre_force(int /*vflag*/) } } } - - // Add temporary options, wiped by preceding fix rheo preforce - for (int i = 0; i < nall; i++) - if (status[i] & STATUS_SOLID) - status[i] |= STATUS_NO_SHIFT; } /* ---------------------------------------------------------------------- */ @@ -482,7 +499,7 @@ void FixRHEOThermal::final_integrate() //Integrate energy for (int i = 0; i < atom->nlocal; i++) { if (status[i] & STATUS_NO_INTEGRATION) continue; - energy[i] += dtf * heatflow[i]; + energy[i] += dth * heatflow[i]; } } @@ -490,8 +507,8 @@ void FixRHEOThermal::final_integrate() void FixRHEOThermal::reset_dt() { - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; + dt = update->dt; + dth = 0.5 * update->dt; } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/fix_rheo_thermal.h b/src/RHEO/fix_rheo_thermal.h index c4c26eef6a..264bbdbce3 100644 --- a/src/RHEO/fix_rheo_thermal.h +++ b/src/RHEO/fix_rheo_thermal.h @@ -48,7 +48,7 @@ class FixRHEOThermal : public Fix { private: double *cv, *Tc, *kappa, *L; - double dtf, dtv; + double dt, dth; double cut_kernel, cut_bond, cutsq_bond; int *cv_style, *Tc_style, *kappa_style, *L_style; int btype; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 6e8c20a5d8..0a52bd53bc 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -208,14 +208,14 @@ void PairRHEO::compute(int eflag, int vflag) // Add corrections for walls rhoi = rho[i]; rhoj = rho[j]; - rho0i = rho[itype]; - rho0j = rho[jtype]; + rho0i = rho0[itype]; + rho0j = rho0[jtype]; Pi = pressure[i]; Pj = pressure[j]; fmag = 0; if (interface_flag) { if (fluidi && (!fluidj)) { - compute_interface->correct_v(vi, vj, i, j); + compute_interface->correct_v(vj, vi, j, i); rhoj = compute_interface->correct_rho(j, i); Pj = fix_pressure->calc_pressure(rhoj, jtype); @@ -223,7 +223,7 @@ void PairRHEO::compute(int eflag, int vflag) fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0j * csq_ave * h * rinv; } else if ((!fluidi) && fluidj) { - compute_interface->correct_v(vj, vi, j, i); + compute_interface->correct_v(vi, vj, i, j); rhoi = compute_interface->correct_rho(i, j); Pi = fix_pressure->calc_pressure(rhoi, itype); From fc0b155de9829003c18ea6040e63f17f306a4a57 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 3 Jun 2024 15:04:24 -0600 Subject: [PATCH 087/104] Dam example, generalizing non-quintic kernels --- doc/src/Howto_rheo.rst | 4 + examples/rheo/balloon/in.rheo.balloon | 1 + examples/rheo/dam-break/in.rheo.dam.break | 45 ++++---- examples/rheo/ice-cubes/in.rheo.ice.cubes | 1 + examples/rheo/oxidation/in.rheo.oxidation | 2 +- examples/rheo/poiseuille/in.rheo.poiseuille | 4 +- .../rheo/taylor-green/in.rheo.taylor.green | 3 +- src/RHEO/compute_rheo_kernel.cpp | 100 ++++++++++++++++-- src/RHEO/compute_rheo_kernel.h | 3 + src/RHEO/compute_rheo_rho_sum.cpp | 2 +- src/RHEO/fix_rheo.cpp | 2 + src/RHEO/fix_rheo.h | 2 +- 12 files changed, 129 insertions(+), 40 deletions(-) diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index b09925d6ac..939754aa95 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -17,6 +17,10 @@ these calculations. Additional numerical details can be found in :ref:`(Palermo) ` and :ref:`(Clemmer) `. +Note, if you simply want to run a traditional SPH simulation, the SPH package +is likely better suited for your application. It has fewer advanced features +and therefore benefits from improved performance. + ---------- At the core of the package is :doc:`fix rheo ` which integrates diff --git a/examples/rheo/balloon/in.rheo.balloon b/examples/rheo/balloon/in.rheo.balloon index d24573b0fb..c82fa39df3 100644 --- a/examples/rheo/balloon/in.rheo.balloon +++ b/examples/rheo/balloon/in.rheo.balloon @@ -60,6 +60,7 @@ fix 1 all rheo ${cut} quintic 0 & fix 2 all rheo/viscosity * constant ${eta} fix 3 all rheo/pressure * linear fix 4 all wall/harmonic ylo EDGE 2.0 1.0 1.0 +fix 5 all enforce2d compute rho all rheo/property/atom rho compute phase all rheo/property/atom phase diff --git a/examples/rheo/dam-break/in.rheo.dam.break b/examples/rheo/dam-break/in.rheo.dam.break index b59b710451..870b3529b6 100644 --- a/examples/rheo/dam-break/in.rheo.dam.break +++ b/examples/rheo/dam-break/in.rheo.dam.break @@ -3,24 +3,24 @@ dimension 2 units lj atom_style rheo -boundary f f p +boundary f s p comm_modify vel yes newton off # ------ Create simulation box ------ # variable n equal 1.0 -variable cut equal 3.0 -variable dx equal 4.0 +variable cut equal 2.2 +variable dx equal 3.0 -region box block -1 200 -1 80 -0.1 0.1 units box -#region box block -1 100 -1 40 -0.1 0.1 units box +region box block -1 150 -1 80 -0.1 0.1 units box create_box 2 box lattice hex ${n} -region fluid block $(xlo+v_dx) $(xlo+44.0) $(ylo+v_dx) $(yhi-16.0) EDGE EDGE units box -#region fluid block $(xlo+v_dx) $(xlo+20.0) $(ylo+v_dx) $(yhi-10.0) EDGE EDGE units box -region walls block $(xlo+v_dx) $(xhi-v_dx) $(ylo+v_dx) $(yhi-v_dx) EDGE EDGE units box side out +region fluid block $(xlo+v_dx+1.0) $(xlo+40.0) $(ylo+v_dx+1.0) $(yhi-20.0) EDGE EDGE units box +region walls1 block $(xlo+v_dx) $(xhi-v_dx) $(ylo+v_dx) $(yhi-v_dx) EDGE EDGE side out units box +region walls2 block EDGE EDGE EDGE $(yhi-v_dx) EDGE EDGE side in units box +region walls intersect 2 walls1 walls2 create_atoms 1 region fluid create_atoms 2 region walls @@ -33,12 +33,13 @@ group rig type 2 variable rho0 equal 1.0 variable mp equal ${rho0}/${n} variable cs equal 1.0 -variable zeta equal 0.05 +variable zeta equal 0.1 variable dt_max equal 0.1*${cut}/${cs}/3 -variable eta equal 0.05 -variable Dr equal 0.05 +variable eta equal 0.1 +variable Dr equal 0.1 -mass * ${mp} +mass 1 ${mp} +mass 2 $(2*v_mp) set group all rheo/rho ${rho0} set group all rheo/status 0 @@ -46,36 +47,30 @@ set group rig rheo/status 1 timestep ${dt_max} -pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} +pair_style rheo ${cut} artificial/visc ${zeta} #rho/damp ${Dr} pair_coeff * * - # ------ Fixes & computes ------ # fix 1 all rheo ${cut} quintic 10 & - shift & surface/detection coordination 22 8 & - interface/reconstruct -#fix 1 all rheo ${cut} RK1 10 surface/detection coordination 36 10 interface/reconstruct shift + rho/sum fix 2 all rheo/viscosity * constant ${eta} fix 3 all rheo/pressure * linear -fix 4 all gravity 5e-4 vector 0 -1 0 +fix 4 all gravity 1e-3 vector 0 -1 0 fix 5 rig setforce 0.0 0.0 0.0 +fix 6 all enforce2d compute rho all rheo/property/atom rho -compute phase all rheo/property/atom phase compute p all rheo/property/atom pressure compute surf all rheo/property/atom surface compute sn all rheo/property/atom surface/n/x surface/n/y -compute vshift all rheo/property/atom shift/v/x shift/v/y - # ------ Output & Run ------ # -thermo 100 +thermo 20 thermo_style custom step time ke press -dump 1 all custom 20 atomDump id type x y vx vy fx fy c_rho c_phase c_surf c_p c_vshift[*] c_sn[*] +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_rho c_surf c_p c_sn[*] -#thermo 1 -run 300000 # 400000 +run 30000 diff --git a/examples/rheo/ice-cubes/in.rheo.ice.cubes b/examples/rheo/ice-cubes/in.rheo.ice.cubes index 12eb54c32e..b023a8bac9 100644 --- a/examples/rheo/ice-cubes/in.rheo.ice.cubes +++ b/examples/rheo/ice-cubes/in.rheo.ice.cubes @@ -64,6 +64,7 @@ fix 4 all rheo/thermal conductivity * constant ${kappa} & fix 5 all wall/region wall harmonic 1.0 1.0 1.0 fix 6 all gravity 5e-4 vector 0 -1 0 fix 7 all deposit 8 0 1000 37241459 mol my_mol region drop near 2.0 vy -0.02 -0.02 +fix 8 all enforce2d compute rho all rheo/property/atom rho compute phase all rheo/property/atom phase diff --git a/examples/rheo/oxidation/in.rheo.oxidation b/examples/rheo/oxidation/in.rheo.oxidation index 5c1456ad5a..d26b379adb 100644 --- a/examples/rheo/oxidation/in.rheo.oxidation +++ b/examples/rheo/oxidation/in.rheo.oxidation @@ -10,7 +10,6 @@ newton off region box block -60 60 0 80 -0.01 0.01 units box create_box 3 box bond/types 2 extra/bond/per/atom 20 extra/special/per/atom 50 - region lbar block -15 0 3 80 EDGE EDGE units box region rbar block 0 15 3 80 EDGE EDGE units box region bar union 2 lbar rbar @@ -83,6 +82,7 @@ fix 7 all gravity 5e-5 vector 0 -1 0 fix 8 floor setforce 0.0 0.0 0.0 fix 9 surf add/heat linear 1.1 0.05 fix 10 floor add/heat constant 0 overwrite yes # fix the temperature of the floor +fix 11 all enforce2d compute surf all rheo/property/atom surface compute rho all rheo/property/atom rho diff --git a/examples/rheo/poiseuille/in.rheo.poiseuille b/examples/rheo/poiseuille/in.rheo.poiseuille index ee8ad5523c..7c38c8a6e0 100644 --- a/examples/rheo/poiseuille/in.rheo.poiseuille +++ b/examples/rheo/poiseuille/in.rheo.poiseuille @@ -6,7 +6,6 @@ atom_style rheo boundary p p p comm_modify vel yes - # ------ Create simulation box ------ # variable n equal 1.0 @@ -53,7 +52,6 @@ timestep ${dt_max} pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} pair_coeff * * - # ------ Fixes & computes ------ # fix 1 all rheo ${cut} quintic 0 shift @@ -62,10 +60,10 @@ fix 2 all rheo/viscosity * constant ${eta} fix 3 all rheo/pressure * linear fix 4 rig setforce 0.0 0.0 0.0 fix 5 fluid addforce ${fext} 0.0 0.0 +fix 6 all enforce2d compute rho all rheo/property/atom rho - # ------ Output & Run ------ # thermo 200 diff --git a/examples/rheo/taylor-green/in.rheo.taylor.green b/examples/rheo/taylor-green/in.rheo.taylor.green index e386d8262c..4485387440 100644 --- a/examples/rheo/taylor-green/in.rheo.taylor.green +++ b/examples/rheo/taylor-green/in.rheo.taylor.green @@ -7,7 +7,6 @@ boundary p p p comm_modify vel yes newton off - # ------ Create simulation box ------ # variable n equal 1.0 @@ -47,12 +46,12 @@ timestep ${dt_max} pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} pair_coeff * * - # ------ Fixes & computes ------ # fix 1 all rheo ${cut} RK1 8 shift fix 2 all rheo/viscosity * constant ${eta} fix 3 all rheo/pressure * linear +fix 4 all enforce2d compute rho all rheo/property/atom rho diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index bd16a89b6a..d0f24850bd 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -25,6 +25,7 @@ #include "error.h" #include "fix_rheo.h" #include "force.h" +#include "math_const.h" #include "math_extra.h" #include "memory.h" #include "modify.h" @@ -43,6 +44,7 @@ using namespace LAMMPS_NS; using namespace RHEO_NS; +using namespace MathConst; using namespace MathExtra; static constexpr int DELTA = 2000; @@ -57,8 +59,7 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : kernel_style = utils::inumeric(FLERR,arg[3],false,lmp); - - if (kernel_style == QUINTIC) { + if (kernel_style == QUINTIC || kernel_style == WENDLANDC4) { correction_order = -1; } else if (kernel_style == RK0) { correction_order = 0; @@ -115,12 +116,22 @@ void ComputeRHEOKernel::init() hsqinv = hinv * hinv; - if (dim == 3) { - pre_w = 0.002652582384864922 * 27.0 * hsqinv * hinv; - pre_wp = pre_w * 3.0 * hinv; + if (kernel_style != WENDLANDC4) { + if (dim == 3) { + pre_w = 1.0 / (120.0 * MY_PI) * 27.0 * hsqinv * hinv; + pre_wp = pre_w * 3.0 * hinv; + } else { + pre_w = 7.0 / (478.0 * MY_PI) * 9 * hsqinv; + pre_wp = pre_w * 3.0 * hinv; + } } else { - pre_w = 0.004661441847879780 * 9 * hsqinv; - pre_wp = pre_w * 3.0 * hinv; + if (dim == 3) { + pre_w = 495.0 / (32.0 * MY_PI * hsq * h); + pre_wp = pre_w * hinv; + } else { + pre_w = 9.0 / (MY_PI * hsq); + pre_wp = pre_w * hinv; + } } nmax_store = atom->nmax; @@ -163,11 +174,27 @@ int ComputeRHEOKernel::check_corrections(int i) /* ---------------------------------------------------------------------- */ +double ComputeRHEOKernel::calc_w_self(int i, int j) +{ + double w; + if (kernel_style == WENDLANDC4) + w = calc_w_wendlandc4(i, j, 0.0, 0.0, 0.0, 0.0); + else + w = calc_w_quintic(i, j, 0.0, 0.0, 0.0, 0.0); + + return w; +} + +/* ---------------------------------------------------------------------- */ + double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double delz, double r) { double w; int corrections_i, corrections_j, corrections; + if (kernel_style == WENDLANDC4) + return calc_w_wendlandc4(i,j,delx,dely,delz,r); + if (kernel_style != QUINTIC) { corrections_i = check_corrections(i); corrections_j = check_corrections(j); @@ -191,6 +218,9 @@ double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double double wp; int corrections_i, corrections_j; + if (kernel_style == WENDLANDC4) + return calc_dw_wendlandc4(i,j,delx,dely,delz,r,dWij,dWji); + if (kernel_style != QUINTIC) { corrections_i = check_corrections(i); corrections_j = check_corrections(j); @@ -288,6 +318,62 @@ double ComputeRHEOKernel::calc_dw_quintic(int i, int j, double delx, double dely return wp; } +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_w_wendlandc4(int i, int j, double delx, double dely, double delz, double r) +{ + double w, tmp6, s; + s = r * hinv; + + if (s > 1.0) { + w = 0.0; + } else { + tmp6 = (1.0 - s) * (1.0 - s); + tmp6 *= tmp6 * tmp6; + w = tmp6 * (1.0 + 6.0 * s + 35.0 * THIRD * s * s); + } + + w *= pre_w; + + Wij = w; + Wji = w; + + return w; +} + +/* ---------------------------------------------------------------------- */ + +double ComputeRHEOKernel::calc_dw_wendlandc4(int i, int j, double delx, double dely, double delz, double r, double *dW1, double *dW2) +{ + double wp, tmp1, tmp5, tmp6, s, wprinv; + double *mass = atom->mass; + int *type = atom->type; + + s = r * hinv; + + if (s > 1.0) { + wp = 0.0; + } else { + tmp1 = 1.0 - s; + tmp5 = tmp1 * tmp1; + tmp5 = tmp5 * tmp5 * tmp1; + tmp6 = tmp5 * tmp1; + wp = tmp6 * (6.0 + 70.0 * THIRD * s); + wp -= 6 * tmp5 * (1.0 + 6.0 * s + 35.0 * THIRD * s * s); + } + + wp *= pre_wp; + wprinv = wp / r; + dW1[0] = delx * wprinv; + dW1[1] = dely * wprinv; + dW1[2] = delz * wprinv; + + dW2[0] = -delx * wprinv; + dW2[1] = -dely * wprinv; + dW2[2] = -delz * wprinv; + + return wp; +} /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index ed190c19ce..543e5d88c0 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -36,10 +36,13 @@ class ComputeRHEOKernel : public Compute { void unpack_forward_comm(int, int, double *) override; double memory_usage() override; void compute_coordination(); + double calc_w_self(int,int); double calc_w(int,int,double,double,double,double); double calc_dw(int,int,double,double,double,double); double calc_w_quintic(int,int,double,double,double,double); double calc_dw_quintic(int,int,double,double,double,double,double *,double *); + double calc_w_wendlandc4(int,int,double,double,double,double); + double calc_dw_wendlandc4(int,int,double,double,double,double,double *,double *); void grow_arrays(int); double dWij[3], dWji[3], Wij, Wji; diff --git a/src/RHEO/compute_rheo_rho_sum.cpp b/src/RHEO/compute_rheo_rho_sum.cpp index c7270897a4..d7f432a03d 100644 --- a/src/RHEO/compute_rheo_rho_sum.cpp +++ b/src/RHEO/compute_rheo_rho_sum.cpp @@ -94,7 +94,7 @@ void ComputeRHEORhoSum::compute_peratom() // initialize arrays, local with quintic self-contribution, ghosts are zeroed for (i = 0; i < nlocal; i++) { - w = compute_kernel->calc_w_quintic(i, i, 0.0, 0.0, 0.0, 0.0); + w = compute_kernel->calc_w_self(i, i); rho[i] = w * mass[type[i]]; } diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index cb2abfb938..c704677bec 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -90,6 +90,8 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : cut = h; if (strcmp(arg[4], "quintic") == 0) { kernel_style = QUINTIC; + } else if (strcmp(arg[4], "wendland/c4") == 0) { + kernel_style = WENDLANDC4; } else if (strcmp(arg[4], "RK0") == 0) { kernel_style = RK0; } else if (strcmp(arg[4], "RK1") == 0) { diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 0af9fa8d01..251f82a99a 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -72,7 +72,7 @@ class FixRHEO : public Fix { namespace RHEO_NS { - enum {QUINTIC, RK0, RK1, RK2}; + enum {QUINTIC, WENDLANDC4, RK0, RK1, RK2}; enum {COORDINATION, DIVR}; // Status variables From 2aacc017cbdb93ee8c461605da05f63f9c5e7c1e Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 12 Jun 2024 17:29:30 -0600 Subject: [PATCH 088/104] Changes to CMake to hopefully match Sachith's suggestions --- cmake/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index dd5fac30c6..d80e7df46c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -440,7 +440,7 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_STANDARD GREATER_EQUA PROPERTIES COMPILE_OPTIONS "-std=c++14") endif() -if(PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_ML-POD OR PKG_ELECTRODE OR BUILD_TOOLS OR PKG_RHEO) +if(PKG_ATC OR PKG_AWPMD OR PKG_ML-QUIP OR PKG_ML-POD OR PKG_ELECTRODE OR BUILD_TOOLS) enable_language(C) if (NOT USE_INTERNAL_LINALG) find_package(LAPACK) @@ -515,7 +515,7 @@ else() endif() foreach(PKG_WITH_INCL KSPACE PYTHON ML-IAP VORONOI COLVARS ML-HDNNP MDI MOLFILE NETCDF - PLUMED QMMM ML-QUIP SCAFACOS MACHDYN VTK KIM COMPRESS ML-PACE LEPTON) + PLUMED QMMM ML-QUIP SCAFACOS MACHDYN VTK KIM COMPRESS ML-PACE LEPTON RHEO) if(PKG_${PKG_WITH_INCL}) include(Packages/${PKG_WITH_INCL}) endif() From 3c0eaf6870d59e72a81191f50a7198b160af45be Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 27 Jun 2024 16:57:53 -0600 Subject: [PATCH 089/104] Moving stress calculation to rheo/prop/atom --- doc/src/compute_rheo_property_atom.rst | 53 +++--- src/RHEO/compute_rheo_property_atom.cpp | 221 +++++++++++++++++------- src/RHEO/compute_rheo_property_atom.h | 8 +- src/RHEO/pair_rheo.cpp | 19 +- src/bond_hybrid.cpp | 2 +- src/pair.cpp | 102 ----------- src/pair.h | 2 - 7 files changed, 202 insertions(+), 205 deletions(-) diff --git a/doc/src/compute_rheo_property_atom.rst b/doc/src/compute_rheo_property_atom.rst index a7e1bff383..861fd04688 100644 --- a/doc/src/compute_rheo_property_atom.rst +++ b/doc/src/compute_rheo_property_atom.rst @@ -17,13 +17,11 @@ Syntax .. parsed-literal:: possible attributes = phase, surface, surface/r, - surface/divr, surface/n/x, surface/n/y, - surface/n/z, coordination, cv, shift/v/x, - shift/v/y, shift/v/z, energy, temperature, heatflow, - conductivity, cv, viscosity, pressure, - rho, grad/v/xx, grad/v/xy, grad/v/xz, - grad/v/yx, grad/v/yy/, grad/v/yz, grad/v/zx, - grad/v/zy, grad/v/zz + surface/divr, surface/n/:math:`\alpha`, coordination, + shift/v/:math:`\alpha`, energy, temperature, heatflow, + conductivity, cv, viscosity, pressure, rho, + grad/v/:math:`\alpha \beta`, stress/v/:math:`\alpha \beta`, + stress/t/:math:`\alpha \beta`, nbond/shell .. parsed-literal:: @@ -31,9 +29,9 @@ Syntax *surface* = atom surface status *surface/r* = atom distance from the surface *surface/divr* = divergence of position at atom position - *surface/n/\** = surface normal vector + *surface/n/:math:`\alpha`* = surface normal vector *coordination* = coordination number - *shift/v/\** = atom shifting velocity + *shift/v/:math:`\alpha`* = atom shifting velocity *energy* = atom energy *temperature* = atom temperature *heatflow* = atom heat flow @@ -42,7 +40,9 @@ Syntax *viscosity* = atom viscosity *pressure* = atom pressure *rho* = atom density - *grad/v/\** = atom velocity gradient + *grad/v/:math:`\alpha \beta`* = atom velocity gradient + *stress/v/:math:`\alpha \beta`* = atom viscous stress + *stress/t/:math:`\alpha \beta`* = atom total stress (pressure and viscous) *nbond/shell* = number of oxide bonds Examples @@ -50,8 +50,8 @@ Examples .. code-block:: LAMMPS - compute 1 all rheo/property/atom phase surface/r pressure - compute 2 all rheo/property/atom shift/v/x grad/v/xx + compute 1 all rheo/property/atom phase surface/r surface/n/* pressure + compute 2 all rheo/property/atom shift/v/x grad/v/xx stress/v/* Description """"""""""" @@ -68,6 +68,17 @@ computes as inputs. See for example, the :doc:`fix ave/chunk `, and :doc:`atom-style variable ` commands. +For vector attributes, e.g. *shift/v/:math:`\alpha`*, one must specify +:math:`\alpha` as the *x*, *y*, or *z* component, e.g. *shift/v/x*. +Alternatively, a wild card \* will include all components, *x* and *y* in +2D or *x*, *y*, and *z* in 3D. + +For tensor attributes, e.g. *grad/v/:math:`\alpha \beta`*, one must specify +both :math:`\alpha` and :math:`\beta` as *x*, *y*, or *z*, e.g. *grad/v/xy*. +Alternatively, a wild card \* will include all components. In 2D, this +includes *xx*, *xy*, *yx*, and *yy*. In 3D, this includes *xx*, *xy*, *xz*, +*yx*, *yy*, *yz*, *zx*, *zy*, and *zz*. + Many properties require their respective fixes, listed below in related commands, be defined. For instance, the *viscosity* attribute is the viscosity of a particle calculated by @@ -85,19 +96,12 @@ distance from the surface, up to the kernel cutoff length. Surface particles have a value of 0. The *surface/n* properties are the components of the surface normal vector. -The *shift/v* properties are the components of the shifting velocity +The *shift/v/:math:`\alpha`* properties are the components of the shifting velocity produced by the *shift* option of :doc:`fix rheo `. -The *surface/n/\** and *shift/v/\** attributes are vectors that require -specification of the *x*, *y*, or *z* component, e.g. *surface/n/x*. - The *nbond/shell* property is the number of shell bonds that have been activated from :doc:`bond style rheo/shell `. -The *grad/v/\** attribute is a tensor and requires specification of -the *xx*, *yy*, *zz*, *xy*, *xz*, *yx*, *yz*, *zx*, or *zy* component, -e.g. *grad/v/xy*. - The values are stored in a per-atom vector or array as discussed below. Zeroes are stored for atoms not in the specified group or for quantities that are not defined for a particular particle in the group @@ -109,9 +113,12 @@ This compute calculates a per-atom vector or per-atom array depending on the number of input values. If a single input is specified, a per-atom vector is produced. If two or more inputs are specified, a per-atom array is produced where the number of columns = the number of -inputs. The vector or array can be accessed by any command that uses -per-atom values from a compute as input. See the :doc:`Howto output -` page for an overview of LAMMPS output options. +inputs. If a wild card \* is used for a vector or tensor, then the number +of inputs is considered to be incremented by the dimensiod or dimension +squared, respectively. The vector or array can be accessed by any command +that uses per-atom values from a compute as input. See the +:doc:`Howto output ` page for an overview of LAMMPS output +options. The vector or array values will be in whatever :doc:`units ` the corresponding attribute is in (e.g., density units for *rho*). diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index d6d8c2a07a..533822bbdd 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -53,7 +53,26 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (narg < 4) utils::missing_cmd_args(FLERR, "compute property/atom", error); peratom_flag = 1; - nvalues = narg - 3; + int dim = domain->dimension; + + // Determine number of values + nvalues = 0; + for (int iarg = 3; iarg < narg; iarg++) { + if (strcmp(arg[iarg], "surface/n/*") == 0) { + nvalues += dim; + } else if (strcmp(arg[iarg], "shift/v/*") == 0) { + nvalues += dim; + } else if (strcmp(arg[iarg], "grad/v/*") == 0) { + nvalues += dim * dim; + } else if (strcmp(arg[iarg], "stress/v/*") == 0) { + nvalues += dim * dim; + } else if (strcmp(arg[iarg], "stress/t/*") == 0) { + nvalues += dim * dim; + } else { + nvalues += 1; + } + } + if (nvalues == 1) size_peratom_cols = 0; else size_peratom_cols = nvalues; @@ -66,11 +85,11 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a pack_choice = new FnPtrPack[nvalues]; avec_index = new int[nvalues]; col_index = new int[nvalues]; + col_t_index = new int[nvalues]; - int i; + int i = 0; + int index, a, b; for (int iarg = 3; iarg < narg; iarg++) { - i = iarg-3; - if (strcmp(arg[iarg], "phase") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_phase; } else if (strcmp(arg[iarg], "rho") == 0) { @@ -87,10 +106,6 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a } else if (strcmp(arg[iarg], "surface/divr") == 0) { surface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_divr; - } else if (utils::strmatch(arg[iarg], "^surface/n")) { - surface_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_surface_n; - col_index[i] = get_vector_index(arg[iarg]); } else if (strcmp(arg[iarg], "coordination") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_coordination; } else if (strcmp(arg[iarg], "pressure") == 0) { @@ -101,13 +116,18 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a } else if (strcmp(arg[iarg], "cv") == 0) { thermal_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; - } else if (utils::strmatch(arg[iarg], "^shift/v")) { + } else if (utils::strmatch(arg[iarg], "^surface/n/")) { + surface_flag = 1; + i += add_vector_component(arg[iarg], i, &ComputeRHEOPropertyAtom::pack_surface_n) - 1; + } else if (utils::strmatch(arg[iarg], "^shift/v/")) { shift_flag = 1; - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_shift_v; - col_index[i] = get_vector_index(arg[iarg]); - } else if (utils::strmatch(arg[iarg], "^grad/v")) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_gradv; - col_index[i] = get_tensor_index(arg[iarg]); + i += add_vector_component(arg[iarg], i, &ComputeRHEOPropertyAtom::pack_shift_v) - 1; + } else if (utils::strmatch(arg[iarg], "^grad/v/")) { + i += add_tensor_component(arg[iarg], i, &ComputeRHEOPropertyAtom::pack_gradv) - 1; + } else if (utils::strmatch(arg[iarg], "^stress/v/")) { + i += add_tensor_component(arg[iarg], i, &ComputeRHEOPropertyAtom::pack_viscous_stress) - 1; + } else if (utils::strmatch(arg[iarg], "^stress/t/")) { + i += add_tensor_component(arg[iarg], i, &ComputeRHEOPropertyAtom::pack_total_stress) - 1; } else if (strcmp(arg[iarg], "energy") == 0) { avec_index[i] = atom->avec->property_atom("esph"); if (avec_index[i] < 0) @@ -131,6 +151,7 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a if (strcmp(arg[iarg], "heatflow") == 0) thermal_flag = 1; if (strcmp(arg[iarg], "conductivity") == 0) thermal_flag = 1; } + i++; } nmax = 0; @@ -143,6 +164,7 @@ ComputeRHEOPropertyAtom::~ComputeRHEOPropertyAtom() delete[] pack_choice; delete[] avec_index; delete[] col_index; + delete[] col_t_index; memory->destroy(vector_atom); memory->destroy(array_atom); } @@ -413,6 +435,56 @@ void ComputeRHEOPropertyAtom::pack_viscosity(int n) /* ---------------------------------------------------------------------- */ +void ComputeRHEOPropertyAtom::pack_viscous_stress(int n) +{ + double **gradv = compute_grad->gradv; + double *viscosity = atom->viscosity; + int *mask = atom->mask; + int nlocal = atom->nlocal; + int index = col_index[n]; + int dim = domain->dimension; + int a = index / dim; + int b = index % dim; + int index_transpose = b * dim + a; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = viscosity[i] * (gradv[i][index] + gradv[i][index_transpose]); + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputeRHEOPropertyAtom::pack_total_stress(int n) +{ + double **gradv = compute_grad->gradv; + double *viscosity = atom->viscosity; + double *rho = atom->rho; + int *type = atom->type; + int *mask = atom->mask; + int nlocal = atom->nlocal; + int index = col_index[n]; + int dim = domain->dimension; + int a = index / dim; + int b = index % dim; + int index_transpose = b * dim + a; + double p; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + if (index == index_transpose) + p = fix_pressure->calc_pressure(rho[i], type[i]); + else + p = 0.0; + buf[n] = viscosity[i] * (gradv[i][index] + gradv[i][index_transpose]) + p; + } else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + void ComputeRHEOPropertyAtom::pack_nbond_shell(int n) { int *nbond = fix_oxidation->nbond; @@ -467,63 +539,92 @@ void ComputeRHEOPropertyAtom::pack_atom_style(int n) /* ---------------------------------------------------------------------- */ -int ComputeRHEOPropertyAtom::get_tensor_index(char* option) +int ComputeRHEOPropertyAtom::add_tensor_component(char* option, int i, FnPtrPack pack_function) { - int index; + int shift; int dim = domain->dimension; - int dim_error = 0; - - if (utils::strmatch(option, "xx$")) { - index = 0; - } else if (utils::strmatch(option, "xy$")) { - index = 1; - } else if (utils::strmatch(option, "xz$")) { - index = 2; - if (dim == 2) dim_error = 1; - } else if (utils::strmatch(option, "yx$")) { - if (dim == 2) index = 2; - else index = 3; - } else if (utils::strmatch(option, "yy$")) { - if (dim == 2) index = 3; - else index = 4; - } else if (utils::strmatch(option, "yz$")) { - index = 5; - if (dim == 2) dim_error = 1; - } else if (utils::strmatch(option, "zx$")) { - index = 6; - if (dim == 2) dim_error = 1; - } else if (utils::strmatch(option, "zy$")) { - index = 7; - if (dim == 2) dim_error = 1; - } else if (utils::strmatch(option, "zz$")) { - index = 8; - if (dim == 2) dim_error = 1; + if (((std::string) option).back() == '*') { + for (int a = 0; a < dim; a++) { + for (int b = 0; b < dim; b++) { + pack_choice[i + a * dim + b] = pack_function; + col_index[i + a * dim + b] = a * dim + b; + } + } + shift = dim * dim; } else { - error->all(FLERR, "Invalid compute rheo/property/atom property {}", option); + int index; + int dim_error = 0; + + if (utils::strmatch(option, "xx$")) { + index = 0; + } else if (utils::strmatch(option, "xy$")) { + index = 1; + } else if (utils::strmatch(option, "xz$")) { + index = 2; + if (dim == 2) dim_error = 1; + } else if (utils::strmatch(option, "yx$")) { + if (dim == 2) index = 2; + else index = 3; + } else if (utils::strmatch(option, "yy$")) { + if (dim == 2) index = 3; + else index = 4; + } else if (utils::strmatch(option, "yz$")) { + index = 5; + if (dim == 2) dim_error = 1; + } else if (utils::strmatch(option, "zx$")) { + index = 6; + if (dim == 2) dim_error = 1; + } else if (utils::strmatch(option, "zy$")) { + index = 7; + if (dim == 2) dim_error = 1; + } else if (utils::strmatch(option, "zz$")) { + index = 8; + if (dim == 2) dim_error = 1; + } else { + error->all(FLERR, "Invalid compute rheo/property/atom property {}", option); + } + + if (dim_error) + error->all(FLERR, "Invalid compute rheo/property/atom property {} in 2D", option); + + pack_choice[i] = pack_function; + col_index[i] = index; + shift = 1; } - if (dim_error) - error->all(FLERR, "Invalid compute rheo/property/atom property {} in 2D", option); - - return index; + return shift; } /* ---------------------------------------------------------------------- */ -int ComputeRHEOPropertyAtom::get_vector_index(char* option) +int ComputeRHEOPropertyAtom::add_vector_component(char* option, int i, FnPtrPack pack_function) { - int index; - if (utils::strmatch(option, "x$")) { - index = 0; - } else if (utils::strmatch(option, "y$")) { - index = 1; - } else if (utils::strmatch(option, "z$")) { - if (domain->dimension == 2) - error->all(FLERR, "Invalid compute rheo/property/atom property {} in 2D", option); - index = 2; + int shift; + int dim = domain->dimension; + if (((std::string) option).back() == '*') { + for (int a = 0; a < dim; a++) { + pack_choice[i + a] = pack_function; + col_index[i + a] = a; + } + shift = dim; } else { - error->all(FLERR, "Invalid compute rheo/property/atom property {}", option); + int index; + if (utils::strmatch(option, "x$")) { + index = 0; + } else if (utils::strmatch(option, "y$")) { + index = 1; + } else if (utils::strmatch(option, "z$")) { + if (dim == 2) + error->all(FLERR, "Invalid compute rheo/property/atom property {} in 2D", option); + index = 2; + } else { + error->all(FLERR, "Invalid compute rheo/property/atom property {}", option); + } + + pack_choice[i] = pack_function; + col_index[i] = index; + shift = 1; } - return index; + return shift; } diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index a61455f0c5..b3d247b102 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -38,7 +38,7 @@ class ComputeRHEOPropertyAtom : public Compute { int pressure_flag, thermal_flag, interface_flag; int surface_flag, shift_flag, shell_flag; int *avec_index; - int *col_index; + int *col_index, *col_t_index; double *buf; typedef void (ComputeRHEOPropertyAtom::*FnPtrPack)(int); @@ -57,11 +57,13 @@ class ComputeRHEOPropertyAtom : public Compute { void pack_gradv(int); void pack_pressure(int); void pack_viscosity(int); + void pack_viscous_stress(int); + void pack_total_stress(int); void pack_nbond_shell(int); void pack_atom_style(int); - int get_vector_index(char*); - int get_tensor_index(char*); + int add_vector_component(char*, int, FnPtrPack); + int add_tensor_component(char*, int, FnPtrPack); class FixRHEO *fix_rheo; class FixRHEOPressure *fix_pressure; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 0a52bd53bc..f206512950 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -306,13 +306,9 @@ void PairRHEO::compute(int eflag, int vflag) f[i][1] += ft[1]; f[i][2] += ft[2]; - if (evflag) { - fnorm = dot3(ft, dx) * rinv * rinv * 0.5; - ftang[0] = ft[0] * 0.5 - dx[0] * fnorm; - ftang[1] = ft[1] * 0.5 - dx[1] * fnorm; - ftang[2] = ft[2] * 0.5 - dx[2] * fnorm; - ev_tally_nt(i, j, nlocal, newton_pair, 0.0, 0.0, fnorm, ftang[0], ftang[1], ftang[2], dx[0], dx[1], dx[2]); - } + // Note the virial's definition is hazy, e.g. viscous contributions will depend on rotation + if (evflag) + ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], dx[0], dx[1], dx[2]); if (newton_pair || j < nlocal) { for (a = 0; a < dim; a ++) { @@ -331,13 +327,8 @@ void PairRHEO::compute(int eflag, int vflag) f[j][1] -= ft[1]; f[j][2] -= ft[2]; - if (evflag) { - fnorm = - dot3(ft, dx) * rinv * rinv * 0.5; - ftang[0] = ft[0] * 0.5 + dx[0] * fnorm; - ftang[1] = ft[1] * 0.5 + dx[1] * fnorm; - ftang[2] = ft[2] * 0.5 + dx[2] * fnorm; - ev_tally_nt(i, j, nlocal, newton_pair, 0.0, 0.0, fnorm, ftang[0], ftang[1], ftang[2], -dx[0], -dx[1], -dx[2]); - } + if (evflag) + ev_tally_xyz(i, j, nlocal, newton_pair, 0.0, 0.0, ft[0], ft[1], ft[2], -dx[0], -dx[1], -dx[2]); } if (compute_interface) { diff --git a/src/bond_hybrid.cpp b/src/bond_hybrid.cpp index 555ded4469..1e3e3c66f9 100644 --- a/src/bond_hybrid.cpp +++ b/src/bond_hybrid.cpp @@ -195,7 +195,7 @@ void BondHybrid::deallocate() delete[] maxbond; for (int i = 0; i < nstyles; i++) memory->destroy(bondlist[i]); delete[] bondlist; - for (i = 0; i < nstyles; i++) memory->destroy(orig_map[i]); + for (int i = 0; i < nstyles; i++) memory->destroy(orig_map[i]); delete[] orig_map; } diff --git a/src/pair.cpp b/src/pair.cpp index 896cfda29d..34c8e4978e 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -1247,108 +1247,6 @@ void Pair::ev_tally_xyz(int i, int j, int nlocal, int newton_pair, } } - -/* ---------------------------------------------------------------------- - tally eng_vdwl and virial into global or per-atom accumulators - for virial, have delx,dely,delz and fnormal and ftangential -------------------------------------------------------------------------- */ - -void Pair::ev_tally_nt(int i, int j, int nlocal, int newton_pair, - double evdwl, double ecoul, double fn, - double ftx, double fty, double ftz, - double delx, double dely, double delz) -{ - double evdwlhalf,ecoulhalf,epairhalf,v[6]; - - if (eflag_either) { - if (eflag_global) { - if (newton_pair) { - eng_vdwl += evdwl; - eng_coul += ecoul; - } else { - evdwlhalf = 0.5*evdwl; - ecoulhalf = 0.5*ecoul; - if (i < nlocal) { - eng_vdwl += evdwlhalf; - eng_coul += ecoulhalf; - } - if (j < nlocal) { - eng_vdwl += evdwlhalf; - eng_coul += ecoulhalf; - } - } - } - if (eflag_atom) { - epairhalf = 0.5 * (evdwl + ecoul); - if (newton_pair || i < nlocal) eatom[i] += epairhalf; - if (newton_pair || j < nlocal) eatom[j] += epairhalf; - } - } - - if (vflag_either) { - v[0] = delx*delx*fn; - v[1] = dely*dely*fn; - v[2] = delz*delz*fn; - v[3] = delx*dely*fn; - v[4] = delx*delz*fn; - v[5] = dely*delz*fn; - - v[0] += delx*ftx; - v[1] += dely*fty; - v[2] += delz*ftz; - v[3] += delx*fty + dely*ftx; - v[4] += delx*ftz + delz*ftx; - v[5] += dely*ftz + delz*fty; - - if (vflag_global) { - if (newton_pair) { - virial[0] += v[0]; - virial[1] += v[1]; - virial[2] += v[2]; - virial[3] += v[3]; - virial[4] += v[4]; - virial[5] += v[5]; - } else { - if (i < nlocal) { - virial[0] += 0.5*v[0]; - virial[1] += 0.5*v[1]; - virial[2] += 0.5*v[2]; - virial[3] += 0.5*v[3]; - virial[4] += 0.5*v[4]; - virial[5] += 0.5*v[5]; - } - if (j < nlocal) { - virial[0] += 0.5*v[0]; - virial[1] += 0.5*v[1]; - virial[2] += 0.5*v[2]; - virial[3] += 0.5*v[3]; - virial[4] += 0.5*v[4]; - virial[5] += 0.5*v[5]; - } - } - } - - if (vflag_atom) { - if (newton_pair || i < nlocal) { - vatom[i][0] += 0.5*v[0]; - vatom[i][1] += 0.5*v[1]; - vatom[i][2] += 0.5*v[2]; - vatom[i][3] += 0.5*v[3]; - vatom[i][4] += 0.5*v[4]; - vatom[i][5] += 0.5*v[5]; - } - if (newton_pair || j < nlocal) { - vatom[j][0] += 0.5*v[0]; - vatom[j][1] += 0.5*v[1]; - vatom[j][2] += 0.5*v[2]; - vatom[j][3] += 0.5*v[3]; - vatom[j][4] += 0.5*v[4]; - vatom[j][5] += 0.5*v[5]; - } - } - } -} - /* ---------------------------------------------------------------------- tally eng_vdwl and virial into global or per-atom accumulators for virial, have delx,dely,delz and fx,fy,fz diff --git a/src/pair.h b/src/pair.h index 153250260a..d36b48f340 100644 --- a/src/pair.h +++ b/src/pair.h @@ -297,8 +297,6 @@ class Pair : protected Pointers { void ev_tally_tip4p(int, int *, double *, double, double); void ev_tally_xyz(int, int, int, int, double, double, double, double, double, double, double, double); - void ev_tally_nt(int, int, int, int, double, double, double, double, double, double, double, - double, double); void v_tally2(int, int, double, double *); void v_tally_tensor(int, int, int, int, double, double, double, double, double, double); void virial_fdotr_compute(); From 1326592f237b86730b9988f7ba1dde5733979c12 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 28 Jun 2024 17:07:23 -0600 Subject: [PATCH 090/104] Proofing RHEO package --- doc/src/Commands_fix.rst | 1 + doc/src/Howto_rheo.rst | 38 +- doc/src/atom_style.rst | 2 +- doc/src/bond_rheo_shell.rst | 47 +- doc/src/bond_style.rst | 1 + doc/src/compute_rheo_property_atom.rst | 43 +- doc/src/fix.rst | 6 +- doc/src/fix_add_heat.rst | 36 +- doc/src/fix_rheo.rst | 74 +- doc/src/fix_rheo_oxidation.rst | 21 +- doc/src/fix_rheo_pressure.rst | 14 +- doc/src/fix_rheo_thermal.rst | 20 +- doc/src/fix_rheo_viscosity.rst | 12 +- doc/src/pair_rheo.rst | 36 +- doc/src/pair_rheo_solid.rst | 6 +- doc/src/pair_style.rst | 2 + examples/rheo/balloon/in.rheo.balloon | 2 +- .../rheo/balloon/log.17Apr2024.balloon.g++.4 | 382 ++++ .../rheo/dam-break/log.17Apr2024.dam.g++.4 | 1694 +++++++++++++++++ examples/rheo/ice-cubes/in.rheo.ice.cubes | 3 +- .../rheo/ice-cubes/log.17Apr2024.ice.g++.4 | 379 ++++ examples/rheo/oxidation/in.rheo.oxidation | 3 +- .../oxidation/log.17Apr2024.oxidation.g++.4 | 488 +++++ examples/rheo/poiseuille/in.rheo.poiseuille | 2 +- .../poiseuille/log.17Apr2024.poiseuille.g++.4 | 288 +++ .../log.17Apr2024.taylor.green.g++.4 | 224 +++ src/BPM/bond_bpm_spring.cpp | 2 - src/BPM/compute_nbond_atom.cpp | 2 +- src/BPM/fix_update_special_bonds.cpp | 2 +- src/RHEO/bond_rheo_shell.cpp | 13 +- src/RHEO/compute_rheo_kernel.cpp | 184 +- src/RHEO/compute_rheo_kernel.h | 2 +- src/RHEO/compute_rheo_surface.cpp | 4 +- src/RHEO/fix_rheo.cpp | 47 +- src/RHEO/fix_rheo.h | 2 +- src/RHEO/fix_rheo_oxidation.cpp | 6 +- src/RHEO/fix_rheo_thermal.cpp | 23 +- src/RHEO/fix_rheo_viscosity.cpp | 1 + src/RHEO/pair_rheo.cpp | 36 +- src/RHEO/pair_rheo.h | 4 +- 40 files changed, 3797 insertions(+), 355 deletions(-) create mode 100644 examples/rheo/balloon/log.17Apr2024.balloon.g++.4 create mode 100644 examples/rheo/dam-break/log.17Apr2024.dam.g++.4 create mode 100644 examples/rheo/ice-cubes/log.17Apr2024.ice.g++.4 create mode 100644 examples/rheo/oxidation/log.17Apr2024.oxidation.g++.4 create mode 100644 examples/rheo/poiseuille/log.17Apr2024.poiseuille.g++.4 create mode 100644 examples/rheo/taylor-green/log.17Apr2024.taylor.green.g++.4 diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index f2771f0c50..4350a98b31 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -28,6 +28,7 @@ OPT. * :doc:`adapt ` * :doc:`adapt/fep ` * :doc:`addforce ` + * :doc:`add/heat ` * :doc:`addtorque ` * :doc:`alchemy ` * :doc:`amoeba/bitorsion ` diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index 9d70bf074f..4c0f069d92 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -2,8 +2,9 @@ Reproducing hydrodynamics and elastic objects (RHEO) ==================================================== The RHEO package is a hybrid implementation of smoothed particle -hydrodynamics (SPH) for fluid flow, coupled to the :doc:`BPM package ` to model -solid elements. RHEO combines these methods to enable mesh-free modeling of multiphase material systems. The SPH solver supports many advanced options +hydrodynamics (SPH) for fluid flow, coupled to the :doc:`BPM package ` +to model solid elements. RHEO combines these methods to enable mesh-free modeling +of multiphase material systems. The SPH solver supports many advanced options including reproducing kernels, particle shifting, free surface identification, and solid surface reconstruction. To model fluid-solid systems, the status of particles can dynamically change between a fluid and solid state, e.g. during @@ -29,9 +30,10 @@ of reproducing kernels). In conjunction to fix rheo, one must specify an instance of :doc:`fix rheo/pressure ` and :doc:`fix rheo/viscosity ` to define a pressure equation of state and viscosity model, respectively. Optionally, one can model -a heat equation with :doc:`fix rheo/thermal`, which also allows the user -to specify equations for a particle's thermal conductivity, specific heat, -latent heat, and melting temperature. The ordering of these fixes in an an input script matters. Fix rheo must be defined prior to all +a heat equation with :doc:`fix rheo/thermal `, which also +allows the user to specify equations for a particle's thermal conductivity, +specific heat, latent heat, and melting temperature. The ordering of these +fixes in an an input script matters. Fix rheo must be defined prior to all other RHEO fixes. Typically, RHEO requires atom style rheo. In addition to typical atom @@ -45,9 +47,9 @@ affect particles. Instead, one should use the *sph/e* attribute. The status variable uses bitmasking to track various properties of a particle such as its current state of matter (fluid or solid) and its location relative to a surface. Some of these properties (and others) can be accessed using -:doc:`compute rheo/property/atom `. The *status* attribute -in :doc:`the set command ` only allows control over the first bit which sets -the state of matter, 0 is fluid and 1 is solid. +:doc:`compute rheo/property/atom `. The *status* +attribute in :doc:`the set command ` only allows control over the first bit +which sets the state of matter, 0 is fluid and 1 is solid. Fluid interactions, including pressure forces, viscous forces, and heat exchange, are calculated using :doc:`pair rheo `. Unlike typical pair styles, @@ -59,18 +61,18 @@ hydrodynamic forces are only calculated if a fluid particle is involved. To model elastic objects, there are currently two mechanisms in RHEO, one designed for bulk solid bodies and the other for thin shells. Both mechanisms rely on -introducing bonded forces between particles and therefore require a hybrid of atom style bond and rheo -(or rheo/thermal). +introducing bonded forces between particles and therefore require a hybrid of atom +style bond and rheo (or rheo/thermal). To create an elastic solid body, one has to (a) change the status of constituent particles to solid (e.g. with the :doc:`set ` command), (b) create bpm bonds between the particles (see the :doc:`bpm howto ` page for more details), and (c) use :doc:`pair rheo/solid ` to apply repulsive contact forces between distinct solid bodies. Akin to pair rheo, -looks at a particles fluid/solid status to determine whether to apply forces. -However, unlike pair rheo, pair rheo/solid does obey special bond settings such -that contact forces do not have to be calculated between two bonded solid particles -in the same elastic body. +pair rheo/solid considers a particles fluid/solid phase to determine whether to +apply forces. However, unlike pair rheo, pair rheo/solid does obey special bond +settings such that contact forces do not have to be calculated between two bonded +solid particles in the same elastic body. In systems with thermal evolution, fix rheo/thermal can optionally set a melting/solidification temperature allowing particles to dynamically swap their @@ -79,9 +81,9 @@ critical temperature, respectively. Using the *react* option, one can specify a bond length and a bond type. Then, when solidifying, particles will search their local neighbors and automatically create bonds with any neighboring solid particles in range. For BPM bond styles, bonds will then use the immediate position of the two -particles to calculate a reference state. When melting, particles will then delete -any bonds of the specified type when reverting to a fluid state. Special bonds are -updated as bonds are created/broken. +particles to calculate a reference state. When melting, particles will delete any +bonds of the specified type when reverting to a fluid state. Special bonds are updated +as bonds are created/broken. The other option for elastic objects is an elastic shell that is nominally much thinner than a particle diameter, e.g. a oxide skin which gradually forms over time @@ -106,7 +108,7 @@ criteria for creating/deleting a bond or altering force calculations). .. _howto_rheo_palermo: -**(Palermo)** Palermo, Clemmer, Wolf, O'Connor, in preparation. +**(Palermo)** Palermo, Wolf, Clemmer, O'Connor, in preparation. .. _howto_rheo_clemmer: diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index 0a3cb642be..2e6a6e1cbe 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -194,7 +194,7 @@ the Additional Information section below. - :ref:`RHEO ` - solid and fluid RHEO particles * - *rheo/thermal* - - *atomic* + rho, status, temperature + - *atomic* + rho, status, energy, temperature - :ref:`RHEO ` - RHEO particles with temperature * - *sph* diff --git a/doc/src/bond_rheo_shell.rst b/doc/src/bond_rheo_shell.rst index 3b5cfa6a49..439f88ec8e 100644 --- a/doc/src/bond_rheo_shell.rst +++ b/doc/src/bond_rheo_shell.rst @@ -44,12 +44,11 @@ The *rheo/shell* bond style is designed to work with :doc:`fix rheo/oxidation ` which creates candidate bonds between eligible surface or near-surface particles. When a bond is first created, it computes no forces and starts a timer. Forces are -not computed until the timer reaches the specified bond formation time -and the bond is fully enabled. If the two particles move outside of the -maximum bond distance or move into the bulk before the timer reaches -the formation time, the bond automatically deletes itself. Not that -this deletion does not generate any broken bond data saved to a -*store/local* fix. +not computed until the timer reaches the specified bond formation time, +*t/form*, and the bond is enabled and applies forces. If the two particles +move outside of the maximum bond distance or move into the bulk before +the timer reaches *t/form*, the bond automatically deletes itself. This +deletion is not recorded as a broken bond in the optional *store/local* fix. Before bonds are enabled, they are still treated as regular bonds by all other parts of LAMMPS. This means they are written to data files @@ -60,17 +59,17 @@ To only count enabled bonds, use the *nbond/shell* attribute in When enabled, the bond then computes forces based on deviations from the initial reference state of the two atoms much like a BPM style bond (as further discussed in the :doc:`BPM howto page `). -The reference state is stored by each bond when it is first enabled -the setup of a run. Data is then preserved across run commands and is -written to :doc:`binary restart files ` such that restarting -the system will not reset the reference state of a bond or the timer. +The reference state is stored by each bond when it is first enabled. +Data is then preserved across run commands and is written to +:doc:`binary restart files ` such that restarting the system +will not reset the reference state of a bond or the timer. This bond style is based on a model described in -:ref:`(Clemmer) `. The force has a magnitude of +:ref:`(Clemmer) `. The force has a magnitude of .. math:: - F = 2 k (r - r_0) + \frac{2 * k}{r_0^2 \epsilon_c^2} (r - r_0)^3 + F = 2 k (r - r_0) + \frac{2 k}{r_0^2 \epsilon_c^2} (r - r_0)^3 where :math:`k` is a stiffness, :math:`r` is the current distance and :math:`r_0` is the initial distance between the two particles, and @@ -78,17 +77,15 @@ and :math:`r_0` is the initial distance between the two particles, and is done by setting the bond type to 0 such that forces are no longer computed. -An additional damping force is applied to the bonded -particles. This forces is proportional to the difference in the -normal velocity of particles using a similar construction as -dissipative particle dynamics :ref:`(Groot) `: +A damping force proportional to the difference in the normal velocity +of particles is also applied to bonded particles: .. math:: F_D = - \gamma w (\hat{r} \bullet \vec{v}) where :math:`\gamma` is the damping strength, :math:`\hat{r}` is the -radial normal vector, and :math:`\vec{v}` is the velocity difference +displacement normal vector, and :math:`\vec{v}` is the velocity difference between the two particles. The following coefficients must be defined for each bond type via the @@ -103,7 +100,7 @@ the data file or restart files read by the :doc:`read_data Unlike other BPM-style bonds, this bond style does not update special bond settings when bonds are created or deleted. This bond style also does not enforce specific :doc:`special_bonds ` settings. -This behavior is purposeful such :doc:`RHEO pair forces ` +This behavior is purposeful such :doc:`RHEO pair ` forces and heat flows are still calculated. If the *store/local* keyword is used, an internal fix will track bonds that @@ -162,10 +159,10 @@ the specified attribute. The single() function of this bond style returns 0.0 for the energy of a bonded interaction, since energy is not conserved in these -dissipative potentials. The single() function also calculates an -extra bond quantity, the initial distance :math:`r_0`. This -extra quantity can be accessed by the -:doc:`compute bond/local ` command as *b1*\ . +dissipative potentials. The single() function also calculates two +extra bond quantities, the initial distance :math:`r_0` and a time. +These extra quantities can be accessed by the +:doc:`compute bond/local ` command as *b1* and *b2*\ . Restrictions """""""""""" @@ -186,10 +183,6 @@ NA ---------- -.. _howto_rheo_clemmer: +.. _rheo_clemmer: **(Clemmer)** Clemmer, Pierce, O'Connor, Nevins, Jones, Lechman, Tencer, Appl. Math. Model., 130, 310-326 (2024). - -.. _Groot4: - -**(Groot)** Groot and Warren, J Chem Phys, 107, 4423-35 (1997). diff --git a/doc/src/bond_style.rst b/doc/src/bond_style.rst index 95f463e695..da56fe7fbb 100644 --- a/doc/src/bond_style.rst +++ b/doc/src/bond_style.rst @@ -105,6 +105,7 @@ accelerated styles exist. * :doc:`oxdna2/fene ` - same as oxdna but used with different pair styles * :doc:`oxrna2/fene ` - modified FENE bond suitable for RNA modeling * :doc:`quartic ` - breakable quartic bond +* :doc:`rheo/shell ` - shell bond for oxidation modeling in RHEO * :doc:`special ` - enable special bond exclusions for 1-5 pairs and beyond * :doc:`table ` - tabulated by bond length diff --git a/doc/src/compute_rheo_property_atom.rst b/doc/src/compute_rheo_property_atom.rst index 861fd04688..f34b2225f5 100644 --- a/doc/src/compute_rheo_property_atom.rst +++ b/doc/src/compute_rheo_property_atom.rst @@ -1,7 +1,7 @@ .. index:: compute rheo/property/atom compute rheo/property/atom command -============================= +================================== Syntax """""" @@ -17,11 +17,10 @@ Syntax .. parsed-literal:: possible attributes = phase, surface, surface/r, - surface/divr, surface/n/:math:`\alpha`, coordination, - shift/v/:math:`\alpha`, energy, temperature, heatflow, + surface/divr, surface/n/a, coordination, + shift/v/a, energy, temperature, heatflow, conductivity, cv, viscosity, pressure, rho, - grad/v/:math:`\alpha \beta`, stress/v/:math:`\alpha \beta`, - stress/t/:math:`\alpha \beta`, nbond/shell + grad/v/ab, stress/v/ab, stress/t/ab, nbond/shell .. parsed-literal:: @@ -29,9 +28,9 @@ Syntax *surface* = atom surface status *surface/r* = atom distance from the surface *surface/divr* = divergence of position at atom position - *surface/n/:math:`\alpha`* = surface normal vector + *surface/n/a* = a-component of surface normal vector *coordination* = coordination number - *shift/v/:math:`\alpha`* = atom shifting velocity + *shift/v/a* = a-component of atom shifting velocity *energy* = atom energy *temperature* = atom temperature *heatflow* = atom heat flow @@ -40,9 +39,9 @@ Syntax *viscosity* = atom viscosity *pressure* = atom pressure *rho* = atom density - *grad/v/:math:`\alpha \beta`* = atom velocity gradient - *stress/v/:math:`\alpha \beta`* = atom viscous stress - *stress/t/:math:`\alpha \beta`* = atom total stress (pressure and viscous) + *grad/v/ab* = ab-component of atom velocity gradient tensor + *stress/v/ab* = ab-component of atom viscous stress tensor + *stress/t/ab* = ab-component of atom total stress tensor (pressure and viscous) *nbond/shell* = number of oxide bonds Examples @@ -68,12 +67,12 @@ computes as inputs. See for example, the :doc:`fix ave/chunk `, and :doc:`atom-style variable ` commands. -For vector attributes, e.g. *shift/v/:math:`\alpha`*, one must specify +For vector attributes, e.g. *shift/v/*:math:`\alpha`, one must specify :math:`\alpha` as the *x*, *y*, or *z* component, e.g. *shift/v/x*. Alternatively, a wild card \* will include all components, *x* and *y* in 2D or *x*, *y*, and *z* in 3D. -For tensor attributes, e.g. *grad/v/:math:`\alpha \beta`*, one must specify +For tensor attributes, e.g. *grad/v/*:math:`\alpha \beta`, one must specify both :math:`\alpha` and :math:`\beta` as *x*, *y*, or *z*, e.g. *grad/v/xy*. Alternatively, a wild card \* will include all components. In 2D, this includes *xx*, *xy*, *yx*, and *yy*. In 3D, this includes *xx*, *xy*, *xz*, @@ -93,11 +92,11 @@ the *interface/reconstruct* option of :doc:`fix rheo `. Bulk particles have a value of 0, surface particles have a value of 1, and splash particles have a value of 2. The *surface/r* property is the distance from the surface, up to the kernel cutoff length. Surface particles -have a value of 0. The *surface/n* properties are the components of the -surface normal vector. +have a value of 0. The *surface/n/*:math:`\alpha` properties are the +components of the surface normal vector. -The *shift/v/:math:`\alpha`* properties are the components of the shifting velocity -produced by the *shift* option of :doc:`fix rheo `. +The *shift/v/*:math:`\alpha` properties are the components of the shifting +velocity produced by the *shift* option of :doc:`fix rheo `. The *nbond/shell* property is the number of shell bonds that have been activated from :doc:`bond style rheo/shell `. @@ -110,13 +109,13 @@ Output info """"""""""" This compute calculates a per-atom vector or per-atom array depending -on the number of input values. If a single input is specified, a -per-atom vector is produced. If two or more inputs are specified, a +on the number of input values. Generally, if a single input is specified, +a per-atom vector is produced. If two or more inputs are specified, a per-atom array is produced where the number of columns = the number of -inputs. If a wild card \* is used for a vector or tensor, then the number -of inputs is considered to be incremented by the dimensiod or dimension -squared, respectively. The vector or array can be accessed by any command -that uses per-atom values from a compute as input. See the +inputs. However, if a wild card \* is used for a vector or tensor, then +the number of inputs is considered to be incremented by the dimension or +the dimension squared, respectively. The vector or array can be accessed +by any command that uses per-atom values from a compute as input. See the :doc:`Howto output ` page for an overview of LAMMPS output options. diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 42f7bcff6b..4919c226fd 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -193,6 +193,7 @@ accelerated styles exist. * :doc:`adapt ` - change a simulation parameter over time * :doc:`adapt/fep ` - enhanced version of fix adapt * :doc:`addforce ` - add a force to each atom +* :doc:`add/heat ` - add a heat flux to each atom * :doc:`addtorque ` - add a torque to a group of atoms * :doc:`alchemy ` - perform an "alchemical transformation" between two partitions * :doc:`amoeba/bitorsion ` - torsion/torsion terms in AMOEBA force field @@ -371,8 +372,9 @@ accelerated styles exist. * :doc:`restrain ` - constrain a bond, angle, dihedral * :doc:`rheo ` - integrator for the RHEO package * :doc:`rheo/thermal ` - thermal integrator for the RHEO package -* :doc:`rheo/pressure ` - pressure derivation for the RHEO package -* :doc:`rheo/viscosity ` - viscosity derivation for the RHEO package +* :doc:`rheo/oxidation ` - create oxidation bonds for the RHEO package +* :doc:`rheo/pressure ` - pressure calculation for the RHEO package +* :doc:`rheo/viscosity ` - viscosity calculation for the RHEO package * :doc:`rhok ` - add bias potential for long-range ordered systems * :doc:`rigid ` - constrain one or more clusters of atoms to move as a rigid body with NVE integration * :doc:`rigid/meso ` - constrain clusters of mesoscopic SPH/SDPD particles to move as a rigid body diff --git a/doc/src/fix_add_heat.rst b/doc/src/fix_add_heat.rst index 2a2d855927..5b67bd4e15 100644 --- a/doc/src/fix_add_heat.rst +++ b/doc/src/fix_add_heat.rst @@ -16,14 +16,14 @@ Syntax .. parsed-literal:: - *constant* args = rate - rate = rate of heat flow (energy/time units) - *linear* args = t_target k - t_target = target temperature (temperature units) - k = prefactor (energy/(time*temperature) units) - *quartic* args = t_target k - t_target = target temperature (temperature units) - k = prefactor (energy/(time*temperature^4) units) + *constant* args = *rate* + *rate* = rate of heat flow (energy/time units) + *linear* args = :math:`T_{target}` *k* + :math:`T_{target}` = target temperature (temperature units) + *k* = prefactor (energy/(time*temperature) units) + *quartic* args = :math:`T_{target}` *k* + :math:`T_{target}` = target temperature (temperature units) + *k* = prefactor (energy/(time*temperature^4) units) * zero or more keyword/value pairs may be appended to args * keyword = *overwrite* @@ -45,7 +45,9 @@ Examples Description """"""""""" -This fix adds heat to particles every timestep. +This fix adds heat to particles with the temperature attribute every timestep. +Note that this is an internal temperature of a particle intended for use with +non-atomistic models like the discrete element method. For the *constant* style, heat is added at the specified rate. For the *linear* style, heat is added at a rate of :math:`k (T_{target} - T)` where :math:`k` is the @@ -62,22 +64,22 @@ determine the rate of heat added. Equal-style variables can specify formulas with various mathematical functions and include :doc:`thermo_style ` command -keywords for the simulation box parameters, time step, and elapsed time. -Thus, it is easy to specify time-dependent heating. +keywords for the simulation box parameters, time step, and elapsed time +to specify time-dependent heating. Atom-style variables can specify the same formulas as equal-style variables but can also include per-atom values, such as atom -coordinates. Thus, it is easy to specify a spatially-dependent heating -field with optional time-dependence as well. +coordinates to specify spatially-dependent heating. -If the *overwrite* keyword is set to *yes*, this fix will effectively set -the total heat flow on a particle, overwriting contributions from pair -styles or other fixes. +If the *overwrite* keyword is set to *yes*, this fix will set the total +heat flow on a particle every timestep, overwriting contributions from pair +styles or other fixes. If *overwrite* is *no*, this fix will add heat on +top of other contributions. ---------- Restart, fix_modify, output, run start/stop, minimize info -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options are relevant to this fix. diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index 978691db41..d69b52d751 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -1,7 +1,7 @@ .. index:: fix rheo fix rheo command -=============== +================ Syntax """""" @@ -38,8 +38,8 @@ Examples .. code-block:: LAMMPS - fix 1 all rheo 1.0 quintic thermal density 0.1 speed/sound 10.0 - fix 1 all rheo 1.0 RK1 shift surface/detection coordination 40 + fix 1 all rheo 3.0 quintic 0 thermal density 0.1 0.1 speed/sound 10.0 1.0 + fix 1 all rheo 3.0 RK1 10 shift surface/detection coordination 40 Description """"""""""" @@ -48,14 +48,15 @@ Description Perform time integration for RHEO particles, updating positions, velocities, and densities. For a detailed breakdown of the integration timestep and -numerical details, see :ref:`(Palermo) `. For an +numerical details, see :ref:`(Palermo) `. For an overview of other features available in the RHEO package, see :doc:`the RHEO howto `. The type of kernel is specified using *kstyle* and the cutoff is *cut*. Four kernels are currently available. The *quintic* kernel is a standard quintic spline function commonly used in SPH. The other options, *RK0*, *RK1*, and -*RK2*, are zeroth, first, and second order reproducing. To generate a reproducing kernel, a particle must have sufficient neighbors inside the +*RK2*, are zeroth, first, and second order reproducing. To generate a +reproducing kernel, a particle must have sufficient neighbors inside the kernel cutoff distance (a coordination number) to accurately calculate moments. This threshold is set by *zmin*. If reproducing kernels are requested but a particle has fewer neighbors, then it will revert to a @@ -81,28 +82,27 @@ surfaces. A modified form of Fickian particle shifting can be enabled with the *shift* keyword. This effectively shifts particle positions to generate a -more uniform spatial distribution. Shifting currently does consider the +more uniform spatial distribution. Shifting currently does not consider the type of a particle and therefore may be inappropriate in systems consisting -of multiple materials. +of multiple fluid phases. In systems with free surfaces, the *surface/detection* keyword can be used to classify the location of particles as being within the bulk fluid, on a free surface, or isolated from other particles in a splash or droplet. -Shifting is then disabled in the direction away from the free surface to -prevent it from diffusing particles away from the bulk fluid. Surface -detection can also be used to control surface-nucleated effects like -oxidation when used in combination with -:doc:`fix rheo/oxidation `. Surface detection is not +Shifting is then disabled in the normal direction away from the free surface +to prevent particles from difusing away. Surface detection can also be used +to control surface-nucleated effects like oxidation when used in combination +with :doc:`fix rheo/oxidation `. Surface detection is not performed on solid bodies. The *surface/detection* keyword takes three arguments: *sdstyle*, *limit*, -and *limi/splash*. The first, *sdstyle*, specifies whether surface particles +and *limit/splash*. The first, *sdstyle*, specifies whether surface particles are identified using a coordination number (*coordination*) or the divergence of the local particle positions (*divergence*). The threshold value for a surface particle for either of these criteria is set by the numerical value of *limit*. Additionally, if a particle's coordination number is too low, i.e. if it has separated off from the bulk in a droplet, it is not possible -to define surfaces and a particle is classified as a splash. The coordination +to define surfaces and the particle is classified as a splash. The coordination threshold for this classification is set by the numerical value of *limit/splash*. @@ -112,23 +112,23 @@ a kernel summation of the masses of neighboring particles by specifying the *rho keyword. The *self/mass* keyword modifies the behavior of the density summation in *rho/sum*. -Typically, the density :math:`\rho` of a particle is calculated as the sum +Typically, the density :math:`\rho` of a particle is calculated as the sum over neighbors .. math:: - \rho_i = \Sum_{j} W_{ij} M_j + \rho_i = \sum_{j} W_{ij} M_j -where the summation is over neighbors, :math:`W_{ij}` is the kernel, and :math:`M_j` -is the mass of particle :math:`j`. The *self/mass* keyword augments this expression -by replacing :math:`M_j` with :math:`M_i`. This may be useful in simulations of -multiple fluid phases with large differences in density, :ref:`(Hu) `. +where :math:`W_{ij}` is the kernel, and :math:`M_j` is the mass of particle :math:`j`. +The *self/mass* keyword augments this expression by replacing :math:`M_j` with +:math:`M_i`. This may be useful in simulations of multiple fluid phases with large +differences in density, :ref:`(Hu) `. -The *density* keyword is used to specify the equilbrium density of each of the N -particle types. It must be followed by N numerical values specifying each -type's equilibrium density *rho0*. +The *density* keyword is used to specify the equilibrium density of each of the N +particle types. It must be followed by N numerical values specifying each type's +equilibrium density *rho0*. The *speed/sound* keyword is used to specify the speed of sound of each of the -N particle types. It must be followed by N numerical values specifying each -type's speed of sound *cs*. +N particle types. It must be followed by N numerical values specifying each type's +speed of sound *cs*. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -144,18 +144,16 @@ the :doc:`run ` command. This fix is not invoked during Restrictions """""""""""" -This fix must be used with atom style rheo or rheo/thermal. -This fix must be used in conjuction with -:doc:`fix rheo/pressure `. and -:doc:`fix rheo/viscosity `, If the *thermal* -setting is used, there must also be an instance of -:doc:`fix rheo/thermal `. The fix group must be -set to all. Only one instance of fix rheo may be defined and it -must be defined prior to all other RHEO fixes. +This fix must be used with atom style rheo or rheo/thermal. This fix must +be used in conjuction with :doc:`fix rheo/pressure `. +and :doc:`fix rheo/viscosity `. If the *thermal* setting +is used, there must also be an instance of +:doc:`fix rheo/thermal `. The fix group must be set to all. +Only one instance of fix rheo may be defined and it must be defined prior +to all other RHEO fixes in the input script. -This fix is part of the RHEO package. It is only enabled if -LAMMPS was built with that package. See the -:doc:`Build package ` page for more info. +This fix is part of the RHEO package. It is only enabled if LAMMPS was built +with that package. See the :doc:`Build package ` page for more info. Related commands """""""""""""""" @@ -173,9 +171,9 @@ Default ---------- -.. _howto_rheo_palermo: +.. _rheo_palermo: -**(Palermo)** Palermo, Clemmer, Wolf, O'Connor, in preparation. +**(Palermo)** Palermo, Wolf, Clemmer, O'Connor, in preparation. .. _fix_rheo_hu: diff --git a/doc/src/fix_rheo_oxidation.rst b/doc/src/fix_rheo_oxidation.rst index 3043291c60..ba3ead3f1f 100644 --- a/doc/src/fix_rheo_oxidation.rst +++ b/doc/src/fix_rheo_oxidation.rst @@ -36,21 +36,21 @@ for use with bond style :doc:`bond rheo/shell `. Every timestep, particles check neighbors within a distance of *cut*. This distance must be smaller than the kernel length defined in :doc:`fix rheo `. Bonds of type *btype* are created between -pairs of particles that satisfy one of two conditions. First, if both -particles are on the fluid surface, or within a distance of *rsurf* -from the surface. Secondly, if one particle is on the fluid surface -and the other bond is solid. This process is further described in -:ref:`(Clemmer) `. +a fluid particle and either a fluid or solid neighbor. The fluid particles +must also be on the fluid surface, or within a distance of *rsurf* from +the surface. This process is further described in +:ref:`(Clemmer) `. If used in conjunction with solid bodies, such as those generated by the *react* option of :doc:`fix rheo/thermal `, -it is recommended that one uses a :doc:`hybrid bond style ` +it is recommended to use a :doc:`hybrid bond style ` with different bond types for solid and oxide bonds. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +No information about this fix is written to :doc:`binary restart files `. +None of the :doc:`fix_modify ` options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various :doc:`output commands `. No parameter of this fix can be used with the *start/stop* keywords of @@ -59,11 +59,12 @@ the :doc:`run ` command. This fix is not invoked during :doc:`energy minim Restrictions """""""""""" -This fix must be used with an bond style :doc:`rheo/shell ` +This fix must be used with the bond style :doc:`rheo/shell ` and :doc:`fix rheo ` with surface detection enabled. This fix is part of the RHEO 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 """""""""""""""" @@ -79,6 +80,6 @@ none ---------- -.. _howto_rheo_clemmer: +.. _howto_rheo_clemmer2: **(Clemmer)** Clemmer, Pierce, O'Connor, Nevins, Jones, Lechman, Tencer, Appl. Math. Model., 130, 310-326 (2024). diff --git a/doc/src/fix_rheo_pressure.rst b/doc/src/fix_rheo_pressure.rst index f2a994da88..e01aebf90f 100644 --- a/doc/src/fix_rheo_pressure.rst +++ b/doc/src/fix_rheo_pressure.rst @@ -1,7 +1,7 @@ .. index:: fix rheo/pressure fix rheo/pressure command -=============== +========================= Syntax """""" @@ -20,7 +20,7 @@ Syntax *linear* args = none *taitwater* args = none - *cubic* args = cubic term prefactor :math:`A_3` (pressure/density\^2) + *cubic* args = cubic prefactor :math:`A_3` (pressure/density\^2) Examples """""""" @@ -36,8 +36,8 @@ Description .. versionadded:: TBD This fix defines a pressure equation of state for RHEO particles. One can -define different equations of state for different atom types, but an -equation must be specified for every atom type. +define different equations of state for different atom types. An equation +must be specified for every atom type. One first defines the atom *types*. A wild-card asterisk can be used in place of or in conjunction with the *types* argument to set the coefficients for @@ -74,7 +74,8 @@ Style *taitwater* is Tait's equation of state: Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +No information about this fix is written to :doc:`binary restart files `. +None of the :doc:`fix_modify ` options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various :doc:`output commands `. No parameter of this fix can be used with the *start/stop* keywords of @@ -89,7 +90,8 @@ conjuction with :doc:`fix rheo `. The fix group must be set to all. Only one instance of fix rheo/pressure can be defined. This fix is part of the RHEO 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 """""""""""""""" diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst index 1ceb1259c0..e116325091 100644 --- a/doc/src/fix_rheo_thermal.rst +++ b/doc/src/fix_rheo_thermal.rst @@ -1,7 +1,7 @@ .. index:: fix rheo/thermal fix rheo/thermal command -=============== +======================== Syntax """""" @@ -50,16 +50,16 @@ Description .. versionadded:: TBD -This fix performs time integration of temperature evolution for atom style -rheo/thermal. In addition, it defines multiple thermal properties of -particles and handles melting/solidification, if applicable. For more details -on phase transitions in RHEO, see :doc:`the RHEO howto `. +This fix performs time integration of temperature for atom style rheo/thermal. +In addition, it defines multiple thermal properties of particles and handles +melting/solidification, if applicable. For more details on phase transitions +in RHEO, see :doc:`the RHEO howto `. Note that the temperature of a particle is always derived from the energy. This implies the *temperature* attribute of :doc:`the set command ` does not affect particles. Instead, one should use the *sph/e* attribute. -For each atom type, one can define attributes for the *conductivity*, +For each atom type, one can define expressions for the *conductivity*, *specific/heat*, *latent/heat*, and critical temperature (*Tfreeze*). The conductivity and specific heat must be defined for all atom types. The latent heat and critical temperature are optional. However, a @@ -88,13 +88,14 @@ types that have a defined value of *Tfreeze*. When a fluid particle's temperature drops below *Tfreeze*, bonds of type *btype* are created between nearby solid particles within a distance of *cut*. The particle's status also swaps to a solid state. When a solid particle's temperature rises above -*Tfreeze*, all bonds of type *btype* are broken and the particle's tatus swaps +*Tfreeze*, all bonds of type *btype* are broken and the particle's status swaps to a fluid state. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options +No information about this fix is written to :doc:`binary restart files `. +None of the :doc:`fix_modify ` options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various :doc:`output commands `. No parameter of this fix can be used with the *start/stop* keywords of @@ -110,7 +111,8 @@ must be used in conjuction with :doc:`fix rheo ` with the instance of fix rheo/pressure can be defined. This fix is part of the RHEO 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 """""""""""""""" diff --git a/doc/src/fix_rheo_viscosity.rst b/doc/src/fix_rheo_viscosity.rst index 8175178787..912de584c2 100644 --- a/doc/src/fix_rheo_viscosity.rst +++ b/doc/src/fix_rheo_viscosity.rst @@ -1,7 +1,7 @@ .. index:: fix rheo/viscosity fix rheo/viscosity command -=============== +========================== Syntax """""" @@ -63,16 +63,16 @@ for the stress :math:`\tau` \tau = \left(\frac{\tau_0}{\dot{\gamma}} + K \dot{\gamma}^{n - 1}\right) \dot{\gamma}, \tau \ge \tau_0 -where :math:`\dot{\gamma}` is the strain rate and :math:`tau_0` is the critical +where :math:`\dot{\gamma}` is the strain rate and :math:`\tau_0` is the critical yield stress, below which :math:`\dot{\gamma} = 0.0`. To avoid divergences, this expression is regularized by defining a critical strain rate *gd0*. If the local strain rate on a particle falls below this limit, a constant viscosity of *eta* is assigned. This implies a value of .. math:: - \tau_0 = \eta * \dot{\gamma}_0 - K \dot{\gamma}_0^N + \tau_0 = \eta \dot{\gamma}_0 - K \dot{\gamma}_0^N -as further discussed in :ref:`(Palermo) `. +as further discussed in :ref:`(Palermo) `. Restart, fix_modify, output, run start/stop, minimize info @@ -112,6 +112,6 @@ none ---------- -.. _howto_rheo_palermo: +.. _rheo_palermo2: -**(Palermo)** Palermo, Clemmer, Wolf, O'Connor, in preparation. +**(Palermo)** Palermo, Wolf, Clemmer, O'Connor, in preparation. diff --git a/doc/src/pair_rheo.rst b/doc/src/pair_rheo.rst index a530444f36..993ec3cee3 100644 --- a/doc/src/pair_rheo.rst +++ b/doc/src/pair_rheo.rst @@ -1,7 +1,7 @@ .. index:: pair_style rheo pair_style rheo command -========================= +======================= Syntax """""" @@ -25,7 +25,7 @@ Examples .. code-block:: LAMMPS - pair_style rheo 1.0 quintic rho/damp 1.0 artificial/visc 2.0 + pair_style rheo 3.0 rho/damp 1.0 artificial/visc 2.0 pair_coeff * * Description @@ -41,22 +41,23 @@ heat exchanged between particles. The *artificial/viscosity* keyword is used to specify the magnitude :math:`\zeta` of an optional artificial viscosity contribution to forces. This factor can help stabilize simulations by smoothing out small length -scale variations in velocity fields. Artificial viscous forces are only -exchanged by fluid particles unless interfaces are not reconstructed in -fix rheo, in which fluid particles will also exchange artificial viscous -forces with solid particles to improve stability. +scale variations in velocity fields. Artificial viscous forces typically +are only exchanged by fluid particles. However, if interfaces are not +reconstructed in fix rheo, fluid particles will also exchange artificial +viscous forces with solid particles to improve stability. The *rho/damp* keyword is used to specify the magnitude :math:`\xi` of an optional pairwise damping term between the density of particles. This factor can help stabilize simulations by smoothing out small length -scale variations in density fields. +scale variations in density fields. However, in systems that develop +a density gradient in equilibrium (e.g. in a hydrostatic column underlying +gravity), this option may be inappropriate. If particles have different viscosities or conductivities, the *harmonic/means* keyword changes how they are averaged before calculating pairwise forces or heat exchanges. By default, an arithmetic averaged is -used, however, a harmonic mean may improve stability in multiphase systems -with large disparities in viscosities. This keyword has no effect on -results if viscosities and conductivities are constant. +used, however, a harmonic mean may improve stability in systems with multiple +fluid phases with large disparities in viscosities. No coefficients are defined for each pair of atoms types via the :doc:`pair_coeff ` command as in the examples @@ -70,16 +71,20 @@ Mixing, shift, table, tail correction, restart, rRESPA info This style does not support the :doc:`pair_modify ` shift, table, and tail options. -This style does not write information to :doc:`binary restart files `. Thus, you need to re-specify the pair_style and -pair_coeff commands in an input script that reads a restart file. +This style does not write information to :doc:`binary restart files `. +Thus, you need to re-specify the pair_style and pair_coeff commands in an input +script that reads a restart file. -This style can only be used via the *pair* keyword of the :doc:`run_style respa ` command. It does not support the *inner*, *middle*, *outer* keywords. +This style can only be used via the *pair* keyword of the +:doc:`run_style respa ` command. It does not support the *inner*, +*middle*, *outer* keywords. Restrictions """""""""""" This fix is part of the RHEO 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 """""""""""""""" @@ -93,4 +98,5 @@ Related commands Default """"""" -Density damping and artificial viscous forces are not calculated. Arithmetic means are used for mixing particle properties. +Density damping and artificial viscous forces are not calculated. +Arithmetic means are used for mixing particle properties. diff --git a/doc/src/pair_rheo_solid.rst b/doc/src/pair_rheo_solid.rst index 4bac9b726f..0b1ed47fb8 100644 --- a/doc/src/pair_rheo_solid.rst +++ b/doc/src/pair_rheo_solid.rst @@ -1,7 +1,7 @@ .. index:: pair_style rheo/solid pair_style rheo/solid command -========================= +============================= Syntax """""" @@ -44,7 +44,7 @@ normal velocity of particles F_D = - \gamma w (\hat{r} \bullet \vec{v}) where :math:`\gamma` is the damping strength, :math:`\hat{r}` is the -radial normal vector, :math:`\vec{v}` is the velocity difference +displacement normal vector, :math:`\vec{v}` is the velocity difference between the two particles, and :math:`w` is a smoothing factor. This smoothing factor is constructed such that damping forces go to zero as particles come out of contact to avoid discontinuities. It is @@ -95,7 +95,7 @@ This pair style can only be used via the *pair* keyword of the Restrictions """""""""""" -This pair style is part of the BPM package. It is only enabled if +This pair style is part of the RHEO package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. diff --git a/doc/src/pair_style.rst b/doc/src/pair_style.rst index 75157d6127..1cb85ff739 100644 --- a/doc/src/pair_style.rst +++ b/doc/src/pair_style.rst @@ -337,6 +337,8 @@ accelerated styles exist. * :doc:`reaxff ` - ReaxFF potential * :doc:`rebo ` - Second generation REBO potential of Brenner * :doc:`rebomos ` - REBOMoS potential for MoS2 +* :doc:`rheo ` - fluid interactions in RHEO package +* :doc:`rheo/solid ` - solid interactions in RHEO package * :doc:`resquared ` - Everaers RE-Squared ellipsoidal potential * :doc:`saip/metal ` - Interlayer potential for hetero-junctions formed with hexagonal 2D materials and metal surfaces * :doc:`sdpd/taitwater/isothermal ` - Smoothed dissipative particle dynamics for water at isothermal conditions diff --git a/examples/rheo/balloon/in.rheo.balloon b/examples/rheo/balloon/in.rheo.balloon index c82fa39df3..24e400f40f 100644 --- a/examples/rheo/balloon/in.rheo.balloon +++ b/examples/rheo/balloon/in.rheo.balloon @@ -71,5 +71,5 @@ compute nbond all nbond/atom thermo 200 thermo_style custom step time ke press atoms -dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_nbond c_rho +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_nbond c_rho run 30000 diff --git a/examples/rheo/balloon/log.17Apr2024.balloon.g++.4 b/examples/rheo/balloon/log.17Apr2024.balloon.g++.4 new file mode 100644 index 0000000000..28fcc4b590 --- /dev/null +++ b/examples/rheo/balloon/log.17Apr2024.balloon.g++.4 @@ -0,0 +1,382 @@ +LAMMPS (17 Apr 2024 - Development - patch_5May2020-18508-g3c0eaf6870-modified) +# ------ 2D water balloon ------ # + +dimension 2 +units lj +atom_style hybrid rheo bond +boundary m m p +comm_modify vel yes +newton off + +region box block -40 40 0 80 -0.01 0.01 units box +create_box 1 box bond/types 1 extra/bond/per/atom 15 extra/special/per/atom 50 +Created orthogonal box = (-40 0 -0.01) to (40 80 0.01) + 2 by 2 by 1 MPI processor grid + +region fluid sphere -10 40 0 30 units box side in +lattice hex 1.0 +Lattice spacing in x,y,z = 1.0745699 1.8612097 1.0745699 +create_atoms 1 region fluid +Created 2830 atoms + using lattice units in orthogonal box = (-40 0 -0.01) to (40 80 0.01) + create_atoms CPU = 0.001 seconds + +region shell sphere -10 40 0 27 units box side out +group shell region shell +544 atoms in group shell + +set group shell rheo/status 1 +Setting atom values ... + 544 settings made for rheo/status +set group all vx 0.005 vy -0.04 +Setting atom values ... + 2830 settings made for vx + 2830 settings made for vy + +# ------ Model parameters ------# + +variable cut equal 3.0 +variable n equal 1.0 +variable rho0 equal 1.0 +variable cs equal 1.0 +variable mp equal ${rho0}/${n} +variable mp equal 1/${n} +variable mp equal 1/1 +variable zeta equal 0.05 +variable kappa equal 0.01*${rho0}/${mp} +variable kappa equal 0.01*1/${mp} +variable kappa equal 0.01*1/1 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable dt_max equal 0.1*3/${cs}/3 +variable dt_max equal 0.1*3/1/3 +variable eta equal 0.05 +variable Cv equal 1.0 +variable L equal 1.0 +variable Tf equal 1.0 + +mass * ${mp} +mass * 1 +timestep 0.1 + +pair_style hybrid/overlay rheo ${cut} artificial/visc ${zeta} rheo/solid +pair_style hybrid/overlay rheo 3 artificial/visc ${zeta} rheo/solid +pair_style hybrid/overlay rheo 3 artificial/visc 0.05 rheo/solid +pair_coeff * * rheo +pair_coeff * * rheo/solid 1.0 1.0 1.0 + +special_bonds lj 0.0 1.0 1.0 coul 0.0 1.0 1.0 +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0 1 1 + special bond factors coul: 0 1 1 + 0 = max # of 1-2 neighbors + 101 = max # of special neighbors + special bonds CPU = 0.000 seconds +create_bonds many shell shell 1 0 1.5 +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.3 + ghost atom cutoff = 3.3 + binsize = 1.65, bins = 49 49 1 + 3 neighbor lists, perpetual/occasional/extra = 2 1 0 + (1) command create_bonds, occasional + attributes: full, newton off + pair build: full/bin + stencil: full/bin/2d + bin: standard + (2) pair rheo, perpetual + attributes: half, newton off + pair build: half/bin/newtoff + stencil: full/bin/2d + bin: standard + (3) pair rheo/solid, perpetual, trim from (2) + attributes: half, newton off, cut 1.3 + pair build: trim + stencil: none + bin: none +Added 1263 bonds, new total = 1263 +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0 1 1 + special bond factors coul: 0 1 1 + 6 = max # of 1-2 neighbors + 101 = max # of special neighbors + special bonds CPU = 0.000 seconds +special_bonds lj 0.0 1.0 1.0 coul 1.0 1.0 1.0 + +bond_style bpm/spring +bond_coeff 1 1.0 1.0 1.0 + +# A lower critical strain allows the balloon to pop +#bond_coeff 1 1.0 0.05 1.0 + +# ------ Drop balloon ------# + +fix 1 all rheo ${cut} quintic 0 shift surface/detection coordination 22 8 +fix 1 all rheo 3 quintic 0 shift surface/detection coordination 22 8 +fix 2 all rheo/viscosity * constant ${eta} +fix 2 all rheo/viscosity * constant 0.05 +fix 3 all rheo/pressure * linear +fix 4 all wall/harmonic ylo EDGE 2.0 1.0 1.0 +fix 5 all enforce2d + +compute rho all rheo/property/atom rho +compute phase all rheo/property/atom phase +compute nbond all nbond/atom + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press atoms + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_nbond c_rho +run 30000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- BPM bond style: doi:10.1039/D3SM01373A + +@Article{Clemmer2024, + author = {Clemmer, Joel T. and Monti, Joseph M. and Lechman, Jeremy B.}, + title = {A soft departure from jamming: the compaction of deformable + granular matter under high pressures}, + journal = {Soft Matter}, + year = 2024, + volume = 20, + number = 8, + pages = {1702--1718} +} + +- @article{PalermoInPrep, + journal = {in prep}, + title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows}, + year = {2024}, + author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor}, +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.3 + ghost atom cutoff = 3.3 + binsize = 1.65, bins = 49 49 1 + 6 neighbor lists, perpetual/occasional/extra = 6 0 0 + (1) pair rheo, perpetual, half/full from (3) + attributes: half, newton off + pair build: halffull/newtoff + stencil: none + bin: none + (2) pair rheo/solid, perpetual, trim from (1) + attributes: half, newton off, cut 1.3 + pair build: trim + stencil: none + bin: none + (3) compute RHEO/KERNEL, perpetual + attributes: full, newton off + pair build: full/bin + stencil: full/bin/2d + bin: standard + (4) compute RHEO/GRAD, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (5) compute RHEO/VSHIFT, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (6) compute RHEO/SURFACE, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 17.63 | 17.64 | 17.65 Mbytes + Step Time KinEng Press Atoms + 0 0 0.0008125 0.00035927734 2830 + 200 20 0.0008125 0.00035927734 2830 + 400 40 0.0008125 0.00035927734 2830 + 600 60 0.0008125 0.00035927734 2830 + 800 80 0.0008125 0.00035927734 2830 + 1000 100 0.0008125 0.00035927734 2830 + 1200 120 0.0008125 0.00035927734 2830 + 1400 140 0.0008125 0.00035927734 2830 + 1600 160 0.0008125 0.00035927734 2830 + 1800 180 0.0008125 0.00035927734 2830 + 2000 200 0.0008125 0.00035927734 2830 + 2200 220 0.0008125 0.00035927734 2830 + 2400 240 0.00079033569 0.00043037861 2830 + 2600 260 0.0007549229 0.00045188383 2830 + 2800 280 0.00072808836 0.00031695003 2830 + 3000 300 0.0007017958 1.6121754e-05 2830 + 3200 320 0.00067479047 -0.00015725514 2830 + 3400 340 0.00064762254 -0.00023361314 2830 + 3600 360 0.00061960255 -0.00033837679 2830 + 3800 380 0.0005857206 -0.00051770716 2830 + 4000 400 0.00055061733 -0.00070309251 2830 + 4200 420 0.00051884719 -0.0008247795 2830 + 4400 440 0.00049022236 -0.00099918413 2830 + 4600 460 0.00046060011 -0.0010923159 2830 + 4800 480 0.00042900173 -0.0011524571 2830 + 5000 500 0.00039751503 -0.0012586358 2830 + 5200 520 0.00036620054 -0.0013973543 2830 + 5400 540 0.00033130023 -0.0015185231 2830 + 5600 560 0.00030565892 -0.0016159836 2830 + 5800 580 0.00028209836 -0.0016925198 2830 + 6000 600 0.00024695044 -0.0017796892 2830 + 6200 620 0.00021190635 -0.0018706272 2830 + 6400 640 0.0001947093 -0.0019146643 2830 + 6600 660 0.00018903936 -0.0019146199 2830 + 6800 680 0.00017753371 -0.0019390155 2830 + 7000 700 0.00015170593 -0.0020247472 2830 + 7200 720 0.00011509692 -0.0021222209 2830 + 7400 740 7.9861785e-05 -0.0022033181 2830 + 7600 760 6.1350463e-05 -0.0022511971 2830 + 7800 780 6.5269523e-05 -0.0022222806 2830 + 8000 800 8.5709569e-05 -0.0021089664 2830 + 8200 820 0.00011746348 -0.0019351493 2830 + 8400 840 0.00015698134 -0.0017079928 2830 + 8600 860 0.00019758065 -0.0014618965 2830 + 8800 880 0.00023338199 -0.0012365832 2830 + 9000 900 0.00026282353 -0.0010348527 2830 + 9200 920 0.00028604776 -0.00085287884 2830 + 9400 940 0.00030388767 -0.000681122 2830 + 9600 960 0.000317589 -0.00052203521 2830 + 9800 980 0.00032716728 -0.00037501187 2830 + 10000 1000 0.00033270692 -0.00025576132 2830 + 10200 1020 0.00033485986 -0.00016554207 2830 + 10400 1040 0.00033476763 -9.8525417e-05 2830 + 10600 1060 0.00033351922 -5.1166347e-05 2830 + 10800 1080 0.00033161645 -2.0773965e-05 2830 + 11000 1100 0.00032913022 2.2384421e-07 2830 + 11200 1120 0.00032618376 1.2304773e-05 2830 + 11400 1140 0.00032310409 1.3725982e-05 2830 + 11600 1160 0.0003202128 9.0431945e-06 2830 + 11800 1180 0.00031760386 -5.3537879e-07 2830 + 12000 1200 0.00031518884 -1.331708e-05 2830 + 12200 1220 0.00031283958 -3.0838612e-05 2830 + 12400 1240 0.0003104901 -5.0038548e-05 2830 + 12600 1260 0.00030811597 -6.9699925e-05 2830 + 12800 1280 0.00030555782 -8.9972287e-05 2830 + 13000 1300 0.00030256671 -0.00011712941 2830 + 13200 1320 0.00029907961 -0.00015495826 2830 + 13400 1340 0.00029504656 -0.00020292633 2830 + 13600 1360 0.0002905184 -0.00024892421 2830 + 13800 1380 0.00028564542 -0.000295085 2830 + 14000 1400 0.00028073246 -0.00034571956 2830 + 14200 1420 0.00027611457 -0.00039341977 2830 + 14400 1440 0.00027217382 -0.0004281012 2830 + 14600 1460 0.00026919129 -0.00045342545 2830 + 14800 1480 0.00026727674 -0.00047323419 2830 + 15000 1500 0.0002663482 -0.00048423944 2830 + 15200 1520 0.00026616663 -0.0004816085 2830 + 15400 1540 0.00026634862 -0.00047573486 2830 + 15600 1560 0.0002664314 -0.00046803192 2830 + 15800 1580 0.00026603348 -0.00045753668 2830 + 16000 1600 0.00026511015 -0.00044676105 2830 + 16200 1620 0.00026373403 -0.00044075794 2830 + 16400 1640 0.00026217342 -0.00043684036 2830 + 16600 1660 0.0002607038 -0.00042774771 2830 + 16800 1680 0.00025951097 -0.00041603026 2830 + 17000 1700 0.00025869088 -0.00040302996 2830 + 17200 1720 0.00025825588 -0.00038415247 2830 + 17400 1740 0.00025818373 -0.00035742127 2830 + 17600 1760 0.00025843381 -0.00032854722 2830 + 17800 1780 0.00025897836 -0.00029821183 2830 + 18000 1800 0.00025981472 -0.00026108907 2830 + 18200 1820 0.00026095775 -0.00021731058 2830 + 18400 1840 0.00026239688 -0.00017030825 2830 + 18600 1860 0.00026404432 -0.00011868778 2830 + 18800 1880 0.00026574247 -5.9556286e-05 2830 + 19000 1900 0.00026729563 2.3014881e-06 2830 + 19200 1920 0.00026852418 6.2100169e-05 2830 + 19400 1940 0.00026929086 0.00012090325 2830 + 19600 1960 0.0002695407 0.00017904223 2830 + 19800 1980 0.00026929677 0.00023112254 2830 + 20000 2000 0.00026863577 0.0002756697 2830 + 20200 2020 0.00026765699 0.0003158399 2830 + 20400 2040 0.00026646841 0.00035200747 2830 + 20600 2060 0.00026516938 0.00038018442 2830 + 20800 2080 0.00026383495 0.00040179111 2830 + 21000 2100 0.00026252489 0.00042030921 2830 + 21200 2120 0.00026128616 0.00043466976 2830 + 21400 2140 0.00026014896 0.00044221445 2830 + 21600 2160 0.00025912325 0.00044531883 2830 + 21800 2180 0.00025821515 0.00044661709 2830 + 22000 2200 0.00025742576 0.00044409089 2830 + 22200 2220 0.00025674938 0.00043634999 2830 + 22400 2240 0.00025617111 0.00042630344 2830 + 22600 2260 0.0002556791 0.00041561603 2830 + 22800 2280 0.00025525963 0.00040166735 2830 + 23000 2300 0.00025489538 0.00038430419 2830 + 23200 2320 0.00025456861 0.0003669402 2830 + 23400 2340 0.00025426747 0.00034972373 2830 + 23600 2360 0.00025398353 0.0003302242 2830 + 23800 2380 0.00025370842 0.00030993088 2830 + 24000 2400 0.00025344084 0.00029143258 2830 + 24200 2420 0.00025318683 0.00027421708 2830 + 24400 2440 0.0002529591 0.00025603123 2830 + 24600 2460 0.0002527713 0.00023950245 2830 + 24800 2480 0.00025264228 0.00022644812 2830 + 25000 2500 0.00025259021 0.00021540748 2830 + 25200 2520 0.00025262892 0.00020544201 2830 + 25400 2540 0.00025276229 0.00019845807 2830 + 25600 2560 0.0002529876 0.00019449958 2830 + 25800 2580 0.00025329374 0.00019082606 2830 + 26000 2600 0.00025366066 0.00018700064 2830 + 26200 2620 0.00025406164 0.00018426061 2830 + 26400 2640 0.00025446737 0.00018098339 2830 + 26600 2660 0.00025484714 0.00017471869 2830 + 26800 2680 0.00025516604 0.00016565557 2830 + 27000 2700 0.00025538911 0.00015493626 2830 + 27200 2720 0.00025548177 0.00014075592 2830 + 27400 2740 0.00025541168 0.00012205573 2830 + 27600 2760 0.00025514889 0.00010039772 2830 + 27800 2780 0.00025467547 7.7069215e-05 2830 + 28000 2800 0.0002539915 5.1158042e-05 2830 + 28200 2820 0.00025312083 2.3468384e-05 2830 + 28400 2840 0.00025211323 -3.2184465e-06 2830 + 28600 2860 0.00025104366 -2.7726301e-05 2830 + 28800 2880 0.00025000263 -5.0202987e-05 2830 + 29000 2900 0.00024907814 -6.9244776e-05 2830 + 29200 2920 0.00024833815 -8.2874516e-05 2830 + 29400 2940 0.0002478155 -9.1854992e-05 2830 + 29600 2960 0.00024750313 -9.766055e-05 2830 + 29800 2980 0.00024735538 -9.9681291e-05 2830 + 30000 3000 0.00024730191 -9.818759e-05 2830 +Loop time of 177.982 on 4 procs for 30000 steps with 2830 atoms + +Performance: 1456330.235 tau/day, 168.557 timesteps/s, 477.016 katom-step/s +99.7% CPU use with 4 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 22.913 | 27.061 | 34.594 | 87.2 | 15.20 +Bond | 0.22386 | 0.26159 | 0.30792 | 6.0 | 0.15 +Neigh | 0.84412 | 0.84509 | 0.8462 | 0.1 | 0.47 +Comm | 0.50015 | 0.55579 | 0.60346 | 5.2 | 0.31 +Output | 0.65854 | 0.69412 | 0.72473 | 2.8 | 0.39 +Modify | 133.13 | 136 | 137.38 | 14.5 | 76.41 +Other | | 12.57 | | | 7.06 + +Nlocal: 707.5 ave 1576 max 53 min +Histogram: 2 0 0 0 0 0 1 0 0 1 +Nghost: 164.75 ave 239 max 94 min +Histogram: 1 0 1 0 0 0 0 1 0 1 +Neighs: 12307.8 ave 27380 max 983 min +Histogram: 2 0 0 0 0 0 1 0 0 1 +FullNghs: 23517 ave 53040 max 1502 min +Histogram: 2 0 0 0 0 0 1 0 0 1 + +Total # of neighbors = 94068 +Ave neighs/atom = 33.239576 +Ave special neighs/atom = 0.89257951 +Neighbor list builds = 783 +Dangerous builds = 0 +Total wall time: 0:02:58 diff --git a/examples/rheo/dam-break/log.17Apr2024.dam.g++.4 b/examples/rheo/dam-break/log.17Apr2024.dam.g++.4 new file mode 100644 index 0000000000..6388d9e478 --- /dev/null +++ b/examples/rheo/dam-break/log.17Apr2024.dam.g++.4 @@ -0,0 +1,1694 @@ +LAMMPS (17 Apr 2024 - Development - patch_5May2020-18508-g3c0eaf6870-modified) +# ------ 2D dam break ------ # + +dimension 2 +units lj +atom_style rheo +boundary f s p +comm_modify vel yes +newton off + +# ------ Create simulation box ------ # + +variable n equal 1.0 +variable cut equal 2.2 +variable dx equal 3.0 + +region box block -1 150 -1 80 -0.1 0.1 units box +create_box 2 box +Created orthogonal box = (-1 -1 -0.1) to (150 80 0.1) + 2 by 2 by 1 MPI processor grid +lattice hex ${n} +lattice hex 1 +Lattice spacing in x,y,z = 1.0745699 1.8612097 1.0745699 + +region fluid block $(xlo+v_dx+1.0) $(xlo+40.0) $(ylo+v_dx+1.0) $(yhi-20.0) EDGE EDGE units box +region fluid block 3 $(xlo+40.0) $(ylo+v_dx+1.0) $(yhi-20.0) EDGE EDGE units box +region fluid block 3 39 $(ylo+v_dx+1.0) $(yhi-20.0) EDGE EDGE units box +region fluid block 3 39 2.991900000000000226 $(yhi-20.0) EDGE EDGE units box +region fluid block 3 39 2.991900000000000226 60.008099999999998886 EDGE EDGE units box +region walls1 block $(xlo+v_dx) $(xhi-v_dx) $(ylo+v_dx) $(yhi-v_dx) EDGE EDGE side out units box +region walls1 block 2 $(xhi-v_dx) $(ylo+v_dx) $(yhi-v_dx) EDGE EDGE side out units box +region walls1 block 2 147 $(ylo+v_dx) $(yhi-v_dx) EDGE EDGE side out units box +region walls1 block 2 147 1.9919000000000000039 $(yhi-v_dx) EDGE EDGE side out units box +region walls1 block 2 147 1.9919000000000000039 77.008099999999998886 EDGE EDGE side out units box +region walls2 block EDGE EDGE EDGE $(yhi-v_dx) EDGE EDGE side in units box +region walls2 block EDGE EDGE EDGE 77.008099999999998886 EDGE EDGE side in units box +region walls intersect 2 walls1 walls2 + +create_atoms 1 region fluid +Created 2044 atoms + using lattice units in orthogonal box = (-1 -1.0081 -0.1) to (150 80.0081 0.1) + create_atoms CPU = 0.001 seconds +create_atoms 2 region walls +Created 1002 atoms + using lattice units in orthogonal box = (-1 -1.0081 -0.1) to (150 80.0081 0.1) + create_atoms CPU = 0.000 seconds + +group fluid type 1 +2044 atoms in group fluid +group rig type 2 +1002 atoms in group rig + +# ------ Model parameters ------ # + +variable rho0 equal 1.0 +variable mp equal ${rho0}/${n} +variable mp equal 1/${n} +variable mp equal 1/1 +variable cs equal 1.0 +variable zeta equal 0.1 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable dt_max equal 0.1*2.2/${cs}/3 +variable dt_max equal 0.1*2.2/1/3 +variable eta equal 0.1 +variable Dr equal 0.1 + +mass 1 ${mp} +mass 1 1 +mass 2 $(2*v_mp) +mass 2 2 +set group all rheo/rho ${rho0} +set group all rheo/rho 1 +Setting atom values ... + 3046 settings made for rheo/rho + +set group all rheo/status 0 +Setting atom values ... + 3046 settings made for rheo/status +set group rig rheo/status 1 +Setting atom values ... + 1002 settings made for rheo/status + +timestep ${dt_max} +timestep 0.0733333333333333 + +pair_style rheo ${cut} artificial/visc ${zeta} #rho/damp ${Dr} +pair_style rheo 2.2 artificial/visc ${zeta} +pair_style rheo 2.2 artificial/visc 0.1 +pair_coeff * * + +# ------ Fixes & computes ------ # + +fix 1 all rheo ${cut} quintic 10 surface/detection coordination 22 8 rho/sum +fix 1 all rheo 2.2 quintic 10 surface/detection coordination 22 8 rho/sum +fix 2 all rheo/viscosity * constant ${eta} +fix 2 all rheo/viscosity * constant 0.1 +fix 3 all rheo/pressure * linear +fix 4 all gravity 1e-3 vector 0 -1 0 +fix 5 rig setforce 0.0 0.0 0.0 +fix 6 all enforce2d + +compute rho all rheo/property/atom rho +compute p all rheo/property/atom pressure +compute surf all rheo/property/atom surface +compute sn all rheo/property/atom surface/n/x surface/n/y + +# ------ Output & Run ------ # + +thermo 20 +thermo_style custom step time ke press + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_rho c_surf c_p c_sn[*] + +run 30000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- @article{PalermoInPrep, + journal = {in prep}, + title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows}, + year = {2024}, + author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor}, +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.5 + ghost atom cutoff = 2.5 + binsize = 1.25, bins = 121 65 1 + 5 neighbor lists, perpetual/occasional/extra = 5 0 0 + (1) pair rheo, perpetual, half/full from (2) + attributes: half, newton off + pair build: halffull/newtoff + stencil: none + bin: none + (2) compute RHEO/KERNEL, perpetual + attributes: full, newton off + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (3) compute RHEO/GRAD, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (4) compute RHEO/RHO/SUM, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (5) compute RHEO/SURFACE, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 5.707 | 5.721 | 5.736 Mbytes + Step Time KinEng Press + 0 0 0 -8.9662357e-06 + 20 1.4666667 0.00034058796 8.9684994e-05 + 40 2.9333333 6.9365611e-05 2.3675864e-05 + 60 4.4 6.1074185e-05 1.6680783e-05 + 80 5.8666667 5.0534793e-05 1.2623473e-05 + 100 7.3333333 4.1073516e-05 1.1708742e-05 + 120 8.8 4.9303871e-05 1.3714304e-05 + 140 10.266667 5.1669035e-05 1.3579535e-05 + 160 11.733333 6.0107096e-05 1.606084e-05 + 180 13.2 6.9154593e-05 1.8429091e-05 + 200 14.666667 8.0009963e-05 2.0757671e-05 + 220 16.133333 9.1883493e-05 2.3542955e-05 + 240 17.6 0.00010524584 2.6786532e-05 + 260 19.066667 0.00011982479 3.0390295e-05 + 280 20.533333 0.00013474016 3.4766566e-05 + 300 22 0.00015081777 4.0596983e-05 + 320 23.466667 0.00016922091 4.7811202e-05 + 340 24.933333 0.00018746472 5.436563e-05 + 360 26.4 0.00020594739 5.8634772e-05 + 380 27.866667 0.00022673738 6.0759081e-05 + 400 29.333333 0.00024754656 6.1922882e-05 + 420 30.8 0.00026882061 6.4956859e-05 + 440 32.266667 0.00029203 7.2311959e-05 + 460 33.733333 0.00031627032 8.1297842e-05 + 480 35.2 0.00034113307 8.9913587e-05 + 500 36.666667 0.00036599396 9.7909338e-05 + 520 38.133333 0.00039120212 0.0001055925 + 540 39.6 0.00041728537 0.00011265914 + 560 41.066667 0.00044402713 0.00011842088 + 580 42.533333 0.00047160578 0.00012321574 + 600 44 0.00050005372 0.00012842455 + 620 45.466667 0.00052908365 0.00013533445 + 640 46.933333 0.00055833314 0.00014412684 + 660 48.4 0.00058760766 0.00015385416 + 680 49.866667 0.00061704537 0.00016323184 + 700 51.333333 0.00064676026 0.0001720558 + 720 52.8 0.00067674239 0.00018065137 + 740 54.266667 0.00070699735 0.00018906348 + 760 55.733333 0.00073745009 0.00019856234 + 780 57.2 0.00076805806 0.00020874484 + 800 58.666667 0.00079892632 0.00021905295 + 820 60.133333 0.00083019385 0.00022890532 + 840 61.6 0.00086204047 0.00023806257 + 860 63.066667 0.00089463638 0.00024675987 + 880 64.533333 0.0009280011 0.00025519683 + 900 66 0.00096201218 0.00026350368 + 920 67.466667 0.00099657113 0.00027166253 + 940 68.933333 0.0010317502 0.00027992975 + 960 70.4 0.0010676863 0.00028790134 + 980 71.866667 0.0011043796 0.00029680468 + 1000 73.333333 0.0011417187 0.00030600061 + 1020 74.8 0.001179618 0.00031551941 + 1040 76.266667 0.0012180222 0.00032540799 + 1060 77.733333 0.0012568886 0.00033557079 + 1080 79.2 0.0012962727 0.00034616068 + 1100 80.666667 0.0013363417 0.00035717164 + 1120 82.133333 0.0013772784 0.00036920892 + 1140 83.6 0.0014192183 0.00038068516 + 1160 85.066667 0.0014621933 0.00039223594 + 1180 86.533333 0.0015061045 0.00040532576 + 1200 88 0.001550789 0.00041895976 + 1220 89.466667 0.0015961278 0.00043309673 + 1240 90.933333 0.0016420919 0.0004476234 + 1260 92.4 0.001688693 0.00046248791 + 1280 93.866667 0.0017358804 0.00047764479 + 1300 95.333333 0.0017834857 0.0004929783 + 1320 96.8 0.0018313096 0.00050814477 + 1340 98.266667 0.0018793086 0.00052401678 + 1360 99.733333 0.0019277217 0.00053716885 + 1380 101.2 0.0019769204 0.00055180327 + 1400 102.66667 0.0020270711 0.0005656469 + 1420 104.13333 0.0020779701 0.00057917022 + 1440 105.6 0.0021293579 0.00059160854 + 1460 107.06667 0.0021813213 0.00060392999 + 1480 108.53333 0.0022341025 0.00061636071 + 1500 110 0.00228757 0.00062924749 + 1520 111.46667 0.0023412951 0.00064266414 + 1540 112.93333 0.0023952355 0.0006565177 + 1560 114.4 0.0024498098 0.00067063291 + 1580 115.86667 0.0025051272 0.00068509378 + 1600 117.33333 0.0025608522 0.00069926059 + 1620 118.8 0.0026168714 0.000713059 + 1640 120.26667 0.0026733349 0.00072675496 + 1660 121.73333 0.0027302055 0.00074010812 + 1680 123.2 0.0027874761 0.00075390199 + 1700 124.66667 0.0028453711 0.00076786487 + 1720 126.13333 0.0029038156 0.0007820191 + 1740 127.6 0.0029624061 0.00079619745 + 1760 129.06667 0.0030211707 0.00081053823 + 1780 130.53333 0.0030802801 0.00082493927 + 1800 132 0.0031393313 0.00083943639 + 1820 133.46667 0.0031981476 0.00085389118 + 1840 134.93333 0.0032572803 0.00086793469 + 1860 136.4 0.0033167316 0.00088219559 + 1880 137.86667 0.0033757606 0.00089612646 + 1900 139.33333 0.0034343394 0.00090982709 + 1920 140.8 0.0034930349 0.00092382861 + 1940 142.26667 0.0035518482 0.00093805745 + 1960 143.73333 0.0036105788 0.00095257985 + 1980 145.2 0.0036693157 0.00096734041 + 2000 146.66667 0.0037279206 0.00098228262 + 2020 148.13333 0.0037863272 0.00099753272 + 2040 149.6 0.0038448977 0.0010129675 + 2060 151.06667 0.0039035631 0.0010289263 + 2080 152.53333 0.0039618021 0.001044226 + 2100 154 0.0040196981 0.001059823 + 2120 155.46667 0.0040776598 0.0010754207 + 2140 156.93333 0.0041356267 0.0010912489 + 2160 158.4 0.0041933707 0.0011068916 + 2180 159.86667 0.0042506844 0.001122462 + 2200 161.33333 0.0043076551 0.0011378276 + 2220 162.8 0.004364899 0.0011531367 + 2240 164.26667 0.0044223607 0.0011685928 + 2260 165.73333 0.0044790909 0.001183629 + 2280 167.2 0.0045350513 0.0011983147 + 2300 168.66667 0.0045910698 0.0012128941 + 2320 170.13333 0.0046473036 0.0012274902 + 2340 171.6 0.0047034572 0.0012420483 + 2360 173.06667 0.0047594904 0.001256434 + 2380 174.53333 0.0048154857 0.0012710526 + 2400 176 0.0048713579 0.0012854643 + 2420 177.46667 0.0049268461 0.0012999539 + 2440 178.93333 0.0049821065 0.0013141319 + 2460 180.4 0.0050376352 0.0013286044 + 2480 181.86667 0.0050932684 0.0013428647 + 2500 183.33333 0.0051487541 0.0013573039 + 2520 184.8 0.0052041856 0.001371655 + 2540 186.26667 0.005259265 0.0013858701 + 2560 187.73333 0.0053140412 0.0014000303 + 2580 189.2 0.0053687577 0.0014142597 + 2600 190.66667 0.0054226172 0.0014281564 + 2620 192.13333 0.0054756639 0.0014420369 + 2640 193.6 0.0055290419 0.0014559949 + 2660 195.06667 0.0055821088 0.0014698039 + 2680 196.53333 0.0056340694 0.0014837338 + 2700 198 0.0056859198 0.0014973779 + 2720 199.46667 0.0057376404 0.0015110075 + 2740 200.93333 0.0057882397 0.0015247587 + 2760 202.4 0.0058380714 0.0015376559 + 2780 203.86667 0.0058874524 0.0015511804 + 2800 205.33333 0.0059360376 0.0015643594 + 2820 206.8 0.0059840503 0.0015776406 + 2840 208.26667 0.0060315172 0.0015904895 + 2860 209.73333 0.0060778724 0.0016030297 + 2880 211.2 0.0061232681 0.0016153868 + 2900 212.66667 0.0061684129 0.0016276456 + 2920 214.13333 0.0062133058 0.0016395859 + 2940 215.6 0.0062576324 0.0016507189 + 2960 217.06667 0.0063013566 0.0016623583 + 2980 218.53333 0.0063443506 0.0016735007 + 3000 220 0.0063871542 0.001684583 + 3020 221.46667 0.006430519 0.001697154 + 3040 222.93333 0.0064740424 0.0017087524 + 3060 224.4 0.0065176616 0.0017189916 + 3080 225.86667 0.0065615555 0.0017301805 + 3100 227.33333 0.006605039 0.0017410152 + 3120 228.8 0.0066482973 0.0017517164 + 3140 230.26667 0.0066915406 0.0017619713 + 3160 231.73333 0.0067344437 0.0017722386 + 3180 233.2 0.006777227 0.0017824734 + 3200 234.66667 0.006819344 0.0017926386 + 3220 236.13333 0.0068607536 0.0018023968 + 3240 237.6 0.0069026957 0.0018127097 + 3260 239.06667 0.0069450313 0.0018236711 + 3280 240.53333 0.0069865151 0.0018341375 + 3300 242 0.0070275294 0.0018448641 + 3320 243.46667 0.0070688646 0.0018561596 + 3340 244.93333 0.0071092014 0.0018662927 + 3360 246.4 0.0071487936 0.0018770385 + 3380 247.86667 0.0071890814 0.001886802 + 3400 249.33333 0.0072281891 0.0018972625 + 3420 250.8 0.0072657267 0.0019062877 + 3440 252.26667 0.0073033651 0.0019160172 + 3460 253.73333 0.0073406213 0.0019254146 + 3480 255.2 0.0073773312 0.0019343899 + 3500 256.66667 0.0074135814 0.0019431867 + 3520 258.13333 0.0074488904 0.0019521168 + 3540 259.6 0.0074841693 0.0019611895 + 3560 261.06667 0.0075194817 0.0019697561 + 3580 262.53333 0.0075540131 0.0019782744 + 3600 264 0.0075880612 0.0019869585 + 3620 265.46667 0.0076217162 0.0019954264 + 3640 266.93333 0.0076541332 0.0020048511 + 3660 268.4 0.0076854774 0.0020121513 + 3680 269.86667 0.0077170032 0.002020407 + 3700 271.33333 0.0077479535 0.002028555 + 3720 272.8 0.0077778112 0.002035829 + 3740 274.26667 0.0078075791 0.0020445579 + 3760 275.73333 0.0078373125 0.002051243 + 3780 277.2 0.0078671935 0.0020596139 + 3800 278.66667 0.0078966016 0.0020667611 + 3820 280.13333 0.0079259829 0.0020737998 + 3840 281.6 0.0079561144 0.0020823896 + 3860 283.06667 0.0079856022 0.0020898018 + 3880 284.53333 0.0080155451 0.0020975877 + 3900 286 0.008045725 0.0021058637 + 3920 287.46667 0.00807515 0.0021132131 + 3940 288.93333 0.0081055524 0.0021220937 + 3960 290.4 0.0081357323 0.0021293745 + 3980 291.86667 0.0081660373 0.0021372148 + 4000 293.33333 0.0081969984 0.0021452255 + 4020 294.8 0.0082267987 0.0021525847 + 4040 296.26667 0.0082567948 0.0021608073 + 4060 297.73333 0.0082871434 0.0021682544 + 4080 299.2 0.0083173455 0.0021769568 + 4100 300.66667 0.0083480923 0.0021843095 + 4120 302.13333 0.008377833 0.0021919136 + 4140 303.6 0.0084065176 0.0022000503 + 4160 305.06667 0.0084359624 0.0022072124 + 4180 306.53333 0.0084657862 0.0022153288 + 4200 308 0.008494679 0.0022227735 + 4220 309.46667 0.008523307 0.002229996 + 4240 310.93333 0.008553561 0.0022382672 + 4260 312.4 0.0085842107 0.0022462238 + 4280 313.86667 0.0086124223 0.0022536478 + 4300 315.33333 0.0086404396 0.0022608951 + 4320 316.8 0.0086693991 0.0022683957 + 4340 318.26667 0.0086973954 0.0022764575 + 4360 319.73333 0.0087253957 0.0022829952 + 4380 321.2 0.0087529268 0.0022901779 + 4400 322.66667 0.0087798869 0.0022970351 + 4420 324.13333 0.0088070731 0.0023035923 + 4440 325.6 0.0088336854 0.0023108163 + 4460 327.06667 0.00886034 0.002317611 + 4480 328.53333 0.008886686 0.0023244292 + 4500 330 0.0089126796 0.0023323098 + 4520 331.46667 0.0089380439 0.002338006 + 4540 332.93333 0.0089625802 0.0023439698 + 4560 334.4 0.0089876608 0.0023508279 + 4580 335.86667 0.0090119764 0.0023567519 + 4600 337.33333 0.0090358053 0.0023630419 + 4620 338.8 0.0090597056 0.0023696207 + 4640 340.26667 0.0090827564 0.0023757413 + 4660 341.73333 0.0091057102 0.0023825055 + 4680 343.2 0.0091280804 0.0023880185 + 4700 344.66667 0.0091501664 0.0023938041 + 4720 346.13333 0.0091724992 0.0024006288 + 4740 347.6 0.0091940571 0.0024066505 + 4760 349.06667 0.0092145857 0.0024118199 + 4780 350.53333 0.0092353995 0.0024187452 + 4800 352 0.0092558703 0.0024235776 + 4820 353.46667 0.009275219 0.0024285703 + 4840 354.93333 0.0092944603 0.0024339815 + 4860 356.4 0.0093126366 0.0024385746 + 4880 357.86667 0.0093312838 0.0024434876 + 4900 359.33333 0.0093497163 0.0024488983 + 4920 360.8 0.009365989 0.0024527436 + 4940 362.26667 0.0093829249 0.0024572285 + 4960 363.73333 0.0093999951 0.0024620002 + 4980 365.2 0.0094162511 0.0024654432 + 5000 366.66667 0.009432966 0.0024696871 + 5020 368.13333 0.0094491728 0.0024752768 + 5040 369.6 0.0094654395 0.0024791774 + 5060 371.06667 0.0094822028 0.0024833783 + 5080 372.53333 0.0094987002 0.0024876159 + 5100 374 0.0095154669 0.0024916919 + 5120 375.46667 0.0095317268 0.0024971427 + 5140 376.93333 0.0095488298 0.0025012162 + 5160 378.4 0.0095659696 0.0025049341 + 5180 379.86667 0.0095824397 0.0025092752 + 5200 381.33333 0.0096000959 0.0025131409 + 5220 382.8 0.0096178056 0.0025171802 + 5240 384.26667 0.0096358075 0.0025217474 + 5260 385.73333 0.0096536841 0.0025259115 + 5280 387.2 0.0096720374 0.0025307756 + 5300 388.66667 0.0096903176 0.0025371145 + 5320 390.13333 0.0097081278 0.002540216 + 5340 391.6 0.0097268941 0.0025456853 + 5360 393.06667 0.009745217 0.0025499166 + 5380 394.53333 0.0097634815 0.0025546822 + 5400 396 0.0097813844 0.0025591351 + 5420 397.46667 0.0097989874 0.0025645654 + 5440 398.93333 0.0098165651 0.0025681155 + 5460 400.4 0.0098343876 0.0025724122 + 5480 401.86667 0.0098522329 0.0025783873 + 5500 403.33333 0.0098691009 0.0025818597 + 5520 404.8 0.0098860184 0.0025857495 + 5540 406.26667 0.0099028987 0.002590578 + 5560 407.73333 0.0099197309 0.0025942164 + 5580 409.2 0.0099359956 0.0025983095 + 5600 410.66667 0.0099524424 0.0026024035 + 5620 412.13333 0.0099690162 0.0026067584 + 5640 413.6 0.0099843964 0.002611251 + 5660 415.06667 0.010000092 0.0026151565 + 5680 416.53333 0.010015971 0.0026189738 + 5700 418 0.01003088 0.0026226851 + 5720 419.46667 0.010046448 0.0026266212 + 5740 420.93333 0.010061779 0.0026305773 + 5760 422.4 0.010077085 0.002634556 + 5780 423.86667 0.010092596 0.0026403454 + 5800 425.33333 0.010107214 0.0026431069 + 5820 426.8 0.010122323 0.0026467806 + 5840 428.26667 0.010136615 0.0026505801 + 5860 429.73333 0.0101514 0.0026545146 + 5880 431.2 0.010165938 0.0026575254 + 5900 432.66667 0.010180061 0.0026611852 + 5920 434.13333 0.010193978 0.0026651517 + 5940 435.6 0.010207399 0.0026700025 + 5960 437.06667 0.010221274 0.0026724013 + 5980 438.53333 0.0102342 0.002675843 + 6000 440 0.010246851 0.0026796139 + 6020 441.46667 0.010259615 0.0026826456 + 6040 442.93333 0.010271994 0.0026856149 + 6060 444.4 0.010284566 0.0026891263 + 6080 445.86667 0.01029697 0.0026934663 + 6100 447.33333 0.010297087 0.0026929648 + 6120 448.8 0.01026953 0.0026859415 + 6140 450.26667 0.010241322 0.0026788232 + 6160 451.73333 0.010201572 0.0026685955 + 6180 453.2 0.010167529 0.0026596809 + 6200 454.66667 0.010140751 0.0026523585 + 6220 456.13333 0.010096077 0.002641072 + 6240 457.6 0.010043217 0.0026282922 + 6260 459.06667 0.0099830892 0.0026127228 + 6280 460.53333 0.0099406642 0.0026021682 + 6300 462 0.0099151275 0.002595732 + 6320 463.46667 0.0098900642 0.0025891145 + 6340 464.93333 0.0098560891 0.0025805017 + 6360 466.4 0.0098293518 0.0025741231 + 6380 467.86667 0.0098089665 0.0025692332 + 6400 469.33333 0.0097886264 0.0025633005 + 6420 470.8 0.0097672621 0.0025580882 + 6440 472.26667 0.0097438543 0.0025530359 + 6460 473.73333 0.0097156792 0.0025441423 + 6480 475.2 0.0096824023 0.0025359007 + 6500 476.66667 0.0096556854 0.0025282404 + 6520 478.13333 0.0096245146 0.0025200185 + 6540 479.6 0.0095942888 0.0025112709 + 6560 481.06667 0.0095630005 0.0025029005 + 6580 482.53333 0.0095307546 0.0024945223 + 6600 484 0.0094979676 0.0024851442 + 6620 485.46667 0.0094678543 0.0024768078 + 6640 486.93333 0.009440454 0.0024694763 + 6660 488.4 0.0094144007 0.0024632333 + 6680 489.86667 0.0093906089 0.0024562358 + 6700 491.33333 0.0093653494 0.0024490631 + 6720 492.8 0.0093388466 0.0024421324 + 6740 494.26667 0.0093068273 0.0024334756 + 6760 495.73333 0.0092747153 0.0024247141 + 6780 497.2 0.0092468798 0.0024172005 + 6800 498.66667 0.0092160816 0.002409021 + 6820 500.13333 0.0091844109 0.0024010176 + 6840 501.6 0.0091543943 0.0023931861 + 6860 503.06667 0.0091225364 0.00238459 + 6880 504.53333 0.009091163 0.0023764251 + 6900 506 0.0090620145 0.0023688628 + 6920 507.46667 0.0090327696 0.0023610683 + 6940 508.93333 0.0090043995 0.0023537352 + 6960 510.4 0.0089749557 0.0023459457 + 6980 511.86667 0.0089447271 0.0023385936 + 7000 513.33333 0.0089161633 0.0023311311 + 7020 514.8 0.008888379 0.002323798 + 7040 516.26667 0.0088597051 0.0023162749 + 7060 517.73333 0.0088314196 0.0023094901 + 7080 519.2 0.0088032697 0.0023017143 + 7100 520.66667 0.0087764174 0.0022945937 + 7120 522.13333 0.0087493465 0.0022878231 + 7140 523.6 0.0087208106 0.0022805679 + 7160 525.06667 0.0086901023 0.0022726678 + 7180 526.53333 0.0086602781 0.0022649995 + 7200 528 0.0086338883 0.0022581858 + 7220 529.46667 0.0086086121 0.002252324 + 7240 530.93333 0.0085801758 0.0022441934 + 7260 532.4 0.0085495659 0.0022361561 + 7280 533.86667 0.0085199727 0.0022288965 + 7300 535.33333 0.0084891254 0.0022216958 + 7320 536.8 0.0084557275 0.0022130525 + 7340 538.26667 0.0084218841 0.002203592 + 7360 539.73333 0.0083899168 0.0021958184 + 7380 541.2 0.0083585487 0.002188024 + 7400 542.66667 0.0083279264 0.0021795695 + 7420 544.13333 0.0082956611 0.0021711337 + 7440 545.6 0.0082600396 0.0021620937 + 7460 547.06667 0.008222435 0.0021524246 + 7480 548.53333 0.0081847492 0.0021422603 + 7500 550 0.0081480769 0.0021324926 + 7520 551.46667 0.0081129495 0.0021237168 + 7540 552.93333 0.0080794573 0.0021154414 + 7560 554.4 0.0080465003 0.0021057182 + 7580 555.86667 0.0080134857 0.0020967731 + 7600 557.33333 0.0079807769 0.0020882759 + 7620 558.8 0.007949081 0.0020799016 + 7640 560.26667 0.0079178914 0.0020720038 + 7660 561.73333 0.0078871135 0.0020650346 + 7680 563.2 0.007856599 0.0020563039 + 7700 564.66667 0.0078260839 0.002048286 + 7720 566.13333 0.007796051 0.0020402506 + 7740 567.6 0.0077667325 0.0020324247 + 7760 569.06667 0.0077368975 0.0020242564 + 7780 570.53333 0.0077063146 0.002016025 + 7800 572 0.0076756813 0.0020076974 + 7820 573.46667 0.0076444658 0.0019992537 + 7840 574.93333 0.0076122527 0.0019912246 + 7860 576.4 0.00757938 0.0019824601 + 7880 577.86667 0.0075457657 0.0019739889 + 7900 579.33333 0.0075114496 0.0019644524 + 7920 580.8 0.0074775871 0.0019556077 + 7940 582.26667 0.0074449114 0.0019470595 + 7960 583.73333 0.0074125826 0.0019386798 + 7980 585.2 0.0073795946 0.0019298994 + 8000 586.66667 0.0073460046 0.0019208737 + 8020 588.13333 0.0073122744 0.0019120703 + 8040 589.6 0.0072783913 0.0019033047 + 8060 591.06667 0.0072440775 0.0018943414 + 8080 592.53333 0.0072092735 0.0018852102 + 8100 594 0.0071736521 0.0018758623 + 8120 595.46667 0.0071373132 0.0018664102 + 8140 596.93333 0.0071013244 0.0018569886 + 8160 598.4 0.0070657891 0.0018477343 + 8180 599.86667 0.0070299646 0.0018383955 + 8200 601.33333 0.0069940522 0.001829006 + 8220 602.8 0.0069586108 0.0018197189 + 8240 604.26667 0.0069231457 0.0018112586 + 8260 605.73333 0.0068871373 0.0018016096 + 8280 607.2 0.0068512951 0.0017928173 + 8300 608.66667 0.006816413 0.0017834399 + 8320 610.13333 0.0067820205 0.0017745017 + 8340 611.6 0.0067473828 0.0017654991 + 8360 613.06667 0.0067124905 0.0017569034 + 8380 614.53333 0.0066773905 0.0017474775 + 8400 616 0.0066417638 0.0017387333 + 8420 617.46667 0.0066057074 0.0017293058 + 8440 618.93333 0.0065700041 0.0017200093 + 8460 620.4 0.0065351174 0.0017110662 + 8480 621.86667 0.0065006001 0.0017017664 + 8500 623.33333 0.0064659553 0.0016926237 + 8520 624.8 0.0064314284 0.0016834464 + 8540 626.26667 0.0063972759 0.0016730222 + 8560 627.73333 0.006363104 0.0016535358 + 8580 629.2 0.0063283374 0.0016341308 + 8600 630.66667 0.0062929939 0.0016145833 + 8620 632.13333 0.0062575534 0.0015952196 + 8640 633.6 0.0062223967 0.0015767924 + 8660 635.06667 0.0061876077 0.0015584021 + 8680 636.53333 0.0061531388 0.0015432462 + 8700 638 0.0061189895 0.0015255547 + 8720 639.46667 0.0060849843 0.0015087078 + 8740 640.93333 0.0060508603 0.0014912511 + 8760 642.4 0.0060166368 0.0014741414 + 8780 643.86667 0.0059825217 0.0014570326 + 8800 645.33333 0.0059487275 0.0014404208 + 8820 646.8 0.005915195 0.001427214 + 8840 648.26667 0.0058815506 0.0014108717 + 8860 649.73333 0.0058475012 0.001394823 + 8880 651.2 0.005813175 0.0013791763 + 8900 652.66667 0.0057788055 0.0013635495 + 8920 654.13333 0.0057442301 0.0013485291 + 8940 655.6 0.0057092563 0.0013329993 + 8960 657.06667 0.0056742445 0.0013200488 + 8980 658.53333 0.0056395856 0.0013052312 + 9000 660 0.005604919 0.0012908181 + 9020 661.46667 0.0055697452 0.001276258 + 9040 662.93333 0.0055345006 0.0012617179 + 9060 664.4 0.0054999699 0.0012488732 + 9080 665.86667 0.0054658705 0.0012342743 + 9100 667.33333 0.0054312056 0.0012219265 + 9120 668.8 0.0053958845 0.0012069595 + 9140 670.26667 0.0053607107 0.0011946481 + 9160 671.73333 0.0053258562 0.0011805403 + 9180 673.2 0.005290634 0.0011685879 + 9200 674.66667 0.0052548527 0.0011548258 + 9220 676.13333 0.0052191394 0.0011431756 + 9240 677.6 0.0051838155 0.0011292222 + 9260 679.06667 0.0051486178 0.0011177695 + 9280 680.53333 0.0051136287 0.0011043218 + 9300 682 0.0050793517 0.001093456 + 9320 683.46667 0.0050458249 0.00108072 + 9340 684.93333 0.0050124909 0.0010699656 + 9360 686.4 0.0049790841 0.0010577503 + 9380 687.86667 0.0049458438 0.0010471846 + 9400 689.33333 0.0049128193 0.0010353066 + 9420 690.8 0.0048796878 0.0010250736 + 9440 692.26667 0.0048463678 0.0010133357 + 9460 693.73333 0.0048130621 0.0010034192 + 9480 695.2 0.0047797612 0.00099181501 + 9500 696.66667 0.0047463058 0.00098192704 + 9520 698.13333 0.0047129773 0.00097114316 + 9540 699.6 0.0046802695 0.0009614797 + 9560 701.06667 0.0046481303 0.00095001935 + 9580 702.53333 0.0046159995 0.00094018625 + 9600 704 0.0045836057 0.00093048866 + 9620 705.46667 0.0045513113 0.00092093431 + 9640 706.93333 0.0045195288 0.00091163732 + 9660 708.4 0.0044881214 0.00090108788 + 9680 709.86667 0.0044565522 0.00089178586 + 9700 711.33333 0.0044245471 0.00088289706 + 9720 712.8 0.0043923571 0.00087366447 + 9740 714.26667 0.0043603446 0.00086340815 + 9760 715.73333 0.0043285042 0.00085450195 + 9780 717.2 0.0042965444 0.00084545827 + 9800 718.66667 0.0042643896 0.00083689129 + 9820 720.13333 0.0042323768 0.00082818681 + 9840 721.6 0.0042008631 0.00081834996 + 9860 723.06667 0.0041697784 0.00081001308 + 9880 724.53333 0.0041387393 0.00080132405 + 9900 726 0.0041075523 0.00079289302 + 9920 727.46667 0.0040764684 0.00078371229 + 9940 728.93333 0.004045842 0.00077617702 + 9960 730.4 0.0040156553 0.00076786882 + 9980 731.86667 0.0039855818 0.00075942893 + 10000 733.33333 0.0039554481 0.0007511838 + 10020 734.8 0.0039255002 0.00074338609 + 10040 736.26667 0.0038961167 0.0007357845 + 10060 737.73333 0.0038673423 0.00072863577 + 10080 739.2 0.0038388258 0.00072101271 + 10100 740.66667 0.0038101889 0.00071325927 + 10120 742.13333 0.0037813579 0.00070577634 + 10140 743.6 0.0037524894 0.00069840857 + 10160 745.06667 0.0037236699 0.0006912217 + 10180 746.53333 0.0036948382 0.00068398999 + 10200 748 0.0036659574 0.0006765938 + 10220 749.46667 0.003637161 0.00066944812 + 10240 750.93333 0.0036086524 0.00066246958 + 10260 752.4 0.0035804876 0.00065555896 + 10280 753.86667 0.0035525249 0.00064877214 + 10300 755.33333 0.003524549 0.00064262835 + 10320 756.8 0.0034964925 0.0006359586 + 10340 758.26667 0.0034685139 0.00062899447 + 10360 759.73333 0.0034408225 0.00062253344 + 10380 761.2 0.0034134787 0.00061569541 + 10400 762.66667 0.0033863357 0.00061002091 + 10420 764.13333 0.0033591874 0.00060376799 + 10440 765.6 0.0033319865 0.00059696082 + 10460 767.06667 0.0033049023 0.00059041399 + 10480 768.53333 0.0032781346 0.00058417754 + 10500 770 0.0032516844 0.0005781413 + 10520 771.46667 0.0032253297 0.00057280542 + 10540 772.93333 0.0031988384 0.00056654214 + 10560 774.4 0.0031722162 0.00056022576 + 10580 775.86667 0.0031457039 0.0005547685 + 10600 777.33333 0.0031195399 0.00054891424 + 10620 778.8 0.003093753 0.00054282948 + 10640 780.26667 0.0030681782 0.0005378126 + 10660 781.73333 0.0030426412 0.00053187104 + 10680 783.2 0.0030171127 0.00052598426 + 10700 784.66667 0.0029917103 0.00052087104 + 10720 786.13333 0.0029665734 0.00051521228 + 10740 787.6 0.0029417486 0.00050965329 + 10760 789.06667 0.0029171964 0.000504914 + 10780 790.53333 0.0028928685 0.00049932491 + 10800 792 0.0028687686 0.00049451045 + 10820 793.46667 0.0028449566 0.00048905426 + 10840 794.93333 0.0028215175 0.00048442583 + 10860 796.4 0.0027985141 0.00047942674 + 10880 797.86667 0.0027759233 0.00047495434 + 10900 799.33333 0.0027536322 0.00046989793 + 10920 800.8 0.0027315039 0.00046490714 + 10940 802.26667 0.0027094846 0.00046064051 + 10960 803.73333 0.0026876651 0.00045602046 + 10980 805.2 0.002666198 0.00045168389 + 11000 806.66667 0.0026451664 0.00044707481 + 11020 808.13333 0.0026244819 0.00044301025 + 11040 809.6 0.0026039186 0.00043882304 + 11060 811.06667 0.0025833111 0.00043484293 + 11080 812.53333 0.0025627062 0.0004302122 + 11100 814 0.0025423309 0.00042635689 + 11120 815.46667 0.0025223953 0.00042237706 + 11140 816.93333 0.002502881 0.00041811928 + 11160 818.4 0.002483558 0.00041427004 + 11180 819.86667 0.0024642 0.00041016131 + 11200 821.33333 0.002444785 0.00040680079 + 11220 822.8 0.0024255271 0.00040255216 + 11240 824.26667 0.0024066719 0.0003989581 + 11260 825.73333 0.0023882699 0.00039531616 + 11280 827.2 0.0023701608 0.00039149232 + 11300 828.66667 0.0023521641 0.00038812202 + 11320 830.13333 0.0023342875 0.00038432826 + 11340 831.6 0.0023167154 0.00038122373 + 11360 833.06667 0.0022996036 0.00037780451 + 11380 834.53333 0.0022829198 0.00037461979 + 11400 836 0.0022664799 0.00037151931 + 11420 837.46667 0.0022501566 0.00036807932 + 11440 838.93333 0.0022340312 0.00036508287 + 11460 840.4 0.0022183033 0.00036190422 + 11480 841.86667 0.0022030817 0.00035916212 + 11500 843.33333 0.0021882572 0.00035628429 + 11520 844.8 0.0021735959 0.00035351859 + 11540 846.26667 0.0021589553 0.00035088484 + 11560 847.73333 0.002144383 0.00034780033 + 11580 849.2 0.0021300334 0.00034517904 + 11600 850.66667 0.0021160134 0.00034238069 + 11620 852.13333 0.0021022646 0.00034000514 + 11640 853.6 0.0020886207 0.00033719824 + 11660 855.06667 0.0020749807 0.00033475998 + 11680 856.53333 0.0020613877 0.0003323936 + 11700 858 0.002047954 0.0003295216 + 11720 859.46667 0.0020347589 0.00032713228 + 11740 860.93333 0.0020218117 0.00032474079 + 11760 862.4 0.0020091095 0.00032239213 + 11780 863.86667 0.0019966993 0.00031989799 + 11800 865.33333 0.0019846286 0.00031771663 + 11820 866.8 0.0019728573 0.0003157215 + 11840 868.26667 0.0019612776 0.00031355627 + 11860 869.73333 0.0019498221 0.00031127816 + 11880 871.2 0.0019385448 0.00030917103 + 11900 872.66667 0.0019275959 0.00030717234 + 11920 874.13333 0.0019170876 0.00030529115 + 11940 875.6 0.0019069791 0.00030345863 + 11960 877.06667 0.0018971139 0.00030170128 + 11980 878.53333 0.0018873555 0.0003001492 + 12000 880 0.0018776861 0.000298125 + 12020 881.46667 0.0018681863 0.0002963477 + 12040 882.93333 0.0018589294 0.00029463961 + 12060 884.4 0.0018499098 0.00029287916 + 12080 885.86667 0.0018410776 0.00029127697 + 12100 887.33333 0.0018324309 0.00028984289 + 12120 888.8 0.0018240594 0.00028840492 + 12140 890.26667 0.0018160961 0.00028702304 + 12160 891.73333 0.0018086145 0.00028549007 + 12180 893.2 0.0018015575 0.00028402955 + 12200 894.66667 0.0017947657 0.00028282399 + 12220 896.13333 0.0017880903 0.00028154717 + 12240 897.6 0.0017814942 0.00028017139 + 12260 899.06667 0.0017750529 0.00027900454 + 12280 900.53333 0.0017688698 0.00027808648 + 12300 902 0.0017629899 0.00027685309 + 12320 903.46667 0.0017573722 0.00027580637 + 12340 904.93333 0.0017519364 0.00027485838 + 12360 906.4 0.0017466397 0.00027394007 + 12380 907.86667 0.001741517 0.00027291856 + 12400 909.33333 0.0017366544 0.00027203238 + 12420 910.8 0.0017321325 0.00027110163 + 12440 912.26667 0.0017279827 0.00027027898 + 12460 913.73333 0.0017241867 0.00026956597 + 12480 915.2 0.0017207028 0.00026893832 + 12500 916.66667 0.0017174942 0.0002684279 + 12520 918.13333 0.0017145473 0.00026791943 + 12540 919.6 0.0017118647 0.00026744382 + 12560 921.06667 0.0017094489 0.00026685887 + 12580 922.53333 0.0017072871 0.00026638424 + 12600 924 0.0017053649 0.00026597657 + 12620 925.46667 0.0017036738 0.00026563478 + 12640 926.93333 0.0017022202 0.00026540665 + 12660 928.4 0.0017010329 0.00026520386 + 12680 929.86667 0.0017001522 0.00026507626 + 12700 931.33333 0.0016995942 0.00026477717 + 12720 932.8 0.0016993235 0.0002646703 + 12740 934.26667 0.0016992705 0.00026461169 + 12760 935.73333 0.0016993774 0.00026456725 + 12780 937.2 0.0016996306 0.00026455988 + 12800 938.66667 0.001700059 0.0002646213 + 12820 940.13333 0.0017007039 0.00026482076 + 12840 941.6 0.0017015791 0.00026487824 + 12860 943.06667 0.0017026482 0.00026493272 + 12880 944.53333 0.0017038391 0.00026510172 + 12900 946 0.0017050887 0.00026529547 + 12920 947.46667 0.0017063854 0.00026551572 + 12940 948.93333 0.001707774 0.00026599737 + 12960 950.4 0.0017093344 0.00026611126 + 12980 951.86667 0.0017111446 0.00026624827 + 13000 953.33333 0.0017132414 0.00026655284 + 13020 954.8 0.0017156029 0.00026692012 + 13040 956.26667 0.0017181728 0.00026731624 + 13060 957.73333 0.001720904 0.00026783066 + 13080 959.2 0.0017237902 0.00026836703 + 13100 960.66667 0.0017268644 0.0002689476 + 13120 962.13333 0.0017301659 0.0002694946 + 13140 963.6 0.0017336967 0.00026985524 + 13160 965.06667 0.0017374153 0.00027047141 + 13180 966.53333 0.0017412627 0.00027116583 + 13200 968 0.0017451982 0.00027186788 + 13220 969.46667 0.0017492157 0.00027241441 + 13240 970.93333 0.0017533345 0.00027303315 + 13260 972.4 0.001757579 0.00027374363 + 13280 973.86667 0.0017619627 0.00027451986 + 13300 975.33333 0.0017664863 0.00027525007 + 13320 976.8 0.0017711394 0.00027591661 + 13340 978.26667 0.0017759051 0.00027671531 + 13360 979.73333 0.0017807725 0.00027754179 + 13380 981.2 0.0017857381 0.00027848699 + 13400 982.66667 0.0017907994 0.00027931598 + 13420 984.13333 0.0017959473 0.00028027815 + 13440 985.6 0.0018011601 0.00028113792 + 13460 987.06667 0.0018064143 0.00028211623 + 13480 988.53333 0.0018117101 0.00028327908 + 13500 990 0.0018170864 0.00028409026 + 13520 991.46667 0.0018225918 0.00028501376 + 13540 992.93333 0.0018282476 0.00028596031 + 13560 994.4 0.0018340585 0.00028716447 + 13580 995.86667 0.0018400197 0.00028805463 + 13600 997.33333 0.0018461017 0.00028921664 + 13620 998.8 0.0018522484 0.00029037184 + 13640 1000.2667 0.0018583764 0.00029143019 + 13660 1001.7333 0.001864373 0.00029269198 + 13680 1003.2 0.0018701272 0.0002936223 + 13700 1004.6667 0.001875598 0.00029471055 + 13720 1006.1333 0.0018808354 0.00029567952 + 13740 1007.6 0.0018859376 0.00029685882 + 13760 1009.0667 0.0018910107 0.00029796198 + 13780 1010.5333 0.0018961401 0.00029897911 + 13800 1012 0.0019013893 0.0002998773 + 13820 1013.4667 0.0019068286 0.00030092291 + 13840 1014.9333 0.0019125242 0.00030190868 + 13860 1016.4 0.0019185061 0.00030309941 + 13880 1017.8667 0.001924749 0.00030441051 + 13900 1019.3333 0.0019311778 0.00030560739 + 13920 1020.8 0.001937711 0.00030711748 + 13940 1022.2667 0.0019442933 0.00030842988 + 13960 1023.7333 0.0019508956 0.00030970219 + 13980 1025.2 0.0019575153 0.00031088886 + 14000 1026.6667 0.0019641693 0.00031199334 + 14020 1028.1333 0.0019708823 0.00031333167 + 14040 1029.6 0.0019776662 0.0003147189 + 14060 1031.0667 0.0019845097 0.0003161484 + 14080 1032.5333 0.0019913915 0.00031776661 + 14100 1034 0.0019983071 0.00031912667 + 14120 1035.4667 0.0020052807 0.00032037968 + 14140 1036.9333 0.0020123438 0.00032176152 + 14160 1038.4 0.002019523 0.00032328697 + 14180 1039.8667 0.0020268687 0.00032480224 + 14200 1041.3333 0.0020344454 0.0003263506 + 14220 1042.8 0.0020422702 0.00032803708 + 14240 1044.2667 0.0020503074 0.00032950555 + 14260 1045.7333 0.0020584954 0.00033107602 + 14280 1047.2 0.0020667453 0.00033272838 + 14300 1048.6667 0.0020749518 0.00033440292 + 14320 1050.1333 0.0020830298 0.00033616301 + 14340 1051.6 0.0020909561 0.00033777436 + 14360 1053.0667 0.002098763 0.00033939304 + 14380 1054.5333 0.0021064571 0.00034108867 + 14400 1056 0.0021139812 0.00034279091 + 14420 1057.4667 0.0021212743 0.00034442447 + 14440 1058.9333 0.0021283312 0.00034608006 + 14460 1060.4 0.0021351913 0.00034766535 + 14480 1061.8667 0.0021418558 0.00034931633 + 14500 1063.3333 0.0021482781 0.00035065187 + 14520 1064.8 0.0021544661 0.00035206483 + 14540 1066.2667 0.0021605274 0.00035349517 + 14560 1067.7333 0.0021666138 0.00035497387 + 14580 1069.2 0.002172775 0.00035650749 + 14600 1070.6667 0.0021789434 0.00035816361 + 14620 1072.1333 0.0021850567 0.00035981347 + 14640 1073.6 0.0021911017 0.00036119002 + 14660 1075.0667 0.0021970459 0.00036263527 + 14680 1076.5333 0.002202891 0.00036408979 + 14700 1078 0.0022086678 0.00036558706 + 14720 1079.4667 0.0022143659 0.00036708363 + 14740 1080.9333 0.0022200095 0.00036872316 + 14760 1082.4 0.0022256795 0.00037031852 + 14780 1083.8667 0.0022314598 0.00037172104 + 14800 1085.3333 0.0022373988 0.00037326473 + 14820 1086.8 0.0022435042 0.00037481567 + 14840 1088.2667 0.0022497418 0.0003767171 + 14860 1089.7333 0.0022560684 0.00037860978 + 14880 1091.2 0.002262451 0.00038015024 + 14900 1092.6667 0.0022688473 0.00038171512 + 14920 1094.1333 0.0022751666 0.00038333305 + 14940 1095.6 0.0022812118 0.00038546448 + 14960 1097.0667 0.0022867513 0.00038693328 + 14980 1098.5333 0.0022917745 0.00038844788 + 15000 1100 0.002296287 0.00038988563 + 15020 1101.4667 0.0022999653 0.00039138878 + 15040 1102.9333 0.0023028622 0.00039244167 + 15060 1104.4 0.002305798 0.00039349216 + 15080 1105.8667 0.0023089263 0.00039463979 + 15100 1107.3333 0.0023120599 0.00039582741 + 15120 1108.8 0.0023154124 0.00039746408 + 15140 1110.2667 0.0023192069 0.00039877981 + 15160 1111.7333 0.0023234403 0.00040024924 + 15180 1113.2 0.0023275332 0.00040194985 + 15200 1114.6667 0.0023309379 0.00040319063 + 15220 1116.1333 0.0023333104 0.0004046024 + 15240 1117.6 0.0023350271 0.00040564766 + 15260 1119.0667 0.0023370916 0.00040733425 + 15280 1120.5333 0.0023395929 0.00040838933 + 15300 1122 0.0023424998 0.00040987095 + 15320 1123.4667 0.0023453536 0.00041107287 + 15340 1124.9333 0.0023473165 0.00041242318 + 15360 1126.4 0.0023477134 0.00041322951 + 15380 1127.8667 0.0023491753 0.0004146031 + 15400 1129.3333 0.0023509302 0.00041566144 + 15420 1130.8 0.0023529326 0.00041714975 + 15440 1132.2667 0.0023554779 0.00041837505 + 15460 1133.7333 0.0023580661 0.00042017965 + 15480 1135.2 0.0023607312 0.0004213224 + 15500 1136.6667 0.0023635957 0.00042300666 + 15520 1138.1333 0.0023666602 0.00042436098 + 15540 1139.6 0.0023691001 0.0004260457 + 15560 1141.0667 0.0023700594 0.00042714685 + 15580 1142.5333 0.0023705741 0.00042853206 + 15600 1144 0.0023711825 0.00042951675 + 15620 1145.4667 0.002371987 0.00043109076 + 15640 1146.9333 0.0023732281 0.00043221551 + 15660 1148.4 0.0023749382 0.00043370865 + 15680 1149.8667 0.0023770404 0.00043490458 + 15700 1151.3333 0.0023793818 0.0004365297 + 15720 1152.8 0.0023816701 0.00043819097 + 15740 1154.2667 0.0023836808 0.00043980236 + 15760 1155.7333 0.0023856065 0.00044146758 + 15780 1157.2 0.0023876705 0.0004433163 + 15800 1158.6667 0.0023898905 0.00044465376 + 15820 1160.1333 0.0023918799 0.00044645614 + 15840 1161.6 0.0023914238 0.00044759356 + 15860 1163.0667 0.0023885514 0.00044839265 + 15880 1164.5333 0.0023867062 0.00044939387 + 15900 1166 0.0023853424 0.00045041476 + 15920 1167.4667 0.0023837839 0.00045152066 + 15940 1168.9333 0.0023823865 0.00045222801 + 15960 1170.4 0.0023800327 0.00045327302 + 15980 1171.8667 0.0023735917 0.00045357981 + 16000 1173.3333 0.0023643861 0.00045337685 + 16020 1174.8 0.0023565577 0.00045352436 + 16040 1176.2667 0.0023484436 0.00045344895 + 16060 1177.7333 0.0023408376 0.00045346696 + 16080 1179.2 0.0023326737 0.00045286966 + 16100 1180.6667 0.0023236531 0.00045261832 + 16120 1182.1333 0.0023169178 0.00045293394 + 16140 1183.6 0.0023111828 0.00045311831 + 16160 1185.0667 0.0023064172 0.00045378709 + 16180 1186.5333 0.002302184 0.00045455946 + 16200 1188 0.0022983621 0.00045539262 + 16220 1189.4667 0.0022953512 0.00045591645 + 16240 1190.9333 0.0022929801 0.00045712856 + 16260 1192.4 0.0022909009 0.00045847159 + 16280 1193.8667 0.0022885525 0.00045961196 + 16300 1195.3333 0.0022855688 0.00046061347 + 16320 1196.8 0.002282828 0.00046188788 + 16340 1198.2667 0.0022802183 0.00046302244 + 16360 1199.7333 0.0022773774 0.00046375719 + 16380 1201.2 0.0022731903 0.00046492183 + 16400 1202.6667 0.0022645201 0.00046516447 + 16420 1204.1333 0.0022568251 0.00046542882 + 16440 1205.6 0.0022422695 0.00046437586 + 16460 1207.0667 0.0022155713 0.00046051887 + 16480 1208.5333 0.0022035759 0.00046001297 + 16500 1210 0.002190894 0.00045893493 + 16520 1211.4667 0.0021802322 0.00045942457 + 16540 1212.9333 0.0021704133 0.000459471 + 16560 1214.4 0.0021615234 0.00045918488 + 16580 1215.8667 0.0021529915 0.00045936006 + 16600 1217.3333 0.0021451373 0.00045959338 + 16620 1218.8 0.0021383906 0.0004600505 + 16640 1220.2667 0.0021325315 0.00046005064 + 16660 1221.7333 0.0021277429 0.00046108228 + 16680 1223.2 0.0021237755 0.00046243368 + 16700 1224.6667 0.0021203172 0.00046394738 + 16720 1226.1333 0.0021172137 0.00046532716 + 16740 1227.6 0.0021142084 0.00046719106 + 16760 1229.0667 0.0021110689 0.00046854799 + 16780 1230.5333 0.0021077864 0.00046991776 + 16800 1232 0.0021045002 0.00047183286 + 16820 1233.4667 0.0021013226 0.00047317989 + 16840 1234.9333 0.002098386 0.0004747552 + 16860 1236.4 0.0020957505 0.00047738008 + 16880 1237.8667 0.0020931882 0.0004792455 + 16900 1239.3333 0.0020905705 0.00048104549 + 16920 1240.8 0.0020878895 0.00048403265 + 16940 1242.2667 0.0020853857 0.00048573735 + 16960 1243.7333 0.0020831358 0.00048728108 + 16980 1245.2 0.0020808323 0.00048952128 + 17000 1246.6667 0.0020784817 0.00049099168 + 17020 1248.1333 0.0020761732 0.00049278614 + 17040 1249.6 0.0020739063 0.00049556886 + 17060 1251.0667 0.0020717239 0.00049826766 + 17080 1252.5333 0.0020697361 0.00050040771 + 17100 1254 0.0020679208 0.00050266159 + 17120 1255.4667 0.0020661569 0.00050465637 + 17140 1256.9333 0.0020645102 0.00050644859 + 17160 1258.4 0.002063175 0.00050945115 + 17180 1259.8667 0.0020620744 0.00051135072 + 17200 1261.3333 0.0020578831 0.00051271416 + 17220 1262.8 0.002036801 0.00051070868 + 17240 1264.2667 0.0020246474 0.0005105671 + 17260 1265.7333 0.0020154083 0.00051056266 + 17280 1267.2 0.0020081398 0.00051203914 + 17300 1268.6667 0.0020033592 0.00051368703 + 17320 1270.1333 0.0019993325 0.00051565203 + 17340 1271.6 0.0019965177 0.00051918806 + 17360 1273.0667 0.0019938276 0.000522221 + 17380 1274.5333 0.0019914867 0.00052433401 + 17400 1276 0.0019892544 0.0005278718 + 17420 1277.4667 0.0019871107 0.00052787286 + 17440 1278.9333 0.0019850499 0.00052722809 + 17460 1280.4 0.0019830428 0.0005263569 + 17480 1281.8667 0.0019811987 0.00052588328 + 17500 1283.3333 0.0019795831 0.00052534586 + 17520 1284.8 0.0019781827 0.00052537295 + 17540 1286.2667 0.0019770664 0.00052509105 + 17560 1287.7333 0.0019762397 0.00052445472 + 17580 1289.2 0.0019755625 0.0005240242 + 17600 1290.6667 0.001974964 0.00052397078 + 17620 1292.1333 0.0019744966 0.00052447005 + 17640 1293.6 0.0019741078 0.00052446447 + 17660 1295.0667 0.0019735916 0.0005241986 + 17680 1296.5333 0.001972809 0.00052362297 + 17700 1298 0.0019718021 0.00052322362 + 17720 1299.4667 0.0019707205 0.00052316488 + 17740 1300.9333 0.0019696972 0.00052280952 + 17760 1302.4 0.0019687912 0.00052267588 + 17780 1303.8667 0.0019679901 0.00052231283 + 17800 1305.3333 0.0019672622 0.00052253006 + 17820 1306.8 0.0019665862 0.00052301876 + 17840 1308.2667 0.0019659299 0.00052301364 + 17860 1309.7333 0.00196528 0.0005229424 + 17880 1311.2 0.0019646495 0.00052264866 + 17900 1312.6667 0.0019640476 0.00052292066 + 17920 1314.1333 0.0019634587 0.0005229915 + 17940 1315.6 0.0019628594 0.00052284877 + 17960 1317.0667 0.0019622352 0.00052292872 + 17980 1318.5333 0.0019612399 0.00052337341 + 18000 1320 0.0019519628 0.00052094399 + 18020 1321.4667 0.0019343509 0.00051533063 + 18040 1322.9333 0.0019199585 0.00051174103 + 18060 1324.4 0.001905945 0.00050822167 + 18080 1325.8667 0.0018954044 0.00050571386 + 18100 1327.3333 0.0018867099 0.0005045138 + 18120 1328.8 0.0018790423 0.00050281498 + 18140 1330.2667 0.0018724677 0.00050092806 + 18160 1331.7333 0.0018669293 0.00049977801 + 18180 1333.2 0.0018621946 0.0004988236 + 18200 1334.6667 0.0018581668 0.00049860903 + 18220 1336.1333 0.0018546088 0.00049734989 + 18240 1337.6 0.001851507 0.00049612125 + 18260 1339.0667 0.0018488437 0.00049539768 + 18280 1340.5333 0.0018464974 0.00049462331 + 18300 1342 0.0018441554 0.00049419987 + 18320 1343.4667 0.0018418357 0.00049359519 + 18340 1344.9333 0.0018400699 0.00049361929 + 18360 1346.4 0.0018391163 0.0004934397 + 18380 1347.8667 0.0018386451 0.00049401695 + 18400 1349.3333 0.0018382434 0.00049404913 + 18420 1350.8 0.0018377762 0.00049284789 + 18440 1352.2667 0.0018373163 0.00049253988 + 18460 1353.7333 0.0018368769 0.00049170154 + 18480 1355.2 0.00183642 0.00049134218 + 18500 1356.6667 0.0018359651 0.00049049622 + 18520 1358.1333 0.0018355476 0.00049018604 + 18540 1359.6 0.0018351502 0.00049009857 + 18560 1361.0667 0.0018347415 0.00049034975 + 18580 1362.5333 0.0018343456 0.00048962734 + 18600 1364 0.0018340032 0.00048910267 + 18620 1365.4667 0.0018337131 0.000489678 + 18640 1366.9333 0.0018334434 0.00048942363 + 18660 1368.4 0.0018331908 0.00048883791 + 18680 1369.8667 0.0018330003 0.00048842189 + 18700 1371.3333 0.0018328613 0.00048778042 + 18720 1372.8 0.0018326423 0.0004879605 + 18740 1374.2667 0.0018322085 0.00048760414 + 18760 1375.7333 0.0018316466 0.00048749865 + 18780 1377.2 0.0018311569 0.00048717362 + 18800 1378.6667 0.0018307322 0.0004871375 + 18820 1380.1333 0.0018303267 0.00048680704 + 18840 1381.6 0.0018299711 0.00048676556 + 18860 1383.0667 0.0018296776 0.00048663795 + 18880 1384.5333 0.0018294387 0.00048659964 + 18900 1386 0.0018292809 0.00048698663 + 18920 1387.4667 0.0018292225 0.00048709797 + 18940 1388.9333 0.0018292283 0.0004870647 + 18960 1390.4 0.0018292259 0.00048674819 + 18980 1391.8667 0.0018291569 0.00048679582 + 19000 1393.3333 0.0018290098 0.00048689638 + 19020 1394.8 0.001828716 0.00048714893 + 19040 1396.2667 0.0018281487 0.00048793626 + 19060 1397.7333 0.0018274368 0.00048766312 + 19080 1399.2 0.0018267859 0.00048800122 + 19100 1400.6667 0.0018262357 0.00048767989 + 19120 1402.1333 0.001825769 0.0004870923 + 19140 1403.6 0.001825325 0.00048705214 + 19160 1405.0667 0.0018249161 0.00048807286 + 19180 1406.5333 0.0018245622 0.0004872987 + 19200 1408 0.001824239 0.00048742747 + 19220 1409.4667 0.0018239467 0.00048750738 + 19240 1410.9333 0.0018230912 0.00048779822 + 19260 1412.4 0.0018134463 0.00048497862 + 19280 1413.8667 0.0018021878 0.00048230785 + 19300 1415.3333 0.0017955735 0.00048083973 + 19320 1416.8 0.0017872753 0.0004788259 + 19340 1418.2667 0.0017779883 0.00047646403 + 19360 1419.7333 0.0017738211 0.00047574559 + 19380 1421.2 0.0017704561 0.00047501448 + 19400 1422.6667 0.0017677224 0.00047433091 + 19420 1424.1333 0.0017653706 0.00047260445 + 19440 1425.6 0.0017632679 0.00047170106 + 19460 1427.0667 0.0017613642 0.00047105927 + 19480 1428.5333 0.001759646 0.00047082774 + 19500 1430 0.001758063 0.00047009269 + 19520 1431.4667 0.0017566191 0.00046954867 + 19540 1432.9333 0.0017551775 0.00046892643 + 19560 1434.4 0.0017536259 0.00046842898 + 19580 1435.8667 0.0017521006 0.00046822248 + 19600 1437.3333 0.0017508378 0.00046758045 + 19620 1438.8 0.0017499266 0.0004680761 + 19640 1440.2667 0.0017492698 0.00046815863 + 19660 1441.7333 0.0017486531 0.00046811847 + 19680 1443.2 0.0017479735 0.00046864003 + 19700 1444.6667 0.0017472425 0.00046795012 + 19720 1446.1333 0.0017465091 0.0004669531 + 19740 1447.6 0.0017458236 0.00046666543 + 19760 1449.0667 0.0017452108 0.00046610386 + 19780 1450.5333 0.0017446777 0.00046578676 + 19800 1452 0.0017442315 0.00046559966 + 19820 1453.4667 0.0017438755 0.00046570962 + 19840 1454.9333 0.0017435917 0.00046591684 + 19860 1456.4 0.0017433538 0.00046605781 + 19880 1457.8667 0.0017431368 0.0004662092 + 19900 1459.3333 0.0017429113 0.00046639344 + 19920 1460.8 0.0017426466 0.00046609654 + 19940 1462.2667 0.0017423307 0.00046558461 + 19960 1463.7333 0.0017419767 0.00046538275 + 19980 1465.2 0.0017416057 0.00046473626 + 20000 1466.6667 0.0017412248 0.00046427697 + 20020 1468.1333 0.0017408365 0.00046360441 + 20040 1469.6 0.0017404537 0.00046250116 + 20060 1471.0667 0.0017400878 0.00046219676 + 20080 1472.5333 0.0017397348 0.0004620366 + 20100 1474 0.0017393906 0.00046142035 + 20120 1475.4667 0.0017390634 0.00046119888 + 20140 1476.9333 0.0017387599 0.00046114118 + 20160 1478.4 0.0017384654 0.00046119273 + 20180 1479.8667 0.0017381599 0.00046112037 + 20200 1481.3333 0.001737838 0.00046085119 + 20220 1482.8 0.0017374971 0.00046088054 + 20240 1484.2667 0.0017371388 0.00046097027 + 20260 1485.7333 0.0017368201 0.00046112449 + 20280 1487.2 0.0017365948 0.00046064697 + 20300 1488.6667 0.0017364148 0.00046068874 + 20320 1490.1333 0.001736224 0.00046068502 + 20340 1491.6 0.0017360297 0.00046057861 + 20360 1493.0667 0.0017358482 0.00046044137 + 20380 1494.5333 0.0017356781 0.00046043159 + 20400 1496 0.0017355222 0.00046062752 + 20420 1497.4667 0.0017353902 0.00046067799 + 20440 1498.9333 0.0017352915 0.00046071384 + 20460 1500.4 0.0017352299 0.00046111809 + 20480 1501.8667 0.0017352025 0.0004613299 + 20500 1503.3333 0.0017352027 0.00046183541 + 20520 1504.8 0.0017352278 0.00046106542 + 20540 1506.2667 0.0017352815 0.00046149717 + 20560 1507.7333 0.0017353649 0.00046105371 + 20580 1509.2 0.0017354697 0.00046104238 + 20600 1510.6667 0.0017355805 0.00046116932 + 20620 1512.1333 0.001735681 0.00046162233 + 20640 1513.6 0.001735758 0.00046178245 + 20660 1515.0667 0.0017358047 0.00046196886 + 20680 1516.5333 0.0017358199 0.00046215457 + 20700 1518 0.0017358084 0.00046228161 + 20720 1519.4667 0.0017357806 0.00046261955 + 20740 1520.9333 0.0017357486 0.00046271037 + 20760 1522.4 0.0017357257 0.00046257919 + 20780 1523.8667 0.0017357263 0.00046250064 + 20800 1525.3333 0.0017357658 0.00046146349 + 20820 1526.8 0.0017358584 0.00046138905 + 20840 1528.2667 0.0017360144 0.00046135266 + 20860 1529.7333 0.0017362378 0.00046136088 + 20880 1531.2 0.0017365251 0.00046203214 + 20900 1532.6667 0.0017368656 0.00046240805 + 20920 1534.1333 0.0017372463 0.00046245586 + 20940 1535.6 0.0017376552 0.00046233017 + 20960 1537.0667 0.0017380838 0.00046211905 + 20980 1538.5333 0.0017385273 0.00046221175 + 21000 1540 0.0017389813 0.0004623322 + 21020 1541.4667 0.0017394408 0.00046248895 + 21040 1542.9333 0.0017399011 0.00046262683 + 21060 1544.4 0.0017403582 0.0004628631 + 21080 1545.8667 0.0017408086 0.00046287413 + 21100 1547.3333 0.0017412486 0.00046253863 + 21120 1548.8 0.0017416739 0.00046239188 + 21140 1550.2667 0.0017420824 0.00046252093 + 21160 1551.7333 0.0017424775 0.00046243663 + 21180 1553.2 0.0017428687 0.00046231674 + 21200 1554.6667 0.0017432678 0.00046228047 + 21220 1556.1333 0.0017436835 0.00046205345 + 21240 1557.6 0.0017441181 0.00046191794 + 21260 1559.0667 0.001744567 0.00046187817 + 21280 1560.5333 0.00174502 0.00046195933 + 21300 1562 0.0017454629 0.00046207568 + 21320 1563.4667 0.0017458791 0.00046237686 + 21340 1564.9333 0.0017462532 0.00046251185 + 21360 1566.4 0.00174658 0.00046256338 + 21380 1567.8667 0.0017468761 0.00046258103 + 21400 1569.3333 0.0017471787 0.00046203359 + 21420 1570.8 0.0017475092 0.00046236915 + 21440 1572.2667 0.0017478285 0.00046240886 + 21460 1573.7333 0.0017480488 0.00046268024 + 21480 1575.2 0.0017481357 0.00046249851 + 21500 1576.6667 0.0017481758 0.00046252177 + 21520 1578.1333 0.0017482237 0.00046224255 + 21540 1579.6 0.0017482326 0.00046244066 + 21560 1581.0667 0.0017481857 0.0004626825 + 21580 1582.5333 0.0017481066 0.00046272441 + 21600 1584 0.0017480121 0.00046281669 + 21620 1585.4667 0.0017479031 0.0004630027 + 21640 1586.9333 0.0017477655 0.00046237554 + 21660 1588.4 0.0017475794 0.00046236536 + 21680 1589.8667 0.0017473246 0.00046234947 + 21700 1591.3333 0.0017469863 0.00046229056 + 21720 1592.8 0.0017465596 0.00046226293 + 21740 1594.2667 0.0017460487 0.00046221488 + 21760 1595.7333 0.0017454604 0.00046228835 + 21780 1597.2 0.0017447972 0.00046224033 + 21800 1598.6667 0.0017440567 0.00046196921 + 21820 1600.1333 0.0017432373 0.00046193024 + 21840 1601.6 0.0017423442 0.00046190113 + 21860 1603.0667 0.0017413885 0.00046182645 + 21880 1604.5333 0.0017403804 0.00046153595 + 21900 1606 0.0017393239 0.00046141594 + 21920 1607.4667 0.0017382204 0.00046059163 + 21940 1608.9333 0.0017370711 0.00046011476 + 21960 1610.4 0.0017358772 0.00045995874 + 21980 1611.8667 0.001734638 0.00045946276 + 22000 1613.3333 0.0017333523 0.00045909152 + 22020 1614.8 0.0017320214 0.00045871657 + 22040 1616.2667 0.0017306506 0.00045875126 + 22060 1617.7333 0.001729244 0.00045851969 + 22080 1619.2 0.0017277891 0.00045815 + 22100 1620.6667 0.0017262472 0.00045800503 + 22120 1622.1333 0.0017245557 0.00045722613 + 22140 1623.6 0.0017226312 0.00045612428 + 22160 1625.0667 0.0017203846 0.00045558148 + 22180 1626.5333 0.0017177538 0.00045493102 + 22200 1628 0.0017147219 0.00045354235 + 22220 1629.4667 0.0017113235 0.00045252377 + 22240 1630.9333 0.0017076396 0.00045148679 + 22260 1632.4 0.0017037869 0.00045053035 + 22280 1633.8667 0.0016998953 0.0004495377 + 22300 1635.3333 0.0016960489 0.00044816777 + 22320 1636.8 0.0016922401 0.00044714973 + 22340 1638.2667 0.0016884053 0.00044610277 + 22360 1639.7333 0.0016844703 0.00044568763 + 22380 1641.2 0.0016803511 0.00044439173 + 22400 1642.6667 0.0016759401 0.00044314089 + 22420 1644.1333 0.0016711286 0.00044193566 + 22440 1645.6 0.0016658281 0.0004406589 + 22460 1647.0667 0.0016599393 0.00043844661 + 22480 1648.5333 0.001653471 0.00043656014 + 22500 1650 0.0016466439 0.00043470146 + 22520 1651.4667 0.0016396283 0.00043288723 + 22540 1652.9333 0.0016322717 0.00043091896 + 22560 1654.4 0.0016242406 0.00042878807 + 22580 1655.8667 0.0016143541 0.00042598276 + 22600 1657.3333 0.0015984531 0.00042184208 + 22620 1658.8 0.0015774545 0.00041639723 + 22640 1660.2667 0.0015581678 0.00041151234 + 22660 1661.7333 0.0015392455 0.0004074519 + 22680 1663.2 0.0015238703 0.0004031907 + 22700 1664.6667 0.0015082033 0.00039905746 + 22720 1666.1333 0.0014910701 0.00039410593 + 22740 1667.6 0.0014773215 0.00039023578 + 22760 1669.0667 0.0014646054 0.00038693028 + 22780 1670.5333 0.0014509254 0.00038338321 + 22800 1672 0.0014387044 0.00038022989 + 22820 1673.4667 0.0014276038 0.00037738369 + 22840 1674.9333 0.0014165206 0.00037467759 + 22860 1676.4 0.0014054416 0.00037186956 + 22880 1677.8667 0.0013942654 0.00036919292 + 22900 1679.3333 0.0013833555 0.00036666326 + 22920 1680.8 0.0013733025 0.00036390292 + 22940 1682.2667 0.001364207 0.00036143657 + 22960 1683.7333 0.001355472 0.00035947361 + 22980 1685.2 0.0013467462 0.00035649775 + 23000 1686.6667 0.0013381467 0.00035425964 + 23020 1688.1333 0.0013298724 0.00035194314 + 23040 1689.6 0.0013219998 0.0003499467 + 23060 1691.0667 0.0013145189 0.00034806194 + 23080 1692.5333 0.0013073428 0.00034626601 + 23100 1694 0.0013004081 0.00034470285 + 23120 1695.4667 0.0012935813 0.00034306885 + 23140 1696.9333 0.0012865972 0.0003412658 + 23160 1698.4 0.0012792092 0.00033945219 + 23180 1699.8667 0.0012712869 0.00033750315 + 23200 1701.3333 0.0012627886 0.0003353201 + 23220 1702.8 0.001253784 0.00033296654 + 23240 1704.2667 0.0012445082 0.00033053745 + 23260 1705.7333 0.001235266 0.00032759425 + 23280 1707.2 0.0012261717 0.000325215 + 23300 1708.6667 0.0012168943 0.00032279239 + 23320 1710.1333 0.0012071081 0.00032042001 + 23340 1711.6 0.0011971594 0.00031782638 + 23360 1713.0667 0.0011876725 0.00031524799 + 23380 1714.5333 0.0011786269 0.00031289556 + 23400 1716 0.001169404 0.00031049786 + 23420 1717.4667 0.0011595669 0.00030723977 + 23440 1718.9333 0.001149266 0.00030443096 + 23460 1720.4 0.001138992 0.00030161041 + 23480 1721.8667 0.001129081 0.00029923744 + 23500 1723.3333 0.0011195152 0.00029668379 + 23520 1724.8 0.0011100863 0.00029417354 + 23540 1726.2667 0.0011005982 0.00029164586 + 23560 1727.7333 0.0010910778 0.0002889626 + 23580 1729.2 0.0010816854 0.00028655072 + 23600 1730.6667 0.001072494 0.00028419823 + 23620 1732.1333 0.0010634481 0.00028189699 + 23640 1733.6 0.0010544699 0.00027928614 + 23660 1735.0667 0.0010455565 0.00027694249 + 23680 1736.5333 0.0010367472 0.00027466258 + 23700 1738 0.0010280561 0.00027240232 + 23720 1739.4667 0.0010194696 0.00027014395 + 23740 1740.9333 0.0010109726 0.00026815472 + 23760 1742.4 0.0010025582 0.00026636602 + 23780 1743.8667 0.00099420961 0.0002639384 + 23800 1745.3333 0.00098589439 0.00026185788 + 23820 1746.8 0.00097758322 0.00025980082 + 23840 1748.2667 0.00096925998 0.00025767237 + 23860 1749.7333 0.00096092015 0.00025564227 + 23880 1751.2 0.00095256615 0.0002533114 + 23900 1752.6667 0.00094419511 0.00025115421 + 23920 1754.1333 0.00093579195 0.00024903122 + 23940 1755.6 0.00092733111 0.00024683875 + 23960 1757.0667 0.00091878509 0.00024461091 + 23980 1758.5333 0.00091013147 0.00024236826 + 24000 1760 0.00090135324 0.0002404806 + 24020 1761.4667 0.00089243423 0.0002380936 + 24040 1762.9333 0.00088336053 0.00023549546 + 24060 1764.4 0.00087412784 0.00023319301 + 24080 1765.8667 0.00086474945 0.00023084155 + 24100 1767.3333 0.00085525774 0.00022851664 + 24120 1768.8 0.0008456963 0.00022615872 + 24140 1770.2667 0.00083610859 0.00022375601 + 24160 1771.7333 0.00082652908 0.00022120807 + 24180 1773.2 0.00081698057 0.00021815795 + 24200 1774.6667 0.00080747609 0.00021555543 + 24220 1776.1333 0.00079802183 0.00021298564 + 24240 1777.6 0.00078862131 0.00021045545 + 24260 1779.0667 0.00077927933 0.00020806904 + 24280 1780.5333 0.00077000523 0.0002058181 + 24300 1782 0.00076081568 0.00020320246 + 24320 1783.4667 0.00075173462 0.00020084308 + 24340 1784.9333 0.0007427896 0.00019868422 + 24360 1786.4 0.00073400423 0.00019651532 + 24380 1787.8667 0.00072538996 0.00019445357 + 24400 1789.3333 0.00071694344 0.00019222062 + 24420 1790.8 0.00070865664 0.0001900288 + 24440 1792.2667 0.00070053087 0.00018789961 + 24460 1793.7333 0.00069258266 0.0001848306 + 24480 1795.2 0.00068483291 0.00018274366 + 24500 1796.6667 0.00067729047 0.00018074446 + 24520 1798.1333 0.00066994193 0.00017882986 + 24540 1799.6 0.00066275021 0.00017698882 + 24560 1801.0667 0.00065565627 0.00017510426 + 24580 1802.5333 0.00064858738 0.00017328965 + 24600 1804 0.00064147322 0.00017147388 + 24620 1805.4667 0.00063426805 0.00016964736 + 24640 1806.9333 0.0006269663 0.00016781232 + 24660 1808.4 0.00061960354 0.00016597943 + 24680 1809.8667 0.00061223634 0.00016419561 + 24700 1811.3333 0.00060491662 0.00016237355 + 24720 1812.8 0.00059767953 0.00016075431 + 24740 1814.2667 0.00059053949 0.00015905558 + 24760 1815.7333 0.00058349084 0.00015739614 + 24780 1817.2 0.0005765115 0.00015502575 + 24800 1818.6667 0.0005695693 0.00015330761 + 24820 1820.1333 0.00056263283 0.00015162196 + 24840 1821.6 0.00055568243 0.00014995088 + 24860 1823.0667 0.00054871692 0.00014819243 + 24880 1824.5333 0.00054175223 0.00014652991 + 24900 1826 0.00053481455 0.00014490663 + 24920 1827.4667 0.00052793142 0.00014324987 + 24940 1828.9333 0.00052112566 0.00014156756 + 24960 1830.4 0.00051441308 0.0001397807 + 24980 1831.8667 0.00050780341 0.00013808181 + 25000 1833.3333 0.0005013017 0.00013637046 + 25020 1834.8 0.00049490926 0.00013464589 + 25040 1836.2667 0.00048862482 0.00013292356 + 25060 1837.7333 0.0004824453 0.0001314188 + 25080 1839.2 0.00047636617 0.0001293314 + 25100 1840.6667 0.00047038116 0.00012754146 + 25120 1842.1333 0.00046448251 0.00012554913 + 25140 1843.6 0.0004586615 0.00012383425 + 25160 1845.0667 0.00045290921 0.00012215229 + 25180 1846.5333 0.00044721746 0.00012074608 + 25200 1848 0.00044157971 0.0001189818 + 25220 1849.4667 0.00043599245 0.00011737642 + 25240 1850.9333 0.00043045564 0.00011575387 + 25260 1852.4 0.00042497205 0.00011421704 + 25280 1853.8667 0.00041954608 0.00011269281 + 25300 1855.3333 0.00041418267 0.00011124707 + 25320 1856.8 0.0004088869 0.00010985539 + 25340 1858.2667 0.00040366377 0.00010856688 + 25360 1859.7333 0.0003985179 0.00010747086 + 25380 1861.2 0.00039345294 0.00010624143 + 25400 1862.6667 0.00038847115 0.00010464611 + 25420 1864.1333 0.00038357328 0.00010342367 + 25440 1865.6 0.00037875866 0.00010197951 + 25460 1867.0667 0.0003740255 0.00010083387 + 25480 1868.5333 0.00036937131 9.9727459e-05 + 25500 1870 0.00036479358 9.8715792e-05 + 25520 1871.4667 0.00036029053 9.7693667e-05 + 25540 1872.9333 0.00035586162 9.6659947e-05 + 25560 1874.4 0.00035150779 9.5730365e-05 + 25580 1875.8667 0.000347231 9.4850676e-05 + 25600 1877.3333 0.00034303359 9.4132269e-05 + 25620 1878.8 0.00033891749 9.3355928e-05 + 25640 1880.2667 0.00033488372 9.282199e-05 + 25660 1881.7333 0.00033093187 9.2101633e-05 + 25680 1883.2 0.00032705982 9.1331225e-05 + 25700 1884.6667 0.00032326391 8.9490029e-05 + 25720 1886.1333 0.0003195392 8.8603192e-05 + 25740 1887.6 0.00031588037 8.7694411e-05 + 25760 1889.0667 0.0003122828 8.6761483e-05 + 25780 1890.5333 0.00030874312 8.5806827e-05 + 25800 1892 0.00030525908 8.4835735e-05 + 25820 1893.4667 0.00030182927 8.402954e-05 + 25840 1894.9333 0.00029845296 8.3049666e-05 + 25860 1896.4 0.00029512991 8.211056e-05 + 25880 1897.8667 0.00029186078 8.1134374e-05 + 25900 1899.3333 0.00028864743 8.0199975e-05 + 25920 1900.8 0.00028549282 7.9325687e-05 + 25940 1902.2667 0.0002824008 7.8437438e-05 + 25960 1903.7333 0.00027937535 7.7544386e-05 + 25980 1905.2 0.00027642007 7.6706594e-05 + 26000 1906.6667 0.00027353814 7.579826e-05 + 26020 1908.1333 0.00027073244 7.5008665e-05 + 26040 1909.6 0.00026800557 7.4544912e-05 + 26060 1911.0667 0.00026535971 7.3786981e-05 + 26080 1912.5333 0.00026279611 7.2166049e-05 + 26100 1914 0.00026031456 7.1403392e-05 + 26120 1915.4667 0.00025791305 7.0702466e-05 + 26140 1916.9333 0.00025558794 7.0006351e-05 + 26160 1918.4 0.00025333488 6.9317329e-05 + 26180 1919.8667 0.00025115003 6.8688062e-05 + 26200 1921.3333 0.00024903038 6.8122851e-05 + 26220 1922.8 0.00024697358 6.7568833e-05 + 26240 1924.2667 0.00024497771 6.6968209e-05 + 26260 1925.7333 0.00024304157 6.6501986e-05 + 26280 1927.2 0.0002411651 6.6088755e-05 + 26300 1928.6667 0.00023934939 6.5705322e-05 + 26320 1930.1333 0.00023759592 6.5362857e-05 + 26340 1931.6 0.00023590514 6.5049803e-05 + 26360 1933.0667 0.00023427484 6.473807e-05 + 26380 1934.5333 0.00023269956 6.4466061e-05 + 26400 1936 0.00023117121 6.4080253e-05 + 26420 1937.4667 0.0002296809 6.3752394e-05 + 26440 1938.9333 0.00022822123 6.3357126e-05 + 26460 1940.4 0.00022678837 6.3049852e-05 + 26480 1941.8667 0.00022538306 6.2753673e-05 + 26500 1943.3333 0.00022400995 6.2294535e-05 + 26520 1944.8 0.00022267608 6.2038117e-05 + 26540 1946.2667 0.00022138844 6.1782883e-05 + 26560 1947.7333 0.00022015168 6.1574119e-05 + 26580 1949.2 0.00021896802 6.1384003e-05 + 26600 1950.6667 0.00021783788 6.1156768e-05 + 26620 1952.1333 0.00021676111 6.0986244e-05 + 26640 1953.6 0.0002157381 6.0849325e-05 + 26660 1955.0667 0.00021477001 6.0683878e-05 + 26680 1956.5333 0.00021385807 6.0516059e-05 + 26700 1958 0.00021300223 6.0329517e-05 + 26720 1959.4667 0.00021220038 6.0110922e-05 + 26740 1960.9333 0.0002114485 5.9940604e-05 + 26760 1962.4 0.00021074077 5.977174e-05 + 26780 1963.8667 0.00021007047 5.9606511e-05 + 26800 1965.3333 0.00020943091 5.9060466e-05 + 26820 1966.8 0.00020881619 5.8839697e-05 + 26840 1968.2667 0.00020822134 5.8633638e-05 + 26860 1969.7333 0.00020764269 5.8541664e-05 + 26880 1971.2 0.0002070779 5.83276e-05 + 26900 1972.6667 0.00020652606 5.8076903e-05 + 26920 1974.1333 0.00020598762 5.7951516e-05 + 26940 1975.6 0.00020546407 5.7793633e-05 + 26960 1977.0667 0.00020495767 5.7642438e-05 + 26980 1978.5333 0.00020447095 5.7497463e-05 + 27000 1980 0.00020400643 5.7358967e-05 + 27020 1981.4667 0.00020356638 5.7197798e-05 + 27040 1982.9333 0.00020315297 5.7081118e-05 + 27060 1984.4 0.00020276878 5.6970958e-05 + 27080 1985.8667 0.0002024165 5.6875439e-05 + 27100 1987.3333 0.00020209914 5.6749323e-05 + 27120 1988.8 0.00020182082 5.6684087e-05 + 27140 1990.2667 0.0002015866 5.6665814e-05 + 27160 1991.7333 0.00020140121 5.6663183e-05 + 27180 1993.2 0.0002012666 5.6636454e-05 + 27200 1994.6667 0.00020117997 5.6723443e-05 + 27220 1996.1333 0.00020113417 5.6708615e-05 + 27240 1997.6 0.00020111982 5.6574526e-05 + 27260 1999.0667 0.00020112751 5.6159e-05 + 27280 2000.5333 0.00020114945 5.612955e-05 + 27300 2002 0.00020118054 5.607577e-05 + 27320 2003.4667 0.00020121792 5.6026534e-05 + 27340 2004.9333 0.00020125939 5.5904818e-05 + 27360 2006.4 0.0002013021 5.5872498e-05 + 27380 2007.8667 0.00020134272 5.5850226e-05 + 27400 2009.3333 0.00020137844 5.5792845e-05 + 27420 2010.8 0.0002014071 5.5793502e-05 + 27440 2012.2667 0.00020142601 5.5834389e-05 + 27460 2013.7333 0.00020143246 5.5853674e-05 + 27480 2015.2 0.00020142475 5.5879946e-05 + 27500 2016.6667 0.00020140167 5.5911328e-05 + 27520 2018.1333 0.000201362 5.5946112e-05 + 27540 2019.6 0.00020130361 5.5982457e-05 + 27560 2021.0667 0.00020122365 5.6018854e-05 + 27580 2022.5333 0.00020111911 5.6199876e-05 + 27600 2024 0.00020098676 5.6207908e-05 + 27620 2025.4667 0.00020082461 5.6235125e-05 + 27640 2026.9333 0.00020063251 5.6261668e-05 + 27660 2028.4 0.00020041288 5.6264024e-05 + 27680 2029.8667 0.00020017135 5.6292857e-05 + 27700 2031.3333 0.00019991548 5.6350987e-05 + 27720 2032.8 0.00019965421 5.6386525e-05 + 27740 2034.2667 0.00019939714 5.6330983e-05 + 27760 2035.7333 0.00019915264 5.6315529e-05 + 27780 2037.2 0.00019892685 5.6357912e-05 + 27800 2038.6667 0.00019872342 5.6400674e-05 + 27820 2040.1333 0.00019854343 5.592942e-05 + 27840 2041.6 0.00019838552 5.5933967e-05 + 27860 2043.0667 0.00019824625 5.5937495e-05 + 27880 2044.5333 0.00019812108 5.5939048e-05 + 27900 2046 0.00019800547 5.5938225e-05 + 27920 2047.4667 0.00019789596 5.5934984e-05 + 27940 2048.9333 0.00019779049 5.5998316e-05 + 27960 2050.4 0.00019768847 5.5990459e-05 + 27980 2051.8667 0.00019759007 5.5934942e-05 + 28000 2053.3333 0.00019749517 5.5921371e-05 + 28020 2054.8 0.00019740272 5.5903442e-05 + 28040 2056.2667 0.00019731052 5.5860176e-05 + 28060 2057.7333 0.00019721613 5.58009e-05 + 28080 2059.2 0.00019711761 5.576013e-05 + 28100 2060.6667 0.00019701413 5.5709878e-05 + 28120 2062.1333 0.00019690592 5.5650013e-05 + 28140 2063.6 0.00019679371 5.549438e-05 + 28160 2065.0667 0.00019667803 5.5419813e-05 + 28180 2066.5333 0.00019655854 5.5339684e-05 + 28200 2068 0.0001964341 5.5255642e-05 + 28220 2069.4667 0.00019630305 5.516945e-05 + 28240 2070.9333 0.00019616373 5.5082892e-05 + 28260 2072.4 0.00019601462 5.4997644e-05 + 28280 2073.8667 0.00019585462 5.4915059e-05 + 28300 2075.3333 0.00019568308 5.4836332e-05 + 28320 2076.8 0.00019549977 5.4945429e-05 + 28340 2078.2667 0.00019530501 5.4861235e-05 + 28360 2079.7333 0.00019509987 5.46661e-05 + 28380 2081.2 0.00019488603 5.4604902e-05 + 28400 2082.6667 0.00019466562 5.4548672e-05 + 28420 2084.1333 0.00019444125 5.4495481e-05 + 28440 2085.6 0.00019421575 5.4450188e-05 + 28460 2087.0667 0.00019399217 5.441163e-05 + 28480 2088.5333 0.00019377343 5.4375395e-05 + 28500 2090 0.00019356194 5.4441594e-05 + 28520 2091.4667 0.00019335923 5.4431527e-05 + 28540 2092.9333 0.00019316575 5.4433248e-05 + 28560 2094.4 0.00019298088 5.4331854e-05 + 28580 2095.8667 0.00019280294 5.4731573e-05 + 28600 2097.3333 0.00019262915 5.4763809e-05 + 28620 2098.8 0.00019245592 5.4802719e-05 + 28640 2100.2667 0.00019227949 5.4072056e-05 + 28660 2101.7333 0.00019209613 5.4088674e-05 + 28680 2103.2 0.00019190237 5.4104871e-05 + 28700 2104.6667 0.00019169556 5.4118777e-05 + 28720 2106.1333 0.00019147409 5.4129434e-05 + 28740 2107.6 0.00019123755 5.4109248e-05 + 28760 2109.0667 0.00019098676 5.4095416e-05 + 28780 2110.5333 0.00019072352 5.40944e-05 + 28800 2112 0.0001904505 5.4089923e-05 + 28820 2113.4667 0.00019017109 5.4081987e-05 + 28840 2114.9333 0.00018988915 5.4070363e-05 + 28860 2116.4 0.00018960886 5.4054643e-05 + 28880 2117.8667 0.00018933429 5.4034314e-05 + 28900 2119.3333 0.00018906938 5.4008966e-05 + 28920 2120.8 0.00018881786 5.3978254e-05 + 28940 2122.2667 0.00018858319 5.3942187e-05 + 28960 2123.7333 0.00018836835 5.3901318e-05 + 28980 2125.2 0.00018817583 5.4169759e-05 + 29000 2126.6667 0.00018800763 5.4121319e-05 + 29020 2128.1333 0.00018786525 5.4070295e-05 + 29040 2129.6 0.00018774951 5.4018165e-05 + 29060 2131.0667 0.00018766058 5.3884893e-05 + 29080 2132.5333 0.00018759795 5.3876376e-05 + 29100 2134 0.00018756047 5.3823317e-05 + 29120 2135.4667 0.00018754627 5.3770657e-05 + 29140 2136.9333 0.00018755268 5.3718045e-05 + 29160 2138.4 0.00018757627 5.3665402e-05 + 29180 2139.8667 0.00018761287 5.3612408e-05 + 29200 2141.3333 0.00018765753 5.3558506e-05 + 29220 2142.8 0.0001877046 5.3503291e-05 + 29240 2144.2667 0.00018774817 5.3446796e-05 + 29260 2145.7333 0.00018778315 5.3389512e-05 + 29280 2147.2 0.00018780643 5.3332431e-05 + 29300 2148.6667 0.00018781742 5.3277223e-05 + 29320 2150.1333 0.00018781793 5.3226314e-05 + 29340 2151.6 0.00018781143 5.3176641e-05 + 29360 2153.0667 0.00018780238 5.3141246e-05 + 29380 2154.5333 0.00018779594 5.3117607e-05 + 29400 2156 0.00018779765 5.310825e-05 + 29420 2157.4667 0.0001878128 5.3115468e-05 + 29440 2158.9333 0.00018784561 5.3139946e-05 + 29460 2160.4 0.00018789868 5.288786e-05 + 29480 2161.8667 0.00018797309 5.294168e-05 + 29500 2163.3333 0.00018806883 5.3008359e-05 + 29520 2164.8 0.0001881852 5.3085712e-05 + 29540 2166.2667 0.000188321 5.317109e-05 + 29560 2167.7333 0.00018847475 5.3261964e-05 + 29580 2169.2 0.00018864479 5.3217461e-05 + 29600 2170.6667 0.00018882945 5.3313718e-05 + 29620 2172.1333 0.00018902706 5.3374367e-05 + 29640 2173.6 0.00018923607 5.347584e-05 + 29660 2175.0667 0.00018945509 5.3579085e-05 + 29680 2176.5333 0.000189683 5.3683544e-05 + 29700 2178 0.00018991893 5.3789562e-05 + 29720 2179.4667 0.00019016223 5.3898155e-05 + 29740 2180.9333 0.00019041244 5.4010173e-05 + 29760 2182.4 0.00019066923 5.4125994e-05 + 29780 2183.8667 0.00019093232 5.4245712e-05 + 29800 2185.3333 0.00019120142 5.436933e-05 + 29820 2186.8 0.00019147625 5.449677e-05 + 29840 2188.2667 0.00019175653 5.4627812e-05 + 29860 2189.7333 0.00019204205 5.476186e-05 + 29880 2191.2 0.00019233262 5.4897917e-05 + 29900 2192.6667 0.00019262806 5.5034988e-05 + 29920 2194.1333 0.00019292829 5.5172428e-05 + 29940 2195.6 0.00019323338 5.5309532e-05 + 29960 2197.0667 0.0001935435 5.5445368e-05 + 29980 2198.5333 0.00019385897 5.5579065e-05 + 30000 2200 0.00019418014 5.5710007e-05 +Loop time of 120.806 on 4 procs for 30000 steps with 3046 atoms + +Performance: 1573425.361 tau/day, 248.331 timesteps/s, 756.416 katom-step/s +99.3% CPU use with 4 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.89764 | 12.463 | 25.361 | 316.2 | 10.32 +Neigh | 0.083839 | 0.94363 | 1.8654 | 87.4 | 0.78 +Comm | 0.23436 | 0.25427 | 0.27244 | 2.9 | 0.21 +Output | 1.2745 | 2.0289 | 2.7205 | 46.3 | 1.68 +Modify | 88.101 | 92.266 | 95.765 | 34.6 | 76.38 +Other | | 12.85 | | | 10.64 + +Nlocal: 761.5 ave 1685 max 105 min +Histogram: 2 0 0 0 0 0 1 0 0 1 +Nghost: 28.5 ave 51 max 7 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 6128.5 ave 14174 max 567 min +Histogram: 2 0 0 0 0 0 1 0 0 1 +FullNghs: 12164 ave 28184 max 1117 min +Histogram: 2 0 0 0 0 0 1 0 0 1 + +Total # of neighbors = 48656 +Ave neighs/atom = 15.973736 +Neighbor list builds = 3012 +Dangerous builds = 0 + +Total wall time: 0:02:00 diff --git a/examples/rheo/ice-cubes/in.rheo.ice.cubes b/examples/rheo/ice-cubes/in.rheo.ice.cubes index b023a8bac9..91e02c780d 100644 --- a/examples/rheo/ice-cubes/in.rheo.ice.cubes +++ b/examples/rheo/ice-cubes/in.rheo.ice.cubes @@ -77,5 +77,6 @@ compute nbond all nbond/atom thermo 200 thermo_style custom step time ke press atoms -dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond c_rho +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond c_rho + run 30000 diff --git a/examples/rheo/ice-cubes/log.17Apr2024.ice.g++.4 b/examples/rheo/ice-cubes/log.17Apr2024.ice.g++.4 new file mode 100644 index 0000000000..98fc2e7540 --- /dev/null +++ b/examples/rheo/ice-cubes/log.17Apr2024.ice.g++.4 @@ -0,0 +1,379 @@ +LAMMPS (17 Apr 2024 - Development - patch_5May2020-18508-g3c0eaf6870-modified) +# ------ 2D Ice Cube Pour ------ # + +dimension 2 +units lj +atom_style hybrid rheo/thermal bond +boundary m m p +comm_modify vel yes +newton off +special_bonds lj 0.0 1.0 1.0 coul 1.0 1.0 1.0 + +region box block -25 25 0 100 -0.01 0.01 units box +create_box 1 box bond/types 1 extra/bond/per/atom 15 extra/special/per/atom 50 +Created orthogonal box = (-25 0 -0.01) to (25 100 0.01) + 2 by 2 by 1 MPI processor grid + +region fluid block $(xlo+1) $(xhi-1) $(ylo+1) $(ylo+30) EDGE EDGE units box +region fluid block -24 $(xhi-1) $(ylo+1) $(ylo+30) EDGE EDGE units box +region fluid block -24 24 $(ylo+1) $(ylo+30) EDGE EDGE units box +region fluid block -24 24 1 $(ylo+30) EDGE EDGE units box +region fluid block -24 24 1 30 EDGE EDGE units box +lattice sq 1.0 +Lattice spacing in x,y,z = 1 1 1 +create_atoms 1 region fluid +Created 1470 atoms + using lattice units in orthogonal box = (-25 0 -0.01) to (25 100 0.01) + create_atoms CPU = 0.001 seconds + +set group all sph/e 8.0 +Setting atom values ... + 1470 settings made for sph/e + +# ------ Model parameters ------# + +variable cut equal 3.0 +variable n equal 1.0 +variable rho0 equal 1.0 +variable cs equal 1.0 +variable mp equal ${rho0}/${n} +variable mp equal 1/${n} +variable mp equal 1/1 +variable zeta equal 0.05 +variable kappa equal 0.01*${rho0}/${mp} +variable kappa equal 0.01*1/${mp} +variable kappa equal 0.01*1/1 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable dt_max equal 0.1*3/${cs}/3 +variable dt_max equal 0.1*3/1/3 +variable eta equal 0.05 +variable Cv equal 1.0 +variable L equal 1.0 +variable Tf equal 1.0 + +mass * ${mp} +mass * 1 +timestep 0.1 + +pair_style hybrid/overlay rheo ${cut} artificial/visc ${zeta} rheo/solid +pair_style hybrid/overlay rheo 3 artificial/visc ${zeta} rheo/solid +pair_style hybrid/overlay rheo 3 artificial/visc 0.05 rheo/solid +pair_coeff * * rheo +pair_coeff * * rheo/solid 1.0 1.0 1.0 + +bond_style bpm/spring +bond_coeff 1 1.0 1.0 1.0 + +# ------ Pour particles ------# + +molecule my_mol "square.mol" +Read molecule template my_mol: +#Made with create_mol.py + 1 molecules + 0 fragments + 100 atoms with max type 1 + 342 bonds with max type 1 + 0 angles with max type 0 + 0 dihedrals with max type 0 + 0 impropers with max type 0 + +# Wall region extends far enough in z to avoid contact +region wall block EDGE EDGE EDGE EDGE -5 5 side in open 4 units box +region drop block -16 16 70 90 EDGE EDGE side in units box + +fix 1 all rheo ${cut} quintic 0 thermal shift surface/detection coordination 22 8 +fix 1 all rheo 3 quintic 0 thermal shift surface/detection coordination 22 8 +fix 2 all rheo/viscosity * constant ${eta} +fix 2 all rheo/viscosity * constant 0.05 +fix 3 all rheo/pressure * linear +fix 4 all rheo/thermal conductivity * constant ${kappa} specific/heat * constant ${Cv} Tfreeze * constant ${Tf} latent/heat * constant ${L} react 1.5 1 +fix 4 all rheo/thermal conductivity * constant 0.01 specific/heat * constant ${Cv} Tfreeze * constant ${Tf} latent/heat * constant ${L} react 1.5 1 +fix 4 all rheo/thermal conductivity * constant 0.01 specific/heat * constant 1 Tfreeze * constant ${Tf} latent/heat * constant ${L} react 1.5 1 +fix 4 all rheo/thermal conductivity * constant 0.01 specific/heat * constant 1 Tfreeze * constant 1 latent/heat * constant ${L} react 1.5 1 +fix 4 all rheo/thermal conductivity * constant 0.01 specific/heat * constant 1 Tfreeze * constant 1 latent/heat * constant 1 react 1.5 1 +fix 5 all wall/region wall harmonic 1.0 1.0 1.0 +fix 6 all gravity 5e-4 vector 0 -1 0 +fix 7 all deposit 8 0 1000 37241459 mol my_mol region drop near 2.0 vy -0.02 -0.02 +WARNING: Molecule attributes do not match system attributes (../molecule.cpp:1881) +fix 8 all enforce2d + +compute rho all rheo/property/atom rho +compute phase all rheo/property/atom phase +compute temp all rheo/property/atom temperature +compute eng all rheo/property/atom energy +compute nbond all nbond/atom + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press atoms + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond c_rho + +run 30000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- BPM bond style: doi:10.1039/D3SM01373A + +@Article{Clemmer2024, + author = {Clemmer, Joel T. and Monti, Joseph M. and Lechman, Jeremy B.}, + title = {A soft departure from jamming: the compaction of deformable + granular matter under high pressures}, + journal = {Soft Matter}, + year = 2024, + volume = 20, + number = 8, + pages = {1702--1718} +} + +- @article{PalermoInPrep, + journal = {in prep}, + title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows}, + year = {2024}, + author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor}, +} + +- @article{ApplMathModel.130.310, + title = {A hybrid smoothed-particle hydrodynamics model of oxide skins on molten aluminum}, + journal = {Applied Mathematical Modelling}, + volume = {130}, + pages = {310-326}, + year = {2024}, + issn = {0307-904X}, + doi = {https://doi.org/10.1016/j.apm.2024.02.027}, + author = {Joel T. Clemmer and Flint Pierce and Thomas C. O'Connor and Thomas D. Nevins and Elizabeth M.C. Jones and Jeremy B. Lechman and John Tencer}, +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.3 + ghost atom cutoff = 3.3 + binsize = 1.65, bins = 31 61 1 + 7 neighbor lists, perpetual/occasional/extra = 6 1 0 + (1) pair rheo, perpetual, half/full from (3) + attributes: half, newton off + pair build: halffull/newtoff + stencil: none + bin: none + (2) pair rheo/solid, perpetual, trim from (4) + attributes: half, newton off, cut 1.3 + pair build: trim + stencil: none + bin: none + (3) compute RHEO/KERNEL, perpetual + attributes: full, newton off + pair build: full/bin + stencil: full/bin/2d + bin: standard + (4) compute RHEO/GRAD, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (5) compute RHEO/VSHIFT, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (6) compute RHEO/SURFACE, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (7) fix rheo/thermal, occasional, trim from (4) + attributes: half, newton off, cut 3 + pair build: trim + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 15.53 | 15.61 | 15.69 Mbytes + Step Time KinEng Press Atoms + 0 0 0 0 1470 + 200 20 5.6002982e-05 3.4434234e-05 1570 + 400 40 8.2173099e-05 8.6171768e-05 1570 + 600 60 8.019018e-05 0.00010750355 1570 + 800 80 0.00013866953 0.00010265608 1570 + 1000 100 0.00018965028 8.1985605e-05 1570 + 1200 120 0.00022033242 7.4736443e-05 1670 + 1400 140 0.00030767062 0.00011264333 1670 + 1600 160 0.00040770127 0.00018779992 1670 + 1800 180 0.00047476332 0.00023153009 1670 + 2000 200 0.00059116774 0.00027200445 1670 + 2200 220 0.0007151733 0.0002919963 1770 + 2400 240 0.00083392135 0.00029757889 1770 + 2600 260 0.00099653466 0.00036547269 1770 + 2800 280 0.0011964069 0.00045983458 1770 + 3000 300 0.0013716953 0.00055013647 1770 + 3200 320 0.0015174096 0.00064203572 1870 + 3400 340 0.0016539743 0.00086671622 1870 + 3600 360 0.0015887858 0.00066353749 1870 + 3800 380 0.0016451684 0.00070551483 1870 + 4000 400 0.0017330971 0.00080722283 1870 + 4200 420 0.001812193 0.00073573903 1970 + 4400 440 0.001755871 0.0010621909 1970 + 4600 460 0.0016190772 0.00072913706 1970 + 4800 480 0.0015741931 0.00073524088 1970 + 5000 500 0.0016488815 0.00088684275 1970 + 5200 520 0.0017213288 0.00077042378 2070 + 5400 540 0.0018509598 0.0010219434 2070 + 5600 560 0.0020251064 0.00083182483 2070 + 5800 580 0.0022473255 0.00095076144 2070 + 6000 600 0.0024843519 0.0011247014 2070 + 6200 620 0.0022282321 0.0018105932 2170 + 6400 640 0.0020289063 0.0014158497 2170 + 6600 660 0.002145241 0.0011359383 2170 + 6800 680 0.0024313937 0.0016475504 2170 + 7000 700 0.0021000599 0.0020983745 2170 + 7200 720 0.0019137235 0.0010439152 2270 + 7400 740 0.0018801367 0.00095436448 2270 + 7600 760 0.0017979449 0.0011184039 2270 + 7800 780 0.0018005205 0.0009243205 2270 + 8000 800 0.0017827073 0.0013671228 2270 + 8200 820 0.0018387108 0.0015426012 2270 + 8400 840 0.0016000788 0.0016751514 2270 + 8600 860 0.0013954964 0.0016884335 2270 + 8800 880 0.0013283728 0.0012399398 2270 + 9000 900 0.001389385 0.0012968496 2270 + 9200 920 0.0012295438 0.0012995821 2270 + 9400 940 0.0010522655 0.00082245528 2270 + 9600 960 0.00097085496 0.00053833131 2270 + 9800 980 0.0009398987 0.00063467387 2270 + 10000 1000 0.00092710392 0.00059494446 2270 + 10200 1020 0.00095545471 0.00074560644 2270 + 10400 1040 0.0009645841 0.00085429807 2270 + 10600 1060 0.00064037148 0.0017222246 2270 + 10800 1080 0.00046790978 0.00088204234 2270 + 11000 1100 0.00030106229 0.00074950209 2270 + 11200 1120 0.00027746016 0.00052831745 2270 + 11400 1140 0.0002533348 0.0006272715 2270 + 11600 1160 0.00021825085 0.00029691552 2270 + 11800 1180 0.0001451308 0.00015037478 2270 + 12000 1200 0.0001314823 0.00017227174 2270 + 12200 1220 0.00013693632 0.00017791384 2270 + 12400 1240 0.00014987347 0.0002286677 2270 + 12600 1260 0.00015092598 0.0003698436 2270 + 12800 1280 0.0001291653 0.00047229532 2270 + 13000 1300 0.00011949988 0.00049560375 2270 + 13200 1320 0.00011694665 0.00057542084 2270 + 13400 1340 9.6164519e-05 0.00062714755 2270 + 13600 1360 8.4517591e-05 0.00044156913 2270 + 13800 1380 0.00019140516 0.0003264745 2270 + 14000 1400 0.00013868599 0.00037753497 2270 + 14200 1420 9.3701636e-05 0.00031517848 2270 + 14400 1440 6.7389077e-05 0.0002946861 2270 + 14600 1460 5.3640086e-05 0.00026650711 2270 + 14800 1480 4.2699992e-05 0.00023789279 2270 + 15000 1500 5.3012016e-05 0.00019933234 2270 + 15200 1520 5.8834197e-05 0.00022407007 2270 + 15400 1540 5.0899982e-05 0.00029695531 2270 + 15600 1560 3.0476742e-05 0.00039119066 2270 + 15800 1580 1.6633264e-05 0.00033770401 2270 + 16000 1600 1.098906e-05 0.00036684894 2270 + 16200 1620 1.464848e-05 0.00036449759 2270 + 16400 1640 1.9598429e-05 0.00021056689 2270 + 16600 1660 1.2644955e-05 0.00020781781 2270 + 16800 1680 8.8428553e-06 0.000165 2270 + 17000 1700 8.8971439e-06 0.00012266475 2270 + 17200 1720 1.7032781e-05 0.00019873443 2270 + 17400 1740 1.9448563e-05 0.00025661663 2270 + 17600 1760 1.3714713e-05 0.000324022 2270 + 17800 1780 9.1326468e-06 0.00031392513 2270 + 18000 1800 9.2464802e-06 0.00029729527 2270 + 18200 1820 1.5553042e-05 0.00027488475 2270 + 18400 1840 1.4132933e-05 0.00019565459 2270 + 18600 1860 9.4734832e-06 0.00016716988 2270 + 18800 1880 5.5115145e-06 0.00013728033 2270 + 19000 1900 8.268812e-06 0.00015119605 2270 + 19200 1920 1.2470136e-05 0.00020222131 2270 + 19400 1940 9.9387775e-06 0.00024503373 2270 + 19600 1960 5.4241999e-06 0.00026921858 2270 + 19800 1980 2.7987348e-06 0.00026201267 2270 + 20000 2000 6.272538e-06 0.00025626323 2270 + 20200 2020 8.0157781e-06 0.000220139 2270 + 20400 2040 6.1652093e-06 0.00017089058 2270 + 20600 2060 2.9967592e-06 0.00014582864 2270 + 20800 2080 3.016678e-06 0.000148629 2270 + 21000 2100 7.287645e-06 0.00016486102 2270 + 21200 2120 8.6905277e-06 0.00020276916 2270 + 21400 2140 6.8453018e-06 0.00023156153 2270 + 21600 2160 3.3853799e-06 0.0002432462 2270 + 21800 2180 4.1241209e-06 0.00022829024 2270 + 22000 2200 7.0802396e-06 0.00020784823 2270 + 22200 2220 7.3361691e-06 0.00018114134 2270 + 22400 2240 5.0764593e-06 0.00014351106 2270 + 22600 2260 2.7487537e-06 0.00012919872 2270 + 22800 2280 4.620167e-06 0.00013746218 2270 + 23000 2300 6.9819357e-06 0.00015985102 2270 + 23200 2320 6.8923916e-06 0.00018713045 2270 + 23400 2340 4.1795088e-06 0.00019846682 2270 + 23600 2360 2.2871028e-06 0.00021068421 2270 + 23800 2380 3.862046e-06 0.00019553306 2270 + 24000 2400 5.2448555e-06 0.00017398041 2270 + 24200 2420 4.7565441e-06 0.00015008142 2270 + 24400 2440 2.2952135e-06 0.00012747106 2270 + 24600 2460 2.1575617e-06 0.00012516996 2270 + 24800 2480 4.1777868e-06 0.0001331902 2270 + 25000 2500 5.5679133e-06 0.00015504562 2270 + 25200 2520 4.5758741e-06 0.00017146032 2270 + 25400 2540 2.3403277e-06 0.00017611666 2270 + 25600 2560 2.7029302e-06 0.00016850788 2270 + 25800 2580 4.3601102e-06 0.00015884642 2270 + 26000 2600 5.2244249e-06 0.00013793898 2270 + 26200 2620 3.4577672e-06 0.00012395875 2270 + 26400 2640 2.361577e-06 0.00011600057 2270 + 26600 2660 2.8515644e-06 0.00011277063 2270 + 26800 2680 4.0851213e-06 0.0001290832 2270 + 27000 2700 4.2579644e-06 0.0001476495 2270 + 27200 2720 2.6593858e-06 0.00015977745 2270 + 27400 2740 1.990115e-06 0.00015612787 2270 + 27600 2760 2.6756835e-06 0.00014913772 2270 + 27800 2780 3.9032806e-06 0.00014014763 2270 + 28000 2800 3.2729446e-06 0.00012216846 2270 + 28200 2820 1.9357278e-06 0.00011078621 2270 + 28400 2840 1.7094832e-06 0.00010910509 2270 + 28600 2860 2.8731406e-06 0.00011179644 2270 + 28800 2880 3.7062354e-06 0.00012254091 2270 + 29000 2900 2.7844262e-06 0.00013060331 2270 + 29200 2920 1.7680655e-06 0.00013797514 2270 + 29400 2940 1.706873e-06 0.0001350685 2270 + 29600 2960 2.8764562e-06 0.00012428508 2270 + 29800 2980 3.1502029e-06 0.00011456718 2270 + 30000 3000 2.1833409e-06 0.00010317469 2270 +Loop time of 165.611 on 4 procs for 30000 steps with 2270 atoms + +Performance: 1565111.240 tau/day, 181.147 timesteps/s, 411.204 katom-step/s +99.7% CPU use with 4 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.63183 | 21.226 | 42.266 | 444.6 | 12.82 +Bond | 0.095073 | 0.17799 | 0.27877 | 17.0 | 0.11 +Neigh | 2.0745 | 2.0781 | 2.0822 | 0.2 | 1.25 +Comm | 0.32024 | 0.38703 | 0.45564 | 8.1 | 0.23 +Output | 0.60459 | 0.76798 | 0.93724 | 18.6 | 0.46 +Modify | 119.85 | 140.76 | 161.36 | 172.2 | 85.00 +Other | | 0.2124 | | | 0.13 + +Nlocal: 567.5 ave 1139 max 0 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Nghost: 75.5 ave 152 max 0 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 9238.25 ave 18490 max 0 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +FullNghs: 17945 ave 35917 max 0 min +Histogram: 2 0 0 0 0 0 0 0 0 2 + +Total # of neighbors = 71780 +Ave neighs/atom = 31.621145 +Ave special neighs/atom = 0.22026432 +Neighbor list builds = 2071 +Dangerous builds = 0 + +Total wall time: 0:02:45 diff --git a/examples/rheo/oxidation/in.rheo.oxidation b/examples/rheo/oxidation/in.rheo.oxidation index d26b379adb..d8b4b1a464 100644 --- a/examples/rheo/oxidation/in.rheo.oxidation +++ b/examples/rheo/oxidation/in.rheo.oxidation @@ -98,5 +98,6 @@ compute nbond_solid all nbond/atom bond/type 1 thermo 200 thermo_style custom step time ke press atoms -dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond_solid c_nbond_shell c_rho c_surf c_status +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond_solid c_nbond_shell c_rho c_surf c_status + run 40000 diff --git a/examples/rheo/oxidation/log.17Apr2024.oxidation.g++.4 b/examples/rheo/oxidation/log.17Apr2024.oxidation.g++.4 new file mode 100644 index 0000000000..92eb4aa94a --- /dev/null +++ b/examples/rheo/oxidation/log.17Apr2024.oxidation.g++.4 @@ -0,0 +1,488 @@ +LAMMPS (17 Apr 2024 - Development - patch_5May2020-18508-g3c0eaf6870-modified) +# ------ 2D oxidizing bar ------ # + +dimension 2 +units lj +atom_style hybrid rheo/thermal bond +boundary m m p +comm_modify vel yes +newton off + +region box block -60 60 0 80 -0.01 0.01 units box +create_box 3 box bond/types 2 extra/bond/per/atom 20 extra/special/per/atom 50 +Created orthogonal box = (-60 0 -0.01) to (60 80 0.01) + 2 by 2 by 1 MPI processor grid + +region lbar block -15 0 3 80 EDGE EDGE units box +region rbar block 0 15 3 80 EDGE EDGE units box +region bar union 2 lbar rbar +region floor block EDGE EDGE EDGE 3.0 EDGE EDGE units box + +lattice hex 1.0 +Lattice spacing in x,y,z = 1.0745699 1.8612097 1.0745699 +create_atoms 1 region bar +Created 2255 atoms + using lattice units in orthogonal box = (-60 0 -0.01) to (60 80 0.01) + create_atoms CPU = 0.001 seconds +create_atoms 3 region floor +Created 446 atoms + using lattice units in orthogonal box = (-60 0 -0.01) to (60 80 0.01) + create_atoms CPU = 0.000 seconds + +set region rbar type 2 +Setting atom values ... + 1148 settings made for type +group bar type 1 2 +2255 atoms in group bar +group rbar type 2 +1148 atoms in group rbar +group floor type 3 +446 atoms in group floor + +set group all sph/e 0.0 +Setting atom values ... + 2701 settings made for sph/e +set group all rheo/status 1 +Setting atom values ... + 2701 settings made for rheo/status + +# ------ Model parameters ------# + +variable cut equal 3.0 +variable n equal 1.0 +variable rho0 equal 1.0 +variable cs equal 1.0 +variable mp equal ${rho0}/${n} +variable mp equal 1/${n} +variable mp equal 1/1 +variable zeta equal 0.05 +variable kappa equal 0.1*${rho0}/${mp} +variable kappa equal 0.1*1/${mp} +variable kappa equal 0.1*1/1 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable dt_max equal 0.1*3/${cs}/3 +variable dt_max equal 0.1*3/1/3 +variable eta equal 0.05 +variable Cv equal 1.0 +variable L equal 0.1 +variable Tf equal 1.0 + +mass * ${mp} +mass * 1 +timestep 0.1 + +pair_style hybrid/overlay rheo ${cut} artificial/visc ${zeta} rheo/solid +pair_style hybrid/overlay rheo 3 artificial/visc ${zeta} rheo/solid +pair_style hybrid/overlay rheo 3 artificial/visc 0.05 rheo/solid +pair_coeff * * rheo +pair_coeff * * rheo/solid 1.0 1.0 1.0 + +special_bonds lj 0.0 1.0 1.0 coul 0.0 1.0 1.0 +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0 1 1 + special bond factors coul: 0 1 1 + 0 = max # of 1-2 neighbors + 101 = max # of special neighbors + special bonds CPU = 0.000 seconds +create_bonds many bar bar 1 0 1.5 +Generated 0 of 3 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.3 + ghost atom cutoff = 3.3 + binsize = 1.65, bins = 73 49 1 + 3 neighbor lists, perpetual/occasional/extra = 2 1 0 + (1) command create_bonds, occasional + attributes: full, newton off + pair build: full/bin + stencil: full/bin/2d + bin: standard + (2) pair rheo, perpetual + attributes: half, newton off + pair build: half/bin/newtoff + stencil: full/bin/2d + bin: standard + (3) pair rheo/solid, perpetual, trim from (2) + attributes: half, newton off, cut 1.3 + pair build: trim + stencil: none + bin: none +Added 6547 bonds, new total = 6547 +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0 1 1 + special bond factors coul: 0 1 1 + 6 = max # of 1-2 neighbors + 101 = max # of special neighbors + special bonds CPU = 0.000 seconds +special_bonds lj 0.0 1.0 1.0 coul 1.0 1.0 1.0 + +bond_style hybrid bpm/spring rheo/shell t/form 100 +bond_coeff 1 bpm/spring 1.0 1.0 1.0 +bond_coeff 2 rheo/shell 0.2 0.2 0.1 + +# ------ Apply dynamics ------# + +# Note: surface detection is not performed on solid bodies, so cannot use surface property +compute coord all rheo/property/atom coordination +variable surf atom c_coord<22 +group surf dynamic all var surf every 10 +dynamic group surf defined + +fix 1 all rheo ${cut} quintic 0 thermal shift surface/detection coordination 22 8 +fix 1 all rheo 3 quintic 0 thermal shift surface/detection coordination 22 8 +fix 2 all rheo/viscosity * constant ${eta} +fix 2 all rheo/viscosity * constant 0.05 +fix 3 all rheo/pressure * linear +fix 4 all rheo/thermal conductivity * constant ${kappa} specific/heat * constant ${Cv} Tfreeze * constant ${Tf} latent/heat * constant ${L} react 1.5 1 +fix 4 all rheo/thermal conductivity * constant 0.1 specific/heat * constant ${Cv} Tfreeze * constant ${Tf} latent/heat * constant ${L} react 1.5 1 +fix 4 all rheo/thermal conductivity * constant 0.1 specific/heat * constant 1 Tfreeze * constant ${Tf} latent/heat * constant ${L} react 1.5 1 +fix 4 all rheo/thermal conductivity * constant 0.1 specific/heat * constant 1 Tfreeze * constant 1 latent/heat * constant ${L} react 1.5 1 +fix 4 all rheo/thermal conductivity * constant 0.1 specific/heat * constant 1 Tfreeze * constant 1 latent/heat * constant 0.1 react 1.5 1 + +fix 5 rbar rheo/oxidation 1.5 2 1.0 +fix 6 all wall/harmonic ylo EDGE 2.0 1.0 1.0 +fix 7 all gravity 5e-5 vector 0 -1 0 +fix 8 floor setforce 0.0 0.0 0.0 +fix 9 surf add/heat linear 1.1 0.05 +fix 10 floor add/heat constant 0 overwrite yes # fix the temperature of the floor +fix 11 all enforce2d + +compute surf all rheo/property/atom surface +compute rho all rheo/property/atom rho +compute phase all rheo/property/atom phase +compute status all rheo/property/atom status +compute temp all rheo/property/atom temperature +compute eng all rheo/property/atom energy +compute nbond_shell all rheo/property/atom nbond/shell +compute nbond_solid all nbond/atom bond/type 1 + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press atoms + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond_solid c_nbond_shell c_rho c_surf c_status + +run 40000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- BPM bond style: doi:10.1039/D3SM01373A + +@Article{Clemmer2024, + author = {Clemmer, Joel T. and Monti, Joseph M. and Lechman, Jeremy B.}, + title = {A soft departure from jamming: the compaction of deformable + granular matter under high pressures}, + journal = {Soft Matter}, + year = 2024, + volume = 20, + number = 8, + pages = {1702--1718} +} + +- @article{PalermoInPrep, + journal = {in prep}, + title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows}, + year = {2024}, + author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor}, +} + +- @article{ApplMathModel.130.310, + title = {A hybrid smoothed-particle hydrodynamics model of oxide skins on molten aluminum}, + journal = {Applied Mathematical Modelling}, + volume = {130}, + pages = {310-326}, + year = {2024}, + issn = {0307-904X}, + doi = {https://doi.org/10.1016/j.apm.2024.02.027}, + author = {Joel T. Clemmer and Flint Pierce and Thomas C. O'Connor and Thomas D. Nevins and Elizabeth M.C. Jones and Jeremy B. Lechman and John Tencer}, +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 3 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.3 + ghost atom cutoff = 3.3 + binsize = 1.65, bins = 73 49 1 + 8 neighbor lists, perpetual/occasional/extra = 7 1 0 + (1) pair rheo, perpetual, half/full from (3) + attributes: half, newton off + pair build: halffull/newtoff + stencil: none + bin: none + (2) pair rheo/solid, perpetual, trim from (4) + attributes: half, newton off, cut 1.3 + pair build: trim + stencil: none + bin: none + (3) compute RHEO/KERNEL, perpetual + attributes: full, newton off + pair build: full/bin + stencil: full/bin/2d + bin: standard + (4) compute RHEO/GRAD, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (5) compute RHEO/VSHIFT, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (6) compute RHEO/SURFACE, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (7) fix rheo/thermal, occasional, trim from (4) + attributes: half, newton off, cut 3 + pair build: trim + stencil: none + bin: none + (8) fix rheo/oxidation, perpetual, trim from (3) + attributes: full, newton off, cut 1.8 + pair build: trim + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 25.96 | 25.96 | 25.96 Mbytes + Step Time KinEng Press Atoms + 0 0 0 0 2701 + 200 20 4.1743799e-07 1.1743617e-07 2701 + 400 40 1.6697519e-06 4.6974469e-07 2701 + 600 60 3.7127333e-06 1.0646825e-05 2701 + 800 80 4.6683656e-06 0.00015182605 2701 + 1000 100 4.7368707e-06 0.00028128761 2701 + 1200 120 3.4384322e-06 0.00045913378 2701 + 1400 140 1.4119866e-06 0.00055627091 2701 + 1600 160 4.4114517e-07 0.00058247308 2701 + 1800 180 4.8289229e-07 0.0005510948 2701 + 2000 200 1.8494183e-06 0.00048386222 2701 + 2200 220 3.3319816e-06 0.00037903264 2701 + 2400 240 3.8128922e-06 0.00024115906 2701 + 2600 260 3.1943401e-06 9.727407e-05 2701 + 2800 280 1.6172816e-06 -2.632162e-05 2701 + 3000 300 3.6100709e-07 -8.5761867e-05 2701 + 3200 320 1.4745502e-07 -5.9204127e-05 2701 + 3400 340 8.3369782e-07 8.8312464e-07 2701 + 3600 360 2.0484052e-06 5.8521477e-05 2701 + 3800 380 3.1639387e-06 0.0001685663 2701 + 4000 400 3.1692907e-06 0.00026875988 2701 + 4200 420 2.391933e-06 0.00038621787 2701 + 4400 440 1.1964404e-06 0.00048901286 2701 + 4600 460 4.0508824e-07 0.00051863639 2701 + 4800 480 5.4908507e-07 0.00049263754 2701 + 5000 500 1.3139665e-06 0.00041984264 2701 + 5200 520 2.1939161e-06 0.00033095351 2701 + 5400 540 2.3687031e-06 0.00022422981 2701 + 5600 560 1.8280882e-06 0.00011544328 2701 + 5800 580 8.8610517e-07 2.9307791e-05 2701 + 6000 600 2.0989359e-07 -1.7340941e-05 2701 + 6200 620 2.8658301e-07 -8.1237835e-06 2701 + 6400 640 9.7636239e-07 4.3755922e-05 2701 + 6600 660 1.891303e-06 0.0001185719 2701 + 6800 680 2.4149904e-06 0.00020830273 2701 + 7000 700 2.3174953e-06 0.00030114767 2701 + 7200 720 1.7918612e-06 0.00037821537 2701 + 7400 740 1.2114987e-06 0.0004233475 2701 + 7600 760 9.9661553e-07 0.00042958263 2701 + 7800 780 1.1552559e-06 0.00039944618 2701 + 8000 800 1.5249138e-06 0.00034034478 2701 + 8200 820 1.7453861e-06 0.00026826463 2701 + 8400 840 1.6259021e-06 0.00019131768 2701 + 8600 860 1.2612805e-06 0.0001162957 2701 + 8800 880 8.6964518e-07 7.1771506e-05 2701 + 9000 900 7.6892472e-07 5.6170687e-05 2701 + 9200 920 1.0780045e-06 7.1925995e-05 2701 + 9400 940 1.6514902e-06 0.00011635293 2701 + 9600 960 2.1891377e-06 0.00017599885 2701 + 9800 980 2.4551701e-06 0.00024127934 2701 + 10000 1000 2.4277051e-06 0.00029918622 2701 + 10200 1020 2.2655987e-06 0.00034067996 2701 + 10400 1040 2.1767207e-06 0.00035598133 2701 + 10600 1060 2.2796719e-06 0.00034359076 2701 + 10800 1080 2.4884225e-06 0.00030749714 2701 + 11000 1100 2.6387215e-06 0.00025725198 2701 + 11200 1120 2.5968908e-06 0.00020170699 2701 + 11400 1140 2.4108931e-06 0.00015185858 2701 + 11600 1160 2.2375166e-06 0.00011800349 2701 + 11800 1180 2.2407196e-06 0.00010646971 2701 + 12000 1200 2.4845263e-06 0.00011817498 2701 + 12200 1220 2.8733204e-06 0.00015013186 2701 + 12400 1240 3.2437087e-06 0.00019211975 2701 + 12600 1260 3.4732728e-06 0.00023620276 2701 + 12800 1280 3.5836611e-06 0.00027352269 2701 + 13000 1300 3.6592211e-06 0.00029533734 2701 + 13200 1320 3.782506e-06 0.00030032559 2701 + 13400 1340 3.9807086e-06 0.00028395722 2701 + 13600 1360 4.2023176e-06 0.00025390325 2701 + 13800 1380 4.3559781e-06 0.00021794236 2701 + 14000 1400 4.4273371e-06 0.00018026034 2701 + 14200 1420 4.49867e-06 0.0001526569 2701 + 14400 1440 4.6591574e-06 0.00013707051 2701 + 14600 1460 4.9589583e-06 0.00013803875 2701 + 14800 1480 5.3859375e-06 0.00015455425 2701 + 15000 1500 5.8639557e-06 0.00017954785 2701 + 15200 1520 6.3075561e-06 0.0002084257 2701 + 15400 1540 6.7022179e-06 0.0002347669 2701 + 15600 1560 7.0789688e-06 0.00025020766 2701 + 15800 1580 7.4734777e-06 0.00025394845 2701 + 16000 1600 7.8884743e-06 0.00024571725 2701 + 16200 1620 8.3224059e-06 0.00022706648 2701 + 16400 1640 8.7337783e-06 0.00020320706 2701 + 16600 1660 9.1454649e-06 0.00017824346 2701 + 16800 1680 9.5948793e-06 0.00015961835 2701 + 17000 1700 1.0106407e-05 0.00015135471 2701 + 17200 1720 1.0707273e-05 0.00015166884 2701 + 17400 1740 1.1392597e-05 0.0001645916 2701 + 17600 1760 1.2118829e-05 0.00018119729 2701 + 17800 1780 1.2846056e-05 0.0002003616 2701 + 18000 1800 1.3555288e-05 0.00021585952 2701 + 18200 1820 1.4301024e-05 0.00022290158 2701 + 18400 1840 1.5089217e-05 0.00021970192 2701 + 18600 1860 1.5902351e-05 0.00020911128 2701 + 18800 1880 1.6753175e-05 0.00019278718 2701 + 19000 1900 1.7602996e-05 0.00017584076 2701 + 19200 1920 1.8479378e-05 0.00016206226 2701 + 19400 1940 1.9421603e-05 0.00015575677 2701 + 19600 1960 2.0477421e-05 0.00015687558 2701 + 19800 1980 2.1617288e-05 0.00016424998 2701 + 20000 2000 2.2814347e-05 0.00017466664 2701 + 20200 2020 2.4029097e-05 0.00018647149 2701 + 20400 2040 2.5255953e-05 0.00019516077 2701 + 20600 2060 2.649418e-05 0.00019906384 2701 + 20800 2080 2.7755897e-05 0.00019630586 2701 + 21000 2100 2.9067854e-05 0.00018674721 2701 + 21200 2120 3.0396477e-05 0.0001758048 2701 + 21400 2140 3.1759719e-05 0.00016782801 2701 + 21600 2160 3.3193597e-05 0.00016324138 2701 + 21800 2180 3.4729384e-05 0.00016124274 2701 + 22000 2200 3.6367594e-05 0.00016437457 2701 + 22200 2220 3.8095131e-05 0.00017015573 2701 + 22400 2240 3.9867003e-05 0.00017649465 2701 + 22600 2260 4.169511e-05 0.00018111374 2701 + 22800 2280 4.3566134e-05 0.00018104136 2701 + 23000 2300 4.5461538e-05 0.00017822707 2701 + 23200 2320 4.7377333e-05 0.00017285066 2701 + 23400 2340 4.9354403e-05 0.00016826524 2701 + 23600 2360 5.1399791e-05 0.00016517913 2701 + 23800 2380 5.3510931e-05 0.00016299649 2701 + 24000 2400 5.5681048e-05 0.00016256674 2701 + 24200 2420 5.7902429e-05 0.00016513449 2701 + 24400 2440 6.0216049e-05 0.00016895109 2701 + 24600 2460 6.270982e-05 0.00016946227 2701 + 24800 2480 6.5390117e-05 0.00016589426 2701 + 25000 2500 6.8121899e-05 0.00016241676 2701 + 25200 2520 7.0947331e-05 0.00015624292 2701 + 25400 2540 7.4304148e-05 0.0001449537 2701 + 25600 2560 7.7745077e-05 0.00013179658 2701 + 25800 2580 8.0739829e-05 0.00013098838 2701 + 26000 2600 8.3827874e-05 0.00014278841 2701 + 26200 2620 8.7060677e-05 0.00015381649 2701 + 26400 2640 9.0266508e-05 0.00016130999 2701 + 26600 2660 9.3339049e-05 0.00016908268 2701 + 26800 2680 9.6347013e-05 0.00016771087 2701 + 27000 2700 9.9294711e-05 0.00016577315 2701 + 27200 2720 0.00010230007 0.0001670893 2701 + 27400 2740 0.00010547172 0.00016569077 2701 + 27600 2760 0.00010872426 0.00016506303 2701 + 27800 2780 0.00011201844 0.00016482702 2701 + 28000 2800 0.00011532129 0.00016694886 2701 + 28200 2820 0.00011869854 0.00016163005 2701 + 28400 2840 0.00012209747 0.00015339281 2701 + 28600 2860 0.00012549322 0.00014765883 2701 + 28800 2880 0.00012898685 0.00014241765 2701 + 29000 2900 0.00013259039 0.00014215724 2701 + 29200 2920 0.00013628209 0.00014881155 2701 + 29400 2940 0.00014001213 0.00015671333 2701 + 29600 2960 0.00014379216 0.00016446215 2701 + 29800 2980 0.00014764687 0.0001639602 2701 + 30000 3000 0.00015142301 0.00015664816 2701 + 30200 3020 0.00015496407 0.00015545099 2701 + 30400 3040 0.00015797338 0.00015368625 2701 + 30600 3060 0.00016042141 0.00015679918 2701 + 30800 3080 0.00016244716 0.00016093678 2701 + 31000 3100 0.00016202247 0.00016066954 2701 + 31200 3120 0.0001613312 0.00015932059 2701 + 31400 3140 0.00016274961 0.00015988567 2701 + 31600 3160 0.00016541518 0.00015724809 2701 + 31800 3180 0.00016809362 0.00015498827 2701 + 32000 3200 0.00017067801 0.00014830489 2701 + 32200 3220 0.00017333906 0.00014371345 2701 + 32400 3240 0.0001759011 0.00014421259 2701 + 32600 3260 0.00017849952 0.00014228443 2701 + 32800 3280 0.00017801812 0.00014117391 2701 + 33000 3300 0.00017718857 0.00014644675 2701 + 33200 3320 0.00017833666 0.0001291286 2701 + 33400 3340 0.000178576 0.00014878558 2701 + 33600 3360 0.00017846711 0.00013905481 2701 + 33800 3380 0.00017822937 0.00015535996 2701 + 34000 3400 0.00017899663 0.00016094303 2701 + 34200 3420 0.00017924661 0.00015017553 2701 + 34400 3440 0.00018024855 0.00014723549 2701 + 34600 3460 0.00018143865 0.00013903131 2701 + 34800 3480 0.00018258173 0.00013722112 2701 + 35000 3500 0.00018404873 0.00014675949 2701 + 35200 3520 0.00018538521 0.00015108242 2701 + 35400 3540 0.00018669649 0.00014564852 2701 + 35600 3560 0.00018814608 0.00013762161 2701 + 35800 3580 0.00018967415 0.00014602307 2701 + 36000 3600 0.00019146735 0.000126909 2701 + 36200 3620 0.00019414036 0.00012384379 2701 + 36400 3640 0.00019613057 0.00011059573 2701 + 36600 3660 0.00019897104 0.00013621801 2701 + 36800 3680 0.00020169688 0.00013665462 2701 + 37000 3700 0.00020447655 0.00013929258 2701 + 37200 3720 0.00020711105 0.0001363895 2701 + 37400 3740 0.00021077854 0.00013610672 2701 + 37600 3760 0.00021303084 0.00015051235 2701 + 37800 3780 0.00021619561 0.00012664801 2701 + 38000 3800 0.0002194018 0.00012808247 2701 + 38200 3820 0.00022242646 0.0001360174 2701 + 38400 3840 0.00022531568 0.00013311221 2701 + 38600 3860 0.00022821731 0.00013523939 2701 + 38800 3880 0.000231228 0.00014090695 2701 + 39000 3900 0.00023404038 0.00013661835 2701 + 39200 3920 0.00023755044 0.00013659469 2701 + 39400 3940 0.00024009059 0.00012097907 2701 + 39600 3960 0.0002432098 9.7877876e-05 2701 + 39800 3980 0.00024475294 0.0001164688 2701 + 40000 4000 0.00024171274 0.00012432219 2701 +Loop time of 192.659 on 4 procs for 40000 steps with 2701 atoms + +Performance: 1793840.118 tau/day, 207.620 timesteps/s, 560.783 katom-step/s +99.6% CPU use with 4 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 16.881 | 24.402 | 30.74 | 114.6 | 12.67 +Bond | 1.1126 | 1.8917 | 2.6935 | 43.3 | 0.98 +Neigh | 35.387 | 35.508 | 35.625 | 1.5 | 18.43 +Comm | 1.5499 | 1.6694 | 1.8006 | 7.4 | 0.87 +Output | 0.99755 | 1.0072 | 1.0165 | 0.8 | 0.52 +Modify | 120.6 | 127.43 | 135.54 | 54.8 | 66.14 +Other | | 0.7553 | | | 0.39 + +Nlocal: 675.25 ave 1373 max 7 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Nghost: 103 ave 163 max 50 min +Histogram: 2 0 0 0 0 0 0 0 1 1 +Neighs: 10509 ave 21592 max 126 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +FullNghs: 20367 ave 41981 max 141 min +Histogram: 2 0 0 0 0 0 0 0 0 2 + +Total # of neighbors = 81468 +Ave neighs/atom = 30.162162 +Ave special neighs/atom = 1.6593854 +Neighbor list builds = 39932 +Dangerous builds = 0 + +Total wall time: 0:03:12 diff --git a/examples/rheo/poiseuille/in.rheo.poiseuille b/examples/rheo/poiseuille/in.rheo.poiseuille index 7c38c8a6e0..ec283d9a00 100644 --- a/examples/rheo/poiseuille/in.rheo.poiseuille +++ b/examples/rheo/poiseuille/in.rheo.poiseuille @@ -69,7 +69,7 @@ compute rho all rheo/property/atom rho thermo 200 thermo_style custom step time ke press -dump 1 all custom 200 atomDump id type x y vx vy fx fy c_rho +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_rho run 20000 diff --git a/examples/rheo/poiseuille/log.17Apr2024.poiseuille.g++.4 b/examples/rheo/poiseuille/log.17Apr2024.poiseuille.g++.4 new file mode 100644 index 0000000000..1fd8377b7a --- /dev/null +++ b/examples/rheo/poiseuille/log.17Apr2024.poiseuille.g++.4 @@ -0,0 +1,288 @@ +LAMMPS (17 Apr 2024 - Development - patch_5May2020-18508-g3c0eaf6870-modified) +# ------ 2D Poiseuille flow ------ # + +dimension 2 +units lj +atom_style rheo +boundary p p p +comm_modify vel yes + +# ------ Create simulation box ------ # + +variable n equal 1.0 +variable cut equal 3.0 + +region box block 0 20 -10 10 -0.01 0.01 +create_box 2 box +Created orthogonal box = (0 -10 -0.01) to (20 10 0.01) + 2 by 2 by 1 MPI processor grid +lattice sq ${n} +lattice sq 1 +Lattice spacing in x,y,z = 1 1 1 + +region inner block INF INF -7.5 7.5 INF INF units box +region walls block INF INF -7.5 7.5 INF INF units box side out + +create_atoms 2 region walls +Created 100 atoms + using lattice units in orthogonal box = (0 -10 -0.01) to (20 10 0.01) + create_atoms CPU = 0.000 seconds +create_atoms 1 region inner +Created 300 atoms + using lattice units in orthogonal box = (0 -10 -0.01) to (20 10 0.01) + create_atoms CPU = 0.000 seconds + +group fluid type 1 +300 atoms in group fluid +group rig type 2 +100 atoms in group rig + +displace_atoms fluid random 0.1 0.1 0 135414 units box +Displacing atoms ... + +# ------ Model parameters ------ # + +variable rho0 equal 1.0 +variable cs equal 1.0 +variable mp equal ${rho0}/${n} +variable mp equal 1/${n} +variable mp equal 1/1 +variable zeta equal 1.0 +variable kappa equal 1.0*${rho0}/${mp} +variable kappa equal 1.0*1/${mp} +variable kappa equal 1.0*1/1 +variable fext equal 1e-4/${n} +variable fext equal 1e-4/1 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable dt_max equal 0.1*3/${cs}/3 +variable dt_max equal 0.1*3/1/3 +variable Dr equal 0.05*${cut}*${cs} +variable Dr equal 0.05*3*${cs} +variable Dr equal 0.05*3*1 + +variable eta equal 0.1 +variable gd0 equal 5e-4 +variable npow equal 0.5 +variable K equal 0.001 + +mass * ${mp} +mass * 1 +set group all rheo/rho ${rho0} +set group all rheo/rho 1 +Setting atom values ... + 400 settings made for rheo/rho +set group all rheo/status 0 +Setting atom values ... + 400 settings made for rheo/status +set group rig rheo/status 1 +Setting atom values ... + 100 settings made for rheo/status + +timestep ${dt_max} +timestep 0.1 + +pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} +pair_style rheo 3 artificial/visc ${zeta} rho/damp ${Dr} +pair_style rheo 3 artificial/visc 1 rho/damp ${Dr} +pair_style rheo 3 artificial/visc 1 rho/damp 0.15 +pair_coeff * * + +# ------ Fixes & computes ------ # + +fix 1 all rheo ${cut} quintic 0 shift +fix 1 all rheo 3 quintic 0 shift +fix 2 all rheo/viscosity * constant ${eta} +fix 2 all rheo/viscosity * constant 0.1 +#fix 2 all rheo/viscosity * power ${eta} ${gd0} ${K} ${npow} +fix 3 all rheo/pressure * linear +fix 4 rig setforce 0.0 0.0 0.0 +fix 5 fluid addforce ${fext} 0.0 0.0 +fix 5 fluid addforce 0.0001 0.0 0.0 +fix 6 all enforce2d + +compute rho all rheo/property/atom rho + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_rho + +run 20000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- @article{PalermoInPrep, + journal = {in prep}, + title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows}, + year = {2024}, + author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor}, +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.3 + ghost atom cutoff = 3.3 + binsize = 1.65, bins = 13 13 1 + 4 neighbor lists, perpetual/occasional/extra = 4 0 0 + (1) pair rheo, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) compute RHEO/KERNEL, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (3) compute RHEO/GRAD, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none + (4) compute RHEO/VSHIFT, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 5.693 | 5.693 | 5.693 Mbytes + Step Time KinEng Press + 0 0 0 0 + 200 20 1.2220462e-06 3.7383146e-05 + 400 40 4.345762e-06 7.5866885e-05 + 600 60 8.8559433e-06 0.00011353743 + 800 80 1.4370506e-05 0.00015135634 + 1000 100 2.0576198e-05 0.00018903722 + 1200 120 2.721926e-05 0.00022533997 + 1400 140 3.4099653e-05 0.00026016069 + 1600 160 4.1064175e-05 0.00029445207 + 1800 180 4.8001225e-05 0.00032893763 + 2000 200 5.4832849e-05 0.00036402396 + 2200 220 6.1508431e-05 0.00039945249 + 2400 240 6.8000141e-05 0.00043534411 + 2600 260 7.430136e-05 0.00046943441 + 2800 280 8.0415328e-05 0.00049807225 + 3000 300 8.6335032e-05 0.00051815375 + 3200 320 9.2021626e-05 0.00052618224 + 3400 340 9.7387936e-05 0.00051877918 + 3600 360 0.00010231526 0.00048650828 + 3800 380 0.00010676617 0.00044578079 + 4000 400 0.00011080098 0.00044777126 + 4200 420 0.00011448127 0.00047047629 + 4400 440 0.00011787852 0.00050280249 + 4600 460 0.00012106805 0.0005397213 + 4800 480 0.00012412056 0.00057885539 + 5000 500 0.0001271078 0.00061396896 + 5200 520 0.00013006637 0.00063981812 + 5400 540 0.00013295039 0.00065094073 + 5600 560 0.00013561487 0.00063918847 + 5800 580 0.00013791796 0.00059087656 + 6000 600 0.00013983422 0.00052171998 + 6200 620 0.00014144833 0.00050658002 + 6400 640 0.00014286538 0.0005248626 + 6600 660 0.00014417734 0.00055826606 + 6800 680 0.00014546931 0.00060063748 + 7000 700 0.00014682553 0.00064421411 + 7200 720 0.0001482833 0.00068252242 + 7400 740 0.00014977996 0.00070671308 + 7600 760 0.00015114829 0.00069774026 + 7800 780 0.0001522719 0.00064408311 + 8000 800 0.00015312897 0.00055977044 + 8200 820 0.00015375669 0.0005225573 + 8400 840 0.00015425683 0.00053833691 + 8600 860 0.00015471278 0.00057447427 + 8800 880 0.0001552059 0.00061980921 + 9000 900 0.00015581593 0.0006659836 + 9200 920 0.0001565564 0.00070813532 + 9400 940 0.00015733573 0.00073378551 + 9600 960 0.00015802107 0.00071560835 + 9800 980 0.00015855339 0.00065636189 + 10000 1000 0.00015890743 0.0005699855 + 10200 1020 0.00015908095 0.00053138971 + 10400 1040 0.00015915523 0.00054790708 + 10600 1060 0.00015921254 0.00058899454 + 10800 1080 0.00015934193 0.00063964906 + 11000 1100 0.00015959891 0.00069241358 + 11200 1120 0.0001599636 0.00073734651 + 11400 1140 0.00016036526 0.00074477329 + 11600 1160 0.00016075471 0.00071047555 + 11800 1180 0.00016109516 0.00064173183 + 12000 1200 0.00016131524 0.00055500553 + 12200 1220 0.00016136366 0.0005290215 + 12400 1240 0.0001613025 0.00055124296 + 12600 1260 0.00016123023 0.00059758627 + 12800 1280 0.00016123043 0.00065488735 + 13000 1300 0.00016132935 0.0007140876 + 13200 1320 0.00016152165 0.00074795629 + 13400 1340 0.00016180372 0.00074730778 + 13600 1360 0.00016216585 0.00071370995 + 13800 1380 0.0001625339 0.00065176323 + 14000 1400 0.00016274999 0.00057515371 + 14200 1420 0.00016271295 0.00055878258 + 14400 1440 0.00016249768 0.00058448193 + 14600 1460 0.00016223675 0.00063096229 + 14800 1480 0.00016201846 0.00068639548 + 15000 1500 0.00016190593 0.00072444357 + 15200 1520 0.00016194466 0.00073830636 + 15400 1540 0.00016216164 0.00072773256 + 15600 1560 0.00016253174 0.00069215481 + 15800 1580 0.00016290895 0.00063239408 + 16000 1600 0.00016306463 0.00057466273 + 16200 1620 0.00016292218 0.00057951567 + 16400 1640 0.00016261117 0.00061504156 + 16600 1660 0.00016225906 0.00066066637 + 16800 1680 0.00016197993 0.00069751908 + 17000 1700 0.0001618568 0.00072202303 + 17200 1720 0.00016194264 0.00073255034 + 17400 1740 0.00016225911 0.0007231031 + 17600 1760 0.00016270465 0.00068931224 + 17800 1780 0.00016304053 0.00062934836 + 18000 1800 0.00016302624 0.00058060272 + 18200 1820 0.00016274847 0.00058859513 + 18400 1840 0.00016236893 0.00061804803 + 18600 1860 0.00016202777 0.00065393237 + 18800 1880 0.0001618184 0.00068747094 + 19000 1900 0.0001618044 0.00071352541 + 19200 1920 0.00016204402 0.00072351769 + 19400 1940 0.00016249999 0.00071330322 + 19600 1960 0.00016297924 0.00067984167 + 19800 1980 0.00016317435 0.00061634142 + 20000 2000 0.00016301186 0.00057234115 +Loop time of 15.6198 on 4 procs for 20000 steps with 400 atoms + +Performance: 11062881.511 tau/day, 1280.426 timesteps/s, 512.170 katom-step/s +99.7% CPU use with 4 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.1979 | 2.4473 | 2.6992 | 15.7 | 15.67 +Neigh | 0.024709 | 0.027006 | 0.029223 | 1.3 | 0.17 +Comm | 0.4657 | 0.71686 | 0.9662 | 29.0 | 4.59 +Output | 0.033698 | 0.036781 | 0.039359 | 1.1 | 0.24 +Modify | 12.306 | 12.313 | 12.319 | 0.2 | 78.83 +Other | | 0.07916 | | | 0.51 + +Nlocal: 100 ave 107 max 93 min +Histogram: 1 0 0 1 0 0 1 0 0 1 +Nghost: 185.5 ave 192 max 179 min +Histogram: 1 0 0 1 0 0 1 0 0 1 +Neighs: 1712 ave 1848 max 1598 min +Histogram: 1 0 1 0 0 1 0 0 0 1 +FullNghs: 3424 ave 3682 max 3174 min +Histogram: 1 0 1 0 0 0 1 0 0 1 + +Total # of neighbors = 13696 +Ave neighs/atom = 34.24 +Neighbor list builds = 331 +Dangerous builds = 0 + + +Total wall time: 0:00:15 diff --git a/examples/rheo/taylor-green/log.17Apr2024.taylor.green.g++.4 b/examples/rheo/taylor-green/log.17Apr2024.taylor.green.g++.4 new file mode 100644 index 0000000000..6daf4a6eee --- /dev/null +++ b/examples/rheo/taylor-green/log.17Apr2024.taylor.green.g++.4 @@ -0,0 +1,224 @@ +LAMMPS (17 Apr 2024 - Development - patch_5May2020-18508-g3c0eaf6870-modified) +# ------ 2D Taylor Green vortex ------ # + +dimension 2 +units lj +atom_style rheo +boundary p p p +comm_modify vel yes +newton off + +# ------ Create simulation box ------ # + +variable n equal 1.0 +variable cut equal 3.0 + +region box block 0 40 0 40 -0.01 0.01 +create_box 1 box +Created orthogonal box = (0 0 -0.01) to (40 40 0.01) + 2 by 2 by 1 MPI processor grid +lattice sq ${n} +lattice sq 1 +Lattice spacing in x,y,z = 1 1 1 + +create_atoms 1 region box +Created 1600 atoms + using lattice units in orthogonal box = (0 0 -0.01) to (40 40 0.01) + create_atoms CPU = 0.001 seconds + +displace_atoms all random 0.1 0.1 0 135414 units box +Displacing atoms ... + +# ------ Model parameters ------ # + +variable rho0 equal 1.0 +variable mp equal ${rho0}/${n} +variable mp equal 1/${n} +variable mp equal 1/1 +variable cs equal 1.0 +variable eta equal 0.05 +variable zeta equal 1 +variable dt_max equal 0.1*${cut}/${cs}/3 +variable dt_max equal 0.1*3/${cs}/3 +variable dt_max equal 0.1*3/1/3 +variable Dr equal 0.1*${cut}*${cs} +variable Dr equal 0.1*3*${cs} +variable Dr equal 0.1*3*1 + +mass * ${mp} +mass * 1 +set group all rheo/rho ${rho0} +set group all rheo/rho 1 +Setting atom values ... + 1600 settings made for rheo/rho +set group all rheo/status 0 +Setting atom values ... + 1600 settings made for rheo/status + +variable u0 equal 0.05 +variable uy atom ${u0}*sin(2*PI*x/lx)*cos(2*PI*y/ly) +variable uy atom 0.05*sin(2*PI*x/lx)*cos(2*PI*y/ly) +variable ux atom -${u0}*sin(2*PI*y/ly)*cos(2*PI*x/ly) +variable ux atom -0.05*sin(2*PI*y/ly)*cos(2*PI*x/ly) +variable d0 atom ${rho0}-${u0}*${u0}*${rho0}*0.25*(cos(4*PI*x/lx)+cos(4*PI*y/ly))/${cs}/${cs} +variable d0 atom 1-${u0}*${u0}*${rho0}*0.25*(cos(4*PI*x/lx)+cos(4*PI*y/ly))/${cs}/${cs} +variable d0 atom 1-0.05*${u0}*${rho0}*0.25*(cos(4*PI*x/lx)+cos(4*PI*y/ly))/${cs}/${cs} +variable d0 atom 1-0.05*0.05*${rho0}*0.25*(cos(4*PI*x/lx)+cos(4*PI*y/ly))/${cs}/${cs} +variable d0 atom 1-0.05*0.05*1*0.25*(cos(4*PI*x/lx)+cos(4*PI*y/ly))/${cs}/${cs} +variable d0 atom 1-0.05*0.05*1*0.25*(cos(4*PI*x/lx)+cos(4*PI*y/ly))/1/${cs} +variable d0 atom 1-0.05*0.05*1*0.25*(cos(4*PI*x/lx)+cos(4*PI*y/ly))/1/1 + +velocity all set v_ux v_uy 0.0 units box + +timestep ${dt_max} +timestep 0.1 + +pair_style rheo ${cut} artificial/visc ${zeta} rho/damp ${Dr} +pair_style rheo 3 artificial/visc ${zeta} rho/damp ${Dr} +pair_style rheo 3 artificial/visc 1 rho/damp ${Dr} +pair_style rheo 3 artificial/visc 1 rho/damp 0.3 +pair_coeff * * + +# ------ Fixes & computes ------ # + +fix 1 all rheo ${cut} RK1 8 shift +fix 1 all rheo 3 RK1 8 shift +fix 2 all rheo/viscosity * constant ${eta} +fix 2 all rheo/viscosity * constant 0.05 +fix 3 all rheo/pressure * linear +fix 4 all enforce2d + +compute rho all rheo/property/atom rho + +# ------ Output & Run ------ # + +thermo 200 +thermo_style custom step time ke press + +dump 1 all custom 200 atomDump id type x y vx vy fx fy c_rho + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- @article{PalermoInPrep, + journal = {in prep}, + title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows}, + year = {2024}, + author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor}, +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.3 + ghost atom cutoff = 3.3 + binsize = 1.65, bins = 25 25 1 + 4 neighbor lists, perpetual/occasional/extra = 4 0 0 + (1) pair rheo, perpetual, half/full from (2) + attributes: half, newton off + pair build: halffull/newtoff + stencil: none + bin: none + (2) compute RHEO/KERNEL, perpetual + attributes: full, newton off + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (3) compute RHEO/GRAD, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none + (4) compute RHEO/VSHIFT, perpetual, copy from (1) + attributes: half, newton off + pair build: copy + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 6.835 | 6.835 | 6.835 Mbytes + Step Time KinEng Press + 0 0 0.00062497276 0.00062607301 + 200 20 0.00056200647 0.00056633785 + 400 40 0.00050570968 0.00051098771 + 600 60 0.00045586684 0.00046081672 + 800 80 0.00041124523 0.00041549607 + 1000 100 0.00037065341 0.00037412741 + 1200 120 0.00033391585 0.00033580899 + 1400 140 0.00030078316 0.00030057307 + 1600 160 0.00027093231 0.00026842603 + 1800 180 0.00024403239 0.00023839026 + 2000 200 0.0002197865 0.00021148941 + 2200 220 0.0001979269 0.00018659386 + 2400 240 0.00017822267 0.00016430442 + 2600 260 0.00016047141 0.00014408514 + 2800 280 0.00014448504 0.00012574125 + 3000 300 0.00013009159 0.00010869938 + 3200 320 0.00011713578 9.414951e-05 + 3400 340 0.00010547564 8.1900579e-05 + 3600 360 9.4982139e-05 7.1285649e-05 + 3800 380 8.5538983e-05 6.1571123e-05 + 4000 400 7.7040171e-05 5.3462572e-05 + 4200 420 6.9390317e-05 4.6338308e-05 + 4400 440 6.2503763e-05 3.9697323e-05 + 4600 460 5.6303766e-05 3.4234465e-05 + 4800 480 5.0721595e-05 3.0841338e-05 + 5000 500 4.5695301e-05 2.7788566e-05 + 5200 520 4.1169161e-05 2.5744409e-05 + 5400 540 3.7093059e-05 2.3912739e-05 + 5600 560 3.3421819e-05 2.2494185e-05 + 5800 580 3.0114735e-05 2.1594384e-05 + 6000 600 2.7135224e-05 2.1164421e-05 + 6200 620 2.4450446e-05 2.0979349e-05 + 6400 640 2.2030925e-05 2.0858567e-05 + 6600 660 1.9850196e-05 2.098115e-05 + 6800 680 1.7884553e-05 2.1134827e-05 + 7000 700 1.6112763e-05 2.1242242e-05 + 7200 720 1.4515783e-05 2.1312763e-05 + 7400 740 1.3076456e-05 2.1370947e-05 + 7600 760 1.1779327e-05 2.1332126e-05 + 7800 780 1.0610469e-05 2.1156562e-05 + 8000 800 9.5573298e-06 2.0898126e-05 + 8200 820 8.6085799e-06 2.0517958e-05 + 8400 840 7.7539888e-06 1.9841551e-05 + 8600 860 6.9843033e-06 1.9114769e-05 + 8800 880 6.2911575e-06 1.8362959e-05 + 9000 900 5.6669785e-06 1.7473404e-05 + 9200 920 5.1049208e-06 1.6452745e-05 + 9400 940 4.5987908e-06 1.5578629e-05 + 9600 960 4.1429972e-06 1.4427274e-05 + 9800 980 3.7324962e-06 1.3169649e-05 + 10000 1000 3.3627455e-06 1.1938723e-05 +Loop time of 38.2006 on 4 procs for 10000 steps with 1600 atoms + +Performance: 2261743.875 tau/day, 261.776 timesteps/s, 418.841 katom-step/s +99.7% CPU use with 4 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 8.2958 | 8.7273 | 9.3582 | 15.2 | 22.85 +Neigh | 0.034282 | 0.035689 | 0.037115 | 0.7 | 0.09 +Comm | 0.16788 | 0.17018 | 0.17278 | 0.4 | 0.45 +Output | 0.066977 | 0.06882 | 0.071704 | 0.7 | 0.18 +Modify | 28.483 | 28.793 | 28.962 | 3.6 | 75.37 +Other | | 0.4053 | | | 1.06 + +Nlocal: 400 ave 402 max 399 min +Histogram: 2 0 0 1 0 0 0 0 0 1 +Nghost: 307.25 ave 308 max 305 min +Histogram: 1 0 0 0 0 0 0 0 0 3 +Neighs: 7618.25 ave 7697 max 7564 min +Histogram: 1 0 1 1 0 0 0 0 0 1 +FullNghs: 13343 ave 13497 max 13258 min +Histogram: 1 1 1 0 0 0 0 0 0 1 + +Total # of neighbors = 53372 +Ave neighs/atom = 33.3575 +Neighbor list builds = 123 +Dangerous builds = 0 +Total wall time: 0:00:38 diff --git a/src/BPM/bond_bpm_spring.cpp b/src/BPM/bond_bpm_spring.cpp index 775d8d1597..2863bbf317 100644 --- a/src/BPM/bond_bpm_spring.cpp +++ b/src/BPM/bond_bpm_spring.cpp @@ -23,8 +23,6 @@ #include "modify.h" #include "neighbor.h" -#include "update.h" - #include #include diff --git a/src/BPM/compute_nbond_atom.cpp b/src/BPM/compute_nbond_atom.cpp index 98263f3b4d..31428b1912 100644 --- a/src/BPM/compute_nbond_atom.cpp +++ b/src/BPM/compute_nbond_atom.cpp @@ -30,7 +30,7 @@ ComputeNBondAtom::ComputeNBondAtom(LAMMPS *_lmp, int narg, char **arg) : if (narg < 3) utils::missing_cmd_args(FLERR, "compute nbond/atom", error); if (atom->avec->bonds_allow == 0) - error->all(FLERR,"Compute nbond/atom used when bonds are not allowed"); + error->all(FLERR,"Compute nbond/atom used in system without bonds"); btype = -1; int iarg = 3; diff --git a/src/BPM/fix_update_special_bonds.cpp b/src/BPM/fix_update_special_bonds.cpp index 5dddbdd55e..c71f6973d0 100644 --- a/src/BPM/fix_update_special_bonds.cpp +++ b/src/BPM/fix_update_special_bonds.cpp @@ -169,7 +169,7 @@ void FixUpdateSpecialBonds::pre_force(int /*vflag*/) tagint *tag = atom->tag; // In theory could communicate a list of broken bonds to neighboring processors here - // to remove restriction that users use Newton bond off + // to remove restriction on Newton bond off for (int ilist = 0; ilist < neighbor->nlist; ilist++) { list = neighbor->lists[ilist]; diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp index c8eee29438..9c198364d6 100644 --- a/src/RHEO/bond_rheo_shell.cpp +++ b/src/RHEO/bond_rheo_shell.cpp @@ -250,8 +250,8 @@ void BondRHEOShell::compute(int eflag, int vflag) if (t >= tform) { bondstore[n][0] = r; r0 = r; - if (newton_bond || i1 < nlocal) dbond[i1] ++; - if (newton_bond || i2 < nlocal) dbond[i2] ++; + if (newton_bond || i1 < nlocal) dbond[i1]++; + if (newton_bond || i2 < nlocal) dbond[i2]++; } else { continue; } @@ -261,8 +261,8 @@ void BondRHEOShell::compute(int eflag, int vflag) if (fabs(e) > ecrit[type]) { bondlist[n][2] = 0; process_broken(i1, i2); - if (newton_bond || i1 < nlocal) dbond[i1] --; - if (newton_bond || i2 < nlocal) dbond[i2] --; + if (newton_bond || i1 < nlocal) dbond[i1]--; + if (newton_bond || i2 < nlocal) dbond[i2]--; continue; } @@ -388,9 +388,8 @@ void BondRHEOShell::settings(int narg, char **arg) for (std::size_t i = 0; i < leftover_iarg.size(); i++) { iarg = leftover_iarg[i]; if (strcmp(arg[iarg], "t/form") == 0) { - if (iarg + 1 > narg) error->all(FLERR, "Illegal bond rheo/shell command, missing option for t/form"); + if (iarg + 1 > narg) utils::missing_cmd_args(FLERR, "bond rheo/shell t/form", error); tform = utils::numeric(FLERR, arg[iarg + 1], false, lmp); - if (tform < 0.0) error->all(FLERR, "Illegal bond rheo/shell value for t/form, {}", tform); i += 1; } else { error->all(FLERR, "Illegal bond rheo/shell command, invalid argument {}", arg[iarg]); @@ -398,7 +397,7 @@ void BondRHEOShell::settings(int narg, char **arg) } if (tform < 0.0) - error->all(FLERR, "Illegal bond rheo/shell command, must specify formation time"); + error->all(FLERR, "Illegal bond rheo/shell command, must specify positive formation time"); } diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index d0f24850bd..cb9a42323b 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -57,7 +57,7 @@ ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : { if (narg != 4) error->all(FLERR,"Illegal compute rheo/kernel command"); - kernel_style = utils::inumeric(FLERR,arg[3],false,lmp); + kernel_style = utils::inumeric(FLERR, arg[3], false, lmp); if (kernel_style == QUINTIC || kernel_style == WENDLANDC4) { correction_order = -1; @@ -110,27 +110,27 @@ void ComputeRHEOKernel::init() compute_interface = fix_rheo->compute_interface; zmin = fix_rheo->zmin_kernel; - h = fix_rheo->h; - hsq = h * h; - hinv = 1.0 / h; - hsqinv = hinv * hinv; + cut = fix_rheo->cut; + cutsq = cut * cut; + cutinv = 1.0 / cut; + cutsqinv = cutinv * cutinv; if (kernel_style != WENDLANDC4) { if (dim == 3) { - pre_w = 1.0 / (120.0 * MY_PI) * 27.0 * hsqinv * hinv; - pre_wp = pre_w * 3.0 * hinv; + pre_w = 1.0 / (120.0 * MY_PI) * 27.0 * cutsqinv * cutinv; + pre_wp = pre_w * 3.0 * cutinv; } else { - pre_w = 7.0 / (478.0 * MY_PI) * 9 * hsqinv; - pre_wp = pre_w * 3.0 * hinv; + pre_w = 7.0 / (478.0 * MY_PI) * 9 * cutsqinv; + pre_wp = pre_w * 3.0 * cutinv; } } else { if (dim == 3) { - pre_w = 495.0 / (32.0 * MY_PI * hsq * h); - pre_wp = pre_w * hinv; + pre_w = 495.0 / (32.0 * MY_PI * cutsq * cut); + pre_wp = pre_w * cutinv; } else { - pre_w = 9.0 / (MY_PI * hsq); - pre_wp = pre_w * hinv; + pre_w = 9.0 / (MY_PI * cutsq); + pre_wp = pre_w * cutinv; } } @@ -193,7 +193,7 @@ double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double int corrections_i, corrections_j, corrections; if (kernel_style == WENDLANDC4) - return calc_w_wendlandc4(i,j,delx,dely,delz,r); + return calc_w_wendlandc4(i, j, delx, dely, delz, r); if (kernel_style != QUINTIC) { corrections_i = check_corrections(i); @@ -203,10 +203,10 @@ double ComputeRHEOKernel::calc_w(int i, int j, double delx, double dely, double corrections = 0; } - if (!corrections) w = calc_w_quintic(i,j,delx,dely,delz,r); - else if (kernel_style == RK0) w = calc_w_rk0(i,j,delx,dely,delz,r); - else if (kernel_style == RK1) w = calc_w_rk1(i,j,delx,dely,delz,r); - else if (kernel_style == RK2) w = calc_w_rk2(i,j,delx,dely,delz,r); + if (!corrections) w = calc_w_quintic(i, j, delx, dely, delz, r); + else if (kernel_style == RK0) w = calc_w_rk0(i, j, delx, dely, delz, r); + else if (kernel_style == RK1) w = calc_w_rk1(i, j, delx, dely, delz, r); + else if (kernel_style == RK2) w = calc_w_rk2(i, j, delx, dely, delz, r); return w; } @@ -219,7 +219,7 @@ double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double int corrections_i, corrections_j; if (kernel_style == WENDLANDC4) - return calc_dw_wendlandc4(i,j,delx,dely,delz,r,dWij,dWji); + return calc_dw_wendlandc4(i, j, delx, dely, delz, r, dWij, dWji); if (kernel_style != QUINTIC) { corrections_i = check_corrections(i); @@ -227,15 +227,15 @@ double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double } // Calc wp and default dW's, a bit inefficient but can redo later - wp = calc_dw_quintic(i,j,delx,dely,delz,r,dWij,dWji); + wp = calc_dw_quintic(i, j, delx, dely, delz, r, dWij, dWji); // Overwrite if there are corrections if (kernel_style == RK1) { - if (corrections_i) calc_dw_rk1(i,j,delx,dely,delz,r,dWij); - if (corrections_j) calc_dw_rk1(j,i,-delx,-dely,-delz,r,dWji); + if (corrections_i) calc_dw_rk1(i, j, delx, dely, delz, r, dWij); + if (corrections_j) calc_dw_rk1(j, i, -delx, -dely, -delz, r, dWji); } else if (kernel_style == RK2) { - if (corrections_i) calc_dw_rk2(i,j,delx,dely,delz,r,dWij); - if (corrections_j) calc_dw_rk2(j,i,-delx,-dely,-delz,r,dWji); + if (corrections_i) calc_dw_rk2(i, j, delx, dely, delz, r, dWij); + if (corrections_j) calc_dw_rk2(j, i, -delx, -dely, -delz, r, dWji); } return wp; @@ -246,7 +246,7 @@ double ComputeRHEOKernel::calc_dw(int i, int j, double delx, double dely, double double ComputeRHEOKernel::calc_w_quintic(int i, int j, double delx, double dely, double delz, double r) { double w, tmp1, tmp2, tmp3, tmp1sq, tmp2sq, tmp3sq, s; - s = r * 3.0 * hinv; + s = r * 3.0 * cutinv; if (s > 3.0) { w = 0.0; @@ -284,7 +284,7 @@ double ComputeRHEOKernel::calc_dw_quintic(int i, int j, double delx, double dely double *mass = atom->mass; int *type = atom->type; - s = r * 3.0 * hinv; + s = r * 3.0 * cutinv; if (s > 3.0) { wp = 0.0; @@ -323,7 +323,7 @@ double ComputeRHEOKernel::calc_dw_quintic(int i, int j, double delx, double dely double ComputeRHEOKernel::calc_w_wendlandc4(int i, int j, double delx, double dely, double delz, double r) { double w, tmp6, s; - s = r * hinv; + s = r * cutinv; if (s > 1.0) { w = 0.0; @@ -349,7 +349,7 @@ double ComputeRHEOKernel::calc_dw_wendlandc4(int i, int j, double delx, double d double *mass = atom->mass; int *type = atom->type; - s = r * hinv; + s = r * cutinv; if (s > 1.0) { wp = 0.0; @@ -381,7 +381,7 @@ double ComputeRHEOKernel::calc_w_rk0(int i, int j, double delx, double dely, dou { double w; - w = calc_w_quintic(i,j,delx,dely,delz,r); + w = calc_w_quintic(i, j, delx, dely, delz, r); Wij = C0[i] * w; Wji = C0[j] * w; @@ -399,17 +399,17 @@ double ComputeRHEOKernel::calc_w_rk1(int i, int j, double delx, double dely, dou dx[0] = delx; dx[1] = dely; dx[2] = delz; - w = calc_w_quintic(i,j,delx,dely,delz,r); + w = calc_w_quintic(i, j, delx, dely, delz, r); if (dim == 2) { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; } else { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; - H[3] = dx[2] * hinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; + H[3] = dx[2] * cutinv; } Wij = 0; for (b = 0; b < Mdim; b++) { @@ -440,26 +440,26 @@ double ComputeRHEOKernel::calc_w_rk2(int i, int j, double delx, double dely, dou dx[0] = delx; dx[1] = dely; dx[2] = delz; - w = calc_w_quintic(i,j,delx,dely,delz,r); + w = calc_w_quintic(i, j, delx, dely, delz, r); if (dim == 2) { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; - H[3] = 0.5 * dx[0] * dx[0] * hsqinv; - H[4] = 0.5 * dx[1] * dx[1] * hsqinv; - H[5] = dx[0] * dx[1] * hsqinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; + H[3] = 0.5 * dx[0] * dx[0] * cutsqinv; + H[4] = 0.5 * dx[1] * dx[1] * cutsqinv; + H[5] = dx[0] * dx[1] * cutsqinv; } else { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; - H[3] = dx[2] * hinv; - H[4] = 0.5 * dx[0] * dx[0] * hsqinv; - H[5] = 0.5 * dx[1] * dx[1] * hsqinv; - H[6] = 0.5 * dx[2] * dx[2] * hsqinv; - H[7] = dx[0] * dx[1] * hsqinv; - H[8] = dx[0] * dx[2] * hsqinv; - H[9] = dx[1] * dx[2] * hsqinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; + H[3] = dx[2] * cutinv; + H[4] = 0.5 * dx[0] * dx[0] * cutsqinv; + H[5] = 0.5 * dx[1] * dx[1] * cutsqinv; + H[6] = 0.5 * dx[2] * dx[2] * cutsqinv; + H[7] = dx[0] * dx[1] * cutsqinv; + H[8] = dx[0] * dx[2] * cutsqinv; + H[9] = dx[1] * dx[2] * cutsqinv; } Wij = 0; for (b = 0; b < Mdim; b++) { @@ -491,18 +491,18 @@ void ComputeRHEOKernel::calc_dw_rk1(int i, int j, double delx, double dely, doub dx[1] = dely; dx[2] = delz; - w = calc_w_quintic(i,j,delx,dely,delz,r); + w = calc_w_quintic(i, j, delx, dely, delz, r); //Populate correction basis if (dim == 2) { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; } else { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; - H[3] = dx[2] * hinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; + H[3] = dx[2] * cutinv; } // dWij[] = dWx dWy (dWz) @@ -528,27 +528,27 @@ void ComputeRHEOKernel::calc_dw_rk2(int i, int j, double delx, double dely, doub dx[1] = dely; dx[2] = delz; - w = calc_w_quintic(i,j,delx,dely,delz,r); + w = calc_w_quintic(i, j, delx, dely, delz, r); //Populate correction basis if (dim == 2) { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; - H[3] = 0.5 * dx[0] * dx[0] * hsqinv; - H[4] = 0.5 * dx[1] * dx[1] * hsqinv; - H[5] = dx[0] * dx[1] * hsqinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; + H[3] = 0.5 * dx[0] * dx[0] * cutsqinv; + H[4] = 0.5 * dx[1] * dx[1] * cutsqinv; + H[5] = dx[0] * dx[1] * cutsqinv; } else { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; - H[3] = dx[2] * hinv; - H[4] = 0.5 * dx[0] * dx[0] * hsqinv; - H[5] = 0.5 * dx[1] * dx[1] * hsqinv; - H[6] = 0.5 * dx[2] * dx[2] * hsqinv; - H[7] = dx[0] * dx[1] * hsqinv; - H[8] = dx[0] * dx[2] * hsqinv; - H[9] = dx[1] * dx[2] * hsqinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; + H[3] = dx[2] * cutinv; + H[4] = 0.5 * dx[0] * dx[0] * cutsqinv; + H[5] = 0.5 * dx[1] * dx[1] * cutsqinv; + H[6] = 0.5 * dx[2] * dx[2] * cutsqinv; + H[7] = dx[0] * dx[1] * cutsqinv; + H[8] = dx[0] * dx[2] * cutsqinv; + H[9] = dx[1] * dx[2] * cutsqinv; } // dWij[] = dWx dWy (dWz) @@ -621,7 +621,7 @@ void ComputeRHEOKernel::compute_peratom() dx[2] = ztmp - x[j][2]; rsq = lensq3(dx); - if (rsq < hsq) { + if (rsq < cutsq) { r = sqrt(rsq); w = calc_w_quintic(i, j, dx[0], dx[1], dx[2], r); rhoj = rho[j]; @@ -639,7 +639,7 @@ void ComputeRHEOKernel::compute_peratom() } } else if (correction_order > 0) { - // Moment matrix M and polynomial basis vector H (1d for gsl compatibility) + // Moment matrix M and polynomial basis vector cut (1d for gsl compatibility) double H[Mdim], M[Mdim * Mdim]; for (ii = 0; ii < inum; ii++) { @@ -652,7 +652,7 @@ void ComputeRHEOKernel::compute_peratom() jnum = numneigh[i]; itype = type[i]; - // Zero upper-triangle M and H (will be symmetric): + // Zero upper-triangle M and cut (will be symmetric): for (a = 0; a < Mdim; a++) { for (b = a; b < Mdim; b++) { M[a * Mdim + b] = 0; @@ -669,7 +669,7 @@ void ComputeRHEOKernel::compute_peratom() rsq = lensq3(dx); - if (rsq < hsq) { + if (rsq < cutsq) { r = sqrt(rsq); w = calc_w_quintic(i, j, dx[0], dx[1], dx[2], r); @@ -683,25 +683,25 @@ void ComputeRHEOKernel::compute_peratom() //Populate the H-vector of polynomials (2D) if (dim == 2) { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; if (kernel_style == RK2) { - H[3] = 0.5 * dx[0] * dx[0] * hsqinv; - H[4] = 0.5 * dx[1] * dx[1] * hsqinv; - H[5] = dx[0] * dx[1] * hsqinv; + H[3] = 0.5 * dx[0] * dx[0] * cutsqinv; + H[4] = 0.5 * dx[1] * dx[1] * cutsqinv; + H[5] = dx[0] * dx[1] * cutsqinv; } } else { H[0] = 1.0; - H[1] = dx[0] * hinv; - H[2] = dx[1] * hinv; - H[3] = dx[2] * hinv; + H[1] = dx[0] * cutinv; + H[2] = dx[1] * cutinv; + H[3] = dx[2] * cutinv; if (kernel_style == RK2) { - H[4] = 0.5 * dx[0] * dx[0] * hsqinv; - H[5] = 0.5 * dx[1] * dx[1] * hsqinv; - H[6] = 0.5 * dx[2] * dx[2] * hsqinv; - H[7] = dx[0] * dx[1] * hsqinv; - H[8] = dx[0] * dx[2] * hsqinv; - H[9] = dx[1] * dx[2] * hsqinv; + H[4] = 0.5 * dx[0] * dx[0] * cutsqinv; + H[5] = 0.5 * dx[1] * dx[1] * cutsqinv; + H[6] = 0.5 * dx[2] * dx[2] * cutsqinv; + H[7] = dx[0] * dx[1] * cutsqinv; + H[8] = dx[0] * dx[2] * cutsqinv; + H[9] = dx[1] * dx[2] * cutsqinv; } } @@ -765,12 +765,12 @@ void ComputeRHEOKernel::compute_peratom() C[i][0][a] = M[a * Mdim + 0]; // all rows of column 0 for (b = 0; b < dim; b++) { //First derivatives - C[i][1 + b][a] = -M[a * Mdim + b + 1] * hinv; + C[i][1 + b][a] = -M[a * Mdim + b + 1] * cutinv; // columns 1-2 (2D) or 1-3 (3D) //Second derivatives if (kernel_style == RK2) - C[i][1 + dim + b][a] = M[a * Mdim + b + 1 + dim] * hsqinv; + C[i][1 + dim + b][a] = M[a * Mdim + b + 1 + dim] * cutsqinv; // columns 3-4 (2D) or 4-6 (3D) } } @@ -822,7 +822,7 @@ void ComputeRHEOKernel::compute_coordination() dx[2] = ztmp - x[j][2]; rsq = lensq3(dx); - if (rsq < hsq) + if (rsq < cutsq) coordination[i] += 1; } } diff --git a/src/RHEO/compute_rheo_kernel.h b/src/RHEO/compute_rheo_kernel.h index 543e5d88c0..d15e8e210a 100644 --- a/src/RHEO/compute_rheo_kernel.h +++ b/src/RHEO/compute_rheo_kernel.h @@ -59,7 +59,7 @@ class ComputeRHEOKernel : public Compute { int corrections_calculated; int kernel_style, zmin, dim, Mdim, ncor; int nmax_store; - double h, hsq, hinv, hsqinv, pre_w, pre_wp; + double cut, cutsq, cutinv, cutsqinv, pre_w, pre_wp; double ***C; double *C0; diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index bf2f2a3297..284afcd992 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -181,7 +181,7 @@ void ComputeRHEOSurface::compute_peratom() gradC[i][a] += dWij[a] * Volj; } - if (j < nlocal || newton) { + if ((j < nlocal) || newton) { for (a = 0; a < dim; a++){ divr[j] += dWji[a] * dx[a] * Voli; gradC[j][a] += dWji[a] * Voli; @@ -287,7 +287,7 @@ void ComputeRHEOSurface::compute_peratom() } } - // clear normal vectors for non surface particles + // clear normal vectors for non-surface particles for (i = 0; i < nall; i++) { if (mask[i] & groupbit) { diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index c704677bec..f12d10b8c5 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -39,7 +39,12 @@ using namespace RHEO_NS; using namespace FixConst; static const char cite_rheo[] = - "TBD\n\n"; + "@article{PalermoInPrep,\n" + " journal = {in prep},\n" + " title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows},\n" + " year = {2024},\n" + " author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor},\n" + "}\n\n"; /* ---------------------------------------------------------------------- */ @@ -84,10 +89,9 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR, "fix rheo command requires atom_style with status"); if (narg < 5) - error->all(FLERR, "Insufficient arguments for fix rheo command"); + utils::missing_cmd_args(FLERR, "fix rheo", error); - h = utils::numeric(FLERR, arg[3], false, lmp); - cut = h; + cut = utils::numeric(FLERR, arg[3], false, lmp); if (strcmp(arg[4], "quintic") == 0) { kernel_style = QUINTIC; } else if (strcmp(arg[4], "wendland/c4") == 0) { @@ -109,7 +113,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : thermal_flag = 1; } else if (strcmp(arg[iarg], "surface/detection") == 0) { surface_flag = 1; - if(iarg + 3 >= narg) error->all(FLERR, "Illegal surface/detection option in fix rheo"); + if(iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo surface/detection", error); if (strcmp(arg[iarg + 1], "coordination") == 0) { surface_style = COORDINATION; zmin_surface = utils::inumeric(FLERR, arg[iarg + 2], false, lmp); @@ -130,12 +134,12 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg], "self/mass") == 0) { self_mass_flag = 1; } else if (strcmp(arg[iarg], "density") == 0) { - if (iarg + n >= narg) error->all(FLERR, "Illegal rho0 option in fix rheo"); + if (iarg + n >= narg) utils::missing_cmd_args(FLERR, "fix rheo density", error); for (i = 1; i <= n; i++) rho0[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); iarg += n; } else if (strcmp(arg[iarg], "speed/sound") == 0) { - if (iarg + n >= narg) error->all(FLERR, "Illegal csq option in fix rheo"); + if (iarg + n >= narg) utils::missing_cmd_args(FLERR, "fix rheo speed/sound", error); for (i = 1; i <= n; i++) { csq[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); csq[i] *= csq[i]; @@ -281,7 +285,7 @@ void FixRHEO::setup(int /*vflag*/) if (!pressure_fix_defined) error->all(FLERR, "Missing fix rheo/pressure"); - if((!thermal_fix_defined) && thermal_flag) + if(thermal_flag && !thermal_fix_defined) error->all(FLERR, "Missing fix rheo/thermal"); // Reset to zero for future runs @@ -290,33 +294,6 @@ void FixRHEO::setup(int /*vflag*/) pressure_fix_defined = 0; oxidation_fix_defined = 0; - // Check fixes cover all atoms (may still fail if atoms are created) - // FixRHEOPressure currently requires group all - auto visc_fixes = modify->get_fix_by_style("rheo/viscosity"); - auto therm_fixes = modify->get_fix_by_style("rheo/thermal"); - - int *mask = atom->mask; - int v_coverage_flag = 1; - int t_coverage_flag = 1; - int covered; - for (int i = 0; i < atom->nlocal; i++) { - covered = 0; - for (auto fix : visc_fixes) - if (mask[i] & fix->groupbit) covered = 1; - if (!covered) v_coverage_flag = 0; - if (thermal_flag) { - covered = 0; - for (auto fix : therm_fixes) - if (mask[i] & fix->groupbit) covered = 1; - if (!covered) t_coverage_flag = 0; - } - } - - if (!v_coverage_flag) - error->one(FLERR, "Fix rheo/viscosity does not fully cover all atoms"); - if (!t_coverage_flag) - error->one(FLERR, "Fix rheo/thermal does not fully cover all atoms"); - if (rhosum_flag) compute_rhosum->compute_peratom(); } diff --git a/src/RHEO/fix_rheo.h b/src/RHEO/fix_rheo.h index 251f82a99a..8c62197fcd 100644 --- a/src/RHEO/fix_rheo.h +++ b/src/RHEO/fix_rheo.h @@ -39,7 +39,7 @@ class FixRHEO : public Fix { void reset_dt() override; // Model parameters - double h, cut; + double cut; double *rho0, *csq; int self_mass_flag; int zmin_kernel, zmin_surface, zmin_splash; diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index 5b0a50b4a5..acd833dfda 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -99,10 +99,10 @@ void FixRHEOOxidation::init() if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/oxidation"); fix_rheo = dynamic_cast(fixes[0]); - if (cut > fix_rheo->h) + if (cut > fix_rheo->cut) error->all(FLERR, "Bonding length exceeds kernel cutoff"); - if (rsurf >= fix_rheo->h) + if (rsurf >= fix_rheo->cut) error->all(FLERR, "Surface distance must be less than kernel cutoff"); if (!force->bond) error->all(FLERR, "Must define a bond style with fix rheo/oxidation"); @@ -233,7 +233,7 @@ void FixRHEOOxidation::post_integrate() // Add bonds to owned atoms // If newton bond off, add to both, otherwise add to whichever has a smaller tag - if (!newton_bond || tagi < tagj) { + if (!newton_bond || (tagi < tagj)) { if (num_bond[i] == atom->bond_per_atom) error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/oxidation for atom {}", tagi); bond_type[i][num_bond[i]] = btype; diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index 321fee07e7..c1cda67500 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -71,6 +71,7 @@ FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : cut_bond = 0; comm_forward = 0; + // Currently can only have one instance of fix rheo/thermal if (igroup != 0) error->all(FLERR,"fix rheo/thermal command requires group all"); @@ -249,7 +250,7 @@ void FixRHEOThermal::init() auto fixes = modify->get_fix_by_style("^rheo$"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo to use fix rheo/viscosity"); fix_rheo = dynamic_cast(fixes[0]); - cut_kernel = fix_rheo->h; + cut_kernel = fix_rheo->cut; if (cut_bond > cut_kernel) error->all(FLERR, "Bonding length exceeds kernel cutoff"); @@ -263,16 +264,16 @@ void FixRHEOThermal::init() dth = 0.5 * update->dt; if (atom->esph_flag != 1) - error->all(FLERR,"fix rheo/thermal command requires atom property esph"); + error->all(FLERR, "fix rheo/thermal command requires atom property esph"); if (atom->temperature_flag != 1) - error->all(FLERR,"fix rheo/thermal command requires atom property temperature"); + error->all(FLERR, "fix rheo/thermal command requires atom property temperature"); if (atom->heatflow_flag != 1) - error->all(FLERR,"fix rheo/thermal command requires atom property heatflow"); + error->all(FLERR, "fix rheo/thermal command requires atom property heatflow"); if (atom->conductivity_flag != 1) - error->all(FLERR,"fix rheo/thermal command requires atom property conductivity"); + error->all(FLERR, "fix rheo/thermal command requires atom property conductivity"); if (cut_bond > 0.0) { - if (!force->bond) error->all(FLERR,"Must define a bond style to use reactive bond generation with fix rheo/thermal"); + if (!force->bond) error->all(FLERR, "Must define a bond style to use reactive bond generation with fix rheo/thermal"); if (!atom->avec->bonds_allow) error->all(FLERR, "Reactive bond generation in fix rheo/thermal requires atom bonds"); // all special weights must be 1.0 (no special neighbors) or there must be an instance of fix update/special/bonds @@ -561,7 +562,7 @@ void FixRHEOThermal::break_bonds() // Update special unless two owned atoms melt simultaneously then // only update for atom with lower tag if (fix_update_special_bonds) { - if (i < nlocal && j < nlocal && melti && meltj) { + if ((i < nlocal) && (j < nlocal) && melti && meltj) { if (tag[i] < tag[j]) { fix_update_special_bonds->add_broken_bond(i, j); } @@ -590,7 +591,7 @@ void FixRHEOThermal::break_bonds() // Delete bonds for non-melted local atoms (shifting) if (i < nlocal && !melti) { for (m = 0; m < num_bond[i]; m++) { - if (bond_atom[i][m] == tag[j] && bond_type[i][m] == btype) { + if ((bond_atom[i][m] == tag[j]) && (bond_type[i][m] == btype)) { nmax = num_bond[i] - 1; bond_type[i][m] = bond_type[i][nmax]; bond_atom[i][m] = bond_atom[i][nmax]; @@ -609,7 +610,7 @@ void FixRHEOThermal::break_bonds() if (j < nlocal && !meltj) { for (m = 0; m < num_bond[j]; m++) { - if (bond_atom[j][m] == tag[i] && bond_type[j][m] == btype) { + if ((bond_atom[j][m] == tag[i]) && (bond_type[j][m] == btype)) { nmax = num_bond[j] - 1; bond_type[j][m] = bond_type[j][nmax]; bond_atom[j][m] = bond_atom[j][nmax]; @@ -692,7 +693,7 @@ void FixRHEOThermal::create_bonds() // Add bonds to owned atoms // If newton bond off, add to both, otherwise add to whichever has a smaller tag - if (i < nlocal && (!newton_bond || tag[i] < tag[j])) { + if ((i < nlocal) && (!newton_bond || (tag[i] < tag[j]))) { if (num_bond[i] == atom->bond_per_atom) error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/thermal"); bond_type[i][num_bond[i]] = btype; @@ -700,7 +701,7 @@ void FixRHEOThermal::create_bonds() num_bond[i]++; } - if (j < nlocal && (!newton_bond || tag[j] < tag[i])) { + if ((j < nlocal) && (!newton_bond || (tag[j] < tag[i]))) { if (num_bond[j] == atom->bond_per_atom) error->one(FLERR,"New bond exceeded bonds per atom in fix rheo/thermal"); bond_type[j][num_bond[j]] = btype; diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 2d5d58d494..5cb1e7c4d0 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -46,6 +46,7 @@ FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : constant_flag = 0; evolve_flag = 0; + // Currently can only have one instance of fix rheo/viscosity if (igroup != 0) error->all(FLERR,"fix rheo/viscosity command requires group all"); diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index f206512950..731047201c 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -33,7 +33,6 @@ #include "modify.h" #include "neighbor.h" #include "neigh_list.h" -#include "update.h" #include "utils.h" #include @@ -81,7 +80,7 @@ void PairRHEO::compute(int eflag, int vflag) int pair_force_flag, pair_rho_flag, pair_avisc_flag; int fluidi, fluidj; double xtmp, ytmp, ztmp, w, wp, Ti, Tj, dT, csq_ave, cs_ave; - double rhoi, rhoj, rho0i, rho0j, voli, volj, Pi, Pj, etai, etaj, kappai, kappaj, eta_ave, kappa_ave,dT_prefactor; + double rhoi, rhoj, rho0i, rho0j, voli, volj, Pi, Pj, etai, etaj, kappai, kappaj, eta_ave, kappa_ave, dT_prefactor; double mu, q, fp_prefactor, drho_damp, fmag, psi_ij, Fij; double *dWij, *dWji, *dW1ij, *dW1ji; double dx[3], du[3], dv[3], fv[3], dfp[3], fsolid[3], ft[3], vi[3], vj[3]; @@ -112,7 +111,6 @@ void PairRHEO::compute(int eflag, int vflag) int *type = atom->type; int *status = atom->status; tagint *tag = atom->tag; - double fnorm, ftang[3]; double **fp_store, *chi; if (compute_interface) { @@ -169,7 +167,7 @@ void PairRHEO::compute(int eflag, int vflag) rsq = lensq3(dx); jtype = type[j]; - if (rsq < hsq) { + if (rsq < cutksq) { r = sqrt(rsq); rinv = 1 / r; @@ -219,16 +217,16 @@ void PairRHEO::compute(int eflag, int vflag) rhoj = compute_interface->correct_rho(j, i); Pj = fix_pressure->calc_pressure(rhoj, jtype); - if ((chi[j] > 0.9) && (r < (h * 0.5))) - fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0j * csq_ave * h * rinv; + if ((chi[j] > 0.9) && (r < (cutk * 0.5))) + fmag = (chi[j] - 0.9) * (cutk * 0.5 - r) * rho0j * csq_ave * cutk * rinv; } else if ((!fluidi) && fluidj) { compute_interface->correct_v(vi, vj, i, j); rhoi = compute_interface->correct_rho(i, j); Pi = fix_pressure->calc_pressure(rhoi, itype); - if (chi[i] > 0.9 && r < (h * 0.5)) - fmag = (chi[i] - 0.9) * (h * 0.5 - r) * rho0i * csq_ave * h * rinv; + if (chi[i] > 0.9 && r < (cutk * 0.5)) + fmag = (chi[i] - 0.9) * (cutk * 0.5 - r) * rho0i * csq_ave * cutk * rinv; } else if ((!fluidi) && (!fluidj)) { rhoi = rho0i; @@ -281,8 +279,8 @@ void PairRHEO::compute(int eflag, int vflag) for (b = 0; b < dim; b++) du[a] -= 0.5 * (gradv[i][a * dim + b] + gradv[j][a * dim + b]) * dx[b]; - mu = dot3(du, dx) * hinv3; - mu /= (rsq * hinv3 * hinv3 + EPSILON); + mu = dot3(du, dx) * cutkinv3; + mu /= (rsq * cutkinv3 * cutkinv3 + EPSILON); mu = MIN(0.0, mu); q = av * (-2.0 * cs_ave * mu + mu * mu); fp_prefactor += voli * volj * q * (rhoj + rhoi); @@ -406,17 +404,17 @@ void PairRHEO::settings(int narg, char **arg) { if (narg < 1) error->all(FLERR, "Illegal pair_style command"); - h = utils::numeric(FLERR, arg[0], false, lmp); + cutk = utils::numeric(FLERR, arg[0], false, lmp); int iarg = 1; while (iarg < narg) { if (strcmp(arg[iarg], "rho/damp") == 0) { - if (iarg + 1 >= narg) error->all(FLERR, "Illegal pair_style command"); + if (iarg + 1 >= narg) utils::missing_cmd_args(FLERR, "pair rheo rho/damp", error); rho_damp_flag = 1; rho_damp = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg++; } else if (strcmp(arg[iarg], "artificial/visc") == 0) { - if (iarg + 1 >= narg) error->all(FLERR, "Illegal pair_style command"); + if (iarg + 1 >= narg) utils::missing_cmd_args(FLERR, "pair rheo artificial/visc", error); artificial_visc_flag = 1; av = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg++; @@ -477,12 +475,12 @@ void PairRHEO::setup() csq = fix_rheo->csq; rho0 = fix_rheo->rho0; - if (h != fix_rheo->h) - error->all(FLERR, "Pair rheo cutoff {} does not agree with fix rheo cutoff {}", h, fix_rheo->h); + if (cutk != fix_rheo->cut) + error->all(FLERR, "Pair rheo cutoff {} does not agree with fix rheo cutoff {}", cutk, fix_rheo->cut); - hsq = h * h; - hinv = 1.0 / h; - hinv3 = hinv * 3.0; + cutksq = cutk * cutk; + cutkinv = 1.0 / cutk; + cutkinv3 = cutkinv * 3.0; laplacian_order = -1; int n = atom->ntypes; @@ -512,7 +510,7 @@ double PairRHEO::init_one(int i, int j) if (setflag[i][j] == 0) error->all(FLERR, "All pair rheo coeffs are not set"); - return h; + return cutk; } /* ---------------------------------------------------------------------- */ diff --git a/src/RHEO/pair_rheo.h b/src/RHEO/pair_rheo.h index 7a47927962..eba3a70eea 100644 --- a/src/RHEO/pair_rheo.h +++ b/src/RHEO/pair_rheo.h @@ -37,8 +37,8 @@ class PairRHEO : public Pair { void unpack_reverse_comm(int, int *, double *) override; protected: - double h, *csq, *rho0; // From fix RHEO - double *cs, hsq, hinv, hinv3, av, rho_damp; + double cutk, *csq, *rho0; // From fix RHEO + double *cs, cutksq, cutkinv, cutkinv3, av, rho_damp; int laplacian_order; int artificial_visc_flag; From d5c90eebfd0b59c78b8588ab993dd2749f789e13 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 28 Jun 2024 17:27:13 -0600 Subject: [PATCH 091/104] Flipping doc reference name --- doc/src/bond_rheo_shell.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/bond_rheo_shell.rst b/doc/src/bond_rheo_shell.rst index 439f88ec8e..f83219b9f3 100644 --- a/doc/src/bond_rheo_shell.rst +++ b/doc/src/bond_rheo_shell.rst @@ -54,7 +54,7 @@ Before bonds are enabled, they are still treated as regular bonds by all other parts of LAMMPS. This means they are written to data files and counted in computes such as :doc:`nbond/atom `. To only count enabled bonds, use the *nbond/shell* attribute in -:doc:`compute property/atom/rheo `. +:doc:`compute rheo/property/atom `. When enabled, the bond then computes forces based on deviations from the initial reference state of the two atoms much like a BPM style From 4b8f961098102120e6dc41322e9df66932f73e95 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 2 Jul 2024 14:00:37 -0600 Subject: [PATCH 092/104] Updating headers --- src/GRANULAR/fix_add_heat.cpp | 2 +- src/RHEO/atom_vec_rheo.cpp | 19 ++++++++++--------- src/RHEO/atom_vec_rheo_thermal.cpp | 19 ++++++++++--------- src/RHEO/bond_rheo_shell.cpp | 1 + src/RHEO/compute_rheo_grad.cpp | 1 + src/RHEO/compute_rheo_interface.cpp | 19 ++++++++++--------- src/RHEO/compute_rheo_kernel.cpp | 19 ++++++++++--------- src/RHEO/compute_rheo_rho_sum.cpp | 5 +++-- src/RHEO/compute_rheo_surface.cpp | 19 ++++++++++--------- src/RHEO/compute_rheo_vshift.cpp | 19 ++++++++++--------- src/RHEO/fix_rheo.cpp | 19 ++++++++++--------- src/RHEO/fix_rheo_oxidation.cpp | 19 ++++++++++--------- src/RHEO/fix_rheo_pressure.cpp | 19 ++++++++++--------- src/RHEO/fix_rheo_thermal.cpp | 19 ++++++++++--------- src/RHEO/fix_rheo_viscosity.cpp | 19 ++++++++++--------- src/RHEO/pair_rheo.cpp | 19 ++++++++++--------- src/RHEO/pair_rheo_solid.cpp | 1 + 17 files changed, 127 insertions(+), 111 deletions(-) diff --git a/src/GRANULAR/fix_add_heat.cpp b/src/GRANULAR/fix_add_heat.cpp index a68c9c2b95..01bc22cdf4 100644 --- a/src/GRANULAR/fix_add_heat.cpp +++ b/src/GRANULAR/fix_add_heat.cpp @@ -1,4 +1,4 @@ -/* -*- c++ -*- ---------------------------------------------------------- +/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories LAMMPS development team: developers@lammps.org diff --git a/src/RHEO/atom_vec_rheo.cpp b/src/RHEO/atom_vec_rheo.cpp index 843269a717..92f5ca05a4 100644 --- a/src/RHEO/atom_vec_rheo.cpp +++ b/src/RHEO/atom_vec_rheo.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/atom_vec_rheo_thermal.cpp b/src/RHEO/atom_vec_rheo_thermal.cpp index 7174d4cb66..f541e2a0cb 100644 --- a/src/RHEO/atom_vec_rheo_thermal.cpp +++ b/src/RHEO/atom_vec_rheo_thermal.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp index 9c198364d6..81e5ba02d1 100644 --- a/src/RHEO/bond_rheo_shell.cpp +++ b/src/RHEO/bond_rheo_shell.cpp @@ -1,3 +1,4 @@ +// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 8b618e6e04..216fcb1978 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -1,3 +1,4 @@ +// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index 672c63ba29..ec8c10f276 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index cb9a42323b..77733f9716 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/compute_rheo_rho_sum.cpp b/src/RHEO/compute_rheo_rho_sum.cpp index d7f432a03d..6e25b35374 100644 --- a/src/RHEO/compute_rheo_rho_sum.cpp +++ b/src/RHEO/compute_rheo_rho_sum.cpp @@ -1,7 +1,8 @@ +// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 284afcd992..69b0ebd108 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index 6e858ca207..b01912111f 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index f12d10b8c5..cd0ca1069a 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index acd833dfda..74d1bbab57 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/fix_rheo_pressure.cpp b/src/RHEO/fix_rheo_pressure.cpp index d6dea8aa1a..82adf52012 100644 --- a/src/RHEO/fix_rheo_pressure.cpp +++ b/src/RHEO/fix_rheo_pressure.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index c1cda67500..dbb59f12f7 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/fix_rheo_viscosity.cpp b/src/RHEO/fix_rheo_viscosity.cpp index 5cb1e7c4d0..3ca7fd8d13 100644 --- a/src/RHEO/fix_rheo_viscosity.cpp +++ b/src/RHEO/fix_rheo_viscosity.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index 731047201c..b9beaf8383 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -1,15 +1,16 @@ +// clang-format off /* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org + 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. + 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. - ------------------------------------------------------------------------- */ + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- Contributing authors: diff --git a/src/RHEO/pair_rheo_solid.cpp b/src/RHEO/pair_rheo_solid.cpp index 9b358420d2..1c8654b3c4 100644 --- a/src/RHEO/pair_rheo_solid.cpp +++ b/src/RHEO/pair_rheo_solid.cpp @@ -1,3 +1,4 @@ +// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories From 0a6fd5b097b7f9ad372ac7ac7afb7ba6c9c52205 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 3 Jul 2024 03:41:57 -0400 Subject: [PATCH 093/104] get rid of some evil tabs --- src/RHEO/compute_rheo_kernel.cpp | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index 77733f9716..a5865b894a 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -249,25 +249,25 @@ double ComputeRHEOKernel::calc_w_quintic(int i, int j, double delx, double dely, double w, tmp1, tmp2, tmp3, tmp1sq, tmp2sq, tmp3sq, s; s = r * 3.0 * cutinv; - if (s > 3.0) { - w = 0.0; - } + if (s > 3.0) { + w = 0.0; + } - if (s <= 3.0) { - tmp3 = 3.0 - s; - tmp3sq = tmp3 * tmp3; - w = tmp3sq * tmp3sq * tmp3; - } - if (s <= 2.0) { + if (s <= 3.0) { + tmp3 = 3.0 - s; + tmp3sq = tmp3 * tmp3; + w = tmp3sq * tmp3sq * tmp3; + } + if (s <= 2.0) { tmp2 = 2.0 - s; tmp2sq = tmp2 * tmp2; w -= 6.0 * tmp2sq * tmp2sq * tmp2; - } - if (s <= 1.0) { - tmp1 = 1.0 - s; - tmp1sq = tmp1 * tmp1; - w += 15.0 * tmp1sq * tmp1sq * tmp1; - } + } + if (s <= 1.0) { + tmp1 = 1.0 - s; + tmp1sq = tmp1 * tmp1; + w += 15.0 * tmp1sq * tmp1sq * tmp1; + } w *= pre_w; @@ -326,9 +326,9 @@ double ComputeRHEOKernel::calc_w_wendlandc4(int i, int j, double delx, double de double w, tmp6, s; s = r * cutinv; - if (s > 1.0) { - w = 0.0; - } else { + if (s > 1.0) { + w = 0.0; + } else { tmp6 = (1.0 - s) * (1.0 - s); tmp6 *= tmp6 * tmp6; w = tmp6 * (1.0 + 6.0 * s + 35.0 * THIRD * s * s); @@ -352,9 +352,9 @@ double ComputeRHEOKernel::calc_dw_wendlandc4(int i, int j, double delx, double d s = r * cutinv; - if (s > 1.0) { - wp = 0.0; - } else { + if (s > 1.0) { + wp = 0.0; + } else { tmp1 = 1.0 - s; tmp5 = tmp1 * tmp1; tmp5 = tmp5 * tmp5 * tmp1; From 1f021782634e3ce346bb54f37346cbcccf9daba6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 3 Jul 2024 09:32:37 -0400 Subject: [PATCH 094/104] make exclusion more specific --- src/.gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/.gitignore b/src/.gitignore index 39c5de7555..5b13a7d55a 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -245,7 +245,8 @@ /pair_tdpd.cpp /pair_tdpd.h -/*rheo* +/*rheo*.cpp +/*rheo*.h /compute_grid.cpp /compute_grid.h From ece17cf56fc3e238d7d5944ce2b00abbea7f9a88 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 3 Jul 2024 15:30:33 -0600 Subject: [PATCH 095/104] Adding rheo make support --- lib/rheo/Makefile.lammps | 7 +++ lib/rheo/README | 5 ++ src/Depend.sh | 4 ++ src/Makefile | 3 ++ src/RHEO/Install.sh | 103 +++++++++++++++++++++++++++++++++++++++ src/RHEO/README | 2 + 6 files changed, 124 insertions(+) create mode 100644 lib/rheo/Makefile.lammps create mode 100644 lib/rheo/README create mode 100644 src/RHEO/Install.sh diff --git a/lib/rheo/Makefile.lammps b/lib/rheo/Makefile.lammps new file mode 100644 index 0000000000..46f6dc7b96 --- /dev/null +++ b/lib/rheo/Makefile.lammps @@ -0,0 +1,7 @@ +# Settings that the LAMMPS build will import when this package is installed + +# change this to -I/path/to/your/lib/gsl/include/ +rheo_SYSINC = -I../../lib/rheo/gsl/include/ + +# change this to -L/path/to/your/lib/gsl/lib/ +rheo_SYSLIB = -L../../lib/rheo/gsl/lib/ -lgslcblas diff --git a/lib/rheo/README b/lib/rheo/README new file mode 100644 index 0000000000..8219d6e21a --- /dev/null +++ b/lib/rheo/README @@ -0,0 +1,5 @@ +This directory has a Makefile.lammps file with settings that allows +LAMMPS to dynamically link to the GSL library. This is +required to use the RHEO package in a LAMMPS input script. + +See the header of Makefile.lammps for more info. diff --git a/src/Depend.sh b/src/Depend.sh index e55b100975..fcd4a20d6f 100755 --- a/src/Depend.sh +++ b/src/Depend.sh @@ -56,6 +56,10 @@ if (test $1 = "ASPHERE") then depend INTEL fi +if (test $1 = "BPM") then + depend RHEO +fi + if (test $1 = "CLASS2") then depend GPU depend KOKKOS diff --git a/src/Makefile b/src/Makefile index 805b950112..4d8b02458a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -124,6 +124,7 @@ PACKAGE = \ reaction \ reaxff \ replica \ + rheo \ rigid \ scafacos \ shock \ @@ -233,6 +234,7 @@ PACKLIB = \ plumed \ qmmm \ ml-quip \ + rheo \ scafacos \ machdyn \ vtk \ @@ -254,6 +256,7 @@ PACKEXT = \ netcdf \ plumed \ qmmm \ + rheo \ scafacos \ voronoi \ vtk \ diff --git a/src/RHEO/Install.sh b/src/RHEO/Install.sh new file mode 100644 index 0000000000..3e3ba75e32 --- /dev/null +++ b/src/RHEO/Install.sh @@ -0,0 +1,103 @@ +# Install/unInstall package files in LAMMPS +# mode = 0/1/2 for uninstall/install/update + +mode=$1 + +# enforce using portable C locale +LC_ALL=C +export LC_ALL + +# arg1 = file, arg2 = file it depends on + +action () { + if (test $mode = 0) then + rm -f ../$1 + elif (! cmp -s $1 ../$1) then + if (test -z "$2" || test -e ../$2) then + cp $1 .. + if (test $mode = 2) then + echo " updating src/$1" + fi + fi + elif (test -n "$2") then + if (test ! -e ../$2) then + rm -f ../$1 + fi + fi +} + +# package files without dependencies +action atom_vec_rheo_thermal.h +action atom_vec_rheo_thermal.cpp +action atom_vec_rheo.h +action atom_vec_rheo.cpp +action compute_rheo_grad.h +action compute_rheo_grad.cpp +action compute_rheo_interface.h +action compute_rheo_interface.cpp +action compute_rheo_kernel.h +action compute_rheo_kernel.cpp +action compute_rheo_rho_sum.h +action compute_rheo_rho_sum.cpp +action compute_rheo_surface.h +action compute_rheo_surface.cpp +action compute_rheo_vshift.h +action compute_rheo_vshift.cpp +action fix_rheo_oxidation.h +action fix_rheo_oxidation.cpp +action fix_rheo_pressure.h +action fix_rheo_pressure.cpp +action fix_rheo_viscosity.h +action fix_rheo_viscosity.cpp +action fix_rheo.h +action fix_rheo.cpp +action pair_rheo.h +action pair_rheo.cpp +action pair_rheo_solid.h +action pair_rheo_solid.cpp + +# package files with dependencies +action bond_rheo_shell.h bond_bpm.h +action bond_rheo_shell.cpp bond_bpm.h +action compute_rheo_property_atom.h fix_update_special_bonds.h +action compute_rheo_property_atom.cpp fix_update_special_bonds.h +action fix_rheo_thermal.h fix_update_special_bonds.h +action fix_rheo_thermal.cpp fix_update_special_bonds.h + +# Warn that some styles in RHEO have base classes in BPM + +if (test $1 = 1) then + if (test ! -e ../bond_bpm.cpp) then + echo "Must install BPM package to use all features of RHEO package" + fi +fi + +# edit 2 Makefile.package files to include/exclude package info + +if (test $1 = 1) then + + if (test -e ../Makefile.package) then + sed -i -e 's/[^ \t]*rheo[^ \t]* //' ../Makefile.package + sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(rheo_SYSINC) |' ../Makefile.package + sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(rheo_SYSLIB) |' ../Makefile.package + fi + + if (test -e ../Makefile.package.settings) then + sed -i -e '/^[ \t]*include.*rheo.*$/d' ../Makefile.package.settings + # multiline form needed for BSD sed on Macs + sed -i -e '4 i \ +include ..\/..\/lib\/rheo\/Makefile.lammps +' ../Makefile.package.settings + fi + +elif (test $1 = 0) then + + if (test -e ../Makefile.package) then + sed -i -e 's/[^ \t]*rheo[^ \t]* //' ../Makefile.package + fi + + if (test -e ../Makefile.package.settings) then + sed -i -e '/^[ \t]*include.*rheo.*$/d' ../Makefile.package.settings + fi + +fi diff --git a/src/RHEO/README b/src/RHEO/README index 7090fc828c..6e8dcfb856 100644 --- a/src/RHEO/README +++ b/src/RHEO/README @@ -2,6 +2,8 @@ RHEO or Reproducing Hydrodynamics and Elastic Objects is a package to model mult systems. The authors include Joel Clemmer (Sandia), Thomas O'Connor (Carnegie Mellon), and Eric Palermo (Carnegie Mellon). +Bond style rheo/shell, compute style rheo/property/atom, and fix style rheo/temperature all depend on the BPM package. + This package requires the GNU scientific library (GSL). We recommend version 2.7 or later. To build this package, one must first separately install GSL in a location that can be found by your environment. From 9b52888e531c09c4e8deef707d06039ec31d554b Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 3 Jul 2024 15:53:38 -0600 Subject: [PATCH 096/104] Adding RHEO dependency to cmake --- cmake/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e66b6b17a7..77f1610064 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -411,6 +411,7 @@ pkg_depends(CG-DNA ASPHERE) pkg_depends(ELECTRODE KSPACE) pkg_depends(EXTRA-MOLECULE MOLECULE) pkg_depends(MESONT MOLECULE) +pkg_depends(RHEO BPM) # detect if we may enable OpenMP support by default set(BUILD_OMP_DEFAULT OFF) From e1232af8677e78b116506e26b23093d2ac1f4640 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 3 Jul 2024 16:12:17 -0600 Subject: [PATCH 097/104] Missing flag and changing dependencies --- lib/rheo/Makefile.lammps | 2 +- src/RHEO/Install.sh | 47 ++++++---------------------------------- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/lib/rheo/Makefile.lammps b/lib/rheo/Makefile.lammps index 46f6dc7b96..3372e9463c 100644 --- a/lib/rheo/Makefile.lammps +++ b/lib/rheo/Makefile.lammps @@ -4,4 +4,4 @@ rheo_SYSINC = -I../../lib/rheo/gsl/include/ # change this to -L/path/to/your/lib/gsl/lib/ -rheo_SYSLIB = -L../../lib/rheo/gsl/lib/ -lgslcblas +rheo_SYSLIB = -L../../lib/rheo/gsl/lib/ -lgsl -lgslcblas diff --git a/src/RHEO/Install.sh b/src/RHEO/Install.sh index 3e3ba75e32..e34ca3a555 100644 --- a/src/RHEO/Install.sh +++ b/src/RHEO/Install.sh @@ -26,52 +26,19 @@ action () { fi } -# package files without dependencies -action atom_vec_rheo_thermal.h -action atom_vec_rheo_thermal.cpp -action atom_vec_rheo.h -action atom_vec_rheo.cpp -action compute_rheo_grad.h -action compute_rheo_grad.cpp -action compute_rheo_interface.h -action compute_rheo_interface.cpp -action compute_rheo_kernel.h -action compute_rheo_kernel.cpp -action compute_rheo_rho_sum.h -action compute_rheo_rho_sum.cpp -action compute_rheo_surface.h -action compute_rheo_surface.cpp -action compute_rheo_vshift.h -action compute_rheo_vshift.cpp -action fix_rheo_oxidation.h -action fix_rheo_oxidation.cpp -action fix_rheo_pressure.h -action fix_rheo_pressure.cpp -action fix_rheo_viscosity.h -action fix_rheo_viscosity.cpp -action fix_rheo.h -action fix_rheo.cpp -action pair_rheo.h -action pair_rheo.cpp -action pair_rheo_solid.h -action pair_rheo_solid.cpp - -# package files with dependencies -action bond_rheo_shell.h bond_bpm.h -action bond_rheo_shell.cpp bond_bpm.h -action compute_rheo_property_atom.h fix_update_special_bonds.h -action compute_rheo_property_atom.cpp fix_update_special_bonds.h -action fix_rheo_thermal.h fix_update_special_bonds.h -action fix_rheo_thermal.cpp fix_update_special_bonds.h - -# Warn that some styles in RHEO have base classes in BPM +# some styles in RHEO have base classes in BPM if (test $1 = 1) then if (test ! -e ../bond_bpm.cpp) then - echo "Must install BPM package to use all features of RHEO package" + echo "Must install BPM package with RHEO" + exit 1 fi fi +for file in *.cpp *.h; do + action ${file} +done + # edit 2 Makefile.package files to include/exclude package info if (test $1 = 1) then From feba9640afc74b2a95b2d9e3c9bbe470d013f707 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 3 Jul 2024 18:22:27 -0400 Subject: [PATCH 098/104] not needed anymore --- src/Depend.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Depend.sh b/src/Depend.sh index fcd4a20d6f..e55b100975 100755 --- a/src/Depend.sh +++ b/src/Depend.sh @@ -56,10 +56,6 @@ if (test $1 = "ASPHERE") then depend INTEL fi -if (test $1 = "BPM") then - depend RHEO -fi - if (test $1 = "CLASS2") then depend GPU depend KOKKOS From 96d58bb03e0fc87d0ca6c4b299347143c5f7f3a8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 3 Jul 2024 18:32:42 -0400 Subject: [PATCH 099/104] automatically set include/libs flags for GSL, if pkg-config is available --- lib/rheo/Makefile.lammps | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/rheo/Makefile.lammps b/lib/rheo/Makefile.lammps index 3372e9463c..ec58740370 100644 --- a/lib/rheo/Makefile.lammps +++ b/lib/rheo/Makefile.lammps @@ -1,7 +1,14 @@ # Settings that the LAMMPS build will import when this package is installed -# change this to -I/path/to/your/lib/gsl/include/ -rheo_SYSINC = -I../../lib/rheo/gsl/include/ +ifeq ($(strip $(shell pkg-config --version)),) + # manual configuration w/o pkg-config/pkgconf + # change this to -I/path/to/your/lib/gsl/include/ + rheo_SYSINC = -I../../lib/rheo/gsl/include/ -# change this to -L/path/to/your/lib/gsl/lib/ -rheo_SYSLIB = -L../../lib/rheo/gsl/lib/ -lgsl -lgslcblas + # change this to -L/path/to/your/lib/gsl/lib/ + rheo_SYSLIB = -L../../lib/rheo/gsl/lib/ -lgsl -lgslcblas +else + # autodetect GSL settings from pkg-config/pkgconf + rheo_SYSINC = $(shell pkg-config --cflags gsl) + rheo_SYSLIB = $(shell pkg-config --libs gsl) +endif From b6d11b5902e3d4357d52aa2c8358ce4086551027 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 3 Jul 2024 19:07:19 -0400 Subject: [PATCH 100/104] document GSL dependency and provide build instructions for RHEO package --- cmake/Modules/Packages/RHEO.cmake | 2 +- doc/src/Build_extras.rst | 40 +++++++++++++++++++++++++++---- doc/src/Packages_details.rst | 20 +++++++++------- lib/rheo/README | 8 ++++--- src/RHEO/README | 15 ++++++------ 5 files changed, 62 insertions(+), 23 deletions(-) diff --git a/cmake/Modules/Packages/RHEO.cmake b/cmake/Modules/Packages/RHEO.cmake index 970a141bbd..be8c22877b 100644 --- a/cmake/Modules/Packages/RHEO.cmake +++ b/cmake/Modules/Packages/RHEO.cmake @@ -1,2 +1,2 @@ -find_package(GSL REQUIRED) +find_package(GSL 2.7 REQUIRED) target_link_libraries(lammps PRIVATE GSL::gsl) diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index f66238c3c9..4802c67420 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -59,6 +59,7 @@ This is the list of packages that may require additional steps. * :ref:`POEMS ` * :ref:`PYTHON ` * :ref:`QMMM ` + * :ref:`RHEO ` * :ref:`SCAFACOS ` * :ref:`VORONOI ` * :ref:`VTK ` @@ -1566,10 +1567,11 @@ LAMMPS build. .. tab:: CMake build When the ``-D PKG_PLUMED=yes`` flag is included in the cmake - command you must ensure that GSL is installed in locations that - are specified in your environment. There are then two additional - variables that control the manner in which PLUMED is obtained and - linked into LAMMPS. + command you must ensure that `the GNU Scientific Library (GSL) + ` is installed in locations + that are accessible in your environment. There are then two + additional variables that control the manner in which PLUMED is + obtained and linked into LAMMPS. .. code-block:: bash @@ -2040,6 +2042,36 @@ verified to work in February 2020 with Quantum Espresso versions 6.3 to ---------- +.. _rheo: + +RHEO package +------------ + +To build with this package you must have the `GNU Scientific Library +(GSL) ` installed in locations that +are accessible in your environment. The GSL library should be at least +version 2.7. + +.. tabs:: + + .. tab:: CMake build + + If CMake cannot find the GSL library or include files, you can set: + + .. code-block:: bash + + -D GSL_ROOT_DIR=path # path to root of GSL installation + + .. tab:: Traditional make + + LAMMPS will try to auto-detect the GSL compiler and linker flags + from the corresponding ``pkg-config`` file (``gsl.pc``), otherwise + you can edit the file ``lib/rheo/Makefile.lammps`` + to specify the paths and library names where indicated by comments. + This must be done **before** the package is installed. + +---------- + .. _scafacos: SCAFACOS package diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index 860ae24489..f3cf086d88 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -8,12 +8,12 @@ info on how to download or build any extra library it requires. It also gives links to documentation, example scripts, and pictures/movies (if available) that illustrate use of the package. -The majority of packages can be included in a LAMMPS build with a -single setting (``-D PKG_=on`` for CMake) or command -(``make yes-`` for make). See the :doc:`Build package ` -page for more info. A few packages may require additional steps; -this is indicated in the descriptions below. The :doc:`Build extras ` -page gives those details. +The majority of packages can be included in a LAMMPS build with a single +setting (``-D PKG_=on`` for CMake) or command (``make yes-`` +for make). See the :doc:`Build package ` page for more +info. A few packages may require additional steps; this is indicated in +the descriptions below. The :doc:`Build extras ` page +gives those details. .. note:: @@ -2630,8 +2630,12 @@ RHEO package **Contents:** Pair styles, bond styles, fixes, and computes for reproducing -hydrodynamics and elastic objects. See the -:doc:`Howto rheo ` page for an overview. +hydrodynamics and elastic objects. See the :doc:`Howto rheo +` page for an overview. + +**Install:** + +This package has :ref:`specific installation instructions ` on the :doc:`Build extras ` page. **Authors:** Joel T. Clemmer (Sandia National Labs), Thomas C. O'Connor (Carnegie Mellon University) diff --git a/lib/rheo/README b/lib/rheo/README index 8219d6e21a..ae421b6e80 100644 --- a/lib/rheo/README +++ b/lib/rheo/README @@ -1,5 +1,7 @@ -This directory has a Makefile.lammps file with settings that allows -LAMMPS to dynamically link to the GSL library. This is -required to use the RHEO package in a LAMMPS input script. +This directory has a Makefile.lammps file with settings that allows LAMMPS to +dynamically link to the GSL library. This is required to use the RHEO package +in a LAMMPS input script. If you have the pkg-config command available, it +will automatically import the GSL settings. Otherwise they will have to be +added manually. See the header of Makefile.lammps for more info. diff --git a/src/RHEO/README b/src/RHEO/README index 6e8dcfb856..4b6f2a162a 100644 --- a/src/RHEO/README +++ b/src/RHEO/README @@ -1,9 +1,10 @@ -RHEO or Reproducing Hydrodynamics and Elastic Objects is a package to model multiphase fluid -systems. The authors include Joel Clemmer (Sandia), Thomas O'Connor (Carnegie Mellon), and -Eric Palermo (Carnegie Mellon). +RHEO or Reproducing Hydrodynamics and Elastic Objects is a package to model +multiphase fluid systems. The authors include Joel Clemmer (Sandia), Thomas +O'Connor (Carnegie Mellon), and Eric Palermo (Carnegie Mellon). -Bond style rheo/shell, compute style rheo/property/atom, and fix style rheo/temperature all depend on the BPM package. +Bond style rheo/shell, compute style rheo/property/atom, and fix style +rheo/temperature all depend on the BPM package. -This package requires the GNU scientific library (GSL). We recommend version 2.7 or later. To -build this package, one must first separately install GSL in a location that can be found by -your environment. +This package requires the GNU scientific library (GSL). We recommend version +2.7 or later. To build this package, one must first separately install GSL in +a location that can be found by your environment. From 0fb74936582fe6ac14e417d50f106d0ba351e3e7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 3 Jul 2024 19:10:37 -0400 Subject: [PATCH 101/104] spelling fixes --- doc/src/Howto_rheo.rst | 10 +++++----- doc/src/atom_modify.rst | 2 +- doc/src/fix_rheo.rst | 4 ++-- doc/src/fix_rheo_pressure.rst | 2 +- doc/src/fix_rheo_thermal.rst | 4 ++-- doc/src/fix_rheo_viscosity.rst | 2 +- doc/utils/sphinx-config/false_positives.txt | 12 ++++++++++++ 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index 4c0f069d92..7c62d09ab1 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -4,7 +4,7 @@ Reproducing hydrodynamics and elastic objects (RHEO) The RHEO package is a hybrid implementation of smoothed particle hydrodynamics (SPH) for fluid flow, coupled to the :doc:`BPM package ` to model solid elements. RHEO combines these methods to enable mesh-free modeling -of multiphase material systems. The SPH solver supports many advanced options +of multi-phase material systems. The SPH solver supports many advanced options including reproducing kernels, particle shifting, free surface identification, and solid surface reconstruction. To model fluid-solid systems, the status of particles can dynamically change between a fluid and solid state, e.g. during @@ -30,7 +30,7 @@ of reproducing kernels). In conjunction to fix rheo, one must specify an instance of :doc:`fix rheo/pressure ` and :doc:`fix rheo/viscosity ` to define a pressure equation of state and viscosity model, respectively. Optionally, one can model -a heat equation with :doc:`fix rheo/thermal `, which also +a heat equation with :doc:`fix rheo/thermal `, which also allows the user to specify equations for a particle's thermal conductivity, specific heat, latent heat, and melting temperature. The ordering of these fixes in an an input script matters. Fix rheo must be defined prior to all @@ -44,7 +44,7 @@ conductivity. Note that the temperature is always derived from the energy. This implies the *temperature* attribute of :doc:`the set command ` does not affect particles. Instead, one should use the *sph/e* attribute. -The status variable uses bitmasking to track various properties of a particle +The status variable uses bit-masking to track various properties of a particle such as its current state of matter (fluid or solid) and its location relative to a surface. Some of these properties (and others) can be accessed using :doc:`compute rheo/property/atom `. The *status* @@ -88,8 +88,8 @@ as bonds are created/broken. The other option for elastic objects is an elastic shell that is nominally much thinner than a particle diameter, e.g. a oxide skin which gradually forms over time on the surface of a fluid. Currently, this is implemented using -:doc:`fix rheo/oxidaton ` and bond style -:doc:`rheo/shell `. Essentially, fix rheo/oxidaton creates candidate +:doc:`fix rheo/oxidation ` and bond style +:doc:`rheo/shell `. Essentially, fix rheo/oxidation creates candidate bonds of a specified type between surface fluid particles within a specified distance. a newly created rheo/shell bond will then start a timer. While the timer is counting down, the bond will delete itself if particles move too far apart or move away from the diff --git a/doc/src/atom_modify.rst b/doc/src/atom_modify.rst index 0d750f1755..9091626feb 100644 --- a/doc/src/atom_modify.rst +++ b/doc/src/atom_modify.rst @@ -190,7 +190,7 @@ Default By default, *id* is yes. By default, atomic systems (no bond topology info) do not use a map. For molecular systems (with bond topology info), the default is to use a map of either *array* or *hash* style -depending on the size of the sustem, as explained above for the *map +depending on the size of the system, as explained above for the *map yes* keyword/value option. By default, a *first* group is not defined. By default, sorting is enabled with a frequency of 1000 and a binsize of 0.0, which means the neighbor cutoff will be used to set diff --git a/doc/src/fix_rheo.rst b/doc/src/fix_rheo.rst index d69b52d751..c9bf0a7aa0 100644 --- a/doc/src/fix_rheo.rst +++ b/doc/src/fix_rheo.rst @@ -90,7 +90,7 @@ In systems with free surfaces, the *surface/detection* keyword can be used to classify the location of particles as being within the bulk fluid, on a free surface, or isolated from other particles in a splash or droplet. Shifting is then disabled in the normal direction away from the free surface -to prevent particles from difusing away. Surface detection can also be used +to prevent particles from diffusing away. Surface detection can also be used to control surface-nucleated effects like oxidation when used in combination with :doc:`fix rheo/oxidation `. Surface detection is not performed on solid bodies. @@ -145,7 +145,7 @@ Restrictions """""""""""" This fix must be used with atom style rheo or rheo/thermal. This fix must -be used in conjuction with :doc:`fix rheo/pressure `. +be used in conjunction with :doc:`fix rheo/pressure `. and :doc:`fix rheo/viscosity `. If the *thermal* setting is used, there must also be an instance of :doc:`fix rheo/thermal `. The fix group must be set to all. diff --git a/doc/src/fix_rheo_pressure.rst b/doc/src/fix_rheo_pressure.rst index e01aebf90f..40d623ae07 100644 --- a/doc/src/fix_rheo_pressure.rst +++ b/doc/src/fix_rheo_pressure.rst @@ -86,7 +86,7 @@ Restrictions This fix must be used with an atom style that includes density such as atom_style rheo or rheo/thermal. This fix must be used in -conjuction with :doc:`fix rheo `. The fix group must be +conjunction with :doc:`fix rheo `. The fix group must be set to all. Only one instance of fix rheo/pressure can be defined. This fix is part of the RHEO package. It is only enabled if diff --git a/doc/src/fix_rheo_thermal.rst b/doc/src/fix_rheo_thermal.rst index e116325091..cf245cbdca 100644 --- a/doc/src/fix_rheo_thermal.rst +++ b/doc/src/fix_rheo_thermal.rst @@ -105,8 +105,8 @@ Restrictions """""""""""" This fix must be used with an atom style that includes temperature, -heatflow, and conductivity such as atom_tyle rheo/thermal This fix -must be used in conjuction with :doc:`fix rheo ` with the +heatflow, and conductivity such as atom_style rheo/thermal This fix +must be used in conjunction with :doc:`fix rheo ` with the *thermal* setting. The fix group must be set to all. Only one instance of fix rheo/pressure can be defined. diff --git a/doc/src/fix_rheo_viscosity.rst b/doc/src/fix_rheo_viscosity.rst index 912de584c2..5eca39dcdd 100644 --- a/doc/src/fix_rheo_viscosity.rst +++ b/doc/src/fix_rheo_viscosity.rst @@ -91,7 +91,7 @@ Restrictions This fix must be used with an atom style that includes viscosity such as atom_style rheo or rheo/thermal. This fix must be used in -conjuction with :doc:`fix rheo `. The fix group must be +conjunction with :doc:`fix rheo `. The fix group must be set to all. Only one instance of fix rheo/viscosity can be defined. This fix is part of the RHEO package. It is only enabled if diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index c300cf608d..babe66d27d 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -393,6 +393,7 @@ buf builtin Bulacu Bulatov +Bulkley Bureekaew burlywood Bussi @@ -564,6 +565,7 @@ cond conda Conda Condens +conductivities conf config configfile @@ -1440,6 +1442,7 @@ henrich Henrich Hermitian Herrmann +Hershchel Hertizian hertzian Hertzsch @@ -1831,6 +1834,7 @@ Kspace KSpace KSpaceStyle Kspring +kstyle kT kTequil kth @@ -2271,6 +2275,7 @@ modelled modelling Modelling Modine +modularity moduli mofff MOFFF @@ -2488,6 +2493,7 @@ Neumann Nevent nevery Nevery +Nevins newfile Newns newtype @@ -3067,6 +3073,7 @@ quatw queryargs Queteschiner quickmin +quintic qw qx qy @@ -3078,6 +3085,7 @@ radialscreenedspin radialspin radian radians +radiative radj Rafferty rahman @@ -3181,6 +3189,7 @@ rg Rg Rhaphson Rhe +rheo rheological rheology rhodo @@ -3268,6 +3277,7 @@ rsort rsq rst rstyle +rsurf Rubensson Rubia Rud @@ -3651,6 +3661,7 @@ Telsa tempCorrCoeff templated Templeton +Tencer Tequil ters tersoff @@ -3997,6 +4008,7 @@ Vries Vsevolod Vsmall Vstream +vstyle vtarget vtk VTK From 8f6cf085e871f4cb1a1aadca6b5f4f7a307b16b3 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 9 Jul 2024 15:06:18 -0600 Subject: [PATCH 102/104] syncing table in build_packages/extra --- doc/src/Build_package.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/Build_package.rst b/doc/src/Build_package.rst index 63ccac534d..b70a1ca4d1 100644 --- a/doc/src/Build_package.rst +++ b/doc/src/Build_package.rst @@ -62,6 +62,7 @@ packages: * :ref:`POEMS ` * :ref:`PYTHON ` * :ref:`QMMM ` + * :ref:`RHEO ` * :ref:`SCAFACOS ` * :ref:`VORONOI ` * :ref:`VTK ` From a9a896c6779317fb6bbbfc5313085da6861ea12b Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 15 Jul 2024 17:19:51 -0600 Subject: [PATCH 103/104] Small doc changes, renaming status variable --- doc/src/Howto_rheo.rst | 33 ++++++++++++----------- examples/rheo/oxidation/in.rheo.oxidation | 3 +-- src/RHEO/atom_vec_rheo.cpp | 28 +++++++++---------- src/RHEO/atom_vec_rheo.h | 2 +- src/RHEO/atom_vec_rheo_thermal.cpp | 28 +++++++++---------- src/RHEO/atom_vec_rheo_thermal.h | 2 +- src/RHEO/bond_rheo_shell.cpp | 2 +- src/RHEO/compute_rheo_grad.cpp | 2 +- src/RHEO/compute_rheo_interface.cpp | 4 +-- src/RHEO/compute_rheo_kernel.cpp | 2 +- src/RHEO/compute_rheo_property_atom.cpp | 32 ++++++---------------- src/RHEO/compute_rheo_property_atom.h | 3 +-- src/RHEO/compute_rheo_surface.cpp | 10 +++---- src/RHEO/compute_rheo_vshift.cpp | 4 +-- src/RHEO/fix_rheo.cpp | 10 +++---- src/RHEO/fix_rheo_oxidation.cpp | 4 +-- src/RHEO/fix_rheo_thermal.cpp | 16 +++++------ src/RHEO/pair_rheo.cpp | 2 +- src/RHEO/pair_rheo_solid.cpp | 6 ++--- src/atom.cpp | 10 +++---- src/atom.h | 4 +-- src/set.cpp | 4 +-- 22 files changed, 97 insertions(+), 114 deletions(-) diff --git a/doc/src/Howto_rheo.rst b/doc/src/Howto_rheo.rst index 7c62d09ab1..34c0f7b6a1 100644 --- a/doc/src/Howto_rheo.rst +++ b/doc/src/Howto_rheo.rst @@ -2,25 +2,26 @@ Reproducing hydrodynamics and elastic objects (RHEO) ==================================================== The RHEO package is a hybrid implementation of smoothed particle -hydrodynamics (SPH) for fluid flow, coupled to the :doc:`BPM package ` -to model solid elements. RHEO combines these methods to enable mesh-free modeling -of multi-phase material systems. The SPH solver supports many advanced options -including reproducing kernels, particle shifting, free surface identification, -and solid surface reconstruction. To model fluid-solid systems, the status of -particles can dynamically change between a fluid and solid state, e.g. during -melting/solidification, which determines how they interact and their physical -behavior. The package is designed with modularity in mind, so one can easily -turn various features on/off, adjust physical details of the system, or -develop new capabilities. For instance, the numerics associated with -calculating gradients, reproducing kernels, etc. are separated into distinct -classes to simplify the development of new integration schemes which can call -these calculations. Additional numerical details can be found in +hydrodynamics (SPH) for fluid flow, which can couple to the :doc:`BPM package +` to model solid elements. RHEO combines these methods to enable +mesh-free modeling of multi-phase material systems. Its SPH solver supports +many advanced options including reproducing kernels, particle shifting, free +surface identification, and solid surface reconstruction. To model fluid-solid +systems, the status of particles can dynamically change between a fluid and +solid state, e.g. during melting/solidification, which determines how they +interact and their physical behavior. The package is designed with modularity +in mind, so one can easily turn various features on/off, adjust physical +details of the system, or develop new capabilities. For instance, the numerics +associated with calculating gradients, reproducing kernels, etc. are separated +into distinctclasses to simplify the development of new integration schemes +which can call these calculations. Additional numerical details can be found in :ref:`(Palermo) ` and :ref:`(Clemmer) `. -Note, if you simply want to run a traditional SPH simulation, the SPH package -is likely better suited for your application. It has fewer advanced features -and therefore benefits from improved performance. +Note, if you simply want to run a traditional SPH simulation, the :ref:`SPH package +` package is likely better suited for your application. It has fewer advanced +features and therefore benefits from improved performance. The :ref:`MACHDYN +` package for solids may also be relevant for fluid-solid problems. ---------- diff --git a/examples/rheo/oxidation/in.rheo.oxidation b/examples/rheo/oxidation/in.rheo.oxidation index d8b4b1a464..57bd71b917 100644 --- a/examples/rheo/oxidation/in.rheo.oxidation +++ b/examples/rheo/oxidation/in.rheo.oxidation @@ -87,7 +87,6 @@ fix 11 all enforce2d compute surf all rheo/property/atom surface compute rho all rheo/property/atom rho compute phase all rheo/property/atom phase -compute status all rheo/property/atom status compute temp all rheo/property/atom temperature compute eng all rheo/property/atom energy compute nbond_shell all rheo/property/atom nbond/shell @@ -98,6 +97,6 @@ compute nbond_solid all nbond/atom bond/type 1 thermo 200 thermo_style custom step time ke press atoms -#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond_solid c_nbond_shell c_rho c_surf c_status +#dump 1 all custom 200 atomDump id type x y vx vy fx fy c_phase c_temp c_eng c_nbond_solid c_nbond_shell c_rho c_surf run 40000 diff --git a/src/RHEO/atom_vec_rheo.cpp b/src/RHEO/atom_vec_rheo.cpp index 92f5ca05a4..0cbebff008 100644 --- a/src/RHEO/atom_vec_rheo.cpp +++ b/src/RHEO/atom_vec_rheo.cpp @@ -33,7 +33,7 @@ AtomVecRHEO::AtomVecRHEO(LAMMPS *lmp) : AtomVec(lmp) mass_type = PER_TYPE; forceclearflag = 1; - atom->status_flag = 1; + atom->rheo_status_flag = 1; atom->pressure_flag = 1; atom->rho_flag = 1; atom->viscosity_flag = 1; @@ -43,17 +43,17 @@ AtomVecRHEO::AtomVecRHEO(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = {"status", "rho", "drho", "pressure", "viscosity"}; - fields_copy = {"status", "rho", "drho", "pressure", "viscosity"}; - fields_comm = {"status", "rho"}; - fields_comm_vel = {"status", "rho"}; + fields_grow = {"rheo_status", "rho", "drho", "pressure", "viscosity"}; + fields_copy = {"rheo_status", "rho", "drho", "pressure", "viscosity"}; + fields_comm = {"rheo_status", "rho"}; + fields_comm_vel = {"rheo_status", "rho"}; fields_reverse = {"drho"}; - fields_border = {"status", "rho"}; - fields_border_vel = {"status", "rho"}; - fields_exchange = {"status", "rho"}; - fields_restart = {"status", "rho"}; - fields_create = {"status", "rho", "drho", "pressure", "viscosity"}; - fields_data_atom = {"id", "type", "status", "rho", "x"}; + fields_border = {"rheo_status", "rho"}; + fields_border_vel = {"rheo_status", "rho"}; + fields_exchange = {"rheo_status", "rho"}; + fields_restart = {"rheo_status", "rho"}; + fields_create = {"rheo_status", "rho", "drho", "pressure", "viscosity"}; + fields_data_atom = {"id", "type", "rheo_status", "rho", "x"}; fields_data_vel = {"id", "v"}; setup_fields(); @@ -66,7 +66,7 @@ AtomVecRHEO::AtomVecRHEO(LAMMPS *lmp) : AtomVec(lmp) void AtomVecRHEO::grow_pointers() { - status = atom->status; + rheo_status = atom->rheo_status; pressure = atom->pressure; rho = atom->rho; drho = atom->drho; @@ -111,7 +111,7 @@ void AtomVecRHEO::data_atom_post(int ilocal) int AtomVecRHEO::property_atom(const std::string &name) { - if (name == "status") return 0; + if (name == "rheo_status") return 0; if (name == "pressure") return 1; if (name == "rho") return 2; if (name == "drho") return 3; @@ -133,7 +133,7 @@ void AtomVecRHEO::pack_property_atom(int index, double *buf, int nvalues, int gr if (index == 0) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) - buf[n] = status[i]; + buf[n] = rheo_status[i]; else buf[n] = 0.0; n += nvalues; diff --git a/src/RHEO/atom_vec_rheo.h b/src/RHEO/atom_vec_rheo.h index 62a7b1a630..8eaa01f7be 100644 --- a/src/RHEO/atom_vec_rheo.h +++ b/src/RHEO/atom_vec_rheo.h @@ -36,7 +36,7 @@ class AtomVecRHEO : virtual public AtomVec { void pack_property_atom(int, double *, int, int) override; private: - int *status; + int *rheo_status; double *pressure, *rho, *drho, *viscosity; }; diff --git a/src/RHEO/atom_vec_rheo_thermal.cpp b/src/RHEO/atom_vec_rheo_thermal.cpp index f541e2a0cb..426c059570 100644 --- a/src/RHEO/atom_vec_rheo_thermal.cpp +++ b/src/RHEO/atom_vec_rheo_thermal.cpp @@ -33,7 +33,7 @@ AtomVecRHEOThermal::AtomVecRHEOThermal(LAMMPS *lmp) : AtomVec(lmp) mass_type = PER_TYPE; forceclearflag = 1; - atom->status_flag = 1; + atom->rheo_status_flag = 1; atom->conductivity_flag = 1; atom->temperature_flag = 1; atom->esph_flag = 1; @@ -47,17 +47,17 @@ AtomVecRHEOThermal::AtomVecRHEOThermal(LAMMPS *lmp) : AtomVec(lmp) // order of fields in a string does not matter // except: fields_data_atom & fields_data_vel must match data file - fields_grow = {"status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_copy = {"status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_comm = {"status", "rho", "esph"}; - fields_comm_vel = {"status", "rho", "esph"}; + fields_grow = {"rheo_status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_copy = {"rheo_status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_comm = {"rheo_status", "rho", "esph"}; + fields_comm_vel = {"rheo_status", "rho", "esph"}; fields_reverse = {"drho", "heatflow"}; - fields_border = {"status", "rho", "esph"}; - fields_border_vel = {"status", "rho", "esph"}; - fields_exchange = {"status", "rho", "esph"}; - fields_restart = {"status", "rho", "esph"}; - fields_create = {"status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; - fields_data_atom = {"id", "type", "status", "rho", "esph", "x"}; + fields_border = {"rheo_status", "rho", "esph"}; + fields_border_vel = {"rheo_status", "rho", "esph"}; + fields_exchange = {"rheo_status", "rho", "esph"}; + fields_restart = {"rheo_status", "rho", "esph"}; + fields_create = {"rheo_status", "rho", "drho", "temperature", "esph", "heatflow", "conductivity", "pressure", "viscosity"}; + fields_data_atom = {"id", "type", "rheo_status", "rho", "esph", "x"}; fields_data_vel = {"id", "v"}; setup_fields(); @@ -70,7 +70,7 @@ AtomVecRHEOThermal::AtomVecRHEOThermal(LAMMPS *lmp) : AtomVec(lmp) void AtomVecRHEOThermal::grow_pointers() { - status = atom->status; + rheo_status = atom->rheo_status; conductivity = atom->conductivity; temperature = atom->temperature; esph = atom->esph; @@ -123,7 +123,7 @@ void AtomVecRHEOThermal::data_atom_post(int ilocal) int AtomVecRHEOThermal::property_atom(const std::string &name) { - if (name == "status") return 0; + if (name == "rheo_status") return 0; if (name == "rho") return 1; if (name == "drho") return 2; if (name == "temperature") return 3; @@ -149,7 +149,7 @@ void AtomVecRHEOThermal::pack_property_atom(int index, double *buf, int nvalues, if (index == 0) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) - buf[n] = status[i]; + buf[n] = rheo_status[i]; else buf[n] = 0.0; n += nvalues; diff --git a/src/RHEO/atom_vec_rheo_thermal.h b/src/RHEO/atom_vec_rheo_thermal.h index 29a764bea9..eaf944ca96 100644 --- a/src/RHEO/atom_vec_rheo_thermal.h +++ b/src/RHEO/atom_vec_rheo_thermal.h @@ -36,7 +36,7 @@ class AtomVecRHEOThermal : virtual public AtomVec { void pack_property_atom(int, double *, int, int) override; private: - int *status; + int *rheo_status; double *conductivity, *temperature, *heatflow, *esph; double *pressure, *rho, *drho, *viscosity; }; diff --git a/src/RHEO/bond_rheo_shell.cpp b/src/RHEO/bond_rheo_shell.cpp index 81e5ba02d1..258d047086 100644 --- a/src/RHEO/bond_rheo_shell.cpp +++ b/src/RHEO/bond_rheo_shell.cpp @@ -182,7 +182,7 @@ void BondRHEOShell::compute(int eflag, int vflag) double **v = atom->v; double **f = atom->f; tagint *tag = atom->tag; - int *status = atom->status; + int *status = atom->rheo_status; int **bondlist = neighbor->bondlist; int nbondlist = neighbor->nbondlist; int nlocal = atom->nlocal; diff --git a/src/RHEO/compute_rheo_grad.cpp b/src/RHEO/compute_rheo_grad.cpp index 216fcb1978..cdf90e1dc5 100644 --- a/src/RHEO/compute_rheo_grad.cpp +++ b/src/RHEO/compute_rheo_grad.cpp @@ -144,7 +144,7 @@ void ComputeRHEOGrad::compute_peratom() double *rho = atom->rho; double *energy = atom->esph; double *viscosity = atom->viscosity; - int *status = atom->status; + int *status = atom->rheo_status; int *type = atom->type; double *mass = atom->mass; int newton = force->newton; diff --git a/src/RHEO/compute_rheo_interface.cpp b/src/RHEO/compute_rheo_interface.cpp index ec8c10f276..8ccd4e6a3b 100644 --- a/src/RHEO/compute_rheo_interface.cpp +++ b/src/RHEO/compute_rheo_interface.cpp @@ -120,7 +120,7 @@ void ComputeRHEOInterface::compute_peratom() double **x = atom->x; int *type = atom->type; int newton = force->newton; - int *status = atom->status; + int *status = atom->rheo_status; double *rho = atom->rho; inum = list->inum; @@ -290,7 +290,7 @@ void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf) { int i, k, j, m; double *rho = atom->rho; - int *status = atom->status; + int *status = atom->rheo_status; m = 0; for (i = 0; i < n; i++) { j = list[i]; diff --git a/src/RHEO/compute_rheo_kernel.cpp b/src/RHEO/compute_rheo_kernel.cpp index a5865b894a..4558ddccc8 100644 --- a/src/RHEO/compute_rheo_kernel.cpp +++ b/src/RHEO/compute_rheo_kernel.cpp @@ -586,7 +586,7 @@ void ComputeRHEOKernel::compute_peratom() int *type = atom->type; double *mass = atom->mass; double *rho = atom->rho; - int *status = atom->status; + int *status = atom->rheo_status; tagint *tag = atom->tag; int *ilist, *jlist, *numneigh, **firstneigh; diff --git a/src/RHEO/compute_rheo_property_atom.cpp b/src/RHEO/compute_rheo_property_atom.cpp index 533822bbdd..7a450e7708 100644 --- a/src/RHEO/compute_rheo_property_atom.cpp +++ b/src/RHEO/compute_rheo_property_atom.cpp @@ -92,8 +92,9 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a for (int iarg = 3; iarg < narg; iarg++) { if (strcmp(arg[iarg], "phase") == 0) { pack_choice[i] = &ComputeRHEOPropertyAtom::pack_phase; - } else if (strcmp(arg[iarg], "rho") == 0) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_rho; + } else if (strcmp(arg[iarg], "status") == 0) { + // Short hand for "rheo_status" + pack_choice[i] = &ComputeRHEOPropertyAtom::pack_status; } else if (strcmp(arg[iarg], "chi") == 0) { interface_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_chi; @@ -111,8 +112,6 @@ ComputeRHEOPropertyAtom::ComputeRHEOPropertyAtom(LAMMPS *lmp, int narg, char **a } else if (strcmp(arg[iarg], "pressure") == 0) { pressure_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_pressure; - } else if (strcmp(arg[iarg], "viscosity") == 0) { - pack_choice[i] = &ComputeRHEOPropertyAtom::pack_viscosity; } else if (strcmp(arg[iarg], "cv") == 0) { thermal_flag = 1; pack_choice[i] = &ComputeRHEOPropertyAtom::pack_cv; @@ -265,7 +264,7 @@ double ComputeRHEOPropertyAtom::memory_usage() void ComputeRHEOPropertyAtom::pack_phase(int n) { - int *status = atom->status; + int *status = atom->rheo_status; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -278,14 +277,14 @@ void ComputeRHEOPropertyAtom::pack_phase(int n) /* ---------------------------------------------------------------------- */ -void ComputeRHEOPropertyAtom::pack_rho(int n) +void ComputeRHEOPropertyAtom::pack_status(int n) { - double *rho = atom->rho; + int *status = atom->rheo_status; int *mask = atom->mask; int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = rho[i]; + if (mask[i] & groupbit) buf[n] = status[i]; else buf[n] = 0.0; n += nvalues; } @@ -310,7 +309,7 @@ void ComputeRHEOPropertyAtom::pack_chi(int n) void ComputeRHEOPropertyAtom::pack_surface(int n) { - int *status = atom->status; + int *status = atom->rheo_status; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -420,21 +419,6 @@ void ComputeRHEOPropertyAtom::pack_pressure(int n) /* ---------------------------------------------------------------------- */ -void ComputeRHEOPropertyAtom::pack_viscosity(int n) -{ - int *mask = atom->mask; - double *viscosity = atom->viscosity; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) buf[n] = viscosity[i]; - else buf[n] = 0.0; - n += nvalues; - } -} - -/* ---------------------------------------------------------------------- */ - void ComputeRHEOPropertyAtom::pack_viscous_stress(int n) { double **gradv = compute_grad->gradv; diff --git a/src/RHEO/compute_rheo_property_atom.h b/src/RHEO/compute_rheo_property_atom.h index b3d247b102..4b1ebf2313 100644 --- a/src/RHEO/compute_rheo_property_atom.h +++ b/src/RHEO/compute_rheo_property_atom.h @@ -45,7 +45,7 @@ class ComputeRHEOPropertyAtom : public Compute { FnPtrPack *pack_choice; // ptrs to pack functions void pack_phase(int); - void pack_rho(int); + void pack_status(int); void pack_chi(int); void pack_surface(int); void pack_surface_r(int); @@ -56,7 +56,6 @@ class ComputeRHEOPropertyAtom : public Compute { void pack_shift_v(int); void pack_gradv(int); void pack_pressure(int); - void pack_viscosity(int); void pack_viscous_stress(int); void pack_total_stress(int); void pack_nbond_shell(int); diff --git a/src/RHEO/compute_rheo_surface.cpp b/src/RHEO/compute_rheo_surface.cpp index 69b0ebd108..c3a3774cdc 100644 --- a/src/RHEO/compute_rheo_surface.cpp +++ b/src/RHEO/compute_rheo_surface.cpp @@ -106,7 +106,7 @@ void ComputeRHEOSurface::compute_peratom() int nlocal = atom->nlocal; double **x = atom->x; - int *status = atom->status; + int *status = atom->rheo_status; int newton = force->newton; int dim = domain->dimension; int *mask = atom->mask; @@ -312,7 +312,7 @@ int ComputeRHEOSurface::pack_reverse_comm(int n, int first, double *buf) { int i,a,b,k,m,last; int dim = domain->dimension; - int *status = atom->status; + int *status = atom->rheo_status; m = 0; last = first + n; @@ -336,7 +336,7 @@ void ComputeRHEOSurface::unpack_reverse_comm(int n, int *list, double *buf) { int i,a,b,k,j,m; int dim = domain->dimension; - int *status = atom->status; + int *status = atom->rheo_status; int tmp1; double tmp2; @@ -367,7 +367,7 @@ int ComputeRHEOSurface::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i,j,a,b,k,m; - int *status = atom->status; + int *status = atom->rheo_status; m = 0; for (i = 0; i < n; i++) { @@ -387,7 +387,7 @@ int ComputeRHEOSurface::pack_forward_comm(int n, int *list, double *buf, void ComputeRHEOSurface::unpack_forward_comm(int n, int first, double *buf) { int i, k, a, b, m, last; - int *status = atom->status; + int *status = atom->rheo_status; m = 0; last = first + n; diff --git a/src/RHEO/compute_rheo_vshift.cpp b/src/RHEO/compute_rheo_vshift.cpp index b01912111f..c06ef533ac 100644 --- a/src/RHEO/compute_rheo_vshift.cpp +++ b/src/RHEO/compute_rheo_vshift.cpp @@ -102,7 +102,7 @@ void ComputeRHEOVShift::compute_peratom() int inum, *ilist, *numneigh, **firstneigh; int *type = atom->type; - int *status = atom->status; + int *status = atom->rheo_status; int *mask = atom->mask; double **x = atom->x; double **v = atom->v; @@ -231,7 +231,7 @@ void ComputeRHEOVShift::correct_surfaces() int i, a, b; - int *status = atom->status; + int *status = atom->rheo_status; int *mask = atom->mask; double **nsurface = compute_surface->nsurface; diff --git a/src/RHEO/fix_rheo.cpp b/src/RHEO/fix_rheo.cpp index cd0ca1069a..f70b9e121f 100644 --- a/src/RHEO/fix_rheo.cpp +++ b/src/RHEO/fix_rheo.cpp @@ -86,7 +86,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR, "fix rheo command requires atom_style with density"); if (atom->viscosity_flag != 1) error->all(FLERR, "fix rheo command requires atom_style with viscosity"); - if (atom->status_flag != 1) + if (atom->rheo_status_flag != 1) error->all(FLERR, "fix rheo command requires atom_style with status"); if (narg < 5) @@ -235,7 +235,7 @@ void FixRHEO::init() if (modify->get_fix_by_style("^rheo$").size() > 1) error->all(FLERR, "Can only specify one instance of fix rheo"); - if (atom->status_flag != 1) + if (atom->rheo_status_flag != 1) error->all(FLERR,"fix rheo command requires atom property status"); if (atom->rho_flag != 1) error->all(FLERR,"fix rheo command requires atom property rho"); @@ -309,7 +309,7 @@ void FixRHEO::initial_integrate(int /*vflag*/) int *type = atom->type; int *mask = atom->mask; - int *status = atom->status; + int *status = atom->rheo_status; double **x = atom->x; double **v = atom->v; double **f = atom->f; @@ -432,7 +432,7 @@ void FixRHEO::pre_force(int /*vflag*/) // Remove temporary options int *mask = atom->mask; - int *status = atom->status; + int *status = atom->rheo_status; int nall = atom->nlocal + atom->nghost; for (int i = 0; i < nall; i++) if (mask[i] & groupbit) @@ -467,7 +467,7 @@ void FixRHEO::final_integrate() double *rmass = atom->rmass; int *type = atom->type; int *mask = atom->mask; - int *status = atom->status; + int *status = atom->rheo_status; int rmass_flag = atom->rmass_flag; int dim = domain->dimension; diff --git a/src/RHEO/fix_rheo_oxidation.cpp b/src/RHEO/fix_rheo_oxidation.cpp index 74d1bbab57..a51f2feb95 100644 --- a/src/RHEO/fix_rheo_oxidation.cpp +++ b/src/RHEO/fix_rheo_oxidation.cpp @@ -163,7 +163,7 @@ void FixRHEOOxidation::post_integrate() int **bond_type = atom->bond_type; int *num_bond = atom->num_bond; int *mask = atom->mask; - int *status = atom->status; + int *status = atom->rheo_status; double *rsurface = compute_surface->rsurface; double **x = atom->x; @@ -255,7 +255,7 @@ void FixRHEOOxidation::post_integrate() void FixRHEOOxidation::post_force(int /*vflag*/) { - int *status = atom->status; + int *status = atom->rheo_status; int *num_bond = atom->num_bond; for (int i = 0; i < atom->nlocal; i++) if (num_bond[i] != 0) diff --git a/src/RHEO/fix_rheo_thermal.cpp b/src/RHEO/fix_rheo_thermal.cpp index dbb59f12f7..daa5b347a7 100644 --- a/src/RHEO/fix_rheo_thermal.cpp +++ b/src/RHEO/fix_rheo_thermal.cpp @@ -326,7 +326,7 @@ void FixRHEOThermal::initial_integrate(int /*vflag*/) if (!fix_rheo->shift_flag) return; int i, a; - int *status = atom->status; + int *status = atom->rheo_status; double *energy = atom->esph; double **grade = compute_grad->grade; double **vshift = compute_vshift->vshift; @@ -351,7 +351,7 @@ void FixRHEOThermal::post_integrate() int i, itype; double cvi, Tci, Ti, Li; - int *status = atom->status; + int *status = atom->rheo_status; double *energy = atom->esph; double *temperature = atom->temperature; double *heatflow = atom->heatflow; @@ -466,7 +466,7 @@ void FixRHEOThermal::pre_force(int /*vflag*/) double *energy = atom->esph; double *temperature = atom->temperature; int *type = atom->type; - int *status = atom->status; + int *status = atom->rheo_status; int nlocal = atom->nlocal; int nall = nlocal + atom->nghost; @@ -494,7 +494,7 @@ void FixRHEOThermal::pre_force(int /*vflag*/) void FixRHEOThermal::final_integrate() { - int *status = atom->status; + int *status = atom->rheo_status; double *energy = atom->esph; double *heatflow = atom->heatflow; @@ -520,7 +520,7 @@ void FixRHEOThermal::break_bonds() int m, n, nmax, i, j, melti, meltj; tagint *tag = atom->tag; - int *status = atom->status; + int *status = atom->rheo_status; int **bond_type = atom->bond_type; tagint **bond_atom = atom->bond_atom; int *num_bond = atom->num_bond; @@ -649,7 +649,7 @@ void FixRHEOThermal::create_bonds() tagint *tag = atom->tag; tagint **bond_atom = atom->bond_atom; - int *status = atom->status; + int *status = atom->rheo_status; int **bond_type = atom->bond_type; int *num_bond = atom->num_bond; double **x = atom->x; @@ -754,7 +754,7 @@ int FixRHEOThermal::pack_forward_comm(int n, int *list, double *buf, int /*pbc_flag*/, int * /*pbc*/) { int i, j, k, m; - int *status = atom->status; + int *status = atom->rheo_status; double **x = atom->x; m = 0; @@ -773,7 +773,7 @@ int FixRHEOThermal::pack_forward_comm(int n, int *list, double *buf, void FixRHEOThermal::unpack_forward_comm(int n, int first, double *buf) { int i, k, m, last; - int *status = atom->status; + int *status = atom->rheo_status; double **x = atom->x; m = 0; last = first + n; diff --git a/src/RHEO/pair_rheo.cpp b/src/RHEO/pair_rheo.cpp index b9beaf8383..9ebf884b6e 100644 --- a/src/RHEO/pair_rheo.cpp +++ b/src/RHEO/pair_rheo.cpp @@ -110,7 +110,7 @@ void PairRHEO::compute(int eflag, int vflag) double *heatflow = atom->heatflow; double *special_lj = force->special_lj; int *type = atom->type; - int *status = atom->status; + int *status = atom->rheo_status; tagint *tag = atom->tag; double **fp_store, *chi; diff --git a/src/RHEO/pair_rheo_solid.cpp b/src/RHEO/pair_rheo_solid.cpp index 1c8654b3c4..070cabaf86 100644 --- a/src/RHEO/pair_rheo_solid.cpp +++ b/src/RHEO/pair_rheo_solid.cpp @@ -74,7 +74,7 @@ void PairRHEOSolid::compute(int eflag, int vflag) double **v = atom->v; double **f = atom->f; int *type = atom->type; - int *status = atom->status; + int *status = atom->rheo_status; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; double *special_lj = force->special_lj; @@ -223,7 +223,7 @@ void PairRHEOSolid::init_style() if (comm->ghost_velocity == 0) error->all(FLERR,"Pair rheo/solid requires ghost atoms store velocity"); - if (!atom->status_flag) + if (!atom->rheo_status_flag) error->all(FLERR,"Pair rheo/solid requires atom_style rheo"); neighbor->add_request(this); @@ -328,7 +328,7 @@ double PairRHEOSolid::single(int i, int j, int itype, int jtype, double rsq, dou if (rsq > cutsq[itype][jtype]) return 0.0; - int *status = atom->status; + int *status = atom->rheo_status; if (!(status[i] & STATUS_SOLID)) return 0.0; if (!(status[j] & STATUS_SOLID)) return 0.0; diff --git a/src/atom.cpp b/src/atom.cpp index 09aaa4f1d8..9af945367b 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -200,7 +200,7 @@ Atom::Atom(LAMMPS *_lmp) : Pointers(_lmp), atom_style(nullptr), avec(nullptr), a // RHEO package - status = nullptr; + rheo_status = nullptr; conductivity = nullptr; pressure = nullptr; viscosity = nullptr; @@ -538,7 +538,7 @@ void Atom::peratom_create() // RHEO package - add_peratom("status",&status,INT,0); + add_peratom("rheo_status",&rheo_status,INT,0); add_peratom("conductivity",&conductivity,DOUBLE,0); add_peratom("pressure",&pressure,DOUBLE,0); add_peratom("viscosity",&viscosity,DOUBLE,0); @@ -648,7 +648,7 @@ void Atom::set_atomflag_defaults() temperature_flag = heatflow_flag = 0; vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; cs_flag = csforce_flag = vforce_flag = ervelforce_flag = etag_flag = 0; - status_flag = conductivity_flag = pressure_flag = viscosity_flag = 0; + rheo_status_flag = conductivity_flag = pressure_flag = viscosity_flag = 0; rho_flag = esph_flag = cv_flag = vest_flag = 0; dpd_flag = edpd_flag = tdpd_flag = 0; sp_flag = 0; @@ -3065,7 +3065,7 @@ void *Atom::extract(const char *name) // RHEO package - if (strcmp(name,"status") == 0) return (void *) status; + if (strcmp(name,"rheo_status") == 0) return (void *) rheo_status; if (strcmp(name,"conductivity") == 0) return (void *) conductivity; if (strcmp(name,"pressure") == 0) return (void *) pressure; if (strcmp(name,"viscosity") == 0) return (void *) viscosity; @@ -3194,7 +3194,7 @@ int Atom::extract_datatype(const char *name) // RHEO package - if (strcmp(name,"status") == 0) return LAMMPS_INT; + if (strcmp(name,"rheo_status") == 0) return LAMMPS_INT; if (strcmp(name,"conductivity") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"pressure") == 0) return LAMMPS_DOUBLE; if (strcmp(name,"viscosity") == 0) return LAMMPS_DOUBLE; diff --git a/src/atom.h b/src/atom.h index 568d78afb2..bd5b352cd0 100644 --- a/src/atom.h +++ b/src/atom.h @@ -157,7 +157,7 @@ class Atom : protected Pointers { // RHEO package - int *status; + int *rheo_status; double *conductivity; double *pressure; double *viscosity; @@ -197,7 +197,7 @@ class Atom : protected Pointers { int temperature_flag, heatflow_flag; int vfrac_flag, spin_flag, eradius_flag, ervel_flag, erforce_flag; int cs_flag, csforce_flag, vforce_flag, ervelforce_flag, etag_flag; - int status_flag, conductivity_flag, pressure_flag, viscosity_flag; + int rheo_status_flag, conductivity_flag, pressure_flag, viscosity_flag; int rho_flag, esph_flag, cv_flag, vest_flag; int dpd_flag, edpd_flag, tdpd_flag; int mesont_flag; diff --git a/src/set.cpp b/src/set.cpp index cd48ba2bfe..93d5068ef3 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -526,7 +526,7 @@ void Set::command(int narg, char **arg) if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "set rheo/status", error); if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1); else ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp); - if (!atom->status_flag) + if (!atom->rheo_status_flag) error->all(FLERR,"Cannot set attribute {} for atom style {}", arg[iarg], atom->get_style()); set(RHEO_STATUS); iarg += 2; @@ -901,7 +901,7 @@ void Set::set(int keyword) else if (keyword == RHEO_STATUS) { if (ivalue != 0 && ivalue != 1) error->one(FLERR,"Invalid value {} in set command for rheo/status", ivalue); - atom->status[i] = ivalue; + atom->rheo_status[i] = ivalue; } else if (keyword == SPH_E) atom->esph[i] = dvalue; From de95eb907af9979519cdfa5a76630b7a22e8b6fd Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 17 Jul 2024 11:53:01 -0600 Subject: [PATCH 104/104] Clarifying comment on breakage in bond hybrid --- src/bond_hybrid.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bond_hybrid.cpp b/src/bond_hybrid.cpp index 1e3e3c66f9..307cbd72fd 100644 --- a/src/bond_hybrid.cpp +++ b/src/bond_hybrid.cpp @@ -142,8 +142,10 @@ void BondHybrid::compute(int eflag, int vflag) } } - // if bond type can be set to zero and deleted, update bondlist_orig - tagint *tag = atom->tag; + // If bond style can be deleted by setting type to zero (BPM or quartic), update bondlist_orig + // Otherwise, bond type could be restored back to its original value during reneighboring + // Use orig_map to propagate changes from temporary bondlist array back to original array + if (partial_flag) { for (m = 0; m < nstyles; m++) { for (i = 0; i < nbondlist[m]; i++) {