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
|
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
from bornagain import deg, nm
def get_sample():
# Define materials
hmdso_color = (0.25, 0.65, 0.35)
hmdso_mat = ba.RefractiveMaterial("HMDSO", hmdso_color, 2.0888e-06, 1.3261e-08)
ptfe_color = (0.93, 0.72, 0.25)
ptfe_mat = ba.RefractiveMaterial("PTFE", ptfe_color, 5.20509e-06, 1.9694e-08)
si_color = (0.30, 0.62, 0.86)
si_mat = ba.RefractiveMaterial("Si", si_color, 5.7816e-06, 1.0229e-07)
vacuum_mat = ba.Vacuum()
# Define roughness
autocorr_1 = ba.SelfAffineFractalModel(1.1, 0.3, 5*nm)
autocorr_2 = ba.SelfAffineFractalModel(2.3, 0.3, 5*nm)
transient = ba.TanhTransient()
roughness_1 = ba.Roughness(autocorr_1, transient)
roughness_2 = ba.Roughness(autocorr_2, transient)
# Define layers
layer_1 = ba.Layer(vacuum_mat)
layer_2 = ba.Layer(hmdso_mat, 18.5*nm, roughness_1)
layer_3 = ba.Layer(ptfe_mat, 22.1*nm, roughness_2)
layer_4 = ba.Layer(si_mat)
# Define sample
sample = ba.Sample()
sample.addLayer(layer_1)
sample.addLayer(layer_2)
sample.addLayer(layer_3)
sample.addLayer(layer_4)
return sample
def get_simulation(sample):
beam = ba.Beam(1e9, 0.1*nm, 0.4*deg)
n = 200
detector = ba.SphericalDetector(n, -2*deg, 2*deg, n, -.6*deg, 1.4*deg)
detector.setResolutionFunction(
ba.ResolutionFunction2DGaussian(0.02*deg, 0.02*deg))
simulation = ba.ScatteringSimulation(beam, sample, detector)
simulation.options().setIncludeSpecular(True)
return simulation
if __name__ == '__main__':
sample = get_sample()
ba.showSample3D(sample, sample_size=500*nm, seed=0)
simulation = get_simulation(sample)
result = simulation.simulate()
ba.plot_datafield(result, unit_aspect=1, log_range=8)
ba.plt.show()
|