diff --git a/Manifest.toml b/Manifest.toml index 26dd24095..7acc88738 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1312,7 +1312,7 @@ uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" version = "3.5.18" [[deps.Ribasim]] -deps = ["Accessors", "Arrow", "BasicModelInterface", "CodecZstd", "ComponentArrays", "Configurations", "DBInterface", "DataInterpolations", "DataStructures", "Dates", "DiffEqCallbacks", "EnumX", "FiniteDiff", "ForwardDiff", "Graphs", "HiGHS", "IterTools", "JuMP", "Legolas", "LineSearches", "LinearSolve", "Logging", "LoggingExtras", "MetaGraphsNext", "OrdinaryDiffEq", "PreallocationTools", "ReadOnlyArrays", "SQLite", "SciMLBase", "SparseArrays", "StructArrays", "Tables", "TerminalLoggers", "TimerOutputs", "TranscodingStreams"] +deps = ["Accessors", "Arrow", "BasicModelInterface", "CodecZstd", "ComponentArrays", "Configurations", "DBInterface", "DataInterpolations", "DataStructures", "Dates", "DiffEqCallbacks", "EnumX", "FiniteDiff", "ForwardDiff", "Graphs", "HiGHS", "IterTools", "JuMP", "Legolas", "LinearSolve", "Logging", "LoggingExtras", "MetaGraphsNext", "OrdinaryDiffEq", "PreallocationTools", "ReadOnlyArrays", "SQLite", "SciMLBase", "SparseArrays", "StructArrays", "Tables", "TerminalLoggers", "TimerOutputs", "TranscodingStreams"] path = "core" uuid = "aac5e3d9-0b8f-4d4f-8241-b1a7a9632635" version = "2024.10.0" diff --git a/core/Project.toml b/core/Project.toml index cac0c9446..d66d26907 100644 --- a/core/Project.toml +++ b/core/Project.toml @@ -24,7 +24,6 @@ HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b" IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" Legolas = "741b9549-f6ed-4911-9fbf-4a1c0c97f0cd" -LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255" LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36" @@ -73,7 +72,6 @@ IterTools = "1.4" JuMP = "1.15" Legolas = "0.5" LinearSolve = "2.24" -LineSearches = "7.2" Logging = "<0.0.1, 1" LoggingExtras = "1" Makie = "0.21" diff --git a/core/src/config.jl b/core/src/config.jl index 11e97608d..c7ef41eec 100644 --- a/core/src/config.jl +++ b/core/src/config.jl @@ -11,7 +11,6 @@ module config using Configurations: Configurations, @option, from_toml, @type_alias using DataStructures: DefaultDict using Dates: DateTime -using LineSearches: BackTracking using Logging: LogLevel, Debug, Info, Warn, Error using ..Ribasim: Ribasim, isnode, nodetype using OrdinaryDiffEq: @@ -241,7 +240,7 @@ function algorithm(solver::Solver)::OrdinaryDiffEqAlgorithm end kwargs = Dict{Symbol, Any}() if algotype <: OrdinaryDiffEqNewtonAdaptiveAlgorithm - kwargs[:nlsolve] = NLNewton(; relax = BackTracking()) + kwargs[:nlsolve] = NLNewton(; relax = 0.1) end # not all algorithms support this keyword kwargs[:autodiff] = solver.autodiff diff --git a/core/test/run_models_test.jl b/core/test/run_models_test.jl index fdf31bf77..340f819df 100644 --- a/core/test/run_models_test.jl +++ b/core/test/run_models_test.jl @@ -206,7 +206,7 @@ end @test successful_retcode(model) @test allunique(Ribasim.tsaves(model)) - @test model.integrator.sol.u[end] ≈ Float32[519.8817, 519.8798, 339.3959, 1418.4331] skip = + @test model.integrator.u ≈ Float32[519.8817, 519.8798, 339.3959, 1418.4331] skip = Sys.isapple() atol = 1.5 @test length(logger.logs) > 10 @@ -241,8 +241,8 @@ end @test allunique(Ribasim.tsaves(model)) precipitation = Ribasim.get_tmp(model.integrator.p.basin.vertical_flux, 0).precipitation @test length(precipitation) == 4 - @test model.integrator.sol.u[end] ≈ Float32[471.9218, 471.9199, 363.6981, 1427.962] skip = - Sys.isapple() + @test model.integrator.u ≈ Float32[472.06555, 472.06366, 367.23883, 1427.9957] atol = + 2.0 skip = Sys.isapple() end @testitem "Allocation example model" begin @@ -276,14 +276,14 @@ end @test successful_retcode(sparse_fdm) @test successful_retcode(dense_fdm) - @test dense_ad.integrator.sol.u[end] ≈ sparse_ad.integrator.sol.u[end] atol = 0.1 - @test sparse_fdm.integrator.sol.u[end] ≈ sparse_ad.integrator.sol.u[end] atol = 4 - @test dense_fdm.integrator.sol.u[end] ≈ sparse_ad.integrator.sol.u[end] atol = 4 + @test dense_ad.integrator.u ≈ sparse_ad.integrator.u atol = 0.1 + @test sparse_fdm.integrator.u ≈ sparse_ad.integrator.u atol = 4 + @test dense_fdm.integrator.u ≈ sparse_ad.integrator.u atol = 4 config = Ribasim.Config(toml_path; solver_algorithm = "Rodas5", solver_autodiff = true) time_ad = Ribasim.run(config) @test successful_retcode(time_ad) - @test time_ad.integrator.sol.u[end] ≈ sparse_ad.integrator.sol.u[end] atol = 4 + @test time_ad.integrator.u ≈ sparse_ad.integrator.u atol = 4 end @testitem "TabulatedRatingCurve model" begin @@ -295,7 +295,7 @@ end model = Ribasim.run(toml_path) @test model isa Ribasim.Model @test successful_retcode(model) - @test model.integrator.sol.u[end] ≈ Float32[7.783636, 726.16394] skip = Sys.isapple() + @test model.integrator.u ≈ Float32[7.783636, 726.16394] skip = Sys.isapple() # the highest level in the dynamic table is updated to 1.2 from the callback @test model.integrator.p.tabulated_rating_curve.table[end].t[end] == 1.2 end @@ -471,8 +471,7 @@ end model = Ribasim.run(toml_path) @test successful_retcode(model) - u = model.integrator.sol.u[end] - p = model.integrator.p + (; u, p) = model.integrator h_actual = get_tmp(p.basin.current_level, u)[1:50] x = collect(10.0:20.0:990.0) h_expected = standard_step_method(x, 5.0, 1.0, 0.04, h_actual[end], 1.0e-6)