From a25c96febdaa66c356bf639a654aac6f71019384 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Mon, 23 Sep 2024 14:45:47 +0200 Subject: [PATCH] Default to finite difference calculation of the Jacobian (#1835) Fixes #1832 --- core/src/config.jl | 2 +- core/test/config_test.jl | 4 ++-- core/test/docs.toml | 2 +- python/ribasim/ribasim/config.py | 2 +- python/ribasim_testmodels/ribasim_testmodels/backwater.py | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/config.jl b/core/src/config.jl index 95e4d8c52..1aa849892 100644 --- a/core/src/config.jl +++ b/core/src/config.jl @@ -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 diff --git a/core/test/config_test.jl b/core/test/config_test.jl index 07021234e..8f9cb3e8f 100644 --- a/core/test/config_test.jl +++ b/core/test/config_test.jl @@ -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 @@ -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)) diff --git a/core/test/docs.toml b/core/test/docs.toml index 317cdf226..39b7b2894 100644 --- a/core/test/docs.toml +++ b/core/test/docs.toml @@ -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 diff --git a/python/ribasim/ribasim/config.py b/python/ribasim/ribasim/config.py index 9e9a7d18d..bc3d7ad5b 100644 --- a/python/ribasim/ribasim/config.py +++ b/python/ribasim/ribasim/config.py @@ -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): diff --git a/python/ribasim_testmodels/ribasim_testmodels/backwater.py b/python/ribasim_testmodels/ribasim_testmodels/backwater.py index b40b72083..81f6fa2a0 100644 --- a/python/ribasim_testmodels/ribasim_testmodels/backwater.py +++ b/python/ribasim_testmodels/ribasim_testmodels/backwater.py @@ -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(