Skip to content

Commit 7a58a9e

Browse files
tweaks
1 parent 4ac990c commit 7a58a9e

File tree

6 files changed

+11
-89
lines changed

6 files changed

+11
-89
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ OrdinaryDiffEqQPRK = "1"
121121
OrdinaryDiffEqRKN = "1"
122122
OrdinaryDiffEqRosenbrock = "1"
123123
OrdinaryDiffEqSDIRK = "1"
124-
OrdinaryDiffEqStabilizedIRK = "1"
125124
OrdinaryDiffEqSSPRK = "1"
125+
OrdinaryDiffEqStabilizedIRK = "1"
126126
OrdinaryDiffEqStabilizedRK = "1"
127127
OrdinaryDiffEqSymplecticRK = "1"
128128
OrdinaryDiffEqTsit5 = "1"

lib/OrdinaryDiffEqFIRK/src/algorithms.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ end
169169

170170
function AdaptiveRadau(; chunk_size = Val{0}(), autodiff = Val{true}(),
171171
standardtag = Val{true}(), concrete_jac = nothing,
172-
diff_type = Val{:forward}, min_num_stages = 3, max_num_stages = 3,
172+
diff_type = Val{:forward}, min_num_stages = 3, max_num_stages = 7,
173173
linsolve = nothing, precs = DEFAULT_PRECS,
174174
extrapolant = :dense, fast_convergence_cutoff = 1 // 5,
175175
new_W_γdt_cutoff = 1 // 5,

lib/OrdinaryDiffEqFIRK/src/controllers.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151
function step_accept_controller!(integrator, controller::PredictiveController, alg::AdaptiveRadau, q)
5252
@unpack qmin, qmax, gamma, qsteady_min, qsteady_max = integrator.opts
5353
@unpack cache = integrator
54-
@unpack num_stages, step, θ, θprev, orders = cache
54+
@unpack num_stages, step, θ, θprev = cache
5555

5656
EEst = DiffEqBase.value(integrator.EEst)
5757

@@ -71,11 +71,12 @@ function step_accept_controller!(integrator, controller::PredictiveController, a
7171
integrator.erracc = max(1e-2, EEst)
7272

7373
cache.step = step + 1
74+
@show cache.num_stages
7475
if (step > 10)
7576
Ψ = θ * θprev
76-
if<= 0.002 && num_stages < alg.max_num_stages)
77+
if<= 0.001 && num_stages < alg.max_num_stages)
7778
cache.num_stages += 2
78-
elseif ((Ψ >= 0.8 || cache.status == VerySlowConvergence || cache.status == Divergence) && num_stages > alg.min_num_stages)
79+
elseif ((Ψ >= 0.1 || cache.status == VerySlowConvergence || cache.status == Divergence) && num_stages > alg.min_num_stages)
7980
cache.num_stages -= 2
8081
cache.step = 1
8182
end

lib/OrdinaryDiffEqFIRK/src/firk_caches.jl

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ mutable struct AdaptiveRadauConstantCache{F, Tab, Tol, Dt, U, JType} <:
490490
step::Int
491491
θ::BigFloat
492492
θprev::BigFloat
493-
orders::Vector{Int}
494493
end
495494

496495
function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits},
@@ -508,29 +507,15 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
508507
push!(tabs, adaptiveRadauTableau(uToltype, constvalue(tTypeNoUnits), i))
509508
i += 2
510509
end
511-
#=
512-
if (num_stages == 3)
513-
tab = BigRadauIIA5Tableau(uToltype, constvalue(tTypeNoUnits))
514-
elseif (num_stages == 5)
515-
tab = BigRadauIIA9Tableau(uToltype, constvalue(tTypeNoUnits))
516-
elseif (num_stages == 7)
517-
tab = BigRadauIIA13Tableau(uToltype, constvalue(tTypeNoUnits))
518-
elseif iseven(num_stages) || num_stages <3
519-
error("num_stages must be odd and 3 or greater")
520-
else
521-
tab = adaptiveRadauTableau(uToltype, constvalue(tTypeNoUnits), min_num_stages)
522-
end
523-
=#
524510
cont = Vector{typeof(u)}(undef, max)
525511
for i in 1: max
526512
cont[i] = zero(u)
527513
end
528514

