Debian Codegraph @

rawEx/specular/SpecularWithSlicing2Q.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 """
3 Specular reflectometry with sliced cylinders (Q-scan variant).
4
5 Same sample as SpecularWithSlicing2.py but the scan axis is q_z
6 instead of incident angle.
7 """
8 from math import pi, sin
9 import numpy as np
10 import bornagain as ba
11 from bornagain import angstrom, ba_plot as bp, deg, nm
12
13 HEIGHT = 5 * nm
14 RADIUS = 5 * nm
15 SURF_DENSITY = 0.01 # nm^-2
16 N_SLICES = 3
17 WAVELENGTH = 1.54 * angstrom
18
19
20 def _sld(delta, beta):
21 """Convert refractive index (delta, beta) to SLD (Å⁻²) at WAVELENGTH."""
22 f = pi * angstrom**2 / WAVELENGTH**2
23 return (2*delta - delta**2 + beta**2) * f, (2*beta - 2*delta*beta) * f
24
25
26 def get_sample():
27 vacuum = ba.Vacuum()
28 sub_re, sub_im = _sld(6e-6, 2e-8)
29 par_re, par_im = _sld(6e-4, 2e-8)
30
31 substrate_color = (0.28, 0.57, 0.82)
32 substrate_mat = ba.SLDMaterial("Substrate", substrate_color, sub_re, sub_im)
33 particle_color = (0.86, 0.24, 0.18)
34 particle_mat = ba.SLDMaterial("Particle", particle_color, par_re, par_im)
35
36 cylinder = ba.Cylinder(RADIUS, HEIGHT)
37 particle = ba.Particle(particle_mat, cylinder)
38
39 top_layer = ba.Layer(vacuum)
40 top_layer.deposit2D(ba.Dilute2D(SURF_DENSITY, particle))
41 top_layer.setNumberOfSlices(N_SLICES)
42
43 sample = ba.Sample()
44 sample.addLayer(top_layer)
45 sample.addLayer(ba.Layer(substrate_mat))
46 return sample
47
48
49 def get_simulation(sample):
50 n = <%= test_mode ? 50 : 500 %>
51 lam = WAVELENGTH
52 qs = [4*pi*sin(a)/lam for a in np.linspace(5*deg/n, 5*deg, n)]
53 scan = ba.QzScan(qs)
54 return ba.SpecularSimulation(scan, sample)
55
56
57 <%= include_partial("template/main/runsim.py",
58 "ba.showSample3D(sample, sample_size=120*nm, seed=0)") -%>