Calculate k-ratiosΒΆ

This is a tutorial to calculate the Al, O and Si \(\text{K}\alpha\) k-ratios from a multilayer sample consisting of a Si substrate and 30-nm Al2O3 layer at an accelerating voltage of 15 kV.

Let’s start by importing the three classes that will later need: Sample, Experiment and Stratagem classes.

from stratagemtools.sample import Sample
from stratagemtools.experiment import Experiment
from stratagemtools.stratagem import Stratagem

The Sample class is used to define the composition of the substrate and the composition, thickness and mass thickness of each layer. In this example, we first define the substrate composition as follows:

sample = Sample({14: 1.0})

The argument {14: 1.0} defines the substrate composition, consisting of silicon (atomic number 14) and with a weight fraction of 1.0 (pure silicon). To help us define the layer composition, we can use the utility function composition_from_formula() in the sample module. The function returns the composition expressed in weight fraction for a given chemical formula.

from stratagemtools.sample import composition_from_formula
comp = composition_from_formula('Al2O3')

The calculated composition can then be used to define a layer, using the method add_layer. The thickness and density (taken from Wikipedia) are also specified. Note that the thickness is expressed in meters and the density in kilograms per cubic meter.

sample.add_layer(comp, 30e-9, density_kg_m3=3950.0)

The next step is to define Experiment‘s. Experiment specifies the experimental parameters used to analyze or to use to calculate the k-ratio of each element. As such, one experiment must be created for each element in the sample, whether or not it is analyzed or of interest to be calculated. For this example, the experiments are:

from stratagemtools.experiment import LINE_KA
energy_eV = 15e3
exp_si = Experiment(14, LINE_KA, energy_eV)
exp_al = Experiment(13, LINE_KA, energy_eV)
exp_o = Experiment(8, LINE_KA, energy_eV)

The constant LINE_KA is imported from the experiment module to specify the \(\text{K}\alpha\) X-ray line. For the moment, the standards (the denominator of the k-ratio) are all assumed to be pure sample, i.e. pure silicon, pure aluminum and (yes!) pure oxygen. The use of custom standards is addressed in another tutorial, Custom standard.

The Sample and Experiment objects should then be added to the Stratagem interface. The interface works as a context manager (with statement) in order to establish and properly close the connection to the STRATAGem’s DLL. All operations on a sample and experiments should be performed inside the with statement. The following lines of code set the sample, add the experiment and compute the k-ratios.

with Stratagem() as strata:
    strata.add_experiments(exp_si, exp_al, exp_o)
    kratios = strata.compute_kratios()

The compute_kratios method returns a dict where the keys are the experiments and the values, k-ratios. To help printing the results, the utility function symbol can be used to convert atomic number into element symbol.

import stratagemtools.element_properties as ep
for exp, kratio  in kratios.items():
    print('{0}: {1:.3f}'.format(ep.symbol(exp.z), kratio))

Going back to the with statement, it is advisable to always get the geometry, type of \(\phi(\rho z)\) and fluorescence flag, as the default values may be changed. stratagemtools relies on the default values from STRATAGem.

import math
from stratagemtools.stratagem import PRZMODE_XPP, FLUORESCENCE_LINE_CONT
with Stratagem() as strata:
    strata.set_geometry(math.radians(40), 0.0, 0.0)