529515
κ = alg.κ !== nothing ? convert(uToltype, alg.κ) : convert(uToltype, 1 // 100)
530516
J = false .* _vec(rate_prototype) .* _vec(rate_prototype)'
531-
orders = [0,0,0,0]
532517
AdaptiveRadauConstantCache(uf, tabs, κ, one(uToltype), 10000, cont, dt, dt,
533-
Convergence, J, num_stages, 1, big"1.0", big"1.0", orders)
518+
Convergence, J, num_stages, 1, big"1.0", big"1.0")
534519
end
535520

536521
mutable struct AdaptiveRadauCache{uType, cuType, tType, uNoUnitsType, rateType, JType, W1Type, W2Type,
@@ -576,7 +561,6 @@ mutable struct AdaptiveRadauCache{uType, cuType, tType, uNoUnitsType, rateType,
576561
step::Int
577562
θ::BigFloat
578563
θprev::BigFloat
579-
orders::Vector{Int}
580564
end
581565

582566
function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits},
@@ -597,19 +581,6 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
597581
push!(tabs, adaptiveRadauTableau(uToltype, constvalue(tTypeNoUnits), i))
598582
i += 2
599583
end
600-
#=
601-
if (num_stages == 3)
602-
tab = BigRadauIIA5Tableau(uToltype, constvalue(tTypeNoUnits))
603-
elseif (num_stages == 5)
604-
tab = BigRadauIIA9Tableau(uToltype, constvalue(tTypeNoUnits))
605-
elseif (num_stages == 7)
606-
tab = BigRadauIIA13Tableau(uToltype, constvalue(tTypeNoUnits))
607-
elseif iseven(num_stages) || num_stages < 3
608-
error("num_stages must be odd and 3 or greater")
609-
else
610-
tab = adaptiveRadauTableau(uToltype, constvalue(tTypeNoUnits), num_stages)
611-
end
612-
=#
613584

614585
κ = alg.κ !== nothing ? convert(uToltype, alg.κ) : convert(uToltype, 1 // 100)
615586

@@ -682,6 +653,6 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
682653
uf, tabs, κ, one(uToltype), 10000, tmp,
683654
atmp, jac_config,
684655
linsolve1, linsolve2, rtol, atol, dt, dt,
685-
Convergence, alg.step_limiter!, num_stages, 1, big"1.0", big"1.0", [0,0,0,0])
656+
Convergence, alg.step_limiter!, num_stages, 1, big"1.0", big"1.0")
686657
end
687658

lib/OrdinaryDiffEqFIRK/src/firk_tableaus.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function BigRadauIIA5Tableau(T1, T2)
136136
e = Vector{T1}(undef, 3)
137137
e[1] = big"-10.048809399827415944628228317014873027801513671875"
138138
e[2] = big"1.3821427331607492039466933420044369995594024658203125"
139-
e[3] = big"-0.333333333333333314829616256247390992939472198486328125"
139+
e[3] = big"-0.333333333333333333333333333333333333333333333333333"
140140

141141
TI = Matrix{T1}(undef, 3, 3)
142142
TI[1, 1] = big"4.32557989006315535102435095295614882731995158490590784287320458848019483341979047442263696495019938973156007686663488090615420049217658854859024016717169837"
@@ -180,7 +180,7 @@ function BigRadauIIA9Tableau(T1, T2)
180180
c[5] = big"1.0"
181181

182182
e = Vector{T1}(undef, 5)
183-
e[1] = big"27.78093394406463730479"
183+
e[1] = big"-27.78093394406463730479"
184184
e[2] = big"3.641478498049213152712"
185185
e[3] = big"-1.252547721169118720491"
186186
e[4] = big"0.5920031671845428725662"

