merge set_time command into reset_timestep
This commit is contained in:
@ -105,7 +105,6 @@ An alphabetic list of all general LAMMPS commands.
|
||||
* :doc:`run <run>`
|
||||
* :doc:`run_style <run_style>`
|
||||
* :doc:`set <set>`
|
||||
* :doc:`set_time <set_time>`
|
||||
* :doc:`shell <shell>`
|
||||
* :doc:`special_bonds <special_bonds>`
|
||||
* :doc:`suffix <suffix>`
|
||||
|
||||
@ -96,7 +96,6 @@ Commands
|
||||
run
|
||||
run_style
|
||||
set
|
||||
set_time
|
||||
shell
|
||||
special_bonds
|
||||
suffix
|
||||
|
||||
@ -8,9 +8,16 @@ Syntax
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
reset_timestep N
|
||||
reset_timestep N keyword values ...
|
||||
|
||||
* N = timestep number
|
||||
* N = timestep number (may be NULL)
|
||||
* zero or more keyword/value pairs may be appended
|
||||
* keyword = *time*
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
*time* value = atime
|
||||
atime = accumulated simulation time
|
||||
|
||||
Examples
|
||||
""""""""
|
||||
@ -19,48 +26,58 @@ Examples
|
||||
|
||||
reset_timestep 0
|
||||
reset_timestep 4000000
|
||||
reset_timestep 1000 time 100.0
|
||||
reset_timestep NULL time 200.0
|
||||
|
||||
Description
|
||||
"""""""""""
|
||||
|
||||
Set the timestep counter to the specified value. This command
|
||||
normally comes after the timestep has been set by reading a restart
|
||||
usually comes after the timestep has been set by reading a restart
|
||||
file via the :doc:`read_restart <read_restart>` command, or a previous
|
||||
simulation advanced the timestep.
|
||||
simulation run or minimization advanced the timestep.
|
||||
|
||||
The optional *time* keyword allows to also set the accumulated
|
||||
simulation time. This is usually the number of timesteps times
|
||||
the size of the timestep, but when using variable size timesteps
|
||||
with :doc:`fix dt/reset <fix_dt_reset>` it can differ. With
|
||||
NULL as the timestep number, only the accumulated time is reset.
|
||||
|
||||
The :doc:`read_data <read_data>` and :doc:`create_box <create_box>`
|
||||
commands set the timestep to 0; the :doc:`read_restart <read_restart>`
|
||||
command sets the timestep to the value it had when the restart file
|
||||
was written.
|
||||
was written. The same applies to the accumulated simulation time.
|
||||
|
||||
|
||||
Restrictions
|
||||
""""""""""""
|
||||
none
|
||||
|
||||
This command cannot be used when any fixes are defined that keep track
|
||||
of elapsed time to perform certain kinds of time-dependent operations.
|
||||
Examples are the :doc:`fix deposit <fix_deposit>` and :doc:`fix dt/reset <fix_dt_reset>` commands. The former adds atoms on
|
||||
specific timesteps. The latter keeps track of accumulated time.
|
||||
Examples are the :doc:`fix deposit <fix_deposit>` and :doc:`fix dt/reset
|
||||
<fix_dt_reset>` commands. The former adds atoms on specific timesteps.
|
||||
The latter keeps track of accumulated time.
|
||||
|
||||
Various fixes use the current timestep to calculate related
|
||||
quantities. If the timestep is reset, this may produce unexpected
|
||||
behavior, but LAMMPS allows the fixes to be defined even if the
|
||||
timestep is reset. For example, commands which thermostat the system,
|
||||
e.g. :doc:`fix nvt <fix_nh>`, allow you to specify a target temperature
|
||||
which ramps from Tstart to Tstop which may persist over several runs.
|
||||
If you change the timestep, you may induce an instantaneous change in
|
||||
the target temperature.
|
||||
Various fixes use the current timestep to calculate related quantities.
|
||||
If the timestep is reset, this may produce unexpected behavior, but
|
||||
LAMMPS allows the fixes to be defined even if the timestep is reset.
|
||||
For example, commands which thermostat the system, e.g. :doc:`fix nvt
|
||||
<fix_nh>`, allow you to specify a target temperature which ramps from
|
||||
Tstart to Tstop which may persist over several runs. If you change the
|
||||
timestep, you may induce an instantaneous change in the target
|
||||
temperature.
|
||||
|
||||
Resetting the timestep clears flags for :doc:`computes <compute>` that
|
||||
may have calculated some quantity from a previous run. This means
|
||||
these quantity cannot be accessed by a variable in between runs until
|
||||
a new run is performed. See the :doc:`variable <variable>` command for
|
||||
more details.
|
||||
may have calculated some quantity from a previous run. This means these
|
||||
quantity cannot be accessed by a variable in between runs until a new
|
||||
run is performed. See the :doc:`variable <variable>` command for more
|
||||
details.
|
||||
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
:doc:`rerun <rerun>`
|
||||
:doc:`rerun <rerun>`, :doc:`timestep <timestep>`,
|
||||
:doc:`fix dt/reset <fix_dt_reset>`
|
||||
|
||||
Default
|
||||
"""""""
|
||||
|
||||
@ -1,44 +0,0 @@
|
||||
.. index:: set_time
|
||||
|
||||
set_time command
|
||||
================
|
||||
|
||||
Syntax
|
||||
""""""
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
set_time t
|
||||
|
||||
* t = current simulation time (time units)
|
||||
|
||||
Examples
|
||||
""""""""
|
||||
|
||||
.. code-block:: LAMMPS
|
||||
|
||||
time 0.0
|
||||
time 10.5
|
||||
|
||||
Description
|
||||
"""""""""""
|
||||
|
||||
Set the current accumulated simulation time for subsequent molecular
|
||||
dynamics simulations. See the :doc:`units <units>` command for the time
|
||||
units associated with each choice of units that LAMMPS supports.
|
||||
|
||||
|
||||
Restrictions
|
||||
""""""""""""
|
||||
none
|
||||
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
:doc:`reset_timestep <reset_timestep>`, :doc:`timestep <timestep>`,
|
||||
:doc:`fix dt/reset <fix_dt_reset>`, :doc:`units <units>`
|
||||
|
||||
Default
|
||||
"""""""
|
||||
|
||||
0.0 at the beginning of the first run.
|
||||
@ -773,7 +773,6 @@ int Input::execute_command()
|
||||
else if (!strcmp(command,"reset_timestep")) reset_timestep();
|
||||
else if (!strcmp(command,"restart")) restart();
|
||||
else if (!strcmp(command,"run_style")) run_style();
|
||||
else if (!strcmp(command,"set_time")) set_time();
|
||||
else if (!strcmp(command,"special_bonds")) special_bonds();
|
||||
else if (!strcmp(command,"suffix")) suffix();
|
||||
else if (!strcmp(command,"thermo")) thermo();
|
||||
@ -1773,16 +1772,6 @@ void Input::run_style()
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void Input::set_time()
|
||||
{
|
||||
if (narg != 1) error->all(FLERR,"Illegal set_time command");
|
||||
|
||||
update->atime = utils::numeric(FLERR,arg[0],false,lmp);
|
||||
update->atimestep = update->ntimestep;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void Input::special_bonds()
|
||||
{
|
||||
// store 1-3,1-4 and dihedral/extra flag values before change
|
||||
|
||||
@ -131,7 +131,6 @@ class Input : protected Pointers {
|
||||
void reset_timestep();
|
||||
void restart();
|
||||
void run_style();
|
||||
void set_time();
|
||||
void special_bonds();
|
||||
void suffix();
|
||||
void thermo();
|
||||
|
||||
@ -457,9 +457,19 @@ void Update::new_minimize(char *style, int /* narg */, char ** /* arg */, int tr
|
||||
|
||||
void Update::reset_timestep(int narg, char **arg)
|
||||
{
|
||||
if (narg != 1) error->all(FLERR, "Illegal reset_timestep command");
|
||||
bigint newstep = utils::bnumeric(FLERR, arg[0], false, lmp);
|
||||
reset_timestep(newstep, true);
|
||||
if (narg < 1) utils::missing_cmd_args(FLERR, "reset_timestep", error);
|
||||
|
||||
if (!utils::strmatch(arg[0], "^NULL$"))
|
||||
reset_timestep(utils::bnumeric(FLERR, arg[0], false, lmp), true);
|
||||
|
||||
if (narg > 1) {
|
||||
if (utils::strmatch(arg[1], "^time$")) {
|
||||
if (narg < 3) utils::missing_cmd_args(FLERR, "reset_timestep time", error);
|
||||
atimestep = ntimestep;
|
||||
atime = utils::numeric(FLERR, arg[2], false, lmp);
|
||||
} else
|
||||
error->all(FLERR, "Unknown reset_timestep option {}", arg[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
@ -224,55 +224,43 @@ TEST_F(SimpleCommandsTest, Quit)
|
||||
TEST_F(SimpleCommandsTest, ResetTimestep)
|
||||
{
|
||||
ASSERT_EQ(lmp->update->ntimestep, 0);
|
||||
ASSERT_EQ(lmp->update->atimestep, 0);
|
||||
ASSERT_DOUBLE_EQ(lmp->update->atime, 0.0);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset_timestep 10");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 10);
|
||||
ASSERT_EQ(lmp->update->atimestep, 10);
|
||||
ASSERT_DOUBLE_EQ(lmp->update->atime, lmp->update->dt * 10);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset_timestep 0");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 0);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Timestep must be >= 0.*", command("reset_timestep -10"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", command("reset_timestep"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", command("reset_timestep 10 10"););
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", command("reset_timestep xxx"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, SetTime)
|
||||
{
|
||||
ASSERT_EQ(lmp->update->ntimestep, 0);
|
||||
ASSERT_EQ(lmp->update->atimestep, 0);
|
||||
ASSERT_DOUBLE_EQ(lmp->update->atime, 0.0);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("set_time 10.0");
|
||||
command("reset_timestep NULL time 10.0");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 0);
|
||||
ASSERT_EQ(lmp->update->atimestep, 0);
|
||||
ASSERT_DOUBLE_EQ(lmp->update->atime, 10.0);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset_timestep 10");
|
||||
command("set_time 10.0");
|
||||
command("reset_timestep 10 time 100.0");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 10);
|
||||
ASSERT_EQ(lmp->update->atimestep, 10);
|
||||
ASSERT_DOUBLE_EQ(lmp->update->atime, 10.0);
|
||||
ASSERT_DOUBLE_EQ(lmp->update->atime, 100.0);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset_timestep 0");
|
||||
command("set_time 10.0");
|
||||
command("reset_timestep 10");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 10);
|
||||
ASSERT_EQ(lmp->update->atimestep, 10);
|
||||
ASSERT_DOUBLE_EQ(lmp->update->atime, 10.0 + lmp->update->dt * 10);
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal set_time .*", command("set_time"););
|
||||
TEST_FAILURE(".*ERROR: Illegal set_time .*", command("set_time 10 10"););
|
||||
TEST_FAILURE(".*ERROR: Expected floating .*", command("set_time xxx"););
|
||||
TEST_FAILURE(".*ERROR: Timestep must be >= 0.*", command("reset_timestep -10"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", command("reset_timestep"););
|
||||
TEST_FAILURE(".*ERROR: Unknown reset_timestep option 10.*", command("reset_timestep 10 10"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_timestep .*", command("reset_timestep 10 time"););
|
||||
TEST_FAILURE(".*ERROR: Expected floating .**", command("reset_timestep 10 time xxx"););
|
||||
TEST_FAILURE(".*ERROR: Expected integer .*", command("reset_timestep xxx"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Suffix)
|
||||
|
||||
Reference in New Issue
Block a user