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

[DRAFT] Add Particle scattering and stopping to the charged particle radiography class #1875

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

pheuer
Copy link
Member

@pheuer pheuer commented Jan 6, 2023

This PR adds particle scattering and stopping in dense matter to the charged particle radiography Tracker class. This capability is important for charged particle radiography in dense plasmas where these effects significantly affect the radiograph.

Builds on #1799, so merge that first.

Note: should compare this implementation of scattering + stopping to the MPRAD code described here: https://aip.scitation.org/doi/full/10.1063/1.5123392

Replaces a previous PR (#1802) because I needed to completely refactor after #1799

@github-actions
Copy link

github-actions bot commented Jan 6, 2023

Thank you for contributing to PlasmaPy! The project's future depends deeply on contributors like you, so we deeply appreciate it! 🌱 The following checklist will be used by the code reviewer to help guide the code review process.

  • Overall
    • Does the PR do what it intends to do?
    • Except for very minor changes, is a changelog entry included and consistent with the changelog guide?
    • Are the continuous integration checks passing? (Most linter problems can be automagically fixed by commenting on this PR with pre-commit.ci autofix.)
  • Code
    • Is new/updated code understandable and consistent with the coding guide?
    • Are there ways to greatly simplify the implementation?
    • Are there any large functions that should be split up into shorter functions?
  • Tests
    • Are tests added/updated as required, and consistent with the testing guide?
    • Are the tests understandable?
    • Do the tests cover all important cases?
  • Docs
    • Are docs added/updated as required, and consistent with the doc guide?
    • Are the docs understandable?
    • Do the docs show up correctly in the preview, including Jupyter notebooks?

@pheuer pheuer changed the title Add back in scattering + stopping to code [DRAFT] Add Particle scattering and stopping to the charged particle radiography class Jan 6, 2023
@codecov
Copy link

codecov bot commented Jan 6, 2023

Codecov Report

Patch coverage: 91.86% and project coverage change: -0.11 ⚠️

Comparison is base (83375f8) 98.31% compared to head (5b5b102) 98.21%.

❗ Current head 5b5b102 differs from pull request most recent head 514e952. Consider uploading reports for the commit 514e952 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1875      +/-   ##
==========================================
- Coverage   98.31%   98.21%   -0.11%     
==========================================
  Files          95       95              
  Lines        8383     8471      +88     
==========================================
+ Hits         8242     8320      +78     
- Misses        141      151      +10     
Impacted Files Coverage Δ
...rged_particle_radiography/synthetic_radiography.py 97.81% <91.86%> (-1.95%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@StanczakDominik
Copy link
Member

1799 is merged, did you mean another PR there, or...?

@pheuer
Copy link
Member Author

pheuer commented Jan 9, 2023

1799 is merged, did you mean another PR there, or...?

#1802 is the one I'm replacing: this PR needed to be refactored after 1799 got merged and, after ending up in a bit of a git tangle, I ended up just making a new branch from main and copying over the changes.

Copy link
Member

@StanczakDominik StanczakDominik left a comment

Choose a reason for hiding this comment

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

A couple quick fixes for now:

Comment on lines +28 to +39
@njit
def draw_from_normal(sigmas):
"""
Draw samples from a set of normal distributions where each
distribution has a different standard deviation.
"""
output = np.zeros(sigmas.size)
for i in range(sigmas.size):
output[i] = np.random.normal(loc=0, scale=sigmas[i])
return output


Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@njit
def draw_from_normal(sigmas):
"""
Draw samples from a set of normal distributions where each
distribution has a different standard deviation.
"""
output = np.zeros(sigmas.size)
for i in range(sigmas.size):
output[i] = np.random.normal(loc=0, scale=sigmas[i])
return output

You can actually just use np.random.normal(scale=sigmas)!

Comment on lines +157 to +160
Tabluated radiation lengths can be found here:
https://pdg.lbl.gov/2022/AtomicNuclearProperties/index.html

Tablulated proton and electron stopping power curves can be found here:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Tabluated radiation lengths can be found here:
https://pdg.lbl.gov/2022/AtomicNuclearProperties/index.html
Tablulated proton and electron stopping power curves can be found here:
Tabulated radiation lengths can be found here:
https://pdg.lbl.gov/2022/AtomicNuclearProperties/index.html
Tabulated proton and electron stopping power curves can be found here:

* np.sqrt(L_m / L_rad[:, i].to(u.m).value)
)

thetas = draw_from_normal(sigmas) # polar angle
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
thetas = draw_from_normal(sigmas) # polar angle
thetas = np.random.normal(scale=sigmas) # polar angle

@namurphy namurphy added the plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage label Mar 29, 2023
@namurphy namurphy added the size: very large ≥500 lines changed label May 26, 2023
@namurphy namurphy added this to the Future milestone Feb 6, 2024
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 size: very large ≥500 lines changed testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants