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

Amended reflectometry examples to correspond to the web-site content

Redmine: #2081
parent 305070e8
No related branches found
No related tags found
No related merge requests found
...@@ -2,60 +2,51 @@ ...@@ -2,60 +2,51 @@
Basic example of specular simulation with BornAgain. Basic example of specular simulation with BornAgain.
""" """
import numpy
import bornagain as ba import bornagain as ba
from bornagain import deg, angstrom, nm from bornagain import deg, angstrom
alpha_i_min, alpha_i_max = 0.0, 2.0 # incoming beam
def get_sample(): def get_sample():
""" """
Returns a sample with two layers on a substrate, with correlated roughnesses. Defines sample and returns it
""" """
m_ambience = ba.HomogeneousMaterial("ambience", 0.0, 0.0)
m_part_a = ba.HomogeneousMaterial("PartA", 5e-6, 0.0)
m_part_b = ba.HomogeneousMaterial("PartB", 10e-6, 0.0)
m_substrate = ba.HomogeneousMaterial("substrate", 15e-6, 0.0)
l_ambience = ba.Layer(m_ambience)
l_part_a = ba.Layer(m_part_a, 5.0*nm)
l_part_b = ba.Layer(m_part_b, 10.0*nm)
l_substrate = ba.Layer(m_substrate)
roughness = ba.LayerRoughness()
roughness.setSigma(1.0*nm)
roughness.setHurstParameter(0.3)
roughness.setLatteralCorrLength(500.0*nm)
my_sample = ba.MultiLayer()
# adding layers # creating materials
my_sample.addLayer(l_ambience) m_ambient = ba.MaterialBySLD("Ambient", 0.0, 0.0)
m_ti = ba.MaterialBySLD("Ti", -1.9493e-06, 0.0)
m_ni = ba.MaterialBySLD("Ni", 9.4245e-06, 0.0)
m_substrate = ba.MaterialBySLD("SiSubstrate", 2.0704e-06, 0.0)
n_repetitions = 10 # creating layers
for i in range(n_repetitions): ambient_layer = ba.Layer(m_ambient)
my_sample.addLayerWithTopRoughness(l_part_a, roughness) ti_layer = ba.Layer(m_ti, 30 * angstrom)
my_sample.addLayerWithTopRoughness(l_part_b, roughness) ni_layer = ba.Layer(m_ni, 70 * angstrom)
substrate_layer = ba.Layer(m_substrate)
my_sample.addLayerWithTopRoughness(l_substrate, roughness) # creating multilayer
multi_layer = ba.MultiLayer()
multi_layer.addLayer(ambient_layer)
for i in range(10):
multi_layer.addLayer(ti_layer)
multi_layer.addLayer(ni_layer)
multi_layer.addLayer(substrate_layer)
return my_sample return multi_layer
def get_simulation(): def get_simulation():
""" """
Returns a specular simulation with beam and detector defined. Defines and returns a specular simulation.
""" """
simulation = ba.SpecularSimulation() simulation = ba.SpecularSimulation()
simulation.setBeamParameters( simulation.setBeamParameters(
1.54*angstrom, 500, alpha_i_min*deg, alpha_i_max*deg) 1.54 * angstrom, 500, 0.0 * deg, 2.0 * deg)
return simulation return simulation
def run_simulation(): def run_simulation():
""" """
Runs simulation and returns it. Runs simulation and returns its result.
""" """
sample = get_sample() sample = get_sample()
simulation = get_simulation() simulation = get_simulation()
......
...@@ -49,18 +49,6 @@ z_min = -100 * nm ...@@ -49,18 +49,6 @@ z_min = -100 * nm
z_max = 100 * nm z_max = 100 * nm
n_z_bins = 500 n_z_bins = 500
# refractive indices of sample materials
ref_indices = {"Si": [3.3009e-05, 0.0],
"Ti": [-3.0637e-05, 1.5278e-08],
"TiO2": [4.1921e-05, 8.1293e-09],
"Pt": [1.0117e-04, 3.01822e-08],
"D2O": [1.0116e-04, 1.8090e-12]}
def get_material(name):
return ba.HomogeneousMaterial(name, ref_indices[name][0],
ref_indices[name][1])
def get_sample(): def get_sample():
""" """
...@@ -68,18 +56,18 @@ def get_sample(): ...@@ -68,18 +56,18 @@ def get_sample():
""" """
# define materials # define materials
m_Si = get_material("Si") m_Si = ba.HomogeneousMaterial("Si", 3.3009e-05, 0.0)
m_Ti = get_material("Ti") m_Ti = ba.HomogeneousMaterial("Ti", -3.0637e-05, 1.5278e-08)
m_TiO2 = get_material("TiO2") m_TiO2 = ba.HomogeneousMaterial("TiO2", 4.1921e-05, 8.1293e-09)
m_Pt = get_material("Pt") m_Pt = ba.HomogeneousMaterial("Pt", 1.0117e-04, 3.01822e-08)
m_D2O = get_material("D2O") m_D2O = ba.HomogeneousMaterial("D2O", 1.0116e-04, 1.8090e-12)
# create layers # create layers
l_Si = ba.Layer(m_Si) l_Si = ba.Layer(m_Si)
l_Ti = ba.Layer(m_Ti, t_Ti) l_Ti = ba.Layer(m_Ti, 130.0 * angstrom)
l_Pt = ba.Layer(m_Pt, t_Pt) l_Pt = ba.Layer(m_Pt, 320.0 * angstrom)
l_Ti_top = ba.Layer(m_Ti, t_Ti_top) l_Ti_top = ba.Layer(m_Ti, 100.0 * angstrom)
l_TiO2 = ba.Layer(m_TiO2, t_TiO2) l_TiO2 = ba.Layer(m_TiO2, 30.0 * angstrom)
l_D2O = ba.Layer(m_D2O) l_D2O = ba.Layer(m_D2O)
# construct sample # construct sample
......
No preview for this file type
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