Skip to content

Commit 158da24

Browse files
Merge branch 'master' into master
2 parents ec86815 + a8beedb commit 158da24

File tree

134 files changed

+19492
-20161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+19492
-20161
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ jobs:
2222
- AlgConvergence_II
2323
- AlgConvergence_III
2424
- Downstream
25+
- Symplectic
2526
- Extrapolation
27+
- StabilizedRK
28+
- StabilizedIRK
2629
- ODEInterfaceRegression
2730
- Multithreading
2831
version:

.github/workflows/Downstream.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- {user: SciML, repo: ModelingToolkit.jl, group: All}
3434
- {user: SciML, repo: DiffEqDevTools.jl, group: Core}
3535
- {user: nathanaelbosch, repo: ProbNumDiffEq.jl, group: Downstream}
36+
- {user: SKopecz, repo: PositiveIntegrators.jl, group: Downstream}
3637

3738
steps:
3839
- uses: actions/checkout@v4
@@ -59,7 +60,7 @@ jobs:
5960
err isa Pkg.Resolve.ResolverError || rethrow()
6061
# If we can't resolve that means this is incompatible by SemVer and this is fine
6162
# It means we marked this as a breaking change, so we don't need to worry about
62-
# Mistakenly introducing a breaking change, as we have intentionally made one
63+
# mistakenly introducing a breaking change, as we have intentionally made one
6364
@info "Not compatible with this release. No problem." exception=err
6465
exit(0) # Exit immediately, as a success
6566
end

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OrdinaryDiffEq"
22
uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
33
authors = ["Chris Rackauckas <[email protected]>", "Yingbo Ma <[email protected]>"]
4-
version = "6.82.0"
4+
version = "6.86.0"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
@@ -40,6 +40,7 @@ SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"
4040
SimpleUnPack = "ce78b400-467f-4804-87d8-8f486da07d0a"
4141
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
4242
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
43+
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
4344
StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
4445
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
4546
TruncatedStacktraces = "781d530d-4396-4725-bb49-402e4bee1e77"
@@ -82,6 +83,7 @@ SimpleNonlinearSolve = "1"
8283
SimpleUnPack = "1"
8384
SparseArrays = "1.9"
8485
SparseDiffTools = "2.3"
86+
Static = "0.8, 1"
8587
StaticArrayInterface = "1.2"
8688
StaticArrays = "1.0"
8789
TruncatedStacktraces = "1.2"

