|
1 |
| -using MultivariateOrthogonalPolynomials, FastTransforms, BlockBandedMatrices, Plots |
| 1 | +using MultivariateOrthogonalPolynomials, FastTransforms, BlockBandedMatrices, Plots, LinearAlgebra, StaticArrays |
2 | 2 | plotly()
|
3 | 3 |
|
| 4 | + |
| 5 | +#### |
| 6 | +# Solving |
| 7 | +# |
| 8 | +# (Δ + k^2*I) * u = f |
| 9 | +# |
| 10 | +# in a unit disk |𝐱| ≤ 1, |
| 11 | +# using orthogonal polynomials (in x and y) in a disk |
| 12 | +# with the weight (1-|𝐱|^2) = (1-x^2-y^2) |
| 13 | +#### |
| 14 | + |
4 | 15 | Z = Zernike(1)
|
5 |
| -W = Weighted(Z) |
6 |
| -xy = axes(Z,1); x,y = first.(xy),last.(xy) |
| 16 | +W = Weighted(Z) # w*Z |
| 17 | +xy = axes(Z, 1); |
| 18 | +x, y = first.(xy), last.(xy); |
7 | 19 | Δ = Z \ (Laplacian(xy) * W)
|
8 |
| -S = Z \ W |
| 20 | +S = Z \ W # identity |
| 21 | + |
| 22 | + |
| 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 | + |
9 | 33 |
|
10 |
| -k = 2 |
11 |
| -f = @.(cos(x*exp(y))) |
12 |
| -F = factorize(Δ + k^2 * S) |
| 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 |
| 42 | +k = 20 |
| 43 | +f = @.(cos(x * exp(y))) |
13 | 44 | c = Z \ f
|
14 |
| -F \ c |
| 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) |
| 67 | + |
| 68 | +surface(u) |
| 69 | + |
| 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)])) |
| 75 | + |
| 76 | +Z \ (x .* Z) |
| 77 | + |
| 78 | + |
| 79 | + |
| 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*𝐮 |
| 85 | + |
| 86 | +P¹ = Jacobi(1, 1) |
| 87 | +W = Weighted(P¹) |
| 88 | +x = axes(W, 1) |
| 89 | +D = Derivative(x) |
| 90 | +-(D * W)' * (D * W) |
| 91 | +W'W |
15 | 92 |
|
16 |
| -u = W * ((Δ + k^2 * S) \ (Z \ f)) |
| 93 | +# p-FEM |
17 | 94 |
|
| 95 | +P = Legendre() |
| 96 | +u = P * [randn(5); zeros(∞)] |
| 97 | +u' * u |
18 | 98 |
|
| 99 | +T[0.1, 1:10] |
| 100 | +T'[1:10, 0.1] |
| 101 | +axes(T') |
19 | 102 |
|
0 commit comments