Zelenyy / nist-calculators

Python implementaion of some NIST calculators
MIT License
19 stars 8 forks source link

Problem with photon attenuation coefficients calculation ? #3

Closed lesnat closed 4 years ago

lesnat commented 4 years ago

Hi !

I just discovered your Python module, and it seems very straightforward to use, so thank's a lot for sharing it ! (the XCOM and ESTAR database are nice, but retrieving informations from it must be done by hand to my knowledge, so you may save me a lot of time ;p)

I'm currently interested about photon attenuation coefficients, and it seems however that there is something going wrong with the calculation in your module.

If I follow your example, to get the photon attenuation coefficients for a given material, I must first create the appropriate material from its atomic number

import xcom
Z = ...
mat = xcom.Material([Z])

and then use the calculate_attenuation method to directly get the data in a numpy format

data = xcom.calculate_attenuation(mat)

When doing this, it seems to agree very well with the NIST data for Z=1 image

image

but when trying with higher Z it seems that both the amplitude and the energies are incorrect. Here is an example for Z=13 image

image

where the vertical dashed black line is at 1 MeV. As you can see the pair production threshold seems to be at tens or hundreds of MeV while it should be around 1 MeV. The value of the attenuation coefficient seems not correct neither. I've also tried with other elements and it seems that this behaviour gets worse and worse as Z increase.

Here is the script I'm using to generate these plots : photons_nist-calculator.py.txt

I've downloaded your package from pip, and it seems it is the last version.

If you don't develop this package actively I'll try to find another equivalent app, or code one on my own so don't worry, but I wanted to let you be aware of this issue because otherwise the package is nice ! :)

Bye, L.

lesnat commented 4 years ago

I think I've fixed the bug: the cross section were divided by a given factor instead of multiplied by this same factor, and the energy was also rescaled by the cross section rescaling factor. Check out your pull requests :smiley: !

laurajohann commented 1 year ago

Were you able to input chemical formulas or element symbols? I keep getting a keyerror from get_element_from_symbol...

lesnat commented 1 year ago

Hello ! I don't remember exactly how I used this code, but if you like my python scripts are available at https://github.com/lesnat/These/tree/master/1-particules I think these scripts should work with the last version of the code. Cheers