BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
SpecularSimulation.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sim/Simulation/SpecularSimulation.h
6 //! @brief Defines class SpecularSimulation.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_SIM_SIMULATION_SPECULARSIMULATION_H
16 #define BORNAGAIN_SIM_SIMULATION_SPECULARSIMULATION_H
17 
19 
20 class IAxis;
21 class IFootprintFactor;
22 class ISpecularScan;
23 class PolMatrices;
24 class SpecularElement;
25 
26 
27 //! Specular reflectometry simulation.
28 //!
29 //! Holds an instrument and sample model.
30 //! Computes detected intensity as function of the glancing angles alpha_i=alpha_f.
31 //! @ingroup simulation
32 
34 public:
36  ~SpecularSimulation() override;
38 
39  std::string className() const final { return "SpecularSimulation"; }
40 
41  //! Returns the total number of the intensity values in the simulation result
42  size_t intensityMapSize() const override;
43 
44  bool force_polarized() const override;
45 
46 #ifndef SWIG
47  //! Put into a clean state for running a simulation.
48  void prepareSimulation() override {}
49 
50  ICoordSystem* createCoordSystem() const override;
51  //! Returns internal data handler
52  const ISpecularScan* scan() const { return m_scan.get(); }
53 
54 private:
55  SimulationResult pack_result() override;
56 
57  //! Initializes the vector of ISimulation elements
58  void initElementVector() override;
59 
60  //! Generate a single threaded computation for a given range of simulation elements
61  //! @param re_sample Preprocessed version of our sample
62  //! @param start Index of the first element to include into computation
63  //! @param n_elements Number of elements to process
64  std::unique_ptr<IComputation> createComputation(const reSample& re_sample, size_t start,
65  size_t n_elements) override;
66 
67  void checkCache() const;
68 
69  //! Checks the distribution validity for simulation.
70  void validateParametrization(const ParameterDistribution& par_distr) const override;
71 
72  //! Normalize the detector counts to beam intensity, to solid angle, and to exposure angle.
73  //! @param start_ind Index of the first element to operate on
74  //! @param n_elements Number of elements to process
75  void normalize(size_t start_ind, size_t n_elements) override;
76 
77  void addBackgroundIntensity(size_t start_ind, size_t n_elements) override;
78 
79  void addDataToCache(double weight) override;
80 
81  void moveDataFromCache() override;
82 
83  //! Gets the number of elements this simulation needs to calculate
84  size_t numberOfElements() const override;
85 
86  std::unique_ptr<const ISpecularScan> m_scan;
87  std::vector<SpecularElement> m_eles;
88  std::vector<double> m_cache;
89 #endif // USER_API
90 };
91 
92 #endif // BORNAGAIN_SIM_SIMULATION_SPECULARSIMULATION_H
Defines interface ISimulation.
Abstract base class for one-dimensional axes.
Definition: IAxis.h:27
Interface to provide axis translations to different units for simulation output.
Definition: ICoordSystem.h:40
Abstract base for classes that calculate the beam footprint factor.
Abstract base class, holds the infrastructure to run a simulation.
Definition: ISimulation.h:42
const MultiLayer * sample() const
Abstract base class for all types of specular scans.
Definition: ISpecularScan.h:34
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:43
A parametric distribution function, for use with any model parameter.
Convenience class for handling polarization density matrix and polarization analyzer operator.
Definition: PolMatrices.h:29
Wrapper around Datafield that also provides unit conversions.
Data stucture containing both input and output of a single image pixel for specular simulation.
Specular reflectometry simulation.
SimulationResult pack_result() override
Sets m_result.
SpecularSimulation(SpecularSimulation &&)
void initElementVector() override
Initializes the vector of ISimulation elements.
std::vector< double > m_cache
bool force_polarized() const override
Force polarized computation even in absence of sample magnetization or external fields.
void addDataToCache(double weight) override
ICoordSystem * createCoordSystem() const override
std::unique_ptr< IComputation > createComputation(const reSample &re_sample, size_t start, size_t n_elements) override
Generate a single threaded computation for a given range of simulation elements.
const ISpecularScan * scan() const
Returns internal data handler.
size_t intensityMapSize() const override
Returns the total number of the intensity values in the simulation result.
~SpecularSimulation() override
std::unique_ptr< const ISpecularScan > m_scan
void addBackgroundIntensity(size_t start_ind, size_t n_elements) override
void prepareSimulation() override
Put into a clean state for running a simulation.
void moveDataFromCache() override
void validateParametrization(const ParameterDistribution &par_distr) const override
Checks the distribution validity for simulation.
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
std::vector< SpecularElement > m_eles
void normalize(size_t start_ind, size_t n_elements) override
Normalize the detector counts to beam intensity, to solid angle, and to exposure angle.
SpecularSimulation(const ISpecularScan &scan, const MultiLayer &sample)
size_t numberOfElements() const override
Gets the number of elements this simulation needs to calculate.
Data structure that contains all the necessary data for scattering calculations.
Definition: ReSample.h:41