BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiLayer Class Reference
Inheritance diagram for MultiLayer:
Collaboration diagram for MultiLayer:

Public Member Functions

 MultiLayer ()
 
 ~MultiLayer () override
 
MultiLayerclone () const final override
 
void accept (INodeVisitor *visitor) const final override
 
size_t numberOfLayers () const
 
void addLayer (const Layer &layer)
 
void addLayerWithTopRoughness (const Layer &layer, const LayerRoughness &roughness)
 
const Layerlayer (size_t i_layer) const
 
const LayerInterfacelayerInterface (size_t i_interface) const
 
void setCrossCorrLength (double crossCorrLength)
 
double crossCorrLength () const
 
void setExternalField (kvector_t ext_field)
 
kvector_t externalField () const
 
std::vector< const INode * > getChildren () const final override
 
void setRoughnessModel (RoughnessModel roughnessModel)
 
RoughnessModel roughnessModel () const
 
virtual const Materialmaterial () const
 
std::vector< const Material * > containedMaterials () const
 
virtual void transferToCPP ()
 
virtual std::string treeToString () const
 
void registerChild (INode *node)
 
virtual void setParent (const INode *newParent)
 
const INodeparent () const
 
INodeparent ()
 
int copyNumber (const INode *node) const
 
std::string displayName () const
 
ParameterPoolcreateParameterTree () const
 
ParameterPoolparameterPool () const
 
std::string parametersToString () const
 
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
 
virtual void onChange ()
 
void removeParameter (const std::string &name)
 
void removeVector (const std::string &base_name)
 
void setName (const std::string &name)
 
const std::string & getName () const
 

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 Attributes

const size_t m_NP
 
std::vector< double > m_P
 

Private Member Functions

void addAndRegisterLayer (Layer *child)
 
void addAndRegisterInterface (LayerInterface *child)
 
void handleLayerThicknessRegistration ()
 
size_t check_layer_index (size_t i_layer) const
 
size_t check_interface_index (size_t i_interface) const
 

Private Attributes

SafePointerVector< Layerm_layers
 
SafePointerVector< LayerInterfacem_interfaces
 
double m_crossCorrLength
 
kvector_t m_ext_field
 
RoughnessModel m_roughness_model {RoughnessModel::DEFAULT}
 
const INodem_parent {nullptr}
 
std::string m_name
 
std::unique_ptr< ParameterPoolm_pool
 

Detailed Description

Our sample model: a stack of layers one below the other.

Example of system of 4 layers (3 interfaces):

ambience layer #0 ------— interface #0 z=0.0 Fe, 20A layer #1 ------— interface #1 z=-20.0 Cr, 40A layer #2 ------— interface #2 z=-60.0 substrate layer #3

Definition at line 41 of file MultiLayer.h.

Constructor & Destructor Documentation

◆ MultiLayer()

MultiLayer::MultiLayer ( )

Definition at line 27 of file MultiLayer.cpp.

