Unverified Commit 2f3c7321 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

detect if dt has been changed from default and print warning if reset by units command

parent df9f0e24
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 ");
  }

+1 −0
Original line number Diff line number Diff line
@@ -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++)
+1 −0
Original line number Diff line number Diff line
@@ -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();
+1 −0
Original line number Diff line number Diff line
@@ -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;
}

/* ---------------------------------------------------------------------- */
+22 −7
Original line number Diff line number Diff line
@@ -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 "comm.h"
#include "compute.h"
#include "integrate.h"
#include "error.h"
#include "fix.h"
#include "force.h"
#include "min.h"
#include "modify.h"
#include "fix.h"
#include "compute.h"
#include "neighbor.h"
#include "output.h"
#include "error.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;
}

/* ---------------------------------------------------------------------- */
Loading