BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
speculartoysimulation.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/quicksimeditor/speculartoysimulation.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
21 #include <Sample/Slice/Slice.h>
23 #include <algorithm>
24 #include <stdexcept>
25 
26 using namespace ModelView;
27 
28 namespace gui2 {
29 
30 SpecularToySimulation::~SpecularToySimulation() = default;
31 
32 SpecularToySimulation::SpecularToySimulation(const SimulationInput& input_data)
33  : m_inputData(input_data), m_strategy(std::make_unique<SpecularScalarTanhStrategy>())
34 {
35 }
36 
38 {
40 
42 
44  for (auto q : m_inputData.qvalues) {
46  throw std::runtime_error("Interrupt request");
47 
48  auto kz = -0.5 * q;
49  auto kzs = KzComputation::computeKzFromSLDs(slices, kz);
50  auto coeff = std::move(m_strategy->Execute(slices, kzs).front());
51  auto amplitude = std::norm(coeff->getScalarR()) * m_inputData.intensity;
52  m_specularResult.amplitudes.emplace_back(amplitude);
53 
55  }
57 }
58 
60 {
62  m_progressHandler.subscribe(callback);
63 }
64 
66 {
67  return m_specularResult;
68 }
69 
71 {
72  auto [xmin, xmax] = MaterialProfile::DefaultMaterialProfileLimits(multislice);
73  auto profile = MaterialProfile::CalculateProfile(multislice, n_points, xmin, xmax);
74  return {xmin, xmax, ModelView::Utils::Real(profile)};
75 }
76 
78 {
79  return m_inputData.qvalues.size();
80 }
81 
82 } // namespace gui2
Declares functions in namespace KzComputation.
Defines class Slice.
Defines class SpecularScalarTanhStrategy.
Defines class CLASS?
void subscribe(callback_t callback)
std::function< bool(size_t)> callback_t
void setCompletedTicks(size_t value)
Increment number of completed computation steps.
void reset()
Resets progress.
void setMaxTicksCount(size_t value)
Sets expected ticks count, representing progress of a computation.
Implements an tanh transition function to model roughness in a scaler computation.
SimulationResult simulationResult() const
static SLDProfile sld_profile(const multislice_t &multislice, int n_points)
void setProgressCallback(ModelView::ProgressHandler::callback_t callback)
ModelView::ProgressHandler m_progressHandler
std::unique_ptr< SpecularScalarTanhStrategy > m_strategy
Defines class CLASS?
Defines class CLASS?
std::vector< complex_t > computeKzFromSLDs(const std::vector< Slice > &slices, double kz)
std::vector< double > Real(const C &container)
Returns vector with real part of complex numbers.
materialitems.h Collection of materials to populate MaterialModel.
DAREFLCORE_EXPORT std::pair< double, double > DefaultMaterialProfileLimits(const multislice_t &multilayer)
Get default z limits for generating a material profile.
DAREFLCORE_EXPORT std::vector< complex_t > CalculateProfile(const multislice_t &multilayer, int n_points, double z_min, double z_max)
Calculate average material profile for given multilayer.
DAREFLCORE_EXPORT std::vector< Slice > createBornAgainSlices(const multislice_t &multislice)
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
std::vector< SliceData > multislice_t
Definition: filesystem.h:81
Defines class CLASS?
Defines class CLASS?
Represents results of SLD profile calculations.
Represents data to run specular simulations.
multislice_t slice_data
std::vector< double > qvalues
Represents results of the simulation.
std::vector< double > qvalues
std::vector< double > amplitudes