Skip to content

Fix MC test: use CSMS model and regenerate reference with n=10000#69

Merged
jlazar17 merged 1 commit intomasterfrom
update/installation-instructions
Mar 20, 2026
Merged

Fix MC test: use CSMS model and regenerate reference with n=10000#69
jlazar17 merged 1 commit intomasterfrom
update/installation-instructions

Conversation

@jlazar17
Copy link
Copy Markdown
Collaborator

Summary

  • Switch the Julia MC testset from DIPOLE to CSMS to match the model used when generating python_reference.json
  • Regenerate MC reference data with n=10000 events (up from n=100), comparing primary particles only to match Julia run_mc convention
  • Python and Julia now agree at the 1-4% level on all three test cases, well within the 30% test tolerance

Root cause

The test was failing for two compounding reasons:

  1. Model mismatch: generate_python_reference.py uses CrossSections('CSMS') but the Julia MC testset was running CrossSections(DIPOLE).

  2. Too few events: n=100 produced 30-60% statistical noise in the median exit energy when comparing across different RNGs (numpy vs MersenneTwister), making the test unreliable even when the physics agrees.

A third issue was identified but does not affect this fix: Python run_MC appends secondary particles to its output (exit_fraction > 1), while Julia run_mc returns one result per injected event. The reference is now generated by slicing out[:n_events] to compare primaries only.

Test plan

  • All 449 tests pass locally

The MC regression test was failing for two reasons:

1. Model mismatch: the Python reference data was generated with CSMS but
   the Julia test was running with DIPOLE.

2. Too few events: n=100 events produced 30-60% statistical noise in the
   median exit energy when comparing across different RNGs (numpy vs
   MersenneTwister), making the test unreliable even when the physics agrees.

Fix: switch the Julia MC testset to CSMS and regenerate python_reference.json
with n=10000 events (primaries only, slicing out[:n_events] to match the
Julia run_mc convention of one result per injected event). Python and Julia
now agree at the 1-4% level on all three test cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jlazar17 jlazar17 merged commit f4ee2e5 into master Mar 20, 2026
0 of 2 checks passed
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