Skip to content

Commit

Permalink
weak convergence
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Nov 24, 2016
1 parent e176384 commit ec8f194
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 5 deletions.
7 changes: 4 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ using StochasticDiffEq, DiffEqDevTools, DiffEqProblemLibrary
using Base.Test

const TEST_PLOT = false

const LONGER_TESTS = false
#SDE
@time @testset "Linear SDE Tests" begin include("sde/sde_linear_tests.jl") end
@time @testset "Two-dimensional Linear SDE Tests" begin include("sde/sde_twodimlinear_tests.jl") end
@time @testset "Additive SDE Tests" begin include("sde/sde_additive_tests.jl") end
@time @testset "Rossler Order Tests" begin include("sde/sde_rosslerorder_tests.jl") end
@time @testset "SDE Convergence Tests" begin include("sde/sde_convergence_tests.jl") end
@time @testset "SDE Number Type Tests" begin include("sde/sde_numbertype_tests.jl") end
@time @testset "Convergence Tests" begin include("sde/sde_convergence_tests.jl") end
LONGER_TESTS && @time @testset "Weak Convergence Tests" begin include("weak_convergence.jl") end
@time @testset "Number Type Tests" begin include("sde/sde_numbertype_tests.jl") end
@time @testset "Oval2" begin include("oval2_test.jl") end

#Adaptive SDE
Expand Down
2 changes: 1 addition & 1 deletion test/sde/sde_convergence_tests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@everywhere using StochasticDiffEq, DiffEqProblemLibrary, DiffEqDevTools
srand(100)
dts = 1./2.^(10:-1:4) #14->7 good plot
dts = 1./2.^(10:-1:2) #14->7 good plot

prob = prob_sde_wave
sim = test_convergence(dts,prob,EM(),numMonte=Int(1e1))
Expand Down
3 changes: 2 additions & 1 deletion test/sde/sde_twodimlinear_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ sol = solve(prob,SRIW1(),dt=1/2^(3),progress=true,progress_steps=1)
#Now do the simulation 5 times in parallel. Return an array
solArr = monte_carlo_simulation(prob,SRIW1(),dt=1//2^(3),numMonte=5)

TEST_PLOT && plot(sol,plot_analytic=true)
#TEST_PLOT && plot(sol,plot_analytic=true)

## Convergence Testing
println("Convergence Test on 2D Linear")
dts = 1./2.^(7:-1:4) #14->7 good plot

sim = test_convergence(dts,prob,EM(),numMonte=10)

@test abs(sim.𝒪est[:l2]-.5) < 0.1

sim2 = test_convergence(dts,prob,RKMil(),numMonte=10)
Expand Down
65 changes: 65 additions & 0 deletions test/weak_convergence.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@everywhere using StochasticDiffEq, DiffEqProblemLibrary, DiffEqDevTools, Base.Test
srand(100)
dts = 1./2.^(10:-1:2) #14->7 good plot

prob = prob_sde_linear
sim = test_convergence(dts,prob,EM(),numMonte=Int(1e4))
@test abs(sim.𝒪est[:weak_final]-1) < 0.3
@test abs(sim.𝒪est[:weak_l2]-1) < 0.3
@test abs(sim.𝒪est[:weak_l∞]-1) < 0.3
sim2 = test_convergence(dts,prob,RKMil(),numMonte=Int(1e4))
@test abs(sim2.𝒪est[:weak_final]-1) < 0.3
@test abs(sim2.𝒪est[:weak_l2]-1) < 0.3
@test abs(sim2.𝒪est[:weak_l∞]-1) < 0.3
sim3 = test_convergence(dts,prob,SRI(),numMonte=Int(1e4))
@test abs(sim3.𝒪est[:weak_final]-2) < 0.3
@test abs(sim3.𝒪est[:weak_l2]-2) < 0.3
@test abs(sim3.𝒪est[:weak_l∞]-2) < 0.3
sim4 = test_convergence(dts,prob,SRIW1(),numMonte=Int(1e4))
@test abs(sim4.𝒪est[:weak_final]-2) < 0.3
@test abs(sim4.𝒪est[:weak_l2]-2) < 0.3
@test abs(sim4.𝒪est[:weak_l∞]-2) < 0.3

prob = prob_sde_2Dlinear
sim = test_convergence(dts,prob,EM(),numMonte=Int(1e4))
@test abs(sim.𝒪est[:weak_final]-1) < 0.3
@test abs(sim.𝒪est[:weak_l2]-1) < 0.3
@test abs(sim.𝒪est[:weak_l∞]-1) < 0.3
sim2 = test_convergence(dts,prob,RKMil(),numMonte=Int(1e4))
@test abs(sim2.𝒪est[:weak_final]-1) < 0.3
@test abs(sim2.𝒪est[:weak_l2]-1) < 0.3
@test abs(sim2.𝒪est[:weak_l∞]-1) < 0.3
sim3 = test_convergence(dts,prob,SRI(),numMonte=Int(1e4))
@test abs(sim3.𝒪est[:weak_final]-2) < 0.3
@test abs(sim3.𝒪est[:weak_l2]-2) < 0.3
@test abs(sim3.𝒪est[:weak_l∞]-2) < 0.3
sim4 = test_convergence(dts,prob,SRIW1(),numMonte=Int(1e4))
@test abs(sim4.𝒪est[:weak_final]-2) < 0.3
@test abs(sim4.𝒪est[:weak_l2]-2) < 0.3
@test abs(sim4.𝒪est[:weak_l∞]-2) < 0.35

prob = prob_sde_additive
sim = test_convergence(dts,prob,EM(),numMonte=Int(1e4))
@test abs(sim.𝒪est[:weak_final]-1) < 0.3
@test abs(sim.𝒪est[:weak_l2]-1) < 0.3
@test abs(sim.𝒪est[:weak_l∞]-1) < 0.3
sim2 = test_convergence(dts,prob,RKMil(),numMonte=Int(1e4))
@test abs(sim2.𝒪est[:weak_final]-1) < 0.3
@test abs(sim2.𝒪est[:weak_l2]-1) < 0.3
@test abs(sim2.𝒪est[:weak_l∞]-1) < 0.3
sim3 = test_convergence(dts,prob,SRI(),numMonte=Int(1e4))
@test abs(sim3.𝒪est[:weak_final]-2) < 0.3
@test abs(sim3.𝒪est[:weak_l2]-2) < 0.3
@test abs(sim3.𝒪est[:weak_l∞]-2) < 0.3
sim4 = test_convergence(dts,prob,SRIW1(),numMonte=Int(1e4))
@test abs(sim4.𝒪est[:weak_final]-2) < 0.3
@test abs(sim4.𝒪est[:weak_l2]-2) < 0.3
@test abs(sim4.𝒪est[:weak_l∞]-2) < 0.35
sim5 = test_convergence(dts,prob,SRA(),numMonte=Int(1e4))
@test abs(sim5.𝒪est[:weak_final]-2) < 0.3
@test abs(sim5.𝒪est[:weak_l2]-2) < 0.3
@test abs(sim5.𝒪est[:weak_l∞]-2) < 0.3
sim6 = test_convergence(dts,prob,SRA1(),numMonte=Int(1e4))
@test abs(sim6.𝒪est[:weak_final]-2) < 0.3
@test abs(sim6.𝒪est[:weak_l2]-2) < 0.3
@test abs(sim6.𝒪est[:weak_l∞]-2) < 0.3

0 comments on commit ec8f194

Please sign in to comment.