diff --git a/Core/StandardSamples/SimulationFactory.cpp b/Core/StandardSamples/SimulationFactory.cpp index 0461ec4f6207a7a04626f4d7def68b9e5a007ba0..39fa1e4ab45fc77ea20a7da7a5017fbf0bc1161f 100644 --- a/Core/StandardSamples/SimulationFactory.cpp +++ b/Core/StandardSamples/SimulationFactory.cpp @@ -157,10 +157,6 @@ SimulationFactory::SimulationFactory() "Simulation implies beam divergence both in wavelength and " "inclination angle."); - registerItem("SpecularDivergentBeamCopy", StandardSimulations::SpecularDivergentBeamCopy, - "Simulation implies beam divergence both in wavelength and " - "inclination angle."); - registerItem("TOFRWithRelativeResolution", StandardSimulations::TOFRWithRelativeResolution, "Q-defined reflectometric scan with relative resolution"); diff --git a/Core/StandardSamples/StandardSimulations.cpp b/Core/StandardSamples/StandardSimulations.cpp index 8a2a13cbea363ab4aff3432f541e81885f1d67e0..f1a0de4cde3c1e5a0fd4282f3e738de283a1df63 100644 --- a/Core/StandardSamples/StandardSimulations.cpp +++ b/Core/StandardSamples/StandardSimulations.cpp @@ -466,32 +466,6 @@ SpecularSimulation* StandardSimulations::SpecularWithSquareBeam() } SpecularSimulation* StandardSimulations::SpecularDivergentBeam() -{ - const double wavelength = 1.54 * Units::angstrom; - const int number_of_bins = 20; - const size_t n_integration_points = 10; - const double min_angle = 0 * Units::deg; - const double max_angle = 5 * Units::deg; - AngularSpecScan scan(wavelength, FixedBinAxis("axis", number_of_bins, min_angle, max_angle)); - - DistributionGaussian wavelength_distr(wavelength, 0.1*Units::angstrom); - DistributionGaussian alpha_distr(0.0, 0.1*Units::degree); - - std::unique_ptr<SpecularSimulation> result(new SpecularSimulation()); - result->setScan(scan); - - ParameterPattern pattern1; - pattern1.beginsWith("*").add(BornAgain::BeamType).add(BornAgain::Wavelength); - result->addParameterDistribution(pattern1.toStdString(), wavelength_distr, - n_integration_points); - ParameterPattern pattern2; - pattern2.beginsWith("*").add(BornAgain::BeamType).add(BornAgain::Inclination); - result->addParameterDistribution(pattern2.toStdString(), alpha_distr, n_integration_points); - - return result.release(); -} - -SpecularSimulation* StandardSimulations::SpecularDivergentBeamCopy() { const double wavelength = 1.54 * Units::angstrom; const int number_of_bins = 20; diff --git a/Core/StandardSamples/StandardSimulations.h b/Core/StandardSamples/StandardSimulations.h index 1105052464d33e45ae707ed40b10522005ffb064..a9b41b685b99849cac65841a8ab32524ebf79c01 100644 --- a/Core/StandardSamples/StandardSimulations.h +++ b/Core/StandardSamples/StandardSimulations.h @@ -64,7 +64,6 @@ BA_CORE_API_ SpecularSimulation* BasicSpecularQ(); BA_CORE_API_ SpecularSimulation* SpecularWithGaussianBeam(); BA_CORE_API_ SpecularSimulation* SpecularWithSquareBeam(); BA_CORE_API_ SpecularSimulation* SpecularDivergentBeam(); -BA_CORE_API_ SpecularSimulation* SpecularDivergentBeamCopy(); BA_CORE_API_ SpecularSimulation* TOFRWithRelativeResolution(); BA_CORE_API_ SpecularSimulation* TOFRWithPointwiseResolution(); diff --git a/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence.py b/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence.py index 01ef2b142c4558c44f2edcd01578834b771c1f8d..47b2376ff8334560982423ccfaf2ebb7390ca403 100644 --- a/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence.py +++ b/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence.py @@ -70,20 +70,16 @@ def get_simulation(scan_size=500): """ Returns a specular simulation with beam and detector defined. """ - # First argument of ba.DistributionGaussian is the mean value for distribution. - # It should be zero in the case of incident angle distribution, otherwise an - # exception is thrown. footprint = ba.FootprintFactorSquare(beam_sample_ratio) + alpha_distr = ba.RangedDistributionGaussian(n_points, n_sig) scan = ba.AngularSpecScan(wavelength, scan_size, alpha_i_min, alpha_i_max) scan.setFootprintFactor(footprint) + scan.setAbsoluteAngularResolution(alpha_distr, d_ang) simulation = ba.SpecularSimulation() simulation.setScan(scan) - alpha_distr = ba.DistributionGaussian(0.0, d_ang) - simulation.addParameterDistribution("*/Beam/InclinationAngle", alpha_distr, - n_points, n_sig) return simulation @@ -100,11 +96,13 @@ def run_simulation(): def plot(results): """ - Plots data for several selected layers + + :param results: + :return: """ from matplotlib import pyplot as plt - ba.plot_simulation_result(results, postpone_show=True, c='gray', linestyle="--") + ba.plot_simulation_result(results, postpone_show=True) genx_axis, genx_values = create_real_data() diff --git a/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence_copy.py b/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence_copy.py deleted file mode 100644 index 47b2376ff8334560982423ccfaf2ebb7390ca403..0000000000000000000000000000000000000000 --- a/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence_copy.py +++ /dev/null @@ -1,119 +0,0 @@ -""" -An example of taking into account beam angular divergence -and beam footprint correction in reflectometry calculations -with BornAgain. - -""" -import numpy as np -import bornagain as ba -from os import path - -# input parameters -wavelength = 1.54 * ba.angstrom -alpha_i_min = 0.0 * ba.deg # min incident angle, deg -alpha_i_max = 2.0 * ba.deg # max incident angle, rad -beam_sample_ratio = 0.01 # beam-to-sample size ratio - -# convolution parameters -d_ang = 0.01 * ba.deg # spread width for incident angle -n_sig = 3 # number of sigmas to convolve over -n_points = 25 # number of points to convolve over - -# substrate (Si) -si_sld_real = 2.0704e-06 # \AA^{-2} -# layer parameters -n_repetitions = 10 -# Ni -ni_sld_real = 9.4245e-06 # \AA^{-2} -d_ni = 70 * ba.angstrom -# Ti -ti_sld_real = -1.9493e-06 # \AA^{-2} -d_ti = 30 * ba.angstrom - - -def get_sample(): - # defining materials - m_air = ba.MaterialBySLD("Air", 0.0, 0.0) - m_ni = ba.MaterialBySLD("Ni", ni_sld_real, 0.0) - m_ti = ba.MaterialBySLD("Ti", ti_sld_real, 0.0) - m_substrate = ba.MaterialBySLD("SiSubstrate", si_sld_real, 0.0) - - air_layer = ba.Layer(m_air) - ni_layer = ba.Layer(m_ni, d_ni) - ti_layer = ba.Layer(m_ti, d_ti) - substrate_layer = ba.Layer(m_substrate) - multi_layer = ba.MultiLayer() - multi_layer.addLayer(air_layer) - for i in range(n_repetitions): - multi_layer.addLayer(ti_layer) - multi_layer.addLayer(ni_layer) - multi_layer.addLayer(substrate_layer) - return multi_layer - - -def create_real_data(): - """ - Loading data from genx_angular_divergence.dat - """ - filepath = path.join(path.dirname(path.realpath(__file__)), - "genx_angular_divergence.dat.gz") - ax_values, real_data = np.loadtxt(filepath, - usecols=(0, 1), skiprows=3, unpack=True) - - # translating axis values from double incident angle # to incident angle - ax_values *= 0.5 - - return ax_values, real_data - - -def get_simulation(scan_size=500): - """ - Returns a specular simulation with beam and detector defined. - """ - footprint = ba.FootprintFactorSquare(beam_sample_ratio) - alpha_distr = ba.RangedDistributionGaussian(n_points, n_sig) - - scan = ba.AngularSpecScan(wavelength, scan_size, alpha_i_min, alpha_i_max) - scan.setFootprintFactor(footprint) - scan.setAbsoluteAngularResolution(alpha_distr, d_ang) - - simulation = ba.SpecularSimulation() - simulation.setScan(scan) - - return simulation - - -def run_simulation(): - """ - Runs simulation and returns it. - """ - sample = get_sample() - simulation = get_simulation() - simulation.setSample(sample) - simulation.runSimulation() - return simulation.result() - - -def plot(results): - """ - - :param results: - :return: - """ - from matplotlib import pyplot as plt - - ba.plot_simulation_result(results, postpone_show=True) - - genx_axis, genx_values = create_real_data() - - plt.semilogy(genx_axis, genx_values, 'ko', markevery=300) - plt.legend(['BornAgain', - 'GenX'], - loc='upper right') - - plt.show() - - -if __name__ == '__main__': - results = run_simulation() - plot(results) diff --git a/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence.py b/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence.py index 0633ea8704ca72970510d6decb86c9909921358d..af8e98d6f6e6f593ef9418819e07bfb8a087a9c0 100644 --- a/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence.py +++ b/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence.py @@ -54,19 +54,17 @@ def get_simulation(scan_size=500): """ Returns a specular simulation with beam and detector defined. """ - # First argument of ba.DistributionGaussian is - # the mean value for distribution. - # It should be zero in the case of incident angle distribution, - # otherwise an exception is thrown. - alpha_distr = ba.DistributionGaussian(0.0, d_ang) - wavelength_distr = ba.DistributionGaussian(wavelength, d_wl) - simulation = ba.SpecularSimulation() + + alpha_distr = ba.RangedDistributionGaussian(n_points, n_sig) + wavelength_distr = ba.RangedDistributionGaussian(n_points, n_sig) + scan = ba.AngularSpecScan(wavelength, scan_size, alpha_i_min, alpha_i_max) + scan.setAbsoluteAngularResolution(alpha_distr, d_ang) + scan.setAbsoluteWavelengthResolution(wavelength_distr, d_wl) + + simulation = ba.SpecularSimulation() simulation.setScan(scan) - simulation.addParameterDistribution("*/Beam/InclinationAngle", - alpha_distr, n_points, n_sig) - simulation.addParameterDistribution("*/Beam/Wavelength", - wavelength_distr, n_points, n_sig) + return simulation @@ -83,4 +81,4 @@ def run_simulation(): if __name__ == '__main__': results = run_simulation() - ba.plot_simulation_result(results, c='b') + ba.plot_simulation_result(results) diff --git a/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence_copy.py b/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence_copy.py deleted file mode 100644 index af8e98d6f6e6f593ef9418819e07bfb8a087a9c0..0000000000000000000000000000000000000000 --- a/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence_copy.py +++ /dev/null @@ -1,84 +0,0 @@ -""" -An example of taking into account beam angular and wavelength -divergence in reflectometry calculations with BornAgain. - -""" -import bornagain as ba - -# input parameters -wavelength = 1.54 * ba.angstrom -alpha_i_min = 0.0 * ba.deg # min incident angle, deg -alpha_i_max = 2.0 * ba.deg # max incident angle, rad - -# convolution parameters -d_wl = 0.01 * wavelength # spread width for wavelength -d_ang = 0.01 * ba.deg # spread width for incident angle -n_sig = 3 # number of sigmas to convolve over -n_points = 25 # number of points to convolve over - -# substrate (Si) -si_sld_real = 2.0704e-06 # \AA^{-2} -# layer parameters -n_repetitions = 10 -# Ni -ni_sld_real = 9.4245e-06 # \AA^{-2} -d_ni = 70 * ba.angstrom # ni layer thickness (nm) -# Ti -ti_sld_real = -1.9493e-06 # \AA^{-2} -d_ti = 30 * ba.angstrom # ti layer thickness (nm) - - -def get_sample(): - # defining materials - # this example implies beam divergence in the wavelength, - # thus MaterialBySLD must be used to provide correct result - m_air = ba.MaterialBySLD("Air", 0.0, 0.0) - m_ni = ba.MaterialBySLD("Ni", ni_sld_real, 0.0) - m_ti = ba.MaterialBySLD("Ti", ti_sld_real, 0.0) - m_substrate = ba.MaterialBySLD("SiSubstrate", si_sld_real, 0.0) - - air_layer = ba.Layer(m_air) - ni_layer = ba.Layer(m_ni, d_ni) - ti_layer = ba.Layer(m_ti, d_ti) - substrate_layer = ba.Layer(m_substrate) - multi_layer = ba.MultiLayer() - multi_layer.addLayer(air_layer) - for i in range(n_repetitions): - multi_layer.addLayer(ti_layer) - multi_layer.addLayer(ni_layer) - multi_layer.addLayer(substrate_layer) - return multi_layer - - -def get_simulation(scan_size=500): - """ - Returns a specular simulation with beam and detector defined. - """ - - alpha_distr = ba.RangedDistributionGaussian(n_points, n_sig) - wavelength_distr = ba.RangedDistributionGaussian(n_points, n_sig) - - scan = ba.AngularSpecScan(wavelength, scan_size, alpha_i_min, alpha_i_max) - scan.setAbsoluteAngularResolution(alpha_distr, d_ang) - scan.setAbsoluteWavelengthResolution(wavelength_distr, d_wl) - - simulation = ba.SpecularSimulation() - simulation.setScan(scan) - - return simulation - - -def run_simulation(): - """ - Runs simulation and returns it. - """ - sample = get_sample() - simulation = get_simulation() - simulation.setSample(sample) - simulation.runSimulation() - return simulation.result() - - -if __name__ == '__main__': - results = run_simulation() - ba.plot_simulation_result(results) diff --git a/Tests/Functional/Core/CoreStandardTest/CMakeLists.txt b/Tests/Functional/Core/CoreStandardTest/CMakeLists.txt index 92051af81bdfce1c867f51f365ccfa54c4ddbb70..68d7cd6a924d2b03dfd6b4b6c8360e9989af0017 100644 --- a/Tests/Functional/Core/CoreStandardTest/CMakeLists.txt +++ b/Tests/Functional/Core/CoreStandardTest/CMakeLists.txt @@ -73,7 +73,6 @@ set(test_cases GaussianBeamFootprint SquareBeamFootprint SpecularDivergentBeam - SpecularDivergentBeamCopy RelativeResolutionTOF OffSpecularResonator DepthProbeTest diff --git a/Tests/Functional/Python/PyPersistence/CMakeLists.txt b/Tests/Functional/Python/PyPersistence/CMakeLists.txt index 6f42dd626cae0680605699afa762ff2aae806d64..c7aabf2a3a0d5b1419ec65f879a395f96f594710 100644 --- a/Tests/Functional/Python/PyPersistence/CMakeLists.txt +++ b/Tests/Functional/Python/PyPersistence/CMakeLists.txt @@ -58,9 +58,7 @@ test_example("simulation/ex05_BeamAndDetector/ConstantBackground" 2e-10) test_example("simulation/ex06_Reflectometry/BasicSpecularSimulation" 2e-10) test_example("simulation/ex06_Reflectometry/BeamAngularDivergence" 2e-10) -test_example("simulation/ex06_Reflectometry/BeamAngularDivergence_copy" 2e-10) test_example("simulation/ex06_Reflectometry/BeamFullDivergence" 2e-10) -test_example("simulation/ex06_Reflectometry/BeamFullDivergence_copy" 2e-10) test_example("simulation/ex06_Reflectometry/TimeOfFlightReflectometry" 2e-10) test_example("simulation/ex06_Reflectometry/TOFRWithResolution" 2e-10) diff --git a/Tests/Functional/Python/PyStandard/CMakeLists.txt b/Tests/Functional/Python/PyStandard/CMakeLists.txt index e8c8df0300dcc6aa1fbc1f5c791f1489ea882af2..86a40daeef7cd8ab4690fca645b017808f63f54d 100644 --- a/Tests/Functional/Python/PyStandard/CMakeLists.txt +++ b/Tests/Functional/Python/PyStandard/CMakeLists.txt @@ -65,7 +65,6 @@ set(test_cases OffSpecularResonator GaussianBeamFootprint SpecularDivergentBeam - SpecularDivergentBeamCopy HomogeneousTiNiSampleWithAbsorption RelativeResolutionTOF ) diff --git a/Tests/Functional/TestMachinery/StandardTestCatalogue.cpp b/Tests/Functional/TestMachinery/StandardTestCatalogue.cpp index 3cec93e6cf56eb2945aba10e0b9fbea933b87915..d78b8d63e9fb0e7eca1a7f5587053395a0a43e2d 100644 --- a/Tests/Functional/TestMachinery/StandardTestCatalogue.cpp +++ b/Tests/Functional/TestMachinery/StandardTestCatalogue.cpp @@ -445,12 +445,6 @@ StandardTestCatalogue::StandardTestCatalogue() "HomogeneousMultilayerBuilder", 1e-10); - add("SpecularDivergentBeamCopy", - "Simulates beam divergence both in wavelength and inclination angle", - "SpecularDivergentBeamCopy", - "HomogeneousMultilayerBuilder", - 1e-10); - add("RelativeResolutionTOF", "Simulates q-defined reflectometry with a fixed relative q resolution", "TOFRWithRelativeResolution", diff --git a/Tests/ReferenceData/Core/SpecularDivergentBeamCopy.int.gz b/Tests/ReferenceData/Core/SpecularDivergentBeamCopy.int.gz deleted file mode 100644 index af8baf443253dd1adffd3ce7b3b930be2425dd8d..0000000000000000000000000000000000000000 Binary files a/Tests/ReferenceData/Core/SpecularDivergentBeamCopy.int.gz and /dev/null differ