53 if (alpha_axis.
size() < 1)
55 "-> Error. Incoming alpha range size < 1.");
56 const double alpha_zero = alpha_axis.
getMin();
70 throw std::runtime_error(
"Error in OffSpecSimulation::createUnitConverter:"
71 " missing inclination angle axis");
95 const double phi_i = beam.
getPhi();
100 double total_alpha = alpha_i;
104 std::make_move_iterator(sim_elements_i.end()));
117 const std::vector<RealParameter*> names =
119 for (
const auto par : names)
120 if (par->getName().find(
"InclinationAngle") != std::string::npos && !zero_mean)
121 throw std::runtime_error(
"Error in OffSpecSimulation: parameter distribution of "
122 "beam inclination angle should have zero mean.");
129 size_t phi_f_size = phi_axis.
size();
132 "OffSpecSimulation::transferResultsToIntensityMap: "
133 "intensity map size does not conform to number of calculated intensities");
144 if (detector_dimension == 2)
153 for (
size_t dim = 0; dim < detector_dimension; ++dim)
156 for (
size_t i = 0; i < detector_size; ++i)
157 detector_image[i] =
m_sim_elements[index * detector_size + i].getIntensity();
160 for (
size_t i = 0; i < detector_size; ++i)
161 m_intensity_map[index * y_axis_size + i % y_axis_size] += detector_image[i];
168 "Incoming alpha range not configured.");
171 "OffSpecSimulation::checkInitialization: detector is not two-dimensional");
Defines class DWBAComputation.
Defines classes representing one-dimensional distributions.
Defines class Histogram2D.
Defines pure virtual base class ISampleBuilder.
Defines class MultiLayer.
Defines class OffSpecSimulation.
Defines class ParameterPool.
Defines class RealParameter.
Defines interface UnitConverterSimple and its subclasses.
Beam defined by wavelength, direction and intensity.
double getWavelength() const
void setCentralK(double wavelength, double alpha_i, double phi_i)
Sets the wavevector in terms of wavelength and incoming angles.
Interface for one-dimensional axes.
virtual IAxis * clone() const =0
clone function
virtual double getMin() const =0
Returns value of first point of axis.
virtual size_t size() const =0
retrieve the number of bins
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)
void applyDetectorResolution(OutputData< double > *p_intensity_map) const
apply the detector resolution to the given intensity map
const IAxis & getDetectorAxis(size_t index) const
void setBeamParameters(double wavelength, double alpha_i, double phi_i)
Sets the beam wavelength and incoming angles.
size_t getDetectorDimension() const
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.
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
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)
IUnitConverter class that handles the unit translations for off-specular simulations with a spherical...
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
Pure virtual base class of OffSpecularSimulation and GISASSimulation.
size_t numberOfSimulationElements() const override
Gets the number of elements this simulation needs to calculate.
std::vector< double > m_cache
std::vector< SimulationElement > m_sim_elements
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.
Wrapper around OutputData<double> that also provides unit conversions.
const Instrument & instrument() const
const double wavelength(0.154)