diff --git a/Manifest.toml b/Manifest.toml index c3f119250..ef1ef47f5 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,8 +1,8 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.5" +julia_version = "1.10.4" manifest_format = "2.0" -project_hash = "cb280eab35cc3e7e9591c656bf26e09cfd6deb26" +project_hash = "e72ac404cd043f3685f5cfeb75ddd98fba9d8a7b" [[deps.ADTypes]] git-tree-sha1 = "99a6f5d0ce1c7c6afdb759daa30226f71c54f6b0" @@ -67,9 +67,9 @@ version = "0.4.0" [[deps.ArrayInterface]] deps = ["Adapt", "LinearAlgebra"] -git-tree-sha1 = "f54c23a5d304fb87110de62bace7777d59088c34" +git-tree-sha1 = "3640d077b6dafd64ceb8fd5c1ec76f7ca53bcf76" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "7.15.0" +version = "7.16.0" [deps.ArrayInterface.extensions] ArrayInterfaceBandedMatricesExt = "BandedMatrices" @@ -107,9 +107,9 @@ weakdeps = ["SparseArrays"] [[deps.Arrow]] deps = ["ArrowTypes", "BitIntegers", "CodecLz4", "CodecZstd", "ConcurrentUtilities", "DataAPI", "Dates", "EnumX", "LoggingExtras", "Mmap", "PooledArrays", "SentinelArrays", "Tables", "TimeZones", "TranscodingStreams", "UUIDs"] -git-tree-sha1 = "f8d411d1b45459368567dc51f683ed78a919d795" +git-tree-sha1 = "4ece4573f169d64b1508b0c8dd38c7919ae7a907" uuid = "69666777-d1a9-59fb-9406-91d4454c9d45" -version = "2.7.2" +version = "2.7.3" [[deps.ArrowTypes]] deps = ["Sockets", "UUIDs"] @@ -682,10 +682,10 @@ weakdeps = ["ArrowTypes", "Parsers"] ParsersExt = "Parsers" [[deps.IntelOpenMP_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "14eb2b542e748570b56446f4c50fbfb2306ebc45" +deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl"] +git-tree-sha1 = "10bd689145d2c3b2a9844005d01087cc1194e79e" uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0" -version = "2024.2.0+0" +version = "2024.2.1+0" [[deps.InteractiveUtils]] deps = ["Markdown"] @@ -729,9 +729,9 @@ version = "0.4.52" [[deps.JLLWrappers]] deps = ["Artifacts", "Preferences"] -git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca" +git-tree-sha1 = "f389674c99bfcde17dc57454011aa44d5a260a40" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.5.0" +version = "1.6.0" [[deps.JSON]] deps = ["Dates", "Mmap", "Parsers", "Unicode"] @@ -1342,7 +1342,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", "OrdinaryDiffEqBDF", "OrdinaryDiffEqCore", "OrdinaryDiffEqLowOrderRK", "OrdinaryDiffEqNonlinearSolve", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqSDIRK", "OrdinaryDiffEqTsit5", "PreallocationTools", "SQLite", "SciMLBase", "SparseArrays", "SparseConnectivityTracer", "StructArrays", "Tables", "TerminalLoggers", "TranscodingStreams"] +deps = ["ADTypes", "Accessors", "Arrow", "BasicModelInterface", "CodecZstd", "ComponentArrays", "Configurations", "DBInterface", "DataInterpolations", "DataStructures", "Dates", "DiffEqBase", "DiffEqCallbacks", "EnumX", "FiniteDiff", "ForwardDiff", "Graphs", "HiGHS", "IterTools", "JuMP", "Legolas", "LineSearches", "LinearSolve", "Logging", "LoggingExtras", "MetaGraphsNext", "OrdinaryDiffEqBDF", "OrdinaryDiffEqCore", "OrdinaryDiffEqLowOrderRK", "OrdinaryDiffEqNonlinearSolve", "OrdinaryDiffEqRosenbrock", "OrdinaryDiffEqSDIRK", "OrdinaryDiffEqTsit5", "PreallocationTools", "SQLite", "SciMLBase", "SparseArrays", "SparseConnectivityTracer", "StructArrays", "Tables", "TerminalLoggers", "TranscodingStreams"] path = "core" uuid = "aac5e3d9-0b8f-4d4f-8241-b1a7a9632635" version = "2024.10.0" @@ -1425,9 +1425,9 @@ weakdeps = ["SparseArrays", "StaticArraysCore"] [[deps.SciMLStructures]] deps = ["ArrayInterface"] -git-tree-sha1 = "20ad3e7c137156c50c93c888d0f2bc5b7883c729" +git-tree-sha1 = "25514a6f200219cd1073e4ff23a6324e4a7efe64" uuid = "53ae85a6-f571-4167-b2af-e1d143709226" -version = "1.4.2" +version = "1.5.0" [[deps.Scratch]] deps = ["Dates"] @@ -1803,7 +1803,7 @@ version = "1.5.6+0" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.11.0+0" +version = "5.8.0+1" [[deps.libsodium_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] diff --git a/core/Project.toml b/core/Project.toml index 314242033..b25398088 100644 --- a/core/Project.toml +++ b/core/Project.toml @@ -5,6 +5,7 @@ manifest = "../Manifest.toml" version = "2024.10.0" [deps] +ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" BasicModelInterface = "59605e27-edc0-445a-b93d-c09a3a50b330" @@ -15,6 +16,7 @@ DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965" DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def" EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56" FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" diff --git a/core/src/Ribasim.jl b/core/src/Ribasim.jl index 06c1bf7c3..8b01b16b1 100644 --- a/core/src/Ribasim.jl +++ b/core/src/Ribasim.jl @@ -23,6 +23,7 @@ using OrdinaryDiffEqCore: calculate_residuals! using OrdinaryDiffEqNonlinearSolve: OrdinaryDiffEqNonlinearSolve, relax!, _compute_rhs! using LineSearches: BackTracking +using DiffEqBase: remake # Interface for defining and solving the ODE problem of the physical layer. using SciMLBase: diff --git a/core/src/config.jl b/core/src/config.jl index 41722747b..3a7bfdb6b 100644 --- a/core/src/config.jl +++ b/core/src/config.jl @@ -14,12 +14,14 @@ using Dates: DateTime using Logging: LogLevel, Debug, Info, Warn, Error using ..Ribasim: Ribasim, isnode, nodetype using OrdinaryDiffEqCore: OrdinaryDiffEqAlgorithm, OrdinaryDiffEqNewtonAdaptiveAlgorithm -using OrdinaryDiffEqNonlinearSolve: NLNewton +using OrdinaryDiffEqNonlinearSolve: NLNewton, NonlinearSolveAlg, NewtonRaphson using OrdinaryDiffEqLowOrderRK: Euler, RK4 using OrdinaryDiffEqTsit5: Tsit5 using OrdinaryDiffEqSDIRK: ImplicitEuler, KenCarp4, TRBDF2 using OrdinaryDiffEqBDF: QNDF using OrdinaryDiffEqRosenbrock: Rodas5, Rosenbrock23 +using LineSearches: BackTracking +using ADTypes: AutoForwardDiff export Config, Solver, Results, Logging, Toml export algorithm, @@ -233,8 +235,11 @@ function algorithm(solver::Solver; u0 = [])::OrdinaryDiffEqAlgorithm end kwargs = Dict{Symbol, Any}() if algotype <: OrdinaryDiffEqNewtonAdaptiveAlgorithm - kwargs[:nlsolve] = NLNewton(; - relax = Ribasim.MonitoredBackTracking(; z_tmp = copy(u0), dz_tmp = copy(u0)), + # kwargs[:nlsolve] = NLNewton(; + # relax = Ribasim.MonitoredBackTracking(; z_tmp = copy(u0), dz_tmp = copy(u0)), + # ) + kwargs[:nlsolve] = NonlinearSolveAlg( + NewtonRaphson(; linesearch = BackTracking(), autodiff = AutoForwardDiff()), ) end # not all algorithms support this keyword diff --git a/core/src/solve.jl b/core/src/solve.jl index f02ed6ac0..4b5d3ac4b 100644 --- a/core/src/solve.jl +++ b/core/src/solve.jl @@ -2,11 +2,11 @@ The right hand side function of the system of ODEs set up by Ribasim. """ function water_balance!( - du::ComponentVector, - u::ComponentVector, + du::V, + u::V, p::Parameters, t::Number, -)::Nothing +)::Nothing where {V <: ComponentVector} (; graph, basin, pid_control) = p du .= 0.0