docs/src/stiff/rosenbrock.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ ROS34PW1b
3838
ROS34PW2
3939
ROS34PW3
4040
ROS34PRw
41+
ROK4a
4142
ROS2S
4243
RosenbrockW6S4OS
4344
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name = "OrdinaryDiffEqDefault"
2+
uuid = "50262376-6c5a-4cf5-baba-aaf4f84d72d7"
3+
authors = ["ParamThakkar123 <[email protected]>"]
4+
version = "1.0.0"
5+
6+
[deps]
7+
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
8+
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
9+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
10+
11+
[extras]
12+
DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
13+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
14+
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
15+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
16+
17+
[compat]
18+
julia = "1.10"
19+
20+
[targets]
21+
test = ["DiffEqDevTools", "Random", "SafeTestsets", "Test"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module OrdinaryDiffEqDefault
2+
3+
using OrdinaryDiffEq: Vern7, Vern8, Vern9, Vern6, Tsit5, Rosenbrock23, Rodas5P, FBDF,
4+
alg_stability_size, beta2_default, beta1_default, AutoSwitchCache, ODEIntegrator,
5+
CompositeAlgorithm, OrdinaryDiffEqAlgorithm, OrdinaryDiffEqMutableCache, AutoAlgSwitch
6+
import OrdinaryDiffEq: is_mass_matrix_alg, default_autoswitch
7+
import LinearSolve
8+
using LinearAlgebra: I, isdiag
9+
using EnumX
10+
11+
include("default_alg.jl")
12+
13+
export DefaultODEAlgorithm
14+
15+
end # module OrdinaryDiffEqDefault
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
EnumX.@enumx DefaultSolverChoice begin
2+
Tsit5 = 1
3+
Vern7 = 2
4+
Rosenbrock23 = 3
5+
Rodas5P = 4
6+
FBDF = 5
7+
KrylovFBDF = 6
8+
end
9+
10+
const NUM_NONSTIFF = 2
11+
const NUM_STIFF = 4
12+
const LOW_TOL = 1e-6
13+
const MED_TOL = 1e-2
14+
const EXTREME_TOL = 1e-9
15+
const SMALLSIZE = 50
16+
const MEDIUMSIZE = 500
17+
const STABILITY_SIZES = (alg_stability_size(Tsit5()), alg_stability_size(Vern7()))
18+
const DEFAULTBETA2S = (
19+
beta2_default(Tsit5()), beta2_default(Vern7()), beta2_default(Rosenbrock23()),
20+
beta2_default(Rodas5P()), beta2_default(FBDF()), beta2_default(FBDF()))
21+
const DEFAULTBETA1S = (
22+
beta1_default(Tsit5(), DEFAULTBETA2S[1]), beta1_default(Vern7(), DEFAULTBETA2S[2]),
23+
beta1_default(Rosenbrock23(), DEFAULTBETA2S[3]), beta1_default(
24+
Rodas5P(), DEFAULTBETA2S[4]),
25+
beta1_default(FBDF(), DEFAULTBETA2S[5]), beta1_default(FBDF(), DEFAULTBETA2S[6]))
26+
27+
callbacks_exists(integrator) = !isempty(integrator.opts.callbacks)
28+
current_nonstiff(current) = ifelse(current <= NUM_NONSTIFF, current, current - NUM_STIFF)
29+
30+
function DefaultODEAlgorithm(; lazy = true, stiffalgfirst = false, kwargs...)
31+
nonstiff = (Tsit5(), Vern7(lazy = lazy))
32+
stiff = (Rosenbrock23(; kwargs...), Rodas5P(; kwargs...), FBDF(; kwargs...),
33+
FBDF(; linsolve = LinearSolve.KrylovJL_GMRES(), kwargs...))
34+
AutoAlgSwitch(nonstiff, stiff; stiffalgfirst)
35+
end
36+
37+
function is_stiff(integrator, alg, ntol, stol, is_stiffalg, current)
38+
eigen_est, dt = integrator.eigen_est, integrator.dt
39+
stiffness = abs(eigen_est * dt /
40+
STABILITY_SIZES[nonstiffchoice(integrator.opts.reltol)]) # `abs` here is just for safety
41+
tol = is_stiffalg ? stol : ntol
42+
os = oneunit(stiffness)
43+
bool = stiffness > os * tol
44+
45+
if !bool
46+
integrator.alg.choice_function.successive_switches += 1
47+
else
48+
integrator.alg.choice_function.successive_switches = 0
49+
end
50+
51+
integrator.do_error_check = (integrator.alg.choice_function.successive_switches >
52+
integrator.alg.choice_function.switch_max || !bool) ||
53+
is_stiffalg
54+
bool
55+
end
56+
57+
function nonstiffchoice(reltol)
58+
x = if reltol < LOW_TOL
59+
DefaultSolverChoice.Vern7
60+
else
61+
DefaultSolverChoice.Tsit5
62+
end
63+
Int(x)
64+
end
65+
66+
function stiffchoice(reltol, len, mass_matrix)
67+
x = if len > MEDIUMSIZE
68+
DefaultSolverChoice.KrylovFBDF
69+
elseif len > SMALLSIZE
70+
DefaultSolverChoice.FBDF
71+
else
72+
if reltol < LOW_TOL || !isdiag(mass_matrix)
73+
DefaultSolverChoice.Rodas5P
74+
else
75+
DefaultSolverChoice.Rosenbrock23
76+
end
77+
end
78+
Int(x)
79+
end
80+
81+
function default_autoswitch(AS::AutoSwitchCache, integrator)
82+
len = length(integrator.u)
83+
reltol = integrator.opts.reltol
84+
85+
# Choose the starting method
86+
if AS.current == 0
87+
choice = if AS.stiffalgfirst || integrator.f.mass_matrix != I
88+
stiffchoice(reltol, len, integrator.f.mass_matrix)
89+
else
90+
nonstiffchoice(reltol)
91+
end
92+
AS.current = choice
93+
return AS.current
94+
end
95+
96+
dt = integrator.dt
97+
# Successive stiffness test positives are counted by a positive integer,
98+
# and successive stiffness test negatives are counted by a negative integer
99+
AS.count = is_stiff(integrator, AS.nonstiffalg, AS.nonstifftol, AS.stifftol,
100+
AS.is_stiffalg, AS.current) ?
101+
AS.count < 0 ? 1 : AS.count + 1 :
102+
AS.count > 0 ? -1 : AS.count - 1
103+
if integrator.f.mass_matrix != I
104+
#don't change anything
105+
elseif (!AS.is_stiffalg && AS.count > AS.maxstiffstep)
106+
integrator.dt = dt * AS.dtfac
107+
AS.is_stiffalg = true
108+
AS.current = stiffchoice(reltol, len, integrator.f.mass_matrix)
109+
elseif (AS.is_stiffalg && AS.count < -AS.maxnonstiffstep)
110+
integrator.dt = dt / AS.dtfac
111+
AS.is_stiffalg = false
112+
AS.current = nonstiffchoice(reltol)
113+
end
114+
return AS.current
115+
end
116+
117+
# hack for the default alg
118+
function is_mass_matrix_alg(alg::CompositeAlgorithm{
119+
<:Any, <:Tuple{Tsit5, Vern7, Rosenbrock23, Rodas5P, FBDF, FBDF}})
120+
true
121+
end

lib/OrdinaryDiffEqExtrapolation/src/OrdinaryDiffEqExtrapolation.jl

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,22 @@ module OrdinaryDiffEqExtrapolation
33
import OrdinaryDiffEq: alg_order, alg_maximum_order, get_current_adaptive_order,
44
get_current_alg_order, calculate_residuals!, accept_step_controller,
55
default_controller, beta2_default, beta1_default, gamma_default,
6-
initialize!, perform_step!, @unpack, unwrap_alg, isthreaded,
6+
initialize!, perform_step!, @unpack, @cache, unwrap_alg, isthreaded,
77
step_accept_controller!, calculate_residuals,
88
OrdinaryDiffEqMutableCache, OrdinaryDiffEqConstantCache,
99
reset_alg_dependent_opts!, AbstractController,
1010
step_accept_controller!, step_reject_controller!,
11-
OrdinaryDiffEqAdaptiveAlgorithm, OrdinaryDiffEqAdaptiveImplicitAlgorithm,
12-
alg_cache, CompiledFloats, @threaded, stepsize_controller!, DEFAULT_PRECS,
11+
OrdinaryDiffEqAdaptiveAlgorithm,
12+
OrdinaryDiffEqAdaptiveImplicitAlgorithm,
13+
alg_cache, CompiledFloats, @threaded, stepsize_controller!,
14+
DEFAULT_PRECS,
1315
constvalue, PolyesterThreads, Sequential, BaseThreads,
1416
_digest_beta1_beta2, timedepentdtmin, _unwrap_val,
1517
TimeDerivativeWrapper, UDerivativeWrapper, calc_J, _reshape, _vec,
1618
WOperator, TimeGradientWrapper, UJacobianWrapper, build_grad_config,
1719
build_jac_config, calc_J!, jacobian2W!, dolinsolve
1820
using DiffEqBase, FastBroadcast, Polyester, MuladdMacro, RecursiveArrayTools, LinearSolve
1921

20-
macro cache(expr)
21-
name = expr.args[2].args[1].args[1]
22-
fields = [x for x in expr.args[3].args if typeof(x) != LineNumberNode]
23-
cache_vars = Expr[]
24-
jac_vars = Pair{Symbol, Expr}[]
25-
for x in fields
26-
if x.args[2] == :uType || x.args[2] == :rateType ||
27-
x.args[2] == :kType || x.args[2] == :uNoUnitsType
28-
push!(cache_vars, :(c.$(x.args[1])))
29-
elseif x.args[2] == :DiffCacheType
30-
push!(cache_vars, :(c.$(x.args[1]).du))
31-
push!(cache_vars, :(c.$(x.args[1]).dual_du))
32-
end
33-
end
34-
quote
35-
$(esc(expr))
36-
$(esc(:full_cache))(c::$name) = tuple($(cache_vars...))
37-
end
38-
end
39-
4022
include("algorithms.jl")
4123
include("alg_utils.jl")
4224
include("controllers.jl")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name = "OrdinaryDiffEqFeagin"
2+
uuid = "101fe9f7-ebb6-4678-b671-3a81e7194747"
3+
authors = ["ParamThakkar123 <[email protected]>"]
4+
version = "1.0.0"
5+
6+
[deps]
7+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
8+
9+
[extras]
10+
DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
11+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
12+
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
13+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
14+
15+
[compat]
16+
julia = "1.10"
17+
18+
[targets]
19+
test = ["DiffEqDevTools", "Random", "SafeTestsets", "Test"]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module OrdinaryDiffEqFeagin
2+
3+
import OrdinaryDiffEq: alg_order, calculate_residuals!,
4+
initialize!, perform_step!, @unpack, unwrap_alg,
5+
calculate_residuals,
6+
OrdinaryDiffEqAlgorithm,
7+
OrdinaryDiffEqMutableCache, OrdinaryDiffEqConstantCache,
8+
OrdinaryDiffEqAdaptiveAlgorithm, CompiledFloats, uses_uprev,
9+
alg_cache, _vec, _reshape, @cache, isfsal, full_cache,
10+
constvalue, _unwrap_val, du_alias_or_new,
11+
explicit_rk_docstring, trivial_limiter!,
12+
_ode_interpolant!, _ode_addsteps!
13+
using DiffEqBase, FastBroadcast, Polyester, MuladdMacro, RecursiveArrayTools
14+
using DiffEqBase: @def, @tight_loop_macros
15+
using Static: False
16+
17+
include("algorithms.jl")
18+
include("alg_utils.jl")
19+
include("feagin_tableaus.jl")
20+
include("feagin_caches.jl")
21+
include("feagin_rk_perform_step.jl")
22+
23+
export Feagin10, Feagin12, Feagin14
24+
25+
end

0 commit comments

Comments
 (0)