Materials from chemical formulas

BornAgain contains no material database or chemical formula parser. Scattering length densities and refractive indices can instead be calculated in Python and passed to SLDMaterial or RefractiveMaterial. The periodictable package supplies chemical formulas, isotope data, and neutron and X-ray optical constants.

periodictable is not a BornAgain dependency. Install it in the environment that runs the calculation:

pip install periodictable

Neutron SLD

periodictable.neutron_sld expects density in g/cm³ and wavelength in angstroms. It returns the real, absorption, and incoherent SLD components in units of $10^{-6}\thinspace\mathrm{Å}^{-2}$. BornAgain has no separate incoherent SLD component.

import bornagain as ba
import periodictable

silica_density = 2.2  # g/cm^3
neutron_wavelength = 4.75  # angstroms

sld_real, sld_imag, _incoherent = periodictable.neutron_sld(
    "SiO2",
    density=silica_density,
    wavelength=neutron_wavelength)

material = ba.SLDMaterial(
    "SiO2 for neutrons", (0.65, 0.75, 0.85), sld_real*1e-6, sld_imag*1e-6)

The second returned component is the nonnegative absorption magnitude, which matches the sld_imag convention of SLDMaterial.

X-ray SLD

The X-ray calculation uses the same density and output units:

import bornagain as ba
import periodictable

silica_density = 2.2  # g/cm^3
xray_wavelength = 1.5498  # angstroms (8 keV)

sld_real, sld_imag = periodictable.xray_sld(
    "SiO2",
    density=silica_density,
    wavelength=xray_wavelength)

material = ba.SLDMaterial(
    "SiO2 for X-rays", (0.65, 0.75, 0.85), sld_real*1e-6, sld_imag*1e-6)

For X-rays, wavelength and energy are related by $\lambda\thinspace[\mathrm{Å}] = 12.398/E\thinspace[\mathrm{keV}]$.

X-ray refractive index

periodictable.xsf.index_of_refraction returns the complex index $n = 1 - \delta - i\beta$ for the same density and wavelength inputs. RefractiveMaterial takes δ and β:

import bornagain as ba
from periodictable import xsf

silica_density = 2.2  # g/cm^3
xray_wavelength = 1.5498  # angstroms (8 keV)

index = xsf.index_of_refraction(
    "SiO2", density=silica_density, wavelength=xray_wavelength)
delta = 1 - index.real
beta = -index.imag

material = ba.RefractiveMaterial(
    "SiO2 for X-rays", (0.65, 0.75, 0.85), delta, beta)

Physical inputs and limitations

Mass density is required because a chemical formula alone does not specify material phase, porosity, or density. Isotopic formulas follow periodictable’s formula syntax.

For most nuclei the neutron SLD is wavelength-independent, but strong or resonant absorbers can be energy-dependent. X-ray SLD is generally wavelength-dependent. When constructed with scalar values, SLDMaterial keeps them fixed throughout a scan. Use a fixed value only when dispersion over the scan range is negligible.

For varying optical constants, evaluate periodictable on a wavelength grid and pass the triples to the table constructors.

For interactive exploration, the same calculations are available through online interfaces:

Both use the periodictable package, so matching values check the formula, density, wavelength, and unit conversion rather than independently validating the underlying atomic data. The first calculator returns inverse square angstroms, which are the input units of SLDMaterial.

Complete example

Open the complete example.