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
|
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
Compare the roughness approximations for a gold surface.
The approximations are discussed by Kozhevnikov and Pyatakhin, "Use of DWBA
and perturbation theory in X-ray control of the surface roughness",
J. X-Ray Sci. Technol. 8, 253-275.
The optical constants are calculated from CXRO Au scattering factors at
lambda=0.154 nm, density=19.3 g/cm^3:
https://henke.lbl.gov/optical_constants/sf/au.nff
"""
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
from bornagain import deg, nm
WAVELENGTH = 0.154*nm
SIGMA = 1*nm
XI = 1000*nm
DELTA = 4.706272993680498e-5
BETA = 4.841358699064536e-6
TERMS = 64
MODES = [('FullDWBA', TERMS, 'FullDWBA', 'black'),
('LowerField', TERMS, 'LowerField', 'tab:blue'),
('UpperField', TERMS, 'UpperField', 'tab:green'),
('FullDWBA', 1, 'FullDWBA, one term', 'tab:purple'),
('HeightPerturbation', 1, 'HeightPerturbation', 'tab:orange')]
def get_sample():
gold_color = (0.9, 0.7, 0.2)
gold = ba.RefractiveMaterial('Gold', gold_color, DELTA, BETA)
model = ba.PoweredExponentialModel(SIGMA, 0.5, XI, float('inf'))
roughness = ba.Roughness(model, ba.ErfTransient())
sample = ba.Sample()
sample.addLayer(ba.Layer(ba.Vacuum()))
sample.addLayer(ba.Layer(gold, roughness))
return sample
def calculate(alpha_i, approximation, terms):
points = 240
scan = ba.AlphaScan([alpha_i])
scan.setWavelength(WAVELENGTH)
detector = ba.OffspecDetector(points, 0.02*deg, 2*deg, -5*deg, 5*deg)
simulation = ba.OffspecSimulation(scan, get_sample(), detector)
options = simulation.options()
options.setDwbaReferenceWaves('Sharp')
options.setRoughnessApproximation(approximation, terms)
result = simulation.simulate().flat()
# Divide by the bin width: intensity per radian of exit angle.
bin_width = (2 - 0.02)*deg/points
return ba.Datafield(result.frame(),
[v/bin_width for v in result.flatVector()])
if __name__ == '__main__':
ba.showSample3D(get_sample(), sample_size=120*nm, seed=0)
fig = ba.plt.figure(figsize=(10, 4.8), layout='constrained')
axes = fig.subplots(1, 2)
for axis, alpha_i in zip(axes.flat, [0.3*deg, 0.8*deg]):
for approximation, terms, label, color in MODES:
ba.plot_curve(calculate(alpha_i, approximation, terms),
ax=axis,
label=label,
ylabel='Diffuse intensity per radian',
lineargs={'color': color})
axis.set_title(rf'$\alpha_i={alpha_i/deg:g}^\circ$')
fig.legend(*axes.flat[0].get_legend_handles_labels(),
loc='outside upper center',
ncol=5,
frameon=False)
ba.plt.show()
|