Merge branch 'develop' into collected-small-fixes

This commit is contained in:
Axel Kohlmeyer
2024-07-29 15:17:55 -04:00
29 changed files with 365 additions and 280 deletions

View File

@ -247,6 +247,11 @@ defined by the :doc:`atom_style sph <atom_style>` command.
All particles in the group must be mesoscopic SPH/SDPD particles. All particles in the group must be mesoscopic SPH/SDPD particles.
versionchanged:: TBD
This fix is incompatible with deformation controls that remap velocity,
for instance the *remap v* option of :doc:`fix deform <fix_deform>`.
Related commands Related commands
"""""""""""""""" """"""""""""""""

View File

@ -97,6 +97,11 @@ These fixes are part of the DPD-MESO package. They are only enabled if
LAMMPS was built with that package. See the :doc:`Build package LAMMPS was built with that package. See the :doc:`Build package
<Build_package>` page for more info. <Build_package>` page for more info.
versionchanged:: TBD
This fix is incompatible with deformation controls that remap velocity,
for instance the *remap v* option of :doc:`fix deform <fix_deform>`.
Related commands Related commands
"""""""""""""""" """"""""""""""""

View File

@ -353,6 +353,11 @@ defined by the :doc:`atom_style sph <atom_style>` command.
All particles in the group must be mesoscopic SPH/SDPD particles. All particles in the group must be mesoscopic SPH/SDPD particles.
versionchanged:: TBD
This fix is incompatible with deformation controls that remap velocity,
for instance the *remap v* option of :doc:`fix deform <fix_deform>`.
Related commands Related commands
"""""""""""""""" """"""""""""""""

View File

@ -53,6 +53,11 @@ Restrictions
This fix is part of the MACHDYN package. It is only enabled if This fix is part of the MACHDYN package. It is only enabled if
LAMMPS was built with that package. See the :doc:`Build package <Build_package>` page for more info. LAMMPS was built with that package. See the :doc:`Build package <Build_package>` page for more info.
versionchanged:: TBD
This fix is incompatible with deformation controls that remap velocity,
for instance the *remap v* option of :doc:`fix deform <fix_deform>`.
Related commands Related commands
"""""""""""""""" """"""""""""""""

View File

@ -61,6 +61,11 @@ Restrictions
This fix is part of the MACHDYN package. It is only enabled if This fix is part of the MACHDYN package. It is only enabled if
LAMMPS was built with that package. See the :doc:`Build package <Build_package>` page for more info. LAMMPS was built with that package. See the :doc:`Build package <Build_package>` page for more info.
versionchanged:: TBD
This fix is incompatible with deformation controls that remap velocity,
for instance the *remap v* option of :doc:`fix deform <fix_deform>`.
Related commands Related commands
"""""""""""""""" """"""""""""""""

View File

@ -24,6 +24,7 @@
#include "fix_mvv_dpd.h" #include "fix_mvv_dpd.h"
#include "atom.h" #include "atom.h"
#include "domain.h"
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "update.h" #include "update.h"
@ -65,6 +66,11 @@ void FixMvvDPD::init()
if (!atom->vest_flag) if (!atom->vest_flag)
error->all(FLERR,"Fix mvv/dpd requires atom attribute vest e.g. from atom style mdpd"); error->all(FLERR,"Fix mvv/dpd requires atom attribute vest e.g. from atom style mdpd");
// Cannot use vremap since its effects aren't propagated to vest
// see RHEO or SPH packages for examples of patches
if (domain->deform_vremap)
error->all(FLERR, "Fix mvv/dpd cannot be used with velocity remapping");
if (!force->pair_match("^mdpd",0) && !force->pair_match("^dpd",0)) { if (!force->pair_match("^mdpd",0) && !force->pair_match("^dpd",0)) {
if (force->pair_match("^hybrid",0)) { if (force->pair_match("^hybrid",0)) {
if (!(force->pair_match("^mdpd",0,1) || force->pair_match("^dpd",0),1)) { if (!(force->pair_match("^mdpd",0,1) || force->pair_match("^dpd",0),1)) {

View File

@ -33,6 +33,7 @@
#include "fix_mvv_edpd.h" #include "fix_mvv_edpd.h"
#include "atom.h" #include "atom.h"
#include "domain.h"
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "update.h" #include "update.h"
@ -73,6 +74,11 @@ void FixMvvEDPD::init()
{ {
if (!atom->edpd_flag) error->all(FLERR,"Fix mvv/edpd requires atom style edpd"); if (!atom->edpd_flag) error->all(FLERR,"Fix mvv/edpd requires atom style edpd");
// Cannot use vremap since its effects aren't propagated to vest
// see RHEO or SPH packages for examples of patches
if (domain->deform_vremap)
error->all(FLERR, "Fix mvv/edpd cannot be used with velocity remapping");
if (!force->pair_match("^edpd",0)) { if (!force->pair_match("^edpd",0)) {
if (force->pair_match("^hybrid",0)) { if (force->pair_match("^hybrid",0)) {
if (!force->pair_match("^edpd",0,1)) { if (!force->pair_match("^edpd",0,1)) {

View File

@ -29,6 +29,7 @@
#include "fix_mvv_tdpd.h" #include "fix_mvv_tdpd.h"
#include "atom.h" #include "atom.h"
#include "domain.h"
#include "error.h" #include "error.h"
#include "force.h" #include "force.h"
#include "update.h" #include "update.h"
@ -71,6 +72,11 @@ void FixMvvTDPD::init()
{ {
if (!atom->tdpd_flag) error->all(FLERR,"Fix mvv/tdpd requires atom style tdpd"); if (!atom->tdpd_flag) error->all(FLERR,"Fix mvv/tdpd requires atom style tdpd");
// Cannot use vremap since its effects aren't propagated to vest
// see RHEO or SPH packages for examples of patches
if (domain->deform_vremap)
error->all(FLERR, "Fix mvv/tdpd cannot be used with velocity remapping");
if (!force->pair_match("^tdpd",0)) { if (!force->pair_match("^tdpd",0)) {
if (force->pair_match("^hybrid",0)) { if (force->pair_match("^hybrid",0)) {
if (!force->pair_match("^tdpd",0,1)) { if (!force->pair_match("^tdpd",0,1)) {

View File

@ -350,7 +350,14 @@ void FixMesoMove::init () {
} }
void FixMesoMove::setup_pre_force (int /*vflag*/) { void FixMesoMove::setup_pre_force (int /*vflag*/) {
// Cannot use vremap since its effects aren't propagated to vest
// see RHEO or SPH packages for examples of patches
if (domain->deform_vremap)
error->all(FLERR, "Fix meso/move cannot be used with velocity remapping");
// set vest equal to v // set vest equal to v
double **v = atom->v; double **v = atom->v;
double **vest = atom->vest; double **vest = atom->vest;
int *mask = atom->mask; int *mask = atom->mask;

View File

@ -29,11 +29,12 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_rigid_meso.h" #include "fix_rigid_meso.h"
#include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "domain.h" #include "domain.h"
#include "memory.h"
#include "error.h" #include "error.h"
#include "math_extra.h"
#include "memory.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -92,6 +93,11 @@ void FixRigidMeso::setup (int vflag) {
conjqm[ibody][2] *= 2.0; conjqm[ibody][2] *= 2.0;
conjqm[ibody][3] *= 2.0; conjqm[ibody][3] *= 2.0;
} }
// Cannot use vremap since its effects aren't propagated to vest
// see RHEO or SPH packages for examples of patches
if (domain->deform_vremap)
error->all(FLERR, "Fix rigid/meso cannot be used with velocity remapping");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -24,15 +24,18 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_smd_integrate_tlsph.h" #include "fix_smd_integrate_tlsph.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "pair.h"
#include "update.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <Eigen/Eigen> #include <Eigen/Eigen>
#include "atom.h"
#include "force.h"
#include "update.h"
#include "error.h"
#include "pair.h"
#include "comm.h"
using namespace Eigen; using namespace Eigen;
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -115,6 +118,11 @@ void FixSMDIntegrateTlsph::init() {
dtv = update->dt; dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
vlimitsq = vlimit * vlimit; vlimitsq = vlimit * vlimit;
// Cannot use vremap since its effects aren't propagated to vest
// see RHEO or SPH packages for examples of patches
if (domain->deform_vremap)
error->all(FLERR, "Fix smd/integrate_tlsph cannot be used with velocity remapping");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -24,15 +24,18 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_smd_integrate_ulsph.h" #include "fix_smd_integrate_ulsph.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "pair.h"
#include "update.h"
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <Eigen/Eigen> #include <Eigen/Eigen>
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "update.h"
#include "error.h"
#include "pair.h"
using namespace Eigen; using namespace Eigen;
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -144,6 +147,11 @@ void FixSMDIntegrateUlsph::init() {
dtv = update->dt; dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
vlimitsq = vlimit * vlimit; vlimitsq = vlimit * vlimit;
// Cannot use vremap since its effects aren't propagated to vest
// see RHEO or SPH packages for examples of patches
if (domain->deform_vremap)
error->all(FLERR, "Fix smd/integrate_ulsph cannot be used with velocity remapping");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -188,6 +188,7 @@ FixIPI::FixIPI(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), irregul
master = (comm->me == 0) ? 1 : 0; master = (comm->me == 0) ? 1 : 0;
inet = 1; inet = 1;
reset_flag = 0; reset_flag = 0;
firsttime = 1;
int iarg = 5; int iarg = 5;
while (iarg < narg) { while (iarg < narg) {
@ -253,6 +254,7 @@ void FixIPI::init()
ipisock = 0; ipisock = 0;
// TODO: should check for success in socket opening, // TODO: should check for success in socket opening,
// but the current open_socket routine dies brutally if unsuccessful // but the current open_socket routine dies brutally if unsuccessful
// tell lammps we have assigned a socket // tell lammps we have assigned a socket
socketflag = 1; socketflag = 1;
@ -373,13 +375,20 @@ void FixIPI::initial_integrate(int /*vflag*/)
if (domain->triclinic) domain->x2lamda(atom->nlocal); if (domain->triclinic) domain->x2lamda(atom->nlocal);
domain->pbc(); domain->pbc();
domain->reset_box(); domain->reset_box();
// move atoms to new processors via irregular()
// only needed if migrate_check() says an atom moves to far
if (irregular->migrate_check()) irregular->migrate_atoms();
if (domain->triclinic) domain->lamda2x(atom->nlocal); if (domain->triclinic) domain->lamda2x(atom->nlocal);
// ensures continuity of trajectories relative to the // ensures continuity of trajectories relative to the
// snapshot at neighbor list creation, minimizing the // snapshot at neighbor list creation, minimizing the
// number of neighbor list updates // number of neighbor list updates
auto xhold = neighbor->get_xhold(); auto xhold = neighbor->get_xhold();
if (xhold != NULL) { // don't wrap if xhold is not used in the NL if (xhold != NULL && !firsttime) {
// don't wrap if xhold is not used in the NL, or the
// first call (because the NL is initialized from the
// data file that might have nothing to do with the
// current structure
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
auto delx = x[i][0] - xhold[i][0]; auto delx = x[i][0] - xhold[i][0];
@ -394,11 +403,7 @@ void FixIPI::initial_integrate(int /*vflag*/)
} }
} }
} }
// move atoms to new processors via irregular() firsttime = 0;
// only needed if migrate_check() says an atom moves to far
if (domain->triclinic) domain->x2lamda(atom->nlocal);
if (irregular->migrate_check()) irregular->migrate_atoms();
if (domain->triclinic) domain->lamda2x(atom->nlocal);
// check if kspace solver is used // check if kspace solver is used
if (reset_flag && kspace_flag) { if (reset_flag && kspace_flag) {

View File

@ -42,6 +42,7 @@ class FixIPI : public Fix {
long bsize; long bsize;
int kspace_flag; int kspace_flag;
int reset_flag; int reset_flag;
int firsttime;
private: private:
class Irregular *irregular; class Irregular *irregular;

View File

@ -13,13 +13,15 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "compute_sph_e_atom.h" #include "compute_sph_e_atom.h"
#include <cstring>
#include "atom.h" #include "atom.h"
#include "update.h"
#include "modify.h"
#include "comm.h" #include "comm.h"
#include "memory.h"
#include "error.h" #include "error.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -31,7 +33,7 @@ ComputeSPHEAtom::ComputeSPHEAtom(LAMMPS *lmp, int narg, char **arg) :
if (narg != 3) if (narg != 3)
error->all(FLERR,"Number of arguments for compute sph/e/atom command != 3"); error->all(FLERR,"Number of arguments for compute sph/e/atom command != 3");
if (atom->esph_flag != 1) if (atom->esph_flag != 1)
error->all(FLERR,"Compute sph/e/atom command requires atom_style sph)"); error->all(FLERR,"Compute sph/e/atom requires atom attribute energy, e.g. in atom_style sph");
peratom_flag = 1; peratom_flag = 1;
size_peratom_cols = 0; size_peratom_cols = 0;
@ -51,12 +53,11 @@ ComputeSPHEAtom::~ComputeSPHEAtom()
void ComputeSPHEAtom::init() void ComputeSPHEAtom::init()
{ {
int count = 0; int count = 0;
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"evector/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"sph/e/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning(FLERR,"More than one compute evector/atom"); error->warning(FLERR,"More than one compute sph/e/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -81,8 +82,7 @@ void ComputeSPHEAtom::compute_peratom()
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
evector[i] = esph[i]; evector[i] = esph[i];
} } else {
else {
evector[i] = 0.0; evector[i] = 0.0;
} }
} }

View File

@ -13,13 +13,15 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "compute_sph_rho_atom.h" #include "compute_sph_rho_atom.h"
#include <cstring>
#include "atom.h" #include "atom.h"
#include "update.h"
#include "modify.h"
#include "comm.h" #include "comm.h"
#include "memory.h"
#include "error.h" #include "error.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -30,8 +32,7 @@ ComputeSPHRhoAtom::ComputeSPHRhoAtom(LAMMPS *lmp, int narg, char **arg) :
{ {
if (narg != 3) error->all(FLERR,"Illegal compute sph/rho/atom command"); if (narg != 3) error->all(FLERR,"Illegal compute sph/rho/atom command");
if (atom->rho_flag != 1) if (atom->rho_flag != 1)
error->all(FLERR,"Compute sph/rho/atom command requires atom_style sph"); error->all(FLERR, "Compute sph/rho/atom requires atom attribute density, e.g. in atom_style sph");
peratom_flag = 1; peratom_flag = 1;
size_peratom_cols = 0; size_peratom_cols = 0;
@ -50,12 +51,11 @@ ComputeSPHRhoAtom::~ComputeSPHRhoAtom()
void ComputeSPHRhoAtom::init() void ComputeSPHRhoAtom::init()
{ {
int count = 0; int count = 0;
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"rhoVector/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"sph/rho/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning(FLERR,"More than one compute rhoVector/atom"); error->warning(FLERR,"More than one compute sph/rho/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -73,8 +73,6 @@ void ComputeSPHRhoAtom::compute_peratom()
vector_atom = rhoVector; vector_atom = rhoVector;
} }
// compute kinetic energy for each atom in group
double *rho = atom->rho; double *rho = atom->rho;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -82,8 +80,7 @@ void ComputeSPHRhoAtom::compute_peratom()
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
rhoVector[i] = rho[i]; rhoVector[i] = rho[i];
} } else {
else {
rhoVector[i] = 0.0; rhoVector[i] = 0.0;
} }
} }

View File

@ -13,13 +13,15 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "compute_sph_t_atom.h" #include "compute_sph_t_atom.h"
#include <cstring>
#include "atom.h" #include "atom.h"
#include "update.h"
#include "modify.h"
#include "comm.h" #include "comm.h"
#include "memory.h"
#include "error.h" #include "error.h"
#include "memory.h"
#include "modify.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -31,7 +33,7 @@ ComputeSPHTAtom::ComputeSPHTAtom(LAMMPS *lmp, int narg, char **arg) :
if (narg != 3) if (narg != 3)
error->all(FLERR,"Number of arguments for compute sph/t/atom command != 3"); error->all(FLERR,"Number of arguments for compute sph/t/atom command != 3");
if ((atom->esph_flag != 1) || (atom->cv_flag != 1)) if ((atom->esph_flag != 1) || (atom->cv_flag != 1))
error->all(FLERR,"Compute sph/t/atom command requires atom_style sph"); error->all(FLERR, "Compute sph/t/atom requires atom attributes energy and specific heat, e.g. in atom_style sph");
peratom_flag = 1; peratom_flag = 1;
size_peratom_cols = 0; size_peratom_cols = 0;
@ -51,12 +53,11 @@ ComputeSPHTAtom::~ComputeSPHTAtom()
void ComputeSPHTAtom::init() void ComputeSPHTAtom::init()
{ {
int count = 0; int count = 0;
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"meso/t/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"sph/t/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning(FLERR,"More than one compute meso/t/atom"); error->warning(FLERR,"More than one compute sph/t/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -84,8 +85,7 @@ void ComputeSPHTAtom::compute_peratom()
if (cv[i] > 0.0) { if (cv[i] > 0.0) {
tvector[i] = esph[i] / cv[i]; tvector[i] = esph[i] / cv[i];
} }
} } else {
else {
tvector[i] = 0.0; tvector[i] = 0.0;
} }
} }

View File

@ -13,10 +13,13 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_sph.h" #include "fix_sph.h"
#include "atom.h" #include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "update.h" #include "update.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -24,11 +27,10 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixSPH::FixSPH(LAMMPS *lmp, int narg, char **arg) : FixSPH::FixSPH(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) { Fix(lmp, narg, arg)
{
if ((atom->esph_flag != 1) || (atom->rho_flag != 1)) if ((atom->esph_flag != 1) || (atom->rho_flag != 1) || (atom->vest_flag != 1))
error->all(FLERR, error->all(FLERR, "Fix sph requires atom attributes energy, density, and velocity estimates, e.g. in atom_style sph");
"Fix sph command requires atom_style with both energy and density");
if (narg != 3) if (narg != 3)
error->all(FLERR,"Illegal number of arguments for fix sph command"); error->all(FLERR,"Illegal number of arguments for fix sph command");
@ -38,7 +40,8 @@ FixSPH::FixSPH(LAMMPS *lmp, int narg, char **arg) :
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int FixSPH::setmask() { int FixSPH::setmask()
{
int mask = 0; int mask = 0;
mask |= INITIAL_INTEGRATE; mask |= INITIAL_INTEGRATE;
mask |= FINAL_INTEGRATE; mask |= FINAL_INTEGRATE;
@ -48,13 +51,20 @@ int FixSPH::setmask() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixSPH::init() { void FixSPH::init()
{
dtv = update->dt; dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
} }
/* ---------------------------------------------------------------------- */
void FixSPH::setup_pre_force(int /*vflag*/) void FixSPH::setup_pre_force(int /*vflag*/)
{ {
remap_v_flag = domain->deform_vremap;
if (remap_v_flag && (!comm->ghost_velocity))
error->all(FLERR, "Fix sph requires ghost atoms store velocity when deforming with remap v");
// set vest equal to v // set vest equal to v
double **v = atom->v; double **v = atom->v;
double **vest = atom->vest; double **vest = atom->vest;
@ -76,7 +86,8 @@ void FixSPH::setup_pre_force(int /*vflag*/)
allow for both per-type and per-atom mass allow for both per-type and per-atom mass
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void FixSPH::initial_integrate(int /*vflag*/) { void FixSPH::initial_integrate(int /*vflag*/)
{
// update v and x and rho and e of atoms in group // update v and x and rho and e of atoms in group
double **x = atom->x; double **x = atom->x;
@ -112,9 +123,16 @@ void FixSPH::initial_integrate(int /*vflag*/) {
rho[i] += dtf * drho[i]; // ... and density rho[i] += dtf * drho[i]; // ... and density
// extrapolate velocity for use with velocity-dependent potentials, e.g. SPH // extrapolate velocity for use with velocity-dependent potentials, e.g. SPH
// if velocities are remapped, perform this extrapolation after communication
if (remap_v_flag) {
vest[i][0] = dtfm * f[i][0];
vest[i][1] = dtfm * f[i][1];
vest[i][2] = dtfm * f[i][2];
} else {
vest[i][0] = v[i][0] + 2.0 * dtfm * f[i][0]; vest[i][0] = v[i][0] + 2.0 * dtfm * f[i][0];
vest[i][1] = v[i][1] + 2.0 * dtfm * f[i][1]; vest[i][1] = v[i][1] + 2.0 * dtfm * f[i][1];
vest[i][2] = v[i][2] + 2.0 * dtfm * f[i][2]; vest[i][2] = v[i][2] + 2.0 * dtfm * f[i][2];
}
v[i][0] += dtfm * f[i][0]; v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1]; v[i][1] += dtfm * f[i][1];
@ -129,8 +147,33 @@ void FixSPH::initial_integrate(int /*vflag*/) {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixSPH::final_integrate() { void FixSPH::pre_force(int /*vflag*/)
{
// if velocities are remapped, calculate estimates here
// note that vest currently stores dtfm * force
if (!remap_v_flag) return;
double **v = atom->v;
double **vest = atom->vest;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup)
nlocal = atom->nfirst;
int nall = nlocal + atom->nghost;
for (int i = 0; i < nall; i++) {
if (mask[i] & groupbit) {
vest[i][0] += v[i][0];
vest[i][1] += v[i][1];
vest[i][2] += v[i][2];
}
}
}
/* ---------------------------------------------------------------------- */
void FixSPH::final_integrate()
{
// update v, rho, and e of atoms in group // update v, rho, and e of atoms in group
double **v = atom->v; double **v = atom->v;
@ -169,7 +212,8 @@ void FixSPH::final_integrate() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixSPH::reset_dt() { void FixSPH::reset_dt()
{
dtv = update->dt; dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
} }

View File

@ -30,6 +30,7 @@ class FixSPH : public Fix {
int setmask() override; int setmask() override;
void init() override; void init() override;
void setup_pre_force(int) override; void setup_pre_force(int) override;
void pre_force(int) override;
void initial_integrate(int) override; void initial_integrate(int) override;
void final_integrate() override; void final_integrate() override;
void reset_dt() override; void reset_dt() override;
@ -41,6 +42,7 @@ class FixSPH : public Fix {
double dtv, dtf; double dtv, dtf;
double *step_respa; double *step_respa;
int mass_require; int mass_require;
int remap_v_flag;
class Pair *pair; class Pair *pair;
}; };

View File

@ -13,10 +13,11 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "fix_sph_stationary.h" #include "fix_sph_stationary.h"
#include "atom.h" #include "atom.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "update.h" #include "update.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
@ -24,11 +25,10 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixSPHStationary::FixSPHStationary(LAMMPS *lmp, int narg, char **arg) : FixSPHStationary::FixSPHStationary(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) { Fix(lmp, narg, arg)
{
if ((atom->esph_flag != 1) || (atom->rho_flag != 1)) if ((atom->esph_flag != 1) || (atom->rho_flag != 1))
error->all(FLERR, error->all(FLERR, "Fix sph/stationary requires atom attributes energy and density, e.g. in atom_style sph");
"Fix sph/stationary command requires atom_style with both energy and density, e.g. meso");
if (narg != 3) if (narg != 3)
error->all(FLERR,"Illegal number of arguments for fix sph/stationary command"); error->all(FLERR,"Illegal number of arguments for fix sph/stationary command");
@ -38,7 +38,8 @@ FixSPHStationary::FixSPHStationary(LAMMPS *lmp, int narg, char **arg) :
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int FixSPHStationary::setmask() { int FixSPHStationary::setmask()
{
int mask = 0; int mask = 0;
mask |= INITIAL_INTEGRATE; mask |= INITIAL_INTEGRATE;
mask |= FINAL_INTEGRATE; mask |= FINAL_INTEGRATE;
@ -47,7 +48,8 @@ int FixSPHStationary::setmask() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixSPHStationary::init() { void FixSPHStationary::init()
{
dtv = update->dt; dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
} }
@ -56,8 +58,8 @@ void FixSPHStationary::init() {
allow for both per-type and per-atom mass allow for both per-type and per-atom mass
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void FixSPHStationary::initial_integrate(int /*vflag*/) { void FixSPHStationary::initial_integrate(int /*vflag*/)
{
double *rho = atom->rho; double *rho = atom->rho;
double *drho = atom->drho; double *drho = atom->drho;
double *esph = atom->esph; double *esph = atom->esph;
@ -80,8 +82,8 @@ void FixSPHStationary::initial_integrate(int /*vflag*/) {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixSPHStationary::final_integrate() { void FixSPHStationary::final_integrate()
{
double *esph = atom->esph; double *esph = atom->esph;
double *desph = atom->desph; double *desph = atom->desph;
double *rho = atom->rho; double *rho = atom->rho;
@ -101,7 +103,8 @@ void FixSPHStationary::final_integrate() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixSPHStationary::reset_dt() { void FixSPHStationary::reset_dt()
{
dtv = update->dt; dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
} }

View File

@ -33,9 +33,6 @@ class FixSPHStationary : public Fix {
void final_integrate() override; void final_integrate() override;
void reset_dt() override; void reset_dt() override;
private:
class NeighList *list;
protected: protected:
double dtv, dtf; double dtv, dtf;
double *step_respa; double *step_respa;

View File

@ -13,14 +13,15 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "pair_sph_heatconduction.h" #include "pair_sph_heatconduction.h"
#include <cmath>
#include "atom.h" #include "atom.h"
#include "domain.h"
#include "error.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
#include "error.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "domain.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -28,12 +29,16 @@ using namespace LAMMPS_NS;
PairSPHHeatConduction::PairSPHHeatConduction(LAMMPS *lmp) : Pair(lmp) PairSPHHeatConduction::PairSPHHeatConduction(LAMMPS *lmp) : Pair(lmp)
{ {
if ((atom->esph_flag != 1) || (atom->rho_flag != 1))
error->all(FLERR, "Pair sph/heatconduction requires atom attributes energy and density, e.g. in atom_style sph");
restartinfo = 0; restartinfo = 0;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
PairSPHHeatConduction::~PairSPHHeatConduction() { PairSPHHeatConduction::~PairSPHHeatConduction()
{
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
memory->destroy(cutsq); memory->destroy(cutsq);
@ -44,7 +49,8 @@ PairSPHHeatConduction::~PairSPHHeatConduction() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairSPHHeatConduction::compute(int eflag, int vflag) { void PairSPHHeatConduction::compute(int eflag, int vflag)
{
int i, j, ii, jj, inum, jnum, itype, jtype; int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz; double xtmp, ytmp, ztmp, delx, dely, delz;
@ -124,7 +130,6 @@ void PairSPHHeatConduction::compute(int eflag, int vflag) {
if (newton_pair || j < nlocal) { if (newton_pair || j < nlocal) {
desph[j] -= deltaE; desph[j] -= deltaE;
} }
} }
} }
} }
@ -134,7 +139,8 @@ void PairSPHHeatConduction::compute(int eflag, int vflag) {
allocate all arrays allocate all arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHHeatConduction::allocate() { void PairSPHHeatConduction::allocate()
{
allocated = 1; allocated = 1;
int n = atom->ntypes; int n = atom->ntypes;
@ -152,7 +158,8 @@ void PairSPHHeatConduction::allocate() {
global settings global settings
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHHeatConduction::settings(int narg, char **/*arg*/) { void PairSPHHeatConduction::settings(int narg, char **/*arg*/)
{
if (narg != 0) if (narg != 0)
error->all(FLERR, error->all(FLERR,
"Illegal number of arguments for pair_style sph/heatconduction"); "Illegal number of arguments for pair_style sph/heatconduction");
@ -162,7 +169,8 @@ void PairSPHHeatConduction::settings(int narg, char **/*arg*/) {
set coeffs for one or more type pairs set coeffs for one or more type pairs
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHHeatConduction::coeff(int narg, char **arg) { void PairSPHHeatConduction::coeff(int narg, char **arg)
{
if (narg != 4) if (narg != 4)
error->all(FLERR,"Incorrect number of args for pair_style sph/heatconduction coefficients"); error->all(FLERR,"Incorrect number of args for pair_style sph/heatconduction coefficients");
if (!allocated) if (!allocated)
@ -178,7 +186,6 @@ void PairSPHHeatConduction::coeff(int narg, char **arg) {
int count = 0; int count = 0;
for (int i = ilo; i <= ihi; i++) { for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = MAX(jlo,i); j <= jhi; j++) {
//printf("setting cut[%d][%d] = %f\n", i, j, cut_one);
cut[i][j] = cut_one; cut[i][j] = cut_one;
alpha[i][j] = alpha_one; alpha[i][j] = alpha_one;
setflag[i][j] = 1; setflag[i][j] = 1;
@ -194,7 +201,8 @@ void PairSPHHeatConduction::coeff(int narg, char **arg) {
init for one type pair i,j and corresponding j,i init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairSPHHeatConduction::init_one(int i, int j) { double PairSPHHeatConduction::init_one(int i, int j)
{
if (setflag[i][j] == 0) { if (setflag[i][j] == 0) {
error->all(FLERR,"All pair sph/heatconduction coeffs are not set"); error->all(FLERR,"All pair sph/heatconduction coeffs are not set");
@ -209,7 +217,8 @@ double PairSPHHeatConduction::init_one(int i, int j) {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double PairSPHHeatConduction::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/, double PairSPHHeatConduction::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/,
double /*rsq*/, double /*factor_coul*/, double /*factor_lj*/, double &fforce) { double /*rsq*/, double /*factor_coul*/, double /*factor_lj*/, double &fforce)
{
fforce = 0.0; fforce = 0.0;
return 0.0; return 0.0;

View File

@ -13,14 +13,15 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "pair_sph_idealgas.h" #include "pair_sph_idealgas.h"
#include <cmath>
#include "atom.h"
#include "force.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "domain.h"
#include "atom.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "neigh_list.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -28,12 +29,17 @@ using namespace LAMMPS_NS;
PairSPHIdealGas::PairSPHIdealGas(LAMMPS *lmp) : Pair(lmp) PairSPHIdealGas::PairSPHIdealGas(LAMMPS *lmp) : Pair(lmp)
{ {
if ((atom->esph_flag != 1) || (atom->rho_flag != 1) || (atom->vest_flag != 1))
error->all(FLERR, "Pair sph/idealgas requires atom attributes energy, density, and velocity estimates, e.g. in atom_style sph");
restartinfo = 0; restartinfo = 0;
single_enable = 0;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
PairSPHIdealGas::~PairSPHIdealGas() { PairSPHIdealGas::~PairSPHIdealGas()
{
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
memory->destroy(cutsq); memory->destroy(cutsq);
@ -45,7 +51,8 @@ PairSPHIdealGas::~PairSPHIdealGas() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairSPHIdealGas::compute(int eflag, int vflag) { void PairSPHIdealGas::compute(int eflag, int vflag)
{
int i, j, ii, jj, inum, jnum, itype, jtype; int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, fpair; double xtmp, ytmp, ztmp, delx, dely, delz, fpair;
@ -160,10 +167,6 @@ void PairSPHIdealGas::compute(int eflag, int vflag) {
if (evflag) if (evflag)
ev_tally(i, j, nlocal, newton_pair, 0.0, 0.0, fpair, delx, dely, delz); ev_tally(i, j, nlocal, newton_pair, 0.0, 0.0, fpair, delx, dely, delz);
if (evflag)
ev_tally(i, j, nlocal, newton_pair, 0.0, 0.0, fpair, delx, dely,
delz);
} }
} }
} }
@ -175,7 +178,8 @@ void PairSPHIdealGas::compute(int eflag, int vflag) {
allocate all arrays allocate all arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHIdealGas::allocate() { void PairSPHIdealGas::allocate()
{
allocated = 1; allocated = 1;
int n = atom->ntypes; int n = atom->ntypes;
@ -194,7 +198,8 @@ void PairSPHIdealGas::allocate() {
global settings global settings
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHIdealGas::settings(int narg, char **/*arg*/) { void PairSPHIdealGas::settings(int narg, char **/*arg*/)
{
if (narg != 0) if (narg != 0)
error->all(FLERR, error->all(FLERR,
"Illegal number of arguments for pair_style sph/idealgas"); "Illegal number of arguments for pair_style sph/idealgas");
@ -204,7 +209,8 @@ void PairSPHIdealGas::settings(int narg, char **/*arg*/) {
set coeffs for one or more type pairs set coeffs for one or more type pairs
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHIdealGas::coeff(int narg, char **arg) { void PairSPHIdealGas::coeff(int narg, char **arg)
{
if (narg != 4) if (narg != 4)
error->all(FLERR,"Incorrect number of args for pair_style sph/idealgas coefficients"); error->all(FLERR,"Incorrect number of args for pair_style sph/idealgas coefficients");
if (!allocated) if (!allocated)
@ -221,7 +227,6 @@ void PairSPHIdealGas::coeff(int narg, char **arg) {
for (int i = ilo; i <= ihi; i++) { for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = MAX(jlo,i); j <= jhi; j++) {
viscosity[i][j] = viscosity_one; viscosity[i][j] = viscosity_one;
//printf("setting cut[%d][%d] = %f\n", i, j, cut_one);
cut[i][j] = cut_one; cut[i][j] = cut_one;
setflag[i][j] = 1; setflag[i][j] = 1;
count++; count++;
@ -236,8 +241,8 @@ void PairSPHIdealGas::coeff(int narg, char **arg) {
init for one type pair i,j and corresponding j,i init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairSPHIdealGas::init_one(int i, int j) { double PairSPHIdealGas::init_one(int i, int j)
{
if (setflag[i][j] == 0) { if (setflag[i][j] == 0) {
error->all(FLERR,"All pair sph/idealgas coeffs are not set"); error->all(FLERR,"All pair sph/idealgas coeffs are not set");
} }
@ -246,12 +251,3 @@ double PairSPHIdealGas::init_one(int i, int j) {
return cut[i][j]; return cut[i][j];
} }
/* ---------------------------------------------------------------------- */
double PairSPHIdealGas::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;
}

View File

@ -32,7 +32,6 @@ class PairSPHIdealGas : public Pair {
void settings(int, char **) override; void settings(int, char **) override;
void coeff(int, char **) override; void coeff(int, char **) override;
double init_one(int, int) override; double init_one(int, int) override;
double single(int, int, int, int, double, double, double, double &) override;
protected: protected:
double **cut, **viscosity; double **cut, **viscosity;

View File

@ -13,14 +13,15 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "pair_sph_lj.h" #include "pair_sph_lj.h"
#include <cmath>
#include "atom.h"
#include "force.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "domain.h"
#include "atom.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "neigh_list.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -28,12 +29,17 @@ using namespace LAMMPS_NS;
PairSPHLJ::PairSPHLJ(LAMMPS *lmp) : Pair(lmp) PairSPHLJ::PairSPHLJ(LAMMPS *lmp) : Pair(lmp)
{ {
if ((atom->esph_flag != 1) || (atom->rho_flag != 1) || (atom->cv_flag != 1) || (atom->vest_flag != 1))
error->all(FLERR, "Pair sph/lj requires atom attributes energy, density, specific heat, and velocity estimates, e.g. in atom_style sph");
restartinfo = 0; restartinfo = 0;
single_enable = 0;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
PairSPHLJ::~PairSPHLJ() { PairSPHLJ::~PairSPHLJ()
{
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
memory->destroy(cutsq); memory->destroy(cutsq);
@ -45,7 +51,8 @@ PairSPHLJ::~PairSPHLJ() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairSPHLJ::compute(int eflag, int vflag) { void PairSPHLJ::compute(int eflag, int vflag)
{
int i, j, ii, jj, inum, jnum, itype, jtype; int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, fpair; double xtmp, ytmp, ztmp, delx, dely, delz, fpair;
@ -182,7 +189,8 @@ void PairSPHLJ::compute(int eflag, int vflag) {
allocate all arrays allocate all arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHLJ::allocate() { void PairSPHLJ::allocate()
{
allocated = 1; allocated = 1;
int n = atom->ntypes; int n = atom->ntypes;
@ -201,7 +209,8 @@ void PairSPHLJ::allocate() {
global settings global settings
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHLJ::settings(int narg, char **/*arg*/) { void PairSPHLJ::settings(int narg, char **/*arg*/)
{
if (narg != 0) if (narg != 0)
error->all(FLERR, error->all(FLERR,
"Illegal number of arguments for pair_style sph/lj"); "Illegal number of arguments for pair_style sph/lj");
@ -211,7 +220,8 @@ void PairSPHLJ::settings(int narg, char **/*arg*/) {
set coeffs for one or more type pairs set coeffs for one or more type pairs
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHLJ::coeff(int narg, char **arg) { void PairSPHLJ::coeff(int narg, char **arg)
{
if (narg != 4) if (narg != 4)
error->all(FLERR, error->all(FLERR,
"Incorrect args for pair_style sph/lj coefficients"); "Incorrect args for pair_style sph/lj coefficients");
@ -229,7 +239,6 @@ void PairSPHLJ::coeff(int narg, char **arg) {
for (int i = ilo; i <= ihi; i++) { for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = MAX(jlo,i); j <= jhi; j++) {
viscosity[i][j] = viscosity_one; viscosity[i][j] = viscosity_one;
printf("setting cut[%d][%d] = %f\n", i, j, cut_one);
cut[i][j] = cut_one; cut[i][j] = cut_one;
setflag[i][j] = 1; setflag[i][j] = 1;
count++; count++;
@ -244,8 +253,8 @@ void PairSPHLJ::coeff(int narg, char **arg) {
init for one type pair i,j and corresponding j,i init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairSPHLJ::init_one(int i, int j) { double PairSPHLJ::init_one(int i, int j)
{
if (setflag[i][j] == 0) { if (setflag[i][j] == 0) {
error->all(FLERR,"All pair sph/lj coeffs are not set"); error->all(FLERR,"All pair sph/lj coeffs are not set");
} }
@ -256,16 +265,6 @@ double PairSPHLJ::init_one(int i, int j) {
return cut[i][j]; return cut[i][j];
} }
/* ---------------------------------------------------------------------- */
double PairSPHLJ::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;
}
/*double PairSPHLJ::LJEOS2(double rho, double e, double cv) { /*double PairSPHLJ::LJEOS2(double rho, double e, double cv) {
@ -297,7 +296,8 @@ double PairSPHLJ::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/,
Journal of Chemical Physics 73 pp. 5401-5403 (1980) Journal of Chemical Physics 73 pp. 5401-5403 (1980)
*/ */
void PairSPHLJ::LJEOS2(double rho, double e, double cv, double *p, double *c) { void PairSPHLJ::LJEOS2(double rho, double e, double cv, double *p, double *c)
{
double T = e/cv; double T = e/cv;
double beta = 1.0 / T; double beta = 1.0 / T;
double beta_sqrt = sqrt(beta); double beta_sqrt = sqrt(beta);

View File

@ -32,8 +32,6 @@ class PairSPHLJ : public Pair {
void settings(int, char **) override; void settings(int, char **) override;
void coeff(int, char **) override; void coeff(int, char **) override;
double init_one(int, int) override; double init_one(int, int) override;
double single(int, int, int, int, double, double, double, double &) override;
//double LJEOS(int);
void LJEOS2(double, double, double, double *, double *); void LJEOS2(double, double, double, double *, double *);
protected: protected:

View File

@ -29,6 +29,9 @@ using namespace LAMMPS_NS;
PairSPHRhoSum::PairSPHRhoSum(LAMMPS *lmp) : Pair(lmp) PairSPHRhoSum::PairSPHRhoSum(LAMMPS *lmp) : Pair(lmp)
{ {
if (atom->rho_flag != 1)
error->all(FLERR, "Pair sph/rhosum requires atom attribute density, e.g. in atom_style sph");
restartinfo = 0; restartinfo = 0;
// set comm size needed by this Pair // set comm size needed by this Pair
@ -39,11 +42,11 @@ PairSPHRhoSum::PairSPHRhoSum(LAMMPS *lmp) : Pair(lmp)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
PairSPHRhoSum::~PairSPHRhoSum() { PairSPHRhoSum::~PairSPHRhoSum()
{
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
memory->destroy(cutsq); memory->destroy(cutsq);
memory->destroy(cut); memory->destroy(cut);
} }
} }
@ -52,14 +55,16 @@ PairSPHRhoSum::~PairSPHRhoSum() {
init specific to this pair style init specific to this pair style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHRhoSum::init_style() { void PairSPHRhoSum::init_style()
{
// need a full neighbor list // need a full neighbor list
neighbor->add_request(this, NeighConst::REQ_FULL); neighbor->add_request(this, NeighConst::REQ_FULL);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairSPHRhoSum::compute(int eflag, int vflag) { void PairSPHRhoSum::compute(int eflag, int vflag)
{
int i, j, ii, jj, jnum, itype, jtype; int i, j, ii, jj, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz; double xtmp, ytmp, ztmp, delx, dely, delz;
double rsq, imass, h, ih, ihsq; double rsq, imass, h, ih, ihsq;
@ -75,25 +80,6 @@ void PairSPHRhoSum::compute(int eflag, int vflag) {
int *type = atom->type; int *type = atom->type;
double *mass = atom->mass; double *mass = atom->mass;
// check consistency of pair coefficients
if (first) {
for (i = 1; i <= atom->ntypes; i++) {
for (j = 1; i <= atom->ntypes; i++) {
if (cutsq[i][j] > 0.0) {
if (!setflag[i][i] || !setflag[j][j]) {
if (comm->me == 0) {
printf(
"SPH particle types %d and %d interact, but not all of their single particle properties are set.\n",
i, j);
}
}
}
}
}
first = 0;
}
inum = list->inum; inum = list->inum;
ilist = list->ilist; ilist = list->ilist;
numneigh = list->numneigh; numneigh = list->numneigh;
@ -186,7 +172,6 @@ void PairSPHRhoSum::compute(int eflag, int vflag) {
rho[i] += mass[jtype] * wf; rho[i] += mass[jtype] * wf;
} }
} }
} }
} }
@ -200,7 +185,8 @@ void PairSPHRhoSum::compute(int eflag, int vflag) {
allocate all arrays allocate all arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHRhoSum::allocate() { void PairSPHRhoSum::allocate()
{
allocated = 1; allocated = 1;
int n = atom->ntypes; int n = atom->ntypes;
@ -210,7 +196,6 @@ void PairSPHRhoSum::allocate() {
setflag[i][j] = 0; setflag[i][j] = 0;
memory->create(cutsq, n + 1, n + 1, "pair:cutsq"); memory->create(cutsq, n + 1, n + 1, "pair:cutsq");
memory->create(cut, n + 1, n + 1, "pair:cut"); memory->create(cut, n + 1, n + 1, "pair:cut");
} }
@ -218,7 +203,8 @@ void PairSPHRhoSum::allocate() {
global settings global settings
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHRhoSum::settings(int narg, char **arg) { void PairSPHRhoSum::settings(int narg, char **arg)
{
if (narg != 1) if (narg != 1)
error->all(FLERR, error->all(FLERR,
"Illegal number of arguments for pair_style sph/rhosum"); "Illegal number of arguments for pair_style sph/rhosum");
@ -229,7 +215,8 @@ void PairSPHRhoSum::settings(int narg, char **arg) {
set coeffs for one or more type pairs set coeffs for one or more type pairs
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHRhoSum::coeff(int narg, char **arg) { void PairSPHRhoSum::coeff(int narg, char **arg)
{
if (narg != 3) if (narg != 3)
error->all(FLERR,"Incorrect number of args for sph/rhosum coefficients"); error->all(FLERR,"Incorrect number of args for sph/rhosum coefficients");
if (!allocated) if (!allocated)
@ -244,7 +231,6 @@ void PairSPHRhoSum::coeff(int narg, char **arg) {
int count = 0; int count = 0;
for (int i = ilo; i <= ihi; i++) { for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = MAX(jlo,i); j <= jhi; j++) {
//printf("setting cut[%d][%d] = %f\n", i, j, cut_one);
cut[i][j] = cut_one; cut[i][j] = cut_one;
setflag[i][j] = 1; setflag[i][j] = 1;
count++; count++;
@ -259,7 +245,8 @@ void PairSPHRhoSum::coeff(int narg, char **arg) {
init for one type pair i,j and corresponding j,i init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairSPHRhoSum::init_one(int i, int j) { double PairSPHRhoSum::init_one(int i, int j)
{
if (setflag[i][j] == 0) { if (setflag[i][j] == 0) {
error->all(FLERR,"All pair sph/rhosum coeffs are not set"); error->all(FLERR,"All pair sph/rhosum coeffs are not set");
} }
@ -272,7 +259,8 @@ double PairSPHRhoSum::init_one(int i, int j) {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double PairSPHRhoSum::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/, double /*rsq*/, double PairSPHRhoSum::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/, double /*rsq*/,
double /*factor_coul*/, double /*factor_lj*/, double &fforce) { double /*factor_coul*/, double /*factor_lj*/, double &fforce)
{
fforce = 0.0; fforce = 0.0;
return 0.0; return 0.0;
@ -281,7 +269,8 @@ double PairSPHRhoSum::single(int /*i*/, int /*j*/, int /*itype*/, int /*jtype*/,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int PairSPHRhoSum::pack_forward_comm(int n, int *list, double *buf, int PairSPHRhoSum::pack_forward_comm(int n, int *list, double *buf,
int /*pbc_flag*/, int * /*pbc*/) { int /*pbc_flag*/, int * /*pbc*/)
{
int i, j, m; int i, j, m;
double *rho = atom->rho; double *rho = atom->rho;
@ -295,7 +284,8 @@ int PairSPHRhoSum::pack_forward_comm(int n, int *list, double *buf,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairSPHRhoSum::unpack_forward_comm(int n, int first, double *buf) { void PairSPHRhoSum::unpack_forward_comm(int n, int first, double *buf)
{
int i, m, last; int i, m, last;
double *rho = atom->rho; double *rho = atom->rho;

View File

@ -13,15 +13,16 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "pair_sph_taitwater.h" #include "pair_sph_taitwater.h"
#include <cmath>
#include "atom.h"
#include "force.h"
#include "comm.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "domain.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "neigh_list.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -29,6 +30,9 @@ using namespace LAMMPS_NS;
PairSPHTaitwater::PairSPHTaitwater(LAMMPS *lmp) : Pair(lmp) PairSPHTaitwater::PairSPHTaitwater(LAMMPS *lmp) : Pair(lmp)
{ {
if ((atom->esph_flag != 1) || (atom->rho_flag != 1) || (atom->vest_flag != 1))
error->all(FLERR, "Pair sph/taitwater requires atom attributes energy, density, and velocity estimates, e.g. in atom_style sph");
restartinfo = 0; restartinfo = 0;
single_enable = 0; single_enable = 0;
first = 1; first = 1;
@ -36,7 +40,8 @@ PairSPHTaitwater::PairSPHTaitwater(LAMMPS *lmp) : Pair(lmp)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
PairSPHTaitwater::~PairSPHTaitwater() { PairSPHTaitwater::~PairSPHTaitwater()
{
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
memory->destroy(cutsq); memory->destroy(cutsq);
@ -51,7 +56,8 @@ PairSPHTaitwater::~PairSPHTaitwater() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairSPHTaitwater::compute(int eflag, int vflag) { void PairSPHTaitwater::compute(int eflag, int vflag)
{
int i, j, ii, jj, inum, jnum, itype, jtype; int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, fpair; double xtmp, ytmp, ztmp, delx, dely, delz, fpair;
@ -72,25 +78,6 @@ void PairSPHTaitwater::compute(int eflag, int vflag) {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
int newton_pair = force->newton_pair; int newton_pair = force->newton_pair;
// check consistency of pair coefficients
if (first) {
for (i = 1; i <= atom->ntypes; i++) {
for (j = 1; i <= atom->ntypes; i++) {
if (cutsq[i][j] > 1.e-32) {
if (!setflag[i][i] || !setflag[j][j]) {
if (comm->me == 0) {
printf(
"SPH particle types %d and %d interact with cutoff=%g, but not all of their single particle properties are set.\n",
i, j, sqrt(cutsq[i][j]));
}
}
}
}
}
first = 0;
}
inum = list->inum; inum = list->inum;
ilist = list->ilist; ilist = list->ilist;
numneigh = list->numneigh; numneigh = list->numneigh;
@ -201,7 +188,8 @@ void PairSPHTaitwater::compute(int eflag, int vflag) {
allocate all arrays allocate all arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHTaitwater::allocate() { void PairSPHTaitwater::allocate()
{
allocated = 1; allocated = 1;
int n = atom->ntypes; int n = atom->ntypes;
@ -223,7 +211,8 @@ void PairSPHTaitwater::allocate() {
global settings global settings
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHTaitwater::settings(int narg, char **/*arg*/) { void PairSPHTaitwater::settings(int narg, char **/*arg*/)
{
if (narg != 0) if (narg != 0)
error->all(FLERR, error->all(FLERR,
"Illegal number of arguments for pair_style sph/taitwater"); "Illegal number of arguments for pair_style sph/taitwater");
@ -233,7 +222,8 @@ void PairSPHTaitwater::settings(int narg, char **/*arg*/) {
set coeffs for one or more type pairs set coeffs for one or more type pairs
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHTaitwater::coeff(int narg, char **arg) { void PairSPHTaitwater::coeff(int narg, char **arg)
{
if (narg != 6) if (narg != 6)
error->all(FLERR, error->all(FLERR,
"Incorrect args for pair_style sph/taitwater coefficients"); "Incorrect args for pair_style sph/taitwater coefficients");
@ -257,14 +247,8 @@ void PairSPHTaitwater::coeff(int narg, char **arg) {
B[i] = B_one; B[i] = B_one;
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = MAX(jlo,i); j <= jhi; j++) {
viscosity[i][j] = viscosity_one; viscosity[i][j] = viscosity_one;
//printf("setting cut[%d][%d] = %f\n", i, j, cut_one);
cut[i][j] = cut_one; cut[i][j] = cut_one;
setflag[i][j] = 1; setflag[i][j] = 1;
//cut[j][i] = cut[i][j];
//viscosity[j][i] = viscosity[i][j];
//setflag[j][i] = 1;
count++; count++;
} }
} }
@ -277,8 +261,8 @@ void PairSPHTaitwater::coeff(int narg, char **arg) {
init for one type pair i,j and corresponding j,i init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairSPHTaitwater::init_one(int i, int j) { double PairSPHTaitwater::init_one(int i, int j)
{
if (setflag[i][j] == 0) { if (setflag[i][j] == 0) {
error->all(FLERR,"All pair sph/taitwater coeffs are set"); error->all(FLERR,"All pair sph/taitwater coeffs are set");
} }

View File

@ -13,15 +13,16 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "pair_sph_taitwater_morris.h" #include "pair_sph_taitwater_morris.h"
#include <cmath>
#include "atom.h"
#include "force.h"
#include "comm.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "domain.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "neigh_list.h"
#include <cmath>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -29,6 +30,9 @@ using namespace LAMMPS_NS;
PairSPHTaitwaterMorris::PairSPHTaitwaterMorris(LAMMPS *lmp) : Pair(lmp) PairSPHTaitwaterMorris::PairSPHTaitwaterMorris(LAMMPS *lmp) : Pair(lmp)
{ {
if ((atom->esph_flag != 1) || (atom->rho_flag != 1) || (atom->vest_flag != 1))
error->all(FLERR, "Pair sph/taitwater/morris requires atom attributes energy, density, and velocity estimates, e.g. in atom_style sph");
restartinfo = 0; restartinfo = 0;
first = 1; first = 1;
single_enable = 0; single_enable = 0;
@ -36,7 +40,8 @@ PairSPHTaitwaterMorris::PairSPHTaitwaterMorris(LAMMPS *lmp) : Pair(lmp)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
PairSPHTaitwaterMorris::~PairSPHTaitwaterMorris() { PairSPHTaitwaterMorris::~PairSPHTaitwaterMorris()
{
if (allocated) { if (allocated) {
memory->destroy(setflag); memory->destroy(setflag);
memory->destroy(cutsq); memory->destroy(cutsq);
@ -51,7 +56,8 @@ PairSPHTaitwaterMorris::~PairSPHTaitwaterMorris() {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void PairSPHTaitwaterMorris::compute(int eflag, int vflag) { void PairSPHTaitwaterMorris::compute(int eflag, int vflag)
{
int i, j, ii, jj, inum, jnum, itype, jtype; int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, fpair; double xtmp, ytmp, ztmp, delx, dely, delz, fpair;
@ -72,25 +78,6 @@ void PairSPHTaitwaterMorris::compute(int eflag, int vflag) {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
int newton_pair = force->newton_pair; int newton_pair = force->newton_pair;
// check consistency of pair coefficients
if (first) {
for (i = 1; i <= atom->ntypes; i++) {
for (j = 1; i <= atom->ntypes; i++) {
if (cutsq[i][j] > 1.e-32) {
if (!setflag[i][i] || !setflag[j][j]) {
if (comm->me == 0) {
printf(
"SPH particle types %d and %d interact with cutoff=%g, but not all of their single particle properties are set.\n",
i, j, sqrt(cutsq[i][j]));
}
}
}
}
}
first = 0;
}
inum = list->inum; inum = list->inum;
ilist = list->ilist; ilist = list->ilist;
numneigh = list->numneigh; numneigh = list->numneigh;
@ -169,8 +156,6 @@ void PairSPHTaitwaterMorris::compute(int eflag, int vflag) {
fpair = -imass * jmass * (fi + fj) * wfd; fpair = -imass * jmass * (fi + fj) * wfd;
deltaE = -0.5 *(fpair * delVdotDelR + fvisc * (velx*velx + vely*vely + velz*velz)); deltaE = -0.5 *(fpair * delVdotDelR + fvisc * (velx*velx + vely*vely + velz*velz));
// printf("testvar= %f, %f \n", delx, dely);
f[i][0] += delx * fpair + velx * fvisc; f[i][0] += delx * fpair + velx * fvisc;
f[i][1] += dely * fpair + vely * fvisc; f[i][1] += dely * fpair + vely * fvisc;
f[i][2] += delz * fpair + velz * fvisc; f[i][2] += delz * fpair + velz * fvisc;
@ -189,6 +174,7 @@ void PairSPHTaitwaterMorris::compute(int eflag, int vflag) {
drho[j] += imass * delVdotDelR * wfd; drho[j] += imass * delVdotDelR * wfd;
} }
// viscous forces do not contribute to virial
if (evflag) if (evflag)
ev_tally(i, j, nlocal, newton_pair, 0.0, 0.0, fpair, delx, dely, delz); ev_tally(i, j, nlocal, newton_pair, 0.0, 0.0, fpair, delx, dely, delz);
} }
@ -202,7 +188,8 @@ void PairSPHTaitwaterMorris::compute(int eflag, int vflag) {
allocate all arrays allocate all arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHTaitwaterMorris::allocate() { void PairSPHTaitwaterMorris::allocate()
{
allocated = 1; allocated = 1;
int n = atom->ntypes; int n = atom->ntypes;
@ -224,7 +211,8 @@ void PairSPHTaitwaterMorris::allocate() {
global settings global settings
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHTaitwaterMorris::settings(int narg, char **/*arg*/) { void PairSPHTaitwaterMorris::settings(int narg, char **/*arg*/)
{
if (narg != 0) if (narg != 0)
error->all(FLERR, error->all(FLERR,
"Illegal number of arguments for pair_style sph/taitwater/morris"); "Illegal number of arguments for pair_style sph/taitwater/morris");
@ -234,7 +222,8 @@ void PairSPHTaitwaterMorris::settings(int narg, char **/*arg*/) {
set coeffs for one or more type pairs set coeffs for one or more type pairs
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairSPHTaitwaterMorris::coeff(int narg, char **arg) { void PairSPHTaitwaterMorris::coeff(int narg, char **arg)
{
if (narg != 6) if (narg != 6)
error->all(FLERR, error->all(FLERR,
"Incorrect args for pair_style sph/taitwater/morris coefficients"); "Incorrect args for pair_style sph/taitwater/morris coefficients");
@ -258,7 +247,6 @@ void PairSPHTaitwaterMorris::coeff(int narg, char **arg) {
B[i] = B_one; B[i] = B_one;
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = MAX(jlo,i); j <= jhi; j++) {
viscosity[i][j] = viscosity_one; viscosity[i][j] = viscosity_one;
//printf("setting cut[%d][%d] = %f\n", i, j, cut_one);
cut[i][j] = cut_one; cut[i][j] = cut_one;
setflag[i][j] = 1; setflag[i][j] = 1;
@ -274,8 +262,8 @@ void PairSPHTaitwaterMorris::coeff(int narg, char **arg) {
init for one type pair i,j and corresponding j,i init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double PairSPHTaitwaterMorris::init_one(int i, int j) { double PairSPHTaitwaterMorris::init_one(int i, int j)
{
if (setflag[i][j] == 0) { if (setflag[i][j] == 0) {
error->all(FLERR,"All pair sph/taitwater/morris coeffs are not set"); error->all(FLERR,"All pair sph/taitwater/morris coeffs are not set");
} }