28 {
29  setName("MultiLayer");
30  registerParameter("CrossCorrelationLength", &m_crossCorrLength).setUnit("nm").setNonnegative();
31  registerVector("ExternalField", &m_ext_field, "");
32 }
RealParameter & registerParameter(const std::string &name, double *parpointer)
void setName(const std::string &name)
void registerVector(const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
double m_crossCorrLength
cross correlation length (in z direction) between different layers
Definition: MultiLayer.h:106
kvector_t m_ext_field
external magnetic field (in A/m)
Definition: MultiLayer.h:108
RealParameter & setNonnegative()
RealParameter & setUnit(const std::string &name)

References m_crossCorrLength, m_ext_field, IParameterized::registerParameter(), IParameterized::registerVector(), IParameterized::setName(), RealParameter::setNonnegative(), and RealParameter::setUnit().

Referenced by clone().

Here is the call graph for this function:

◆ ~MultiLayer()

MultiLayer::~MultiLayer ( )
overridedefault

Member Function Documentation

◆ clone()

MultiLayer * MultiLayer::clone ( ) const
finaloverridevirtual

Returns a clone of multilayer with clones of all layers and interfaces between layers.

Implements ISample.

Definition at line 36 of file MultiLayer.cpp.

37 {
38  auto* ret = new MultiLayer;
39  ret->setCrossCorrLength(crossCorrLength());
40  ret->setExternalField(externalField());
41  ret->setRoughnessModel(roughnessModel());
42  for (size_t i = 0; i < numberOfLayers(); ++i) {
43  const auto* interface = i > 0 ? m_interfaces[i - 1] : nullptr;
44  Layer* layer = m_layers[i]->clone();
45  if (i > 0 && interface->getRoughness())
46  ret->addLayerWithTopRoughness(*layer, *interface->getRoughness());
47  else
48  ret->addLayer(*layer);
49  }
50  return ret;
51 }
A layer, with thickness (in nanometer) and material.
Definition: Layer.h:28
SafePointerVector< LayerInterface > m_interfaces
stack of layer interfaces [nlayers-1]
Definition: MultiLayer.h:104
const Layer * layer(size_t i_layer) const
Returns layer with given index.
Definition: MultiLayer.cpp:88
MultiLayer * clone() const final override
Returns a clone of multilayer with clones of all layers and interfaces between layers.
Definition: MultiLayer.cpp:36
kvector_t externalField() const
Returns the external field applied to the multilayer (units: A/m)
Definition: MultiLayer.h:77
SafePointerVector< Layer > m_layers
stack of layers [nlayers]
Definition: MultiLayer.h:102
RoughnessModel roughnessModel() const
Definition: MultiLayer.h:83
size_t numberOfLayers() const
Definition: MultiLayer.h:53
void addLayer(const Layer &layer)
Adds object to multilayer.
Definition: MultiLayer.cpp:54
void addLayerWithTopRoughness(const Layer &layer, const LayerRoughness &roughness)
Adds layer with top roughness.
Definition: MultiLayer.cpp:61
double crossCorrLength() const
Returns cross correlation length of roughnesses between interfaces.
Definition: MultiLayer.h:71

References addLayer(), addLayerWithTopRoughness(), crossCorrLength(), externalField(), layer(), m_interfaces, m_layers, MultiLayer(), numberOfLayers(), and roughnessModel().

Referenced by PyImport::createFromPython(), and SampleProvider::setSample().

Here is the call graph for this function:

◆ accept()

void MultiLayer::accept ( INodeVisitor visitor) const
inlinefinaloverridevirtual

Calls the INodeVisitor's visit method.

Implements INode.

Definition at line 51 of file MultiLayer.h.

51 { visitor->visit(this); }
virtual void visit(const BasicLattice *)
Definition: INodeVisitor.h:154

◆ numberOfLayers()

size_t MultiLayer::numberOfLayers ( ) const
inline

◆ addLayer()

void MultiLayer::addLayer ( const Layer layer)

Adds object to multilayer.

Adds layer with default (zero) roughness.

Definition at line 54 of file MultiLayer.cpp.

55 {
56  LayerRoughness zero_roughness;
57  addLayerWithTopRoughness(layer, zero_roughness);
58 }
A roughness of interface between two layers.

References addLayerWithTopRoughness(), and layer().

Referenced by BoxesSquareLatticeBuilder::buildSample(), CoreShellParticleBuilder::buildSample(), CoreShellBoxRotateZandYBuilder::buildSample(), CustomMorphologyBuilder::buildSample(), CylindersAndPrismsBuilder::buildSample(), CylindersInDWBABuilder::buildSample(), CylindersInBABuilder::buildSample(), LargeCylindersInDWBABuilder::buildSample(), RotatedCylindersBuilder::buildSample(), HomogeneousMultilayerBuilder::buildSample(), Lattice1DBuilder::buildSample(), LayersWithAbsorptionBuilder::buildSample(), LayersWithAbsorptionBySLDBuilder::buildSample(), MagneticSubstrateZeroFieldBuilder::buildSample(), SimpleMagneticLayerBuilder::buildSample(), MagneticLayerBuilder::buildSample(), MagneticRotationBuilder::buildSample(), MagneticParticleZeroFieldBuilder::buildSample(), MagneticCylindersBuilder::buildSample(), MagneticSpheresBuilder::buildSample(), MesoCrystalBuilder::buildSample(), MultiLayerWithRoughnessBuilder::buildSample(), MultipleLayoutBuilder::buildSample(), RadialParaCrystalBuilder::buildSample(), Basic2DParaCrystalBuilder::buildSample(), HexParaCrystalBuilder::buildSample(), RectParaCrystalBuilder::buildSample(), ParticleCompositionBuilder::buildSample(), CylindersWithSizeDistributionBuilder::buildSample(), TwoTypesCylindersDistributionBuilder::buildSample(), RotatedPyramidsDistributionBuilder::buildSample(), SpheresWithLimitsDistributionBuilder::buildSample(), ConesWithLimitsDistributionBuilder::buildSample(), LinkedBoxDistributionBuilder::buildSample(), ParticleInVacuumBuilder::buildSample(), HardDiskBuilder::buildSample(), CosineRippleBuilder::buildSample(), TriangularRippleBuilder::buildSample(), RotatedPyramidsBuilder::buildSample(), SizeDistributionDAModelBuilder::buildSample(), SizeDistributionLMAModelBuilder::buildSample(), SizeDistributionSSCAModelBuilder::buildSample(), CylindersInSSCABuilder::buildSample(), SlicedCompositionBuilder::buildSample(), SlicedCylindersBuilder::buildSample(), SLDSlicedCylindersBuilder::buildSample(), AveragedSlicedCylindersBuilder::buildSample(), TransformBoxBuilder::buildSample(), Basic2DLatticeBuilder::buildSample(), SquareLatticeBuilder::buildSample(), CenteredSquareLatticeBuilder::buildSample(), RotatedSquareLatticeBuilder::buildSample(), FiniteSquareLatticeBuilder::buildSample(), SuperLatticeBuilder::buildSample(), TwoLayerRoughnessBuilder::buildSample(), PlainMultiLayerBySLDBuilder::buildSample(), ThickAbsorptiveSampleBuilder::buildSample(), clone(), anonymous_namespace{BoxCompositionBuilder.cpp}::finalizeMultiLayer(), and anonymous_namespace{MagneticLayersBuilder.cpp}::parametricBuild().

Here is the call graph for this function:

◆ addLayerWithTopRoughness()

void MultiLayer::addLayerWithTopRoughness ( const Layer layer,
const LayerRoughness roughness 
)

Adds layer with top roughness.

Definition at line 61 of file MultiLayer.cpp.

62 {
63  Layer* new_layer = layer.clone();
64  if (numberOfLayers()) {
65  // not the top layer
66  const Layer* last_layer = m_layers.back();
67  LayerInterface* interface(nullptr);
68  if (roughness.getSigma() != 0.0)
69  interface = LayerInterface::createRoughInterface(last_layer, new_layer, roughness);
70  else
71  interface = LayerInterface::createSmoothInterface(last_layer, new_layer);
72  addAndRegisterInterface(interface);
73  } else {
74  // the top layer
75  if (new_layer->thickness() != 0.0)
76  throw std::runtime_error(
77  "Invalid call to MultiLayer::addLayer(): the semi-infinite top layer "
78  "must have a pro forma thickness of 0");
79 
80  if (roughness.getSigma() != 0.0)
81  throw std::runtime_error(
82  "Invalid call to MultiLayer::addLayer(): the semi-infinite top layer "
83  "cannot have roughness.");
84  }
85  addAndRegisterLayer(new_layer);
86 }
Interface between two layers, possibly with roughness.
static LayerInterface * createRoughInterface(const Layer *top_layer, const Layer *bottom_layer, const LayerRoughness &roughness)
Creates rough interface between two layers.
static LayerInterface * createSmoothInterface(const Layer *top_layer, const Layer *bottom_layer)
Creates smooth interface between two layers.
double getSigma() const
Returns rms of roughness.
double thickness() const
Definition: Layer.h:39
Layer * clone() const override final
Returns a clone of this ISample object.
Definition: Layer.cpp:33
void addAndRegisterLayer(Layer *child)
Adds the layer with simultaneous registration in parent class.
Definition: MultiLayer.cpp:130
void addAndRegisterInterface(LayerInterface *child)
Adds the interface with simultaneous registration in parent class.
Definition: MultiLayer.cpp:137

References addAndRegisterInterface(), addAndRegisterLayer(), SafePointerVector< T >::back(), Layer::clone(), LayerInterface::createRoughInterface(), LayerInterface::createSmoothInterface(), LayerRoughness::getSigma(), layer(), m_layers, numberOfLayers(), and Layer::thickness().

Referenced by addLayer(), MultiLayerWithRoughnessBuilder::buildSample(), TwoLayerRoughnessBuilder::buildSample(), ThickAbsorptiveSampleBuilder::buildSample(), clone(), and anonymous_namespace{MagneticLayersBuilder.cpp}::parametricBuild().

Here is the call graph for this function:

◆ layer()

const Layer * MultiLayer::layer ( size_t  i_layer) const

Returns layer with given index.

Definition at line 88 of file MultiLayer.cpp.

89 {
90  return m_layers[check_layer_index(i_layer)];
91 }
size_t check_layer_index(size_t i_layer) const
Checks index of layer w.r.t. vector length.
Definition: MultiLayer.cpp:150

References check_layer_index(), and m_layers.

Referenced by addLayer(), addLayerWithTopRoughness(), clone(), MultiLayerUtils::IndexOfLayer(), ProcessedSample::initLayouts(), ProcessedSample::initSlices(), MultiLayerUtils::LayerThickness(), and MultiLayerUtils::ParticleRegions().

Here is the call graph for this function:

◆ layerInterface()

const LayerInterface * MultiLayer::layerInterface ( size_t  i_interface) const

Returns interface with given index.

Definition at line 93 of file MultiLayer.cpp.

94 {
95  return m_interfaces[check_interface_index(i_interface)];
96 }
size_t check_interface_index(size_t i_interface) const
Checks index of interface w.r.t. vector length.
Definition: MultiLayer.cpp:157

References check_interface_index(), and m_interfaces.

Referenced by MultiLayerUtils::hasRoughness(), MultiLayerUtils::LayerBottomInterface(), MultiLayerUtils::LayerTopInterface(), and MultiLayerUtils::LayerTopRoughness().

Here is the call graph for this function:

◆ setCrossCorrLength()

void MultiLayer::setCrossCorrLength ( double  crossCorrLength)

Sets cross correlation length of roughnesses between interfaces.

Definition at line 98 of file MultiLayer.cpp.

99 {
100  if (crossCorrLength < 0.0)
101  throw Exceptions::LogicErrorException("Attempt to set crossCorrLength to negative value");
103 }

References crossCorrLength(), and m_crossCorrLength.

Referenced by MultiLayerWithRoughnessBuilder::buildSample().

Here is the call graph for this function:

◆ crossCorrLength()

double MultiLayer::crossCorrLength ( ) const
inline

Returns cross correlation length of roughnesses between interfaces.

Definition at line 71 of file MultiLayer.h.

71 { return m_crossCorrLength; }

References m_crossCorrLength.

Referenced by clone(), and setCrossCorrLength().

◆ setExternalField()

void MultiLayer::setExternalField ( kvector_t  ext_field)

Sets the external field applied to the multilayer (units: A/m)

Definition at line 105 of file MultiLayer.cpp.

106 {
107  m_ext_field = ext_field;
108 }

References m_ext_field.

◆ externalField()

kvector_t MultiLayer::externalField ( ) const
inline

Returns the external field applied to the multilayer (units: A/m)

Definition at line 77 of file MultiLayer.h.

77 { return m_ext_field; }

References m_ext_field.

Referenced by clone().

◆ getChildren()

std::vector< const INode * > MultiLayer::getChildren ( ) const
finaloverridevirtual

Returns a vector of children (const).

Reimplemented from INode.

Definition at line 115 of file MultiLayer.cpp.

116 {
117  std::vector<const INode*> ret;
118  const size_t N = m_layers.size();
119  ret.reserve(N + m_interfaces.size());
120 
121  for (size_t i = 0; i < N; ++i) {
122  ret.push_back(m_layers[i]);
123  const LayerInterface* interface = MultiLayerUtils::LayerBottomInterface(*this, i);
124  if (interface)
125  ret.push_back(interface);
126  }
127  return ret;
128 }
const LayerInterface * LayerBottomInterface(const MultiLayer &multilayer, size_t i)
Returns bottom interface of layer.

References MultiLayerUtils::LayerBottomInterface(), m_interfaces, m_layers, and SafePointerVector< T >::size().

Here is the call graph for this function:

◆ setRoughnessModel()

void MultiLayer::setRoughnessModel ( RoughnessModel  roughnessModel)

Definition at line 110 of file MultiLayer.cpp.

111 {
113 }
RoughnessModel m_roughness_model
Definition: MultiLayer.h:110

References m_roughness_model, and roughnessModel().

Referenced by anonymous_namespace{MagneticLayersBuilder.cpp}::parametricBuild().

Here is the call graph for this function:

◆ roughnessModel()

◆ addAndRegisterLayer()

void MultiLayer::addAndRegisterLayer ( Layer child)
private

Adds the layer with simultaneous registration in parent class.

Definition at line 130 of file MultiLayer.cpp.

131 {
132  m_layers.push_back(child);
134  registerChild(child);
135 }
void registerChild(INode *node)
Definition: INode.cpp:58
void handleLayerThicknessRegistration()
Handles correct registration of layer thicknesses (not needed for top and bottom layer)
Definition: MultiLayer.cpp:143
void push_back(T *pointer)

References handleLayerThicknessRegistration(), m_layers, SafePointerVector< T >::push_back(), and INode::registerChild().

Referenced by addLayerWithTopRoughness().

Here is the call graph for this function:

◆ addAndRegisterInterface()

void MultiLayer::addAndRegisterInterface ( LayerInterface child)
private

Adds the interface with simultaneous registration in parent class.

Definition at line 137 of file MultiLayer.cpp.

138 {
139  m_interfaces.push_back(child);
140  registerChild(child);
141 }

References m_interfaces, SafePointerVector< T >::push_back(), and INode::registerChild().

Referenced by addLayerWithTopRoughness().

Here is the call graph for this function:

◆ handleLayerThicknessRegistration()

void MultiLayer::handleLayerThicknessRegistration ( )
private

Handles correct registration of layer thicknesses (not needed for top and bottom layer)

Definition at line 143 of file MultiLayer.cpp.

144 {
145  size_t n_layers = numberOfLayers();
146  for (size_t i = 0; i < numberOfLayers(); ++i)
147  m_layers[i]->registerThickness(i > 0 && i < n_layers - 1);
148 }

References m_layers, and numberOfLayers().

Referenced by addAndRegisterLayer().

Here is the call graph for this function:

◆ check_layer_index()

size_t MultiLayer::check_layer_index ( size_t  i_layer) const
private

Checks index of layer w.r.t. vector length.

Definition at line 150 of file MultiLayer.cpp.

151 {
152  if (i_layer >= m_layers.size())
153  throw Exceptions::OutOfBoundsException("Layer index is out of bounds");
154  return i_layer;
155 }

References m_layers, and SafePointerVector< T >::size().

Referenced by layer().

Here is the call graph for this function:

◆ check_interface_index()

size_t MultiLayer::check_interface_index ( size_t  i_interface) const
private

Checks index of interface w.r.t. vector length.

Definition at line 157 of file MultiLayer.cpp.

158 {
159  if (i_interface >= m_interfaces.size())
160  throw Exceptions::OutOfBoundsException("Interface index is out of bounds");
161  return i_interface;
162 }

References m_interfaces, and SafePointerVector< T >::size().

Referenced by layerInterface().

Here is the call graph for this function:

◆ material()

◆ containedMaterials()

std::vector< const Material * > ISample::containedMaterials ( ) const
inherited

Returns set of unique materials contained in this ISample.

Definition at line 23 of file ISample.cpp.

24 {
25  std::vector<const Material*> result;
26  if (const Material* p_material = material())
27  result.push_back(p_material);
28  for (auto child : getChildren()) {
29  if (const ISample* sample = dynamic_cast<const ISample*>(child)) {
30  for (const Material* p_material : sample->containedMaterials())
31  result.push_back(p_material);
32  }
33  }
34  return result;
35 }
virtual std::vector< const INode * > getChildren() const
Returns a vector of children (const).
Definition: INode.cpp:64
Pure virtual base class for sample components and properties related to scattering.
Definition: ISample.h:28
virtual const Material * material() const
Returns nullptr, unless overwritten to return a specific material.
Definition: ISample.h:37
A wrapper for underlying material implementation.
Definition: Material.h:29

References INode::getChildren(), and ISample::material().

Referenced by MultiLayerUtils::ContainsCompatibleMaterials(), anonymous_namespace{ProcessedSample.cpp}::ContainsMagneticMaterial(), and SampleToPython::initLabels().

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 53 of file INode.cpp.

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

References NodeUtils::nodeToString().

Here is the call graph for this function:

◆ registerChild()

void INode::registerChild ( INode node)
inherited

Definition at line 58 of file INode.cpp.

59 {
60  ASSERT(node);
61  node->setParent(this);
62 }
#define ASSERT(condition)
Definition: Assert.h:26
virtual void setParent(const INode *newParent)
Definition: INode.cpp:69

References ASSERT, and INode::setParent().

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

Here is the call graph for this function:

◆ setParent()

void INode::setParent ( const INode newParent)
virtualinherited

Reimplemented in SampleProvider.

Definition at line 69 of file INode.cpp.

70 {
71  m_parent = newParent;
72 }
const INode * m_parent
Definition: INode.h:81

References INode::m_parent.

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

◆ parent() [1/2]

const INode * INode::parent ( ) const
inherited

◆ parent() [2/2]

INode * INode::parent ( )
inherited

Definition at line 79 of file INode.cpp.

80 {
81  return const_cast<INode*>(m_parent);
82 }
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49

References INode::m_parent.

◆ 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 84 of file INode.cpp.

85 {
86  if (node->parent() != this)
87  return -1;
88 
89  int result(-1), count(0);
90  for (auto child : getChildren()) {
91 
92  if (child == nullptr)
93  throw std::runtime_error("INode::copyNumber() -> Error. Nullptr as child.");
94 
95  if (child == node)
96  result = count;
97 
98  if (child->getName() == node->getName())
99  ++count;
100  }
101 
102  return count > 1 ? result : -1;
103 }
const INode * parent() const
Definition: INode.cpp:74
const std::string & getName() const

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

Referenced by INode::displayName().

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 105 of file INode.cpp.

106 {
107  std::string result = getName();
108  if (m_parent) {
109  int index = m_parent->copyNumber(this);
110  if (index >= 0)
111  result = result + std::to_string(index);
112  }
113  return result;
114 }
int copyNumber(const INode *node) const
Returns copyNumber of child, which takes into account existence of children with same name.
Definition: INode.cpp:84

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

Referenced by NodeUtils::nodePath(), and anonymous_namespace{NodeUtils.cpp}::nodeString().

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 IParameterized.

Definition at line 116 of file INode.cpp.

117 {
118  std::unique_ptr<ParameterPool> result(new ParameterPool);
119 
121  it.first();
122  while (!it.isDone()) {
123  const INode* child = it.getCurrent();
124  const std::string path = NodeUtils::nodePath(*child, this->parent()) + "/";
125  child->parameterPool()->copyToExternalPool(path, result.get());
126  it.next();
127  }
128 
129  return result.release();
130 }
ParameterPool * parameterPool() const
Returns pointer to the parameter pool.
Iterator through INode tree of objects.
Definition: NodeIterator.h:90
Container with parameters for IParameterized object.
Definition: ParameterPool.h:30
void copyToExternalPool(const std::string &prefix, ParameterPool *other_pool) const
Copies parameters of given pool to other pool, prepeding prefix to the parameter names.
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:82

References ParameterPool::copyToExternalPool(), NodeIterator< Strategy >::first(), NodeIterator< Strategy >::getCurrent(), NodeIterator< Strategy >::isDone(), NodeIterator< Strategy >::next(), NodeUtils::nodePath(), IParameterized::parameterPool(), and INode::parent().

Referenced by ParticleDistribution::generateParticles(), Simulation::runSimulation(), DepthProbeSimulation::validateParametrization(), OffSpecSimulation::validateParametrization(), and SpecularSimulation::validateParametrization().

Here is the call graph for this function:

◆ parameterPool()

ParameterPool* IParameterized::parameterPool ( ) const
inlineinherited

Returns pointer to the parameter pool.

Definition at line 38 of file IParameterized.h.

38 { return m_pool.get(); } // has non-const usages!
std::unique_ptr< ParameterPool > m_pool
parameter pool (kind of pointer-to-implementation)

References IParameterized::m_pool.

Referenced by pyfmt2::argumentList(), SampleBuilderNode::borrow_builder_parameters(), INode::createParameterTree(), INode::INode(), IParameterized::IParameterized(), anonymous_namespace{NodeUtils.cpp}::poolToString(), SampleBuilderNode::reset(), and IDistribution1D::setUnits().

◆ parametersToString()

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

Returns multiline string representing available parameters.

Definition at line 40 of file IParameterized.cpp.

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

References IParameterized::createParameterTree().

Here is the call graph for this function:

◆ registerParameter()

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

Definition at line 48 of file IParameterized.cpp.

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

References IParameterized::getName(), IParameterized::m_pool, and IParameterized::onChange().

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

Here is the call graph for this function:

◆ registerVector()

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

Definition at line 54 of file IParameterized.cpp.

56 {
57  registerParameter(XComponentName(base_name), &((*p_vec)[0])).setUnit(units);
58  registerParameter(YComponentName(base_name), &((*p_vec)[1])).setUnit(units);
59  registerParameter(ZComponentName(base_name), &((*p_vec)[2])).setUnit(units);
60 }
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)