lib/OrdinaryDiffEqFIRK/test/ode_firk_tests.jl

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,57 +23,7 @@ for i in [3, 5, 7, 9], prob in [prob_ode_linear_big, prob_ode_2Dlinear_big]
2323
@test sim21.𝒪est[:final] (2 * i - 1) atol=testTol
2424
end
2525

26-
solve(prob_ode_linear, AdaptiveRadau(min_num_stages = 3, max_num_stages = 3))
27-
solve(prob_ode_linear, RadauIIA5())
28-
29-
using OrdinaryDiffEq, StaticArrays, LinearSolve, ParameterizedFunctions
30-
31-
hires = @ode_def Hires begin
32-
dy1 = -1.71 * y1 + 0.43 * y2 + 8.32 * y3 + 0.0007
33-
dy2 = 1.71 * y1 - 8.75 * y2
34-
dy3 = -10.03 * y3 + 0.43 * y4 + 0.035 * y5
35-
dy4 = 8.32 * y2 + 1.71 * y3 - 1.12 * y4
36-
dy5 = -1.745 * y5 + 0.43 * y6 + 0.43 * y7
37-
dy6 = -280.0 * y6 * y8 + 0.69 * y4 + 1.71 * y5 - 0.43 * y6 + 0.69 * y7
38-
dy7 = 280.0 * y6 * y8 - 1.81 * y7
39-
dy8 = -280.0 * y6 * y8 + 1.81 * y7
40-
end
41-
42-
u0 = SA[1, 0, 0, 0, 0, 0, 0, 0.0057]
43-
probiip = ODEProblem{true}(hires, Vector(u0), (0.0, 10.0))
44-
proboop = ODEProblem{false}(hires, Vector(u0), (0.0, 10.0))
45-
proboop = ODEProblem{false}(hires, u0, (0.0, 10.0))
46-
47-
#=@btime =# sol = solve(proboop, AdaptiveRadau(min_num_stages = 3, max_num_stages = 7), reltol = 1e-1)
48-
#=@btime =# sol = solve(proboop, RadauIIA5())
49-
50-
function rober!(du, u, p, t)
51-
y₁, y₂, y₃ = u
52-
k₁, k₂, k₃ = p
53-
du[1] = -k₁ * y₁ + k₃ * y₂ * y₃
54-
du[2] = k₁ * y₁ - k₂ * y₂^2 - k₃ * y₂ * y₃
55-
du[3] = k₂ * y₂^2
56-
nothing
57-
end
58-
prob = ODEProblem(rober!, [1.0, 0.0, 0.0], (0.0, 1e5), [0.04, 3e7, 1e4])
59-
sol = solve(prob, AdaptiveRadau(min_num_stages = 3, max_num_stages =7))
60-
sol2 = solve(prob, RadauIIA5())
61-
62-
using BenchmarkTools
63-
#oop
64-
@btime solve(prob_ode_linear, RadauIIA5(), adaptive = false, dt = 1e-2)
65-
@btime solve(prob_ode_linear, AdaptiveRadau(num_stages = 3), adaptive = false, dt = 1e-2)
66-
67-
#ip
68-
@btime solve(prob_ode_2Dlinear, RadauIIA5(), adaptive = false, dt = 1e-2)
69-
@btime solve(prob_ode_2Dlinear, AdaptiveRadau(num_stages = 3), adaptive = false, dt = 1e-2)
70-
71-
VSCodeServer.@profview solve(prob_ode_linear, AdaptiveRadau(num_stages = 3), adaptive = false, dt = 1e-5)
72-
VSCodeServer.@profview solve(prob_ode_linear, RadauIIA5(), adaptive = false, dt = 1e-5)
73-
74-
75-
solve(prob_ode_linear, AdaptiveRadau(num_stages = 3), adaptive = false, dt = 1e-2)
76-
26+
solve(prob_ode_2Dlinear, AdaptiveRadau())
7727

7828
# test adaptivity
7929
for iip in (true, false)

0 commit comments

Comments
 (0)