diff --git a/Project.toml b/Project.toml index 2ac3331b5e..da47ef934b 100644 --- a/Project.toml +++ b/Project.toml @@ -96,7 +96,7 @@ LinearSolve = "2" Logging = "1.9" MacroTools = "0.5" MuladdMacro = "0.2.1" -NonlinearSolve = "3" +NonlinearSolve = "3, 4" OrdinaryDiffEqAdamsBashforthMoulton = "1" OrdinaryDiffEqBDF = "1" OrdinaryDiffEqCore = "1" @@ -121,8 +121,8 @@ OrdinaryDiffEqQPRK = "1" OrdinaryDiffEqRKN = "1" OrdinaryDiffEqRosenbrock = "1" OrdinaryDiffEqSDIRK = "1" -OrdinaryDiffEqStabilizedIRK = "1" OrdinaryDiffEqSSPRK = "1" +OrdinaryDiffEqStabilizedIRK = "1" OrdinaryDiffEqStabilizedRK = "1" OrdinaryDiffEqSymplecticRK = "1" OrdinaryDiffEqTsit5 = "1" @@ -136,7 +136,7 @@ Reexport = "1.0" SciMLBase = "2.53.2" SciMLOperators = "0.3" SciMLStructures = "1" -SimpleNonlinearSolve = "1" +SimpleNonlinearSolve = "1, 2" SimpleUnPack = "1" SparseDiffTools = "2" Static = "0.8, 1" diff --git a/README.md b/README.md index 2af90c5a93..7d5268ac48 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ ordinary differential equation solvers and utilities. While completely independe and usable on its own, users interested in using this functionality should check out [DifferentialEquations.jl](https://github.com/SciML/DifferentialEquations.jl). + ## Installation Assuming that you already have Julia correctly installed, it suffices to import diff --git a/lib/OrdinaryDiffEqCore/Project.toml b/lib/OrdinaryDiffEqCore/Project.toml index 99b5cc8b23..3ebfcd37f1 100644 --- a/lib/OrdinaryDiffEqCore/Project.toml +++ b/lib/OrdinaryDiffEqCore/Project.toml @@ -1,7 +1,7 @@ name = "OrdinaryDiffEqCore" uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8" authors = ["ParamThakkar123 "] -version = "1.9.0" +version = "1.10.0" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" @@ -34,6 +34,7 @@ SimpleUnPack = "ce78b400-467f-4804-87d8-8f486da07d0a" Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" +SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5" TruncatedStacktraces = "781d530d-4396-4725-bb49-402e4bee1e77" [weakdeps] @@ -69,13 +70,14 @@ Random = "<0.0.1, 1" RecursiveArrayTools = "2.36, 3" Reexport = "1.0" SafeTestsets = "0.1.0" -SciMLBase = "2.56" +SciMLBase = "2.57.2" SciMLOperators = "0.3" SciMLStructures = "1" SimpleUnPack = "1" Static = "0.8, 1" StaticArrayInterface = "1.2" StaticArraysCore = "1.0" +SymbolicIndexingInterface = "0.3.31" Test = "<0.0.1, 1" TruncatedStacktraces = "1.2" julia = "1.10" diff --git a/lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl b/lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl index 071509cba1..92e6181891 100644 --- a/lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl +++ b/lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl @@ -76,6 +76,8 @@ import Accessors: @reset using SciMLStructures: canonicalize, Tunable, isscimlstructure +using SymbolicIndexingInterface: parameter_values, is_variable, variable_index, symbolic_type, NotSymbolic + const CompiledFloats = Union{Float32, Float64} import Preferences diff --git a/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl b/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl index b629a81141..e64e03dc39 100644 --- a/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl +++ b/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl @@ -3,7 +3,7 @@ # Hence, we need to have two separate functions. function _change_t_via_interpolation!(integrator, t, - modify_save_endpoint::Type{Val{T}}) where {T} + modify_save_endpoint::Type{Val{T}}, reinitialize_alg=nothing) where {T} # Can get rid of an allocation here with a function # get_tmp_arr(integrator.cache) which gives a pointer to some # cache array which can be modified. @@ -17,7 +17,7 @@ function _change_t_via_interpolation!(integrator, t, end integrator.t = t integrator.dt = integrator.t - integrator.tprev - DiffEqBase.reeval_internals_due_to_modification!(integrator) + DiffEqBase.reeval_internals_due_to_modification!(integrator; callback_initializealg=reinitialize_alg) if T solution_endpoint_match_cur_integrator!(integrator) end @@ -28,10 +28,10 @@ function DiffEqBase.change_t_via_interpolation!(integrator::ODEIntegrator, t, modify_save_endpoint::Type{Val{T}} = Val{ false, - }) where { + }, reinitialize_alg=nothing) where { T, } - _change_t_via_interpolation!(integrator, t, modify_save_endpoint) + _change_t_via_interpolation!(integrator, t, modify_save_endpoint, reinitialize_alg) return nothing end diff --git a/lib/OrdinaryDiffEqCore/src/solve.jl b/lib/OrdinaryDiffEqCore/src/solve.jl index e65a766b11..ef77e4c6b4 100644 --- a/lib/OrdinaryDiffEqCore/src/solve.jl +++ b/lib/OrdinaryDiffEqCore/src/solve.jl @@ -264,6 +264,30 @@ function DiffEqBase.__init( end ### Algorithm-specific defaults ### + if save_idxs === nothing + saved_subsystem = nothing + else + if !(save_idxs isa AbstractArray) || symbolic_type(save_idxs) != NotSymbolic() + _save_idxs = [save_idxs] + else + _save_idxs = save_idxs + end + saved_subsystem = SciMLBase.SavedSubsystem(prob, parameter_values(prob), _save_idxs) + if saved_subsystem !== nothing + _save_idxs = SciMLBase.get_saved_state_idxs(saved_subsystem) + if isempty(_save_idxs) + # no states to save + save_idxs = Int[] + elseif !(save_idxs isa AbstractArray) || symbolic_type(save_idxs) != NotSymbolic() + # only a single state to save, and save it as a scalar timeseries instead of + # single-element array + save_idxs = only(_save_idxs) + else + save_idxs = _save_idxs + end + end + end + if save_idxs === nothing ksEltype = Vector{rateType} else @@ -427,7 +451,7 @@ function DiffEqBase.__init( f, timeseries, ts, ks, alg_choice, dense, cache, differential_vars, false) sol = DiffEqBase.build_solution(prob, _alg, ts, timeseries, dense = dense, k = ks, interp = id, alg_choice = alg_choice, - calculate_error = false, stats = stats) + calculate_error = false, stats = stats, saved_subsystem = saved_subsystem) if recompile_flag == true FType = typeof(f) diff --git a/lib/OrdinaryDiffEqExtrapolation/Project.toml b/lib/OrdinaryDiffEqExtrapolation/Project.toml index f5fed64c5d..917b72b001 100644 --- a/lib/OrdinaryDiffEqExtrapolation/Project.toml +++ b/lib/OrdinaryDiffEqExtrapolation/Project.toml @@ -1,7 +1,7 @@ name = "OrdinaryDiffEqExtrapolation" uuid = "becaefa8-8ca2-5cf9-886d-c06f3d2bd2c4" authors = ["Chris Rackauckas ", "Yingbo Ma "] -version = "1.2.0" +version = "1.2.1" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/lib/OrdinaryDiffEqFIRK/test/ode_firk_tests.jl b/lib/OrdinaryDiffEqFIRK/test/ode_firk_tests.jl index b90c9da113..ab3799c15b 100644 --- a/lib/OrdinaryDiffEqFIRK/test/ode_firk_tests.jl +++ b/lib/OrdinaryDiffEqFIRK/test/ode_firk_tests.jl @@ -1,7 +1,7 @@ using OrdinaryDiffEqFIRK, DiffEqDevTools, Test, LinearAlgebra import ODEProblemLibrary: prob_ode_linear, prob_ode_2Dlinear, van -testTol = 0.35 +testTol = 0.5 for prob in [prob_ode_linear, prob_ode_2Dlinear] sim21 = test_convergence(1 .// 2 .^ (6:-1:3), prob, RadauIIA5()) diff --git a/lib/OrdinaryDiffEqNonlinearSolve/Project.toml b/lib/OrdinaryDiffEqNonlinearSolve/Project.toml index 1d93f1277d..7fdf2ae5c4 100644 --- a/lib/OrdinaryDiffEqNonlinearSolve/Project.toml +++ b/lib/OrdinaryDiffEqNonlinearSolve/Project.toml @@ -1,7 +1,7 @@ name = "OrdinaryDiffEqNonlinearSolve" uuid = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8" authors = ["Chris Rackauckas ", "Yingbo Ma "] -version = "1.2.1" +version = "1.2.2" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" diff --git a/lib/OrdinaryDiffEqNonlinearSolve/src/type.jl b/lib/OrdinaryDiffEqNonlinearSolve/src/type.jl index 4c36666b6e..89dba2fd81 100644 --- a/lib/OrdinaryDiffEqNonlinearSolve/src/type.jl +++ b/lib/OrdinaryDiffEqNonlinearSolve/src/type.jl @@ -100,7 +100,7 @@ function NLSolver{iip, tType}(z, tmp, ztmp, γ, c, α, alg, κ, fast_convergence tmp, tmp2, ztmp, - γ, + float(γ), convert(tType, c), convert(tType, α), alg, diff --git a/lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl b/lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl index 928b8c2b1d..6ba64ee4ab 100644 --- a/lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl +++ b/lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl @@ -40,7 +40,7 @@ using Reexport import OrdinaryDiffEqCore: alg_autodiff import OrdinaryDiffEqCore -function rosenbrock_wanner_docstring(description::String, +function rosenbrock_wolfbrandt_docstring(description::String, name::String; references::String = "", extra_keyword_description = "", @@ -119,7 +119,7 @@ function rosenbrock_wanner_docstring(description::String, end generic_solver_docstring( - description, name, "Rosenbrock-Wanner Method. ", references, + description, name, "Rosenbrock-Wanner-W(olfbrandt) Method. ", references, keyword_default_description, keyword_default ) end @@ -203,7 +203,7 @@ function rosenbrock_docstring(description::String, end generic_solver_docstring( - description, name, "Rosenbrock Method. ", references, + description, name, "Rosenbrock-Wanner Method. ", references, keyword_default_description, keyword_default ) end diff --git a/lib/OrdinaryDiffEqRosenbrock/src/algorithms.jl b/lib/OrdinaryDiffEqRosenbrock/src/algorithms.jl index 6e17d853ad..e0174e4bd3 100644 --- a/lib/OrdinaryDiffEqRosenbrock/src/algorithms.jl +++ b/lib/OrdinaryDiffEqRosenbrock/src/algorithms.jl @@ -144,7 +144,7 @@ function GeneralRosenbrock(; chunk_size = Val{0}(), autodiff = AutoForwardDiff() factorization) end -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 4th order L-stable Rosenbrock-W method (fixed step only). """, diff --git a/lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl b/lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl index d04018b4a6..74a0ad57c6 100644 --- a/lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl +++ b/lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl @@ -911,7 +911,7 @@ function ROS2Tableau() # 2nd order RosenbrockAdaptiveTableau(a,C,b,btilde,gamma,d,c) end -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ An Order 2/3 L-Stable Rosenbrock-W method which is good for very stiff equations with oscillations at low tolerances. 2nd order stiff-aware interpolation. """, @@ -922,7 +922,7 @@ Scientific Computing, 18 (1), pp. 1-22. """, with_step_limiter = true) Rosenbrock23 -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ An Order 3/2 A-Stable Rosenbrock-W method which is good for mildly stiff equations without oscillations at low tolerances. Note that this method is prone to instability in the presence of oscillations, so use with caution. 2nd order stiff-aware interpolation. """, @@ -944,7 +944,7 @@ references = """ """, with_step_limiter = true) ROS3P -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ An Order 2/3 L-Stable Rosenbrock-W method for stiff ODEs and DAEs in mass matrix form. 2nd order stiff-aware interpolation and additional error test for interpolation. """, @@ -955,7 +955,7 @@ references = """ """, with_step_limiter = true) Rodas23W -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 4th order L-stable Rosenbrock-W method. """, @@ -971,7 +971,7 @@ references = """ publisher={Springer}} """) ROS34PW1a -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 4th order L-stable Rosenbrock-W method. """, @@ -987,7 +987,7 @@ references = """ publisher={Springer}} """) ROS34PW1b -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 4th order stiffy accurate Rosenbrock-W method for PDAEs. """, @@ -1003,7 +1003,7 @@ references = """ publisher={Springer}} """) ROS34PW2 -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 4th order strongly A-stable (Rinf~0.63) Rosenbrock-W method. """, @@ -1088,7 +1088,7 @@ references = """ """, with_step_limiter=true) Rodas42 -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_docstring( """ 4th order A-stable stiffly stable Rosenbrock method with a stiff-aware 3rd order interpolant. 4th order on linear parabolic problems and 3rd order accurate on nonlinear parabolic problems (as opposed to @@ -1102,7 +1102,7 @@ references = """ """, with_step_limiter=true) Rodas4P -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 4th order L-stable stiffly stable Rosenbrock method with a stiff-aware 3rd order interpolant. 4th order on linear parabolic problems and 3rd order accurate on nonlinear parabolic problems. It is an improvement @@ -1128,7 +1128,7 @@ references = """ """, with_step_limiter=true) Rodas5 -@doc rosenbrock_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 5th order A-stable stiffly stable Rosenbrock method with a stiff-aware 4th order interpolant. Has improved stability in the adaptive time stepping embedding. @@ -1141,7 +1141,7 @@ references = """ """, with_step_limiter=true) Rodas5P -@doc rosenbrock_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 5th order A-stable stiffly stable Rosenbrock method with a stiff-aware 4th order interpolant. Has improved stability in the adaptive time stepping embedding. @@ -1154,7 +1154,7 @@ references = """ """, with_step_limiter=true) Rodas5Pr -@doc rosenbrock_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 5th order A-stable stiffly stable Rosenbrock method with a stiff-aware 4th order interpolant. Has improved stability in the adaptive time stepping embedding. @@ -1200,7 +1200,7 @@ references = """ """, with_step_limiter=true) Veldd4 -@doc rosenbrock_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ A 4th order A-stable Rosenbrock method. """, @@ -1324,7 +1324,7 @@ function ROS2STableau() # 2nd order RosenbrockAdaptiveTableau(a,C,b,btilde,gamma,d,c) end -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ 2nd order stiffly accurate Rosenbrock-Wanner W-method with 3 internal stages with B_PR consistent of order 2 with (Rinf=0). """, @@ -1619,7 +1619,7 @@ function ROS34PRwTableau() # 3rd order RosenbrockAdaptiveTableau(a,C,b,btilde,gamma,d,c) end -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ 3rd order stiffly accurate Rosenbrock-Wanner W-method with 4 internal stages, B_PR consistent of order 2. @@ -1736,7 +1736,7 @@ function ROK4aTableau() # 4rd order RosenbrockAdaptiveTableau(a,C,b,btilde,gamma,d,c) end -@doc rosenbrock_wanner_docstring( +@doc rosenbrock_wolfbrandt_docstring( """ 4rd order L-stable Rosenbrock-Krylov method with 4 internal stages, with a 3rd order embedded method which is strongly A-stable with Rinf~=0.55. (when using exact Jacobians) diff --git a/test/downstream/autodiff_events.jl b/test/downstream/autodiff_events.jl index 2b7438aa82..9c2a23c5a0 100644 --- a/test/downstream/autodiff_events.jl +++ b/test/downstream/autodiff_events.jl @@ -24,7 +24,7 @@ prob = ODEProblem(f, eltype(p).([1.0, 0.0]), eltype(p).((0.0, 1.0)), copy(p)) function test_f(p) _prob = remake(prob, p = p) solve(_prob, Tsit5(), abstol = 1e-14, reltol = 1e-14, callback = cb, - save_everystep = false)[end] + save_everystep = false).u[end] end findiff = Calculus.finite_difference_jacobian(test_f, p) findiff diff --git a/test/downstream/delaydiffeq.jl b/test/downstream/delaydiffeq.jl index 0601c3f421..65fe2d6aa8 100644 --- a/test/downstream/delaydiffeq.jl +++ b/test/downstream/delaydiffeq.jl @@ -24,8 +24,8 @@ using Test @test sol.errors[:l∞] < error sol_scalar = solve(prob_scalar, ddealg) - @test sol.t≈sol_scalar.t atol=1e-6 - @test sol[1, :] ≈ sol_scalar.u + @test sol.t≈sol_scalar.t atol=1e-3 + @test sol[1, :] ≈ sol_scalar.u atol=1e-3 end end