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

Commit b6b39f6

Browse files
author
AndiMD
committed
Test Robin BC with complex function values
1 parent 0db40b7 commit b6b39f6

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/robin_complex.jl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
include("src/DiffEqOperators.jl")
2+
using .DiffEqOperators
3+
using LinearAlgebra, Random, Test
4+
5+
# Generate random parameters
6+
# Generate random parameters
7+
al = rand(ComplexF64,5)
8+
bl = rand(ComplexF64,5)
9+
cl = rand(ComplexF64,5)
10+
dx = rand(Float64,5)
11+
ar = rand(ComplexF64,5)
12+
br = rand(ComplexF64,5)
13+
cr = rand(ComplexF64,5)
14+
15+
# Construct 5 arbitrary RobinBC operators for each parameter set
16+
for i in 1:5
17+
18+
Q = RobinBC((al[i], bl[i], cl[i]), (ar[i], br[i], cr[i]), dx[i])
19+
20+
Q_L, Q_b = Array(Q,5i)
21+
22+
#Check that Q_L is is correctly computed
23+
@test Q_L[2:5i+1,1:5i] Array(I, 5i, 5i)
24+
@test Q_L[1,:] [1 / (1-al[i]*dx[i]/bl[i]); zeros(5i-1)]
25+
@test Q_L[5i+2,:] [zeros(5i-1); 1 / (1+ar[i]*dx[i]/br[i])]
26+
27+
#Check that Q_b is computed correctly
28+
@test Q_b [cl[i]/(al[i]-bl[i]/dx[i]); zeros(5i); cr[i]/(ar[i]+br[i]/dx[i])]
29+
30+
# Construct the extended operator and check that it correctly extends u to a (5i+2)
31+
# vector, along with encoding boundary condition information.
32+
u = rand(ComplexF64,5i)
33+
34+
Qextended = Q*u
35+
CorrectQextended = [(cl[i]-(bl[i]/dx[i])*u[1])/(al[i]-bl[i]/dx[i]); u; (cr[i]+ (br[i]/dx[i])*u[5i])/(ar[i]+br[i]/dx[i])]
36+
@test length(Qextended) 5i+2
37+
38+
# Check concretization
39+
@test Array(Qextended) CorrectQextended # Q.a_l ⋅ u[1:length(Q.a_l)] + Q.b_l, Q.a_r ⋅ u[(end-length(Q.a_r)+1):end] + Q.b_r
40+
41+
# Check that Q_L and Q_b correctly compute BoundaryPaddedVector
42+
@test Q_L*u + Q_b CorrectQextended
43+
44+
@test [Qextended[1]; Qextended.u; Qextended[5i+2]] CorrectQextended
45+
46+
end

0 commit comments

Comments
 (0)