Skip to content

Commit

Permalink
Default to finite difference calculation of the Jacobian (#1835)
Browse files Browse the repository at this point in the history
Fixes #1832
  • Loading branch information
visr authored Sep 23, 2024
1 parent 221d51b commit a25c96f
Show file tree
Hide file tree
Showing 5 changed files with 6 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 @@ -106,7 +106,7 @@ const nodetypes = collect(keys(nodekinds))
water_balance_reltol::Float64 = 1e-2
maxiters::Int = 1e9
sparse::Bool = true
autodiff::Bool = true
autodiff::Bool = false
end

# Separate struct, as basin clashes with nodetype
Expand Down
4 changes: 2 additions & 2 deletions core/test/config_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@testset "docs" begin
config = Ribasim.Config(normpath(@__DIR__, "docs.toml"))
@test config isa Ribasim.Config
@test config.solver.autodiff
@test !config.solver.autodiff
end
end

Expand Down Expand Up @@ -60,7 +60,7 @@ end
AutoForwardDiff()
@test alg_autodiff(algorithm(Solver(; algorithm = "QNDF", autodiff = false))) ==
AutoFiniteDiff()
@test alg_autodiff(algorithm(Solver(; algorithm = "QNDF"))) == AutoForwardDiff()
@test alg_autodiff(algorithm(Solver(; algorithm = "QNDF"))) == AutoFiniteDiff()
# autodiff is not a kwargs for explicit algorithms, but we use try-catch to bypass
algorithm(Solver(; algorithm = "Euler", 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 @@ -37,7 +37,7 @@ water_balance_abstol = 1e-3 # optional, default 1e-3
water_balance_reltol = 1e-2 # optional, default 1e-2
maxiters = 1e9 # optional, default 1e9
sparse = true # optional, default true
autodiff = true # optional, default true
autodiff = false # optional, default false

[logging]
# defines the logging level of Ribasim
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 @@ -121,7 +121,7 @@ class Solver(ChildModel):
reltol: float = 1e-05
maxiters: int = 1000000000
sparse: bool = True
autodiff: bool = True
autodiff: bool = False


class Verbosity(str, Enum):
Expand Down
1 change: 1 addition & 0 deletions python/ribasim_testmodels/ribasim_testmodels/backwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def backwater_model():
starttime="2020-01-01",
endtime="2021-01-01",
crs="EPSG:28992",
solver=ribasim.Solver(autodiff=True),
)

model.flow_boundary.add(
Expand Down

0 comments on commit a25c96f

Please sign in to comment.