BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ISimulation2D Class Referenceabstract

Abstract base class of OffSpecularSimulation and GISASSimulation. More...

Inheritance diagram for ISimulation2D:
[legend]
Collaboration diagram for ISimulation2D:
[legend]

Public Member Functions

 ISimulation2D ()
 
 ISimulation2D (const Beam &beam, const IDetector &detector)
 
 ISimulation2D (const Beam &beam, const MultiLayer &sample, const IDetector &detector)
 
 ~ISimulation2D () override
 
virtual void accept (INodeVisitor *visitor) const =0
 Calls the INodeVisitor's visit method. More...
 
void addMask (const IShape2D &shape, bool mask_value=true)
 Adds mask of given shape to the stack of detector masks. More...
 
void addParameterDistribution (const ParameterDistribution &par_distr)
 
void addParameterDistribution (const std::string &param_name, const IDistribution1D &distribution, size_t nbr_samples, double sigma_factor=0.0, const RealLimits &limits=RealLimits())
 
const IBackgroundbackground () const
 
Beambeam ()
 
const Beambeam () const
 
ISimulation2Dclone () const override=0
 
SimulationResult convertData (const OutputData< double > &data, bool put_masked_areas_to_zero=true)
 Convert user data to SimulationResult object for later drawing in various axes units. More...
 
int copyNumber (const INode *node) const
 Returns copyNumber of child, which takes into account existence of children with same name. More...
 
ParameterPoolcreateParameterTree () const
 Creates new parameter pool, with all local parameters and those of its children. More...
 
IDetectordetector ()
 
const IDetectordetector () const
 
IDetector2Ddetector2D ()
 
const IDetector2Ddetector2D () const
 
std::string displayName () const
 Returns display name, composed from the name of node and it's copy number. More...
 
std::vector< const INode * > getChildren () const
 Returns a vector of children. More...
 
IDetectorgetDetector ()
 
const IDetectorgetDetector () const
 
const DistributionHandlergetDistributionHandler () const
 
const std::string & getName () const
 
SimulationOptionsgetOptions ()
 
const SimulationOptionsgetOptions () const
 
Instrumentinstrument ()
 
const Instrumentinstrument () const
 
virtual size_t intensityMapSize () const =0
 Returns the total number of the intensity values in the simulation result. More...
 
void maskAll ()
 Put the mask for all detector channels (i.e. exclude whole detector from the analysis) More...
 
virtual void onChange ()
 Action to be taken in inherited class when a parameter has changed. More...
 
RealParameterparameter (const std::string &name) const
 Returns parameter with given 'name'. More...
 
ParameterPoolparameterPool () const
 Returns pointer to the parameter pool. More...
 
std::string parametersToString () const
 Returns multiline string representing available parameters. More...
 
INodeparent ()
 
const INodeparent () const
 
void prepareSimulation () override
 Put into a clean state for running a simulation. More...
 
std::vector< const INode * > progeny () const
 Returns a vector of all descendants. More...
 
void registerChild (INode *node)
 
RealParameterregisterParameter (const std::string &name, double *parpointer)
 
