From eaa0ace00e681c0d6f7f94298eba2305e341cb05 Mon Sep 17 00:00:00 2001 From: Dmitry Yurov <d.yurov@fz-juelich.de> Date: Tue, 17 Jul 2018 09:25:58 +0200 Subject: [PATCH] Amended reflectometry examples to correspond to the web-site content Redmine: #2081 --- .../BasicSpecularSimulation.py | 55 ++++++++---------- .../ex07_Miscellaneous/DepthProbe.py | 30 +++------- .../Python/BasicSpecularSimulation.ref.int.gz | Bin 214 -> 253 bytes 3 files changed, 32 insertions(+), 53 deletions(-) diff --git a/Examples/python/simulation/ex06_Reflectometry/BasicSpecularSimulation.py b/Examples/python/simulation/ex06_Reflectometry/BasicSpecularSimulation.py index 27425830d92..bf5e5173727 100644 --- a/Examples/python/simulation/ex06_Reflectometry/BasicSpecularSimulation.py +++ b/Examples/python/simulation/ex06_Reflectometry/BasicSpecularSimulation.py @@ -2,60 +2,51 @@ Basic example of specular simulation with BornAgain. """ -import numpy import bornagain as ba -from bornagain import deg, angstrom, nm - -alpha_i_min, alpha_i_max = 0.0, 2.0 # incoming beam +from bornagain import deg, angstrom 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 - my_sample.addLayer(l_ambience) + # creating materials + 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 - for i in range(n_repetitions): - my_sample.addLayerWithTopRoughness(l_part_a, roughness) - my_sample.addLayerWithTopRoughness(l_part_b, roughness) + # creating layers + ambient_layer = ba.Layer(m_ambient) + ti_layer = ba.Layer(m_ti, 30 * angstrom) + 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(): """ - Returns a specular simulation with beam and detector defined. + Defines and returns a specular simulation. """ simulation = ba.SpecularSimulation() 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 def run_simulation(): """ - Runs simulation and returns it. + Runs simulation and returns its result. """ sample = get_sample() simulation = get_simulation() diff --git a/Examples/python/simulation/ex07_Miscellaneous/DepthProbe.py b/Examples/python/simulation/ex07_Miscellaneous/DepthProbe.py index 315dbcac0e7..c3860293815 100644 --- a/Examples/python/simulation/ex07_Miscellaneous/DepthProbe.py +++ b/Examples/python/simulation/ex07_Miscellaneous/DepthProbe.py @@ -49,18 +49,6 @@ z_min = -100 * nm z_max = 100 * nm 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(): """ @@ -68,18 +56,18 @@ def get_sample(): """ # define materials - m_Si = get_material("Si") - m_Ti = get_material("Ti") - m_TiO2 = get_material("TiO2") - m_Pt = get_material("Pt") - m_D2O = get_material("D2O") + m_Si = ba.HomogeneousMaterial("Si", 3.3009e-05, 0.0) + m_Ti = ba.HomogeneousMaterial("Ti", -3.0637e-05, 1.5278e-08) + m_TiO2 = ba.HomogeneousMaterial("TiO2", 4.1921e-05, 8.1293e-09) + m_Pt = ba.HomogeneousMaterial("Pt", 1.0117e-04, 3.01822e-08) + m_D2O = ba.HomogeneousMaterial("D2O", 1.0116e-04, 1.8090e-12) # create layers l_Si = ba.Layer(m_Si) - l_Ti = ba.Layer(m_Ti, t_Ti) - l_Pt = ba.Layer(m_Pt, t_Pt) - l_Ti_top = ba.Layer(m_Ti, t_Ti_top) - l_TiO2 = ba.Layer(m_TiO2, t_TiO2) + l_Ti = ba.Layer(m_Ti, 130.0 * angstrom) + l_Pt = ba.Layer(m_Pt, 320.0 * angstrom) + l_Ti_top = ba.Layer(m_Ti, 100.0 * angstrom) + l_TiO2 = ba.Layer(m_TiO2, 30.0 * angstrom) l_D2O = ba.Layer(m_D2O) # construct sample diff --git a/Tests/ReferenceData/Python/BasicSpecularSimulation.ref.int.gz b/Tests/ReferenceData/Python/BasicSpecularSimulation.ref.int.gz index 6cae1c95e3153040478fb9967bdaae459127f37b..91b959aa6c622b6be301983b24d4422a4eae4db0 100644 GIT binary patch literal 253 zcmV<Z00RFXiwFP!00000|6R|$Y6CG02k`x#!X!%ziP4v3YfR|U7wA$txb!Fo<qF9S z?b}ys2q7nI3_s+*&^8^vPxIlkPjh;nmvKH%%Wrz>OCN?|oBGdm-ox<HPg8&Y8jsU_ zaCz8-!)BKdcInkGWP<y`Kv^LL>IyBetx!DM&pMXE*zPNA75e|T?Gn8`#u^{7k7ct) zPz0=?jeEf4g&7GAOKnJ`t`tgHv{famY^}ITXv@$H6j;=wT+5}GiwYGhQncI>YSY@- zu(Havw`A0cY*4GI-4ZGZn;7{^u6pSeW{z<_kgvVIJ}5USsEm<YLx<rH6@RoM$pHWW DMa+0z literal 214 zcmV;{04e_;iwFP!00000|80-UY6CG0Mfd&+lWba=n5&0nYnf0A{fvPO#hWQKQ%L{5 zc7{L~y+{ikqyyT=^XJ!c`k2}h-<Ne>u5JB^uhTk(5cYApwd)b#t=;C!xh<zYKJC7D zhe$ZYQ3;|B%QZv1R?AM$<M1*Jl<+6>3lMw$r=HZAiozA}`3M=5QxPv*!9}@rs+*yh zXf}5UqtiU7C2+Qy#Yv4jwQbk3u(%oV-Fv5!3JSx7yqg{dPE<+zH=taHw`>Mw5h&H( Q@}MF70`S#`7drs}0R8u8l>h($ -- GitLab