Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Added sanity check to ensure tstep_out <= tstop
Browse files Browse the repository at this point in the history
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Jul 28, 2023
1 parent fa59443 commit 5970e5e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -676,13 +676,18 @@ 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)

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)
Expand Down

0 comments on commit 5970e5e

Please sign in to comment.