Skip to content

Conversion from ZernikeAnnulus to Bubble #4

Open
@ioannisPApapadopoulos

Description

@ioannisPApapadopoulos

@dlfivefifty The conversion from ZernikeAnnulus to the hats+bubble on one element becomes increasingly ill-conditioned as m (the Fourier mode) gets larger. This is true for either of the ZernikeAnnulus(0,0) or ZernikeAnnulus(1,1) routes.

This is alleviated is we instead do a least squares solve to find the coefficients in hats+bubble (include an extra 2 columns in the ZernikeAnnulus(0,0) case or 4 columns in the ZernikeAnnulus(1,1) case).

Do you see an easy way around this? Should we just do least square solves for the coefficients for now? I've attached a snippet to show the difference in the ZernikeAnnulus(0,0) route.

using AlgebraicCurveOrthogonalPolynomials, SemiclassicalOrthogonalPolynomials, LinearAlgebra

# Function to expand in annulus with radius ρ = 0.5
ρ = 0.5
c1 = -400; c2 = 0; c3=0.6
function ua(xy)
    x,y = first(xy), last(xy)
    exp(c1*(x^2 + (y-c3)^2)) * (1-(x^2+y^2)) * ((x^2+y^2)-ρ^2)
end

function ann002element(t::T, m::Int) where T

    Q₀₀ = SemiclassicalJacobi{T}(t, 0, 0, m)
    Q₀₁ = SemiclassicalJacobi{T}(t, 0, 1, m)
    Q₁₀ = SemiclassicalJacobi{T}(t, 1, 0, m)
    Q₁₁ = SemiclassicalJacobi{T}(t, 1, 1, m)

    L₁₁ = (Weighted(Q₀₀) \ Weighted(Q₁₁)) / t^2
    L₀₁ = (Weighted(Q₀₀) \ Weighted(Q₀₁)) / t
    L₁₀ = (Weighted(Q₀₀) \ Weighted(Q₁₀)) / t

    (L₁₁, L₀₁, L₁₀)
end

Z = ZernikeAnnulus(ρ,0,0)
fz = Z[:, Block.(1:40)] \ ua.(axes(Z,1))

# Look at the conversion of column 38
b = 38;
c = ModalTrav(fz).matrix[:,b]
N = length(c)

# Form conversion matrix from ZernikeAnnulus(ρ,0,0) to hats+bubble
t = inv(one(T)-ρ^2)
(L₁₁, L₀₁, L₁₀) = ann002element(t, b÷2);
R = [L₁₀[:,1] L₀₁[:,1] L₁₁]

# Do the conversion via a direct solve
dat = R[1:N,1:N] \ c
norm(c, Inf), norm(dat, Inf) # Big coefficients relative to original expansions, eugh..
# (0.0012030351196273754, 271.66452286973276)

# Go via a least squares solve
dat = Matrix(R[1:N,1:N+2]) \ c
norm(c, Inf), norm(dat, Inf) # Much better coefficients
# (0.0012030351196273754, 0.024122418305535603)
norm(R[1:N,1:N+2]*dat-c) # machine error
# 1.2575586067638361e-18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions