Skip to content

Commit

Permalink
Test for success (#457)
Browse files Browse the repository at this point in the history
#450 broke the misc_nodes tests
since now `adaptive=false` has to be expilictly set.

This only showed up as a warning:

```
┌ Warning: dt(3.725290298461914e-9) <= dtmin(3.725290298461914e-9) at t=34560.0, and step error estimate = 1.0. Aborting. There is either an error in your model specification or the true solution is unstable.
└ @ SciMLBase C:\Users\visser_mn\.julia\packages\SciMLBase\kTUaf\src\integrator_interface.jl:599
```

To avoid missing issues like that we should check if the model returns
with a `ReturnCode.Success`.
  • Loading branch information
visr authored Jul 25, 2023
1 parent 8760c68 commit 8cb1fea
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/core_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
- uses: julia-actions/cache@v1
with:
cache-compiled: "true"
cache-registries: "true"
- uses: julia-actions/julia-buildpkg@v1
with:
project: core
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- uses: julia-actions/cache@v1
with:
cache-compiled: "true"
cache-registries: "true"

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
Expand Down
4 changes: 4 additions & 0 deletions core/test/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ TimerOutputs.disable_debug_timings(Ribasim) # causes recompilation (!)
toml_path = normpath(@__DIR__, "../../data/linear_resistance/linear_resistance.toml")
@test ispath(toml_path)
model = Ribasim.run(toml_path)
@test model.integrator.sol.retcode == Ribasim.ReturnCode.Success
p = model.integrator.p

t = Ribasim.timesteps(model)
Expand All @@ -89,6 +90,7 @@ end
toml_path = normpath(@__DIR__, "../../data/rating_curve/rating_curve.toml")
@test ispath(toml_path)
model = Ribasim.run(toml_path)
@test model.integrator.sol.retcode == Ribasim.ReturnCode.Success
p = model.integrator.p

t = Ribasim.timesteps(model)
Expand Down Expand Up @@ -120,6 +122,7 @@ end
toml_path = normpath(@__DIR__, "../../data/manning_resistance/manning_resistance.toml")
@test ispath(toml_path)
model = Ribasim.run(toml_path)
@test model.integrator.sol.retcode == Ribasim.ReturnCode.Success
p = model.integrator.p
(; manning_resistance) = p

Expand Down Expand Up @@ -154,6 +157,7 @@ end
toml_path = normpath(@__DIR__, "../../data/misc_nodes/misc_nodes.toml")
@test ispath(toml_path)
model = Ribasim.run(toml_path)
@test model.integrator.sol.retcode == Ribasim.ReturnCode.Success
p = model.integrator.p
(; flow_boundary, fractional_flow, pump) = p

Expand Down
1 change: 1 addition & 0 deletions core/test/run_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ end
toml_path = normpath(@__DIR__, "../../data/backwater/backwater.toml")
@test ispath(toml_path)
model = Ribasim.run(toml_path)
@test model.integrator.sol.retcode == Ribasim.ReturnCode.Success

u = model.integrator.sol.u[end]
p = model.integrator.p
Expand Down
1 change: 1 addition & 0 deletions python/ribasim_testmodels/ribasim_testmodels/equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ def miscellaneous_nodes_model():

# Setup solver:
solver = ribasim.Solver(
adaptive=False,
dt=24 * 24 * 60,
algorithm="Euler",
)
Expand Down

0 comments on commit 8cb1fea

Please sign in to comment.