BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Simulation2D Class Referenceabstract

Pure virtual base class of OffSpecularSimulation and GISASSimulation. More...

+ Inheritance diagram for Simulation2D:

Public Member Functions

Simulation2Dclone () const override=0
 
void prepareSimulation () override
 Put into a clean state for running a simulation.
 
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 setDetector (const IDetector2D &detector)
 Sets the detector (axes can be overwritten later)
 
void removeMasks ()
 removes all masks from the detector
 
void addMask (const IShape2D &shape, bool mask_value=true)
 Adds mask of given shape to the stack of detector masks. More...
 
void maskAll ()
 Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
 
void setRegionOfInterest (double xlow, double ylow, double xup, double yup)
 Sets rectangular region of interest with lower left and upper right corners defined.
 
- Public Member Functions inherited from Simulation
void runSimulation ()
 Run a simulation, possibly averaged over parameter distributions. More...
 
void runMPISimulation ()
 Run a simulation in a MPI environment.
 
void setInstrument (const Instrument &instrument_)
 
const Instrumentinstrument () const
 
Instrumentinstrument ()
 
void setBeamIntensity (double intensity)
 
double getBeamIntensity () const
 
void setBeamPolarization (const kvector_t bloch_vector)
 Sets the beam polarization according to the given Bloch vector.
 
void setDetectorResolutionFunction (const IResolutionFunction2D &resolution_function)
 
void removeDetectorResolutionFunction ()
 
void setAnalyzerProperties (const kvector_t direction, double efficiency, double total_transmission)
 Sets the polarization analyzer characteristics of the detector.
 
void setSample (const MultiLayer &sample)
 The MultiLayer object will not be owned by the Simulation object.
 
const MultiLayersample () const
 
void setSampleBuilder (const std::shared_ptr< ISampleBuilder > &sample_builder)
 
void setBackground (const IBackground &bg)
 
const IBackgroundbackground () const
 
virtual size_t intensityMapSize () const =0
 Returns the total number of the intensity values in the simulation result.
 
virtual SimulationResult result () const =0
 Returns the results of the simulation in a format that supports unit conversion and export to numpy arrays.
 
void addParameterDistribution (const std::string &param_name, const IDistribution1D &distribution, size_t nbr_samples, double sigma_factor=0.0, const RealLimits &limits=RealLimits())
 
void addParameterDistribution (const ParameterDistribution &par_distr)
 
const DistributionHandlergetDistributionHandler () const
 
void setOptions (const SimulationOptions &options)
 
const SimulationOptionsgetOptions () const
 
SimulationOptionsgetOptions ()
 
void subscribe (ProgressHandler::Callback_t inform)
 
void setTerminalProgressMonitor ()
 Initializes a progress monitor that prints to stdout.
 
std::vector< const INode * > getChildren () const
 Returns a vector of children (const).
 
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...
 
- Public Member Functions inherited from ICloneable
 ICloneable (const ICloneable &)=delete
 
 ICloneable (ICloneable &&)=default
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py)
 
- Public Member Functions inherited from INode
 INode (const NodeMeta &meta, const std::vector< double > &PValues)
 
virtual void accept (INodeVisitor *visitor) const =0
 Calls the INodeVisitor's visit method.
 
virtual std::string treeToString () const
 Returns multiline string representing tree structure below the node.
 
void registerChild (INode *node)
 
virtual void setParent (const INode *newParent)
 
const INodeparent () const
 
INodeparent ()
 
int copyNumber (const INode *node) const
 Returns copyNumber of child, which takes into account existence of children with same name.
 
std::string displayName () const
 Returns display name, composed from the name of node and it's copy number.
 
ParameterPoolcreateParameterTree () const
 Creates new parameter pool, with all local parameters and those of its children.
 
- Public Member Functions inherited from IParameterized
 IParameterized (const std::string &name="")
 
 IParameterized (const IParameterized &other)
 
IParameterizedoperator= (const IParameterized &other)=delete
 
ParameterPoolparameterPool () const
 Returns pointer to the parameter pool.
 
std::string parametersToString () const
 Returns multiline string representing available parameters.
 
RealParameterregisterParameter (const std::string &name, double *parpointer)
 
void registerVector (const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
 
void setParameterValue (const std::string &name, double value)
 
void setVectorValue (const std::string &base_name, kvector_t value)
 
RealParameterparameter (const std::string &name) const
 Returns parameter with given 'name'.
 
virtual void onChange ()
 Action to be taken in inherited class when a parameter has changed.
 
void removeParameter (const std::string &name)
 
void removeVector (const std::string &base_name)
 
void setName (const std::string &name)
 
const std::string & getName () const
 

Protected Member Functions

 Simulation2D (const Simulation2D &other)
 
virtual void initUnitConverter ()
 
size_t numberOfSimulationElements () const override
 Gets the number of elements this simulation needs to calculate.
 
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...
 
std::vector< SimulationElementgenerateSimulationElements (const Beam &beam)
 Generate simulation elements for given beam.
 
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...
 
void addBackgroundIntensity (size_t start_ind, size_t n_elements) override
 
void addDataToCache (double weight) override
 
void moveDataFromCache () override
 
- Protected Member Functions inherited from Simulation
 Simulation (const Simulation &other)
 
virtual void transferResultsToIntensityMap ()
 Creates the appropriate data structure (e.g. More...
 
virtual void initSimulationElementVector ()=0
 Initializes the vector of Simulation elements.
 
virtual void updateIntensityMap ()
 
const SimulationOptionsoptions () const
 
ProgressHandlerprogress ()
 

Protected Attributes

std::vector< SimulationElementm_sim_elements
 
std::vector< double > m_cache
 
- Protected Attributes inherited from INode
const size_t m_NP
 
std::vector< double > m_P
 

Additional Inherited Members

- Static Public Member Functions inherited from IParameterized
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)
 

Detailed Description

Pure virtual base class of OffSpecularSimulation and GISASSimulation.

Holds the common implementations for simulations with a 2D detector

Definition at line 26 of file Simulation2D.h.

Member Function Documentation

◆ setDetectorParameters()

void Simulation2D::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 64 of file Simulation2D.cpp.

◆ addMask()

void Simulation2D::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 37 of file Simulation2D.cpp.

◆ generateSingleThreadedComputation()

std::unique_ptr< IComputation > Simulation2D::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 Simulation.

Definition at line 77 of file Simulation2D.cpp.

◆ normalize()

void Simulation2D::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 Simulation.

Definition at line 113 of file Simulation2D.cpp.


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