Reflectivity Q4

Result

Reflectivity Q4 result

Sample

Reflectivity Q4 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
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
Custom plot of specular reflectivity and R(qz)*qz^4.
"""
import numpy as np
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
from bornagain import nm


def get_sample():
    a_color = (0.05, 0.62, 0.55)
    a_mat = ba.SLDMaterial("A", a_color, 5e-06, 0)
    substrate_color = (0.28, 0.57, 0.82)
    substrate_mat = ba.SLDMaterial("Substrate", substrate_color, 2e-06, 0)

    sample = ba.Sample()
    sample.addLayer(ba.Layer(ba.Vacuum()))
    sample.addLayer(ba.Layer(a_mat, 30*nm))
    sample.addLayer(ba.Layer(substrate_mat))
    return sample


def get_simulation(sample):
    n = 500
    scan = ba.QzScan(np.linspace(0.01, 1, n))
    return ba.SpecularSimulation(scan, sample)


if __name__ == '__main__':
    # Create the sample and show its layer stack in interactive runs.
    sample = get_sample()
    ba.showSample3D(sample, sample_size=80*nm, seed=0)

    # Run the specular simulation.
    result = get_simulation(sample).simulate()

    # Prepare reflectivity and the Porod-scaled quantity.
    qz = np.asarray(result.xCenters())
    R = np.asarray(result.flatVector())
    Rq4 = R*qz**4


    # Plot R and R*qz^4 separately because their dimensions differ.
    fig, (ax_R, ax_Rq4) = ba.plt.subplots(1, 2, figsize=(11, 4))

    ba.plt.sca(ax_R)
    ba.plot_datafield(result,
                      title=r"$R(q_z)$",
                      ylabel="Reflectivity",
    )

    ba.plt.sca(ax_Rq4)
    ba.plot_array(Rq4,
                  result.frame(),
                  title=r"$R(q_z)\,q_z^4$",
                  ylabel=r"$R(q_z)\,q_z^4$ (nm$^{-4}$)",
    )

    fig.tight_layout()
    ba.plt.show()
auto/Examples/specular/basics/ReflectivityQ4.py