Skip to content

Commit 260b90d

Browse files
authored
Merge pull request #70 from SciML/myb/stability_ply
Optimize stability polynomial evaluation and add order star plots
2 parents 63fe683 + 766862d commit 260b90d

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
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.23.0"
4+
version = "2.24.0"
55

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

src/plotrecipes.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,21 @@ end
5353
errors,times
5454
end
5555

56-
@recipe function f(tab::ODERKTableau;dx=1/100,dy=1/100,xlim=[-6,1],ylim=[-5,5])
57-
x = xlim[1]:dx:xlim[2]
58-
y = ylim[1]:dy:ylim[2]
59-
f = (u,v)-> abs(stability_region(u+v*im,tab))<1
56+
@recipe function f(tab::ODERKTableau;dx=1/100,dy=1/100,order_star=false,embedded=false)
57+
xlims = get(plotattributes, :xlims, (-6,1))
58+
ylims = get(plotattributes, :ylims, (-5,5))
59+
x = xlims[1]:dx:xlims[2]
60+
y = ylims[1]:dy:ylims[2]
61+
62+
if order_star
63+
f = (u,v)-> abs(stability_region(u+v*im,tab; embedded=embedded)/exp(u+v*im)) < 1
64+
else
65+
f = (u,v)-> abs(stability_region(u+v*im,tab; embedded=embedded)) < 1
66+
end
6067
seriestype --> :contour
6168
fill --> true
62-
cbar --> false
69+
colorbar --> false
70+
seriescolor --> :grays
71+
aspect_ratio --> 1
6372
x,y,f
6473
end

src/tableau_info.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ Base.length(tab::ODERKTableau) = tab.stages
1212
Calculates the stability function from the tableau at `z`. Stable if <1.
1313
1414
```math
15-
r(z) = \\frac{\\det(I-zA+zeb^T)}{\\det(I-zA)}
15+
r(z) = 1 + z bᵀ(I - zA)⁻¹ 𝟙
1616
```
17+
where 𝟙 denotes a vector of ones.
1718
"""
18-
stability_region(z,tab::ODERKTableau) = det(Matrix{Float64}(I,tab.stages,tab.stages)- z*tab.A + z*ones(tab.stages)*tab.α')/det(Matrix{Float64}(I,tab.stages,tab.stages)-z*tab.A)
19+
function stability_region(z,tab::ODERKTableau; embedded=false)
20+
A, c = tab.A, tab.c
21+
b = embedded ? tab.αEEst : tab.α
22+
𝟙 = ones(eltype(A), length(b))
23+
stages = (I - z*A) \ 𝟙
24+
1 + z * (transpose(b) * stages)
25+
end
1926

2027
"""
2128
`stability_region(tab::ODERKTableau; initial_guess=-3.0)`

0 commit comments

Comments
 (0)