void registerVector (const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
 
void removeParameter (const std::string &name)
 
void removeVector (const std::string &base_name)
 
virtual SimulationResult result () const =0
 Returns the results of the simulation in a format that supports unit conversion and export to numpy arrays. More...
 
void runMPISimulation ()
 Run a simulation in a MPI environment. More...
 
void runSimulation ()
 Run a simulation, possibly averaged over parameter distributions. More...
 
const MultiLayersample () const
 
void setBackground (const IBackground &bg)
 
void setDetector (const IDetector2D &detector)
 Sets the detector (axes can be overwritten later) More...
 
void setDetectorParameters (size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max)
 Sets spherical detector parameters using angle ranges. More...
 
void setDetectorResolutionFunction (const IResolutionFunction2D &resolution_function)
 
void setInstrument (const Instrument &instrument_)
 
void setName (const std::string &name)
 
void setOptions (const SimulationOptions &options)
 
void setParameterValue (const std::string &name, double value)
 
virtual void setParent (const INode *newParent)
 
void setRegionOfInterest (double xlow, double ylow, double xup, double yup)
 Sets rectangular region of interest with lower left and upper right corners defined. More...
 
void setSample (const MultiLayer &sample)
 The MultiLayer object will not be owned by the ISimulation object. More...
 
void setSampleBuilder (const std::shared_ptr< ISampleBuilder > &sample_builder)
 
void setTerminalProgressMonitor ()
 Initializes a progress monitor that prints to stdout. More...
 
void setVectorValue (const std::string &base_name, kvector_t value)
 
void subscribe (ProgressHandler::Callback_t inform)
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
virtual std::string treeToString () const
 Returns multiline string representing tree structure below the node. More...
 

Static Public Member Functions

static std::string XComponentName (const std::string &base_name)
 
static std::string YComponentName (const std::string &base_name)
 
static std::string ZComponentName (const std::string &base_name)
 

Protected Member Functions

 ISimulation2D (const ISimulation2D &other)
 
void addBackgroundIntensity (size_t start_ind, size_t n_elements) override
 
void addDataToCache (double weight) override
 
std::vector< SimulationElementgenerateSimulationElements (const Beam &beam)
 Generate simulation elements for given beam. More...
 
std::unique_ptr< IComputationgenerateSingleThreadedComputation (size_t start, size_t n_elements) override
 Generate a single threaded computation for a given range of simulation elements. More...
 
virtual void initSimulationElementVector ()=0
 Initializes the vector of ISimulation elements. More...
 
virtual void initUnitConverter ()
 
void moveDataFromCache () override
 
void normalize (size_t start_ind, size_t n_elements) override
 Normalize the detector counts to beam intensity, to solid angle, and to exposure angle. More...
 
size_t numberOfSimulationElements () const override
 Gets the number of elements this simulation needs to calculate. More...
 
const SimulationOptionsoptions () const
 
ProgressHandlerprogress ()
 
virtual void transferResultsToIntensityMap ()
 Creates the appropriate data structure (e.g. More...
 
virtual void updateIntensityMap ()
 

Protected Attributes

std::vector< double > m_cache
 
const size_t m_NP
 
std::vector< double > m_P
 
std::vector< SimulationElementm_sim_elements
 

Private Member Functions

void initialize ()
 
std::vector< double > rawResults () const override
 
void runSingleSimulation (size_t batch_start, size_t batch_size, double weight=1.0)
 Runs a single simulation with fixed parameter values. More...
 
void setRawResults (const std::vector< double > &raw_data) override
 
virtual void validateParametrization (const ParameterDistribution &) const
 Checks the distribution validity for simulation. More...
 

Private Attributes

std::unique_ptr< IBackgroundm_background
 
std::unique_ptr< DetectorContextm_detector_context
 
DistributionHandler m_distribution_handler
 
Instrument m_instrument
 
std::string m_name
 
SimulationOptions m_options
 
const INodem_parent {nullptr}
 
std::unique_ptr< ParameterPoolm_pool
 parameter pool (kind of pointer-to-implementation) More...
 
ProgressHandler m_progress
 
SampleProvider m_sample_provider
 

Detailed Description

Abstract base class of OffSpecularSimulation and GISASSimulation.

Holds the common implementations for simulations with a 2D detector

Definition at line 27 of file ISimulation2D.h.

Constructor & Destructor Documentation

◆ ISimulation2D() [1/4]

ISimulation2D::ISimulation2D ( const Beam beam,
const MultiLayer sample,
const IDetector detector 
)

Definition at line 22 of file ISimulation2D.cpp.

24 {
25 }
const MultiLayer * sample() const
IDetector & detector()
Definition: ISimulation.h:63
Beam & beam()
Definition: ISimulation.h:58

◆ ISimulation2D() [2/4]

ISimulation2D::ISimulation2D ( const Beam beam,
const IDetector detector 
)

Definition at line 28 of file ISimulation2D.cpp.

30 {
31 }

◆ ISimulation2D() [3/4]

ISimulation2D::ISimulation2D ( )
default

◆ ~ISimulation2D()

ISimulation2D::~ISimulation2D ( )
overridedefault

◆ ISimulation2D() [4/4]

ISimulation2D::ISimulation2D ( const ISimulation2D other)
protected

Definition at line 75 of file ISimulation2D.cpp.

77 {
78 }
std::vector< SimulationElement > m_sim_elements
Definition: ISimulation2D.h:98
std::vector< double > m_cache
Definition: ISimulation2D.h:99

Member Function Documentation

◆ accept()

virtual void INode::accept ( INodeVisitor visitor) const
pure virtualinherited

Calls the INodeVisitor's visit method.

Implemented in FormFactorDecoratorMaterial, FormFactorWeighted, FormFactorCrystal, FormFactorCoreShell, Lattice3D, MisesGaussPeakShape, MisesFisherGaussPeakShape, LorentzFisherPeakShape, GaussFisherPeakShape, IsotropicLorentzPeakShape, IsotropicGaussPeakShape, ParticleLayout, InterferenceFunctionHardDisk, InterferenceFunctionFinite3DLattice, InterferenceFunctionFinite2DLattice, InterferenceFunction3DLattice, InterferenceFunction2DSuperLattice, InterferenceFunction2DParaCrystal, InterferenceFunction2DLattice, InterferenceFunction1DLattice, SphericalDetector, SpecularDetector1D, FootprintSquare, FootprintGauss, Beam, OffSpecularSimulation, GISASSimulation, PoissonNoiseBackground, ConstantBackground, FormFactorSphereLogNormalRadius, FormFactorSphereGaussianRadius, FormFactorGaussSphere, FormFactorDecoratorRotation, FormFactorDecoratorPositionFactor, SampleProvider, SampleBuilderNode, ParticleDistribution, ParticleCoreShell, ParticleComposition, Particle, MesoCrystal, Crystal, MultiLayer, Layer, HexagonalLattice2D, SquareLattice2D, BasicLattice2D, FormFactorTruncatedSpheroid, FormFactorTruncatedSphere, FormFactorTruncatedCube, FormFactorTetrahedron, FormFactorSawtoothRippleLorentz, FormFactorSawtoothRippleGauss, FormFactorSawtoothRippleBox, FormFactorPyramid, FormFactorPrism6, FormFactorPrism3, FormFactorLongBoxLorentz, FormFactorLongBoxGauss, FormFactorIcosahedron, FormFactorHollowSphere, FormFactorHemiEllipsoid, FormFactorFullSpheroid, FormFactorFullSphere, FormFactorEllipsoidalCylinder, FormFactorDot, FormFactorDodecahedron, FormFactorCylinder, FormFactorCuboctahedron, FormFactorCosineRippleLorentz, FormFactorCosineRippleGauss, FormFactorCosineRippleBox, FormFactorCone6, FormFactorCone, FormFactorCantellatedCube, FormFactorBox, FormFactorBarLorentz, FormFactorBarGauss, FormFactorAnisoPyramid, FTDistribution2DVoigt, FTDistribution2DCone, FTDistribution2DGate, FTDistribution2DGauss, FTDistribution2DCauchy, FTDistribution1DVoigt, FTDistribution1DCosine, FTDistribution1DTriangle, FTDistribution1DGate, FTDistribution1DGauss, FTDistribution1DCauchy, FTDecayFunction2DVoigt, FTDecayFunction2DGauss, FTDecayFunction2DCauchy, FTDecayFunction1DVoigt, FTDecayFunction1DTriangle, FTDecayFunction1DGauss, FTDecayFunction1DCauchy, InterferenceFunctionTwin, InterferenceFunctionRadialParaCrystal, InterferenceFunctionNone, DistributionTrapezoid, DistributionCosine, DistributionLogNormal, DistributionGaussian, DistributionLorentz, DistributionGate, ResolutionFunction2DGaussian, ConvolutionDetectorResolution, Instrument, RectangularDetector, IsGISAXSDetector, DetectionProperties, SpecularSimulation, DepthProbeSimulation, LayerRoughness, LayerInterface, RotationEuler, RotationZ, RotationY, RotationX, IdentityRotation, and IAbstractParticle.

◆ addBackgroundIntensity()

void ISimulation2D::addBackgroundIntensity ( size_t  start_ind,
size_t  n_elements 
)
overrideprotectedvirtual

Implements ISimulation.

Definition at line 151 of file ISimulation2D.cpp.

152 {
153  if (!background())
154  return;
155  for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
156  SimulationElement& element = m_sim_elements[i];
157  element.setIntensity(background()->addBackground(element.intensity()));
158  }
159 }
const IBackground * background() const
Definition: ISimulation.h:74
Data stucture containing both input and output of a single detector cell.
double intensity() const
void setIntensity(double intensity)

References ISimulation::background(), SimulationElement::intensity(), m_sim_elements, and SimulationElement::setIntensity().

Here is the call graph for this function:

◆ addDataToCache()

void ISimulation2D::addDataToCache ( double  weight)
overrideprotectedvirtual

Implements ISimulation.

Definition at line 161 of file ISimulation2D.cpp.

162 {
163  if (m_sim_elements.size() != m_cache.size())
164  throw std::runtime_error("Error in ISimulation2D::addDataToCache(double): cache size"
165  " not the same as element size");
166  for (unsigned i = 0; i < m_sim_elements.size(); i++)
167  m_cache[i] += m_sim_elements[i].intensity() * weight;
168 }

References m_cache, and m_sim_elements.

◆ addMask()

void ISimulation2D::addMask ( const IShape2D shape,
bool  mask_value = true 
)

Adds mask of given shape to the stack of detector masks.

The mask value 'true' means that the channel will be excluded from the simulation. The mask which is added last has priority.

Parameters
shapeThe shape of mask (Rectangle, Polygon, Line, Ellipse)
mask_valueThe value of mask

Definition at line 60 of file ISimulation2D.cpp.

61 {
62  detector2D().addMask(shape, mask_value);
63 }
void addMask(const IShape2D &shape, bool mask_value=true)
Adds mask of given shape to the stack of detector masks.
Definition: IDetector2D.cpp:74
IDetector2D & detector2D()

References IDetector2D::addMask(), and detector2D().

Referenced by StandardSimulations::GISASWithMasks(), StandardSimulations::RectDetWithRoi(), and StandardSimulations::SphericalDetWithRoi().

Here is the call graph for this function:

◆ addParameterDistribution() [1/2]

void ISimulation::addParameterDistribution ( const ParameterDistribution par_distr)
inherited

Definition at line 272 of file ISimulation.cpp.

273 {
274  validateParametrization(par_distr);
276 }
void addParameterDistribution(const std::string &param_name, const IDistribution1D &distribution, size_t nbr_samples, double sigma_factor=0.0, const RealLimits &limits=RealLimits())
add a sampled parameter distribution
virtual void validateParametrization(const ParameterDistribution &) const
Checks the distribution validity for simulation.
Definition: ISimulation.h:139
DistributionHandler m_distribution_handler
Definition: ISimulation.h:159

References DistributionHandler::addParameterDistribution(), ISimulation::m_distribution_handler, and ISimulation::validateParametrization().

Here is the call graph for this function:

◆ addParameterDistribution() [2/2]

void ISimulation::addParameterDistribution ( const std::string &  param_name,
const IDistribution1D distribution,
size_t  nbr_samples,
double  sigma_factor = 0.0,
const RealLimits limits = RealLimits() 
)
inherited

Definition at line 264 of file ISimulation.cpp.

267 {
268  ParameterDistribution par_distr(param_name, distribution, nbr_samples, sigma_factor, limits);
269  addParameterDistribution(par_distr);
270 }
void addParameterDistribution(const std::string &param_name, const IDistribution1D &distribution, size_t nbr_samples, double sigma_factor=0.0, const RealLimits &limits=RealLimits())
A parametric distribution function, for use with any model parameter.

Referenced by StandardSimulations::MiniGISASBeamDivergence(), and TransformToDomain::setBeamDistribution().

◆ background()

const IBackground* ISimulation::background ( ) const
inlineinherited

◆ beam() [1/2]

◆ beam() [2/2]

const Beam& ISimulation::beam ( ) const
inlineinherited

Definition at line 59 of file ISimulation.h.

59 { return m_instrument.beam(); }

References Instrument::beam(), and ISimulation::m_instrument.

Here is the call graph for this function:

◆ clone()

ISimulation2D* ISimulation2D::clone ( ) const
overridepure virtual

Implements ISimulation.

Implemented in OffSpecularSimulation, and GISASSimulation.

◆ convertData()

SimulationResult ISimulation::convertData ( const OutputData< double > &  data,
bool  put_masked_areas_to_zero = true 
)
inherited

Convert user data to SimulationResult object for later drawing in various axes units.

User data will be cropped to the ROI defined in the simulation, amplitudes in areas corresponding to the masked areas of the detector will be set to zero.

Definition at line 308 of file ISimulation.cpp.

310 {
311  auto converter = UnitConverterUtils::createConverter(*this);
312  auto roi_data = UnitConverterUtils::createOutputData(*converter, converter->defaultUnits());
313 
314  if (roi_data->hasSameDimensions(data)) {
315  // data is already cropped to ROI
316  if (put_masked_areas_to_zero) {
317  detector().iterate(
318  [&](IDetector::const_iterator it) {
319  (*roi_data)[it.roiIndex()] = data[it.roiIndex()];
320  },
321  /*visit_masked*/ false);
322  } else {
323  roi_data->setRawDataVector(data.getRawDataVector());
324  }
325 
326  } else if (detHasSameDimensions(detector(), data)) {
327  // exp data has same shape as the detector, we have to put orig data to smaller roi map
328  detector().iterate(
329  [&](IDetector::const_iterator it) {
330  (*roi_data)[it.roiIndex()] = data[it.detectorIndex()];
331  },
332  /*visit_masked*/ !put_masked_areas_to_zero);
333 
334  } else {
335  throw std::runtime_error("FitObject::init_dataset() -> Error. Detector and exp data have "
336  "different shape.");
337  }
338 
339  return SimulationResult(*roi_data, *converter);
340 }
void iterate(std::function< void(const_iterator)> func, bool visit_masks=false) const
Definition: IDetector.cpp:197
std::vector< T > getRawDataVector() const
Returns copy of raw data vector.
Definition: OutputData.h:334
An iterator for SimulationArea.
Wrapper around OutputData<double> that also provides unit conversions.
std::unique_ptr< IUnitConverter > createConverter(const ISimulation &simulation)
std::unique_ptr< OutputData< double > > createOutputData(const IUnitConverter &converter, Axes::Units units)
Returns zero-valued output data array in specified units.

References UnitConverterUtils::createConverter(), UnitConverterUtils::createOutputData(), ISimulation::detector(), SimulationAreaIterator::detectorIndex(), OutputData< T >::getRawDataVector(), IDetector::iterate(), and SimulationAreaIterator::roiIndex().

Here is the call graph for this function:

◆ copyNumber()

int INode::copyNumber ( const INode node) const
inherited

Returns copyNumber of child, which takes into account existence of children with same name.

Definition at line 94 of file INode.cpp.

95 {
96  if (node->parent() != this)
97  return -1;
98 
99  int result(-1), count(0);
100  for (auto child : getChildren()) {
101 
102  if (child == nullptr)
103  throw std::runtime_error("INode::copyNumber() -> Error. Nullptr as child.");
104 
105  if (child == node)
106  result = count;
107 
108  if (child->getName() == node->getName())
109  ++count;
110  }
111 
112  return count > 1 ? result : -1;
113 }
const INode * parent() const
Definition: INode.cpp:84
virtual std::vector< const INode * > getChildren() const
Returns a vector of children.
Definition: INode.cpp:63
const std::string & getName() const

References INode::getChildren(), IParametricComponent::getName(), and INode::parent().

Referenced by INode::displayName().

Here is the call graph for this function:

◆ createParameterTree()

ParameterPool * INode::createParameterTree ( ) const
virtualinherited

Creates new parameter pool, with all local parameters and those of its children.

Reimplemented from IParametricComponent.

Definition at line 126 of file INode.cpp.

127 {
128  std::unique_ptr<ParameterPool> result(new ParameterPool);
129 
130  for (const INode* child : progeny()) {
131  const std::string path = NodeUtils::nodePath(child, parent()) + "/";
132  child->parameterPool()->copyToExternalPool(path, result.get());
133  }
134 
135  return result.release();
136 }
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
std::vector< const INode * > progeny() const
Returns a vector of all descendants.
Definition: INode.cpp:68
Container with parameters for IParametricComponent object.
Definition: ParameterPool.h:29
std::string nodePath(const INode *node, const INode *root=nullptr)
Returns path composed of node's displayName, with respect to root node.
Definition: NodeUtils.cpp:89

References NodeUtils::nodePath(), INode::parent(), and INode::progeny().

Referenced by ISimulation::runSimulation(), DepthProbeSimulation::validateParametrization(), OffSpecularSimulation::validateParametrization(), and SpecularSimulation::validateParametrization().

Here is the call graph for this function:

◆ detector() [1/2]

◆ detector() [2/2]

const IDetector& ISimulation::detector ( ) const
inlineinherited

Definition at line 64 of file ISimulation.h.

64 { return m_instrument.detector(); }

References Instrument::detector(), and ISimulation::m_instrument.

Here is the call graph for this function:

◆ detector2D() [1/2]

IDetector2D & ISimulation2D::detector2D ( )

Definition at line 38 of file ISimulation2D.cpp.

39 {
41  IDetector2D* p = dynamic_cast<IDetector2D*>(getDetector());
42  ASSERT(p);
43  return *p;
44 }
#define ASSERT(condition)
Definition: Assert.h:31
Abstract 2D detector interface.
Definition: IDetector2D.h:31
IDetector * getDetector()
Definition: ISimulation.h:61

References ASSERT, and ISimulation::getDetector().

Referenced by addMask(), OffSpecularSimulation::createUnitConverter(), generateSimulationElements(), maskAll(), prepareSimulation(), OffSpecularSimulation::result(), setDetectorParameters(), and setRegionOfInterest().

Here is the call graph for this function:

◆ detector2D() [2/2]

const IDetector2D & ISimulation2D::detector2D ( ) const

Definition at line 46 of file ISimulation2D.cpp.

47 {
49  const IDetector2D* p = dynamic_cast<const IDetector2D*>(getDetector());
50  ASSERT(p);
51  return *p;
52 }

References ASSERT, and ISimulation::getDetector().

Here is the call graph for this function:

◆ displayName()

std::string INode::displayName ( ) const
inherited

Returns display name, composed from the name of node and it's copy number.

Definition at line 115 of file INode.cpp.

116 {
117  std::string result = getName();
118  if (m_parent) {
119  int index = m_parent->copyNumber(this);
120  if (index >= 0)
121  result = result + std::to_string(index);
122  }
123  return result;
124 }
const INode * m_parent
Definition: INode.h:83
int copyNumber(const INode *node) const
Returns copyNumber of child, which takes into account existence of children with same name.
Definition: INode.cpp:94

References INode::copyNumber(), IParametricComponent::getName(), and INode::m_parent.

Referenced by NodeUtils::nodePath().

Here is the call graph for this function:

◆ generateSimulationElements()

std::vector< SimulationElement > ISimulation2D::generateSimulationElements ( const Beam beam)
protected

Generate simulation elements for given beam.

Definition at line 111 of file ISimulation2D.cpp.

112 {
113  const double wavelength = beam.wavelength();
114  const double alpha_i = -beam.direction().alpha(); // Defined to be always positive in Beam
115  const double phi_i = beam.direction().phi();
116  const Eigen::Matrix2cd beam_polarization = beam.getPolarization();
117 
118  const IDetector2D& detector = detector2D();
119  const Eigen::Matrix2cd analyzer_operator = detector.detectionProperties().analyzerOperator();
120  const size_t spec_index = detector.indexOfSpecular(beam);
121 
122  const size_t N = m_detector_context->numberOfSimulationElements();
123 
124  std::vector<SimulationElement> result;
125  result.reserve(N);
126  for (size_t element_index = 0; element_index < N; ++element_index) {
127  SimulationElement element(wavelength, alpha_i, phi_i,
128  m_detector_context->createPixel(element_index), beam_polarization,
129  analyzer_operator,
130  m_detector_context->detectorIndex(element_index) == spec_index);
131  result.emplace_back(std::move(element));
132  }
133  return result;
134 }
Direction direction() const
Definition: Beam.h:45
Eigen::Matrix2cd getPolarization() const
Returns the polarization density matrix (in spin basis along z-axis)
Definition: Beam.cpp:127
double wavelength() const
Definition: Beam.h:43
Eigen::Matrix2cd analyzerOperator() const
Return the polarization density matrix (in spin basis along z-axis)
double phi() const
Definition: Direction.h:30
double alpha() const
Definition: Direction.h:29
const DetectionProperties & detectionProperties() const
Returns detection properties.
Definition: IDetector.h:82
std::unique_ptr< DetectorContext > m_detector_context
virtual SimulationResult result() const =0
Returns the results of the simulation in a format that supports unit conversion and export to numpy a...

References Direction::alpha(), DetectionProperties::analyzerOperator(), ISimulation::beam(), IDetector::detectionProperties(), ISimulation::detector(), detector2D(), Beam::direction(), Beam::getPolarization(), m_detector_context, Direction::phi(), ISimulation::result(), and Beam::wavelength().

Referenced by GISASSimulation::initSimulationElementVector(), and OffSpecularSimulation::initSimulationElementVector().

Here is the call graph for this function:

◆ generateSingleThreadedComputation()

std::unique_ptr< IComputation > ISimulation2D::generateSingleThreadedComputation ( size_t  start,
size_t  n_elements 
)
overrideprotectedvirtual

Generate a single threaded computation for a given range of simulation elements.

Parameters
startIndex of the first element to include into computation
n_elementsNumber of elements to process

Implements ISimulation.

Definition at line 100 of file ISimulation2D.cpp.

102 {
103  ASSERT(start < m_sim_elements.size() && start + n_elements <= m_sim_elements.size());
104  const auto& begin = m_sim_elements.begin() + static_cast<long>(start);
105  const auto polarized =
107  return std::make_unique<DWBAComputation>(*sample(), options(), progress(), begin,
108  begin + static_cast<long>(n_elements), polarized);
109 }
kvector_t analyzerDirection() const
Retrieve the analyzer characteristics.
ProgressHandler & progress()
Definition: ISimulation.h:125
const SimulationOptions & options() const
Definition: ISimulation.h:124
matrixFFVector_t polarized(const SimulationElement &sim_element, const std::vector< FormFactorCoherentSum > &ff_wrappers)

References DetectionProperties::analyzerDirection(), ASSERT, IDetector::detectionProperties(), ISimulation::detector(), m_sim_elements, ISimulation::options(), FormFactorPrecompute::polarized(), ISimulation::progress(), and ISimulation::sample().

Here is the call graph for this function:

◆ getChildren()

std::vector< const INode * > ISimulation::getChildren ( ) const
virtualinherited

Returns a vector of children.

Reimplemented from INode.

Definition at line 254 of file ISimulation.cpp.

255 {
256  std::vector<const INode*> result;
257  result.push_back(&instrument());
259  if (m_background)
260  result.push_back(m_background.get());
261  return result;
262 }
SampleProvider m_sample_provider
Definition: ISimulation.h:158
const Instrument & instrument() const
Definition: ISimulation.h:55
std::vector< const INode * > getChildren() const override
Returns a vector of children.

References SampleProvider::getChildren(), ISimulation::instrument(), ISimulation::m_background, ISimulation::m_sample_provider, and ISimulation::result().

Here is the call graph for this function:

◆ getDetector() [1/2]

IDetector* ISimulation::getDetector ( )
inlineinherited

Definition at line 61 of file ISimulation.h.

61 { return m_instrument.getDetector(); }
IDetector * getDetector()
Definition: Instrument.cpp:96

References Instrument::getDetector(), and ISimulation::m_instrument.

Referenced by detector2D(), TransformFromDomain::setDetector(), and TransformFromDomain::setDetectorMasks().

Here is the call graph for this function:

◆ getDetector() [2/2]

const IDetector* ISimulation::getDetector ( ) const
inlineinherited

Definition at line 62 of file ISimulation.h.

62 { return m_instrument.getDetector(); }

References Instrument::getDetector(), and ISimulation::m_instrument.

Here is the call graph for this function:

◆ getDistributionHandler()

const DistributionHandler& ISimulation::getDistributionHandler ( ) const
inlineinherited

Definition at line 88 of file ISimulation.h.

88 { return m_distribution_handler; }

References ISimulation::m_distribution_handler.

Referenced by TransformFromDomain::setGISASBeamItem().

◆ getName()

◆ getOptions() [1/2]

SimulationOptions& ISimulation::getOptions ( )
inlineinherited

Definition at line 92 of file ISimulation.h.

92 { return m_options; }
SimulationOptions m_options
Definition: ISimulation.h:156

References ISimulation::m_options.

◆ getOptions() [2/2]

◆ initialize()

void ISimulation::initialize ( )
privateinherited

Definition at line 151 of file ISimulation.cpp.

152 {
155 }
void registerChild(INode *node)
Definition: INode.cpp:57

References ISimulation::m_instrument, ISimulation::m_sample_provider, and INode::registerChild().

Referenced by ISimulation::ISimulation().

Here is the call graph for this function:

◆ initSimulationElementVector()

virtual void ISimulation::initSimulationElementVector ( )
protectedpure virtualinherited

◆ initUnitConverter()

virtual void ISimulation2D::initUnitConverter ( )
inlineprotectedvirtual

Definition at line 73 of file ISimulation2D.h.

73 {}

Referenced by setDetector().

◆ instrument() [1/2]

Instrument& ISimulation::instrument ( )
inlineinherited

Definition at line 56 of file ISimulation.h.

56 { return m_instrument; }

References ISimulation::m_instrument.

◆ instrument() [2/2]

◆ intensityMapSize()

virtual size_t ISimulation::intensityMapSize ( ) const
pure virtualinherited

Returns the total number of the intensity values in the simulation result.

Implemented in SpecularSimulation, OffSpecularSimulation, GISASSimulation, and DepthProbeSimulation.

◆ maskAll()

void ISimulation2D::maskAll ( )

Put the mask for all detector channels (i.e. exclude whole detector from the analysis)

Definition at line 65 of file ISimulation2D.cpp.

66 {
67  detector2D().maskAll();
68 }
void maskAll()
Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
Definition: IDetector2D.cpp:80

References detector2D(), and IDetector2D::maskAll().

Referenced by StandardSimulations::GISASWithMasks().

Here is the call graph for this function:

◆ moveDataFromCache()

void ISimulation2D::moveDataFromCache ( )
overrideprotectedvirtual

Implements ISimulation.

Definition at line 170 of file ISimulation2D.cpp.

171 {
172  ASSERT(!m_cache.empty());
173  if (!m_cache.empty()) {
174  for (unsigned i = 0; i < m_sim_elements.size(); i++)
175  m_sim_elements[i].setIntensity(m_cache[i]);
176  m_cache.clear();
177  }
178 }

References ASSERT, m_cache, and m_sim_elements.

◆ normalize()

void ISimulation2D::normalize ( size_t  start_ind,
size_t  n_elements 
)
overrideprotectedvirtual

Normalize the detector counts to beam intensity, to solid angle, and to exposure angle.

Parameters
start_indIndex of the first element to operate on
n_elementsNumber of elements to process

Implements ISimulation.

Definition at line 136 of file ISimulation2D.cpp.

137 {
138  const double beam_intensity = beam().intensity();
139  for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
140  SimulationElement& element = m_sim_elements[i];
141  double sin_alpha_i = std::abs(std::sin(element.getAlphaI()));
142  if (sin_alpha_i == 0.0) {
143  element.setIntensity(0);
144  continue;
145  }
146  const double solid_angle = element.solidAngle();
147  element.setIntensity(element.intensity() * beam_intensity * solid_angle / sin_alpha_i);
148  }
149 }
double intensity() const
Returns the beam intensity in neutrons/sec.
Definition: Beam.h:42
double solidAngle() const
double getAlphaI() const

References ISimulation::beam(), SimulationElement::getAlphaI(), SimulationElement::intensity(), Beam::intensity(), m_sim_elements, SimulationElement::setIntensity(), and SimulationElement::solidAngle().

Here is the call graph for this function:

◆ numberOfSimulationElements()

size_t ISimulation2D::numberOfSimulationElements ( ) const
overrideprotectedvirtual

Gets the number of elements this simulation needs to calculate.

Implements ISimulation.

Reimplemented in OffSpecularSimulation.

Definition at line 80 of file ISimulation2D.cpp.

81 {
82  if (!m_detector_context)
83  throw std::runtime_error("Error in numberOfSimulationElements(): no detector context");
84  return m_detector_context->numberOfSimulationElements();
85 }

References m_detector_context.

Referenced by OffSpecularSimulation::numberOfSimulationElements().

◆ onChange()

◆ options()

◆ parameter()

RealParameter * IParametricComponent::parameter ( const std::string &  name) const
inherited

Returns parameter with given 'name'.

Definition at line 86 of file IParametricComponent.cpp.

87 {
88  return m_pool->parameter(name);
89 }
std::unique_ptr< ParameterPool > m_pool
parameter pool (kind of pointer-to-implementation)
QString const & name(EShape k)
Definition: particles.cpp:21

