BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
OffspecSimulation.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sim/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_SIM_SIMULATION_OFFSPECSIMULATION_H
16 #define BORNAGAIN_SIM_SIMULATION_OFFSPECSIMULATION_H
17 
19 
20 class IAxis;
21 
22 class Datafield;
23 
24 //! Off-specular scattering simulation.
25 //!
26 //! Holds an instrument and sample model.
27 //! Computes reflected and scattered intensity as function of incident and final glancing angle.
28 //! @ingroup simulation
29 
31 public:
34  ~OffspecSimulation() override = default;
35 
36  std::string className() const final { return "OffspecSimulation"; }
37 
38  //! Sets beam parameters from here (forwarded to Instrument)
39  void setBeamParameters(double wavelength, const IAxis& alpha_axis, double phi_i);
40 
41  //! Returns axis of the beam.
42  const IAxis* beamAxis() const;
43 
44  //! Returns the total number of the intensity values in the simulation result
45  size_t intensityMapSize() const override;
46 
47 #ifndef SWIG
48  ICoordSystem* createCoordSystem() const override;
49 
50 private:
51  SimulationResult pack_result() override;
52 
53  //! Put into a clean state for running a simulation
54  void prepareSimulation() override;
55 
56  //! Initializes the vector of ISimulation elements
57  void initElementVector() override;
58 
59  //! Checks the distribution validity for simulation.
60  void validateParametrization(const ParameterDistribution& par_distr) const override;
61 
62  //! Default implementation only adds the detector axes
63  void updateIntensityMap() override;
64 
65  //! Gets the number of elements this simulation needs to calculate
66  size_t numberOfElements() const override;
67 
68  //! Normalize, apply detector resolution and transfer detector image corresponding to
69  //! alpha_i = m_alpha_i_axis->bin(index)
70  void transferDetectorImage(size_t index);
71 
72  //! Check correct number of axes
73  void checkInitialization() const;
74 
75  std::unique_ptr<IAxis> m_alpha_i_axis;
76  std::unique_ptr<Datafield> m_intensity_map;
77 #endif
78 };
79 
80 #endif // BORNAGAIN_SIM_SIMULATION_OFFSPECSIMULATION_H
Defines interface ISimulation2D.
An incident neutron or x-ray beam.
Definition: Beam.h:28
Stores radiation power per bin.
Definition: Datafield.h:30
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 detector interface.
Definition: IDetector.h:57
Abstract base class of simulations that generate 2D patterns.
Definition: ISimulation2D.h:34
IDetector & detector()
Definition: ISimulation2D.h:58
Beam & beam()
Definition: ISimulation2D.h:57
const MultiLayer * sample() const
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:43
Off-specular scattering simulation.
const IAxis * beamAxis() const
Returns axis of the beam.
std::unique_ptr< Datafield > m_intensity_map
void updateIntensityMap() override
Default implementation only adds the detector axes.
void transferDetectorImage(size_t index)
Normalize, apply detector resolution and transfer detector image corresponding to alpha_i = m_alpha_i...
OffspecSimulation(const Beam &beam, const MultiLayer &sample, const IDetector &detector)
size_t numberOfElements() const override
Gets the number of elements this simulation needs to calculate.
size_t intensityMapSize() const override
Returns the total number of the intensity values in the simulation result.
SimulationResult pack_result() override
Sets m_result.
void prepareSimulation() override
Put into a clean state for running a simulation.
ICoordSystem * createCoordSystem() const override
void validateParametrization(const ParameterDistribution &par_distr) const override
Checks the distribution validity for simulation.
std::unique_ptr< IAxis > m_alpha_i_axis
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
void setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)
Sets beam parameters from here (forwarded to Instrument)
void checkInitialization() const
Check correct number of axes.
~OffspecSimulation() override=default
void initElementVector() override
Initializes the vector of ISimulation elements.
A parametric distribution function, for use with any model parameter.
Wrapper around Datafield that also provides unit conversions.