Skip to content

Commit

Permalink
Add lateral straggle to stack
Browse files Browse the repository at this point in the history
  • Loading branch information
pheuer committed Feb 20, 2025
1 parent 7fa9678 commit 8373b2d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cr39py/filtration/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def lateral_straggle(self, particle: str, E_in: u.Quantity) -> u.Quantity:
Returns
-------
R : u.Quantity
Projected range of the particle in the layer.
straggle : u.Quantity
Lateral straggle of the particle in the stack.
"""
straggle_interp = self.srim_data(particle).lateral_straggle_interpolator

Expand Down
37 changes: 37 additions & 0 deletions src/cr39py/filtration/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,40 @@ def ranging_energy_loss(
"""
return E_in - self.range_down(particle, E_in, dx=dx)

def lateral_straggle(self, particle: str, E_in: u.Quantity) -> u.Quantity:
"""
Calculate the lateral straggle of a particle in the stack.
If the particle passes through the stack, this is the straggle experienced by the particle in the stack.
If the particle stops in the stack, this is the total straggle up to the stopping point.
This model assumes that the lateral straggle is additive in each layer.
See the `~cr39py.filtration.srim.SRIMData` class for formal definition of this quantity.
Parameters
----------
particle : str
Incident particle
E_in : u.Quantity
Energy of the particle before ranging in the stack.
Returns
-------
straggle : u.Quantity
Lateral straggle of the particle in the stack.
"""
straggle = 0 * u.um
for l in self.layers:
straggle += l.lateral_straggle(particle, E_in)

# Range down the particle energy before calculating straggle in the next layer
E_in = l.range_down(particle, E_in)

# If the particle has stopped, return the accumulated straggle
if E_in.m <= 0:
return straggle

Check warning on line 237 in src/cr39py/filtration/stack.py

View check run for this annotation

Codecov / codecov/patch

src/cr39py/filtration/stack.py#L237

Added line #L237 was not covered by tests

return straggle
6 changes: 6 additions & 0 deletions tests/filtration/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ def test_stack_ranging_energy_loss():
Elost = s.ranging_energy_loss("Deuteron", Ein)

assert np.isclose(Elost, Ein - Eout, rtol=0.01)


def test_stack_lateral_straggle():
s = Stack.from_string("100 um Ta, 100 um Al")
straggle = s.lateral_straggle("Proton", 12 * u.MeV)
assert np.isclose(straggle, 14.52 * u.um, rtol=0.01)

0 comments on commit 8373b2d

Please sign in to comment.