diff --git a/auto/Examples/fit/scatter2d/expfit_galaxi.py b/auto/Examples/fit/scatter2d/expfit_galaxi.py index 560a99b4c334238f7a555835406c94e0e27be434..c173661b99dd54209cdb68ea9d2eb6da7dc76c3b 100755 --- a/auto/Examples/fit/scatter2d/expfit_galaxi.py +++ b/auto/Examples/fit/scatter2d/expfit_galaxi.py @@ -96,7 +96,7 @@ def create_detector(beam): """ nx = pilatus_npx ny = pilatus_npy - return ba.Detector2D(3.4*deg, 1.84*deg, nx, ny, 0, 0.92*deg) + return ba.Detector2D(3.4*deg, 1.84*deg, nx, ny, 0, 0.32*deg) def create_simulation(P): diff --git a/auto/Examples/scatter2d/RoughAndSpecular.py b/auto/Examples/scatter2d/RoughAndSpecular.py new file mode 100755 index 0000000000000000000000000000000000000000..1690fe9871c79dbdf93eba7f6b35e550d949a98a --- /dev/null +++ b/auto/Examples/scatter2d/RoughAndSpecular.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +import bornagain as ba +from bornagain import ba_plot as bp, deg, nm + +def get_sample(): + # Define materials + material_HMDSO = ba.RefractiveMaterial("HMDSO", 2.0888e-06, 1.3261e-08) + material_PTFE = ba.RefractiveMaterial("PTFE", 5.20509e-06, 1.9694e-08) + material_Si = ba.RefractiveMaterial("Si", 5.7816e-06, 1.0229e-07) + material_Vacuum = ba.RefractiveMaterial("Vacuum", 0.0, 0.0) + + # Define roughness + roughness_1 = ba.LayerRoughness(1.1, 0.3, 5*nm) + roughness_2 = ba.LayerRoughness(2.3, 0.3, 5*nm) + + # Define layers + layer_1 = ba.Layer(material_Vacuum) + layer_2 = ba.Layer(material_HMDSO, 18.5*nm) + layer_3 = ba.Layer(material_PTFE, 22.1*nm) + layer_4 = ba.Layer(material_Si) + + # Define sample + sample = ba.MultiLayer() + sample.addLayer(layer_1) + sample.addLayerWithTopRoughness(layer_2, roughness_1) + sample.addLayerWithTopRoughness(layer_3, roughness_2) + sample.addLayer(layer_4) + + return sample + + +def get_simulation(sample): + beam = ba.Beam(1e9, 0.1*nm, 0.4*deg) + n = 200 + detector = ba.Detector2D(4*deg, 2*deg, n, n, 0, .4*deg) + detector.setResolutionFunction( + ba.ResolutionFunction2DGaussian(0.02*deg, 0.02*deg)) + simulation = ba.ScatteringSimulation(beam, sample, detector) + simulation.options().setUseAvgMaterials(True) + simulation.options().setIncludeSpecular(True) + return simulation + + +if __name__ == '__main__': + sample = get_sample() + simulation = get_simulation(sample) + result = simulation.simulate() + bp.plot_simulation_result(result) + bp.show_or_export() diff --git a/auto/MiniExamples/fit/scatter2d/expfit_galaxi.py b/auto/MiniExamples/fit/scatter2d/expfit_galaxi.py index 57b273fc50cf25bb524b272461aa1329d5392b2f..5dd586f210131c37d5df5af136c114f13e46097e 100755 --- a/auto/MiniExamples/fit/scatter2d/expfit_galaxi.py +++ b/auto/MiniExamples/fit/scatter2d/expfit_galaxi.py @@ -96,7 +96,7 @@ def create_detector(beam): """ nx = pilatus_npx ny = pilatus_npy - return ba.Detector2D(3.4*deg, 1.84*deg, nx, ny, 0, 0.92*deg) + return ba.Detector2D(3.4*deg, 1.84*deg, nx, ny, 0, 0.32*deg) def create_simulation(P): diff --git a/auto/MiniExamples/scatter2d/RoughAndSpecular.py b/auto/MiniExamples/scatter2d/RoughAndSpecular.py new file mode 100755 index 0000000000000000000000000000000000000000..f9c1a73cbd204452c8645b02a757602fe021b671 --- /dev/null +++ b/auto/MiniExamples/scatter2d/RoughAndSpecular.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +import bornagain as ba +from bornagain import ba_plot as bp, deg, nm + +def get_sample(): + # Define materials + material_HMDSO = ba.RefractiveMaterial("HMDSO", 2.0888e-06, 1.3261e-08) + material_PTFE = ba.RefractiveMaterial("PTFE", 5.20509e-06, 1.9694e-08) + material_Si = ba.RefractiveMaterial("Si", 5.7816e-06, 1.0229e-07) + material_Vacuum = ba.RefractiveMaterial("Vacuum", 0.0, 0.0) + + # Define roughness + roughness_1 = ba.LayerRoughness(1.1, 0.3, 5*nm) + roughness_2 = ba.LayerRoughness(2.3, 0.3, 5*nm) + + # Define layers + layer_1 = ba.Layer(material_Vacuum) + layer_2 = ba.Layer(material_HMDSO, 18.5*nm) + layer_3 = ba.Layer(material_PTFE, 22.1*nm) + layer_4 = ba.Layer(material_Si) + + # Define sample + sample = ba.MultiLayer() + sample.addLayer(layer_1) + sample.addLayerWithTopRoughness(layer_2, roughness_1) + sample.addLayerWithTopRoughness(layer_3, roughness_2) + sample.addLayer(layer_4) + + return sample + + +def get_simulation(sample): + beam = ba.Beam(1e9, 0.1*nm, 0.4*deg) + n = 11 + detector = ba.Detector2D(4*deg, 2*deg, n, n, 0, .4*deg) + detector.setResolutionFunction( + ba.ResolutionFunction2DGaussian(0.02*deg, 0.02*deg)) + simulation = ba.ScatteringSimulation(beam, sample, detector) + simulation.options().setUseAvgMaterials(True) + simulation.options().setIncludeSpecular(True) + return simulation + + +if __name__ == '__main__': + sample = get_sample() + simulation = get_simulation(sample) + result = simulation.simulate() + bp.plot_simulation_result(result) + bp.show_or_export() diff --git a/rawEx/scatter2d/RoughAndSpecular.py b/rawEx/scatter2d/RoughAndSpecular.py new file mode 100755 index 0000000000000000000000000000000000000000..4b2b1b41dc6f134484dfe2a6e67f83a355f59963 --- /dev/null +++ b/rawEx/scatter2d/RoughAndSpecular.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +import bornagain as ba +from bornagain import ba_plot as bp, deg, nm + +def get_sample(): + # Define materials + material_HMDSO = ba.RefractiveMaterial("HMDSO", 2.0888e-06, 1.3261e-08) + material_PTFE = ba.RefractiveMaterial("PTFE", 5.20509e-06, 1.9694e-08) + material_Si = ba.RefractiveMaterial("Si", 5.7816e-06, 1.0229e-07) + material_Vacuum = ba.RefractiveMaterial("Vacuum", 0.0, 0.0) + + # Define roughness + roughness_1 = ba.LayerRoughness(1.1, 0.3, 5*nm) + roughness_2 = ba.LayerRoughness(2.3, 0.3, 5*nm) + + # Define layers + layer_1 = ba.Layer(material_Vacuum) + layer_2 = ba.Layer(material_HMDSO, 18.5*nm) + layer_3 = ba.Layer(material_PTFE, 22.1*nm) + layer_4 = ba.Layer(material_Si) + + # Define sample + sample = ba.MultiLayer() + sample.addLayer(layer_1) + sample.addLayerWithTopRoughness(layer_2, roughness_1) + sample.addLayerWithTopRoughness(layer_3, roughness_2) + sample.addLayer(layer_4) + + return sample + + +def get_simulation(sample): + beam = ba.Beam(1e9, 0.1*nm, 0.4*deg) + n = <%= sm ? 11 : 200 %> + detector = ba.Detector2D(4*deg, 2*deg, n, n, 0, .4*deg) + detector.setResolutionFunction( + ba.ResolutionFunction2DGaussian(0.02*deg, 0.02*deg)) + simulation = ba.ScatteringSimulation(beam, sample, detector) + simulation.options().setUseAvgMaterials(True) + simulation.options().setIncludeSpecular(True) + return simulation + + +if __name__ == '__main__': + sample = get_sample() + simulation = get_simulation(sample) + result = simulation.simulate() + bp.plot_simulation_result(result) + bp.show_or_export()