References IParametricComponent::m_pool, and RealSpace::Particles::name().

Referenced by DepthProbeSimulation::initialize(), SpecularSimulation::initialize(), Lattice3D::initialize(), IParticle::registerAbundance(), ParticleLayout::registerParticleDensity(), IParticle::registerPosition(), Layer::registerThickness(), Lattice2D::setRotationEnabled(), and DistributionLogNormal::setUnits().

Here is the call graph for this function:

◆ parameterPool()

ParameterPool* IParametricComponent::parameterPool ( ) const
inlineinherited

Returns pointer to the parameter pool.

Definition at line 39 of file IParametricComponent.h.

39 { return m_pool.get(); } // has non-const usages!

References IParametricComponent::m_pool.

Referenced by INode::INode(), IParametricComponent::IParametricComponent(), pyfmt2::argumentList(), SampleBuilderNode::borrow_builder_parameters(), SampleBuilderNode::reset(), and IDistribution1D::setUnits().

◆ parametersToString()

std::string IParametricComponent::parametersToString ( ) const
inherited

Returns multiline string representing available parameters.

Definition at line 43 of file IParametricComponent.cpp.

44 {
45  std::ostringstream result;
46  std::unique_ptr<ParameterPool> P_pool(createParameterTree());
47  result << *P_pool << "\n";
48  return result.str();
49 }
virtual ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.

