Skip to content
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

Merged
merged 6 commits into from
Feb 23, 2021
Merged

PRad Bugfix #1035

merged 6 commits into from
Feb 23, 2021

Conversation

pheuer
Copy link
Member

@pheuer pheuer commented Feb 23, 2021

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 (since v and v_init were then un-equal in length). I fixed this by removing deflected particles from v_init as well in _coast_to_detector.

  • _adaptive_dt depended on the velocity of the particles v0, which was calculated in create_particles but not defined if the user provided particles in load_particles. Furthermore, user-provided particles don't necessarily have the same energy. I solved that by using max(v) in _adaptive_dt, which I'm calculating once at the beginning of run().

  • _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.

@codecov
Copy link

codecov bot commented Feb 23, 2021

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.82%. Comparing base (d4371b5) to head (f6d6fdd).

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.
📢 Have feedback on the report? Share it here.

with pytest.warns(RuntimeWarning):
sim.run(field_weighting="nearest neighbor", dt=1e-12 * u.s)
# Calc max deflection
sim.max_deflection
Copy link
Member

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!

Copy link
Member Author

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).

@StanczakDominik StanczakDominik merged commit bf9db26 into PlasmaPy:master Feb 23, 2021
@StanczakDominik StanczakDominik added this to the 0.6.0 milestone Mar 12, 2021
rocco8773 added a commit to rocco8773/PlasmaPy that referenced this pull request Mar 14, 2021
@namurphy namurphy added the plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage label May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants