BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
Specular reflectometry simulation.
Holds an instrument and sample model. Computes detected intensity as function of the glancing angles alpha_i=alpha_f.
Definition at line 33 of file SpecularSimulation.h.
Public Member Functions | |
SpecularSimulation (const ISpecularScan &scan, const MultiLayer &sample) | |
SpecularSimulation (SpecularSimulation &&) | |
~SpecularSimulation () override | |
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 |
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 |
bool | force_polarized () const override |
Force polarized computation even in absence of sample magnetization or external fields. More... | |
const std::vector< ParameterDistribution > & | getDistributions () const |
size_t | intensityMapSize () const override |
Returns the total number of the intensity values in the simulation result. 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... | |
void | prepareSimulation () override |
Put into a clean state for running a simulation. More... | |
const MultiLayer * | sample () const |
const ISpecularScan * | scan () const |
Returns internal data handler. More... | |
void | setBackground (const IBackground &bg) |
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 | |
virtual void | initDistributionHandler () |
ProgressHandler & | progress () |
virtual void | updateIntensityMap () |
Protected Attributes | |
DistributionHandler | m_distribution_handler |
std::vector< double > | m_P |
Private Member Functions | |
void | addBackgroundIntensity (size_t start_ind, size_t n_elements) override |
void | addDataToCache (double weight) override |
void | checkCache () const |
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... | |
void | initElementVector () override |
Initializes the vector of ISimulation elements. 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... | |
SimulationResult | pack_result () override |
Sets m_result. 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... | |
void | validateParametrization (const ParameterDistribution &par_distr) const override |
Checks the distribution validity for simulation. More... | |
Private Attributes | |
std::shared_ptr< IBackground > | m_background |
std::vector< double > | m_cache |
std::vector< SpecularElement > | m_eles |
std::shared_ptr< SimulationOptions > | m_options |
std::shared_ptr< ProgressHandler > | m_progress |
std::shared_ptr< MultiLayer > | m_sample |
std::unique_ptr< const ISpecularScan > | m_scan |
SpecularSimulation::SpecularSimulation | ( | const ISpecularScan & | scan, |
const MultiLayer & | sample | ||
) |
Definition at line 33 of file SpecularSimulation.cpp.
References ISpecularScan::coordinateAxis(), IAxis::min(), and scan().
|
overridedefault |
|
default |
|
overrideprivatevirtual |
Implements ISimulation.
Definition at line 115 of file SpecularSimulation.cpp.
References ISimulation::background(), and m_eles.
|
overrideprivatevirtual |
Implements ISimulation.
Definition at line 125 of file SpecularSimulation.cpp.
References checkCache(), m_cache, and m_eles.
|
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 addBackgroundIntensity().
|
private |
Definition at line 88 of file SpecularSimulation.cpp.
References ASSERT, m_cache, and m_eles.
Referenced by addDataToCache(), and moveDataFromCache().
|
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 39 of file SpecularSimulation.h.
|
overrideprivatevirtual |
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 79 of file SpecularSimulation.cpp.
References ASSERT, m_eles, ISimulation::options(), and ISimulation::progress().
|
overridevirtual |
Implements ISimulation.
Definition at line 64 of file SpecularSimulation.cpp.
References m_scan.
Referenced by pack_result().
|
overridevirtual |
Force polarized computation even in absence of sample magnetization or external fields.
Implements ISimulation.
Definition at line 140 of file SpecularSimulation.cpp.
References m_scan.
|
inherited |
Definition at line 237 of file ISimulation.cpp.
References DistributionHandler::getDistributions(), and ISimulation::m_distribution_handler.
|
inlineprotectedvirtualinherited |
Reimplemented in ISimulation2D.
Definition at line 106 of file ISimulation.h.
Referenced by ISimulation::simulate().
|
overrideprivatevirtual |
Initializes the vector of ISimulation elements.
Implements ISimulation.
Definition at line 70 of file SpecularSimulation.cpp.
|
overridevirtual |
Returns the total number of the intensity values in the simulation result.
Implements ISimulation.
Definition at line 58 of file SpecularSimulation.cpp.
References m_scan.
|
overrideprivatevirtual |
Implements ISimulation.
Definition at line 132 of file SpecularSimulation.cpp.
References checkCache(), m_cache, and m_eles.
|
overridevirtualinherited |
Returns all children.
Reimplemented from INode.
Reimplemented in ISimulation2D.
Definition at line 201 of file ISimulation.cpp.
References ISimulation::m_sample.
Referenced by ISimulation2D::nodeChildren().
|
inherited |
Returns all descendants.
Definition at line 61 of file INode.cpp.
References INode::nodeChildren().
|
overrideprivatevirtual |
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 105 of file SpecularSimulation.cpp.
|
overrideprivatevirtual |
Gets the number of elements this simulation needs to calculate.
Implements ISimulation.
Definition at line 46 of file SpecularSimulation.cpp.
References m_scan.
|
inherited |
|
inherited |
Definition at line 117 of file ISimulation.cpp.
References ASSERT, and ISimulation::m_options.
Referenced by DepthProbeSimulation::createComputation(), ISimulation2D::createComputation(), createComputation(), and ISimulation::simulate().
|
overrideprivatevirtual |
Sets m_result.
Implements ISimulation.
Definition at line 51 of file SpecularSimulation.cpp.
References ASSERT, createCoordSystem(), m_eles, and m_scan.
|
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().
|
inlineoverridevirtual |
Put into a clean state for running a simulation.
Implements ISimulation.
Definition at line 48 of file SpecularSimulation.h.
|
protectedinherited |
Definition at line 129 of file ISimulation.cpp.
References ASSERT, and ISimulation::m_progress.
Referenced by DepthProbeSimulation::createComputation(), ISimulation2D::createComputation(), and 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().
|
inline |
Returns internal data handler.
Definition at line 52 of file SpecularSimulation.h.
References m_scan.
Referenced by SpecularSimulation().
|
inherited |
Definition at line 196 of file ISimulation.cpp.
References IBackground::clone(), and ISimulation::m_background.
|
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 |
|
overrideprivatevirtual |
Checks the distribution validity for simulation.
Reimplemented from ISimulation.
Definition at line 93 of file SpecularSimulation.cpp.
References ParameterDistribution::getDistribution(), and IDistribution1D::mean().
|
privateinherited |
Definition at line 137 of file ISimulation.h.
Referenced by ISimulation::background(), and ISimulation::setBackground().
|
private |
Definition at line 88 of file SpecularSimulation.h.
Referenced by addDataToCache(), checkCache(), initElementVector(), and moveDataFromCache().
|
protectedinherited |
Definition at line 104 of file ISimulation.h.
Referenced by ISimulation::addParameterDistribution(), ISimulation::getDistributions(), ISimulation2D::initDistributionHandler(), and ISimulation::simulate().
|
private |
Definition at line 87 of file SpecularSimulation.h.
Referenced by addBackgroundIntensity(), addDataToCache(), checkCache(), createComputation(), initElementVector(), moveDataFromCache(), normalize(), and pack_result().
|
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().
|
private |
Definition at line 86 of file SpecularSimulation.h.
Referenced by createCoordSystem(), force_polarized(), initElementVector(), intensityMapSize(), normalize(), numberOfElements(), pack_result(), and scan().