How to restart simulations#
Restarting simulations with Nek5000 can be tricky. For example, it is easy to erase some
results from the initial simulation! To fix this issue Snek5000 uses the notion of
“sessions”, meaning that some results of the different simulations are saved in
directories session_00
, session_01
, …
Moreover, there are with Nek5000 two different methods to restart a simulation:
(builtin with Nek5000) from a state file (but the time-stepping scheme has to be initialize so the restart is not perfect),
(with the KTH toolbox) from restart files (only works with solvers using this toolbox).
With Snek5000, restarting can be done with the command line snek-restart
(recommanded)
or with a Python function snek5000.load_for_restart()
. In this page, with focus on
the former method.
One can get the documentation of the command with
!snek-restart -h
usage: snek-restart [-h] [-oc] [-oi] [--modify-params MODIFY_PARAMS]
[--new-dir-results] [-np NB_MPI_PROCS]
[--use-start-from USE_START_FROM]
[--use-checkpoint USE_CHECKPOINT]
[--session-id SESSION_ID] [--skip-verify-contents]
[--add-to-end-time ADD_TO_END_TIME] [--end-time END_TIME]
[--num-steps NUM_STEPS]
path
Restart a fluidsim simulation
positional arguments:
path Path of the directory or file from which to restart
optional arguments:
-h, --help show this help message and exit
-oc, --only-check Only check what should be done
-oi, --only-init Only run initialization phase
--modify-params MODIFY_PARAMS
Code modifying the `params` object.
--new-dir-results Create a new directory for the new simulation
-np NB_MPI_PROCS, --nb-mpi-procs NB_MPI_PROCS
Number of MPI processes
--use-start-from USE_START_FROM
Name (relative to the session path) of the field file
to restart from. Mutually exclusive option with
`use_checkpoint`.
--use-checkpoint USE_CHECKPOINT
Number of the multi-file checkpoint file set to
restart from. Mutually exclusive parameter with
`use_start_from`.
--session-id SESSION_ID
Indicate which session directory should be used to
look for restart files. If not specified it would
default to the `path_session` value last recorded in
the `params_simul.xml` file.
--skip-verify-contents
Do not verify directory contents to avoid runtime
errors.
--add-to-end-time ADD_TO_END_TIME
Time added to params.nek.general.end_time
--end-time END_TIME params.nek.general.end_time
--num-steps NUM_STEPS
params.nek.general.num_steps
Let’s give few examples. We start from a simulation using the snek5000-phill
solver
(which uses the KTH toolbox).
To restart the simulation in a new session (no compilation needed) from the last state file, one can run:
snek-restart /path/of/the/simulation --use-start-from -1 --end-time 0.005
Note
This method is used in the tutorial using our snek5000-tgv solver.
To restart the simulation in a new session (no compilation needed) from the KTH toolbox restart files:
snek-restart /path/of/the/simulation --use-checkpoint 1 --end-time 0.005
Alternatively, one can restart a simulation in a new directory (new compilation needed, first directory unmodified) with:
snek-restart /path/of/the/simulation \ --use-checkpoint 1 --end-time 0.005 --new-dir-results \ --modify-params "params.nek.stat.av_step=1;"
This method is particularly useful when one wants to change parameters with the
--modify-params
option.