[PR] FLR effects with Padé approximants - #1078
Open
Antoinehoff wants to merge 16 commits into
Open
Conversation
… was missing in the species FLR operators. The gk_field_flr is also changed and now does nothing as it should invert the flr on phi. There is now a placeholder where we will call the application for the operator 1 -rho^2 laplacian_perp which is currently not possible.
…m to a DG array. Basically, while the current poisson fem solver solves (M+K) phi = M rho for phi, the new routine gkyl_fem_poisson_lhs_apply computes rho = M^-1 (M+K) phi which is the DG representation of the linear operator applied to phi. This is done using superlu sp_dgemv routine on CPU. There is no equivalent in cuDSS so we use cusparse cusparse SpMV routine on GPU. Cusparse provides a routine that allows to points on an existing matrix, cusparseCreateCsr, which prevents double allocation/computation of the matrix in the poisson updater. The unit test associated to this new feature tests that we can revert a poisson solve by applying the operator back. I need to test the GPU code on perlmutter.
…commit was using the global fem_poisson operator which is not coherent with how we solve the field equation in GK. A new apply mat operator is created to apply matrices with the gk_fem_poisson_perp now. An equivalent unit test is provided. We can see if we want to remove the other apply LHS later. We also move poisson_bcs inside the field structure so that we can reuse it for FLR effects. It also simplifies gk_species.c as it does not have to compute it again, the only caveat is that field must be initialized before species but I think other parts of the code assume that.
…use deflated here because we use the value at the boundary as BC.
… apply LHS builder and build the exact same matrix. I am not sure on how stable and sound this is but otherwise, the FLR operator will break the bias plane BC. In general, I am not sure that the clopen setup is compatible with FLR since this is varying BCs...
Antoinehoff
marked this pull request as ready for review
July 6, 2026 17:31
…passes. I have to come up with a less trivial case now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the proposed algorithm of DR #797.
Implementation details
The code change resides in the implementation of a new
superlu/cusparseupdater to apply a LHS matrix. This is the solution found to perform theinvert_flrstep, i.e.,where$\Phi_0$ is the solution of the quasi-neutrality equation with FLR corrected charge density (see #797 for more details).
This new updater,
gkyl_fem_poisson_perp_lhs_applyhas the advantage to use the exact same representation as thegkyl_fem_poisson_perp_solve, which should ensure coherence in the discretization. A unit test verify the capability of the updater by solving the problemusing
gkyl_fem_poisson_perp_solvewhere the RHS is built asusing the new updater$g$ .
gkyl_fem_poisson_perp_apply_lhson an analytical functionInterface
We add a new entry
gyroradiusinto thegkyl_gyrokinetic_flrtable and add an instance of this structure in thefieldtable. The new regression test,rt_gk_flr_d3d_iwl_2x2v_p1.cis testing the FLR feature. For the species, we passwhere
.Tperpwill be used to compute the gyroradius (the magnetic field amplitude can be specified too but here it is taken from theapptable). For the field, we passwhere$\phi$ from $\Phi_0$ .
.gyroardiusis the ion gyroradius that will be used to getThe type
GKYL_GK_FLR_PADE_CONSTmeans that we use only one reference gyroradius. The former version of the code used a sum over the gyroradii which is not correct but is still available usingGKYL_GK_FLR_PADE_CONST_SUM.Caveats and open questions
This implementation should conserve particle and energy (to be checked). One important limitation is that we cannot use varying boundary conditions, nor varying gyroradii, if we want to maintain conservation. While the former is not very common, the latter may limit the physical accuracy of our simulations.
This PR reintroduce
cuSPARSE, that I heard was removed from Gkeyll a while ago. I don't see an interference on CPU nor GPU (cuda13 on Perlmutter). I could not usecuDSSonly because it does not have a routine to apply a matrix. One thing that is not very logical in the PR is that thecuSPARSEuse is in thecuDSSfile. Should we create a newcuSPARSEfile ?Additional feature
By mistake I implemented the apply LHS updater using the
gkyl_fem_poissoninmoments. This updater also has a unit test and seems to work. I don't know if we want to keep it or remove it, because it is not used.Results
TCV 2x2v
We use the TCV 2x2v regression test and increase the resolution to
24x16x12x8to compare quickly the effect of the FLR model. We see an effect of the FLR operator on the potential.Postgkyl command
One main difference is that the initial poisson solve is non zero when we use FLR, even if$n_i^g=n_e^g$ at $t=0$ . This may be physical because with FLR effects activated, the densities $n_s^g=\int dv f_s$ are passed through the FLR operator before computing the charge density. Since the FLR operator is dependent on the gyroradius, the resulting gyroaverage densities change between electron and ions which will create a non zero charge density at $t=0$ .
Postgkyl command