### Spin-flip reflectivity

In this section, we want to extend the basic polarized reflectometry tutorial to simulate spin-flip reflectivity. For this purpose, we want to parametrize the magnetization by the angle $\alpha$ between the magnetization and the spin of the incoming neutrons and its magnitude $\left| \mathbf{M} \right|$: $$\mathbf M = \left| \mathbf{M} \right| \left( \sin \alpha, \cos \alpha, 0\right)^\mathrm{T}$$ In practice, the construction of the magnetization vector in Python then proceeds as follows:

magnetizationMagnitude = 1e8
angle                  = 30 * deg
magnetizationVector    = R3(
magnetizationMagnitude * numpy.sin(angle),
magnetizationMagnitude * numpy.cos(angle),
0)


In addition to the non-spin-flip channels, we simulate the spin-flip channels (up-down and down-up) with the following function calls

results_pm = run_simulation(R3(0,  1, 0),
R3(0, -1, 0))
results_mp = run_simulation(R3(0, -1, 0),
R3(0,  1, 0))


Running the full script that is given below, we obtain the following simulation result:

This plot shows the resulting reflectivity in all four channels. The non-spin-flip channels (up-up and down-down) are similar to the result without spin flip. As expected, both spin-flip channels are identical.

Here is the complete example:

  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 84 85  #!/usr/bin/env python3 """ An example of computing splin-flip reflectivity from a magnetized sample. """ from math import sqrt import bornagain as ba from bornagain import angstrom, ba_plot as bp, deg, nm, R3 import matplotlib.pyplot as plt def get_sample(): """ Defines sample and returns it """ # Define materials material_Ambient = ba.MaterialBySLD("Ambient", 0, 0) h = 1e8 magnetic_field = R3(1/2*h, sqrt(3)/2*h, 0) material_Layer = ba.MaterialBySLD("Layer", 0.0001, 1e-08, magnetic_field) material_Substrate = ba.MaterialBySLD("Substrate", 7e-05, 2e-06) # Define layers layer_1 = ba.Layer(material_Ambient) layer_2 = ba.Layer(material_Layer, 10*nm) layer_3 = ba.Layer(material_Substrate) # Define sample sample = ba.MultiLayer() sample.addLayer(layer_1) sample.addLayer(layer_2) sample.addLayer(layer_3) return sample def run_simulation(sample, polarizer_dir=R3(0, 1, 0), analyzer_dir=R3(0, 1, 0)): """ Runs simulation and returns its result. """ scan = ba.AlphaScan(500, 5*deg/500, 5*deg) scan.setWavelength(1.54*angstrom) scan.setPolarization(polarizer_dir) scan.setAnalyzer(analyzer_dir, 1, 0.5) simulation = ba.SpecularSimulation(scan, sample) return simulation.simulate() def plot(data, labels): plt.figure() plt.yscale('log') for d, l in zip(data, labels): plt.plot(d.convertedBinCenters(), d.array(), label=l, linewidth=1) plt.legend(loc='upper right') bp.inside_ticks() plt.xlabel(r"$\alpha_{\rm i} \;(^\circ)$") plt.ylabel("Reflectivity") plt.tight_layout() if __name__ == '__main__': bp.parse_args() sample = get_sample() results_pp = run_simulation(sample, R3(0, 1, 0), R3(0, 1, 0)) results_mm = run_simulation(sample, R3(0, -1, 0), R3(0, -1, 0)) results_pm = run_simulation(sample, R3(0, 1, 0), R3(0, -1, 0)) results_mp = run_simulation(sample, R3(0, -1, 0), R3(0, 1, 0)) plot([results_pp, results_mm, results_pm, results_mp], ["$++$", "$--$", "$+-$", "$-+$"]) bp.show_or_export() 
Examples/specular/PolarizedSpinFlip.py