BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DistributionTrapezoid Class Reference

Trapezoidal distribution. More...

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

Public Member Functions

 DistributionTrapezoid ()
 
 DistributionTrapezoid (const std::vector< double > P)
 
 DistributionTrapezoid (double center, double left, double middle, double right)
 
void accept (INodeVisitor *visitor) const final
 Calls the INodeVisitor's visit method. More...
 
DistributionTrapezoidclone () const final
 
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...
 
std::string displayName () const
 Returns display name, composed from the name of node and it's copy number. More...
 
virtual std::vector< double > equidistantPoints (size_t nbr_samples, double sigma_factor, const RealLimits &limits=RealLimits()) const
 generate list of sample values More...
 
virtual std::vector< double > equidistantPointsInRange (size_t nbr_samples, double xmin, double xmax) const
 Returns equidistant interpolation points from xmin to xmax. More...
 
std::vector< ParameterSampleequidistantSamples (size_t nbr_samples, double sigma_factor=0., const RealLimits &limits=RealLimits()) const
 Returns equidistant samples, using intrinsic parameters, weighted with probabilityDensity(). More...
 
std::vector< ParameterSampleequidistantSamplesInRange (size_t nbr_samples, double xmin, double xmax) const
 Returns equidistant samples from xmin to xmax, weighted with probabilityDensity(). More...
 
virtual std::vector< const INode * > getChildren () const
 Returns a vector of children. More...
 
double getLeftWidth () const
 
double getMean () const final
 Returns the distribution-specific mean. More...
 
double getMiddleWidth () const
 
const std::string & getName () const
 
double getRightWidth () const
 
bool isDelta () const final
 Returns true if the distribution is in the limit case of a Dirac delta distribution. 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
 
double probabilityDensity (double x) const final
 Returns the distribution-specific probability density for value x. 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)
 
void setName (const std::string &name)
 
void setParameterValue (const std::string &name, double value)
 
virtual void setParent (const INode *newParent)
 
virtual void setUnits (const std::string &units)
 Sets distribution units. More...
 
void setVectorValue (const std::string &base_name, kvector_t value)
 
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

void adjustMinMaxForLimits (double &xmin, double &xmax, const RealLimits &limits) const
 modifies xmin and xmax if they are outside of limits More...
 
std::vector< ParameterSamplegenerateSamplesFromValues (const std::vector< double > &sample_values) const
 Returns weighted samples from given interpolation points and probabilityDensity(). More...
 

Protected Attributes

const size_t m_NP
 
std::vector< double > m_P
 

Private Member Functions

void adjustLimitsToNonZeroSamples (double &min, double &max, size_t nbr_samples) const
 

Private Attributes

const double & m_center
 
const double & m_left
 
const double & m_middle
 
std::string m_name
 
const INodem_parent {nullptr}
 
std::unique_ptr< ParameterPoolm_pool
 parameter pool (kind of pointer-to-implementation) More...
 
const double & m_right
 

Detailed Description

Trapezoidal distribution.

Definition at line 258 of file Distributions.h.

Constructor & Destructor Documentation

◆ DistributionTrapezoid() [1/3]

DistributionTrapezoid::DistributionTrapezoid ( const std::vector< double >  P)

Definition at line 382 of file Distributions.cpp.

383  : IDistribution1D({"DistributionTrapezoid",
384  "class_tooltip",
385  {{"Center", "", "para_tooltip", -INF, +INF, 0},
386  {"LeftWidth", "", "para_tooltip", -INF, +INF, 0},
387  {"MiddleWidth", "", "para_tooltip", -INF, +INF, 0},
388  {"RightWidth", "", "para_tooltip", -INF, +INF, 0}}},
389  P)
390  , m_center(m_P[0])
391  , m_left(m_P[1])
392  , m_middle(m_P[2])
393  , m_right(m_P[3])
394 {
395  if (m_left < 0.0)
396  throw std::runtime_error("DistributionTrapezoid: leftWidth < 0");
397  if (m_middle < 0.0)
398  throw std::runtime_error("DistributionTrapezoid: middleWidth < 0");
399  if (m_right < 0.0)
400  throw std::runtime_error("DistributionTrapezoid: rightWidth < 0");
401 }
const double INF
Definition: INode.h:25
const double & m_center
const double & m_left
const double & m_middle
const double & m_right
IDistribution1D(const NodeMeta &meta, const std::vector< double > &PValues)
std::vector< double > m_P
Definition: INode.h:89

