Skip to content

feat: switch to DormandPrince745 stepper by default#42

Open
wdconinc wants to merge 3 commits intomainfrom
dopri
Open

feat: switch to DormandPrince745 stepper by default#42
wdconinc wants to merge 3 commits intomainfrom
dopri

Conversation

@wdconinc
Copy link
Contributor

@wdconinc wdconinc commented Feb 25, 2026

Briefly, what does this PR introduce?

This PR changes the default stepper from:

  stepper = "ClassicalRK4"
  eps_min = 5e-05
  eps_max = 0.001
  delta_chord = 0.25 * g4units.mm
  delta_one_step = 0.01 * g4units.mm
  delta_intersection = 0.001 * g4units.mm
  min_chord_step = 0.01 * g4units.mm

to

  stepper = "DormandPrince745"  ## different
  eps_min = 5e-05
  eps_max = 1e-04  ## 10x smaller
  delta_chord = 0.025 * g4units.mm  ## 10x smaller
  delta_one_step = 0.01 * g4units.mm
  delta_intersection = 0.01 * g4units.mm  ## 10x larger
  min_chord_step = 0.01 * g4units.mm

The differences are for the following reasons:

  • DormandPrince745 has 6 evaluations per step instead of ClassicalRK4 which has 11 per step
  • eps_max is reduced because it sets the relative scale of maximum accumulated step errors, and for a 2 m radius 1 GeV particle in a 1.7 T field this results in 2 mm, much larger than the pixel size,
  • delta_chord is reduced because it is the sagitta between the step chord and the true curved track, and at 0.25 mm this is much larger than a pixel,
  • delta_intersection is increased because a precision of 1 um is much smaller than the size of pixels we care about.

Note: to explore these on the command line, pass them as bare numbers in mm without explicit units, e.g. --field.delta_chord=0.025.

This PR, in preliminary testing (with tracking_only) increases throughput by about 5%.

What kind of change does this PR introduce?

  • Bug fix (issue #__)
  • New feature (issue: different stepper)
  • Documentation update
  • Other: __

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No.

Copilot AI review requested due to automatic review settings February 25, 2026 23:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the npsim front-end defaults for Geant4 magnetic field integration to use the DormandPrince745 stepper and retunes several field accuracy/geometry tolerances to better match pixel-scale detector resolutions.

Changes:

  • Switch default magnetic field stepper to DormandPrince745.
  • Tighten eps_max and delta_chord, and loosen delta_intersection to new target tolerances.
  • Introduce g4units usage for mm-based configuration values in the script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

wdconinc and others added 2 commits February 25, 2026 17:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@wdconinc wdconinc requested a review from veprbl February 26, 2026 00:29
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