Skip to content

Commit d11faed

Browse files
small tweaks
1 parent 3a77668 commit d11faed

File tree

4 files changed

+38
-34
lines changed

4 files changed

+38
-34
lines changed

src/algorithms.jl

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,8 +1724,8 @@ publisher={Elsevier}
17241724
RadauIIA7: Fully-Implicit Runge-Kutta Method
17251725
An A-B-L stable fully implicit Runge-Kutta method with internal tableau complex basis transform for efficiency.
17261726
"""
1727-
struct RadauIIA7{CS, AD, F, P, FDT, ST, CJ, Tol, C1, C2} <:
1728-
OrdinaryDiffEqNewtonAdaptiveAlgorithm{CS, AD, FDT, ST, CJ}
1727+
struct RadauIIA7{CS, AD, F, P, FDT, ST, CJ, Tol, C1, C2, StepLimiter} <:
1728+
OrdinaryDiffEqNewtonAdaptiveAlgorithm{CS, AD, FDT, ST, CJ}
17291729
linsolve::F
17301730
precs::P
17311731
smooth_est::Bool
@@ -1735,26 +1735,30 @@ struct RadauIIA7{CS, AD, F, P, FDT, ST, CJ, Tol, C1, C2} <:
17351735
fast_convergence_cutoff::C1
17361736
new_W_γdt_cutoff::C2
17371737
controller::Symbol
1738+
step_limiter!::StepLimiter
17381739
end
17391740

17401741
function RadauIIA7(; chunk_size = Val{0}(), autodiff = Val{true}(),
1741-
standardtag = Val{true}(), concrete_jac = nothing,
1742-
diff_type = Val{:forward},
1743-
linsolve = nothing, precs = DEFAULT_PRECS,
1744-
extrapolant = :dense, fast_convergence_cutoff = 1 // 5,
1745-
new_W_γdt_cutoff = 1 // 5,
1746-
controller = :Predictive, κ = nothing, maxiters = 10, smooth_est = true)
1747-
RadauIIA7{_unwrap_val(chunk_size), _unwrap_val(autodiff), typeof(linsolve),
1748-
typeof(precs), diff_type, _unwrap_val(standardtag), _unwrap_val(concrete_jac),
1749-
typeof(κ), typeof(fast_convergence_cutoff), typeof(new_W_γdt_cutoff)}(linsolve,
1750-
precs,
1751-
smooth_est,
1752-
extrapolant,
1753-
κ,
1754-
maxiters,
1755-
fast_convergence_cutoff,
1756-
new_W_γdt_cutoff,
1757-
controller)
1742+
standardtag = Val{true}(), concrete_jac = nothing,
1743+
diff_type = Val{:forward},
1744+
linsolve = nothing, precs = DEFAULT_PRECS,
1745+
extrapolant = :dense, fast_convergence_cutoff = 1 // 5,
1746+
new_W_γdt_cutoff = 1 // 5,
1747+
controller = :Predictive, κ = nothing, maxiters = 10, smooth_est = true,
1748+
step_limiter! = trivial_limiter!)
1749+
RadauIIA7{_unwrap_val(chunk_size), _unwrap_val(autodiff), typeof(linsolve),
1750+
typeof(precs), diff_type, _unwrap_val(standardtag), _unwrap_val(concrete_jac),
1751+
typeof(κ), typeof(fast_convergence_cutoff),
1752+
typeof(new_W_γdt_cutoff), typeof(step_limiter!)}(linsolve,
1753+
precs,
1754+
smooth_est,
1755+
extrapolant,
1756+
κ,
1757+
maxiters,
1758+
fast_convergence_cutoff,
1759+
new_W_γdt_cutoff,
1760+
controller,
1761+
step_limiter!)
17581762
end
17591763
TruncatedStacktraces.@truncate_stacktrace RadauIIA7
17601764

src/caches/firk_caches.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ uf = UDerivativeWrapper(f, t, p)
299299
uToltype = constvalue(uBottomEltypeNoUnits)
300300
tab = RadauIIA7Tableau(uToltype, constvalue(tTypeNoUnits))
301301

302-
κ = convert(uToltype, 1 // 100)
302+
κ = alg.κ !== nothing ? convert(uToltype, alg.κ) : convert(uToltype, 1 // 100)
303303
J = false .* _vec(rate_prototype) .* _vec(rate_prototype)'
304304

305305
RadauIIA7ConstantCache(uf, tab, κ, one(uToltype), 10000, u, u, u, u, dt, dt,

src/integrators/controllers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ end
397397
if alg isa Union{RKC, IRKC, SERK2}
398398
fac = gamma
399399
else
400-
if alg isa Union{RadauIIA3, RadauIIA5}
400+
if alg isa Union{RadauIIA3, RadauIIA5, RadauIIA7}
401401
@unpack iter = integrator.cache
402402
@unpack maxiters = alg
403403
else

src/perform_step/firk_perform_step.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,8 @@ end
788788
@unpack maxiters = alg
789789
mass_matrix = integrator.f.mass_matrix
790790

791-
# precalculations
792-
rtol = @.. broadcast=false reltol^(2 / 3)/10
791+
# precalculations rtol pow is (num stages + 1)/(2*num stages)
792+
rtol = @.. broadcast=false reltol#^(5/8)/10
793793
atol = @.. broadcast=false rtol*(abstol / reltol)
794794
c1m1 = c1 - 1
795795
c2m1 = c2 - 1
@@ -927,7 +927,7 @@ end
927927
z2 = @.. broadcast=false T21*w1 + T22*w2 + T23*w3 + T24*w4 + T25*w5
928928
z3 = @.. broadcast=false T31*w1 + T32*w2 + T33*w3 + T34*w4 + T35*w5
929929
z4 = @.. broadcast=false T41*w1 + T42*w2 + T43*w3 + T44*w4 + T45*w5
930-
z5 = @.. broadcast=false T51*w1 + w2 + w4 #= T52=1, T53 = 0, T54 = 1, T55 = 0=#
930+
z5 = @.. broadcast=false T51*w1 + w2 + w4 #= T52=1, T53=0, T54=1, T55=0 =#
931931

932932
# check stopping criterion
933933
iter > 1 &&= θ / (1 - θ))
@@ -974,16 +974,16 @@ end
974974
if integrator.EEst <= oneunit(integrator.EEst)
975975
cache.dtprev = dt
976976
if alg.extrapolant != :constant
977-
cache.cont1 = @.. broadcast=false (z4 - z5) / c4m1 # first derivative on [c4, 1]
978-
tmp1 = @.. broadcast=false (z3 - z4) / c3mc4 # first derivative on [c3, c4]
979-
cache.cont2 = @.. broadcast=false (tmp1 - cache.cont1) / c3m1 # second derivative on [c3, 1]
980-
tmp2 = @.. broadcast=false (z2 - z3) / c2mc3 # first derivative on [c2, c3]
981-
tmp3 = @.. broadcast=false (tmp2 - tmp1) / c2mc4 # second derivative on [c2, c4]
982-
cache.cont3 = @.. broadcast=false (tmp3 - cache.cont2) / c2m1 # third derivative on [c2, 1]
983-
tmp4 = @.. broadcast=false (z1 - z2) / c1mc2 # first derivative on [c1, c2]
984-
tmp5 = @.. broadcast=false (tmp4 - tmp2) / c1mc3 # second derivative on [c1, c3]
985-
tmp6 = @.. broadcast=false (tmp5 - tmp3) / c1mc4 # third derivative on [c1, c4]
986-
cache.cont4 = @.. broadcast=false (tmp6 - cache.cont3) / c1m1 #fourth derivative on [c1, 1]
977+
cache.cont1 = @.. (z4 - z5) / c4m1 # first derivative on [c4, 1]
978+
tmp1 = @.. (z3 - z4) / c3mc4 # first derivative on [c3, c4]
979+
cache.cont2 = @.. (tmp1 - cache.cont1) / c3m1 # second derivative on [c3, 1]
980+
tmp2 = @.. (z2 - z3) / c2mc3 # first derivative on [c2, c3]
981+
tmp3 = @.. (tmp2 - tmp1) / c2mc4 # second derivative on [c2, c4]
982+
cache.cont3 = @.. (tmp3 - cache.cont2) / c2m1 # third derivative on [c2, 1]
983+
tmp4 = @.. (z1 - z2) / c1mc2 # first derivative on [c1, c2]
984+
tmp5 = @.. (tmp4 - tmp2) / c1mc3 # second derivative on [c1, c3]
985+
tmp6 = @.. (tmp5 - tmp3) / c1mc4 # third derivative on [c1, c4]
986+
cache.cont4 = @.. (tmp6 - cache.cont3) / c1m1 #fourth derivative on [c1, 1]
987987
end
988988
end
989989

0 commit comments

Comments
 (0)