Get EM back - #888
Open
Antoinehoff wants to merge 220 commits into
Open
Conversation
The code has the main infrastructures to include Aparallel effects by solving apardot and stepping Aparallel accordingly. Of course many bugs must reside and for now the EM effects are not included in the GK rhs. I checked that the 2x2v D3D regression test is behaving exactly the same if we activate EM or not. I want to see next if we get meaningful Apar and Apardot values as the diagnostics are included.
…ot in species. Mu0 needs to be set in the input file, other wise there will be a division by 0.
… the species struct.
…to get_em_back
…ing and recreating a solver because just rebuilding the matrix introduces memory leaks.
… em computation in comp time, note a "TODO" for the next step, lso removed an unused variable in fem_poisson_perp
We cannot use GKYL_GK_COLLISIONLESS_EM because this will remove the kernels for surf and volume terms... I want EM to keep them and just call new ones that will only add the EM contributions, especially because I need the ES RHS to compute current dot. We'll have to think about how to do that in a good way
…w if we are evolving ES, EM_BPAR, EM_BPERP, or EM without mentioning NO_BY anymore. Instead a new boolean `no_by` is introduced in the collisionless public and private tables. The kernel selections is now done according to the value of no_by and not according to the collisionless_id anymore. This makes the code cleaner and avoid introducing three other enums for EM+NO_BY.
…cies struct, I don't think we will add FLR to EM soon). We also add an option to the gkyl_dg_gyrokinetic updater to get an EM adder only or ES. And also add many empty kernels for the code to compile and checking the workflow. This branch is related to the gkylcas branch gkeyllorg/gkylcas#89
…tuff, then all the EM.
…code is able to run without apparent issue with EM option turned on. need to check how clean it is in valgrind.
…only available for Apardot but one may be interested to use it for phi if we decide to implement the adiabatic electron model.
…e with the stepped version. Also fix a merge bug.
… function pointer either points to a none func or connect to fem_projection_par_phi_func. This is then used on `out` in the apar stepper in gk_field.c. I guess this way allows to fully use any twist or other special BCs since it uses the phi infra. Tests soon. This is valgrind clean btw
…ollisionless term
…ion writing in a static routine.
Antoinehoff
marked this pull request as ready for review
June 29, 2026 22:34
Collaborator
Author
|
@JunoRavin, @manauref, I think this is ready for review. I don't think the design will change, the previous results were reproduced and the new tokamak geometry is not stable yet but it is capable. I would like to merge this so that I can stop resolving conflicts every week :) |
…e and make the gk 3x2v unit test EM
Collaborator
Author
@JunoRavin @manauref , a kind reminder now that the simulations are stable. |
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 is related to the DR #867 and gkylcas#89
Test cases
We report on a few test cases and benchmark, most of them taken from the work of @nmandell (see, e.g., Mandell et al. 2020 and Mandell thesis)
Alfven waves
We create the new associated regression tests.
and verify that the results in Mandell thesis are retrieved.

The scan was performed on Perlmutter using one CPU node and running many Gkeyll session in parallel using the following C input file and python scripting:
3x2v helical scrape-off layer
We create a new associated regression test
and we verify that the results are similar to Mandell et al. 2020.
Note: the geometry is adjusted to pass the right hand check (see PR #933).
Integrated moments

Electron density and perp. magnetic fluctuations
Helical SOL performance benchmark
We benchmark our different electromagnetic implementations with 3x2v shearless helical SOL turbulence, which uses a 3x2v phase-space grid with resolution$N_x=16$ , $N_y=32$ , $N_z=12$ , $N_{v_\parallel}=10$ , $N_\mu=5$ . The table below summarizes the performance benchmarks for different versions of the solver, using 3 A100 GPUs on Perlmutter.
this branch


Mandel et al. 2020
Need to smooth$A_\parallel$ along $z$ in tokamak geometry
We now test EM effects on known simulation like TCV simulations. Before smoothing$A_\parallel$ , it was not possible to run any TCV simulation for more than O(10) microseconds before observing a violent event breaking the simulation. This phenomenon was observed present in the following cases.
We tested a version where we apply$\dot A_\parallel \leftarrow \dot A_\parallel \langle \dot A_\parallel \rangle_{fs}$ at each Ohm solve to remove any zonal component of EM fluctuations. Suprisingly it did not even affect the time where the catastrophic event occur.
The simulation crashes approx. 450 mus after the restart. It does not seem that it reached steady state as shown with the evolution of$A_\parallel$ which continuously drops.This is no longer valid and was solved by restoring the bias plane in the potential (lost during some input file editing...).When$A_\parallel$ is smoothed just after the stepping using $\dot{A}_\parallel$ , the TCV PT coarse simulation runs smoothly:

For comparison purposes, this is the same simulation but electrostatic:

and time averaged profile comparisons averaged between 0.5ms and 1ms:
