Skip to content

Commit 24026eb

Browse files
committed
add test
1 parent fe43d9d commit 24026eb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/sde/sde_dynamical.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,43 @@ end
4545
sim1 = analyticless_test_convergence(dts,prob1,BAOAB(gamma=γ),(1/2)^10;trajectories=Int(1e2),use_noise_grid=false)
4646
@test abs(sim1.𝒪est[:weak_final]-1) < 0.3
4747
end
48+
49+
@testset "Scalar u, scale_noise=false" begin
50+
u0 = 0
51+
v0 = 1
52+
53+
ff_harmonic = DynamicalSDEFunction(f1_harmonic,f2_harmonic,g)
54+
prob1 = DynamicalSDEProblem(ff_harmonic,v0,u0,(0.0,5.0))
55+
56+
dts = (1/2) .^ (8:-1:4)
57+
58+
# Can't use NoiseGrid as noise is not generated with the correct size in convergence.jl. We require noise with shape of v.
59+
sim1 = analyticless_test_convergence(dts,prob1,BAOAB(gamma=γ,scale_noise=false),(1/2)^10;trajectories=Int(2e2),use_noise_grid=false)
60+
display(sim1.𝒪est)
61+
@test abs(sim1.𝒪est[:weak_final]-1) < 0.3
62+
end
63+
64+
@testset "Vector u, scale_noise=false" begin
65+
66+
u0 = zeros(2)
67+
v0 = ones(2)
68+
69+
f1_harmonic_iip(dv,v,u,p,t) = dv .= f1_harmonic(v,u,p,t)
70+
f2_harmonic_iip(du,v,u,p,t) = du .= f2_harmonic(v,u,p,t)
71+
g_iip(du,u,p,t) = du .= g(u,p,t)
72+
73+
ff_harmonic = DynamicalSDEFunction(f1_harmonic,f2_harmonic,g)
74+
prob1 = DynamicalSDEProblem(ff_harmonic,v0,u0,(0.0,5.0))
75+
sol1 = solve(prob1,BAOAB(gamma=γ,scale_noise=false);dt=1/10,save_noise=true)
76+
77+
prob2 = DynamicalSDEProblem(f1_harmonic_iip,f2_harmonic_iip,g_iip,v0,u0,(0.0,5.0); noise=NoiseWrapper(sol1.W))
78+
sol2 = solve(prob2,BAOAB(gamma=γ,scale_noise=false);dt=1/10)
79+
80+
@test sol1[:] sol2[:]
81+
82+
dts = (1/2) .^ (8:-1:4)
83+
84+
# Can't use NoiseGrid as noise is not generated with the correct size in convergence.jl. We require noise with shape of v.
85+
sim1 = analyticless_test_convergence(dts,prob1,BAOAB(gamma=γ,scale_noise=false),(1/2)^10;trajectories=Int(1e2),use_noise_grid=false)
86+
@test abs(sim1.𝒪est[:weak_final]-1) < 0.3
87+
end

0 commit comments

Comments
 (0)