Skip to content

Commit c069898

Browse files
renaming
1 parent afd385b commit c069898

File tree

2 files changed

+34
-58
lines changed

2 files changed

+34
-58
lines changed

lib/OrdinaryDiffEqFIRK/src/firk_caches.jl

Lines changed: 33 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -509,39 +509,27 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
509509

510510
max_order = alg.max_order
511511
min_order = alg.min_order
512-
max = (max_order - 1) ÷ 4 * 2 + 1
513-
min = (min_order - 1) ÷ 4 * 2 + 1
512+
max_stages = (max_order - 1) ÷ 4 * 2 + 1
513+
min_stages = (min_order - 1) ÷ 4 * 2 + 1
514514
if (alg.min_order < 5)
515515
error("min_order choice $min_order below 5 is not compatible with the algorithm")
516-
elseif (max < min)
516+
elseif (max_stages < min_stages)
517517
error("max_order $max_order is below min_order $min_order")
518518
end
519-
num_stages = min
519+
num_stages = min_stages
520520

521521
tabs = [RadauIIATableau5(uToltype, constvalue(tTypeNoUnits)), RadauIIATableau9(uToltype, constvalue(tTypeNoUnits)), RadauIIATableau13(uToltype, constvalue(tTypeNoUnits))]
522-
if (min == 3 || min == 5 || min == 7)
523-
i = 9
524-
else
525-
i = min
526-
end
527-
while i <= max
522+
i = max(min_stages, 9)
523+
while i <= max_stages
528524
push!(tabs, RadauIIATableau(uToltype, constvalue(tTypeNoUnits), i))
529525
i += 2
530526
end
531-
cont = Vector{typeof(u)}(undef, max)
532-
for i in 1:max
527+
cont = Vector{typeof(u)}(undef, max_stages)
528+
for i in 1:max_stages
533529
cont[i] = zero(u)
534530
end
535531

536-
if (min == 3)
537-
index = 1
538-
elseif (min == 5)
539-
index = 2
540-
elseif (min == 7)
541-
index = 3
542-
else
543-
index = 4
544-
end
532+
index = min((min_stages - 1) ÷ 2, 4)
545533

