Debian Codegraph @

rawEx/specular/PolarizedFeNiBilayerSpinFlipTanh.py

raw symbols SCIP
1 #!/usr/bin/env python3
2 """
3 Polarized neutron reflectometry of a 4x Fe/Ni bilayer on Au substrate
4 with TanhTransient interface roughness.
5
6 Four-channel (PP, PM, MP, MM) angle-scan. The Fe magnetization is
7 rotated 38 deg from the Y axis, enabling spin-flip scattering (PM, MP
8 non-zero).
9 See PolarizedFeNiBilayerTanh.py for the two-channel variant
10 (0 deg tilt, PM=MP=0).
11
12 Compare PolarizedFeNiBilayerSpinFlipTanhQ.py for the Q-space equivalent.
13 """
14 from math import cos, sin
15 import bornagain as ba
16 from bornagain import angstrom, ba_plot as bp, deg, nm, R3
17
18
19 def get_sample():
20 vacuum = ba.Vacuum()
21 mag_vec = R3(sin(38*deg), cos(38*deg), 0) * 1e7
22 fe_color = (0.48, 0.32, 0.80)
23 fe_mat = ba.SLDMaterial("Fe", fe_color, 8.02e-6, 0, mag_vec)
24 ni_color = (0.93, 0.48, 0.14)
25 ni_mat = ba.SLDMaterial("Ni", ni_color, 9.4245e-6, 0)
26 substrate_color = (0.93, 0.72, 0.25)
27 substrate_mat = ba.SLDMaterial("Au", substrate_color, 4.6665e-6, 0)
28
29 autocorr = ba.SelfAffineFractalModel(0.2*nm, 0.7, 25*nm)
30 roughness = ba.Roughness(autocorr, ba.TanhTransient())
31
32 stack = ba.LayerStack(4)
33 stack.addLayer(ba.Layer(fe_mat, 10*nm, roughness))
34 stack.addLayer(ba.Layer(ni_mat, 4*nm, roughness))
35
36 sample = ba.Sample()
37 sample.addLayer(ba.Layer(vacuum))
38 sample.addStack(stack)
39 sample.addLayer(ba.Layer(substrate_mat, roughness))
40 return sample
41
42
43 def simulate(sample, pol, an, title):
44 n = <%= test_mode ? 50 : 500 %>
45 scan = ba.AlphaScan(n, 5*deg/n, 5*deg)
46 scan.setWavelength(1.54*angstrom)
47 scan.setPolarization(pol)
48 scan.setAnalyzer(an)
49 result = ba.SpecularSimulation(scan, sample).simulate()
50 result.setTitle(title)
51 return result
52
53
54 if __name__ == '__main__':
55 sample = get_sample()
56 <%- unless test_mode || figure_mode -%>
57 ba.showSample3D(sample, sample_size=120*nm, seed=0)
58 <%- end -%>
59 results = [
60 simulate(sample, R3(0, +1, 0), R3(0, +1, 0), "PP"),
61 simulate(sample, R3(0, +1, 0), R3(0, -1, 0), "PM"),
62 simulate(sample, R3(0, -1, 0), R3(0, +1, 0), "MP"),
63 simulate(sample, R3(0, -1, 0), R3(0, -1, 0), "MM"),
64 ]
65 <%= include_partial("template/main/plot_multicurve.py") -%>