BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
GISASSimulation.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Simulation/GISASSimulation.cpp
6 //! @brief Implements class Simulation.
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 
22 
24 {
25  initialize();
26 }
27 
29 {
30  if (instrument().getDetectorDimension() != 2)
32  "GISASSimulation::prepareSimulation() "
33  "-> Error. The detector was not properly configured.");
36 }
37 
39 {
41  const std::unique_ptr<OutputData<double>> data(
42  instrument().detector().createDetectorIntensity(m_sim_elements));
43  return SimulationResult(*data, *converter);
44 }
45 
46 void GISASSimulation::setBeamParameters(double wavelength, double alpha_i, double phi_i)
47 {
48  if (wavelength <= 0.0)
50  "Simulation::setBeamParameters() -> Error. Incoming wavelength <= 0.");
51  instrument().setBeamParameters(wavelength, alpha_i, phi_i);
52 }
53 
55 {
56  size_t result = 0;
58  return result;
59 }
60 
62 {
63  initialize();
64 }
65 
67 {
68  auto beam = instrument().getBeam();
70  if (m_cache.empty())
71  m_cache.resize(m_sim_elements.size(), 0.0);
72 }
73 
75 {
76  setName("GISASSimulation");
77 }
Defines class DWBAComputation.
Defines class GISASSimulation.
Defines class Histogram2D.
Defines interface IBackground.
Defines pure virtual base class ISampleBuilder.
Defines class MultiLayer.
Declares utilities for unit converters.
Main class to run a Grazing-Incidence Small-Angle Scattering simulation.
void initSimulationElementVector() override
Initializes the vector of Simulation elements.
void setBeamParameters(double wavelength, double alpha_i, double phi_i)
Sets beam parameters from here (forwarded to Instrument)
size_t intensityMapSize() const override
Returns the total number of the intensity values in the simulation result.
void prepareSimulation() override
Put into a clean state for running a simulation.
SimulationResult result() const override
Returns the results of the simulation in a format that supports unit conversion and export to numpy a...
void iterate(std::function< void(const_iterator)> func, bool visit_masks=false) const
Definition: IDetector.cpp:201
void setName(const std::string &name)
Beam & getBeam()
Definition: Instrument.h:44
void setBeamParameters(double wavelength, double alpha_i, double phi_i)
Sets the beam wavelength and incoming angles.
Definition: Instrument.cpp:87
IDetector & detector()
Definition: Instrument.cpp:133
void initDetector()
init detector with beam settings
Definition: Instrument.cpp:55
Pure virtual base class of OffSpecularSimulation and GISASSimulation.
Definition: Simulation2D.h:27
std::vector< double > m_cache
Definition: Simulation2D.h:95
std::vector< SimulationElement > m_sim_elements
Definition: Simulation2D.h:94
std::vector< SimulationElement > generateSimulationElements(const Beam &beam)
Generate simulation elements for given beam.
void prepareSimulation() override
Put into a clean state for running a simulation.
An iterator for SimulationArea.
Wrapper around OutputData<double> that also provides unit conversions.
const Instrument & instrument() const
Definition: Simulation.h:55
std::unique_ptr< IUnitConverter > createConverterForGISAS(const Instrument &instrument)
Helper factory function to use in GISASSimulation.