Open jccurtis opened 7 years ago
I think this code would do what you want:
import numpy as np
from becquerel.tools import xcom
def prob_no_interact(energy_kev, material, density, thickness):
df = xcom.fetch_xcom_data(material, energies_kev=[energy_kev])
mu_rho = df.total_wo_coh[0]
return np.exp(-mu_rho * density * thickness)
So 662 keV into 8 cm of HPGe would be:
>>> prob_no_interact(662, 'Ge', 5.3, 8)
0.052618895168927801
For more fun you could define:
def prob_interact(energy_kev, interaction, material, density, thickness):
prob_no = prob_no_interact(energy_kev, material, density, thickness)
df = xcom.fetch_xcom_data(material, energies_kev=[energy_kev])
mu_rho_total = df.total_wo_coh[0]
mu_rho_int = df[interaction][0]
return (1 - prob_no) * mu_rho_int / mu_rho_total
So:
>>> prob_interact(662, 'photoelec', 'Ge', 5.3, 8)
0.024022147236969306
>>> prob_interact(662, 'incoherent', 'Ge', 5.3, 8)
0.92337259879071676
>>> prob_interact(662, 'pair_nuc', 'Ge', 5.3, 8)
0.0
Lets get this merged ... @markbandstra make a PR!
Lets get this merged ... @markbandstra make a PR!
bump
Unless I'm mistaken there is not currently a tool to calculate the attenuation of a gamma ray given energy, elemental compound, density and thickness. I'm pretty sure @markbandstra has developed this for his gamma spectrum emission and detection simulator. I propose we include the calculator inside the XCOM tool as another function which could use the material definitions in #51.