-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PRad Bugfix #1035
PRad Bugfix #1035
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1035 +/- ##
=======================================
Coverage 96.82% 96.82%
=======================================
Files 69 69
Lines 6737 6737
=======================================
Hits 6523 6523
Misses 214 214 ☔ View full report in Codecov by Sentry. |
with pytest.warns(RuntimeWarning): | ||
sim.run(field_weighting="nearest neighbor", dt=1e-12 * u.s) | ||
# Calc max deflection | ||
sim.max_deflection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to at least have a bounds check (assert lower < sim.max_deflection < upper
) here, rather than calculating it just for the non-exception-throwing-execution code coverage!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea - I've set a bound between 0 and pi/2 (which is valid for particles with a small max_theta
).
I found a few minor bugs in sections of
proton_radiography.SyntheticProtonRadiograph
that I used rarely:Accessing the
max_deflection
property raised an exception if particles had been deflected away from the detector (sincev
andv_init
were then un-equal in length). I fixed this by removing deflected particles fromv_init
as well in_coast_to_detector
._adaptive_dt
depended on the velocity of the particlesv0
, which was calculated increate_particles
but not defined if the user provided particles inload_particles
. Furthermore, user-provided particles don't necessarily have the same energy. I solved that by usingmax(v)
in_adaptive_dt
, which I'm calculating once at the beginning ofrun()
._adaptive_dt
now calculates the cyclotron period using the provided particle charge and mass (previously assumed protons).I have added a changelog entry for this pull request.