Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 6484158

Browse files
committed
coverage tests for biased Upwind
1 parent fa0c34e commit 6484158

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

test/KdV.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,28 @@ using DiffEqOperators, OrdinaryDiffEq, LinearAlgebra
4141
@show maximum(soln(t)-ϕ(x,t))
4242
end
4343
=#
44+
for t in 0:0.5:5
45+
@test soln(t) ϕ(x,t) atol = 0.01;
46+
end
4447

48+
# Using Biased Upwinds with 1 offside pont
49+
A2 = UpwindDifference{Float64}(1,3,Δx,length(x),-1,offside=1);
50+
function KdV(du, u, p, t)
51+
bc = GeneralBC([0,1,-6*ϕ(-10,t),0,-1],[0,1,-6*ϕ(10,t),0,-1],Δx,3)
52+
mul!(du,A2,bc*u)
53+
end
54+
single_solition = ODEProblem(KdV, u0, (0.,5.));
55+
soln = solve(single_solition,Tsit5(),abstol=1e-6,reltol=1e-6);
56+
for t in 0:0.5:5
57+
@test soln(t) ϕ(x,t) atol = 0.01;
58+
end
59+
A3 = UpwindDifference{Float64}(1,3,Δx*ones(length(x)+1),length(x),-1,offside=1);
60+
function KdV(du, u, p, t)
61+
bc = GeneralBC([0,1,-6*ϕ(-10,t),0,-1],[0,1,-6*ϕ(10,t),0,-1],Δx,3)
62+
mul!(du,A3,bc*u)
63+
end
64+
single_solition = ODEProblem(KdV, u0, (0.,5.));
65+
soln = solve(single_solition,Tsit5(),abstol=1e-6,reltol=1e-6);
4566
for t in 0:0.5:5
4667
@test soln(t) ϕ(x,t) atol = 0.01;
4768
end

test/heat_eqn.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@ end
9292
end
9393

9494
# UpwindDifference with equal no. of primay wind and offside points should behave like a CenteredDifference
95-
A2 = UpwindDifference(2,1,dx,N,1,offside=1);
95+
A2 = UpwindDifference(2,1,dx*ones(513),N,1,offside=1);
96+
B2 = UpwindDifference(1,2,dx,N,1,offside=1)
97+
deriv_start, deriv_end = (B2*u0)[1], (B2*u0)[end]
98+
left_RBC = params[1]*u0[1] - params[2]*deriv_start
99+
right_RBC = params[1]*u0[end] + params[2]*deriv_end
100+
bc = RobinBC((params[1],-params[2],left_RBC), (params[1],params[2],right_RBC),dx,1);
101+
96102
step(u,p,t) = A2*bc*u
97103
heat_eqn = ODEProblem(step, u0, (0.,10.));
98104
soln = solve(heat_eqn,Tsit5(),dense=false,tstops=0:0.01:10);

0 commit comments

Comments
 (0)