|
| 1 | +.. _mu calc Example: |
| 2 | + |
| 3 | +:tocdepth: -1 |
| 4 | + |
| 5 | +Linear Absorption Coefficient (μ) Examples |
| 6 | +######################################### |
| 7 | + |
| 8 | +These examples will demonstrate how to calculate the Linear absorption |
| 9 | +coefficient, μ, using different methods provided in ``diffpy.utils``. |
| 10 | + |
| 11 | + |
| 12 | +.. admonition:: Methods for obtaining linear absorption coefficient |
| 13 | + |
| 14 | + Obtaining μ can be done in **two |
| 15 | + different ways** using ``diffpy.utils``. |
| 16 | + |
| 17 | + 1. **Using a "z-scan" measurement**: Perform a z-scan measurement |
| 18 | + on the sample and use ``diffpy.utils.tools.compute_mud`` to calculate |
| 19 | + μ. |
| 20 | + 2. **Using tabulated values**: Given composition, density, and X-ray energy, |
| 21 | + use ``diffpy.utils.tools.compute_mu_using_xraydb`` to calculate μ from |
| 22 | + tabulated values. |
| 23 | + |
| 24 | +Why is μ Important? |
| 25 | +----------------------- |
| 26 | + |
| 27 | +The linear absorption coefficient, μ, quantifies how much X-ray |
| 28 | +radiation is absorbed by a material per unit length. It is a critical |
| 29 | +parameter in many scientific techniques. |
| 30 | + |
| 31 | +For example, when calculating pair distribution functions (PDFs) |
| 32 | +using ``diffpy.pdfgetx``, |
| 33 | +a key assumption is that the linear absorption is negligible. |
| 34 | +This is frequently the case for high-energy X-rays. However, |
| 35 | +this must be corrected for when using low energy X-rays, such |
| 36 | +as those from a laboratory source. To correct for linear absorption, |
| 37 | +the linear absorption coefficient, μ, must be known. |
| 38 | + |
| 39 | +.. admonition:: Correcting for linear absorption with ``diffpy.labpdfproc`` |
| 40 | + |
| 41 | + If your objective is to correct for linear absorption in PDF calculations, |
| 42 | + please refer to our package ``diffpy.labpdfproc``. This package is specifically |
| 43 | + designed to correct your laboratory X-ray PDF data for absorption effects. |
| 44 | + More information can be found in the |
| 45 | + `diffpy.labpdfproc documentation <https://www.diffpy.org/diffpy.labpdfproc//>`_. |
| 46 | + |
| 47 | + |
| 48 | +Calculating μ from a "z-scan" Measurement |
| 49 | +----------------------------------------- |
| 50 | + |
| 51 | +.. note:: |
| 52 | + |
| 53 | + The data we will be using for this example can be found, |
| 54 | + `here <https://github.com/diffpy/diffpy.utils/tree/main/docs/source/examples/example_data>`_. |
| 55 | + |
| 56 | +A "z-scan" measurement is the measured transmission of your X-ray incident beam |
| 57 | +as a function of sample position. This is obtained by moving the sample |
| 58 | +perpendicular to the X-ray beam (z-direction) and recording the transmitted |
| 59 | +intensity at each position. This measured data looks something like this, |
| 60 | + |
| 61 | +.. image:: ../img/zscan-plot.png |
| 62 | + :alt: Example of a z-scan measurement. |
| 63 | + :align: center |
| 64 | + :width: 300px |
| 65 | + |
| 66 | +Using this z-scan data, you can calculate **μ·d**, where d is the inner diameter of |
| 67 | +your sample capillary. To do this, simply pass your z-scan measurement to the ``compute_mud`` |
| 68 | +function from the ``diffpy.utils.tools`` module. |
| 69 | + |
| 70 | + |
| 71 | +First, import the ``compute_mud`` function, |
| 72 | + |
| 73 | +.. code-block:: python |
| 74 | +
|
| 75 | + from diffpy.utils.tools import compute_mud |
| 76 | +
|
| 77 | +Next, pass the filepath to the function, |
| 78 | + |
| 79 | +.. code-block:: python |
| 80 | +
|
| 81 | + filepath = "CeO2_635um_zscan_200umSlit_chanClose_exported.xy" |
| 82 | + capillary_diameter = 0.5 # mm |
| 83 | + mud = compute_mud(filepath) |
| 84 | + print(f"Calculated mu*d: {round(mud, 3)}") |
| 85 | + print(f"Calculated mu: {round(mud / capillary_diameter, 3)} mm^-1") |
| 86 | +
|
| 87 | +This will output the calculated value of μ·d, which is unitless, and μ in mm\ :sup:`-1`. |
| 88 | + |
| 89 | +.. code-block:: console |
| 90 | +
|
| 91 | + Calculated mu*d: 3.489 |
| 92 | + Calculated mu: 6.977 mm^-1 |
| 93 | +
|
| 94 | +Calculating μ from Tabulated Values |
| 95 | +----------------------------------- |
| 96 | + |
| 97 | +The function to calculate μ from tabulated values is located |
| 98 | +in the ``diffpy.utils.tools`` module. So first, import the function, |
| 99 | + |
| 100 | +.. code-block:: python |
| 101 | +
|
| 102 | + from diffpy.utils.tools import compute_mu_using_xraydb |
| 103 | +
|
| 104 | +To calculate μ, you need to know the sample composition, and X-ray energy, and sample mass density (g/cm\ :sup:`3`). |
| 105 | + |
| 106 | +.. code-block:: python |
| 107 | +
|
| 108 | + composition = "Fe2O3" |
| 109 | + energy_keV = 17.45 # Mo K-alpha energy |
| 110 | + sample_mass_density = 5.24 # g/cm^3 |
| 111 | +
|
| 112 | +Now calculate μ using the ``compute_mu_using_xraydb`` function. |
| 113 | + |
| 114 | +.. code-block:: python |
| 115 | +
|
| 116 | + mu = compute_mu_using_xraydb(composition, energy_keV, sample_mass_density) |
| 117 | + print(f"Calculated mu: {round(mu, 3)} mm^-1") |
| 118 | +
|
| 119 | +This will output the calculated linear absorption coefficient, μ, in mm\ :sup:`-1`. |
| 120 | + |
| 121 | +.. code-block:: console |
| 122 | +
|
| 123 | + Calculated mu: 13.967 mm^-1 |
0 commit comments