Skip to content

Commit

Permalink
Merge branch 'master' into ADTypesSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
jClugstor authored Nov 7, 2024
2 parents 949e0de + 45e7a23 commit f0590ff
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 37 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -121,8 +121,8 @@ OrdinaryDiffEqQPRK = "1"
OrdinaryDiffEqRKN = "1"
OrdinaryDiffEqRosenbrock = "1"
OrdinaryDiffEqSDIRK = "1"
OrdinaryDiffEqStabilizedIRK = "1"
OrdinaryDiffEqSSPRK = "1"
OrdinaryDiffEqStabilizedIRK = "1"
OrdinaryDiffEqStabilizedRK = "1"
OrdinaryDiffEqSymplecticRK = "1"
OrdinaryDiffEqTsit5 = "1"
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions lib/OrdinaryDiffEqCore/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OrdinaryDiffEqCore"
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
authors = ["ParamThakkar123 <[email protected]>"]
version = "1.9.0"
version = "1.10.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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

Expand Down
26 changes: 25 additions & 1 deletion lib/OrdinaryDiffEqCore/src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqExtrapolation/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OrdinaryDiffEqExtrapolation"
uuid = "becaefa8-8ca2-5cf9-886d-c06f3d2bd2c4"
authors = ["Chris Rackauckas <[email protected]>", "Yingbo Ma <[email protected]>"]
version = "1.2.0"
version = "1.2.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqFIRK/test/ode_firk_tests.jl
Original file line number Diff line number Diff line change
@@ -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())
Expand Down
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqNonlinearSolve/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OrdinaryDiffEqNonlinearSolve"
uuid = "127b3ac7-2247-4354-8eb6-78cf4e7c58e8"
authors = ["Chris Rackauckas <[email protected]>", "Yingbo Ma <[email protected]>"]
version = "1.2.1"
version = "1.2.2"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqNonlinearSolve/src/type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqRosenbrock/src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
""",
Expand Down
32 changes: 16 additions & 16 deletions lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
""",
Expand All @@ -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.
""",
Expand All @@ -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.
""",
Expand All @@ -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.
""",
Expand All @@ -971,7 +971,7 @@ references = """
publisher={Springer}}
""") ROS34PW1a

@doc rosenbrock_wanner_docstring(
@doc rosenbrock_wolfbrandt_docstring(
"""
A 4th order L-stable Rosenbrock-W method.
""",
Expand All @@ -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.
""",
Expand All @@ -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.
""",
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -1200,7 +1200,7 @@ references = """
""",
with_step_limiter=true) Veldd4

@doc rosenbrock_docstring(
@doc rosenbrock_wolfbrandt_docstring(
"""
A 4th order A-stable Rosenbrock method.
""",
Expand Down Expand Up @@ -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).
""",
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/downstream/autodiff_events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/downstream/delaydiffeq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ using Test
@test sol.errors[:l∞] < error

sol_scalar = solve(prob_scalar, ddealg)
@test sol.tsol_scalar.t atol=1e-6
@test sol[1, :] sol_scalar.u
@test sol.tsol_scalar.t atol=1e-3
@test sol[1, :] sol_scalar.u atol=1e-3
end
end

Expand Down

0 comments on commit f0590ff

Please sign in to comment.