Mathematica Scripts

X-ray Powder Diffraction in Education

May 17, 2023

A collection of user-friendly, interactive, and freely distributable Mathematica (Wolfram Research, 2022) teaching scripts for visualizing various contributions to the peak profile and peak intensity in a powder diffraction pattern in terms of physical models was developed. In particular, the so-called “Manipulate” command is extensively used to visualize the impact of parameters in an interactive manner. When possible, parameter values from real-life examples are given as the default inputs. The idea is to “learn by doing”; one may gain intuition for how a given mathematical model performs for describing diffraction peaks in an experimental powder pattern and what are the limitations of said model. Every model is an oversimplification of the underlying physics, but different models can be useful for studying various phenomena or increasing the precision of the investigation.
The first collection of scripts deals with the various contributions to the peak profile in a powder diffraction pattern1 while the second set of scripts visualizes the complex atomic form factor for angular and energy dispersive X-ray diffraction and the displacement factor due to thermal motion, as well as various correction factors for step-scan and integrated intensities (Fig. 1). In addition, the intensity distribution of a powder pattern is demonstrated for a nanocrystalline material, following two alternative approaches based on: (i) structure factor and common volume function (CVF), including the effect of small angle scattering for spherical particles, and (ii) total scattering from a single crystallite, with atomic distances used in the Debye scattering equation (DSE).

Donwload the corrected paper here

Second paper

This article is the second part of a series dealing with the 
description and visualization of mathematical functions used to 
describe a powder diffraction pattern for teaching and education 
purposes. The first part dealt with the instrumental and sample 
contributions to the profile of a Bragg peak [Dinnebier & Scardi 
(2021). J. Appl. Cryst. 54, 1811–1831]. The second part, here, deals 
with the mathematics and physics of the intensity in X-ray powder 
diffraction. Scholarly scripts are again provided using the Wolfram 
language in Mathematica.

Read the paper online


  1. Unpack the files scripts1.rar and scripts2.rar
  2. Run all *_general.nb files in Mathematica to create *_general.m files
    in the subdirectory "Applications" of the path $UserBaseDirectory.
  3. Now all other *.nb files can be run

Be aware that some files need some time to run. Be patient.


Scripts 1

Scripts 2

Go to Editor View