546534
κ = alg.κ !== nothing ? convert(uToltype, alg.κ) : convert(uToltype, 1 // 100)
547535
J = false .* _vec(rate_prototype) .* _vec(rate_prototype)'
@@ -605,70 +593,58 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
605593

606594
max_order = alg.max_order
607595
min_order = alg.min_order
608-
max = (max_order - 1) ÷ 4 * 2 + 1
609-
min = (min_order - 1) ÷ 4 * 2 + 1
596+
max_stages = (max_order - 1) ÷ 4 * 2 + 1
597+
min_stages = (min_order - 1) ÷ 4 * 2 + 1
610598
if (alg.min_order < 5)
611599
error("min_order choice $min_order below 5 is not compatible with the algorithm")
612-
elseif (max < min)
600+
elseif (max_stages < min_stages)
613601
error("max_order $max_order is below min_order $min_order")
614602
end
615-
num_stages = min
603+
num_stages = min_stages
616604

617605
tabs = [RadauIIATableau5(uToltype, constvalue(tTypeNoUnits)), RadauIIATableau9(uToltype, constvalue(tTypeNoUnits)), RadauIIATableau13(uToltype, constvalue(tTypeNoUnits))]
618-
if (min == 3 || min == 5 || min == 7)
619-
i = 9
620-
else
621-
i = min
622-
end
623-
while i <= max
606+
i = max(min_stages, 9)
607+
while i <= max_stages
624608
push!(tabs, RadauIIATableau(uToltype, constvalue(tTypeNoUnits), i))
625609
i += 2
626610
end
627611

628-
if (min == 3)
629-
index = 1
630-
elseif (min == 5)
631-
index = 2
632-
elseif (min == 7)
633-
index = 3
634-
else
635-
index = 4
636-
end
612+
index = min((min_stages - 1) ÷ 2, 4)
637613

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

640-
z = Vector{typeof(u)}(undef, max)
641-
w = Vector{typeof(u)}(undef, max)
642-
for i in 1 : max
616+
z = Vector{typeof(u)}(undef, max_stages)
617+
w = Vector{typeof(u)}(undef, max_stages)
618+
for i in 1 : max_stages
643619
z[i] = zero(u)
644620
w[i] = zero(u)
645621
end
646622

647-
αdt = [zero(t) for i in 1:max]
648-
βdt = [zero(t) for i in 1:max]
649-
c_prime = Vector{typeof(t)}(undef, max) #time stepping
650-
for i in 1 : max
623+
αdt = [zero(t) for i in 1:max_stages]
624+
βdt = [zero(t) for i in 1:max_stages]
625+
c_prime = Vector{typeof(t)}(undef, max_stages) #time stepping
626+
for i in 1 : max_stages
651627
c_prime[i] = zero(t)
652628
end
653629

654630
dw1 = zero(u)
655631
ubuff = zero(u)
656-
dw2 = [similar(u, Complex{eltype(u)}) for _ in 1 : (max - 1) ÷ 2]
632+
dw2 = [similar(u, Complex{eltype(u)}) for _ in 1 : (max_stages - 1) ÷ 2]
657633
recursivefill!.(dw2, false)
658-
cubuff = [similar(u, Complex{eltype(u)}) for _ in 1 : (max - 1) ÷ 2]
634+
cubuff = [similar(u, Complex{eltype(u)}) for _ in 1 : (max_stages - 1) ÷ 2]
659635
recursivefill!.(cubuff, false)
660-
dw = [zero(u) for i in 1 : max]
636+
dw = [zero(u) for i in 1:max_stages]
661637

662-
cont = [zero(u) for i in 1:max]
638+
cont = [zero(u) for i in 1:max_stages]
663639

664-
derivatives = Matrix{typeof(u)}(undef, max, max)
665-
for i in 1 : max, j in 1 : max
640+
derivatives = Matrix{typeof(u)}(undef, max_stages, max_stages)
641+
for i in 1 : max_stages, j in 1 : max_stages
666642
derivatives[i, j] = zero(u)
667643
end
668644

669645
fsalfirst = zero(rate_prototype)
670-
fw = [zero(rate_prototype) for i in 1 : max]
671-
ks = [zero(rate_prototype) for i in 1 : max]
646+
fw = [zero(rate_prototype) for i in 1 : max_stages]
647+
ks = [zero(rate_prototype) for i in 1 : max_stages]
672648

673649
k = ks[1]
674650

@@ -677,7 +653,7 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
677653
error("Non-concrete Jacobian not yet supported by AdaptiveRadau.")
678654
end
679655

680-
W2 = [similar(J, Complex{eltype(W1)}) for _ in 1 : (max - 1) ÷ 2]
656+
W2 = [similar(J, Complex{eltype(W1)}) for _ in 1 : (max_stages - 1) ÷ 2]
681657
recursivefill!.(W2, false)
682658

683659
du1 = zero(rate_prototype)
@@ -695,7 +671,7 @@ function alg_cache(alg::AdaptiveRadau, u, rate_prototype, ::Type{uEltypeNoUnits}
695671

696672
linsolve2 = [
697673
init(LinearProblem(W2[i], _vec(cubuff[i]); u0 = _vec(dw2[i])), alg.linsolve, alias_A = true, alias_b = true,
698-
assumptions = LinearSolve.OperatorAssumptions(true)) for i in 1 : (max - 1) ÷ 2]
674+
assumptions = LinearSolve.OperatorAssumptions(true)) for i in 1 : (max_stages - 1) ÷ 2]
699675

700676
rtol = reltol isa Number ? reltol : zero(reltol)
701677
atol = reltol isa Number ? reltol : zero(reltol)

lib/OrdinaryDiffEqFIRK/test/ode_high_order_firk_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ testTol = 0.5
77
prob_ode_linear_big = remake(prob_ode_linear, u0 = big.(prob_ode_linear.u0), tspan = big.(prob_ode_linear.tspan))
88
prob_ode_2Dlinear_big = remake(prob_ode_2Dlinear, u0 = big.(prob_ode_2Dlinear.u0), tspan = big.(prob_ode_2Dlinear.tspan))
99

10-
for i in [17, 21], prob in [prob_ode_linear_big, prob_ode_2Dlinear_big]
10+
for i in [17, 21, 25], prob in [prob_ode_linear_big, prob_ode_2Dlinear_big]
1111
dts = 1 ./ 2 .^ (4.25:-1:0.25)
1212
sim21 = test_convergence(dts, prob, AdaptiveRadau(min_order = i, max_order = i))
1313
@test sim21.𝒪est[:final] i atol=testTol

0 commit comments

Comments
 (0)