References IParameterized::registerParameter(), RealParameter::setUnit(), IParameterized::XComponentName(), IParameterized::YComponentName(), and IParameterized::ZComponentName().

Referenced by Beam::Beam(), DetectionProperties::DetectionProperties(), InterferenceFunctionTwin::InterferenceFunctionTwin(), MultiLayer(), Lattice::registerBasisVectors(), and IParticle::registerPosition().

Here is the call graph for this function:

◆ setParameterValue()

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

Definition at line 62 of file IParameterized.cpp.

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

References IParameterized::createParameterTree(), IParameterized::m_pool, and ParameterPool::setMatchedParametersValue().

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

Here is the call graph for this function:

◆ setVectorValue()

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

Definition at line 75 of file IParameterized.cpp.

76 {
77  setParameterValue(XComponentName(base_name), value.x());
78  setParameterValue(YComponentName(base_name), value.y());
79  setParameterValue(ZComponentName(base_name), value.z());
80 }
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64
void setParameterValue(const std::string &name, double value)

References IParameterized::setParameterValue(), BasicVector3D< T >::x(), IParameterized::XComponentName(), BasicVector3D< T >::y(), IParameterized::YComponentName(), BasicVector3D< T >::z(), and IParameterized::ZComponentName().

Here is the call graph for this function:

