56 if (alpha_axis.
size() < 1)
57 throw std::runtime_error(
"OffSpecularSimulation::prepareSimulation() "
58 "-> Error. Incoming alpha range size < 1.");
59 const double alpha_zero = alpha_axis.
lowerBound();
73 throw std::runtime_error(
"Error in OffSpecularSimulation::createUnitConverter:"
74 " missing inclination angle axis");
75 return std::make_unique<OffSpecularConverter>(
detector2D(),
beam(), *axis);
100 for (
auto ele : sim_elements_i)
114 const std::vector<RealParameter*> names =
116 for (
const auto par : names)
117 if (par->getName().find(
"InclinationAngle") != std::string::npos && !zero_mean)
118 throw std::runtime_error(
"Error in OffSpecularSimulation: parameter distribution of "
119 "beam inclination angle should have zero mean.");
126 size_t phi_f_size = phi_axis.
size();
128 throw std::runtime_error(
129 "OffSpecularSimulation::transferResultsToIntensityMap: "
130 "intensity map size does not conform to number of calculated intensities");
141 if (detector_dimension == 2)
150 for (
size_t dim = 0; dim < detector_dimension; ++dim)
153 for (
size_t i = 0; i < detector_size; ++i)
154 detector_image[i] =
m_sim_elements[index * detector_size + i].intensity();
157 for (
size_t i = 0; i < detector_size; ++i)
158 m_intensity_map[index * y_axis_size + i % y_axis_size] += detector_image[i];
164 throw std::runtime_error(
"OffSpecularSimulation::checkInitialization() "
165 "Incoming alpha range not configured.");
167 throw std::runtime_error(
168 "OffSpecularSimulation::checkInitialization: detector is not two-dimensional");
173 setName(
"OffSpecularSimulation");
Defines classes representing one-dimensional distributions.
Defines interface ISampleBuilder.
Defines class OffSpecularSimulation.
Defines class ParameterPool.
Defines class RealParameter.
Defines interface UnitConverterSimple and its subclasses.
An incident neutron or x-ray beam.
void setInclination(const double alpha)
Interface for one-dimensional axes.
virtual IAxis * clone() const =0
clone function
virtual size_t size() const =0
retrieve the number of bins
virtual double lowerBound() const =0
Returns value of first point of axis.
Abstract detector interface.
void applyDetectorResolution(OutputData< double > *p_intensity_map) const
Applies the detector resolution to the given intensity maps.
size_t dimension() const
Returns actual dimensionality of the detector (number of defined axes)
const IAxis & axis(size_t index) const
virtual double getMean() const =0
Returns the distribution-specific mean.
ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.
void setName(const std::string &name)
Abstract base class of OffSpecularSimulation and GISASSimulation.
size_t numberOfSimulationElements() const override
Gets the number of elements this simulation needs to calculate.
std::vector< SimulationElement > generateSimulationElements(const Beam &beam)
Generate simulation elements for given beam.
IDetector2D & detector2D()
std::vector< SimulationElement > m_sim_elements
void prepareSimulation() override
Put into a clean state for running a simulation.
std::vector< double > m_cache
const Instrument & instrument() const
void setBeamParameters(double wavelength, double alpha_i, double phi_i)
Sets the beam wavelength and incoming angles.
Our sample model: a stack of layers one below the other.
IUnitConverter class that handles the unit translations for off-specular simulations with a spherical...
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 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)
void checkInitialization() const
Check correct number of axes.
void copyFrom(const OutputData< T > &x)
void setAllTo(const T &value)
Sets content of output data to specific value.
void addAxis(const IAxis &new_axis)
size_t getAllocatedSize() const
Returns total size of data buffer (product of bin number in every dimension).
OutputData * clone() const
void clear()
Sets object into initial state (no dimensions, data)
A parametric distribution function, for use with any model parameter.
const IDistribution1D * getDistribution() const
std::string getMainParameterName() const
get the main parameter's name
Wrapper around OutputData<double> that also provides unit conversions.