-
Notifications
You must be signed in to change notification settings - Fork 5
Fractional Laplacian for generalized Zernike Disk polynomials #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Might be a good time to discuss what we want the syntax to look like for this object @dlfivefifty. At the moment I just have FractionalLaplacian(β) to represent (-Δ)^(β) acting on (1-r^2)^β * Zernike(β). |
Codecov Report
@@ Coverage Diff @@
## master #73 +/- ##
==========================================
+ Coverage 94.73% 94.81% +0.07%
==========================================
Files 2 3 +1
Lines 456 482 +26
==========================================
+ Hits 432 457 +25
- Misses 24 25 +1
Continue to review full report at Codecov.
|
I would say we support either Maybe add struct AbsLaplacianPower{T,D,A} <: LazyQuasiMatrix{T}
axis::Inclusion{T,D}
α::A
end
AbsLaplacianPower{T}(axis::Inclusion{<:Any,D},α) where {T,D} = Laplacian{T,D,typeof(α)}(axis,α)
axes(D:: AbsLaplacianPower) = (D.axis, D.axis)
==(a:: AbsLaplacianPower, b:: AbsLaplacianPower) = a.axis == b.axis && a.α == b.α
copy(D:: AbsLaplacianPower) = AbsLaplacianPower(copy(D.axis), D.α)
abs(Δ::Laplacian) = AbsLaplacianPower(Δ,1)
-(Δ::Laplacian) = abs(Δ)
^(D::AbsLaplacianPower, k) = AbsLaplacianPower(D.axis, D.α*k) Probably add it here https://github.com/JuliaApproximation/HarmonicOrthogonalPolynomials.jl/blob/master/src/laplace.jl |
@dlfivefifty Okay, I think this is basically doing everything I wanted now. Fractional Laplacians and fractional Poisson equation on disk work and pass various explicit solution tests. This is based on results in https://link.springer.com/article/10.1007%2Fs00365-016-9336-4 and similar ideas seem to have been explored before for spectral methods, see e.g. https://arxiv.org/abs/1812.08325. We can now adaptively do all of the stuff in that paper in 2D and it would be easy to adapt for arbitrary dimensions if we had the OPs set up for that. I was thinking we could do nice surface plots for the fractional Poisson equation but plotting Zernike and weighted Zernike via surface() seems broken? Is disk plotting functional yet and do we have a minimal working example somewhere? |
Plotting should work with |
Yes but it seems I can only get it to plot things in Zernike basis, but get errors for weighted bases. Are weighted bases also meant to be working? julia> using MultivariateOrthogonalPolynomials, InfiniteArrays, Plots
julia> plotly()
julia> Z = Zernike(1)
Zernike{Float64}
julia> W = Weighted(Z)
Weighted(Zernike{Float64})
julia> u = Z*Vcat(1,zeros(∞))
Zernike{Float64} * [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 … ]
julia> w = W*Vcat(1,zeros(∞))
Weighted(Zernike{Float64}) * [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 … ]
julia> surface(u) # this works as expected
julia> surface(w)
ERROR: LoadError: Overload Grid
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] _grid(#unused#::ContinuumArrays.BasisLayout, P::Zernike{Float64})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/bases/bases.jl:124
[3] grid(P::Zernike{Float64})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/bases/bases.jl:129
[4] _grid(#unused#::ContinuumArrays.SubBasisLayout, P::QuasiArrays.SubQuasiArray{Float64, 2, Zernike{Float64}, Tuple{QuasiArrays.Inclusion{StaticArrays.SVector{2, Float64}, DomainSets.FixedUnitBall{StaticArrays.SVector{2, Float64}, :closed}}, UnitRange{Int64}}, false})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/bases/bases.jl:127
[5] grid(P::QuasiArrays.SubQuasiArray{Float64, 2, Zernike{Float64}, Tuple{QuasiArrays.Inclusion{StaticArrays.SVector{2, Float64}, DomainSets.FixedUnitBall{StaticArrays.SVector{2, Float64}, :closed}}, UnitRange{Int64}}, false})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/bases/bases.jl:129
[6] _grid(#unused#::ContinuumArrays.SubWeightedBasisLayout, P::QuasiArrays.SubQuasiArray{Float64, 2, Weighted{Float64, Zernike{Float64}}, Tuple{QuasiArrays.Inclusion{StaticArrays.SVector{2, Float64}, DomainSets.FixedUnitBall{StaticArrays.SVector{2, Float64}, :closed}}, UnitRange{Int64}}, false})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/bases/bases.jl:128
[7] grid(P::QuasiArrays.SubQuasiArray{Float64, 2, Weighted{Float64, Zernike{Float64}}, Tuple{QuasiArrays.Inclusion{StaticArrays.SVector{2, Float64}, DomainSets.FixedUnitBall{StaticArrays.SVector{2, Float64}, :closed}}, UnitRange{Int64}}, false})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/bases/bases.jl:129
[8] _plotgrid(#unused#::ContinuumArrays.SubWeightedBasisLayout, P::QuasiArrays.SubQuasiArray{Float64, 2, Weighted{Float64, Zernike{Float64}}, Tuple{QuasiArrays.Inclusion{StaticArrays.SVector{2, Float64}, DomainSets.FixedUnitBall{StaticArrays.SVector{2, Float64}, :closed}}, UnitRange{Int64}}, false})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/plotting.jl:11
[9] plotgrid(g::QuasiArrays.SubQuasiArray{Float64, 2, Weighted{Float64, Zernike{Float64}}, Tuple{QuasiArrays.Inclusion{StaticArrays.SVector{2, Float64}, DomainSets.FixedUnitBall{StaticArrays.SVector{2, Float64}, :closed}}, UnitRange{Int64}}, false})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/plotting.jl:13
[10] _mul_plotgrid(#unused#::Tuple{ContinuumArrays.WeightedBasisLayout, LazyArrays.PaddedLayout{LazyArrays.ApplyLayout{typeof(vcat)}}}, ::Tuple{Weighted{Float64, Zernike{Float64}}, LazyArrays.ApplyArray{Float64, 1, typeof(vcat), Tuple{Int64, LazyArrays.CachedArray{Float64, 1, Vector{Float64}, Zeros{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}}}}})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/plotting.jl:4
[11] _plotgrid(lay::LazyArrays.ApplyLayout{typeof(*)}, P::QuasiArrays.ApplyQuasiVector{Float64, typeof(*), Tuple{Weighted{Float64, Zernike{Float64}}, LazyArrays.ApplyArray{Float64, 1, typeof(vcat), Tuple{Int64, LazyArrays.CachedArray{Float64, 1, Vector{Float64}, Zeros{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}}}}}})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/plotting.jl:8
[12] plotgrid(g::QuasiArrays.ApplyQuasiVector{Float64, typeof(*), Tuple{Weighted{Float64, Zernike{Float64}}, LazyArrays.ApplyArray{Float64, 1, typeof(vcat), Tuple{Int64, LazyArrays.CachedArray{Float64, 1, Vector{Float64}, Zeros{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}}}}}})
@ ContinuumArrays ~/.julia/packages/ContinuumArrays/6hwP3/src/plotting.jl:13
[13] macro expansion
@ ~/.julia/packages/ContinuumArrays/6hwP3/src/plotting.jl:19 [inlined]
[14] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, g::QuasiArrays.AbstractQuasiVector{T} where T)
@ ContinuumArrays ~/.julia/packages/RecipesBase/92zOw/src/RecipesBase.jl:282
[15] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline ~/.julia/packages/RecipesPipeline/CirY4/src/user_recipe.jl:36
[16] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline ~/.julia/packages/RecipesPipeline/CirY4/src/RecipesPipeline.jl:70
[17] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
@ Plots ~/.julia/packages/Plots/vVVub/src/plot.jl:172
[18] plot(args::Any; kw::Any)
@ Plots ~/.julia/packages/Plots/vVVub/src/plot.jl:58
[19] surface(args::Any; kw::Any)
@ Plots ~/.julia/packages/RecipesBase/92zOw/src/RecipesBase.jl:403
[20] surface(args::Any)
@ Plots ~/.julia/packages/RecipesBase/92zOw/src/RecipesBase.jl:403
[21] top-level scope
@ ~/Documents/Projects/MultivariateOrthogonalPolynomials.jl/examples/diskfractionalpoisson.jl:92
|
Ah yes that's a missing feature...probably need to add to ContinuumArrays.jl/src/plotting.jl something like _plotgrid(::WeightedBasisLayouts, wP) = plotgrid(unweightedbasis(wP)) Do you feel like trying to make that change and see if it works? (We do need to add some more features to get plotting to take advantage of fast transforms but that I can wait.) |
Yes, I'll have a look! 👍 I'm curious to see a bit of the plotting backend, haven't had too much of a reason to look into it before. |
It’s very simple like 10 lines |
A lot simpler than I thought it would be. And yes it looks like that works. I'll do some more tests and then add a PR to ContinuumArrays.jl. |
With JuliaApproximation/ContinuumArrays.jl#96 we can now also do some nice plots for the fractional Poisson equation on the disk. |
Starting work on fractional Laplacian here. Should also include an example file for fractional Poisson by the time this is done.