◆ parameter()

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

◆ onChange()

◆ removeParameter()

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

◆ removeVector()

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

Definition at line 93 of file IParameterized.cpp.

94 {
95  removeParameter(XComponentName(base_name));
96  removeParameter(YComponentName(base_name));
97  removeParameter(ZComponentName(base_name));
98 }
void removeParameter(const std::string &name)

References IParameterized::removeParameter(), IParameterized::XComponentName(), IParameterized::YComponentName(), and IParameterized::ZComponentName().

Referenced by IParticle::registerPosition().

Here is the call graph for this function:

◆ XComponentName()

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

◆ YComponentName()

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

Definition at line 105 of file IParameterized.cpp.

106 {
107  return base_name + "Y";
108 }

Referenced by IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::setVectorValue().

◆ ZComponentName()

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

Definition at line 110 of file IParameterized.cpp.

111 {
112  return base_name + "Z";
113 }

Referenced by IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::setVectorValue().

◆ setName()

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

Definition at line 68 of file IParameterized.h.

68 { m_name = name; }
std::string m_name

References IParameterized::m_name.

Referenced by BasicLattice::BasicLattice(), Beam::Beam(), Layer::clone(), ConvolutionDetectorResolution::ConvolutionDetectorResolution(), LayersWithAbsorptionBuilder::createSampleByIndex(), Basic2DParaCrystalBuilder::createSampleByIndex(), ParticleInVacuumBuilder::createSampleByIndex(), SimpleMagneticRotationBuilder::createSampleByIndex(), Crystal::Crystal(), DetectionProperties::DetectionProperties(), DistributionHandler::DistributionHandler(), FormFactorBAPol::FormFactorBAPol(), FormFactorCoreShell::FormFactorCoreShell(), FormFactorCrystal::FormFactorCrystal(), FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(), FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(), FormFactorDecoratorRotation::FormFactorDecoratorRotation(), FormFactorDWBA::FormFactorDWBA(), FormFactorDWBAPol::FormFactorDWBAPol(), FormFactorWeighted::FormFactorWeighted(), HexagonalLattice::HexagonalLattice(), IDetector::IDetector(), DepthProbeSimulation::initialize(), GISASSimulation::initialize(), OffSpecSimulation::initialize(), SpecularSimulation::initialize(), SpecularDetector1D::initialize(), MesoCrystal::initialize(), Particle::initialize(), ParticleComposition::initialize(), 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(), Lattice::Lattice(), Layer::Layer(), LayerInterface::LayerInterface(), LayerRoughness::LayerRoughness(), MultiLayer(), Beam::operator=(), SampleBuilderNode::operator=(), ParticleCoreShell::ParticleCoreShell(), ParticleDistribution::ParticleDistribution(), ParticleLayout::ParticleLayout(), RectangularDetector::RectangularDetector(), SampleBuilderNode::reset(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), SampleBuilderNode::SampleBuilderNode(), SampleBuilderNode::setSBN(), SphericalDetector::SphericalDetector(), and SquareLattice::SquareLattice().

