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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26", "periodictable"]
# ///
"""
Compare rough Gd/Sm multilayer depth profiles at several wavelengths.
"""
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
import numpy as np
import periodictable
from bornagain import angstrom, 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()
# Densities in g/cm^3.
gd_color = (0.17, 0.63, 0.17)
sm_color = (1.0, 0.5, 0.05)
si_color = (0.12, 0.47, 0.71)
gadolinium = ba.SLDMaterial("Gd", gd_color,
neutron_table("Gd", 7.9, wavelengths))
samarium = ba.SLDMaterial("Sm", sm_color,
neutron_table("Sm", 7.52, wavelengths))
silicon = ba.SLDMaterial("Si", si_color,
neutron_table("Si", 2.33, wavelengths))
autocorrelation = ba.SelfAffineFractalModel(1*nm, 0.5, 10*nm)
transition = ba.TanhTransient()
roughness = ba.Roughness(autocorrelation, transition)
vacuum_layer = ba.Layer(vacuum)
gadolinium_layer = ba.Layer(gadolinium, 8*nm, roughness)
samarium_layer = ba.Layer(samarium, 12*nm, roughness)
substrate = ba.Layer(silicon, roughness)
stack = ba.LayerStack(num_periods=3)
stack.addLayer(gadolinium_layer)
stack.addLayer(samarium_layer)
sample = ba.Sample()
sample.addLayer(vacuum_layer)
sample.addStack(stack)
sample.addLayer(substrate)
return sample
def plot_profiles(sample, wavelengths):
depth_count = 401
profiles = []
for wavelength in wavelengths:
depths, profile = ba.materialProfile(
sample, depth_count, wavelength=wavelength)
profiles.append(profile)
ba.plt.plot(depths, profile.real*1e6,
label=f"{wavelength/nm:g} nm")
ba.plt.xlabel("z (nm)")
ba.plt.ylabel(r"Real SLD ($10^{-6}$ Å$^{-2}$)")
ba.plt.legend(title="Wavelength")
return profiles
if __name__ == "__main__":
sample = get_sample(np.linspace(0.1*nm, 0.8*nm, 71))
ba.plt.rcParams["font.size"] = 16
ba.plt.figure(figsize=(10, 5))
profile_wavelengths = np.array([0.1, 0.475, 0.75])*nm
profiles = plot_profiles(sample, profile_wavelengths)
ba.plt.title("Rough Gd/Sm multilayer: real SLD depth profiles")
ba.plt.tight_layout()
ba.showSample3D(sample, sample_size=100*nm, seed=0)
ba.plt.show()
|