References IParametricComponent::createParameterTree().

Here is the call graph for this function:

◆ parent() [1/2]

INode * INode::parent ( )
inherited

Definition at line 89 of file INode.cpp.

90 {
91  return const_cast<INode*>(m_parent);
92 }

References INode::m_parent.

◆ parent() [2/2]

◆ prepareSimulation()

void ISimulation2D::prepareSimulation ( )
overridevirtual

Put into a clean state for running a simulation.

Reimplemented from ISimulation.

Reimplemented in OffSpecularSimulation.

Definition at line 54 of file ISimulation2D.cpp.

55 {
58 }
std::unique_ptr< DetectorContext > createContext() const
Definition: IDetector2D.cpp:69
virtual void prepareSimulation()
Put into a clean state for running a simulation.

References IDetector2D::createContext(), detector2D(), m_detector_context, and ISimulation::prepareSimulation().

Referenced by GISASSimulation::prepareSimulation(), and OffSpecularSimulation::prepareSimulation().

Here is the call graph for this function:

◆ progeny()

std::vector< const INode * > INode::progeny ( ) const
inherited

Returns a vector of all descendants.

Definition at line 68 of file INode.cpp.

69 {
70  std::vector<const INode*> result;
71  result.push_back(this);
72  for (const auto* child : getChildren()) {
73  for (const auto* p : child->progeny())
74  result.push_back(p);
75  }
76  return result;
77 }

References INode::getChildren().

Referenced by INode::createParameterTree(), and ParticleDistribution::generateParticles().

Here is the call graph for this function:

◆ progress()

ProgressHandler& ISimulation::progress ( )
inlineprotectedinherited

◆ rawResults()

std::vector< double > ISimulation2D::rawResults ( ) const
overrideprivatevirtual

Implements ISimulation.

Definition at line 180 of file ISimulation2D.cpp.

181 {
182  std::vector<double> result;
183  result.resize(m_sim_elements.size());
184  for (unsigned i = 0; i < m_sim_elements.size(); ++i)
185  result[i] = m_sim_elements[i].intensity();
186  return result;
187 }

References m_sim_elements, and ISimulation::result().

Here is the call graph for this function:

◆ registerChild()

void INode::registerChild ( INode node)
inherited

Definition at line 57 of file INode.cpp.

58 {
59  ASSERT(node);
60  node->setParent(this);
61 }
virtual void setParent(const INode *newParent)
Definition: INode.cpp:79

References ASSERT, and INode::setParent().

Referenced by Beam::Beam(), Crystal::Crystal(), IDetector::IDetector(), Instrument::Instrument(), InterferenceFunction2DLattice::InterferenceFunction2DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(), InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(), Particle::Particle(), ParticleDistribution::ParticleDistribution(), ParticleLayout::addAndRegisterAbstractParticle(), ParticleCoreShell::addAndRegisterCore(), MultiLayer::addAndRegisterInterface(), MultiLayer::addAndRegisterLayer(), ParticleCoreShell::addAndRegisterShell(), Layer::addLayout(), ParticleComposition::addParticlePointer(), ISimulation::initialize(), MesoCrystal::initialize(), Beam::operator=(), Instrument::operator=(), IParticle::rotate(), ParticleLayout::setAndRegisterInterferenceFunction(), ISimulation::setBackground(), InterferenceFunction1DLattice::setDecayFunction(), InterferenceFunction2DLattice::setDecayFunction(), Instrument::setDetector(), IDetector::setDetectorResolution(), Beam::setFootprintFactor(), Particle::setFormFactor(), InterferenceFunctionFinite3DLattice::setLattice(), InterferenceFunctionRadialParaCrystal::setProbabilityDistribution(), InterferenceFunction2DParaCrystal::setProbabilityDistributions(), ConvolutionDetectorResolution::setResolutionFunction(), IParticle::setRotation(), LayerInterface::setRoughness(), and InterferenceFunction2DSuperLattice::setSubstructureIFF().

Here is the call graph for this function:

◆ registerParameter()

RealParameter & IParametricComponent::registerParameter ( const std::string &  name,
double *  parpointer 
)
inherited

Definition at line 51 of file IParametricComponent.cpp.

52 {
53  return m_pool->addParameter(
54  new RealParameter(name, data, getName(), [&]() -> void { onChange(); }));
55 }
virtual void onChange()
Action to be taken in inherited class when a parameter has changed.
Wraps a parameter of type double.
Definition: RealParameter.h:31

References IParametricComponent::getName(), IParametricComponent::m_pool, RealSpace::Particles::name(), and IParametricComponent::onChange().

Referenced by BasicLattice2D::BasicLattice2D(), Beam::Beam(), CylindersInBABuilder::CylindersInBABuilder(), DetectionProperties::DetectionProperties(), HexagonalLattice2D::HexagonalLattice2D(), IInterferenceFunction::IInterferenceFunction(), INode::INode(), InterferenceFunction1DLattice::InterferenceFunction1DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(), InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(), InterferenceFunctionTwin::InterferenceFunctionTwin(), Lattice2D::Lattice2D(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), ParticleDistribution::ParticleDistribution(), PlainMultiLayerBySLDBuilder::PlainMultiLayerBySLDBuilder(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), ResonatorBuilder::ResonatorBuilder(), SquareLattice2D::SquareLattice2D(), TriangularRippleBuilder::TriangularRippleBuilder(), IParticle::registerAbundance(), ParticleLayout::registerParticleDensity(), Layer::registerThickness(), IParametricComponent::registerVector(), ParticleLayout::registerWeight(), and Lattice2D::setRotationEnabled().

