XRayAttenuation Tutorial

Demonstration of the use of the "XRayAttenuation.m" package

John Schweppe

Introduction

The package "XRayAttenuation.m" provides functions which interpolate the tables of x-ray mass attenuation coefficients μ/ρ and mass energy-absorption coefficients (Subscript[μ, en])/ρ given in NIST report 5632, "Tables of X-Ray Mass Attenuation Coefficients and Mass Energy-Absorption Coefficients 1 keV to 20 MeV for Elements Z = 1 to 92 and 48 Additional Substances of Dosimetric Interest," by J. Hubbell and S.M. Seltzer. As indicated by the title, the tables in the NIST report cover the x-ray energy range from 0.001 MeV to 20 MeV, and give values for 140 materials: the first 92 elements, from hydrogen through uranium, as well as 48 additional materials of dosimetric interest. As described in greater detail in the NIST report, the mass attenuation coefficient μ/ρ describes the exponential attenuation of photons in matter as follows. For the case of a narrow beam of monoenergetic photons of intensity (Subscript[I, 0]) impinging on a layer of material, the intensity I of photons which penetrates a thickness t of material with density ρ is given by I/(Subscript[I, 0]) = (e^(-ρ(μ/ρ) t)). The mass attenuation coefficient μ/ρ is a function only of the material and the energy of the photons. In a similar manner, the mass energy-absorption coefficients (Subscript[μ, en])/ρ describes the deposition of energy by photons penetrating material. Its calculation is described in the NIST report, and involves taking into account the different processes by which the photons generate charged particles as they penetrate matter and what fraction of the kinetic energy of those particles is not lost through further radiative processes as the particles slow to rest. The mass energy-absorption coefficient (Subscript[μ, en])/ρ also depends only on the material and on the energy of the photons.

