ammarhakim / gkylzero

Lowest, compiled layer of Gkeyll infrastructure.
MIT License
22 stars 5 forks source link

[DR] Second derivatives for Basis Object #443

Closed akashukla closed 3 months ago

akashukla commented 3 months ago

I would like to add the capability to evaluate the expansion of the second derivatives and mixed partial derivatives of our DG expansions. Currently the basis.eval_grad_expand function allows us to take a first derivative in any direction. Similar to this, it would be good to have a basis.eval_laplacian_expand function which allows us to take the second derivative in any direction and a basis.eval_mixedpartial expand function which allows us to take the mixed partial derivative.

Currently I have only two use cases for these functions:

  1. To find the X-points, I use the Newton-Raphson method which requires calculating which involves $\frac{\partial^2\psi}{\partial x^2}$, $\frac{\partial^2\psi}{\partial y^2}$ , and $\frac{\partial^2\psi}{\partial x \partial y}$.
  2. To calculate the magnetic field on axis for magnetic mirrors, we will need to be able to calculate $\frac{\partial^2\psi}{\partial x^2}$ and $\frac{\partial^2\psi}{\partial x \partial y}$.

Previously when we were only supporting p=2 tensor basis for psi, I put these functions directly in the efit_utils.c file for use by the efit updater. Now that we are supporting the cubics as well, it seems like it would be good to have these as part of the basis object.

The only 2 bases we would currently need these functions for are 2D tensor p=2 and p=3. If this is too invasive of a change, I can include every function I need directly in the efit_utils.c file for use in the efit updater.

This branch https://github.com/ammarhakim/gkylzero/tree/multib-app_gk_cubicbmag shows the example change to the basis object.

ammarhakim commented 3 months ago

We will not allow any changes to the basis object without more discussion. I think this issue is now resolved with a different design. Please submit a new DR for that. I am closing this.