References INF.

◆ DistributionTrapezoid() [2/3]

DistributionTrapezoid::DistributionTrapezoid ( double  center,
double  left,
double  middle,
double  right 
)

Definition at line 403 of file Distributions.cpp.

405  : DistributionTrapezoid(std::vector<double>{center, left, middle, right})
406 {
407 }

◆ DistributionTrapezoid() [3/3]

DistributionTrapezoid::DistributionTrapezoid ( )

Definition at line 285 of file Distributions.cpp.

285 : DistributionTrapezoid(0., 0., 1., 0.) {}

Referenced by clone().

Member Function Documentation

◆ accept()

void DistributionTrapezoid::accept ( INodeVisitor visitor) const
inlinefinalvirtual

Calls the INodeVisitor's visit method.

Implements INode.

Definition at line 281 of file Distributions.h.

281 { visitor->visit(this); }
virtual void visit(const BasicLattice2D *)
Definition: INodeVisitor.h:151

◆ adjustLimitsToNonZeroSamples()

void DistributionTrapezoid::adjustLimitsToNonZeroSamples ( double &  min,
double &  max,
size_t  nbr_samples 
) const
private

Definition at line 440 of file Distributions.cpp.

442 {
443  if (nbr_samples <= 1)
444  return;
445  size_t N = nbr_samples;
446  if (m_left > 0.0)
447  ++N;
448  if (m_right > 0.0)
449  ++N;
450  if (N == nbr_samples)
451  return;
452  double step = (max - min) / (N - 1);
453  if (m_left > 0.0)
454  min += step;
455  if (m_right > 0.0)
456  max -= step;
457 }

References m_left, and m_right.

Referenced by equidistantPoints().

◆ adjustMinMaxForLimits()

void IDistribution1D::adjustMinMaxForLimits ( double &  xmin,
double &  xmax,
const RealLimits limits 
) const
protectedinherited

modifies xmin and xmax if they are outside of limits

Definition at line 84 of file Distributions.cpp.

86 {
87  if (limits.hasLowerLimit() && xmin < limits.lowerLimit())
88  xmin = limits.lowerLimit();
89  if (limits.hasUpperLimit() && xmax > limits.upperLimit())
90  xmax = limits.upperLimit();
91  if (xmin > xmax) {
92  std::ostringstream ostr;
93  ostr << "IDistribution1D::adjustMinMaxForLimits() -> Error. Can't' adjust ";
94  ostr << "xmin:" << xmin << " xmax:" << xmax << " for given limits " << limits << std::endl;
95  throw std::runtime_error(ostr.str());
96  }
97 }
bool hasUpperLimit() const
if has upper limit
Definition: RealLimits.cpp:57
double upperLimit() const
Returns upper limit.
Definition: RealLimits.cpp:62
double lowerLimit() const
Returns lower limit.
Definition: RealLimits.cpp:40
bool hasLowerLimit() const
if has lower limit
Definition: RealLimits.cpp:35

References RealLimits::hasLowerLimit(), RealLimits::hasUpperLimit(), RealLimits::lowerLimit(), and RealLimits::upperLimit().

Referenced by DistributionGate::equidistantPoints(), DistributionLorentz::equidistantPoints(), DistributionGaussian::equidistantPoints(), DistributionLogNormal::equidistantPoints(), DistributionCosine::equidistantPoints(), and equidistantPoints().

Here is the call graph for this function:

◆ clone()

DistributionTrapezoid* DistributionTrapezoid::clone ( ) const
inlinefinalvirtual

Implements IDistribution1D.

Definition at line 264 of file Distributions.h.

265  {
267  }

References DistributionTrapezoid(), m_center, m_left, m_middle, and m_right.

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:

◆ 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:

◆ equidistantPoints()

std::vector< double > DistributionTrapezoid::equidistantPoints ( size_t  nbr_samples,
double  sigma_factor,
const RealLimits limits = RealLimits() 
) const
virtual

generate list of sample values

Implements IDistribution1D.

Definition at line 425 of file Distributions.cpp.

