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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["bornagain>=25,<26"]
# ///
"""
GISAS from rough interfaces with magnetic contrast.
A magnetic film and a non-magnetic substrate share a small nuclear SLD below
vacuum, keeping the magnetic roughness contrast prominent. The film
roughnesses share a frequency-dependent cross-correlation. Tilted spin
channels make the magnetic contrast visibly different.
"""
import bornagain as ba
ba.require_versions("bornagain>=25,<26")
from bornagain import R3, deg, nm
def get_sample():
sld_vacuum = (0.0, 0.0)
sld_film_substrate = (1e-6, 0.0)
color_ambient = (0.90, 0.93, 0.97)
color_film = (0.86, 0.24, 0.18)
color_substrate = (0.28, 0.57, 0.82)
magnetization_film = R3(0, 6.0e6, 0)
material_ambient = ba.RefractiveMaterial("Vacuum", color_ambient, *sld_vacuum)
material_film = ba.RefractiveMaterial(
"Film", color_film, *sld_film_substrate, magnetization_film)
material_substrate = ba.RefractiveMaterial("Substrate", color_substrate,
*sld_film_substrate)
transient = ba.TanhTransient()
autocorr = ba.SelfAffineFractalModel(1.3*nm, 0.65, 15*nm)
crosscorr = ba.SpatialFrequencyCrosscorrelation(45*nm, 0.03/nm, 2)
roughness = ba.Roughness(autocorr, transient, crosscorr)
sample = ba.Sample()
sample.addLayer(ba.Layer(material_ambient))
sample.addLayer(ba.Layer(material_film, 7*nm, roughness))
sample.addLayer(ba.Layer(material_substrate, roughness))
return sample
def get_simulation(sample, pol_dir, an_dir):
beam = ba.Beam(1, 0.1*nm, 0.25*deg, 0)
n = 160
detector = ba.SphericalDetector(n, -2*deg, 2*deg, n, 0, 2.5*deg)
beam.setPolarization(pol_dir)
detector.setAnalyzer(an_dir)
return ba.ScatteringSimulation(beam, sample, detector)
def simulate(pol_dir, an_dir, title):
sample = get_sample()
result = get_simulation(sample, pol_dir, an_dir).simulate()
result.setTitle(title)
return result
if __name__ == '__main__':
spin_up = R3(0, 0.6, 0.8)
spin_down = -spin_up
channels = [
("$++$", spin_up, spin_up),
("$+-$", spin_up, spin_down),
("$-+$", spin_down, spin_up),
("$--$", spin_down, spin_down),
]
results = [
simulate(pol_dir, an_dir, label)
for label, pol_dir, an_dir in channels
]
ba.showSample3D(get_sample(), sample_size=120*nm, seed=0)
vmax = max(max(result.flatVector()) for result in results)
vmin = vmax/1e8
clip = dict(intensity_min=vmin, intensity_max=vmax)
ba.plot2d_to_grid(results, 2, unit_aspect=1, **clip)
ba.plt.show()
|