import numpy as np
import escape as esc
esc.require("0.9.8")
Off-specular reflectivity. Tungsten/silicon multilayer.¶
Ten periods of tungsten and silicon on silicon, Cu Kα. The interfaces share a Lagally roughness. Where the vertical momentum transfer meets a Bragg condition, the diffuse waves add in phase and the intensity gathers into a Bragg sheet.
The measured counts are the sum of that diffuse part and the specular reflectivity,
I = I_beam · footprint(αᵢ) · [ Δ_det · (2π / sin αᵢ) · D + F(α_f − αᵢ) · R(qz) ].
esc.offspecrefl returns D in the X-ray Server normalization. The curves in data/ were generated once from this model, with Poisson noise, and saved. Every parameter below is free.
The files were generated with W = 15 Å, Si = 35 Å, σ = 4 Å, ξ = 300 Å, Hurst exponent 1, L_v = 2000 Å, I_beam = 10⁸, Qmax = 0.03211 Å⁻¹, a detector acceptance of 0.04° and a specular width of 0.05°. The fit starts away from those values. ξ is used both for each interface and for the correlation between interfaces.
wavelength = 1.540562
src = esc.xrays(wavelength, units="angstrom")
degree = np.pi / 180.0
wave = 2.0 * np.pi / src.wavelength
repeats = 10
thickness_w = esc.par("W thickness", 13.0, units="Å", userlim=[8.0, 25.0])
thickness_si = esc.par("Si thickness", 38.0, units="Å", userlim=[20.0, 60.0])
sigma = esc.par("Roughness", 3.0, units="Å", userlim=[0.5, 8.0])
lateral = esc.par("Lateral correlation", 200.0, units="Å", userlim=[50.0, 3000.0])
hurst = esc.par("Hurst", 0.8, userlim=[0.2, 1.0])
vertical = esc.par("Vertical correlation", 1200.0, units="Å", userlim=[100.0, 20000.0])
Tungsten and silicon come from the material database. The same Lagally roughness is used on the tungsten, on the silicon in the period, and on the substrate.
tungsten = esc.amorphous("W", density="mdb", density_fixed=True, name="W")
silicon = esc.amorphous("Si", density="mdb", density_fixed=True, name="Si")
tungsten_rough = esc.lagally_roughness(sigma, lateral, hurst, lateral, vertical, name="W roughness")
silicon_rough = esc.lagally_roughness(sigma, lateral, hurst, lateral, vertical, name="Si roughness")
substrate_rough = esc.lagally_roughness(sigma, lateral, hurst, lateral, vertical, name="Substrate roughness")
period = esc.layer_stack(repeat=repeats, name="W/Si")
period.add(esc.layer(tungsten, thickness_w, tungsten_rough, name="W"))
period.add(esc.layer(silicon, thickness_si, silicon_rough, name="Si"))
sample = esc.multilayer(
name="W/Si x10",
frgr=esc.air("Air"),
bkgr=esc.substrate(silicon, substrate_rough, name="Substrate"),
)
sample.add(period)
sample.show(source=src)
The generated curves used a beam 0.2 mm high and a 2 inch wafer, which fixes Qmax = 4π h / (λ L) = 0.03211 Å⁻¹. Below Qmax the footprint is q / Qmax, with q = 2k sin αᵢ. The fit starts from a different Qmax, acceptance and specular width. I_beam is stored in units of 10⁸ counts.
I_beam = esc.par("I_beam", 0.7, scale=1.0e8, userlim=[0.1, 5.0])
Qmax = esc.par("Qmax", 0.04, units="1/Å", userlim=[0.005, 0.2])
acceptance = esc.par("Detector acceptance", 0.06, units="deg", userlim=[0.01, 0.25])
width = esc.par("Specular width", 0.08, units="deg", userlim=[0.01, 0.4])
angle = esc.var("angle")
q_angle = 2.0 * wave * esc.sin(angle * degree)
illuminated = esc.conditional(q_angle > Qmax, 1.0, q_angle / Qmax)
illuminated.show(coordinates=np.linspace(0.01, 1.0, 200)).config(
xlabel="incident angle [deg]", ylabel="illuminated fraction",
)
Rocking curves at the Bragg peaks¶
Each file is θ, counts and the counting error. The first line records the detector angle 2θ of that curve: the Bragg angle of the sample that generated the data. α_f = 2θ − θ, so the scan stays on one Bragg sheet. The three models share the sample parameters and are shown together.
two_theta_1 = float(np.genfromtxt("data/rocking_1.txt", max_rows=1, dtype=str, comments=None)[-1])
angle_1, counts_1, errors_1 = np.loadtxt("data/rocking_1.txt", unpack=True)
theta_1 = esc.var("theta")
alpha_i_1 = theta_1 * degree
alpha_f_1 = (two_theta_1 - theta_1) * degree
q_i_1 = 2.0 * wave * esc.sin(alpha_i_1)
illuminated_1 = esc.conditional(q_i_1 > Qmax, 1.0, q_i_1 / Qmax)
diffuse_1 = esc.offspecrefl(
wave * (esc.cos(alpha_f_1) - esc.cos(alpha_i_1)),
wave * esc.sin(alpha_i_1),
wave * esc.sin(alpha_f_1),
sample,
source=src,
formalism="full",
name="Rocking curve, order 1",
)
specular_1 = esc.specrefl(wave * (esc.sin(alpha_i_1) + esc.sin(alpha_f_1)), sample, source=src)
transmission_1 = esc.exp(-4.0 * np.log(2.0) * ((alpha_f_1 - alpha_i_1) / (width * degree)) ** 2)
rock_1 = I_beam * illuminated_1 * (
acceptance * degree * 2.0 * np.pi / esc.sin(alpha_i_1) * diffuse_1
+ transmission_1 * specular_1
)
rock_data_1 = esc.data(angle_1.copy(), counts_1.copy(), errors_1.copy(), copy=True, name="Rocking curve, order 1")
rock_model_1 = esc.model(
rock_1, rock_data_1, residuals_scale="none", weight_type="data",
normalize_cost=True, name="Rocking curve, order 1",
)
two_theta_2 = float(np.genfromtxt("data/rocking_2.txt", max_rows=1, dtype=str, comments=None)[-1])
angle_2, counts_2, errors_2 = np.loadtxt("data/rocking_2.txt", unpack=True)
theta_2 = esc.var("theta")
alpha_i_2 = theta_2 * degree
alpha_f_2 = (two_theta_2 - theta_2) * degree
q_i_2 = 2.0 * wave * esc.sin(alpha_i_2)
illuminated_2 = esc.conditional(q_i_2 > Qmax, 1.0, q_i_2 / Qmax)
diffuse_2 = esc.offspecrefl(
wave * (esc.cos(alpha_f_2) - esc.cos(alpha_i_2)),
wave * esc.sin(alpha_i_2),
wave * esc.sin(alpha_f_2),
sample,
source=src,
formalism="full",
name="Rocking curve, order 2",
)
specular_2 = esc.specrefl(wave * (esc.sin(alpha_i_2) + esc.sin(alpha_f_2)), sample, source=src)
transmission_2 = esc.exp(-4.0 * np.log(2.0) * ((alpha_f_2 - alpha_i_2) / (width * degree)) ** 2)
rock_2 = I_beam * illuminated_2 * (
acceptance * degree * 2.0 * np.pi / esc.sin(alpha_i_2) * diffuse_2
+ transmission_2 * specular_2
)
rock_data_2 = esc.data(angle_2.copy(), counts_2.copy(), errors_2.copy(), copy=True, name="Rocking curve, order 2")
rock_model_2 = esc.model(
rock_2, rock_data_2, residuals_scale="none", weight_type="data",
normalize_cost=True, name="Rocking curve, order 2",
)
two_theta_3 = float(np.genfromtxt("data/rocking_3.txt", max_rows=1, dtype=str, comments=None)[-1])
angle_3, counts_3, errors_3 = np.loadtxt("data/rocking_3.txt", unpack=True)
theta_3 = esc.var("theta")
alpha_i_3 = theta_3 * degree
alpha_f_3 = (two_theta_3 - theta_3) * degree
q_i_3 = 2.0 * wave * esc.sin(alpha_i_3)
illuminated_3 = esc.conditional(q_i_3 > Qmax, 1.0, q_i_3 / Qmax)
diffuse_3 = esc.offspecrefl(
wave * (esc.cos(alpha_f_3) - esc.cos(alpha_i_3)),
wave * esc.sin(alpha_i_3),
wave * esc.sin(alpha_f_3),
sample,
source=src,
formalism="full",
name="Rocking curve, order 3",
)
specular_3 = esc.specrefl(wave * (esc.sin(alpha_i_3) + esc.sin(alpha_f_3)), sample, source=src)
transmission_3 = esc.exp(-4.0 * np.log(2.0) * ((alpha_f_3 - alpha_i_3) / (width * degree)) ** 2)
rock_3 = I_beam * illuminated_3 * (
acceptance * degree * 2.0 * np.pi / esc.sin(alpha_i_3) * diffuse_3
+ transmission_3 * specular_3
)
rock_data_3 = esc.data(angle_3.copy(), counts_3.copy(), errors_3.copy(), copy=True, name="Rocking curve, order 3")
rock_model_3 = esc.model(
rock_3, rock_data_3, residuals_scale="none", weight_type="data",
normalize_cost=True, name="Rocking curve, order 3",
)
print(f"order 1: 2θ = {two_theta_1:.4f}°, {len(angle_1)} points")
print(f"order 2: 2θ = {two_theta_2:.4f}°, {len(angle_2)} points")
print(f"order 3: 2θ = {two_theta_3:.4f}°, {len(angle_3)} points")
rock_stack = esc.modelstack(
[rock_model_1, rock_model_2, rock_model_3], name="Rocking curves",
)
rock_stack.show().config_model(ylog=True, xlabel="θ [deg]", ylabel="Counts")
order 1: 2θ = 1.8820°, 241 points order 2: 2θ = 3.5928°, 241 points order 3: 2θ = 5.3216°, 241 points
Detector scan¶
The incident angle is the first Bragg angle of the generated sample, recorded on the first line of the file. The exit angle runs from 0.05° to 5°. The specular spike is the first-order Bragg reflection, and the diffuse intensity spikes again on the second and third Bragg sheets.
incidence = float(np.genfromtxt("data/detector.txt", max_rows=1, dtype=str, comments=None)[-1])
exit_values, detector_counts, detector_errors = np.loadtxt("data/detector.txt", unpack=True)
exit_angle = esc.var("exit")
alpha_i_det = esc.func(exit_angle, incidence * degree)
alpha_f_det = exit_angle * degree
q_i_det = 2.0 * wave * esc.sin(alpha_i_det)
illuminated_det = esc.conditional(q_i_det > Qmax, 1.0, q_i_det / Qmax)
diffuse_det = esc.offspecrefl(
wave * (esc.cos(alpha_f_det) - esc.cos(alpha_i_det)),
wave * esc.sin(alpha_i_det),
wave * esc.sin(alpha_f_det),
sample,
source=src,
formalism="full",
name="Detector scan",
)
specular_det = esc.specrefl(
wave * (esc.sin(alpha_i_det) + esc.sin(alpha_f_det)), sample, source=src,
)
transmission_det = esc.exp(-4.0 * np.log(2.0) * ((alpha_f_det - alpha_i_det) / (width * degree)) ** 2)
detector = I_beam * illuminated_det * (
acceptance * degree * 2.0 * np.pi / esc.sin(alpha_i_det) * diffuse_det
+ transmission_det * specular_det
)
detector_data = esc.data(
exit_values.copy(), detector_counts.copy(), detector_errors.copy(),
copy=True, name="Detector scan",
)
detector_model = esc.model(
detector, detector_data, residuals_scale="none", weight_type="data",
normalize_cost=True, name="Detector scan",
)
print(f"incidence = {incidence:.4f}°, {len(exit_values)} points")
detector_model.show().config(ylog=True, xlabel="exit angle [deg]", ylabel="Counts")
incidence = 0.9410°, 331 points
Map of the two angles¶
a_in and a_out each run from 0.20° to 4.20° on an 81 by 81 grid. The file stores one point per row. A two-axis dataset interleaves the coordinates in alphabetical variable-name order, so each point is (a_in, a_out). This model is fitted on its own, after the scans.
a_in_values, a_out_values, map_counts, map_errors = np.loadtxt("data/map.txt", unpack=True)
map_coordinates = np.column_stack([a_in_values, a_out_values]).ravel().copy()
a_in = esc.var("a_in")
a_out = esc.var("a_out")
alpha_i_map = a_in * degree
alpha_f_map = a_out * degree
q_i_map = 2.0 * wave * esc.sin(alpha_i_map)
illuminated_map = esc.conditional(q_i_map > Qmax, 1.0, q_i_map / Qmax)
diffuse_map = esc.offspecrefl(
wave * (esc.cos(alpha_f_map) - esc.cos(alpha_i_map)),
wave * esc.sin(alpha_i_map),
wave * esc.sin(alpha_f_map),
sample,
source=src,
formalism="full",
name="Angle map",
)
specular_map = esc.specrefl(
wave * (esc.sin(alpha_i_map) + esc.sin(alpha_f_map)), sample, source=src,
)
transmission_map = esc.exp(-4.0 * np.log(2.0) * ((alpha_f_map - alpha_i_map) / (width * degree)) ** 2)
angle_map = I_beam * illuminated_map * (
acceptance * degree * 2.0 * np.pi / esc.sin(alpha_i_map) * diffuse_map
+ transmission_map * specular_map
)
map_data = esc.data(
map_coordinates, map_counts.copy(), map_errors.copy(), copy=True, name="Angle map",
)
map_model = esc.model(
angle_map, map_data, residuals_scale="none", weight_type="data",
normalize_cost=True, name="Angle map",
)
map_model.show().config(cblog=True, xlabel="incidence [deg]", ylabel="exit [deg]")
The three rocking curves and the detector scan are one fit. σ sets the specular decay and the diffuse level, ξ how far the sheets extend from the specular condition, and L_v how much of the diffuse intensity sits in the sheets. The thicknesses move the Bragg angles relative to the fixed detector positions. I_beam, the acceptance and the specular width share the intensity scale; Qmax bends the curves only below the cover angle.
scan_stack = esc.modelstack(
[rock_model_1, rock_model_2, rock_model_3, detector_model],
name="W/Si scans",
)
opt_scans = esc.levmar(
scan_stack,
xtol=1.0e-8, ftol=1.0e-10, gtol=1.0e-8, maxiter=40, maxfev=200,
nupdate=5, epsfcn=1.0e-7,
)
#opt_scans()
print(opt_scans.status_msg, "cost", opt_scans.best_cost)
print(
"W", thickness_w.value, "Si", thickness_si.value,
"roughness", sigma.value, "lateral", lateral.value, "hurst", hurst.value,
"vertical", vertical.value,
)
print(
"I_beam", I_beam.value, "Qmax", Qmax.value,
"acceptance", acceptance.value, "width", width.value,
)
opt_scans.show().config_model(
ylog=True,
xlabel=["θ [deg]", "θ [deg]", "θ [deg]", "exit angle [deg]"],
ylabel="Counts",
)
cost inf W 13.0 Si 38.0 roughness 3.0 lateral 200.0 hurst 0.8 vertical 1200.0 I_beam 70000000.0 Qmax 0.04 acceptance 0.06 width 0.08
opt_scans
Name: Levenberg-Marquardt Parameters number: 12 Parameter Value +- Error Units Fixed I_beam 0.99987 +- 0.00015413 x1e+08 0 Qmax 0.032536 +- 9.0538e-05 1/Å 0 Detector acceptance 0.040073 +- 5.0378e-05 deg 0 W density 19.3 +- 0 g/cm^3 1 W thickness 15.003 +- 0.002228 Å 0 Roughness 3.9998 +- 0.0010255 Å 0 Lateral correlation 299.73 +- 0.28009 Å 0 Hurst 1 +- 0.0021074 0 Vertical correlation 1997.3 +- 7.0071 Å 0 Si density 2.33 +- 0 g/cm^3 1 Si thickness 34.996 +- 0.0020825 Å 0 Specular width 0.05 +- 1.8672e-06 deg 0
Map fit¶
The angle map is a second fit of the same parameters. It starts from the values found on the rocking curves and the detector scan.
opt_map = esc.levmar(
map_model,
xtol=1.0e-8, ftol=1.0e-10, gtol=1.0e-8, maxiter=5, maxfev=60,
nupdate=1, epsfcn=1.0e-7,
)
#opt_map()
print(opt_map.status_msg, "cost", opt_map.best_cost)
print(
"W", thickness_w.value, "Si", thickness_si.value,
"roughness", sigma.value, "lateral", lateral.value, "hurst", hurst.value,
"vertical", vertical.value,
)
print(
"I_beam", I_beam.value, "Qmax", Qmax.value,
"acceptance", acceptance.value, "width", width.value,
)
opt_map.show().config_model(cblog=True, xlabel="incidence [deg]", ylabel="exit [deg]")
cost inf W 15.003165575892348 Si 34.99619402224058 roughness 3.9997641551863214 lateral 299.7289569383054 hurst 1.0 vertical 1997.2574441258457 I_beam 99987153.02578068 Qmax 0.03253596958957789 acceptance 0.04007279123777755 width 0.04999952611721886
opt_map
Name: Levenberg-Marquardt Parameters number: 12 Parameter Value +- Error Units Fixed I_beam 0.99987 +- 0.00015413 x1e+08 0 Qmax 0.032536 +- 9.0538e-05 1/Å 0 Detector acceptance 0.040073 +- 5.0378e-05 deg 0 W density 19.3 +- 0 g/cm^3 1 W thickness 15.003 +- 0.002228 Å 0 Roughness 3.9998 +- 0.0010255 Å 0 Lateral correlation 299.73 +- 0.28009 Å 0 Hurst 1 +- 0.0021074 0 Vertical correlation 1997.3 +- 7.0071 Å 0 Si density 2.33 +- 0 g/cm^3 1 Si thickness 34.996 +- 0.0020825 Å 0 Specular width 0.05 +- 1.8672e-06 deg 0