Skip to content

Get EM back - #888

Open
Antoinehoff wants to merge 220 commits into
mainfrom
get_em_back
Open

Get EM back#888
Antoinehoff wants to merge 220 commits into
mainfrom
get_em_back

Conversation

@Antoinehoff

@Antoinehoff Antoinehoff commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator

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.

gyrokinetic/creg/rt_gk_em_alfven_1x2v_p1.c
gyrokinetic/creg/rt_gk_em_alfven_2x2v_p1.c
gyrokinetic/creg/rt_gk_em_alfven_3x2v_p1.c

and verify that the results in Mandell thesis are retrieved.
kaw_scan_results

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

gyrokinetic/creg/rt_gk_em_helical_sol_3x2v_p1.c

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
image

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.

Version Throughput
Full upwind, non-optimized ~2.2 steps/s
w. Kernel vpar flux optim. ~2.8 steps/s
w. Ohm's LHS updater (this branch) ~7.7 steps/s
Electrostatic ~9.1 steps/s
image

this branch
image
Mandel et al. 2020
Screenshot 2026-04-30 at 3 08 04 PM

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.

  • TCV 2x2v SOL only (24x16x16x8)
  • TCV 3x2v SOL only (24x16x12x12x8)
  • TCV 2x2v clopen (24x16x16x8)
  • TCV 3x2v clopen (24x16x12x12x8)

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:
image

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

and time averaged profile comparisons averaged between 0.5ms and 1ms:
Screenshot 2026-09-08 at 11 57 08 AM

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.
…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
…code is able to run without apparent issue with EM option turned on. need to check how clean it is in valgrind.
@Antoinehoff Antoinehoff changed the title Get EM back 🚧 Get EM back Jun 11, 2026
@Antoinehoff
Antoinehoff marked this pull request as ready for review June 29, 2026 22:34
@Antoinehoff

Copy link
Copy Markdown
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 :)

@Antoinehoff

Copy link
Copy Markdown
Collaborator Author

Collaborator

@JunoRavin @manauref , a kind reminder now that the simulations are stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant