McStasMcXtrace / McCode

The home of the McStas (neutrons) and McXtrace (x-rays) Monte-Carlo ray-tracing instrument simulation codes.
https://github.com/McStasMcXtrace/McCode/wiki
GNU General Public License v3.0
77 stars 52 forks source link

Enhancement: McXtrace: add fluorescence sample #1261

Closed farhi closed 1 year ago

farhi commented 1 year ago

Use X-ray lib to simulate the energy and probability of fluorescence lines:

In any case there are questions to assess:

farhi commented 1 year ago

A link with xraylib (libxrl) is a straight-forward solution. An implementation with Compton scattering shows how libxrl can be used:

In principle, fluo, Compton, etc can be used the same. The list of all cross sections is available:

farhi commented 1 year ago

For instance:

double CS_Energy(int Z, double E, xrl_error **error);

Given an element Z and an energy E, returns the mass-energy absorption cross section in cm2g

double CS_Total_CP(const char compound[], double E, xrl_error **error);
double CS_Photo_CP(const char compound[], double E, xrl_error **error);
double CS_Rayl_CP(const char compound[], double E, xrl_error **error);
double CS_Compt_CP(const char compound[], double E, xrl_error **error);
double CSb_Total_CP(const char compound[], double E, xrl_error **error);
double CSb_Photo_CP(const char compound[], double E, xrl_error **error);
double CSb_Rayl_CP(const char compound[], double E, xrl_error **error);
double CSb_Compt_CP(const char compound[], double E, xrl_error **error);
double CS_Total_Kissel_CP(const char compound[], double E, xrl_error **error);
double CSb_Total_Kissel_CP(const char compound[], double E, xrl_error **error);
double CS_Energy(const char compound[], double E, xrl_error **error);

Identical to the earlier mentioned functions, but require a chemical formula or a NIST compound name compound as first argument.

A C implementation is: