BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
OffSpecularSimulation.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Core/Simulation/OffSpecularSimulation.h
6 //! @brief Defines class OffSpecularSimulation.
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_OFFSPECULARSIMULATION_H
16 #define BORNAGAIN_CORE_SIMULATION_OFFSPECULARSIMULATION_H
17 
20 
21 class Histogram2D;
22 
23 //! Main class to run an off-specular simulation.
24 //! @ingroup simulation
25 
27 public:
30  ~OffSpecularSimulation() override {}
31 
32  OffSpecularSimulation* clone() const override { return new OffSpecularSimulation(*this); }
33 
34  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
35 
36  //! Put into a clean state for running a simulation
37  void prepareSimulation() override;
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 ISimulation 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 override;
74 
75  //! Normalize, apply detector resolution and transfer detector image corresponding to
76  //! alpha_i = m_alpha_i_axis->bin(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> m_alpha_i_axis;
86 };
87 
88 #endif // BORNAGAIN_CORE_SIMULATION_OFFSPECULARSIMULATION_H
Defines interface ISimulation2D.
Defines class SimulationElement.
An incident neutron or x-ray beam.
Definition: Beam.h:27
Two dimensional histogram.
Definition: Histogram2D.h:24
Interface for one-dimensional axes.
Definition: IAxis.h:25
Abstract detector interface.
Definition: IDetector.h:36
Visitor interface to visit ISampleNode objects.
Definition: INodeVisitor.h:146
virtual void visit(const BasicLattice2D *)
Definition: INodeVisitor.h:151
Abstract base class of OffSpecularSimulation and GISASSimulation.
Definition: ISimulation2D.h:27
const MultiLayer * sample() const
IDetector & detector()
Definition: ISimulation.h:63
Beam & beam()
Definition: ISimulation.h:58
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
Main class to run an off-specular simulation.
size_t intensityMapSize() const override
Returns the total number of the intensity values in the simulation result.
OutputData< double > m_intensity_map
void prepareSimulation() override
Put into a clean state for running a simulation.
size_t numberOfSimulationElements() const override
Gets the number of elements this simulation needs to calculate.
const IAxis * beamAxis() const
Returns axis of the beam.
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
void validateParametrization(const ParameterDistribution &par_distr) const override
Checks the distribution validity for simulation.
void transferDetectorImage(size_t index)
Normalize, apply detector resolution and transfer detector image corresponding to alpha_i = m_alpha_i...
void initSimulationElementVector() override
Initializes the vector of ISimulation elements.
std::unique_ptr< IAxis > m_alpha_i_axis
void updateIntensityMap() override
Default implementation only adds the detector axes.
SimulationResult result() const override
Returns the results of the simulation in a format that supports unit conversion and export to numpy a...
void transferResultsToIntensityMap() override
Creates the appropriate data structure (e.g.
std::unique_ptr< IUnitConverter > createUnitConverter() const
void setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)
Sets beam parameters from here (forwarded to Instrument)
OffSpecularSimulation * clone() const override
void checkInitialization() const
Check correct number of axes.
A parametric distribution function, for use with any model parameter.
Wrapper around OutputData<double> that also provides unit conversions.