Skip to content
Snippets Groups Projects
Commit 0627f8e5 authored by Yurov, Dmitry's avatar Yurov, Dmitry
Browse files

Add example for polarized reflectometry

parent c83caf27
No related branches found
No related tags found
No related merge requests found
"""
An example of computing reflectivity on a
magnetized sample.
"""
import bornagain as ba
from bornagain import deg, angstrom
def get_sample():
"""
Defines sample and returns it
"""
# creating materials
m_ambient = ba.MaterialBySLD("Ambient", 0.0, 0.0)
m_layer_mat = ba.MaterialBySLD("Layer", 1e-4, 1e-8,
ba.kvector_t(0.0, 1e8, 0.0))
m_substrate = ba.MaterialBySLD("Substrate", 7e-5, 2e-6)
# creating layers
ambient_layer = ba.Layer(m_ambient)
layer = ba.Layer(m_layer_mat, 10)
substrate_layer = ba.Layer(m_substrate)
# creating multilayer
multi_layer = ba.MultiLayer()
multi_layer.addLayer(ambient_layer)
multi_layer.addLayer(layer)
multi_layer.addLayer(substrate_layer)
return multi_layer
def get_simulation(scan_size=500):
"""
Defines and returns a specular simulation.
"""
simulation = ba.SpecularSimulation()
scan = ba.AngularSpecScan(1.54 * angstrom, scan_size,
0.0 * deg, 5.0 * deg)
simulation.setScan(scan)
return simulation
def run_simulation(polarization=ba.kvector_t(0.0, 1.0, 0.0),
analyzer=ba.kvector_t(0.0, 1.0, 0.0)):
"""
Runs simulation and returns its result.
"""
sample = get_sample()
simulation = get_simulation()
# adding polarization and analyzer operator
simulation.setBeamPolarization(polarization)
simulation.setAnalyzerProperties(analyzer, 1.0, 0.5)
simulation.setSample(sample)
simulation.runSimulation()
return simulation.result()
def plot(pp, mm):
from matplotlib import pyplot as plt
ba.plot_simulation_result(pp, postpone_show=True)
plt.semilogy(mm.axis(), mm.array())
plt.legend(['Up-Up', 'Down-Down'],
loc='upper right')
plt.show()
if __name__ == '__main__':
results_pp = run_simulation(ba.kvector_t(0.0, 1.0, 0.0),
ba.kvector_t(0.0, 1.0, 0.0))
results_mm = run_simulation(ba.kvector_t(0.0, -1.0, 0.0),
ba.kvector_t(0.0, -1.0, 0.0))
plot(results_pp, results_mm)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment