Fix MC test: use CSMS model and regenerate reference with n=10000#69
Merged
Fix MC test: use CSMS model and regenerate reference with n=10000#69
Conversation
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>
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.
Summary
DIPOLEtoCSMSto match the model used when generatingpython_reference.jsonrun_mcconventionRoot cause
The test was failing for two compounding reasons:
Model mismatch:
generate_python_reference.pyusesCrossSections('CSMS')but the Julia MC testset was runningCrossSections(DIPOLE).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_MCappends secondary particles to its output (exit_fraction > 1), while Juliarun_mcreturns one result per injected event. The reference is now generated by slicingout[:n_events]to compare primaries only.Test plan