tschoonj / xraylib

A library for X-ray matter interaction cross sections for X-ray fluorescence applications
https://github.com/tschoonj/xraylib/wiki
Other
120 stars 54 forks source link

Possible problem about complex refractive index #42

Closed tontyoutoure closed 7 years ago

tontyoutoure commented 7 years ago

Recently I've been using your refractive index to compute the absorption length for tissues and PMMA. I find that the numbers your functions gives is a factor away (to be specific, 0.5) from what can I find on the NIST website

My code to calculate the absorption length is

ri = Refractive_Index(argv[1], energy ,atof(argv[2]));//argv[1] is the compound formula, argv[2] is density
L = KEV2ANGST*1e-10/(2*PI*ri.im*energy);

The matlab code I used to calculate absorption length from NIST data is

nist(:,4) = 1./nist(:,2)/rho/100; % Calculate absorption length from absorption coefficient, which is the second column of the data table

I draw the energy-absorption length plot for both your data and the NIST data, here's what I got (the x-axis has the unit of keV, the y axis has the unit of m):

pmma

They are 0.5 times away. I tried several compounds, like PMMA, lung tissue and so on, the result hold the same.

tschoonj commented 7 years ago

I am afraid I do not understand why you are using refractive indices to calculate absorption lengths: these are by definition equal to the product of total absorption cross section and density. Total absorption cross sections (also known as mass attenuation coefficients) can be easily calculated using CS_Total (for single elements) and CS_Total_CP (for chemical formulas/NIST catalog compounds). You can verify that the values on the NIST correspond very well to those offered by xraylib by using the xraylib online calculator. Clicking the link will show you the total absorption cross sections for PMMA at 1 keV: feel free to modify the energy to see how it corresponds to the values in the first column of the NIST table.

Also, the second column table in the NIST table are mass energy-absorption coefficients, which cannot be used to calculate absorption lengths. If you need these, you can calculate these with xraylib using the CS_Energy and CS_Energy_CP functions.

This being said, it is indeed possible to calculate total absorption cross sections (and therefore also absorption lengths) using the imaginary part of the refractive index, but I don't think your approach is right. Have a look at the code for Refractive_Index_Im in src/refractive_indices.c and you will see that I am using a different equation, most notably in my using 4PI vs your 2PI, which would explain the factor of two difference.

I did notice just now that the refractive index functions do not support the NIST catalog: I will fix this in the next release.

I hope this helps!

Best,

Tom

altaskier commented 7 years ago

I think the explanation is simple: amplitudes are affected as exp[-kbetat] but intensities (amplitudes squared) are affected as exp[-2kbetat]. Here k=2pi/\lambda, t is the thickness, and beta is from the refractive index 1-delta-ibeta

On Jan 16, 2017, at 10:53 AM, Tom Schoonjans notifications@github.com wrote:

I am afraid I do not understand why you are using refractive indices to calculate absorption lengths: these are by definition equal to the product of total absorption cross section and density. Total absorption cross sections (also known as mass attenuation coefficients) can be easily calculated using CS_Total (for single elements) and CS_Total_CP (for chemical formulas/NIST catalog compounds). You can verify that the values on the NIST correspond very well to those offered by xraylib by using the xraylib online calculator. Clicking the link will show you the total absorption cross sections for PMMA at 1 keV: feel free to modify the energy to see how it corresponds to the values in the first column of the NIST table.

Also, the second column table in the NIST table are mass energy-absorption coefficients, which cannot be used to calculate absorption lengths. If you need these, you can calculate these with xraylib using the CS_Energy and CS_Energy_CP functions.

This being said, it is indeed possible to calculate total absorption cross sections (and therefore also absorption lengths) using the imaginary part of the refractive index, but I don't think your approach is right. Have a look at the code for Refractive_Index_Im in src/refractive_indices.c and you will see that I am using a different equation, most notably in my using 4PI vs your 2PI, which would explain the factor of two difference.

I did notice just now that the refractive index functions do not support the NIST catalog: I will fix this in the next release.

I hope this helps!

Best,

Tom

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.


Chris Jacobsen (cjacobsen@anl.gov, +1-630-252-7960) Argonne Lab/Northwestern University http://xrm.phys.northwestern.edu/~jacobsen/index.html

tontyoutoure commented 7 years ago

OMFG twice in a row I submit such a stupid issue. @altaskier thanks for your simple answer and @tschoonj thanks for your concerning reply.

tschoonj commented 7 years ago

You're welcome. Glad I could be of help!