For those who prefer to use mean free paths instead of mass attenuation coefficients, the "XRayAttenuation.m" package defines additional functions to give the mean free path corresponding to either the mass attenuation coefficient or the mass energy-absorption coefficient. The x-ray attenuation mean free path λ assocoiated with the mass attenuation coefficient μ/ρ is defined as \(TraditionalForm\`λ = \([\((μ/ρ)\) ρ]\)\^\(-1\)\), where ρ is the density of the material.  For the sake of consistency, the material density used in the NIST report is also used to calculate the mean free path. The attenuation mean free path is used to describe the exponential attenuation of photons in a material as I/(Subscript[I, 0]) = (e^(-t/λ)). In a similar manner, the energy-absorption mean free path (Subscript[λ, en]) assocoiated with the mass energy-absorption coefficient (Subscript[μ, en])/ρ is defined as \(TraditionalForm\`λ\_en = \([\((μ\_en/ρ)\) ρ]\)\^\(-1\)\).

The total fracional transmission T of x-rays of a given energy E passing through a thickness t of material with density ρ and mass attenuation coefficient μ/ρ at that energy is given by T = I/(Subscript[I, 0]) = 
          (e^(-ρ(μ/ρ) t)). The total transmitted energy is T E.In a similar manner, the total fracional energy absorption (Subscript[A, en]) of x-rays of a given energy E through a thickness t of material with density ρ and mass energy-absorption coefficient (Subscript[μ, en])/ρ at that energy is given by (Subscript[A, en]) = 
        1 - (e^(-ρ((Subscript[μ, en])/ρ) t)). The total absorbed energy is (Subscript[A, en]) E. The "XRayAttenuation.m" package defines functions to give the transmission fraction of x-rays through these same 140 materials materials and energy absorption fraction in these materials.

The x-ray mass attenuation coefficient (Subscript[((μ/ρ)), mix]) of an homogenous mixture is given by (Subscript[((μ/ρ)), mix]) = (∑_i) (Subscript[w, i])(Subscript[((μ/ρ)), i]), where (Subscript[((μ/ρ)), i]) is the mass attenuattion coefficient of the (i^th) constituent and  (Subscript[w, i]) is the fraction by weight of the (i^th) constituent. For chemical compounds of the elements, where the fraction by number (Subscript[n, i]) is specified for the (i^th) element rather than the fraction by weight, the corresponding fraction by weight (Subscript[w, i]) is given by (Subscript[w, i])=(((Subscript[n, i]) (Subscript[A, i]))/((∑_i) (Subscript[n, i]) (Subscript[A, i])))where (Subscript[n, i]) is the number of atoms per molecule of the (i^th) atomic constituent and (Subscript[A, i])is the atomic weight of the (i^th) atomic constituent. The "XRayAttenuation.m" package defines functions to give the x-ray mass attenuation coefficient, attenuation mean free path, and fractional transmission of both homogenous mixtures of the 140 materials and chemical compounds of the first 92 elements. Functions are not given for energy absorption since the simple additivity law above for mass attenuation coefficients does not strictly apply for mass energy-absorption coefficients (although it can be a good approximation in many cases).

Finally, as an aid to calculation, the package also defines functions to give the x-ray energy corresponding to a given x-ray wave length or frequency. The energy E of an x-ray is related to its wave length λ as E = h c/λ and to its frequency f as E = h f, where h is Planck's constant and c is the speed of light.

The names of the first 92 elements are taken from the Miscellaneous`ChemicalElements` package, in order to be consistent with that package. as mentioned above, the densities of materials, used internally to calculate mean free path, transmission, and absorption, are taken from the NIST report, rather than from the Miscellaneous`ChemicalElements` package, in order to be consistent with the NIST report.
	
The tables in the NIST report list coefficients in (cm^2)/g against energy in MeV. The report also lists density in g/(cm^3) for each of the materials. The XRayAttenuation.m package is set up to use any of the appropriate units in the standard "Miscellaneous`Units`" and "Miscellaneous`SIUnits`" packages. The energy, length, and density arguments to the various functions must be input with units and the output of the functions are returned with units.

Interpolation of the tables is done to the logarithm of coefficients against the logarithm of energy because of the near power-law dependence of coefficients against energy over much of the energy range. The result is returned as the exponential of the interpolation: coefficient = Exp[Interpolation[Log[energy]]]. At each atomic absorption edge the coefficients undergo a discontinuous change as a new absorption channel becomes available, so the interpolation is done separately for each region of the table, between pairs of absorption edges. The order of the polynomial function for the interpolation is set to 3, except for regions of the table with only three points between absorptiion edges, where it is set to 2. The NIST tables include at least 3 points between each pair of absorption edges.

The values in the table for gases appear to be for 20 degrees C at 1 atmosphere. The values for ceric ammonium sulfate solution are for 0.015 Molar solution.

The XRayAttenuation.m package needs the following standard packages. "DiscreteMath`Tree`" is used to determine in which section of each table, between absorption edges, a given energy belongs. "Miscellaneous`ChemicalElements`" is used for the names of the first 92 elements and for the AtomicWeight function in defining the mass attenuation coefficients for chemical compounds. "Miscellaneous`Units`" and "Miscellaneous`SIUnits`" are used to define the energy, length, density, mass density, and frequency units used by the various functions and to make conversions between units. "Miscellaneous`PhysicalConstants`" is used to define functions to convert x-ray wave length and frequency to energy and back. The needed packages are automatically loaded with the XRayAttenuation.m package.

Use of the package

Load the package XRayAttenuation.m. The package needs to be in the path that Mathematica searchs for files, as indicated by the variable $Path. A good place to put XRayAttenuation.m is the directory .../AddOns/Applications. Otherwise set the working directory to the directory containing XRay Attenuation.m with the SetDirectory[directory] command.

Needs["XRayAttenuation`"];

The package defines several new functions as well as the materials that the functions apply to.

?XRayAttenuation

The basic functions XRayMAC[material, energy] and XRayMEAC[material, energy] interpolate the tables of x-ray mass attenuation coefficients μ/ρ (MAC) and mass energy-absorption coefficients (Subscript[μ, en])/ρ (MEAC), respectively, given in NIST report 5632 by J. Hubbell and S.M. Seltzer.

?XRayMAC
?XRayMEAC

XRayMAC[Hydrogen, 1. Kilo ElectronVolt]
XRayMEAC[Hydrogen, 1. Kilo ElectronVolt]

The input material must be one of the first 92 elements, from hydrogen through uranium, or one of the 48 additional radiological materials covered in the report. The names of the elements are taken from the Miscellaneous`ChemicalElements` package in order to be consistent with that pakage. One can also use the alternative names or spellings defined in that package.

Take[Elements, 92]

The 48 additonal radiological materials covered by the tables are given below.

?RadiologicalMaterials
RadiologicalMaterials

Shorter, equivalent names are defined for some of the additional radiological materials.

?A150
?TissueEquivalentPlastic
?Air
?B100
?BoneEquivalentPlastic
?Blood
?Bone
?Brain
?Breast
?C552
?AirEquivalentPlastic
?Concrete
?StandardFricke
?Pyrex
?Lung
?Muscle
?KodakEmulsion
?NuclearEmulsion
?Vinyltoluene
?Mylar
?Teflon
?Water

The NIST tables list coefficients as (cm^2)/g against energy in MeV, but for all of the functions defined in this package input energy can, and indeed must, be entered with one of the units recognized by the Miscellaneous`Units` package.

XRayMAC[Air, 1.*^-13 Joule]
XRayMEAC[Water, 1.*^-6 Erg]

The output of these first two functions is mass density (cm^2)/g, but can be changed to any other appropriate mass density units with the Convert[old, new] command.

XRayMAC[Air, 1. Kilo ElectronVolt]
Convert[%, Meter^2 / (Kilogram)]

The x-ray attenuation mean free path λ (AMFP) corresponding to the x-ray mass attenuation coefficient μ/ρ and the x-ray energy-absorption mean free path (Subscript[λ, en]) (EAMFP) corresponding to the x-ray mass energy-absorption coefficient (Subscript[μ, en])/ρ are given by the two functions XRayAMFP[material, energy] and XRayEAMFP[material, energy], respectively, defined in the package. The output of these two functions has the units of length. The default is centimeters, but as above can be changed with the Convert[old, new] funcion.

?XRayAMFP
?XRayEAMFP

XRayAMFP[Hydrogen, 1. Kilo ElectronVolt]
XRayEAMFP[Hydrogen, 1. Kilo ElectronVolt]

Convert[%, Inch]

The function XRayTransmission[material, energy, thickness], defined in the package, gives the total fracional transmission of x-rays of a specified energy through a specified thickness of a material. Note that the thickness arguement, just as the energy arguement , must be given with units recognized by the Miscellaneous`Units` package. The output of this function is a dimensionless fraction.

?XRayTransmission

XRayTransmission[Lead, 1. Mega ElectronVolt, 5. Milli Meter]

In a similar manner, the function XRayAbsorption[material, energy, thickness], defined in the package, gives the total fracional absorption of x-rays of a specified energy in a specified thickness of a material. The output of this function is also a dimensionless fraction.

?XRayAbsorption

XRayAbsorption[Lead, 1. Mega ElectronVolt, 5. Milli Meter]

Note that both of the functions XRayTransmission and XRayAbsorption return the fraction of the number of x-rays. To obtain the transmitted or absorbed energy, multiply by the x-ray energy:

xRayEnergy = 1. Mega ElectronVolt;

xRayEnergy * XRayTransmission[Lead, xRayEnergy, 5. Milli Meter]
xRayEnergy * XRayAbsorption[Lead, xRayEnergy, 5. Milli Meter]

Clear[xRayEnergy];

Warning messages

All of these functions try to identify improper input, such as specifying a material not included in the table, specifying an energy outside of the table range of 1 keV to 20 MeV, or specifying improper units for energy or thickness.

XRayMAC[Uranium, 25. Mega ElectronVolt]

XRayMEAC[Beer, 1. Mega ElectronVolt]

XRayAMFP[Hydrogen, 1. Meter]

XRayEAMFP[Hydrogen, 1.]

XRayTransmission[Lead, 1. Mega ElectronVolt, 5. Joule]

XRayAbsorption[Lead, 1. Mega ElectronVolt, 5.]

Mixtures and compounds

The x-ray mass attenuation coefficient of an homogenous mixture of any of the 140 materials coverd by the tables can be calculated with the function MixtureMAC[mixture, energy]. A mixture is defined by the form {{material1, fraction1}, {material2, fraction2}, ...}. Each material must be one of the elements or radiological materials covered by the tables. Each fraction is the faction by weight for that material in the mixture. For convenience, the fractions are each divided by the sum of all fractions in the mixture, so that they need not add to one. In a similar manner, the x-ray attenuation mean free path of a mixture is given by MixtureAMFP[mixture, density, energy]. Here one must also input the density of the mixture, with proper density units. Finally, the total fracional transmission of x-rays through a mixture is given by MixtureTransmission[mixture, density, energy, thickness]. This funcion also requires the thickness of the mixture, input with thickness units.

?MixtureMAC

?MixtureAMFP

?MixtureTransmission

The following is an example for naval brass, which is nominally 60 % copper, 39.25 % zinc, and 0.75 % tin by weight and has a density of approximately 525 lb/(ft^3).

navalBrass = {{Copper, 0.60}, {Zinc, 0.3925}, {Tin, 0.0075}}

navalBrassDensity = 525. Pound / Foot^3

Convert[MixtureMAC[navalBrass, 100. Kilo ElectronVolt], Foot^2 / Pound]

Convert[MixtureAMFP[navalBrass, navalBrassDensity, 100. Kilo ElectronVolt], Inch]

MixtureTransmission[navalBrass, navalBrassDensity, 100. Kilo ElectronVolt, 0.1 Inch]

Clear[navalBrass];

Clear[navalBrassDensity];

The x-ray mass attenuation coefficient of chemical compounds can be calculated with the function CompoundMAC[compound, energy]. A compound is defined by the form {{element1, number1}, {element2, number2}, ...}. Each element must be one of the first 92 elements covered by the tables. Each number is the number of atoms of that element per molecule of the compound. In a similar manner, the x-ray attenuation mean free path of a chemical compound is given by CompoundAMFP[compound, density, energy]. Here one must also input the density of the chemical compound, with proper density units. Finally, the total fracional transmission of x-rays through a chemical compound is given by CompoundTransmission[compound, density, energy, thickness]. This funcion also requires the thickness of the chemical compound, input with thickness units.

?CompoundMAC

?CompoundAMFP

?CompoundTransmission

The following is an example for the polyimide film Kapton®, which has the nominal chemical formula (Subscript[(((Subscript[C, 22]) (Subscript[H, 10]) (Subscript[N, 2]) (Subscript[O, 4]))), n]) and a density of approximately 1.4 g/(cm^3).

kapton = {{Carbon, 22}, {Hydrogen, 10}, {Nitrogen, 2}, {Oxygen, 4}}

kaptonDensity = 1.4 Gram / (Centi Meter)^3

CompoundMAC[kapton, 50. Kilo ElectronVolt]

CompoundAMFP[kapton, kaptonDensity, 50. Kilo ElectronVolt]

CompoundTransmission[kapton, kaptonDensity, 50. Kilo ElectronVolt, 10. Milli Meter]

Clear[kapton];

Clear[kaptonDensity];

Warning messages for mixtures and compounds

The functions for mixtures try to identify improper input, such as an improper form for the mixture, specifying a material not included in the table, specifying a non-numerical value for any of the fractional weights, or specifying improper units for the energy, density, or thickness arguments.

MixtureMAC[Copper, 100. Kilo ElectronVolt]

MixtureAMFP[{{Cop, 0.60}, {Zinc, 0.3925}, {Tin, 0.0075}}, 525. Pound / Foot^3,
	100. Kilo ElectronVolt]

MixtureTransmission[{{Copper, x}, {Zinc, 0.3925}, {Tin, 0.0075}},
	525. Pound / Foot^3, 100. Kilo ElectronVolt, 0.1 Inch]

MixtureMAC[{{Copper, 0.60}, {Zinc, 0.3925}, {Tin, 0.0075}}, 100. Meter]

MixtureAMFP[{{Copper, 0.60}, {Zinc, 0.3925}, {Tin, 0.0075}}, 525. Pound,
	100. Kilo ElectronVolt]

MixtureTransmission[{{Copper, 0.60}, {Zinc, 0.3925}, {Tin, 0.0075}},
	525. Pound / Foot^3, 100. Kilo ElectronVolt, 0.1 Pound]

The functions for chemical compounds also try to identify improper input, such as an improper form for the compound, specifying a material which is not one of the first 92 elements, specifying a non-numerical value for any of the numbers, or specifying improper units for the energy, density, or thickness arguments.

CompoundMAC[Carbon, 50. Kilo ElectronVolt]

CompoundAMFP[{{Car, 22}, {Hydrogen, 10}, {Nitrogen, 2}, {Oxygen, 4}},
	1.11 Gram / (Centi Meter)^3, 50. Kilo ElectronVolt]

CompoundTransmission[{{Carbon, x}, {Hydrogen, 10}, {Nitrogen, 2}, {Oxygen, 4}},
	1.11 Gram / (Centi Meter)^3, 50. Kilo ElectronVolt, 10. Milli Meter]

CompoundMAC[{{Carbon, 22}, {Hydrogen, 10}, {Nitrogen, 2}, {Oxygen, 4}}, 100. Meter]

CompoundAMFP[{{Carbon, 22}, {Hydrogen, 10}, {Nitrogen, 2}, {Oxygen, 4}},
	1.11 Gram, 50. Kilo ElectronVolt]

CompoundTransmission[{{Carbon, 22}, {Hydrogen, 10}, {Nitrogen, 2}, {Oxygen, 4}},
	1.11 Gram / (Centi Meter)^3, 50. Kilo ElectronVolt, 10. Gram]

Converting x-ray wavelength or frequency to energy

Two functions defined in the package allow one to also use either the wave length or the frequency of the x-rays as an energy input.

?WaveLengthToEnergy
?FrequencyToEnergy

WaveLengthToEnergy[0.1 Nano Meter]
FrequencyToEnergy[1. Exa Hertz]

This is demonstarted in the following examples.

XRayMAC[Iron, WaveLengthToEnergy[0.1 Nano Meter]]
XRayMEAC[Concrete, FrequencyToEnergy[1. Exa Hertz]]

For the sake of completeness, the inverse functions are also defined in the package.

?EnergyToWaveLength
?EnergyToFrequency

EnergyToWaveLength[10. Kilo ElectronVolt]
EnergyToFrequency[10. Kilo ElectronVolt]

Making plots

As a final example, we can make plots for each material in the NIST report that show both the x-ray mass attenuation coefficients and mass energy-absorption coefficients over the entire range of the table. (These are similar to the plots for each material in the original report.) The plots will need the following standard add-on graphical packages to make a log-log list plot and to add a legend to the plot..

Needs["Graphics`Graphics`"];
Needs["Graphics`Legend`"];

We will first define a function to create a geometric, or logarithmic, list of energies for the log-log list plot.

geometricList[firstValue_, lastValue_, numberOfElements_] := 
	Module[ {multiplier},
		multiplier = (lastValue/firstValue)^(1/(numberOfElements-1)); 
		NestList[Function[x, multiplier*x], firstValue, (numberOfElements-1)]];

We then define a function to make a plot of the x-ray mass attenuation coefficients and the mass energy-absorption coefficients together for a specified material. The function uses the fact that the tables give the coefficients in (cm^2)/g against energy in MeV.

makeCoefficentPlot[material_] :=
	Module[
		{	legendOptions =
				Sequence[LegendPosition->{0.1, 0.2},
					LegendSize->{0.7, 0.2},
					LegendShadow->{0, 0}],
			plotEnergy = geometricList[0.001, 20., 400],
			redStyle = RGBColor[1, 0, 0],
			blueStyle = RGBColor[0, 0, 1],
			horizontalLine = Line[{{0, 0}, {1, 0}}],
			redLine,
			blueLine},
		redLine = Graphics[{redStyle, horizontalLine}];
		blueLine = Graphics[{blueStyle, horizontalLine}];
		ShowLegend[
			DisplayTogether[
				LogLogListPlot[Transpose[{plotEnergy,
					Map[XRayMAC[material, #] /
						(Centi^2 Meter^2 / Gram)&,
						plotEnergy * Mega * ElectronVolt]}],
					PlotJoined->True, GridLines->Automatic, PlotStyle->{blueStyle}],
				LogLogListPlot[Transpose[{plotEnergy,
					Map[XRayMEAC[material, #] /
						(Centi^2 Meter^2 / Gram)&,
						plotEnergy * Mega * ElectronVolt]}],
					PlotJoined->True, GridLines->Automatic, PlotStyle->{redStyle}],
				PlotRange->All, Frame->True, ImageSize->600, DisplayFunction->Identity,
				FrameLabel->{"Energy (MeV)", "Coefficient (cm^2/g)", material, ""}],
			{{{blueLine, "Attenuation"}, {redLine, "Energy Absorption"}}, legendOptions}]];

The plot for uranium shows the discontinuities at the many absorption edges and the nearly power-law behavior inbetween the edges. (Evaluate the following cell to see the graphics.)

makeCoefficentPlot[Uranium];

We can also define a similar function to make a plot of the x-ray attenuation mean free path and the energy-absorption mean free path together for a specified material.

makeMFPPlot[material_] :=
	Module[
		{legendOptions =
			Sequence[LegendPosition->{0.2, -0.3}, LegendSize->{0.7, 0.2},
				LegendShadow->{0, 0}],
			plotEnergy = geometricList[0.001, 20., 400],
			redStyle = RGBColor[1, 0, 0],
			blueStyle = RGBColor[0, 0, 1],
			horizontalLine = Line[{{0, 0}, {1, 0}}],
			redLine,
			blueLine},
		redLine = Graphics[{redStyle, horizontalLine}];
		blueLine = Graphics[{blueStyle, horizontalLine}];
		ShowLegend[
			DisplayTogether[
				LogLogListPlot[Transpose[{plotEnergy,
					Map[(XRayAMFP[material, #] / (Centi Meter))&,
						plotEnergy * Mega * ElectronVolt]}],
					PlotJoined->True, GridLines->Automatic, PlotStyle->{blueStyle}],
				LogLogListPlot[Transpose[{plotEnergy,
					Map[(XRayEAMFP[material, #] / (Centi Meter))&,
						plotEnergy * Mega * ElectronVolt]}],
					PlotJoined->True, GridLines->Automatic, PlotStyle->{redStyle}],
				PlotRange->All, Frame->True, ImageSize->600, DisplayFunction->Identity,
				FrameLabel->{"Energy (MeV)", "MFP (cm)", material, ""}],
			{{{blueLine, "Attenuation"}, {redLine, "Energy Absorption"}}, legendOptions}]];

The resulting mean free path plot is sort of an inverse of the coefficents plot above.  (Evaluate the following cell to see the graphics.)

makeMFPPlot[Uranium];

References

J. Hubbell and S.M. Seltzer, "Tables of X-Ray Mass Attenuation Coefficients and Mass Energy-Absorption Coefficients 1 keV to 20 MeV for Elements Z = 1 to 92 and 48 Additional Substances of Dosimetric Interest," National Institute of Standards and Technology report NISTIR 5632 (1995).
The data in this NIST report is also available on line at http://physics.nist.gov/PhysRefData/XrayMassCoef/cover.html.