Skip to content

Commit fdae29a

Browse files
Merge pull request #6 from YingboMa/master
Add a method to compute the length of the stability region
2 parents 20814b3 + 3961559 commit fdae29a

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ RecipesBase 0.1.0
33
DiffEqBase 3.0.0
44
RecursiveArrayTools 0.4.0
55
DiffEqPDEBase 0.4.0
6+
NLsolve 0.14.1
67
DiffEqMonteCarlo
78
DiffEqNoiseProcess
89
Juno

src/tableau_info.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using NLsolve
12
"""
23
`Base.length(tab::ODERKTableau)`
34
@@ -15,3 +16,16 @@ r(z) = \\frac{\\det(I-zA+zeb^T)}{\\det(I-zA)}
1516
```
1617
"""
1718
stability_region(z,tab::ODERKTableau) = det(eye(tab.stages)- z*tab.A + z*ones(tab.stages)*tab.α')/det(eye(tab.stages)-z*tab.A)
19+
20+
"""
21+
`stability_region(tab::ODERKTableau; initial_guess=-3.0)`
22+
23+
Calculates the length of the stability region in the real axis.
24+
"""
25+
function stability_region(tab::ODERKTableau; initial_guess=-3.0)
26+
residual! = function (resid, x)
27+
resid[1] = abs(stability_region(x[1], tab)) - 1
28+
end
29+
sol = nlsolve(residual!, [initial_guess])
30+
sol.zero[1]
31+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ using Base.Test
77
@time @testset "Analyticless Convergence Tests" begin include("analyticless_convergence_tests.jl") end
88
@time @testset "ODE Tableau Convergence Tests" begin include("ode_tableau_convergence_tests.jl") end ## Windows 32-bit fails on Butcher62 convergence test
99
@time @testset "Analyticless Stochastic WP" begin include("analyticless_stochastic_wp.jl") end
10+
@time @testset "Stability Region Tests" begin include("stability_region_test.jl") end

test/stability_region_test.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using DiffEqDevTools, Base.Test
2+
3+
@test stability_region(constructDormandPrince6(), initial_guess=-3.5) -3.95413 rtol=1e-3
4+
@test stability_region(constructTsitourasPapakostas6(), initial_guess=-3.5) -3.95413 rtol=1e-3
5+
@test stability_region(constructRadauIIA5(), initial_guess=12.) 11.84 rtol=1e-2

0 commit comments

Comments
 (0)