Skip to content

Commit cf0d0ba

Browse files
committed
Clean up disk hemholtz
1 parent d36576f commit cf0d0ba

File tree

2 files changed

+21
-66
lines changed

2 files changed

+21
-66
lines changed

examples/diskheat.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using MultivariateOrthogonalPolynomials, DifferentialEquations
2+
3+
Z = Zernike(1)
4+
W = Weighted(Z)
5+
xy = axes(W,1)
6+
Δ = Z \ Laplacian(xy) * W

examples/diskhelmholtz.jl

Lines changed: 15 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -20,83 +20,32 @@ x, y = first.(xy), last.(xy);
2020
S = Z \ W # identity
2121

2222

23-
f = @.(cos(x * exp(y)))
24-
25-
f[SVector(0.1, 0.2)]
26-
g = ((1 .- x .^ 2 .- y .^ 2) .* f)
27-
@time W \ g
28-
29-
Z \ g
30-
N = 100
31-
S[Block.(1:N), Block.(1:N)] * (W\g)[Block.(1:N)]
32-
33-
34-
# F = factorize(Δ + k^2 * S)
35-
# c = Z \ f
36-
# F \ c
37-
38-
# u = W * ((Δ + k^2 * S) \ (Z \ f))
39-
40-
41-
N = 20
4223
k = 20
24+
L = Δ + k^2 * S # discretisation of Helmholtz
4325
f = @.(cos(x * exp(y)))
44-
c = Z \ f
45-
𝐮 =+k^2*S)[Block.(1:N), Block.(1:N)] \ c[Block.(1:N)]
46-
u = W[:, Block.(1:N)] * 𝐮
47-
axes(u)
48-
49-
50-
= Z / Z \ u
51-
52-
= Z / Z \ u
53-
54-
= (Z / Z) \ u
55-
= inv(Z * inv(Z)) * u
56-
= Z * (inv(Z) * u)
57-
= Z * (Z \ u)
58-
# Z \ u means Find c s.t. Z*c == u
59-
60-
sum(ũ .* f)
61-
62-
W \ f
63-
64-
65-
sum(u .^ 2 * W \ f)
66-
norm(u)
6726

27+
u = W * (L \ (Z \ f))
6828
surface(u)
6929

70-
# Δ*u == λ*u
71-
# Z\Δ*W*𝐮 == λ*Z\W*𝐮
72-
# Δ*𝐮 == λ*S*𝐮
73-
Matrix(Δ[Block.(1:N), Block.(1:N)])
74-
eigvals(Matrix(Δ[Block.(1:N), Block.(1:N)]), Matrix(S[Block.(1:N), Block.(1:N)]))
7530

76-
Z \ (x .* Z)
31+
# One can also fix the discretisation size
7732

33+
N = 20
34+
Zₙ = Z[:,Block.(1:N)]
35+
Wₙ = W[:,Block.(1:N)]
36+
Lₙ = L[Block.(1:N),Block.(1:N)]
7837

38+
u = Wₙ * (Lₙ \ (Zₙ \ f))
39+
surface(u)
7940

80-
# u = (1-x^2) * P^(1,1) * 𝐮 = W * 𝐮
81-
# v = (1-x^2) * P^(1,1) * 𝐯 = W * 𝐯
82-
# -<D*v,D*u>
83-
# -(D*v)'(D*u) == -𝐯'*(D*W)'D*W*𝐮
84-
# <v,u> == 𝐯'*W'W*𝐮
8541

86-
= Jacobi(1, 1)
87-
W = Weighted(P¹)
88-
x = axes(W, 1)
89-
D = Derivative(x)
90-
-(D * W)' * (D * W)
91-
W'W
42+
# We can also do eigenvalues of the Laplacian
9243

93-
# p-FEM
44+
Δₙ = Δ[Block.(1:N),Block.(1:N)]
45+
Sₙ = S[Block.(1:N),Block.(1:N)]
9446

95-
P = Legendre()
96-
u = P * [randn(5); zeros(∞)]
97-
u' * u
47+
BandedMatrix(Δₙ)
9848

99-
T[0.1, 1:10]
100-
T'[1:10, 0.1]
101-
axes(T')
49+
λ,Q = eigen(Symmetric(Matrix(Δₙ)), Symmetric(Matrix(Sₙ)))
10250

51+
surface(Wₙ * Q[:,end])

0 commit comments

Comments
 (0)