# Custom standard¶

This tutorial shows how to use different standards in the definition of the Experiment. The possibly to easily define standards is certainly an interesting feature of stratagemtools, in comparison to the graphical interface of STRATAGem where the standards must be manually defined and saved in separate files.

In stratagemtools, a standard is a Sample. Any sample definition can be used as a standard, as long as the composition and thickness of every layer are known. This example shows how to use three different standards to calculate the Al, O and Si $$\text{K}\alpha$$ k-ratios from the previous tutorial, Calculate k-ratios.

We import the same packages and constants as the last tutorial

import math
from stratagemtools.sample import Sample, composition_from_formula
from stratagemtools.experiment import Experiment, LINE_KA
from stratagemtools.stratagem import Stratagem, PRZMODE_XPP, FLUORESCENCE_LINE_CONT
import stratagemtools.element_properties as ep


and create the unknown sample, a 30-nm Al2O3 layer over a Si substrate

unknown = Sample({14: 1.0})
comp = composition_from_formula('Al2O3')


Now we define three standards, Fe2O3, SiO2 and Al2O3:

std_fe2o3 = Sample(composition_from_formula('Fe2O3'), density_kg_m3=5240.0)
std_sio2 = Sample(composition_from_formula('SiO2'), density_kg_m3=2650.0)
std_al2o3 = Sample(composition_from_formula('Al2O3'), density_kg_m3=3950.0)


We then create experiments for Si and Al using the new standards. Note that in the previous tutorial pure standards were assumed.

energy_eV = 15e3
exp_si = Experiment(14, LINE_KA, energy_eV, standard=std_sio2)
exp_al = Experiment(13, LINE_KA, energy_eV, standard=std_al2o3)


For the O $$\text{K}\alpha$$, all three standards can be used. To illustrate how easy it is to change the standard, we will loop over the standards and define a new experiment using each standard. This gives

with Stratagem() as strata:
strata.set_prz_mode(PRZMODE_XPP)
strata.set_fluorescence(FLUORESCENCE_LINE_CONT)

for std_name, std_o in [('Fe2O3', std_fe2o3),
('SiO2', std_sio2),
('Al2O3', std_al2o3)]:
exp_o = Experiment(8, LINE_KA, energy_eV, standard=std_o)

strata.reset()
strata.set_sample(unknown)