427 {
428  double xmin = m_center - m_middle / 2.0 - m_left;
429  double xmax = xmin + m_left + m_middle + m_right;
430  adjustLimitsToNonZeroSamples(xmin, xmax, nbr_samples);
431  adjustMinMaxForLimits(xmin, xmax, limits);
432  return equidistantPointsInRange(nbr_samples, xmin, xmax);
433 }
void adjustLimitsToNonZeroSamples(double &min, double &max, size_t nbr_samples) const
void adjustMinMaxForLimits(double &xmin, double &xmax, const RealLimits &limits) const
modifies xmin and xmax if they are outside of limits
virtual std::vector< double > equidistantPointsInRange(size_t nbr_samples, double xmin, double xmax) const
Returns equidistant interpolation points from xmin to xmax.

References adjustLimitsToNonZeroSamples(), IDistribution1D::adjustMinMaxForLimits(), IDistribution1D::equidistantPointsInRange(), m_center, m_left, m_middle, and m_right.

Here is the call graph for this function:

◆ equidistantPointsInRange()

std::vector< double > IDistribution1D::equidistantPointsInRange ( size_t  nbr_samples,
double  xmin,
double  xmax 
) const
virtualinherited

Returns equidistant interpolation points from xmin to xmax.

Definition at line 67 of file Distributions.cpp.

69 {
70  if (nbr_samples < 2 || DoubleEqual(xmin, xmax))
71  return {getMean()};
72  std::vector<double> result(nbr_samples);
73  for (size_t i = 0; i < nbr_samples; ++i)
74  result[i] = xmin + i * (xmax - xmin) / (nbr_samples - 1.0);
75  return result;
76 }
virtual double getMean() const =0
Returns the distribution-specific mean.

References IDistribution1D::getMean().

Referenced by DistributionGate::equidistantPoints(), DistributionLorentz::equidistantPoints(), DistributionGaussian::equidistantPoints(), DistributionLogNormal::equidistantPoints(), DistributionCosine::equidistantPoints(), equidistantPoints(), and IDistribution1D::equidistantSamplesInRange().

Here is the call graph for this function:

◆ equidistantSamples()

std::vector< ParameterSample > IDistribution1D::equidistantSamples ( size_t  nbr_samples,
double  sigma_factor = 0.,
const RealLimits limits = RealLimits() 
) const
inherited

Returns equidistant samples, using intrinsic parameters, weighted with probabilityDensity().

Definition at line 40 of file Distributions.cpp.

43 {
44  if (nbr_samples == 0)
45  throw std::runtime_error("IDistribution1D::generateSamples: "
46  "number of generated samples must be bigger than zero");
47  if (isDelta())
48  return {ParameterSample(getMean())};
49  return generateSamplesFromValues(equidistantPoints(nbr_samples, sigma_factor, limits));
50 }
std::vector< ParameterSample > generateSamplesFromValues(const std::vector< double > &sample_values) const
Returns weighted samples from given interpolation points and probabilityDensity().
virtual bool isDelta() const =0
Returns true if the distribution is in the limit case of a Dirac delta distribution.
virtual std::vector< double > equidistantPoints(size_t nbr_samples, double sigma_factor, const RealLimits &limits=RealLimits()) const =0
Returns equidistant interpolation points, with range computed in distribution-specific way from mean ...
A parameter value with a weight, as obtained when sampling from a distribution.

References IDistribution1D::equidistantPoints(), IDistribution1D::generateSamplesFromValues(), IDistribution1D::getMean(), and IDistribution1D::isDelta().

Here is the call graph for this function:

◆ equidistantSamplesInRange()

std::vector< ParameterSample > IDistribution1D::equidistantSamplesInRange ( size_t  nbr_samples,
double  xmin,
double  xmax 
) const
inherited

Returns equidistant samples from xmin to xmax, weighted with probabilityDensity().

Definition at line 55 of file Distributions.cpp.

56 {
57  if (nbr_samples == 0)
58  throw std::runtime_error("IDistribution1D::generateSamples: "
59  "number of generated samples must be bigger than zero");
60  if (isDelta())
61  return {ParameterSample(getMean())};
62  return generateSamplesFromValues(equidistantPointsInRange(nbr_samples, xmin, xmax));
63 }

References IDistribution1D::equidistantPointsInRange(), IDistribution1D::generateSamplesFromValues(), IDistribution1D::getMean(), and IDistribution1D::isDelta().

Here is the call graph for this function:

◆ generateSamplesFromValues()

