Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try Rodas5P as default solver #1869

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ end
const nodetypes = collect(keys(nodekinds))

@option struct Solver <: TableOption
algorithm::String = "QNDF"
algorithm::String = "Rodas5P"
saveat::Float64 = 86400.0
dt::Union{Float64, Nothing} = nothing
dtmin::Float64 = 0.0
Expand Down
2 changes: 1 addition & 1 deletion core/test/config_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end
using Ribasim: convert_saveat, convert_dt, Solver, algorithm

solver = Solver()
@test solver.algorithm == "QNDF"
@test solver.algorithm == "Rodas5P"
Solver(;
algorithm = "Rosenbrock23",
autodiff = true,
Expand Down
2 changes: 1 addition & 1 deletion core/test/docs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ timestep = 86400 # optional (required if use_allocation = true
use_allocation = false # optional, default false

[solver]
algorithm = "QNDF" # optional, default "QNDF"
algorithm = "Rodas5P" # optional, default "Rodas5P"
saveat = 86400 # optional, default 86400, 0 saves every timestep, inf saves only at start- and endtime
dt = 60.0 # optional, remove for adaptive time stepping
dtmin = 0.0 # optional, default 0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/concept/equations.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ There are many things that can influence the calculations times, for instance:
- [Solver tolerance](https://diffeq.sciml.ai/stable/basics/faq/#What-does-tolerance-mean-and-how-much-error-should-I-expect):
By default we use absolute and relative tolerances of `1e-6` and `1e-5` respectively.
- [ODE solvers](https://diffeq.sciml.ai/stable/solvers/ode_solve/):
The `QNDF` method we use is robust to oscillations and massive stiffness, however other solvers should be tried as well.
The `Rodas5P` method we use is robust to oscillations and massive stiffness, however other solvers should be tried as well.
- Forcing: Every time new forcing data is injected into the model, it needs to pause.
Moreover, the larger the forcing fluxes are, the bigger the shock to the system, leading to smaller timesteps and thus longer simulation times.

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/usage.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The solver section in the configuration file is entirely optional, since we aim
Common reasons to modify the solver settings are to adjust the calculation or result stepsizes: `dt`, and `saveat`.
If your model does not converge, or your performance is lower than expected, it can help to adjust other solver settings as well.

The default solver `algorithm = "QNDF"`, which is a multistep method similar to Matlab's `ode15s` [@shampine1997matlab].
The default solver is `algorithm = "Rodas5P"`, which is a 5th order A-stable stiffly stable Rosenbrock method.
It is an implicit method that supports the default adaptive timestepping.
The full list of available solvers is: `QNDF`, `FBDF`, `Rosenbrock23`, `Rodas4P`, `Rodas5P`, `TRBDF2`, `KenCarp4`, `Tsit5`, `RK4`, `ImplicitEuler`, `Euler`.
Information on the solver algorithms can be found on the [ODE solvers page](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/).
Expand Down
11 changes: 0 additions & 11 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,3 @@ @misc {pdoktopnl
url = "https://www.pdok.nl/downloads/-/article/basisregistratie-topografie-brt-topnl",
note = "[Online; accessed 31-August-2022]"
}

@article{shampine1997matlab,
title={The matlab ode suite},
author={Shampine, Lawrence F and Reichelt, Mark W},
journal={SIAM journal on scientific computing},
volume={18},
number={1},
pages={1--22},
year={1997},
publisher={SIAM}
}
4 changes: 2 additions & 2 deletions python/ribasim/ribasim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Solver(ChildModel):
Attributes
----------
algorithm : str
The used numerical time integration algorithm (Optional, defaults to QNDF)
The used numerical time integration algorithm (Optional, defaults to Rodas5P)
saveat : float
Time interval in seconds between saves of output data.
0 saves every timestep, inf only saves at start- and endtime. (Optional, defaults to 86400)
Expand All @@ -110,7 +110,7 @@ class Solver(ChildModel):
Whether automatic differentiation instead of fine difference is used to compute the Jacobian. (Optional, defaults to true)
"""

algorithm: str = "QNDF"
algorithm: str = "Rodas5P"
saveat: float = 86400.0
dt: float | None = None
dtmin: float | None = None
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_repr(basic):

def test_solver():
solver = Solver()
assert solver.algorithm == "QNDF" # default
assert solver.algorithm == "Rodas5P" # default
assert solver.saveat == 86400.0

solver = Solver(saveat=3600.0)
Expand Down
Loading