detect if dt has been changed from default and print warning if reset by units command
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user