CalculustJL / NodalPolynomialSpaces.jl

Largrange polynomial based spectral PDE solvers
MIT License
1 stars 0 forks source link

nonlinearity, other quadratures #4

Open AshtonSBradley opened 1 year ago

AshtonSBradley commented 1 year ago

Hi @vpuri3 I am interested in this project and also

quadratures, and how nonlinear terms are handled. In particular there is a body of work in ultra-cold gases that uses quadrature methods for solving the Gross-Pitaevskii equation, damped Gross-Pitaevskii equation, and stochastic projected Gross-Pitaevskii equation. (e.g. Appendix A of https://www.tandfonline.com/doi/full/10.1080/00018730802564254)

The standard 2/3 rule for Fourier anti-aliasing the GPE has a version for these quadrature methods (a bit more to the implementation, but the concept is related). The right modes also provide a good basis for open systems theories and noise. There are various implementations around but nothing very flexible or general ...

So I am curious as to whether you would see this kind of thing as relevant for this package?

vpuri3 commented 1 year ago

Hi Ashton,

Gauss-Hermite and Gauss-Laguerre weren't on the horizon because I was interested in finite domain problems. But I'm happy to add them to the list if you are willing to help build out that functionality.

We need to overload the function CalculustCore.transform(:: AbstractSpace) like we did in FourierSpaces.jl so we can smoothly transform between nodal (physical) and modal spaces. It is simply a matrix-vector product, and corresponds to the FFTs for Chebyshev.

You should also look at projects like ApproxFun.jl, ClassicalOrthogonalPolynomials.jl.

This should be fun. Looking forward to working with you

AshtonSBradley commented 1 year ago

ok interesting. I am interested in this project because this is the first time it seems to hit the right level of tooling to be generally useful. I know ApproxFun a little bit. Its great at what it aims to do, but doesnt seem very practical for large scale 3D simulations.

Regarding the nonlinearity, for fourier methods the projection integrals have trivial weight, so there is no weight transformation required. For e.g. Gauss-Hermite, there is a weight transformation to make sure the integrals are computed over the correct weight (exp(-x^2) for GH). Wondering if you have come across a version of this in other polynomial spaces?

I think I have a bit to learn about the design of the project before I will be able to be useful

vpuri3 commented 1 year ago

I agree - the design is HPC friendly.

The weight end up in the Galerkin mass-matrix, whose entries are

[M]_{ij} = \int_\Omega \phi_i(x) \phi_j(x) d x

where phi_i are your basis functions. Note that our basis functions aren't the spectral polynomials. Rather, our basis are the Lagrange polynomials over the zeros of the N+1th spectral polynomial. The Lagrange polynomials still end up being orthogonal, and M is a diagonal matrix whose entries are just the quadrature weights. The weights are all 1/2pi or something for Fourier basis so it boils down to a simple scaling.

I define the mass-matrix and other vector calculus operators here, and here.

Note the quadrature weight I am referring to is not the same as the exp(-x^2) weight for Gauss Hermite. Let's call the latter orthogonality weight. At this point, this package only has Legendre polynomials which are kinda trivial because the orthogonality weight is just unity. I like to consult this reference to keep my thoughts in order.

How about this: after I finish https://github.com/CalculustJL/CalculustCore.jl/pull/34, lemme try to implement Chebyshev polynomials this weekend. I should be straightforward to extend to other quadratures from there.

AshtonSBradley commented 1 year ago

Thanks for the references. For nonuniform orthogonality weight the degree of nonlinearity determines a change of variables to get the orthogonality weight into standard form. The transformation to collocation points is set by this. I have code for Gauss-Hermite.

The essential feature is making the transformation back to mode space projective for products of fixed degree fields

vpuri3 commented 1 year ago

Working on Chebyshev stuff right now. The spectral transform from type 1 chebyshev points to type 1 chebyshev polynomial coefficients is just the Discrete Cosine Transform per this reference.

My understanding is that you want to solve PDEs in spectral space via collocation method. Do you know what the differentiation matrix is in spectral space for these polynomials?