Skip to content

Commit 76afa67

Browse files
Merge pull request #149 from SciML/hr/imaginary_stability_interval
implement `imaginary_stability_interval`
2 parents b69281c + bdd167c commit 76afa67

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DiffEqDevTools"
22
uuid = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "2.45.1"
4+
version = "2.46.0"
55

66
[deps]
77
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"

src/DiffEqDevTools.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export test_convergence, analyticless_test_convergence, appxtrue!, appxtrue
4545
export get_sample_errors
4646

4747
#Tab Functions
48-
export stability_region, residual_order_condition, check_tableau
48+
export stability_region, residual_order_condition, check_tableau, imaginary_stability_interval
4949

5050
#Tableaus
5151
export deduce_Butcher_tableau

src/tableau_info.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ end
2727
`stability_region(tab::ODERKTableau; initial_guess=-3.0)`
2828
2929
Calculates the length of the stability region in the real axis.
30+
See also [`imaginary_stability_interval`](@ref).
3031
"""
3132
function stability_region(tab::ODERKTableau; initial_guess = -3.0, kw...)
3233
residual! = function (resid, x)
@@ -36,6 +37,24 @@ function stability_region(tab::ODERKTableau; initial_guess = -3.0, kw...)
3637
sol.zero[1]
3738
end
3839

40+
"""
41+
imaginary_stability_interval(tab::ODERKTableau;
42+
initial_guess = length(tab) - 1)
43+
44+
Calculates the length of the imaginary stability interval, i.e.,
45+
the size of the stability region on the imaginary axis.
46+
See also [`stability_region`](@ref).
47+
"""
48+
function imaginary_stability_interval(tab::ODERKTableau;
49+
initial_guess = length(tab) - one(eltype(tab.A)),
50+
kw...)
51+
residual! = function (resid, x)
52+
resid[1] = abs(stability_region(im * x[1], tab)) - 1
53+
end
54+
sol = nlsolve(residual!, [initial_guess]; kw...)
55+
sol.zero[1]
56+
end
57+
3958
function RootedTrees.residual_order_condition(tab::ODERKTableau, order::Int,
4059
reducer = nothing, mapper = x -> x^2;
4160
embedded = false)

test/stability_region_test.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ using DiffEqDevTools, Test
33
@test stability_region(constructDormandPrince6(), initial_guess = -3.5)-3.95413 rtol=1e-3
44
@test stability_region(constructTsitourasPapakostas6(), initial_guess = -3.5)-3.95413 rtol=1e-3
55
@test stability_region(constructRadauIIA5(), initial_guess = 12.0)11.84 rtol=1e-2
6+
7+
@test @inferred(imaginary_stability_interval(constructSSPRK33()))sqrt(3)
8+
@test @inferred(imaginary_stability_interval(constructSSPRK33(Float32)))sqrt(3.0f0)
9+
@test @inferred(imaginary_stability_interval(constructKutta3()))sqrt(3)
10+
@test @inferred(imaginary_stability_interval(constructKutta3(Float32)))sqrt(3.0f0)
11+
@test @inferred(imaginary_stability_interval(constructRK4()))2.8284271247

0 commit comments

Comments
 (0)