Skip to content

Add cross-collisions diagnostics to the GK LBO app - #1013

Closed
Maxwell-Rosen wants to merge 9 commits into
mainfrom
cross-lbo-diag
Closed

Add cross-collisions diagnostics to the GK LBO app#1013
Maxwell-Rosen wants to merge 9 commits into
mainfrom
cross-lbo-diag

Conversation

@Maxwell-Rosen

@Maxwell-Rosen Maxwell-Rosen commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Feature

This PR is nearly 100% Claude, but it's not AI slop. I verify that this implementation is how I would do it, also.

Summary

Purpose: My mirror simulations are exposing an issue with the implementation of cross-species collisions. The moments can go negative if $m_i \gg m_e$, $T_e \ll T_i$, $u_{\parallel,i} \ll u_{\parallel,e}$. This is just in the mathematics of how these cross-moments are computed. By outputting detailed cross-species collision diagnostics, we can effectively diagnose such issues.

Implementation Details

Key changes: gk_species_lbo.c is expanded to include a new diagnostic for the cross-species collisions. Since these diagnostics are on intermediate quantities, they must be re-computed, so I refactored the update function as well.

I decided to reuse some memory from the prim_moms_ho and nu_sum_ho to save some memory and avoid additional allocations.

I could see someone arguing that this should just be under the write_diagnostics flag and not a separate flag. It's good to keep this modular.

Automated testing: Existing tests

Example Use

    .collisions =  {
      .collision_id = GKYL_LBO_COLLISIONS,
      .den_ref = ctx.n0,
      .temp_ref = ctx.Ti0,
      .num_cross_collisions = 1,
      .collide_with = { "elc" },
      .write_diagnostics = true,
    },

Community Standards

  • Documentation has been updated.
  • My code follows the project's coding guidelines.
  • Changes to layer/zero should have a unit test, e.g., core/zero.

Testing:

  • I added a regression test to test this feature.
  • I added this feature to an existing regression test.
  • I added a unit test to test this feature.
  • Ran make check and unit tests all pass.
  • I ran the code with make valcheck, and it is clean.
  • I ran the code through computer-sanitizer on GPU, and it is clean.
  • I ran a few regression tests to ensure no apparent errors.
  • Tested and works on CPU.
  • Tested and works on multi-CPU.
  • Tested and works on GPU.
  • Tested and works on multi-GPU.

Additional Notes

Comment thread gyrokinetic/apps/gkyl_gyrokinetic.h Outdated
@Maxwell-Rosen
Maxwell-Rosen requested a review from manauref June 6, 2026 18:51
…This took me hours to debug and claude found it in 30 seconds, but I wouldn't have been able to focus claude in the right areas without the debugging.
@Maxwell-Rosen

Copy link
Copy Markdown
Collaborator Author

Continued in #1076

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.

2 participants