Skip to content

Commit

Permalink
Add error starttime > endtime (#1379)
Browse files Browse the repository at this point in the history
Fixes #1378.

---------

Co-authored-by: Martijn Visser <[email protected]>
  • Loading branch information
SouthEndMusic and visr authored Apr 11, 2024
1 parent 6e53201 commit 8ee1d35
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ function Model(config::Config)::Model
TimerOutputs.enable_debug_timings(Ribasim) # causes recompilation (!)
end

t_end = seconds_since(config.endtime, config.starttime)
if t_end <= 0
error("Model starttime is not before endtime.")
end

# All data from the database that we need during runtime is copied into memory,
# so we can directly close it again.
db = SQLite.DB(db_path)
Expand Down Expand Up @@ -108,7 +113,6 @@ function Model(config::Config)::Model
# Integrals for PID control
integral = zeros(length(parameters.pid_control.node_id))
u0 = ComponentVector{Float64}(; storage, integral)
t_end = seconds_since(config.endtime, config.starttime)
# for Float32 this method allows max ~1000 year simulations without accuracy issues
@assert eps(t_end) < 3600 "Simulation time too long"
t0 = zero(t_end)
Expand Down

0 comments on commit 8ee1d35

Please sign in to comment.