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

Anomalous scattering factors: switch to EPDL97 #76

Closed woutdenolf closed 5 years ago

woutdenolf commented 6 years ago

The relationship between photoabsorption cross-section and form factor (see NIST:FFAST eq 7) has degraded numerically by commit https://github.com/tschoonj/xraylib/commit/d28f2ef8861a32bde4e1bbc3f0778b0b1f5e29a1 which is in v3.3.0.

Code to test:

import xraylib

def mu_photo(element,energy):
    Z = xraylib.SymbolToAtomicNumber(element)
    M = xraylib.AtomicWeight(Z)
    f2 = xraylib.Fii(Z,energy)
    mu1 = xraylib.CS_Photo_Total(Z,energy)
    conv = -2*xraylib.R_E*xraylib.AVOGNUM*xraylib.KEV2ANGST/energy/M*1e18 # cm^2/g
    mu2 = conv*f2
    print ("Rel. Difference ({} @ {}keV): {}".format(element,energy,(mu2-mu1)/mu1))

mu_photo("Cl",30)
mu_photo("Fe",30)
mu_photo("Pb",30)

Version 3.2.0 (before change): Rel. Difference (Cl @ 30keV): 3.7915729507e-06 Rel. Difference (Fe @ 30keV): 3.77828790713e-07 Rel. Difference (Pb @ 30keV): 1.24547963341e-06

Version 3.3.0 (after change): Rel. Difference (Cl @ 30keV): 0.0064609625621 Rel. Difference (Fe @ 30keV): -0.000222803321302 Rel. Difference (Pb @ 30keV): 0.000661094705178

Not sure whether this is problematic but at least the data sources for CS_Photo_Total and Fii are less consistent than before.

tschoonj commented 6 years ago

Hey Wout,

Sorry for the delay.

I think I can live with these increased differences (still small IMHO), given that reverting to the old Fi/Fii dataset is not an option due to the problems that were brought to my attention by @mdw771 and @altaskier. If you need full internal consistency, I recommend calculating Fii yourself based on CS_Photo_Total (or vice versa), instead of using xraylib's Fii (or CS_Photo_Total).

Best,

Tom