Pass a table to SLDMaterial or RefractiveMaterial when the optical
constants vary over the wavelengths of a calculation. Each material takes
its own table; grids, lengths, and ranges may differ between materials.
For SLD, each row contains wavelength in nm, real SLD in Å⁻², and
nonnegative absorption in Å⁻². As for constant SLD, the physical SLD is
real - 1j*absorption:
table = [
(0.1, 2.0e-6, 1.0e-8),
(0.3, 3.0e-6, 1.5e-8),
(0.8, 4.0e-6, 2.0e-8),
]
material = ba.SLDMaterial("Film", (0.8, 0.3, 0.2), table)
For a refractive index, each row contains wavelength in nm, δ, and β, where n = 1 − δ + iβ:
table = [
(0.1, 2.0e-6, 1.0e-8),
(0.3, 4.0e-6, 2.0e-8),
(0.8, 1.0e-5, 4.0e-8),
]
material = ba.RefractiveMaterial("Film", (0.8, 0.3, 0.2), table)
Lists, tuples, and NumPy arrays are accepted; the data are copied, and the rows may come in any order. A table needs at least one row, finite values, positive wavelengths that occur once each, and nonnegative imaginary parts. A single row gives a constant material.
The optional magnetization follows the table, and the interpolation and extrapolation methods come last:
material = ba.SLDMaterial(name, color, table)
material = ba.SLDMaterial(name, color, table, magnetization)
material = ba.SLDMaterial(name, color, table, magnetization, "linear", "error")
material = ba.SLDMaterial(name, color, table, "linear", "error")
material = ba.RefractiveMaterial(name, color, table)
material = ba.RefractiveMaterial(name, color, table, magnetization)
material = ba.RefractiveMaterial(name, color, table, magnetization,
"linear", "error")
material = ba.RefractiveMaterial(name, color, table, "linear", "error")
| Argument | Default |
|---|---|
magnetization |
zero R3 vector, in A/m |
interpolation |
"steffen" |
extrapolation |
"error" |
These constructors accept positional arguments only.
"steffen" is a smooth monotone interpolation, "linear" a linear one;
see the GSL interpolation reference.
By default, a wavelength outside a table, also one introduced by beam
resolution, raises an error naming the material and its range. With
"constant" extrapolation, the nearest endpoint value of the supplied
quantity holds outside the table:
material = ba.SLDMaterial(name, color, table, "steffen", "constant")
Tables can come from measurements, databases, or calculations. For text
files with three whitespace-separated columns, wavelength, SLD, and
absorption in sld.txt, or wavelength, δ, and β in index.txt:
table = np.loadtxt("sld.txt", ndmin=2)
material = ba.SLDMaterial("Film", color, table)
table = np.loadtxt("index.txt", ndmin=2)
material = ba.RefractiveMaterial("Film", color, table)
A function can likewise be sampled on a chosen wavelength grid. See materials from chemical formulas for periodictable’s units and conventions.
The examples show a neutron Gd film and an X-ray scan across the Ni absorption edge, each compared with optical constants fixed at one wavelength, given as one-row tables; neutron and X-ray spectra from periodictable; and depth profiles of a Gd/Sm multilayer at three wavelengths.
During a simulation, each material is evaluated at every wavelength used by the beam and its resolution distribution; resolution then averages the intensities. Volume averages evaluate their constituents before combining the squared refractive indices.
This requires a physical wavelength, as given by LambdaScan or
AlphaScan. QzScan specifies none and therefore needs constant SLDs in
the layers, also after averaging particles. A material profile of tabulated
or mixed materials requires an explicit wavelength.