Skip to content

Conversation

@henry2004y
Copy link
Owner

  • Add check_interval parameter for the hybrid solver to reduce the frequency of adiabaticity check and method switching

@gemini-code-assist
Copy link

Summary of Changes

Hello @henry2004y, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the AdaptiveHybrid solver by introducing a configurable check_interval parameter. This parameter allows for optimization of the solver's performance by reducing the frequency of computationally intensive adiabaticity checks and subsequent method switching, thereby improving overall simulation efficiency.

Highlights

  • New check_interval parameter: Introduced a check_interval parameter to the AdaptiveHybrid solver, allowing users to specify the frequency of adiabaticity checks and method switching.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/examples/features/demo_hybrid.jl
    • Added check_interval = 100 to the AdaptiveHybrid constructor call in the example.
  • src/hybrid.jl
    • Added check_interval::Int field to the AdaptiveHybrid struct.
    • Updated the AdaptiveHybrid constructor to accept and initialize the check_interval parameter, with a default value of 10.
    • Modified the adiabaticity check logic in both Guiding Center (GC) and Full Orbit (FO) modes to only execute when the current iteration count is a multiple of check_interval.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a check_interval parameter to the adaptive hybrid solver, which is a good performance optimization to reduce the frequency of expensive adiabaticity checks and potential method switching. However, a medium-severity vulnerability was identified: a missing input validation on the new check_interval parameter could lead to a denial of service if a user provides a value of zero, causing a division-by-zero error. It is recommended to add a check to ensure this parameter is a positive integer to prevent potential runtime errors and improve robustness.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.04%. Comparing base (dbf2799) to head (5ea4307).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #459      +/-   ##
==========================================
+ Coverage   81.80%   82.04%   +0.23%     
==========================================
  Files          21       21              
  Lines        2056     2061       +5     
==========================================
+ Hits         1682     1691       +9     
+ Misses        374      370       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Benchmark Results (Julia v1)

Time benchmarks
master 5ea4307... master / 5ea4307...
interpolation/cartesian 0.12 ± 0.011 μs 0.12 ± 0.001 μs 1 ± 0.092
interpolation/spherical 0.42 ± 0.01 μs 0.411 ± 0.01 μs 1.02 ± 0.035
interpolation/time-dependent 3.57 ± 0.53 μs 4.27 ± 3.2 μs 0.836 ± 0.64
trace/GC/DiffEq Vern6 5.62 ± 1.4 μs 5.63 ± 1.3 μs 0.998 ± 0.35
trace/GC/Native RK4 0.137 ± 0.00016 s 0.137 ± 0.00016 s 0.999 ± 0.0017
trace/GC/Native RK45 3.36 ± 0.11 μs 3.36 ± 0.1 μs 1 ± 0.045
trace/Hybrid/Sheared 3.41 ± 0.09 μs 2.01 ± 0.07 μs 1.69 ± 0.074
trace/analytic field/in place 0.0569 ± 0.035 ms 0.0573 ± 0.035 ms 0.994 ± 0.86
trace/analytic field/in place relativistic 0.0787 ± 0.034 ms 0.0802 ± 0.034 ms 0.981 ± 0.6
trace/analytic field/out of place 0.0448 ± 0.033 ms 0.0447 ± 0.033 ms 1 ± 1
trace/normalized/out of place 15.6 ± 7 μs 15.5 ± 5.6 μs 1.01 ± 0.58
trace/numerical field/Adaptive Boris 4.19 ± 0.11 ms 4.2 ± 0.099 ms 0.996 ± 0.035
trace/numerical field/Boris 7.34 ± 0.081 μs 7.35 ± 0.07 μs 0.999 ± 0.015
trace/numerical field/Boris ensemble 14.7 ± 0.14 μs 14.7 ± 0.13 μs 1 ± 0.013
trace/numerical field/Boris kernel 9.46 ± 0.14 μs 9.46 ± 0.13 μs 1 ± 0.02
trace/numerical field/Boris with fields 8 ± 0.07 μs 7.99 ± 0.07 μs 1 ± 0.012
trace/numerical field/Multistep Boris 11 ± 0.071 μs 11 ± 0.071 μs 1 ± 0.0092
trace/numerical field/in place 27.5 ± 4.6 μs 27 ± 4.7 μs 1.02 ± 0.25
trace/numerical field/out of place 18.8 ± 4.7 μs 18.9 ± 4.7 μs 0.999 ± 0.35
trace/time-dependent field/in place 0.133 ± 0.0032 ms 0.136 ± 0.0034 ms 0.98 ± 0.034
trace/time-dependent field/out of place 0.108 ± 0.003 ms 0.105 ± 0.0033 ms 1.03 ± 0.043
time_to_load 2.01 ± 0.0074 s 2.08 ± 0.0061 s 0.966 ± 0.0045
Memory benchmarks
master 5ea4307... master / 5ea4307...
interpolation/cartesian 2 allocs: 0.234 kB 2 allocs: 0.234 kB 1
interpolation/spherical 2 allocs: 0.203 kB 2 allocs: 0.203 kB 1
interpolation/time-dependent 0.044 k allocs: 9.62 kB 0.044 k allocs: 9.62 kB 1
trace/GC/DiffEq Vern6 0.177 k allocs: 12.1 kB 0.177 k allocs: 12.1 kB 1
trace/GC/Native RK4 13 allocs: 0.382 MB 13 allocs: 0.382 MB 1
trace/GC/Native RK45 16 allocs: 2.44 kB 16 allocs: 2.44 kB 1
trace/Hybrid/Sheared 8 allocs: 2.98 kB 8 allocs: 2.98 kB 1
trace/analytic field/in place 2.07 k allocs: 0.0883 MB 2.07 k allocs: 0.0883 MB 1
trace/analytic field/in place relativistic 2.07 k allocs: 0.0883 MB 2.07 k allocs: 0.0883 MB 1
trace/analytic field/out of place 2.03 k allocs: 0.0865 MB 2.03 k allocs: 0.0865 MB 1
trace/normalized/out of place 0.753 k allocs: 0.0321 MB 0.753 k allocs: 0.0321 MB 1
trace/numerical field/Adaptive Boris 27 allocs: 1.5 MB 27 allocs: 1.5 MB 1
trace/numerical field/Boris 6 allocs: 1.16 kB 6 allocs: 1.16 kB 1
trace/numerical field/Boris ensemble 10 allocs: 2.28 kB 10 allocs: 2.28 kB 1
trace/numerical field/Boris kernel 0.038 k allocs: 2.12 kB 0.038 k allocs: 2.12 kB 1
trace/numerical field/Boris with fields 6 allocs: 1.52 kB 6 allocs: 1.52 kB 1
trace/numerical field/Multistep Boris 6 allocs: 1.16 kB 6 allocs: 1.16 kB 1
trace/numerical field/in place 0.432 k allocs: 20.7 kB 0.432 k allocs: 20.7 kB 1
trace/numerical field/out of place 0.393 k allocs: 18.5 kB 0.393 k allocs: 18.5 kB 1
trace/time-dependent field/in place 3.97 k allocs: 0.177 MB 3.97 k allocs: 0.177 MB 1
trace/time-dependent field/out of place 3.93 k allocs: 0.175 MB 3.93 k allocs: 0.175 MB 1
time_to_load 0.145 k allocs: 11 kB 0.145 k allocs: 11 kB 1

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