detect if dt has been changed from default and print warning if reset by units command
This commit is contained in:
@ -869,7 +869,7 @@ void PairEffCut::init_style()
|
||||
// make sure to use the appropriate timestep when using real units
|
||||
|
||||
if (update->whichflag == 1) {
|
||||
if (force->qqr2e == 332.06371 && update->dt == 1.0)
|
||||
if (utils::strmatch(update->unit_style,"^real") && update->dt_default)
|
||||
error->all(FLERR,"Must lower the default real units timestep for pEFF ");
|
||||
}
|
||||
|
||||
|
||||
@ -186,6 +186,7 @@ void FixSMDTlsphDtReset::end_of_step() {
|
||||
|
||||
|
||||
update->dt = dt;
|
||||
update->dt_default = 0;
|
||||
if (force->pair)
|
||||
force->pair->reset_dt();
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
|
||||
@ -190,6 +190,7 @@ void FixDtReset::end_of_step()
|
||||
|
||||
update->update_time();
|
||||
update->dt = dt;
|
||||
update->dt_default = 0;
|
||||
if (respaflag) update->integrate->reset_dt();
|
||||
if (force->pair) force->pair->reset_dt();
|
||||
for (int i = 0; i < modify->nfix; i++) modify->fix[i]->reset_dt();
|
||||
|
||||
@ -1871,6 +1871,7 @@ void Input::timestep()
|
||||
{
|
||||
if (narg != 1) error->all(FLERR,"Illegal timestep command");
|
||||
update->dt = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
update->dt_default = 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -12,18 +12,22 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "update.h"
|
||||
#include <cstring>
|
||||
#include "integrate.h"
|
||||
#include "min.h"
|
||||
|
||||
#include "style_integrate.h" // IWYU pragma: keep
|
||||
#include "style_minimize.h" // IWYU pragma: keep
|
||||
#include "neighbor.h"
|
||||
#include "force.h"
|
||||
#include "modify.h"
|
||||
#include "fix.h"
|
||||
|
||||
#include "comm.h"
|
||||
#include "compute.h"
|
||||
#include "output.h"
|
||||
#include "integrate.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#include "force.h"
|
||||
#include "min.h"
|
||||
#include "modify.h"
|
||||
#include "neighbor.h"
|
||||
#include "output.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
@ -48,6 +52,7 @@ Update::Update(LAMMPS *lmp) : Pointers(lmp)
|
||||
|
||||
eflag_global = vflag_global = -1;
|
||||
|
||||
dt_default = 1;
|
||||
unit_style = NULL;
|
||||
set_units("lj");
|
||||
|
||||
@ -121,6 +126,8 @@ void Update::set_units(const char *style)
|
||||
// http://physics.nist.gov/cuu/Constants/Table/allascii.txt
|
||||
// using thermochemical calorie = 4.184 J
|
||||
|
||||
double dt_old = dt;
|
||||
|
||||
if (strcmp(style,"lj") == 0) {
|
||||
force->boltz = 1.0;
|
||||
force->hplanck = 1.0;
|
||||
@ -295,6 +302,14 @@ void Update::set_units(const char *style)
|
||||
int n = strlen(style) + 1;
|
||||
unit_style = new char[n];
|
||||
strcpy(unit_style,style);
|
||||
|
||||
// check if timestep was changed from default value
|
||||
if (!dt_default && (comm->me == 0)) {
|
||||
error->warning(FLERR,fmt::format("Changing timestep from {:.6} to {:.6} "
|
||||
"due to changing units to {}",
|
||||
dt_old, dt, unit_style));
|
||||
}
|
||||
dt_default = 1;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -37,6 +37,7 @@ class Update : protected Pointers {
|
||||
int setupflag; // set when setup() is computing forces
|
||||
int post_integrate; // 1 if now at post_integrate() in timestep
|
||||
int multireplica; // 1 if min across replicas, else 0
|
||||
int dt_default; // 1 if dt is at default value, else 0
|
||||
|
||||
bigint eflag_global,eflag_atom; // timestep global/peratom eng is tallied on
|
||||
bigint vflag_global,vflag_atom; // ditto for virial
|
||||
|
||||
Reference in New Issue
Block a user