Here is the call graph for this function:

◆ registerVector()

void IParametricComponent::registerVector ( const std::string &  base_name,
kvector_t p_vec,
const std::string &  units = "nm" 
)
inherited

Definition at line 57 of file IParametricComponent.cpp.

59 {
60  registerParameter(XComponentName(base_name), &((*p_vec)[0])).setUnit(units);
61  registerParameter(YComponentName(base_name), &((*p_vec)[1])).setUnit(units);
62  registerParameter(ZComponentName(base_name), &((*p_vec)[2])).setUnit(units);
63 }
static std::string XComponentName(const std::string &base_name)
static std::string ZComponentName(const std::string &base_name)
RealParameter & registerParameter(const std::string &name, double *parpointer)
static std::string YComponentName(const std::string &base_name)
RealParameter & setUnit(const std::string &name)
MVVM_MODEL_EXPORT std::string base_name(const std::string &path)
Provide the filename of a file path.
Definition: fileutils.cpp:78

References ModelView::Utils::base_name(), IParametricComponent::registerParameter(), RealParameter::setUnit(), IParametricComponent::XComponentName(), IParametricComponent::YComponentName(), and IParametricComponent::ZComponentName().

Referenced by Beam::Beam(), DetectionProperties::DetectionProperties(), InterferenceFunctionTwin::InterferenceFunctionTwin(), MultiLayer::MultiLayer(), Lattice3D::initialize(), and IParticle::registerPosition().

Here is the call graph for this function:

◆ removeParameter()

void IParametricComponent::removeParameter ( const std::string &  name)
inherited

Definition at line 91 of file IParametricComponent.cpp.

92 {
93  m_pool->removeParameter(name);
94 }

References IParametricComponent::m_pool, and RealSpace::Particles::name().

Referenced by IParticle::registerAbundance(), ParticleLayout::registerParticleDensity(), Layer::registerThickness(), IParametricComponent::removeVector(), and Lattice2D::setRotationEnabled().

Here is the call graph for this function:

◆ removeVector()

void IParametricComponent::removeVector ( const std::string &  base_name)
inherited

Definition at line 96 of file IParametricComponent.cpp.

References ModelView::Utils::base_name(), IParametricComponent::removeParameter(), IParametricComponent::XComponentName(), IParametricComponent::YComponentName(), and IParametricComponent::ZComponentName().

Referenced by IParticle::registerPosition().

Here is the call graph for this function:

◆ result()

virtual SimulationResult ISimulation::result ( ) const
pure virtualinherited

Returns the results of the simulation in a format that supports unit conversion and export to numpy arrays.

Implemented in SpecularSimulation, OffSpecularSimulation, GISASSimulation, and DepthProbeSimulation.

Referenced by generateSimulationElements(), ISimulation::getChildren(), rawResults(), and JobItemUtils::setResults().

◆ runMPISimulation()

void ISimulation::runMPISimulation ( )
inherited

Run a simulation in a MPI environment.

Definition at line 226 of file ISimulation.cpp.

227 {
228  MPISimulation ompi;
229  ompi.runSimulation(this);
230 }
void runSimulation(ISimulation *simulation)

References MPISimulation::runSimulation().

Here is the call graph for this function:

◆ runSimulation()

void ISimulation::runSimulation ( )
inherited

Run a simulation, possibly averaged over parameter distributions.

Run simulation with possible averaging over parameter distributions.

Definition at line 193 of file ISimulation.cpp.

