Wavelength-dependent neutron SLD

Neutron reflectivity of a Gd film on Si in a wavelength scan. The SLDs of both materials are tabulated with periodictable. For comparison, a second simulation uses one-row tables, that is, the SLDs at a single wavelength.

See wavelength-dependent materials for the table format and interpolation options.

Result

Gd film reflectivity with spectral and fixed SLD

Python script

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26", "periodictable"]
# ///
"""
Neutron reflectivity of a Gd film on Si with wavelength-dependent SLDs.
Compare with SLDs fixed at 0.475 nm.
"""
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
import numpy as np
import periodictable
from bornagain import angstrom, deg, nm


def neutron_table(formula, density, wavelengths):
    # periodictable uses angstroms and returns SLD in 10^-6 A^-2.
    rows = []
    for wavelength in wavelengths:
        real, absorption, incoherent = periodictable.neutron_sld(
            formula, density=density, wavelength=wavelength/angstrom)
        rows.append((wavelength, real*1e-6, absorption*1e-6))
    return np.array(rows)


def get_sample(wavelengths):
    vacuum = ba.Vacuum()

    # Several wavelengths give tables, a single one gives constant SLDs.
    gadolinium_color = (0.8, 0.35, 0.2)
    gadolinium = ba.SLDMaterial("Gd", gadolinium_color,
                                neutron_table("Gd", 7.9, wavelengths))
    silicon_color = (0.65, 0.75, 0.85)
    silicon = ba.SLDMaterial("Si", silicon_color,
                             neutron_table("Si", 2.33, wavelengths))

    vacuum_layer = ba.Layer(vacuum)
    gadolinium_layer = ba.Layer(gadolinium, 20*nm)
    substrate = ba.Layer(silicon)

    sample = ba.Sample()
    sample.addLayer(vacuum_layer)
    sample.addLayer(gadolinium_layer)
    sample.addLayer(substrate)
    return sample


def simulate(sample):
    n_points = 401
    scan = ba.LambdaScan(n_points, 0.1*nm, 0.8*nm)
    scan.setGrazingAngle(0.5*deg)
    simulation = ba.SpecularSimulation(scan, sample)
    return simulation.simulate()


if __name__ == "__main__":
    spectral_sample = get_sample(np.linspace(0.1*nm, 0.8*nm, 201))
    fixed_sample = get_sample(np.array([0.475])*nm)
    spectral_result = simulate(spectral_sample)
    fixed_result = simulate(fixed_sample)
    spectral_result.setTitle("Wavelength-dependent SLDs")
    fixed_result.setTitle("SLDs fixed at 0.475 nm")

    results = [spectral_result, fixed_result]
    ba.plot_multicurve(results, legendloc="lower right")
    ba.plt.show()
auto/Examples/specular/instrument/SpectralSLD.py