BornAgain contains no material database or chemical formula parser. Scattering
length densities can instead be calculated in Python and passed to
SLDMaterial. The periodictable
package supplies chemical formulas, isotope data, and neutron and X-ray SLD
calculations.
periodictable is not a BornAgain dependency. Install it in the environment
that runs the calculation:
pip install periodictable
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},\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*ba.angstrom
sld_real, sld_imag, _incoherent = periodictable.neutron_sld(
"SiO2",
density=silica_density,
wavelength=neutron_wavelength/ba.angstrom)
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.
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*ba.angstrom # 8 keV
sld_real, sld_imag = periodictable.xray_sld(
"SiO2",
density=silica_density,
wavelength=xray_wavelength/ba.angstrom)
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,[\mathrm{Å}] = 12.398/E,[\mathrm{keV}]$.
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. SLDMaterial stores the calculated value; it does not
recalculate SLD when the wavelength changes within a scan. Use a fixed value
only when dispersion over the scan range is negligible.
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.
|
|