194 {
196 
197  const size_t total_size = numberOfSimulationElements();
198  size_t param_combinations = m_distribution_handler.getTotalNumberOfSamples();
199 
200  m_progress.reset();
201  m_progress.setExpectedNTicks(param_combinations * total_size);
202 
203  // restrict calculation to current batch
204  const size_t n_batches = m_options.getNumberOfBatches();
205  const size_t current_batch = m_options.getCurrentBatch();
206 
207  const size_t batch_start = getStartIndex(n_batches, current_batch, total_size);
208  const size_t batch_size = getNumberOfElements(n_batches, current_batch, total_size);
209  if (batch_size == 0)
210  return;
211 
212  if(param_combinations == 1)
213  runSingleSimulation(batch_start, batch_size, 1.);
214  else{
215  std::unique_ptr<ParameterPool> param_pool(createParameterTree());
216  for (size_t index = 0; index < param_combinations; ++index) {
217  double weight = m_distribution_handler.setParameterValues(param_pool.get(), index);
218  runSingleSimulation(batch_start, batch_size, weight);
219  }
221  }
224 }
double setParameterValues(ParameterPool *p_parameter_pool, size_t index)
set the parameter values of the simulation object to a specific combination of values,...
void setParameterToMeans(ParameterPool *p_parameter_pool) const
Sets mean distribution values to the parameter pool.
size_t getTotalNumberOfSamples() const
get the total number of parameter value combinations (product of the individual sizes of each paramet...
ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.
Definition: INode.cpp:126
void runSingleSimulation(size_t batch_start, size_t batch_size, double weight=1.0)
Runs a single simulation with fixed parameter values.
virtual size_t numberOfSimulationElements() const =0
Gets the number of elements this simulation needs to calculate.
virtual void moveDataFromCache()=0
virtual void transferResultsToIntensityMap()
Creates the appropriate data structure (e.g.
Definition: ISimulation.h:114
void setExpectedNTicks(size_t n)
unsigned getNumberOfBatches() const
unsigned getCurrentBatch() const

References INode::createParameterTree(), SimulationOptions::getCurrentBatch(), SimulationOptions::getNumberOfBatches(), DistributionHandler::getTotalNumberOfSamples(), ISimulation::m_distribution_handler, ISimulation::m_options, ISimulation::m_progress, ISimulation::moveDataFromCache(), ISimulation::numberOfSimulationElements(), ISimulation::prepareSimulation(), ProgressHandler::reset(), ISimulation::runSingleSimulation(), ProgressHandler::setExpectedNTicks(), DistributionHandler::setParameterToMeans(), DistributionHandler::setParameterValues(), and ISimulation::transferResultsToIntensityMap().

Referenced by JobWorker::start().

Here is the call graph for this function:

◆ runSingleSimulation()

void ISimulation::runSingleSimulation ( size_t  batch_start,
size_t  batch_size,
double  weight = 1.0 
)
privateinherited

Runs a single simulation with fixed parameter values.

If desired, the simulation is run in several threads.

Definition at line 280 of file ISimulation.cpp.

281 {
283 
284  const size_t n_threads = m_options.getNumberOfThreads();
285  ASSERT(n_threads > 0);
286 
287  std::vector<std::unique_ptr<IComputation>> computations;
288 
289  for (size_t i_thread = 0; i_thread < n_threads;
290  ++i_thread) { // Distribute computations by threads
291  const size_t thread_start = batch_start + getStartIndex(n_threads, i_thread, batch_size);
292  const size_t thread_size = getNumberOfElements(n_threads, i_thread, batch_size);
293  if (thread_size == 0)
294  break;
295  computations.push_back(generateSingleThreadedComputation(thread_start, thread_size));
296  }
297  runComputations(computations);
298 
299  normalize(batch_start, batch_size);
300  addBackgroundIntensity(batch_start, batch_size);
301  addDataToCache(weight);
302 }
virtual void addDataToCache(double weight)=0
virtual std::unique_ptr< IComputation > generateSingleThreadedComputation(size_t start, size_t n_elements)=0
Generate a single threaded computation for a given range of simulation elements.
virtual void addBackgroundIntensity(size_t start_ind, size_t n_elements)=0
virtual void initSimulationElementVector()=0
Initializes the vector of ISimulation elements.
virtual void normalize(size_t start_ind, size_t n_elements)=0
Normalize the detector counts to beam intensity, to solid angle, and to exposure angle.
unsigned getNumberOfThreads() const

References ISimulation::addBackgroundIntensity(), ISimulation::addDataToCache(), ASSERT, ISimulation::generateSingleThreadedComputation(), SimulationOptions::getNumberOfThreads(), ISimulation::initSimulationElementVector(), ISimulation::m_options, and ISimulation::normalize().

Referenced by ISimulation::runSimulation().

Here is the call graph for this function:

◆ sample()

const MultiLayer * ISimulation::sample ( ) const
inherited

Definition at line 238 of file ISimulation.cpp.

239 {
240  return m_sample_provider.sample();
241 }
const MultiLayer * sample() const
Returns current sample.

References ISimulation::m_sample_provider, and SampleProvider::sample().

Referenced by ISimulation::ISimulation(), DepthProbeSimulation::generateSingleThreadedComputation(), generateSingleThreadedComputation(), SpecularSimulation::generateSingleThreadedComputation(), ISimulation::setSample(), and DepthProbeSimulation::validityCheck().

Here is the call graph for this function:

◆ setBackground()

void ISimulation::setBackground ( const IBackground bg)
inherited

Definition at line 248 of file ISimulation.cpp.

249 {
250  m_background.reset(bg.clone());
252 }
virtual IBackground * clone() const =0

References IBackground::clone(), ISimulation::m_background, and INode::registerChild().

Referenced by ISimulation::ISimulation(), and StandardSimulations::ConstantBackgroundGISAS().

Here is the call graph for this function:

◆ setDetector()

void ISimulation2D::setDetector ( const IDetector2D detector)

Sets the detector (axes can be overwritten later)

Definition at line 94 of file ISimulation2D.cpp.

95 {
98 }
virtual void initUnitConverter()
Definition: ISimulation2D.h:73
void setDetector(const IDetector &detector)
Sets the detector (axes can be overwritten later)
Definition: Instrument.cpp:52

References ISimulation::detector(), initUnitConverter(), ISimulation::instrument(), and Instrument::setDetector().

Here is the call graph for this function:

◆ setDetectorParameters()

void ISimulation2D::setDetectorParameters ( size_t  n_phi,
double  phi_min,
double  phi_max,
size_t  n_alpha,
double  alpha_min,
double  alpha_max 
)

Sets spherical detector parameters using angle ranges.

Parameters
n_phinumber of phi-axis bins
phi_minlow edge of first phi-bin
phi_maxupper edge of last phi-bin
n_alphanumber of alpha-axis bins
alpha_minlow edge of first alpha-bin
alpha_maxupper edge of last alpha-bin

Definition at line 87 of file ISimulation2D.cpp.

89 {
90  detector2D().setDetectorParameters(n_x, x_min, x_max, n_y, y_min, y_max);
92 }
void setDetectorParameters(size_t n_x, double x_min, double x_max, size_t n_y, double y_min, double y_max)
Sets detector parameters using angle ranges.
Definition: IDetector2D.cpp:35
virtual void updateIntensityMap()
Definition: ISimulation.h:119

References detector2D(), IDetector2D::setDetectorParameters(), and ISimulation::updateIntensityMap().

Referenced by StandardSimulations::MiniGISASFit().

Here is the call graph for this function:

◆ setDetectorResolutionFunction()

void ISimulation::setDetectorResolutionFunction ( const IResolutionFunction2D resolution_function)
inherited

Definition at line 177 of file ISimulation.cpp.

178 {
179  detector().setResolutionFunction(resolution_function);
180 }
void setResolutionFunction(const IResolutionFunction2D &resFunc)
Definition: IDetector.cpp:112

References ISimulation::detector(), and IDetector::setResolutionFunction().

Referenced by StandardSimulations::MiniGISASDetectorResolution().

Here is the call graph for this function:

◆ setInstrument()

void ISimulation::setInstrument ( const Instrument instrument_)
inherited

Definition at line 158 of file ISimulation.cpp.

159 {
160  m_instrument = instrument_;
162 }

References ISimulation::m_instrument, and ISimulation::updateIntensityMap().

Here is the call graph for this function:

◆ setName()

void IParametricComponent::setName ( const std::string &  name)
inlineinherited

Definition at line 69 of file IParametricComponent.h.

69 { m_name = name; }

References IParametricComponent::m_name, and RealSpace::Particles::name().

Referenced by BasicLattice2D::BasicLattice2D(), Beam::Beam(), ConvolutionDetectorResolution::ConvolutionDetectorResolution(), Crystal::Crystal(), DetectionProperties::DetectionProperties(), DistributionHandler::DistributionHandler(), FormFactorCoreShell::FormFactorCoreShell(), FormFactorCrystal::FormFactorCrystal(), FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(), FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(), FormFactorDecoratorRotation::FormFactorDecoratorRotation(), FormFactorWeighted::FormFactorWeighted(), HexagonalLattice2D::HexagonalLattice2D(), IDetector::IDetector(), INode::INode(), Instrument::Instrument(), InterferenceFunction1DLattice::InterferenceFunction1DLattice(), InterferenceFunction2DLattice::InterferenceFunction2DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(), InterferenceFunction3DLattice::InterferenceFunction3DLattice(), InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(), InterferenceFunctionFinite3DLattice::InterferenceFunctionFinite3DLattice(), InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(), InterferenceFunctionNone::InterferenceFunctionNone(), InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(), InterferenceFunctionTwin::InterferenceFunctionTwin(), ISampleBuilder::ISampleBuilder(), IsGISAXSDetector::IsGISAXSDetector(), Lattice3D::Lattice3D(), Layer::Layer(), LayerInterface::LayerInterface(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), ParticleCoreShell::ParticleCoreShell(), ParticleDistribution::ParticleDistribution(), ParticleLayout::ParticleLayout(), RectangularDetector::RectangularDetector(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), SampleBuilderNode::SampleBuilderNode(), SphericalDetector::SphericalDetector(), SquareLattice2D::SquareLattice2D(), Layer::clone(), LayersWithAbsorptionBuilder::createSampleByIndex(), Basic2DParaCrystalBuilder::createSampleByIndex(), ParticleInVacuumBuilder::createSampleByIndex(), SimpleMagneticRotationBuilder::createSampleByIndex(), DepthProbeSimulation::initialize(), GISASSimulation::initialize(), OffSpecularSimulation::initialize(), SpecularSimulation::initialize(), SpecularDetector1D::initialize(), MesoCrystal::initialize(), Particle::initialize(), ParticleComposition::initialize(), Beam::operator=(), SampleBuilderNode::operator=(), SampleBuilderNode::reset(), and SampleBuilderNode::setSBN().

Here is the call graph for this function:

◆ setOptions()

void ISimulation::setOptions ( const SimulationOptions options)
inlineinherited

Definition at line 90 of file ISimulation.h.

90 { m_options = options; }

References ISimulation::m_options, and ISimulation::options().

Here is the call graph for this function:

◆ setParameterValue()

void IParametricComponent::setParameterValue ( const std::string &  name,
double  value 
)
inherited

Definition at line 65 of file IParametricComponent.cpp.

66 {
67  if (name.find('*') == std::string::npos && name.find('/') == std::string::npos) {
68  m_pool->setParameterValue(name, value);
69  } else {
70  std::unique_ptr<ParameterPool> P_pool{createParameterTree()};
71  if (name.find('*') != std::string::npos)
72  P_pool->setMatchedParametersValue(name, value);
73  else
74  P_pool->setParameterValue(name, value);
75  }
76 }
int setMatchedParametersValue(const std::string &wildcards, double value)
Sets value of the nonzero parameters that match pattern ('*' allowed), or throws.

References IParametricComponent::createParameterTree(), IParametricComponent::m_pool, RealSpace::Particles::name(), and ParameterPool::setMatchedParametersValue().

Referenced by AsymRippleBuilder::buildSample(), and IParametricComponent::setVectorValue().

Here is the call graph for this function:

◆ setParent()

void INode::setParent ( const INode newParent)
virtualinherited

Reimplemented in SampleProvider.

Definition at line 79 of file INode.cpp.

80 {
81  m_parent = newParent;
82 }

References INode::m_parent.

Referenced by INode::registerChild(), SampleProvider::setBuilder(), and SampleProvider::setParent().

◆ setRawResults()

void ISimulation2D::setRawResults ( const std::vector< double > &  raw_data)
overrideprivatevirtual

Implements ISimulation.

Definition at line 189 of file ISimulation2D.cpp.

190 {
192  if (raw_data.size() != m_sim_elements.size())
193  throw std::runtime_error("ISimulation2D::setRawResults: size of vector passed as "
194  "argument doesn't match number of elements in this simulation");
195  for (unsigned i = 0; i < raw_data.size(); i++)
196  m_sim_elements[i].setIntensity(raw_data[i]);
198 }

References ISimulation::initSimulationElementVector(), m_sim_elements, and ISimulation::transferResultsToIntensityMap().

Here is the call graph for this function:

◆ setRegionOfInterest()

void ISimulation2D::setRegionOfInterest ( double  xlow,
double  ylow,
double  xup,
double  yup 
)

Sets rectangular region of interest with lower left and upper right corners defined.

Definition at line 70 of file ISimulation2D.cpp.

71 {
72  detector2D().setRegionOfInterest(xlow, ylow, xup, yup);
73 }
void setRegionOfInterest(double xlow, double ylow, double xup, double yup)
Sets rectangular region of interest with lower left and upper right corners defined.
Definition: IDetector2D.cpp:48

References detector2D(), and IDetector2D::setRegionOfInterest().

Referenced by StandardSimulations::RectDetWithRoi(), and StandardSimulations::SphericalDetWithRoi().

Here is the call graph for this function:

◆ setSample()

void ISimulation::setSample ( const MultiLayer sample)
inherited

The MultiLayer object will not be owned by the ISimulation object.

Definition at line 233 of file ISimulation.cpp.

234 {
236 }
void setSample(const MultiLayer &multilayer)

References ISimulation::m_sample_provider, ISimulation::sample(), and SampleProvider::setSample().

Referenced by ISimulation::ISimulation().

Here is the call graph for this function:

◆ setSampleBuilder()

void ISimulation::setSampleBuilder ( const std::shared_ptr< ISampleBuilder > &  sample_builder)
inherited

Definition at line 243 of file ISimulation.cpp.

244 {
245  m_sample_provider.setBuilder(sample_builder);
246 }
void setBuilder(const std::shared_ptr< ISampleBuilder > &sample_builder)

References ISimulation::m_sample_provider, and SampleProvider::setBuilder().

Here is the call graph for this function:

◆ setTerminalProgressMonitor()

void ISimulation::setTerminalProgressMonitor ( )
inherited

Initializes a progress monitor that prints to stdout.

Definition at line 166 of file ISimulation.cpp.

167 {
168  m_progress.subscribe([](size_t percentage_done) -> bool {
169  if (percentage_done < 100)
170  std::cout << std::setprecision(2) << "\r... " << percentage_done << "%" << std::flush;
171  else // wipe out
172  std::cout << "\r... 100%\n";
173  return true;
174  });
175 }
void subscribe(ProgressHandler::Callback_t callback)

References ISimulation::m_progress, and ProgressHandler::subscribe().

Here is the call graph for this function:

◆ setVectorValue()

void IParametricComponent::setVectorValue ( const std::string &  base_name,
kvector_t  value 
)
inherited

Definition at line 78 of file IParametricComponent.cpp.

79 {
83 }
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:67
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:65
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:63
void setParameterValue(const std::string &name, double value)

References ModelView::Utils::base_name(), IParametricComponent::setParameterValue(), BasicVector3D< T >::x(), IParametricComponent::XComponentName(), BasicVector3D< T >::y(), IParametricComponent::YComponentName(), BasicVector3D< T >::z(), and IParametricComponent::ZComponentName().

Here is the call graph for this function:

◆ subscribe()

void ISimulation::subscribe ( ProgressHandler::Callback_t  inform)
inlineinherited

Definition at line 94 of file ISimulation.h.

94 { m_progress.subscribe(inform); }

References ISimulation::m_progress, and ProgressHandler::subscribe().

Referenced by JobWorker::start().

Here is the call graph for this function:

◆ transferResultsToIntensityMap()

virtual void ISimulation::transferResultsToIntensityMap ( )
inlineprotectedvirtualinherited

Creates the appropriate data structure (e.g.

2D intensity map) from the calculated SimulationElement objects

Reimplemented in OffSpecularSimulation.

Definition at line 114 of file ISimulation.h.

114 {}

Referenced by ISimulation::runSimulation(), setRawResults(), and SpecularSimulation::setRawResults().

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

Used for Python overriding of clone (see swig/tweaks.py)

Definition at line 34 of file ICloneable.h.

◆ treeToString()

std::string INode::treeToString ( ) const
virtualinherited

Returns multiline string representing tree structure below the node.

Definition at line 52 of file INode.cpp.

53 {
54  return NodeUtils::nodeToString(this);
55 }
std::string nodeToString(const INode *node)
Returns multiline string representing tree structure starting from given node.
Definition: NodeUtils.cpp:81

References NodeUtils::nodeToString().

Here is the call graph for this function:

◆ updateIntensityMap()

virtual void ISimulation::updateIntensityMap ( )
inlineprotectedvirtualinherited

Reimplemented in OffSpecularSimulation.

Definition at line 119 of file ISimulation.h.

119 {}

Referenced by setDetectorParameters(), and ISimulation::setInstrument().

◆ validateParametrization()

virtual void ISimulation::validateParametrization ( const ParameterDistribution ) const
inlineprivatevirtualinherited

Checks the distribution validity for simulation.

Reimplemented in SpecularSimulation, OffSpecularSimulation, and DepthProbeSimulation.

Definition at line 139 of file ISimulation.h.

139 {}

Referenced by ISimulation::addParameterDistribution().

◆ XComponentName()

std::string IParametricComponent::XComponentName ( const std::string &  base_name)
staticinherited

Definition at line 103 of file IParametricComponent.cpp.

104 {
105  return base_name + "X";
106 }

References ModelView::Utils::base_name().

Referenced by Lattice3D::initialize(), IParticle::registerPosition(), IParametricComponent::registerVector(), IParametricComponent::removeVector(), IParametricComponent::setVectorValue(), and VectorParameterTranslator::translate().

Here is the call graph for this function:

◆ YComponentName()

std::string IParametricComponent::YComponentName ( const std::string &  base_name)
staticinherited

Definition at line 108 of file IParametricComponent.cpp.

109 {
110  return base_name + "Y";
111 }

References ModelView::Utils::base_name().

Referenced by IParametricComponent::registerVector(), IParametricComponent::removeVector(), IParametricComponent::setVectorValue(), and VectorParameterTranslator::translate().

Here is the call graph for this function:

◆ ZComponentName()

std::string IParametricComponent::ZComponentName ( const std::string &  base_name)
staticinherited

Definition at line 113 of file IParametricComponent.cpp.

114 {
115  return base_name + "Z";
116 }

References ModelView::Utils::base_name().

Referenced by IParametricComponent::registerVector(), IParametricComponent::removeVector(), IParametricComponent::setVectorValue(), and VectorParameterTranslator::translate().

Here is the call graph for this function:

Member Data Documentation

◆ m_background

std::unique_ptr<IBackground> ISimulation::m_background
privateinherited

◆ m_cache

std::vector<double> ISimulation2D::m_cache
protected

◆ m_detector_context

std::unique_ptr<DetectorContext> ISimulation2D::m_detector_context
private

◆ m_distribution_handler

DistributionHandler ISimulation::m_distribution_handler
privateinherited

◆ m_instrument

◆ m_name

std::string IParametricComponent::m_name
privateinherited

◆ m_NP

const size_t INode::m_NP
protectedinherited

Definition at line 88 of file INode.h.

Referenced by INode::INode().

◆ m_options

◆ m_P

std::vector<double> INode::m_P
protectedinherited

Definition at line 89 of file INode.h.

Referenced by INode::INode(), and IFootprintFactor::setWidthRatio().

◆ m_parent

const INode* INode::m_parent {nullptr}
privateinherited

Definition at line 83 of file INode.h.

Referenced by INode::displayName(), INode::parent(), and INode::setParent().

◆ m_pool

◆ m_progress

ProgressHandler ISimulation::m_progress
privateinherited

◆ m_sample_provider

◆ m_sim_elements


The documentation for this class was generated from the following files: