Skip to content

Commit

Permalink
Decrease relative tolerance from 1e-5 to 1e-7
Browse files Browse the repository at this point in the history
With #1819 the state goes further away from 0 with time. That meanse we rely more on the relative tolerance than the aboslute tolerance.

Reducing the default `reltol` by two orders of magnitude is enough to get only negligible leaky Terminals with occasional very brief leaks of 1e-8 m3/s. It is also enough to minimize the infiltration error to acceptable levels as can be seen in #1863 (comment).

For HWS this slows down simulation from 9.1s to 12.3s, which isn't too bad for a two orders of magnitude reduction in relative tolerance.

https://docs.sciml.ai/DiffEqDocs/stable/basics/faq/#What-does-tolerance-mean-and-how-much-error-should-I-expect
  • Loading branch information
visr committed Oct 7, 2024
1 parent e9339b8 commit 8a5d7db
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/src/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const nodetypes = collect(keys(nodekinds))
dtmax::Union{Float64, Nothing} = nothing
force_dtmin::Bool = false
abstol::Float64 = 1e-6
reltol::Float64 = 1e-5
reltol::Float64 = 1e-7
water_balance_abstol::Float64 = 1e-3
water_balance_reltol::Float64 = 1e-2
maxiters::Int = 1e9
Expand Down
2 changes: 1 addition & 1 deletion core/test/docs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dtmin = 0.0 # optional, default 0.0
dtmax = 0.0 # optional, default length of simulation
force_dtmin = false # optional, default false
abstol = 1e-6 # optional, default 1e-6
reltol = 1e-5 # optional, default 1e-5
reltol = 1e-7 # optional, default 1e-7
water_balance_abstol = 1e-3 # optional, default 1e-3
water_balance_reltol = 1e-2 # optional, default 1e-2
maxiters = 1e9 # optional, default 1e9
Expand Down
4 changes: 2 additions & 2 deletions docs/concept/equations.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ For more a more in-depth discussion of numerical computations see [Numerical con

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.
- [Solver tolerance](https://docs.sciml.ai/DiffEqDocs/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-7` 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.
- Forcing: Every time new forcing data is injected into the model, it needs to pause.
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Solver(ChildModel):
abstol : float
The absolute tolerance for adaptive timestepping (Optional, defaults to 1e-6)
reltol : float
The relative tolerance for adaptive timestepping (Optional, defaults to 1e-5)
The relative tolerance for adaptive timestepping (Optional, defaults to 1e-7)
maxiters : int
The total number of linear iterations over the whole simulation. (Defaults to 1e9, only needs to be increased for extremely long simulations)
sparse : bool
Expand Down

0 comments on commit 8a5d7db

Please sign in to comment.