Add a low pass time filter to GK - #990
Draft
Maxwell-Rosen wants to merge 28 commits into
Draft
Conversation
- Add low-pass filter damping type to gkyl_gyrokinetic_damping enum. - Initialize filtered distribution function in gk_species_apply_ic. - Implement damping initialization and calculation functions for low-pass filter. - Update SSP RK3 integration to advance filtered distributions.
…ty and functionality
…netic update process
…for clarity and consistency
…in low-pass filter
…e a ton of memory and computation on the updates
…me from someone using Vim in the gyrokinetic_multib_update_ssp_rk3. I fixed the spacing issues. I also found an issue with the implementation where the fbar was not being passed appropriately from ssprk3 down to the damping modules. Syntax is updated
…e conflicts with another PR and nobody is using this feature, as far as I know
…ving fbar having gkhyb basis will help with rapid oscillations in gradients of f, driving negativity
…the function call for reset
…cross resets and add configuration options This was pretty difficult to figure out and make sure it's valgrind clean. The damping_release method needed to be circumvented, posing memory sanitization issues. This is valgrind clean with and without the flag. rt_gk_sheath_1x2v is also valgrind clean
Maxwell-Rosen
marked this pull request as ready for review
April 21, 2026 16:54
Maxwell-Rosen
marked this pull request as draft
April 21, 2026 19:11
Collaborator
Author
|
This will merge after the sundials branch. It heavily interacts with #996 |
…restarted as well from the file. Implement this • Implemented fbar restart support. - Reads the matching damping_fbar frame file. - Synchronizes CPU/GPU state and SSP-RK stage arrays. - Supports single- and multi-block restarts. - Properly propagates missing/corrupt restart-file errors. - Falls back to restarted f when fbar output is disabled. Verified with reduced WHAM restart and Valgrind: 0 errors, 0 leaks. Build compiled and linked; only the sandbox-blocked external ADAS install copy failed.
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.
Feature
Summary
The coding for this PR was almost entirely done with GitHub Copilot, with @Maxwell-Rosen providing direction. I certify the results and take responsibility for any mistakes that may have been made.
Purpose: A low-pass filter is added to the gk_species_damping modules to damp high-frequency oscillations in$f$ .
Issue link: fixes #985
Implementation Details
Key changes:
This PR features pretty big changes, extending from gk_species_damping.c, all the way to the SSPRK3 time stepper. This is necessary because the low-pass filter adds an entirely new equation, RHS, and a new variable to step in time. I did my best to preserve the current architecture while simply adding new arguments to existing functions and mirroring how the distribution function is updated.
The new variable
fbaris constructed as P0 so that this feature doesn't take up too much memory. I am pretty sure thatfbarandfhaving different bases will not cause discritization errors, but I wouldn’t be surprised if it did.I had to refactor gk_species_damping quite a lot because there were tons of if statements in the advance functions and the write function.
There are severe merge conflicts with #934, so I ultimately deprecated the loss cone damping term. I'm not using this, and no one else is running mirror simulations. If it's important in the future, we can always bring it back. This was implemented as one of the first ideas regarding pseudo-orbit averaging, which did not work as we intended.
Although this function does look like a BGK operator, we should keep the BGK collisions app seperate, while this term is used to damp oscillations. The damping properties of the low pass filter are why I put this in damping, not the bgk app.
Automated testing: rt_gk_wham_1x2v has included this as a term in its input file
Example Use
Community Standards
layer/zeroshould have a unit test, e.g.,core/zero.Testing:
make checkand unit tests all pass.Additional Notes
gyrokinetic/creg/rt_gk_mirror_boltz_elc_poa_1x2v_p1.c and gyrokinetic/creg/rt_gk_mirror_boltz_elc_damping_1x2v_p1.c are valgrind clean, even with the resets and restoring fbar during different cycles.
Here is a simulation that used the low-pass filter using R=50 for the mirror ratio. I do notice that the time evolution is much slower in the density; however, in the temperatures, it can be quite rapid. Although rapid oscillations are strongly damped, they still occur. This simulation uses

rate_const = 1/5e-6.