Specular with slicing 3

Result

Specular with slicing 3 result

Sample

Specular with slicing 3 sample

Python script

 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
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
Specular reflectometry with hand-averaged SLD layers (no particles).

Instead of explicit particles with setNumberOfSlices, N homogeneous SLD
layers with the volume-averaged scattering length density replace the
sliced-particle layer. Results must agree with SpecularWithSlicing2.py.
"""
from math import pi
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
from bornagain import angstrom, deg, nm

HEIGHT = 5 * nm
RADIUS = 5 * nm
SURF_DENSITY = 0.01   # nm^-2
N_SLICES = 3
WAVELENGTH = 1.54 * angstrom


def _sld(delta, beta):
    """
    Convert refractive index (delta, beta) to SLD (Å⁻²) at WAVELENGTH.
    """
    f = pi * angstrom**2 / WAVELENGTH**2
    return (2*delta - delta**2 + beta**2) * f, (2*beta - 2*delta*beta) * f


def get_sample():
    vacuum = ba.Vacuum()
    sub_re, sub_im = _sld(6e-6, 2e-8)
    par_re, par_im = _sld(6e-4, 2e-8)

    # Effective volume fraction of cylinders in each slice
    eff_vol = SURF_DENSITY * pi * RADIUS**2
    avr_re = eff_vol * par_re
    avr_im = eff_vol * par_im

    substrate_color = (0.28, 0.57, 0.82)
    substrate_mat = ba.SLDMaterial("Substrate", substrate_color, sub_re, sub_im)
    avr_color = (0.05, 0.62, 0.55)
    avr_mat = ba.SLDMaterial("Avr", avr_color, avr_re, avr_im)

    sample = ba.Sample()
    sample.addLayer(ba.Layer(vacuum))
    for _ in range(N_SLICES):
        sample.addLayer(ba.Layer(avr_mat, HEIGHT / N_SLICES))
    sample.addLayer(ba.Layer(substrate_mat))
    return sample


def get_simulation(sample):
    n = 500
    scan = ba.AlphaScan(n, 5*deg/n, 5*deg)
    scan.setWavelength(WAVELENGTH)
    return ba.SpecularSimulation(scan, sample)


if __name__ == '__main__':
    sample = get_sample()
    ba.showSample3D(sample, sample_size=120*nm, seed=0)
    simulation = get_simulation(sample)
    result = simulation.simulate()
    ba.plot_datafield(result)
    ba.plt.show()
auto/Examples/specular/interfaces/SpecularWithSlicing3.py