◆ getName()

Member Data Documentation

◆ m_layers

SafePointerVector<Layer> MultiLayer::m_layers
private

◆ m_interfaces

SafePointerVector<LayerInterface> MultiLayer::m_interfaces
private

stack of layer interfaces [nlayers-1]

Definition at line 104 of file MultiLayer.h.

Referenced by addAndRegisterInterface(), check_interface_index(), clone(), getChildren(), and layerInterface().

◆ m_crossCorrLength

double MultiLayer::m_crossCorrLength
private

cross correlation length (in z direction) between different layers

Definition at line 106 of file MultiLayer.h.

Referenced by crossCorrLength(), MultiLayer(), and setCrossCorrLength().

◆ m_ext_field

kvector_t MultiLayer::m_ext_field
private

external magnetic field (in A/m)

Definition at line 108 of file MultiLayer.h.

Referenced by externalField(), MultiLayer(), and setExternalField().

◆ m_roughness_model

RoughnessModel MultiLayer::m_roughness_model {RoughnessModel::DEFAULT}
private

Definition at line 110 of file MultiLayer.h.

Referenced by roughnessModel(), and setRoughnessModel().

◆ m_parent

const INode* INode::m_parent {nullptr}
privateinherited

Definition at line 81 of file INode.h.

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

◆ m_NP

const size_t INode::m_NP
protectedinherited

Definition at line 86 of file INode.h.

Referenced by INode::INode().

◆ m_P

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

Definition at line 87 of file INode.h.

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

◆ m_name

std::string IParameterized::m_name
privateinherited

Definition at line 72 of file IParameterized.h.

Referenced by IParameterized::getName(), and IParameterized::setName().

◆ m_pool

std::unique_ptr<ParameterPool> IParameterized::m_pool
privateinherited

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