BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
OffSpecSimulation.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Simulation/OffSpecSimulation.h
6 //! @brief Defines class OffSpecSimulation.
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_CORE_SIMULATION_OFFSPECSIMULATION_H
16 #define BORNAGAIN_CORE_SIMULATION_OFFSPECSIMULATION_H
17 
20 
21 class Histogram2D;
22 
23 //! Main class to run an off-specular simulation.
24 //! @ingroup simulation
25 
27 {
28 public:
30  ~OffSpecSimulation() final {}
31 
32  OffSpecSimulation* clone() const override { return new OffSpecSimulation(*this); }
33 
34  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
35 
36  //! Put into a clean state for running a simulation
37  void prepareSimulation() final;
38 
39  //! Returns the results of the simulation in a format that supports unit conversion and export
40  //! to numpy arrays
41  SimulationResult result() const override;
42 
43  //! Sets beam parameters from here (forwarded to Instrument)
44  void setBeamParameters(double wavelength, const IAxis& alpha_axis, double phi_i);
45 
46  //! Returns axis of the beam.
47  const IAxis* beamAxis() const;
48 
49 #ifndef SWIG
50  std::unique_ptr<IUnitConverter> createUnitConverter() const;
51 #endif
52 
53  //! Returns the total number of the intensity values in the simulation result
54  size_t intensityMapSize() const override;
55 
56 private:
58 
59  //! Initializes the vector of Simulation elements
60  void initSimulationElementVector() override;
61 
62  //! Checks the distribution validity for simulation.
63  void validateParametrization(const ParameterDistribution& par_distr) const override;
64 
65  //! Creates the appropriate data structure (e.g. 2D intensity map) from the calculated
66  //! SimulationElement objects
67  void transferResultsToIntensityMap() override;
68 
69  //! Default implementation only adds the detector axes
70  void updateIntensityMap() override;
71 
72  //! Gets the number of elements this simulation needs to calculate
73  size_t numberOfSimulationElements() const final;
74 
75  //! Normalize, apply detector resolution and transfer detector image corresponding to
76  //! alpha_i = mp_alpha_i_axis->getBin(index)
77  void transferDetectorImage(size_t index);
78 
79  //! Check correct number of axes
80  void checkInitialization() const;
81 
82  void initialize();
83 
84  std::unique_ptr<IAxis> mP_alpha_i_axis;
86 };
87 
88 #endif // BORNAGAIN_CORE_SIMULATION_OFFSPECSIMULATION_H
Defines class Simulation2D.
Defines class SimulationElement.
Two dimensional histogram.
Definition: Histogram2D.h:25
Interface for one-dimensional axes.
Definition: IAxis.h:25
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
Main class to run an off-specular simulation.
void transferResultsToIntensityMap() override
Creates the appropriate data structure (e.g.
SimulationResult result() const override
Returns the results of the simulation in a format that supports unit conversion and export to numpy a...
void updateIntensityMap() override
Default implementation only adds the detector axes.
void initSimulationElementVector() override
Initializes the vector of Simulation elements.
OffSpecSimulation * clone() const override
const IAxis * beamAxis() const
Returns axis of the beam.
size_t numberOfSimulationElements() const final
Gets the number of elements this simulation needs to calculate.
void transferDetectorImage(size_t index)
Normalize, apply detector resolution and transfer detector image corresponding to alpha_i = mp_alpha_...
std::unique_ptr< IAxis > mP_alpha_i_axis
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
size_t intensityMapSize() const override
Returns the total number of the intensity values in the simulation result.
void prepareSimulation() final
Put into a clean state for running a simulation.
void validateParametrization(const ParameterDistribution &par_distr) const override
Checks the distribution validity for simulation.
std::unique_ptr< IUnitConverter > createUnitConverter() const
void checkInitialization() const
Check correct number of axes.
OutputData< double > m_intensity_map
void setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)
Sets beam parameters from here (forwarded to Instrument)
Template class to store data of any type in multi-dimensional space.
Definition: OutputData.h:33
A parametric distribution function, for use with any model parameter.
Pure virtual base class of OffSpecularSimulation and GISASSimulation.
Definition: Simulation2D.h:27
Wrapper around OutputData<double> that also provides unit conversions.