Polarized Q angle reflectivity

Result

Polarized Q angle reflectivity result

Sample

Polarized Q angle reflectivity 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
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
Polarized neutron reflectometry of a simple magnetic layer in Q-space.

Two-channel (PP, MM) Q-scan with Y-axis polarization.
Results must agree with BasicSpecular.py (angle-scan equivalent).
"""
from math import pi, sin
import numpy as np
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
from bornagain import angstrom, deg, nm, R3


def get_sample():
    vacuum = ba.Vacuum()
    layer_color = (0.86, 0.24, 0.18)
    layer_mat = ba.SLDMaterial("MagLayer", layer_color, 1e-4, 1e-8,
                                    R3(0, 1e8, 0))
    substrate_color = (0.28, 0.57, 0.82)
    substrate_mat = ba.SLDMaterial("Substrate", substrate_color, 7e-5, 2e-6)

    sample = ba.Sample()
    sample.addLayer(ba.Layer(vacuum))
    sample.addLayer(ba.Layer(layer_mat, 10*nm))
    sample.addLayer(ba.Layer(substrate_mat))
    return sample


def simulate(sample, pol, an, title):
    n = 500
    lam = 1.54*angstrom
    qs = [4*pi*sin(a)/lam
          for a in np.linspace(5*deg/n, 5*deg, n)]
    scan = ba.QzScan(qs)
    scan.setPolarization(pol)
    scan.setAnalyzer(an)
    result = ba.SpecularSimulation(scan, sample).simulate()
    result.setTitle(title)
    return result


if __name__ == '__main__':
    sample = get_sample()
    ba.showSample3D(sample, sample_size=80*nm, seed=0)
    results = [
        simulate(sample, R3(0, +1, 0), R3(0, +1, 0), "PP"),
        simulate(sample, R3(0, -1, 0), R3(0, -1, 0), "MM"),
    ]
    ba.plot_multicurve(results)
    ba.plt.show()
auto/Examples/specular/magnetic/PolarizedQAngleReflectivity.py