From 5970e5e6db6f6dc5cc199f2d84b3632dc4050b5d Mon Sep 17 00:00:00 2001 From: MintoDA1 <51412913+MintoDA1@users.noreply.github.com> Date: Fri, 28 Jul 2023 12:24:55 -0400 Subject: [PATCH] Added sanity check to ensure tstep_out <= tstop --- python/swiftest/swiftest/simulation_class.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 139bec27d..809ca5615 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -113,7 +113,7 @@ def __init__(self,read_param: bool = False, Parameter input file equivalent: `ISTEP_OUT` tstep_out : float, optional The approximate time between when outputs are written to file. Passing this computes - `istep_out = floor(tstep_out/dt)`. *Note*: only `istep_out` or `tstep_out` can be set. + `istep_out = floor(tstep_out/dt)`. *Note*: only `istep_out` or `tstep_out` can be set. `tstep_out` must be less than `tstop` Parameter input file equivalent: None nstep_out : int, optional The total number of times that outputs are written to file. Passing this allows for a geometric progression of output steps: @@ -676,6 +676,10 @@ def set_simulation_time(self, return {} else: update_list.append("istep_out") + + if tstep_out is not None and tstep_out > tstop: + warnings.warn("tstep_out must be less than tstop. Setting tstep_out=tstop",stacklevel=2) + tstep_out = tstop if tstep_out is not None and dt is not None: istep_out = int(tstep_out / dt) @@ -683,6 +687,7 @@ def set_simulation_time(self, if istep_out is not None: self.param['ISTEP_OUT'] = int(istep_out) + if nstep_out is not None: if istep_out is None: warnings.warn("nstep_out requires either istep_out or tstep_out to also be set", stacklevel=2)