BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
GISAS simulation.
Holds an instrument and sample model. Computes the scattered intensity as function of 2D detector coordinates.
Definition at line 28 of file ScatteringSimulation.h.
Public Member Functions | |
ScatteringSimulation (const Beam &beam, const MultiLayer &sample, const IDetector &detector) | |
~ScatteringSimulation () override=default | |
void | 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. More... | |
void | addParameterDistribution (const ParameterDistribution &par_distr) |
void | addParameterDistribution (ParameterDistribution::WhichParameter whichParameter, const IDistribution1D &distribution, size_t nbr_samples, double sigma_factor=0.0, const RealLimits &limits=RealLimits()) |
const IBackground * | background () const |
Beam & | beam () |
const Beam & | beam () const |
void | checkNodeArgs () const |
Raises exception if a parameter value is invalid. More... | |
std::string | className () const final |
Returns the class name, to be hard-coded in each leaf class that inherits from INode. More... | |
ICoordSystem * | createCoordSystem () const override |
IDetector & | detector () |
const IDetector & | detector () const |
bool | force_polarized () const override |
Force polarized computation even in absence of sample magnetization or external fields. More... | |
const IDetector * | getDetector () const |
const std::vector< ParameterDistribution > & | getDistributions () const |
size_t | intensityMapSize () const override |
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... | |
std::vector< const INode * > | nodeChildren () const override |
Returns all children. More... | |
std::vector< const INode * > | nodeOffspring () const |
Returns all descendants. More... | |
SimulationOptions & | options () |
const SimulationOptions & | options () const |
virtual std::vector< ParaMeta > | parDefs () const |
Returns the parameter definitions, to be hard-coded in each leaf class. More... | |
const MultiLayer * | sample () const |
void | setBackground (const IBackground &bg) |
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 | setTerminalProgressMonitor () |
Initializes a progress monitor that prints to stdout. More... | |
SimulationResult | simulate () |
Run a simulation, and return the result. More... | |
void | subscribe (const std::function< bool(size_t)> &inform) |
std::string | unitOfParameter (ParameterDistribution::WhichParameter which) const |
Protected Member Functions | |
void | addBackgroundIntensity (size_t start_ind, size_t n_elements) override |
void | addDataToCache (double weight) override |
std::unique_ptr< IComputation > | createComputation (const reSample &re_sample, size_t start, size_t n_elements) override |
Generate a single threaded computation for a given range of simulation elements. More... | |
std::vector< std::unique_ptr< DiffuseElement > > | generateElements (const Beam &beam) |
Generate simulation elements for given beam. More... | |
virtual void | initCoordSystem () |
void | initDistributionHandler () override |
init callbacks for setting the parameter values More... | |
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 | numberOfElements () const override |
Gets the number of elements this simulation needs to calculate. More... | |
ProgressHandler & | progress () |
virtual void | updateIntensityMap () |
Protected Attributes | |
std::unique_ptr< Beam > | m_beam |
std::vector< double > | m_cache |
std::unique_ptr< IDetector > | m_detector |
DistributionHandler | m_distribution_handler |
std::vector< std::unique_ptr< DiffuseElement > > | m_eles |
std::vector< double > | m_P |
Private Member Functions | |
void | initElementVector () override |
Initializes the vector of ISimulation elements. More... | |
SimulationResult | pack_result () override |
Sets m_result. More... | |
void | prepareSimulation () override |
Put into a clean state for running a simulation. More... | |
void | runSingleSimulation (const reSample &re_sample, size_t batch_start, size_t batch_size, double weight=1.0) |
Runs a single simulation with fixed parameter values. If desired, the simulation is run in several threads. More... | |
virtual void | validateParametrization (const ParameterDistribution &) const |
Checks the distribution validity for simulation. More... | |
Private Attributes | |
std::shared_ptr< IBackground > | m_background |
std::unique_ptr< DetectorContext > | m_detector_context |
std::shared_ptr< SimulationOptions > | m_options |
std::shared_ptr< ProgressHandler > | m_progress |
std::shared_ptr< MultiLayer > | m_sample |
ScatteringSimulation::ScatteringSimulation | ( | const Beam & | beam, |
const MultiLayer & | sample, | ||
const IDetector & | detector | ||
) |
Definition at line 24 of file ScatteringSimulation.cpp.
|
overridedefault |
|
overrideprotectedvirtualinherited |
Implements ISimulation.
Definition at line 124 of file ISimulation2D.cpp.
References ISimulation::background(), DiffuseElement::intensity(), ISimulation2D::m_eles, and DiffuseElement::setIntensity().
|
overrideprotectedvirtualinherited |
Implements ISimulation.
Definition at line 134 of file ISimulation2D.cpp.
References ISimulation2D::m_cache, and ISimulation2D::m_eles.
|
inherited |
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.
Definition at line 56 of file ISimulation2D.cpp.
References IDetector::addMask(), and ISimulation2D::detector().
|
inherited |
Definition at line 231 of file ISimulation.cpp.
References DistributionHandler::addParameterDistribution(), ISimulation::m_distribution_handler, and ISimulation::validateParametrization().
|
inherited |
Definition at line 222 of file ISimulation.cpp.
|
inlineinherited |
Definition at line 76 of file ISimulation.h.
References ISimulation::m_background.
Referenced by DepthProbeSimulation::addBackgroundIntensity(), ISimulation2D::addBackgroundIntensity(), and SpecularSimulation::addBackgroundIntensity().
|
inlineinherited |
Definition at line 57 of file ISimulation2D.h.
References ISimulation2D::m_beam.
Referenced by DepthProbeSimulation::DepthProbeSimulation(), DepthProbeSimulation::createCoordSystem(), OffspecSimulation::createCoordSystem(), createCoordSystem(), DepthProbeSimulation::generateElements(), ISimulation2D::generateElements(), ISimulation2D::initDistributionHandler(), DepthProbeSimulation::initElementVector(), OffspecSimulation::initElementVector(), initElementVector(), DepthProbeSimulation::normalize(), ISimulation2D::normalize(), DepthProbeSimulation::setBeamParameters(), and OffspecSimulation::setBeamParameters().
|
inlineinherited |
|
inherited |
Raises exception if a parameter value is invalid.
Definition at line 27 of file INode.cpp.
References ASSERT, RealLimits::check(), INode::className(), INF, RealLimits::limited(), RealLimits::limitless(), INode::m_P, ParaMeta::name, RealLimits::nonnegative(), INode::parDefs(), ParaMeta::vMax, and ParaMeta::vMin.
Referenced by BarGauss::BarGauss(), BarLorentz::BarLorentz(), Bipyramid4::Bipyramid4(), Box::Box(), CantellatedCube::CantellatedCube(), Cone::Cone(), ConstantBackground::ConstantBackground(), CosineRippleBox::CosineRippleBox(), CosineRippleGauss::CosineRippleGauss(), CosineRippleLorentz::CosineRippleLorentz(), Cylinder::Cylinder(), DistributionCosine::DistributionCosine(), DistributionGate::DistributionGate(), DistributionGaussian::DistributionGaussian(), DistributionLogNormal::DistributionLogNormal(), DistributionLorentz::DistributionLorentz(), DistributionTrapezoid::DistributionTrapezoid(), Dodecahedron::Dodecahedron(), EllipsoidalCylinder::EllipsoidalCylinder(), FootprintGauss::FootprintGauss(), FootprintSquare::FootprintSquare(), FuzzySphere::FuzzySphere(), GaussSphere::GaussSphere(), HemiEllipsoid::HemiEllipsoid(), HollowSphere::HollowSphere(), HorizontalCylinder::HorizontalCylinder(), Icosahedron::Icosahedron(), LongBoxGauss::LongBoxGauss(), LongBoxLorentz::LongBoxLorentz(), PlatonicOctahedron::PlatonicOctahedron(), PlatonicTetrahedron::PlatonicTetrahedron(), Prism3::Prism3(), Prism6::Prism6(), Profile1DCauchy::Profile1DCauchy(), Profile1DCosine::Profile1DCosine(), Profile1DGate::Profile1DGate(), Profile1DGauss::Profile1DGauss(), Profile1DTriangle::Profile1DTriangle(), Profile1DVoigt::Profile1DVoigt(), Profile2DCauchy::Profile2DCauchy(), Profile2DCone::Profile2DCone(), Profile2DGate::Profile2DGate(), Profile2DGauss::Profile2DGauss(), Profile2DVoigt::Profile2DVoigt(), Pyramid2::Pyramid2(), Pyramid3::Pyramid3(), Pyramid4::Pyramid4(), Pyramid6::Pyramid6(), RotationEuler::RotationEuler(), RotationX::RotationX(), RotationY::RotationY(), RotationZ::RotationZ(), SawtoothRippleBox::SawtoothRippleBox(), SawtoothRippleGauss::SawtoothRippleGauss(), SawtoothRippleLorentz::SawtoothRippleLorentz(), Sphere::Sphere(), Spheroid::Spheroid(), TruncatedCube::TruncatedCube(), TruncatedSphere::TruncatedSphere(), and TruncatedSpheroid::TruncatedSpheroid().
|
inlinefinalvirtual |
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Implements INode.
Definition at line 33 of file ScatteringSimulation.h.
|
overrideprotectedvirtualinherited |
Generate a single threaded computation for a given range of simulation elements.
re_sample | Preprocessed version of our sample |
start | Index of the first element to include into computation |
n_elements | Number of elements to process |
Implements ISimulation.
Definition at line 78 of file ISimulation2D.cpp.
References ASSERT, ISimulation2D::m_eles, ISimulation::options(), and ISimulation::progress().
|
overridevirtual |
Implements ISimulation.
Definition at line 54 of file ScatteringSimulation.cpp.
References ASSERT, ISimulation2D::beam(), and ISimulation2D::getDetector().
Referenced by pack_result().
|
inlineinherited |
Definition at line 58 of file ISimulation2D.h.
References ISimulation2D::m_detector.
Referenced by ISimulation2D::addMask(), OffspecSimulation::checkInitialization(), OffspecSimulation::createCoordSystem(), ISimulation2D::force_polarized(), ISimulation2D::generateElements(), OffspecSimulation::intensityMapSize(), intensityMapSize(), ISimulation2D::maskAll(), OffspecSimulation::pack_result(), pack_result(), ISimulation2D::prepareSimulation(), prepareSimulation(), ISimulation2D::setRegionOfInterest(), OffspecSimulation::transferDetectorImage(), and OffspecSimulation::updateIntensityMap().
|
inlineinherited |
|
overridevirtualinherited |
Force polarized computation even in absence of sample magnetization or external fields.
Implements ISimulation.
Definition at line 153 of file ISimulation2D.cpp.
References IDetector::analyzer(), PolFilter::analyzerDirection(), and ISimulation2D::detector().
|
protectedinherited |
Generate simulation elements for given beam.
Definition at line 87 of file ISimulation2D.cpp.
References Direction::alpha(), IDetector::analyzer(), ISimulation2D::beam(), ISimulation2D::detector(), Beam::direction(), IDetector::indexOfSpecular(), ISimulation2D::m_detector_context, PolFilter::matrix(), N, Direction::phi(), Beam::polMatrix(), and Beam::wavelength().
Referenced by OffspecSimulation::initElementVector(), and initElementVector().
|
inlineinherited |
Definition at line 64 of file ISimulation2D.h.
References ISimulation2D::m_detector.
Referenced by createCoordSystem().
|
inherited |
Definition at line 237 of file ISimulation.cpp.
References DistributionHandler::getDistributions(), and ISimulation::m_distribution_handler.
|
inlineprotectedvirtualinherited |
Definition at line 70 of file ISimulation2D.h.
|
overrideprotectedvirtualinherited |
init callbacks for setting the parameter values
Reimplemented from ISimulation.
Definition at line 159 of file ISimulation2D.cpp.
References ASSERT, ISimulation2D::beam(), ParameterDistribution::BeamAzimuthalAngle, ParameterDistribution::BeamInclinationAngle, ParameterDistribution::BeamWavelength, DistributionHandler::defineCallbackForDistribution(), DistributionHandler::getDistributions(), ISimulation::m_distribution_handler, Beam::setAzimuthalAngleGuarded(), Beam::setInclinationAngleGuarded(), and Beam::setWavelengthGuarded().
|
overrideprivatevirtual |
Initializes the vector of ISimulation elements.
Implements ISimulation.
Definition at line 62 of file ScatteringSimulation.cpp.
References ISimulation2D::beam(), ISimulation2D::generateElements(), ISimulation2D::m_cache, and ISimulation2D::m_eles.
|
overridevirtual |
Returns the total number of the intensity values in the simulation result.
Implements ISimulation.
Definition at line 45 of file ScatteringSimulation.cpp.
References ISimulation2D::detector(), and IDetector::iterateOverRegionOfInterest().
|
inherited |
Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
Definition at line 61 of file ISimulation2D.cpp.
References ISimulation2D::detector(), and IDetector::maskAll().
|
overrideprotectedvirtualinherited |
Implements ISimulation.
Definition at line 143 of file ISimulation2D.cpp.
References ASSERT, ISimulation2D::m_cache, and ISimulation2D::m_eles.
|
overridevirtualinherited |
Returns all children.
Reimplemented from ISimulation.
Definition at line 42 of file ISimulation2D.cpp.
References ISimulation2D::m_beam, ISimulation2D::m_detector, and ISimulation::nodeChildren().
|
inherited |
Returns all descendants.
Definition at line 61 of file INode.cpp.
References INode::nodeChildren().
|
overrideprotectedvirtualinherited |
Normalize the detector counts to beam intensity, to solid angle, and to exposure angle.
start_ind | Index of the first element to operate on |
n_elements | Number of elements to process |
Implements ISimulation.
Definition at line 109 of file ISimulation2D.cpp.
References DiffuseElement::alphaI(), ISimulation2D::beam(), Beam::intensity(), DiffuseElement::intensity(), ISimulation2D::m_eles, DiffuseElement::setIntensity(), and DiffuseElement::solidAngle().
|
overrideprotectedvirtualinherited |
Gets the number of elements this simulation needs to calculate.
Implements ISimulation.
Reimplemented in OffspecSimulation.
Definition at line 71 of file ISimulation2D.cpp.
References ISimulation2D::m_detector_context.
Referenced by OffspecSimulation::numberOfElements().
|
inherited |
|
inherited |
Definition at line 117 of file ISimulation.cpp.
References ASSERT, and ISimulation::m_options.
Referenced by DepthProbeSimulation::createComputation(), ISimulation2D::createComputation(), SpecularSimulation::createComputation(), and ISimulation::simulate().
|
overrideprivatevirtual |
Sets m_result.
Implements ISimulation.
Definition at line 38 of file ScatteringSimulation.cpp.
References createCoordSystem(), ISimulation2D::detector(), and ISimulation2D::m_eles.
|
inlinevirtualinherited |
Returns the parameter definitions, to be hard-coded in each leaf class.
Reimplemented in ConstantBackground, GaussSphere, FuzzySphere, RotationEuler, RotationZ, RotationY, RotationX, Crystal, Layer, HexagonalLattice2D, SquareLattice2D, BasicLattice2D, LayerRoughness, TruncatedSpheroid, TruncatedSphere, TruncatedCube, Spheroid, Sphere, SawtoothRippleLorentz, SawtoothRippleGauss, SawtoothRippleBox, Pyramid6, Pyramid4, Pyramid3, Pyramid2, Prism6, Prism3, PlatonicTetrahedron, PlatonicOctahedron, LongBoxLorentz, LongBoxGauss, Icosahedron, HorizontalCylinder, HollowSphere, HemiEllipsoid, EllipsoidalCylinder, Dodecahedron, Cylinder, CosineRippleLorentz, CosineRippleGauss, CosineRippleBox, Cone, CantellatedCube, Box, Bipyramid4, BarLorentz, BarGauss, Profile2DVoigt, Profile2DCone, Profile2DGate, Profile2DGauss, Profile2DCauchy, Profile1DVoigt, Profile1DCosine, Profile1DTriangle, Profile1DGate, Profile1DGauss, Profile1DCauchy, MisesGaussPeakShape, MisesFisherGaussPeakShape, LorentzFisherPeakShape, GaussFisherPeakShape, IsotropicLorentzPeakShape, IsotropicGaussPeakShape, ParticleLayout, InterferenceTwin, InterferenceRadialParaCrystal, InterferenceHardDisk, Interference2DSuperLattice, Interference2DParaCrystal, Interference1DLattice, DistributionTrapezoid, DistributionCosine, DistributionLogNormal, DistributionGaussian, DistributionLorentz, DistributionGate, ResolutionFunction2DGaussian, PolFilter, FootprintSquare, and FootprintGauss.
Definition at line 51 of file INode.h.
Referenced by INode::checkNodeArgs(), and IFormFactor::pythonConstructor().
|
overrideprivatevirtual |
Put into a clean state for running a simulation.
Reimplemented from ISimulation2D.
Definition at line 30 of file ScatteringSimulation.cpp.
References ISimulation2D::detector(), and ISimulation2D::prepareSimulation().
|
protectedinherited |
Definition at line 129 of file ISimulation.cpp.
References ASSERT, and ISimulation::m_progress.
Referenced by DepthProbeSimulation::createComputation(), ISimulation2D::createComputation(), and SpecularSimulation::createComputation().
|
privateinherited |
Runs a single simulation with fixed parameter values. If desired, the simulation is run in several threads.
Definition at line 245 of file ISimulation.cpp.
References ISimulation::addBackgroundIntensity(), ISimulation::addDataToCache(), ASSERT, ISimulation::createComputation(), ISimulation::initElementVector(), ISimulation::m_options, and ISimulation::normalize().
Referenced by ISimulation::simulate().
|
inherited |
Definition at line 191 of file ISimulation.cpp.
References ISimulation::m_sample.
Referenced by ISimulation::simulate(), and DepthProbeSimulation::validityCheck().
|
inherited |
Definition at line 196 of file ISimulation.cpp.
References IBackground::clone(), and ISimulation::m_background.
|
inherited |
Sets rectangular region of interest with lower left and upper right corners defined.
Definition at line 66 of file ISimulation2D.cpp.
References ISimulation2D::detector(), and IDetector::setRegionOfInterest().
|
inherited |
Initializes a progress monitor that prints to stdout.
Definition at line 142 of file ISimulation.cpp.
References ISimulation::m_progress.
|
inherited |
Run a simulation, and return the result.
Runs simulation with possible averaging over parameter distributions; returns result.
Definition at line 154 of file ISimulation.cpp.
References ASSERT, SampleUtils::Multilayer::ContainsCompatibleMaterials(), ISimulation::force_polarized(), DistributionHandler::getTotalNumberOfSamples(), ISimulation::initDistributionHandler(), ISimulation::m_distribution_handler, ISimulation::m_options, ISimulation::m_progress, ISimulation::m_sample, reSample::make(), ISimulation::moveDataFromCache(), ISimulation::numberOfElements(), ISimulation::options(), ISimulation::pack_result(), ISimulation::prepareSimulation(), ISimulation::runSingleSimulation(), ISimulation::sample(), and DistributionHandler::setParameterValues().
|
inherited |
Definition at line 135 of file ISimulation.cpp.
References ASSERT, and ISimulation::m_progress.
|
inherited |
Definition at line 209 of file ISimulation.cpp.
References ParameterDistribution::BeamAzimuthalAngle, ParameterDistribution::BeamInclinationAngle, and ParameterDistribution::BeamWavelength.
|
inlineprotectedvirtualinherited |
|
inlineprivatevirtualinherited |
Checks the distribution validity for simulation.
Reimplemented in SpecularSimulation, OffspecSimulation, and DepthProbeSimulation.
Definition at line 120 of file ISimulation.h.
Referenced by ISimulation::addParameterDistribution().
|
privateinherited |
Definition at line 137 of file ISimulation.h.
Referenced by ISimulation::background(), and ISimulation::setBackground().
|
protectedinherited |
Definition at line 98 of file ISimulation2D.h.
Referenced by ISimulation2D::ISimulation2D(), ISimulation2D::beam(), and ISimulation2D::nodeChildren().
|
protectedinherited |
Definition at line 101 of file ISimulation2D.h.
Referenced by ISimulation2D::addDataToCache(), OffspecSimulation::initElementVector(), initElementVector(), and ISimulation2D::moveDataFromCache().
|
protectedinherited |
Definition at line 99 of file ISimulation2D.h.
Referenced by ISimulation2D::ISimulation2D(), ISimulation2D::detector(), ISimulation2D::getDetector(), and ISimulation2D::nodeChildren().
|
privateinherited |
Definition at line 104 of file ISimulation2D.h.
Referenced by ISimulation2D::generateElements(), ISimulation2D::numberOfElements(), and ISimulation2D::prepareSimulation().
|
protectedinherited |
Definition at line 104 of file ISimulation.h.
Referenced by ISimulation::addParameterDistribution(), ISimulation::getDistributions(), ISimulation2D::initDistributionHandler(), and ISimulation::simulate().
|
protectedinherited |
Definition at line 100 of file ISimulation2D.h.
Referenced by ISimulation2D::addBackgroundIntensity(), ISimulation2D::addDataToCache(), ISimulation2D::createComputation(), OffspecSimulation::initElementVector(), initElementVector(), ISimulation2D::moveDataFromCache(), ISimulation2D::normalize(), OffspecSimulation::pack_result(), pack_result(), and OffspecSimulation::transferDetectorImage().
|
privateinherited |
Definition at line 135 of file ISimulation.h.
Referenced by ISimulation::options(), ISimulation::runSingleSimulation(), and ISimulation::simulate().
|
protectedinherited |
Definition at line 63 of file INode.h.
Referenced by IFootprintFactor::IFootprintFactor(), INode::checkNodeArgs(), IProfile1D::pythonConstructor(), IProfile2D::pythonConstructor(), IFormFactor::pythonConstructor(), Profile1DVoigt::pythonConstructor(), and Profile2DVoigt::pythonConstructor().
|
privateinherited |
Definition at line 136 of file ISimulation.h.
Referenced by ISimulation::progress(), ISimulation::setTerminalProgressMonitor(), ISimulation::simulate(), and ISimulation::subscribe().
|
privateinherited |
Definition at line 133 of file ISimulation.h.
Referenced by ISimulation::nodeChildren(), ISimulation::sample(), and ISimulation::simulate().