Merge pull request #3855 from akohlmey/collected-small-changes

Collected small changes and fixes
This commit is contained in:
Axel Kohlmeyer
2023-07-17 19:00:40 -04:00
committed by GitHub
23 changed files with 172 additions and 186 deletions

View File

@ -4,7 +4,7 @@
dynamical_matrix command dynamical_matrix command
======================== ========================
Accelerator Variants: dynamical_matrix/kk Accelerator Variant: dynamical_matrix/kk
Syntax Syntax
"""""" """"""

View File

@ -1,10 +1,10 @@
.. index:: minimize .. index:: minimize
.. index:: minimize/kk
minimize command minimize command
================ ================
minimize/kk command Accelerator Variant: minimize/kk
===================
Syntax Syntax
"""""" """"""

View File

@ -4,7 +4,7 @@
third_order command third_order command
=================== ===================
Accelerator Variants: third_order/kk Accelerator Variant: third_order/kk
Syntax Syntax
"""""" """"""

View File

@ -37,7 +37,7 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
// #define TEMPER_DEBUG 1 #define TEMPER_DEBUG 0
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -63,11 +63,10 @@ Temper::~Temper()
void Temper::command(int narg, char **arg) void Temper::command(int narg, char **arg)
{ {
if (universe->nworlds == 1) if (universe->nworlds == 1)
error->all(FLERR,"Must have more than one processor partition to temper"); error->universe_all(FLERR,"More than one processor partition required for temper command");
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR,"Temper command before simulation box is defined"); error->universe_all(FLERR,"Temper command before simulation box is defined");
if (narg != 6 && narg != 7) if (narg != 6 && narg != 7) error->universe_all(FLERR,"Illegal temper command");
error->universe_all(FLERR,"Illegal temper command");
int nsteps = utils::inumeric(FLERR,arg[0],false,lmp); int nsteps = utils::inumeric(FLERR,arg[0],false,lmp);
nevery = utils::inumeric(FLERR,arg[1],false,lmp); nevery = utils::inumeric(FLERR,arg[1],false,lmp);
@ -77,10 +76,9 @@ void Temper::command(int narg, char **arg)
if (timer->is_timeout()) return; if (timer->is_timeout()) return;
for (whichfix = 0; whichfix < modify->nfix; whichfix++) whichfix = modify->get_fix_by_id(arg[3]);
if (strcmp(arg[3],modify->fix[whichfix]->id) == 0) break; if (!whichfix)
if (whichfix == modify->nfix) error->universe_all(FLERR,fmt::format("Tempering fix ID {} is not defined", arg[3]));
error->universe_all(FLERR,"Tempering fix ID is not defined");
seed_swap = utils::inumeric(FLERR,arg[4],false,lmp); seed_swap = utils::inumeric(FLERR,arg[4],false,lmp);
seed_boltz = utils::inumeric(FLERR,arg[5],false,lmp); seed_boltz = utils::inumeric(FLERR,arg[5],false,lmp);
@ -88,7 +86,7 @@ void Temper::command(int narg, char **arg)
my_set_temp = universe->iworld; my_set_temp = universe->iworld;
if (narg == 7) my_set_temp = utils::inumeric(FLERR,arg[6],false,lmp); if (narg == 7) my_set_temp = utils::inumeric(FLERR,arg[6],false,lmp);
if ((my_set_temp < 0) || (my_set_temp >= universe->nworlds)) if ((my_set_temp < 0) || (my_set_temp >= universe->nworlds))
error->universe_one(FLERR,"Illegal temperature index"); error->universe_one(FLERR,"Invalid temperature index value");
// swap frequency must evenly divide total # of timesteps // swap frequency must evenly divide total # of timesteps
@ -101,11 +99,11 @@ void Temper::command(int narg, char **arg)
// fix style must be appropriate for temperature control, i.e. it needs // fix style must be appropriate for temperature control, i.e. it needs
// to provide a working Fix::reset_target() and must not change the volume. // to provide a working Fix::reset_target() and must not change the volume.
if ((!utils::strmatch(modify->fix[whichfix]->style,"^nvt")) && if ((!utils::strmatch(whichfix->style,"^nvt")) &&
(!utils::strmatch(modify->fix[whichfix]->style,"^langevin")) && (!utils::strmatch(whichfix->style,"^langevin")) &&
(!utils::strmatch(modify->fix[whichfix]->style,"^gl[de]$")) && (!utils::strmatch(whichfix->style,"^gl[de]$")) &&
(!utils::strmatch(modify->fix[whichfix]->style,"^rigid/nvt")) && (!utils::strmatch(whichfix->style,"^rigid/nvt")) &&
(!utils::strmatch(modify->fix[whichfix]->style,"^temp/"))) (!utils::strmatch(whichfix->style,"^temp/")))
error->universe_all(FLERR,"Tempering temperature fix is not supported"); error->universe_all(FLERR,"Tempering temperature fix is not supported");
// setup for long tempering run // setup for long tempering run
@ -116,8 +114,7 @@ void Temper::command(int narg, char **arg)
update->nsteps = nsteps; update->nsteps = nsteps;
update->beginstep = update->firststep = update->ntimestep; update->beginstep = update->firststep = update->ntimestep;
update->endstep = update->laststep = update->firststep + nsteps; update->endstep = update->laststep = update->firststep + nsteps;
if (update->laststep < 0) if (update->laststep < 0) error->all(FLERR,"Too many timesteps");
error->all(FLERR,"Too many timesteps");
lmp->init(); lmp->init();
@ -132,9 +129,9 @@ void Temper::command(int narg, char **arg)
// pe_compute = ptr to thermo_pe compute // pe_compute = ptr to thermo_pe compute
// notify compute it will be called at first swap // notify compute it will be called at first swap
int id = modify->find_compute("thermo_pe"); Compute *pe_compute = modify->get_compute_by_id("thermo_pe");
if (id < 0) error->all(FLERR,"Tempering could not find thermo_pe compute"); if (!pe_compute) error->all(FLERR,"Tempering could not find thermo_pe compute");
Compute *pe_compute = modify->compute[id];
pe_compute->addstep(update->ntimestep + nevery); pe_compute->addstep(update->ntimestep + nevery);
// create MPI communicator for root proc from each world // create MPI communicator for root proc from each world
@ -183,7 +180,7 @@ void Temper::command(int narg, char **arg)
if (narg == 7) { if (narg == 7) {
double new_temp = set_temp[my_set_temp]; double new_temp = set_temp[my_set_temp];
modify->fix[whichfix]->reset_target(new_temp); whichfix->reset_target(new_temp);
} }
// setup tempering runs // setup tempering runs
@ -289,13 +286,12 @@ void Temper::command(int narg, char **arg)
else else
MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE); MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE);
#ifdef TEMPER_DEBUG #if TEMPER_DEBUG
if (me_universe < partner) if (me_universe < partner)
printf("SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n", fprintf(universe->uscreen,"SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n",
me_universe,partner,swap,my_set_temp,partner_set_temp, me_universe,partner,swap,my_set_temp,partner_set_temp,
pe,pe_partner,boltz_factor,exp(boltz_factor)); pe,pe_partner,boltz_factor,exp(boltz_factor));
#endif #endif
} }
// bcast swap result to other procs in my world // bcast swap result to other procs in my world
@ -310,7 +306,7 @@ void Temper::command(int narg, char **arg)
if (swap) { if (swap) {
new_temp = set_temp[partner_set_temp]; new_temp = set_temp[partner_set_temp];
modify->fix[whichfix]->reset_target(new_temp); whichfix->reset_target(new_temp);
} }
// update my_set_temp and temp2world on every proc // update my_set_temp and temp2world on every proc

View File

@ -40,8 +40,7 @@ class Temper : public Command {
int nswaps; // # of tempering swaps to perform int nswaps; // # of tempering swaps to perform
int seed_swap; // 0 = toggle swaps, n = RNG for swap direction int seed_swap; // 0 = toggle swaps, n = RNG for swap direction
int seed_boltz; // seed for Boltz factor comparison int seed_boltz; // seed for Boltz factor comparison
int whichfix; // index of temperature fix to use class Fix *whichfix; // temperature fix to use
int fixstyle; // what kind of temperature fix is used
int my_set_temp; // which set temp I am simulating int my_set_temp; // which set temp I am simulating
double *set_temp; // static list of replica set temperatures double *set_temp; // static list of replica set temperatures

View File

@ -24,6 +24,7 @@
#include "finish.h" #include "finish.h"
#include "fix.h" #include "fix.h"
#include "fix_grem.h" #include "fix_grem.h"
#include "fix_nh.h"
#include "force.h" #include "force.h"
#include "integrate.h" #include "integrate.h"
#include "modify.h" #include "modify.h"
@ -37,7 +38,7 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
//#define TEMPER_DEBUG 1 #define TEMPER_DEBUG 0
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -54,7 +55,6 @@ TemperGrem::~TemperGrem()
delete[] lambda2world; delete[] lambda2world;
delete[] world2lambda; delete[] world2lambda;
delete[] world2root; delete[] world2root;
delete [] id_nh;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -64,46 +64,50 @@ TemperGrem::~TemperGrem()
void TemperGrem::command(int narg, char **arg) void TemperGrem::command(int narg, char **arg)
{ {
if (universe->nworlds == 1) if (universe->nworlds == 1)
error->all(FLERR,"Must have more than one processor partition to temper"); error->universe_all(FLERR,"More than one processor partition required for temper/grem command");
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR,"Temper/gREM command before simulation box is defined"); error->universe_all(FLERR,"Temper/grem command before simulation box is defined");
if (narg != 7 && narg != 8) if (narg != 7 && narg != 8) error->universe_all(FLERR,"Illegal temper/grem command");
error->universe_all(FLERR,"Illegal temper command");
int nsteps = utils::inumeric(FLERR,arg[0],false,lmp); int nsteps = utils::inumeric(FLERR,arg[0],false,lmp);
nevery = utils::inumeric(FLERR,arg[1],false,lmp); nevery = utils::inumeric(FLERR,arg[1],false,lmp);
double lambda = utils::numeric(FLERR,arg[2],false,lmp); double lambda = utils::numeric(FLERR,arg[2],false,lmp);
// ignore temper command, if walltime limit was already reached // ignore temper command, if walltime limit was already reached
if (timer->is_timeout()) return; if (timer->is_timeout()) return;
// Get and check if gREM fix exists // Get and check if gREM fix exists and is correct style
for (whichfix = 0; whichfix < modify->nfix; whichfix++)
if (strcmp(arg[3],modify->fix[whichfix]->id) == 0) break; auto ifix = modify->get_fix_by_id(arg[3]);
if (whichfix == modify->nfix) if (!ifix) error->universe_all(FLERR,fmt::format("Tempering fix ID {} is not defined", arg[3]));
error->universe_all(FLERR,"Tempering fix ID is not defined");
fix_grem = dynamic_cast<FixGrem*>(modify->fix[whichfix]); fix_grem = dynamic_cast<FixGrem*>(ifix);
if (!fix_grem || (strcmp(ifix->style,"grem") != 0))
error->universe_all(FLERR,"Tempering temperature fix is of incorrect style");
// Check input values lambdas should be equal, assign other gREM values // Check input values lambdas should be equal, assign other gREM values
if (lambda != fix_grem->lambda) if (lambda != fix_grem->lambda)
error->universe_all(FLERR,"Lambda from tempering and fix in the same world" error->universe_all(FLERR,"Lambda from tempering and fix in the same world must be the same");
" must be the same");
double eta = fix_grem->eta; double eta = fix_grem->eta;
double h0 = fix_grem->h0; double h0 = fix_grem->h0;
double pressref = 0; double pressref = 0;
// Get and check for nh fix // Get and check for nh fix
id_nh = utils::strdup(arg[4]);
int ifix = modify->find_fix(id_nh); FixNH *nh = dynamic_cast<FixNH *>(modify->get_fix_by_id(arg[4]));
if (ifix < 0) if (!nh)
error->all(FLERR,"Fix id for nvt or npt fix does not exist"); error->all(FLERR,fmt::format("Fix {} for Nose-Hoover fix does not exist", arg[4]));
Fix *nh = modify->fix[ifix];
// get result from nvt vs npt check from fix_grem // get result from nvt vs npt check from fix_grem
int pressflag = fix_grem->pressflag; int pressflag = fix_grem->pressflag;
// fix_grem does all the checking... // fix_grem does all the checking...
if (pressflag) { if (pressflag) {
auto p_start = (double *) nh->extract("p_start",ifix); int dummy;
auto p_start = (double *) nh->extract("p_start",dummy);
pressref = p_start[0]; pressref = p_start[0];
} }
@ -123,11 +127,6 @@ void TemperGrem::command(int narg, char **arg)
if (nswaps*nevery != nsteps) if (nswaps*nevery != nsteps)
error->universe_all(FLERR,"Non integer # of swaps in temper command"); error->universe_all(FLERR,"Non integer # of swaps in temper command");
// Must be used with fix_grem
if (strcmp(modify->fix[whichfix]->style,"grem") != 0)
error->universe_all(FLERR,"Tempering temperature fix is not supported");
// setup for long tempering run // setup for long tempering run
update->whichflag = 1; update->whichflag = 1;
@ -136,8 +135,7 @@ void TemperGrem::command(int narg, char **arg)
update->nsteps = nsteps; update->nsteps = nsteps;
update->beginstep = update->firststep = update->ntimestep; update->beginstep = update->firststep = update->ntimestep;
update->endstep = update->laststep = update->firststep + nsteps; update->endstep = update->laststep = update->firststep + nsteps;
if (update->laststep < 0) if (update->laststep < 0) error->all(FLERR,"Too many timesteps");
error->all(FLERR,"Too many timesteps");
lmp->init(); lmp->init();
@ -152,9 +150,9 @@ void TemperGrem::command(int narg, char **arg)
// pe_compute = ptr to thermo_pe compute // pe_compute = ptr to thermo_pe compute
// notify compute it will be called at first swap // notify compute it will be called at first swap
int id = modify->find_compute("thermo_pe"); Compute *pe_compute = modify->get_compute_by_id("thermo_pe");
if (id < 0) error->all(FLERR,"Tempering could not find thermo_pe compute"); if (!pe_compute) error->all(FLERR,"Tempering could not find thermo_pe compute");
Compute *pe_compute = modify->compute[id];
pe_compute->addstep(update->ntimestep + nevery); pe_compute->addstep(update->ntimestep + nevery);
// create MPI communicator for root proc from each world // create MPI communicator for root proc from each world
@ -319,13 +317,12 @@ void TemperGrem::command(int narg, char **arg)
else else
MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE); MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE);
#ifdef TEMPER_DEBUG #if TEMPER_DEBUG
if (me_universe < partner) if (me_universe < partner)
printf("SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n", fprintf(universe->uscreen,"SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n",
me_universe,partner,swap,my_set_lambda,partner_set_lambda, me_universe,partner,swap,my_set_lambda,partner_set_lambda,
weight,weight_partner,boltz_factor,exp(boltz_factor)); weight,weight_partner,boltz_factor,exp(boltz_factor));
#endif #endif
} }
// bcast swap result to other procs in my world // bcast swap result to other procs in my world

View File

@ -40,8 +40,7 @@ class TemperGrem : public Command {
int nswaps; // # of tempering swaps to perform int nswaps; // # of tempering swaps to perform
int seed_swap; // 0 = toggle swaps, n = RNG for swap direction int seed_swap; // 0 = toggle swaps, n = RNG for swap direction
int seed_boltz; // seed for Boltz factor comparison int seed_boltz; // seed for Boltz factor comparison
int whichfix; // index of temperature fix to use class Fix *whichfix; // temperature fix to use
int fixstyle; // what kind of temperature fix is used
int my_set_lambda; // which set lambda I am simulating int my_set_lambda; // which set lambda I am simulating
double *set_lambda; // static list of replica set lambdas double *set_lambda; // static list of replica set lambdas
@ -54,7 +53,6 @@ class TemperGrem : public Command {
class FixGrem *fix_grem; class FixGrem *fix_grem;
protected: protected:
char *id_nh;
int pressflag; int pressflag;
}; };

View File

@ -65,11 +65,10 @@ TemperNPT::~TemperNPT()
void TemperNPT::command(int narg, char **arg) void TemperNPT::command(int narg, char **arg)
{ {
if (universe->nworlds == 1) if (universe->nworlds == 1)
error->all(FLERR,"Must have more than one processor partition to temper"); error->universe_all(FLERR,"More than one processor partition required for temper/npt command");
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR,"temper/npt command before simulation box is defined"); error->universe_all(FLERR,"Temper/npt command before simulation box is defined");
if (narg != 7 && narg != 8) if (narg != 7 && narg != 8) error->universe_all(FLERR,"Illegal temper/npt command");
error->universe_all(FLERR,"Illegal temper/npt command");
int nsteps = utils::inumeric(FLERR,arg[0],false,lmp); int nsteps = utils::inumeric(FLERR,arg[0],false,lmp);
nevery = utils::inumeric(FLERR,arg[1],false,lmp); nevery = utils::inumeric(FLERR,arg[1],false,lmp);
@ -80,16 +79,17 @@ void TemperNPT::command(int narg, char **arg)
if (timer->is_timeout()) return; if (timer->is_timeout()) return;
for (whichfix = 0; whichfix < modify->nfix; whichfix++) whichfix = modify->get_fix_by_id(arg[3]);
if (strcmp(arg[3],modify->fix[whichfix]->id) == 0) break; if (!whichfix)
if (whichfix == modify->nfix) error->universe_all(FLERR,fmt::format("Tempering fix ID {} is not defined", arg[3]));
error->universe_all(FLERR,"Tempering fix ID is not defined");
seed_swap = utils::inumeric(FLERR,arg[4],false,lmp); seed_swap = utils::inumeric(FLERR,arg[4],false,lmp);
seed_boltz = utils::inumeric(FLERR,arg[5],false,lmp); seed_boltz = utils::inumeric(FLERR,arg[5],false,lmp);
my_set_temp = universe->iworld; my_set_temp = universe->iworld;
if (narg == 8) my_set_temp = utils::inumeric(FLERR,arg[6],false,lmp); if (narg == 8) my_set_temp = utils::inumeric(FLERR,arg[7],false,lmp);
if ((my_set_temp < 0) || (my_set_temp >= universe->nworlds))
error->universe_one(FLERR,"Invalid temperature index value");
// swap frequency must evenly divide total # of timesteps // swap frequency must evenly divide total # of timesteps
@ -104,8 +104,8 @@ void TemperNPT::command(int narg, char **arg)
// change the volume. This currently only applies to fix npt and // change the volume. This currently only applies to fix npt and
// fix rigid/npt variants // fix rigid/npt variants
if ( (!utils::strmatch(modify->fix[whichfix]->style,"^npt")) && if ( (!utils::strmatch(whichfix->style,"^npt")) &&
(!utils::strmatch(modify->fix[whichfix]->style,"^rigid/npt")) ) (!utils::strmatch(whichfix->style,"^rigid/npt")) )
error->universe_all(FLERR,"Tempering temperature and pressure fix is not supported"); error->universe_all(FLERR,"Tempering temperature and pressure fix is not supported");
// setup for long tempering run // setup for long tempering run
@ -116,8 +116,7 @@ void TemperNPT::command(int narg, char **arg)
update->nsteps = nsteps; update->nsteps = nsteps;
update->beginstep = update->firststep = update->ntimestep; update->beginstep = update->firststep = update->ntimestep;
update->endstep = update->laststep = update->firststep + nsteps; update->endstep = update->laststep = update->firststep + nsteps;
if (update->laststep < 0) if (update->laststep < 0) error->all(FLERR,"Too many timesteps");
error->all(FLERR,"Too many timesteps");
lmp->init(); lmp->init();
@ -133,9 +132,9 @@ void TemperNPT::command(int narg, char **arg)
// pe_compute = ptr to thermo_pe compute // pe_compute = ptr to thermo_pe compute
// notify compute it will be called at first swap // notify compute it will be called at first swap
int id = modify->find_compute("thermo_pe"); Compute *pe_compute = modify->get_compute_by_id("thermo_pe");
if (id < 0) error->all(FLERR,"Tempering could not find thermo_pe compute"); if (!pe_compute) error->all(FLERR,"Tempering could not find thermo_pe compute");
Compute *pe_compute = modify->compute[id];
pe_compute->addstep(update->ntimestep + nevery); pe_compute->addstep(update->ntimestep + nevery);
// create MPI communicator for root proc from each world // create MPI communicator for root proc from each world
@ -184,7 +183,7 @@ void TemperNPT::command(int narg, char **arg)
if (narg == 8) { if (narg == 8) {
double new_temp = set_temp[my_set_temp]; double new_temp = set_temp[my_set_temp];
modify->fix[whichfix]->reset_target(new_temp); whichfix->reset_target(new_temp);
} }
// setup tempering runs // setup tempering runs
@ -279,22 +278,23 @@ void TemperNPT::command(int narg, char **arg)
swap = 0; swap = 0;
if (partner != -1) { if (partner != -1) {
if (me_universe > partner) { if (me_universe > partner)
MPI_Send(&pe,1,MPI_DOUBLE,partner,0,universe->uworld); MPI_Send(&pe,1,MPI_DOUBLE,partner,0,universe->uworld);
} else
else {
MPI_Recv(&pe_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE); MPI_Recv(&pe_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE);
}
if (me_universe > partner) { if (me_universe > partner)
MPI_Send(&vol,1, MPI_DOUBLE,partner,0,universe->uworld); MPI_Send(&vol,1, MPI_DOUBLE,partner,0,universe->uworld);
} else
else {
MPI_Recv(&vol_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE); MPI_Recv(&vol_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE);
}
// Acceptance criteria changed for NPT ensemble // Acceptance criteria changed versus temper command for NPT ensemble
if (me_universe < partner) { if (me_universe < partner) {
press_units = press_set/nktv2p; press_units = press_set/nktv2p;
delr = (pe_partner - pe)*(1.0/(boltz*set_temp[my_set_temp]) - 1.0/(boltz*set_temp[partner_set_temp])) + press_units*(1.0/(boltz*set_temp[my_set_temp]) - 1.0/(boltz*set_temp[partner_set_temp]))*(vol_partner - vol); delr = (pe_partner - pe)*(1.0/(boltz*set_temp[my_set_temp])
- 1.0/(boltz*set_temp[partner_set_temp]))
+ press_units*(1.0/(boltz*set_temp[my_set_temp])
- 1.0/(boltz*set_temp[partner_set_temp]))*(vol_partner - vol);
boltz_factor = -delr; boltz_factor = -delr;
if (boltz_factor >= 0.0) swap = 1; if (boltz_factor >= 0.0) swap = 1;
else if (ranboltz->uniform() < exp(boltz_factor)) swap = 1; else if (ranboltz->uniform() < exp(boltz_factor)) swap = 1;
@ -304,13 +304,13 @@ void TemperNPT::command(int narg, char **arg)
MPI_Send(&swap,1,MPI_INT,partner,0,universe->uworld); MPI_Send(&swap,1,MPI_INT,partner,0,universe->uworld);
else else
MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE); MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE);
#ifdef TEMPER_DEBUG
#if TEMPER_DEBUG
if (me_universe < partner) if (me_universe < partner)
fprintf(universe->uscreen,"SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g, vol = %g %g\n", fprintf(universe->uscreen,"SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g, vol = %g %g\n",
me_universe,partner,swap,my_set_temp,partner_set_temp, me_universe,partner,swap,my_set_temp,partner_set_temp,
pe,pe_partner,boltz_factor,exp(boltz_factor), vol, vol_partner); pe,pe_partner,boltz_factor,exp(boltz_factor), vol, vol_partner);
#endif #endif
} }
// bcast swap result to other procs in my world // bcast swap result to other procs in my world
@ -325,7 +325,7 @@ void TemperNPT::command(int narg, char **arg)
if (swap) { if (swap) {
new_temp = set_temp[partner_set_temp]; new_temp = set_temp[partner_set_temp];
modify->fix[whichfix]->reset_target(new_temp); whichfix->reset_target(new_temp);
} }
// update my_set_temp and temp2world on every proc // update my_set_temp and temp2world on every proc

View File

@ -42,8 +42,7 @@ class TemperNPT : public Command {
int nswaps; // # of tempering swaps to perform int nswaps; // # of tempering swaps to perform
int seed_swap; // 0 = toggle swaps, n = RNG for swap direction int seed_swap; // 0 = toggle swaps, n = RNG for swap direction
int seed_boltz; // seed for Boltz factor comparison int seed_boltz; // seed for Boltz factor comparison
int whichfix; // index of temperature fix to use class Fix *whichfix; // temperature fix to use
int fixstyle; // what kind of temperature fix is used
int my_set_temp; // which set temp I am simulating int my_set_temp; // which set temp I am simulating
double *set_temp; // static list of replica set temperatures double *set_temp; // static list of replica set temperatures

View File

@ -1818,17 +1818,16 @@ void Atom::data_bodies(int n, char *buf, AtomVec *avec_body, tagint id_offset)
void Atom::data_fix_compute_variable(int nprev, int nnew) void Atom::data_fix_compute_variable(int nprev, int nnew)
{ {
for (const auto &fix : modify->get_fix_list()) { for (const auto &ifix : modify->get_fix_list()) {
if (fix->create_attribute) if (ifix->create_attribute)
for (int i = nprev; i < nnew; i++) for (int i = nprev; i < nnew; i++)
fix->set_arrays(i); ifix->set_arrays(i);
} }
for (int m = 0; m < modify->ncompute; m++) { for (const auto &icompute : modify->get_compute_list()) {
Compute *compute = modify->compute[m]; if (icompute->create_attribute)
if (compute->create_attribute)
for (int i = nprev; i < nnew; i++) for (int i = nprev; i < nnew; i++)
compute->set_arrays(i); icompute->set_arrays(i);
} }
for (int i = nprev; i < nnew; i++) for (int i = nprev; i < nnew; i++)

View File

@ -17,6 +17,7 @@
#include "error.h" #include "error.h"
#include "fix.h" #include "fix.h"
#include "fix_adapt.h" #include "fix_adapt.h"
#include "fix_adapt_fep.h"
#include "math_const.h" #include "math_const.h"
#include "modify.h" #include "modify.h"
@ -88,12 +89,18 @@ void AtomVecSphere::init()
// check if optional radvary setting should have been set to 1 // check if optional radvary setting should have been set to 1
for (int i = 0; i < modify->nfix; i++) for (auto &ifix : modify->get_fix_by_style("^adapt")) {
if (strcmp(modify->fix[i]->style, "adapt") == 0) { if (utils::strmatch(ifix->style, "^adapt$")) {
auto fix = dynamic_cast<FixAdapt *>(modify->fix[i]); auto fix = dynamic_cast<FixAdapt *>(ifix);
if (fix->diamflag && radvary == 0) if (fix && fix->diamflag && radvary == 0)
error->all(FLERR, "Fix adapt changes particle radii but atom_style sphere is not dynamic"); error->all(FLERR, "Fix adapt changes particle radii but atom_style sphere is not dynamic");
} }
if (utils::strmatch(ifix->style, "^adapt/fep$")) {
auto fix = dynamic_cast<FixAdaptFEP *>(ifix);
if (fix && fix->diamflag && radvary == 0)
error->all(FLERR, "Fix adapt/fep changes particle radii but atom_style sphere is not dynamic");
}
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -82,10 +82,8 @@ void ComputeAggregateAtom::init()
neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL);
int count = 0; if (modify->get_compute_by_style(style).size() > 1)
for (int i = 0; i < modify->ncompute; i++) if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style);
if (strcmp(modify->compute[i]->style, "aggregate/atom") == 0) count++;
if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute aggregate/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -93,14 +93,12 @@ void ComputeCentroAtom::init()
if (force->pair == nullptr) if (force->pair == nullptr)
error->all(FLERR, "Compute centro/atom requires a pair style be defined"); error->all(FLERR, "Compute centro/atom requires a pair style be defined");
int count = 0;
for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style, "centro/atom") == 0) count++;
if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute centro/atom");
// need an occasional full neighbor list // need an occasional full neighbor list
neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL);
if (modify->get_compute_by_style(style).size() > 1)
if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -69,10 +69,8 @@ void ComputeClusterAtom::init()
neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL);
int count = 0; if (modify->get_compute_by_style(style).size() > 1)
for (int i = 0; i < modify->ncompute; i++) if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style);
if (strcmp(modify->compute[i]->style, "cluster/atom") == 0) count++;
if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute cluster/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -76,19 +76,15 @@ void ComputeCNAAtom::init()
// cannot use neighbor->cutneighmax b/c neighbor has not yet been init // cannot use neighbor->cutneighmax b/c neighbor has not yet been init
if (2.0 * sqrt(cutsq) > force->pair->cutforce + neighbor->skin && comm->me == 0) if ((2.0 * sqrt(cutsq)) > (force->pair->cutforce + neighbor->skin) && (comm->me == 0))
error->warning(FLERR, error->warning(FLERR, "Compute cna/atom cutoff may be too large to find ghost atom neighbors");
"Compute cna/atom cutoff may be too large to find "
"ghost atom neighbors");
int count = 0;
for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style, "cna/atom") == 0) count++;
if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute cna/atom defined");
// need an occasional full neighbor list // need an occasional full neighbor list
neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL);
if (modify->get_compute_by_style(style).size() > 1)
if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -82,10 +82,11 @@ ComputeCoordAtom::ComputeCoordAtom(LAMMPS *lmp, int narg, char **arg) :
id_orientorder = utils::strdup(arg[4]); id_orientorder = utils::strdup(arg[4]);
int iorientorder = modify->find_compute(id_orientorder); auto iorientorder = modify->get_compute_by_id(id_orientorder);
if (iorientorder < 0) error->all(FLERR, "Could not find compute coord/atom compute ID"); if (!iorientorder)
if (!utils::strmatch(modify->compute[iorientorder]->style, "^orientorder/atom")) error->all(FLERR, "Could not find compute coord/atom compute ID {}", id_orientorder);
error->all(FLERR, "Compute coord/atom compute ID is not orientorder/atom"); if (!utils::strmatch(iorientorder->style, "^orientorder/atom"))
error->all(FLERR, "Compute coord/atom compute ID {} is not orientorder/atom", id_orientorder);
threshold = utils::numeric(FLERR, arg[5], false, lmp); threshold = utils::numeric(FLERR, arg[5], false, lmp);
if (threshold <= -1.0 || threshold >= 1.0) if (threshold <= -1.0 || threshold >= 1.0)
@ -128,8 +129,11 @@ ComputeCoordAtom::~ComputeCoordAtom()
void ComputeCoordAtom::init() void ComputeCoordAtom::init()
{ {
if (cstyle == ORIENT) { if (cstyle == ORIENT) {
int iorientorder = modify->find_compute(id_orientorder); c_orientorder =
c_orientorder = dynamic_cast<ComputeOrientOrderAtom *>(modify->compute[iorientorder]); dynamic_cast<ComputeOrientOrderAtom *>(modify->get_compute_by_id(id_orientorder));
if (!c_orientorder)
error->all(FLERR, "Could not find compute coord/atom compute ID {}", id_orientorder);
cutsq = c_orientorder->cutsq; cutsq = c_orientorder->cutsq;
l = c_orientorder->qlcomp; l = c_orientorder->qlcomp;
// communicate real and imaginary 2*l+1 components of the normalized vector // communicate real and imaginary 2*l+1 components of the normalized vector

View File

@ -159,6 +159,8 @@ void ComputeCountType::compute_vector()
nvec = count_dihedrals(); nvec = count_dihedrals();
else if (mode == IMPROPER) else if (mode == IMPROPER)
nvec = count_impropers(); nvec = count_impropers();
else
nvec = 0;
// sum across procs as bigint, then convert to double // sum across procs as bigint, then convert to double
// correct for multiple counting if newton_bond off // correct for multiple counting if newton_bond off

View File

@ -57,11 +57,8 @@ ComputeErotateSphereAtom::~ComputeErotateSphereAtom()
void ComputeErotateSphereAtom::init() void ComputeErotateSphereAtom::init()
{ {
int count = 0; if (modify->get_compute_by_style(style).size() > 1)
for (int i = 0; i < modify->ncompute; i++) if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style);
if (strcmp(modify->compute[i]->style,"erotate/sphere/atom") == 0) count++;
if (count > 1 && comm->me == 0)
error->warning(FLERR,"More than one compute erotate/sphere/atom");
pfactor = 0.5 * force->mvv2e * INERTIA; pfactor = 0.5 * force->mvv2e * INERTIA;
} }

View File

@ -84,11 +84,8 @@ void ComputeFragmentAtom::init()
if (atom->molecular != Atom::MOLECULAR) if (atom->molecular != Atom::MOLECULAR)
error->all(FLERR,"Compute fragment/atom requires a molecular system"); error->all(FLERR,"Compute fragment/atom requires a molecular system");
int count = 0; if (modify->get_compute_by_style(style).size() > 1)
for (int i = 0; i < modify->ncompute; i++) if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style);
if (strcmp(modify->compute[i]->style,"fragment/atom") == 0) count++;
if (count > 1 && comm->me == 0)
error->warning(FLERR,"More than one compute fragment/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -47,10 +47,8 @@ ComputeKEAtom::~ComputeKEAtom()
void ComputeKEAtom::init() void ComputeKEAtom::init()
{ {
int count = 0; if (modify->get_compute_by_style(style).size() > 1)
for (int i = 0; i < modify->ncompute; i++) if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style);
if (strcmp(modify->compute[i]->style, "ke/atom") == 0) count++;
if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute ke/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -176,12 +176,11 @@ void FixWallReflect::init()
} }
int nrigid = 0; int nrigid = 0;
for (int i = 0; i < modify->nfix; i++) for (const auto &ifix : modify->get_fix_list())
if (modify->fix[i]->rigid_flag) nrigid++; if (ifix->rigid_flag) nrigid++;
if (nrigid && comm->me == 0) if (nrigid && (comm->me == 0))
error->warning(FLERR,"Should not allow rigid bodies to bounce off " error->warning(FLERR,"Should not use reflecting walls with rigid bodies");
"relecting walls");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -55,9 +55,9 @@ void ResetAtomsID::command(int narg, char **arg)
error->all(FLERR, "Reset_atoms id command before simulation box is defined"); error->all(FLERR, "Reset_atoms id command before simulation box is defined");
if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset_atoms id unless atoms have IDs"); if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset_atoms id unless atoms have IDs");
for (int i = 0; i < modify->nfix; i++) for (const auto &ifix : modify->get_fix_list())
if (modify->fix[i]->stores_ids) if (ifix->stores_ids)
error->all(FLERR, "Cannot use reset_atoms id when a fix exists that stores atom IDs"); error->all(FLERR, "Cannot use reset_atoms id with a fix {} storing atom IDs", ifix->style);
if (comm->me == 0) utils::logmesg(lmp, "Resetting atom IDs ...\n"); if (comm->me == 0) utils::logmesg(lmp, "Resetting atom IDs ...\n");

View File

@ -2,22 +2,26 @@
" Language: Lammps Simulation Script File " Language: Lammps Simulation Script File
" Maintainer: Gerolf Ziegenhain <gerolf@ziegenhain.com> " Maintainer: Gerolf Ziegenhain <gerolf@ziegenhain.com>
" Updates: Axel Kohlmeyer <akohlmey@gmail.com>, Sam Bateman <sam.bateman@nrlssc.navy.mil>, Daniel Möller Montull <d.moller.m@gmail.com>, Eryk Skalinski <eskalinski@protonmail.com> " Updates: Axel Kohlmeyer <akohlmey@gmail.com>, Sam Bateman <sam.bateman@nrlssc.navy.mil>, Daniel Möller Montull <d.moller.m@gmail.com>, Eryk Skalinski <eskalinski@protonmail.com>
" Latest Revision: 2022-08-17 " Latest Revision: 2023-07-15
syn clear syn clear
syn keyword lammpsOutput log write_data write_dump info shell write_restart restart dump undump thermo thermo_modify thermo_style print timer " Add '/' to list of valid keyword characters
set iskeyword+=/
syn keyword lammpsOutput log write_data write_dump write_coeff info shell write_restart restart dump undump thermo thermo_modify
syn keyword lammpsOutput thermo_style print timer
syn keyword lammpsRead include read_restart read_data read_dump molecule syn keyword lammpsRead include read_restart read_data read_dump molecule
syn keyword lammpsLattice boundary units atom_style lattice region create_box create_atoms dielectric syn keyword lammpsLattice boundary units atom_style lattice region create_box create_atoms dielectric
syn keyword lammpsLattice delete_atoms displace_atoms change_box dimension replicate syn keyword lammpsLattice delete_atoms displace_atoms change_box dimension replicate
syn keyword lammpsParticle pair_coeff pair_style pair_modify pair_write mass velocity angle_coeff angle_style syn keyword lammpsParticle pair_coeff pair_style pair_modify pair_write mass velocity angle_coeff angle_style angle_write
syn keyword lammpsParticle atom_modify atom_style bond_coeff bond_style bond_write create_bonds delete_bonds kspace_style syn keyword lammpsParticle atom_modify atom_style bond_coeff bond_style bond_write create_bonds delete_bonds kspace_style
syn keyword lammpsParticle kspace_modify dihedral_style dihedral_coeff improper_style improper_coeff syn keyword lammpsParticle kspace_modify dihedral_style dihedral_coeff dihedral_write improper_style improper_coeff labelmap
syn keyword lammpsSetup min_style fix_modify run_style timestep neighbor neigh_modify fix unfix suffix special_bonds syn keyword lammpsSetup min_style min_modify fix_modify run_style timestep neighbor neigh_modify fix unfix suffix special_bonds
syn keyword lammpsSetup balance box clear comm_modify comm_style newton package processors reset_ids reset_timestep syn keyword lammpsSetup balance box clear comm_modify comm_style newton package processors reset_atoms reset_ids reset_timestep
syn keyword lammpsRun minimize run rerun tad neb prd quit server temper temper/grem temper/npt syn keyword lammpsRun minimize minimize/kk run rerun tad neb neb/spin prd quit server temper/npt temper/grem temper
syn keyword lammpsRun min/spin message hyper dynamical_matrix syn keyword lammpsRun message hyper dynamical_matrix dynamical_matrix/kk third_order third_order/kk fitpod
syn keyword lammpsDefine variable group compute python set uncompute kim_query syn keyword lammpsDefine variable group compute python set uncompute kim_query kim group2ndx ndx2group mdi
syn keyword lammpsRepeat jump next loop syn keyword lammpsRepeat jump next loop