std::vector< ParameterSample > IDistribution1D::generateSamplesFromValues ( const std::vector< double > &  sample_values) const
protectedinherited

Returns weighted samples from given interpolation points and probabilityDensity().

Definition at line 102 of file Distributions.cpp.

103 {
104  std::vector<ParameterSample> result;
105  double norm_factor = 0.0;
106  for (double value : sample_values) {
107  double pdf = probabilityDensity(value);
108  result.push_back(ParameterSample(value, pdf));
109  norm_factor += pdf;
110  }
111  if (norm_factor <= 0.0)
112  throw std::runtime_error("IDistribution1D::generateSamples: "
113  "total probability must be bigger than zero");
114  for (ParameterSample& sample : result)
115  sample.weight /= norm_factor;
116  return result;
117 }
virtual double probabilityDensity(double x) const =0
Returns the distribution-specific probability density for value x.

References IDistribution1D::probabilityDensity().

Referenced by IDistribution1D::equidistantSamples(), and IDistribution1D::equidistantSamplesInRange().

Here is the call graph for this function:

◆ getChildren()

◆ getLeftWidth()

double DistributionTrapezoid::getLeftWidth ( ) const
inline

Definition at line 271 of file Distributions.h.

271 { return m_left; }

References m_left.

◆ getMean()

double DistributionTrapezoid::getMean ( ) const
inlinefinalvirtual

Returns the distribution-specific mean.

Implements IDistribution1D.

Definition at line 270 of file Distributions.h.

270 { return m_center; }

References m_center.

◆ getMiddleWidth()

double DistributionTrapezoid::getMiddleWidth ( ) const
inline

Definition at line 272 of file Distributions.h.

272 { return m_middle; }

References m_middle.

◆ getName()

◆ getRightWidth()

double DistributionTrapezoid::getRightWidth ( ) const
inline

Definition at line 273 of file Distributions.h.

273 { return m_right; }

References m_right.

◆ isDelta()

bool DistributionTrapezoid::isDelta ( ) const
finalvirtual

Returns true if the distribution is in the limit case of a Dirac delta distribution.

Implements IDistribution1D.

Definition at line 435 of file Distributions.cpp.

436 {
437  return (m_left + m_middle + m_right) == 0.0;
438 }

References m_left, m_middle, and m_right.

◆ onChange()

◆ 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]

◆ probabilityDensity()

double DistributionTrapezoid::probabilityDensity ( double  x) const
finalvirtual

Returns the distribution-specific probability density for value x.

Implements IDistribution1D.

Definition at line 409 of file Distributions.cpp.

410 {
411  double height = 2.0 / (m_left + 2.0 * m_middle + m_right);
412  double min = m_center - m_middle / 2.0 - m_left;
413  if (x < min)
414  return 0.0;
415  if (x < min + m_left)
416  return (x - min) * height / m_left;
417  if (x < min + m_left + m_middle)
418  return height;
419  if (x < min + m_left + m_middle + m_right) {
420  return height - (x - min - m_left - m_middle) * height / m_right;
421  }
422  return 0.0;
423 }

References m_center, m_left, m_middle, and m_right.

◆ 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:

◆ registerChild()

void INode::registerChild ( INode node)
inherited

Definition at line 57 of file INode.cpp.

58 {
59  ASSERT(node);
60  node->setParent(this);
61 }
#define ASSERT(condition)
Definition: Assert.h:31
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:

◆ 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:

◆ 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().

◆ setUnits()

void IDistribution1D::setUnits ( const std::string &  units)
virtualinherited

Sets distribution units.

Reimplemented in DistributionLogNormal.

Definition at line 78 of file Distributions.cpp.

79 {
80  for (auto* par : parameterPool()->parameters())
81  par->setUnit(units);
82 }
ParameterPool * parameterPool() const
Returns pointer to the parameter pool.

References IParametricComponent::parameterPool().

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:

◆ 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:

◆ 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_center

const double& DistributionTrapezoid::m_center
private

Definition at line 285 of file Distributions.h.

Referenced by clone(), equidistantPoints(), getMean(), and probabilityDensity().

◆ m_left

const double& DistributionTrapezoid::m_left
private

◆ m_middle

const double& DistributionTrapezoid::m_middle
private

◆ 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_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_right

const double& DistributionTrapezoid::m_right
private

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