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
|
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
Off-specular scan of a rough surface at constant two-theta.
Each incident angle is paired with one outgoing angle: alpha_f = 2theta - alpha_i.
"""
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
import numpy as np
from bornagain import deg, nm
def get_sample():
substrate_color = (0.3, 0.5, 0.7)
substrate = ba.RefractiveMaterial("Substrate", substrate_color, 3.5e-6,
1e-8)
autocorr = ba.SelfAffineFractalModel(0.3*nm, 0.8, 100*nm)
roughness = ba.Roughness(autocorr, ba.TanhTransient())
sample = ba.Sample()
sample.addLayer(ba.Layer(ba.Vacuum()))
sample.addLayer(ba.Layer(substrate, roughness))
return sample
def get_simulation(sample):
alpha_i = np.linspace(0.02, 0.78, 381)*deg
two_theta = 0.8*deg
alpha_f = two_theta - alpha_i
scan = ba.AlphaScan(alpha_i)
scan.setWavelength(0.154*nm)
scan.setIntensity(1e8)
detector = ba.SlitOffspecDetector(
alpha_f, alpha_width=0.008*deg, phi_min=-0.1*deg, phi_max=0.1*deg)
simulation = ba.OffspecSimulation(scan=scan, sample=sample, detector=detector)
simulation.options().setIncludeSpecular(True)
return simulation
if __name__ == '__main__':
sample = get_sample()
result = get_simulation(sample).simulate()
ba.showSample3D(sample, sample_size=300*nm, seed=0)
ba.plot_datafield(result, title='Constant 2θ = 0.8°')
ba.plt.show()
|