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

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

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

Public Member Functions

 MultiLayer ()
 
 ~MultiLayer () override
 
void accept (INodeVisitor *visitor) const final
 Calls the INodeVisitor's visit method. More...
 
void addLayer (const Layer &layer)
 Adds layer with default (zero) roughness. More...
 
void addLayerWithTopRoughness (const Layer &layer, const LayerRoughness &roughness)
 Adds layer with top roughness. More...
 
MultiLayerclone () const final
 Returns a clone of this ISampleNode object. More...
 
std::vector< const Material * > containedMaterials () const
 Returns set of unique materials contained in this ISampleNode. More...
 
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...
 
double crossCorrLength () const
 Returns cross correlation length of roughnesses between interfaces. More...
 
std::string displayName () const
 Returns display name, composed from the name of node and it's copy number. More...
 
kvector_t externalField () const
 Returns the external field applied to the multilayer (units: A/m) More...
 
std::vector< const INode * > getChildren () const final
 Returns a vector of children. More...
 
const std::string & getName () const
 
bool isMagnetic () const
 Returns true if there is any magnetic material in this ISampleNode. More...
 
const Layerlayer (size_t i_layer) const
 Returns layer with given index. More...
 
const LayerInterfacelayerInterface (size_t i_interface) const
 Returns interface with given index. More...
 
virtual const Materialmaterial () const
 Returns nullptr, unless overwritten to return a specific material. More...
 
size_t numberOfLayers () const
 
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
 
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)
 
RoughnessModel roughnessModel () const
 
void setCrossCorrLength (double crossCorrLength)
 Sets cross correlation length of roughnesses between interfaces. More...
 
void setExternalField (kvector_t ext_field)
 Sets the external field applied to the multilayer (units: A/m) More...
 
void setName (const std::string &name)
 
void setParameterValue (const std::string &name, double value)
 
virtual void setParent (const INode *newParent)
 
void setRoughnessModel (RoughnessModel roughnessModel)
 
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 Attributes

const size_t m_NP
 
std::vector< double > m_P
 

Private Member Functions

void addAndRegisterInterface (LayerInterface *child)
 Adds the interface with simultaneous registration in parent class. More...
 
void addAndRegisterLayer (Layer *child)
 Adds the layer with simultaneous registration in parent class. More...
 
size_t check_interface_index (size_t i_interface) const
 Checks index of interface w.r.t. vector length. More...
 
size_t check_layer_index (size_t i_layer) const
 Checks index of layer w.r.t. vector length. More...
 
void handleLayerThicknessRegistration ()
 Handles correct registration of layer thicknesses (not needed for top and bottom layer) More...
 

Private Attributes

double m_crossCorrLength
 cross correlation length (in z direction) between different layers More...
 
kvector_t m_ext_field
 external magnetic field (in A/m) More...
 
SafePointerVector< LayerInterfacem_interfaces
 stack of layer interfaces [nlayers-1] More...
 
SafePointerVector< Layerm_layers
 stack of layers [nlayers] More...
 
std::string m_name
 
const INodem_parent {nullptr}
 
std::unique_ptr< ParameterPoolm_pool
 parameter pool (kind of pointer-to-implementation) More...
 
RoughnessModel m_roughness_model {RoughnessModel::DEFAULT}
 

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 }
void registerVector(const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
void setName(const std::string &name)
RealParameter & registerParameter(const std::string &name, double *parpointer)
double m_crossCorrLength
cross correlation length (in z direction) between different layers
Definition: MultiLayer.h:95
kvector_t m_ext_field
external magnetic field (in A/m)
Definition: MultiLayer.h:97
RealParameter & setNonnegative()
RealParameter & setUnit(const std::string &name)

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

Referenced by clone().

Here is the call graph for this function:

◆ ~MultiLayer()

MultiLayer::~MultiLayer ( )
overridedefault

Member Function Documentation

◆ accept()

void MultiLayer::accept ( INodeVisitor visitor) const
inlinefinalvirtual

Calls the INodeVisitor's visit method.

Implements INode.

Definition at line 48 of file MultiLayer.h.

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

◆ addAndRegisterInterface()

void MultiLayer::addAndRegisterInterface ( LayerInterface child)
private

Adds the interface with simultaneous registration in parent class.

Definition at line 140 of file MultiLayer.cpp.

141 {
142  m_interfaces.push_back(child);
143  registerChild(child);
144 }
void registerChild(INode *node)
Definition: INode.cpp:57
SafePointerVector< LayerInterface > m_interfaces
stack of layer interfaces [nlayers-1]
Definition: MultiLayer.h:93
void push_back(T *pointer)

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

Referenced by addLayerWithTopRoughness().

Here is the call graph for this function:

◆ addAndRegisterLayer()

void MultiLayer::addAndRegisterLayer ( Layer child)
private

Adds the layer with simultaneous registration in parent class.

Definition at line 133 of file MultiLayer.cpp.

134 {
135  m_layers.push_back(child);
137  registerChild(child);
138 }
SafePointerVector< Layer > m_layers
stack of layers [nlayers]
Definition: MultiLayer.h:91
void handleLayerThicknessRegistration()
Handles correct registration of layer thicknesses (not needed for top and bottom layer)
Definition: MultiLayer.cpp:146

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

Referenced by addLayerWithTopRoughness().

Here is the call graph for this function:

◆ addLayer()

void MultiLayer::addLayer ( const Layer layer)

Adds layer with default (zero) roughness.

Definition at line 53 of file MultiLayer.cpp.

54 {
55  LayerRoughness zero_roughness;
56  addLayerWithTopRoughness(layer, zero_roughness);
57 }
A roughness of interface between two layers.
const Layer * layer(size_t i_layer) const
Returns layer with given index.
Definition: MultiLayer.cpp:91
void addLayerWithTopRoughness(const Layer &layer, const LayerRoughness &roughness)
Adds layer with top roughness.
Definition: MultiLayer.cpp:60

References addLayerWithTopRoughness(), and layer().

Referenced by BoxesSquareLattice2DBuilder::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(), SquareLattice2DBuilder::buildSample(), CenteredSquareLattice2DBuilder::buildSample(), RotatedSquareLattice2DBuilder::buildSample(), FiniteSquareLattice2DBuilder::buildSample(), SuperLatticeBuilder::buildSample(), TwoLayerRoughnessBuilder::buildSample(), PlainMultiLayerBySLDBuilder::buildSample(), ThickAbsorptiveSampleBuilder::buildSample(), and clone().

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 60 of file MultiLayer.cpp.

61 {
62  Layer* new_layer = layer.clone();
63  if (numberOfLayers()) {
64  // not the top layer
65  const Layer* last_layer = m_layers.back();
66  LayerInterface* interface(nullptr);
67  if (roughness.getSigma() != 0.0)
68  interface = LayerInterface::createRoughInterface(last_layer, new_layer, roughness);
69  else
70  interface = LayerInterface::createSmoothInterface(last_layer, new_layer);
71  addAndRegisterInterface(interface);
72  } else {
73  // the top layer
74  if (new_layer->thickness() != 0.0){
75  delete new_layer;
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 
81  if (roughness.getSigma() != 0.0){
82  delete new_layer;
83  throw std::runtime_error(
84  "Invalid call to MultiLayer::addLayer(): the semi-infinite top layer "
85  "cannot have roughness.");
86  }
87  }
88  addAndRegisterLayer(new_layer);
89 }
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.
A layer in a MultiLayer sample.
Definition: Layer.h:27
double thickness() const
Definition: Layer.h:38
Layer * clone() const final
Returns a clone of this ISampleNode object.
Definition: Layer.cpp:34
void addAndRegisterLayer(Layer *child)
Adds the layer with simultaneous registration in parent class.
Definition: MultiLayer.cpp:133
size_t numberOfLayers() const
Definition: MultiLayer.h:50
void addAndRegisterInterface(LayerInterface *child)
Adds the interface with simultaneous registration in parent class.
Definition: MultiLayer.cpp:140

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(), and clone().

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 162 of file MultiLayer.cpp.

163 {
164  if (i_interface >= m_interfaces.size())
165  throw std::runtime_error("Interface index is out of bounds");
166  return i_interface;
167 }
size_t size() const

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

Referenced by layerInterface().

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 155 of file MultiLayer.cpp.

156 {
157  if (i_layer >= m_layers.size())
158  throw std::runtime_error("Layer index is out of bounds");
159  return i_layer;
160 }

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

Referenced by layer().

Here is the call graph for this function:

◆ clone()

MultiLayer * MultiLayer::clone ( ) const
finalvirtual

Returns a clone of this ISampleNode object.

Implements ISampleNode.

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  if (i > 0 && interface->getRoughness())
45  ret->addLayerWithTopRoughness(std::as_const(*m_layers[i]), *interface->getRoughness());
46  else
47  ret->addLayer(std::as_const(*m_layers[i]));
48  }
49  return ret;
50 }
kvector_t externalField() const
Returns the external field applied to the multilayer (units: A/m)
Definition: MultiLayer.h:70
RoughnessModel roughnessModel() const
Definition: MultiLayer.h:66
void addLayer(const Layer &layer)
Adds layer with default (zero) roughness.
Definition: MultiLayer.cpp:53
double crossCorrLength() const
Returns cross correlation length of roughnesses between interfaces.
Definition: MultiLayer.h:68

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

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

Here is the call graph for this function:

◆ containedMaterials()

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

Returns set of unique materials contained in this ISampleNode.

Definition at line 26 of file ISampleNode.cpp.

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

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

Referenced by MultiLayerUtils::ContainsCompatibleMaterials(), SampleToPython::initLabels(), and ISampleNode::isMagnetic().

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

◆ crossCorrLength()

double MultiLayer::crossCorrLength ( ) const
inline

Returns cross correlation length of roughnesses between interfaces.

Definition at line 68 of file MultiLayer.h.

68 { return m_crossCorrLength; }

References m_crossCorrLength.

Referenced by clone(), setCrossCorrLength(), and GUIDomainSampleVisitor::visit().

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

◆ externalField()

kvector_t MultiLayer::externalField ( ) const
inline

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

Definition at line 70 of file MultiLayer.h.

70 { return m_ext_field; }

References m_ext_field.

Referenced by clone(), and GUIDomainSampleVisitor::visit().

◆ getChildren()

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

Returns a vector of children.

Reimplemented from INode.

Definition at line 118 of file MultiLayer.cpp.

119 {
120  std::vector<const INode*> ret;
121  const size_t N = m_layers.size();
122  ret.reserve(N + m_interfaces.size());
123 
124  for (size_t i = 0; i < N; ++i) {
125  ret.push_back(m_layers[i]);
126  if (i == N - 1)
127  break;
128  ret.push_back(layerInterface(i));
129  }
130  return ret;
131 }
const LayerInterface * layerInterface(size_t i_interface) const
Returns interface with given index.
Definition: MultiLayer.cpp:96

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

Here is the call graph for this function:

◆ getName()

◆ handleLayerThicknessRegistration()

void MultiLayer::handleLayerThicknessRegistration ( )
private

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

Definition at line 146 of file MultiLayer.cpp.

147 {
148  size_t n_layers = numberOfLayers();
149  ASSERT(n_layers > 0);
150  m_layers[n_layers-1]->registerThickness(false);
151  if(n_layers > 2)
152  m_layers[n_layers-2]->registerThickness();
153 }
#define ASSERT(condition)
Definition: Assert.h:31

References ASSERT, m_layers, and numberOfLayers().

Referenced by addAndRegisterLayer().

Here is the call graph for this function:

◆ isMagnetic()

bool ISampleNode::isMagnetic ( ) const
inherited

Returns true if there is any magnetic material in this ISampleNode.

Definition at line 40 of file ISampleNode.cpp.

41 {
42  const auto materials = containedMaterials();
43  return std::any_of(materials.cbegin(), materials.cend(),
44  [](const Material* mat) { return mat->isMagneticMaterial(); });
45 }
std::vector< const Material * > containedMaterials() const
Returns set of unique materials contained in this ISampleNode.
Definition: ISampleNode.cpp:26

References ISampleNode::containedMaterials().

Referenced by ProcessedSample::initLayouts().

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 91 of file MultiLayer.cpp.

92 {
93  return m_layers[check_layer_index(i_layer)];
94 }
size_t check_layer_index(size_t i_layer) const
Checks index of layer w.r.t. vector length.
Definition: MultiLayer.cpp:155

References check_layer_index(), and m_layers.

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

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 96 of file MultiLayer.cpp.

97 {
98  return m_interfaces[check_interface_index(i_interface)];
99 }
size_t check_interface_index(size_t i_interface) const
Checks index of interface w.r.t. vector length.
Definition: MultiLayer.cpp:162

References check_interface_index(), and m_interfaces.

Referenced by getChildren(), MultiLayerUtils::hasRoughness(), and MultiLayerUtils::LayerTopRoughness().

Here is the call graph for this function:

◆ material()

virtual const Material* ISampleNode::material ( ) const
inlinevirtualinherited

◆ numberOfLayers()

size_t MultiLayer::numberOfLayers ( ) const
inline

Definition at line 50 of file MultiLayer.h.

50 { return m_layers.size(); }

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

Referenced by addLayerWithTopRoughness(), clone(), handleLayerThicknessRegistration(), MultiLayerUtils::hasRoughness(), MultiLayerUtils::IndexOfLayer(), ProcessedSample::initLayouts(), and ProcessedSample::initSlices().

Here is the call graph for this function:

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

◆ 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 }
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(), addAndRegisterInterface(), 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(), 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)
static std::string YComponentName(const std::string &base_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(), 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:

◆ roughnessModel()

◆ setCrossCorrLength()

void MultiLayer::setCrossCorrLength ( double  crossCorrLength)

Sets cross correlation length of roughnesses between interfaces.

Definition at line 101 of file MultiLayer.cpp.

102 {
103  if (crossCorrLength < 0.0)
104  throw std::runtime_error("Attempt to set crossCorrLength to negative value");
106 }

References crossCorrLength(), and m_crossCorrLength.

Referenced by MultiLayerWithRoughnessBuilder::buildSample().

Here is the call graph for this function:

◆ setExternalField()

void MultiLayer::setExternalField ( kvector_t  ext_field)

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

Definition at line 108 of file MultiLayer.cpp.

109 {
110  m_ext_field = ext_field;
111 }

References m_ext_field.

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

◆ setRoughnessModel()

void MultiLayer::setRoughnessModel ( RoughnessModel  roughnessModel)

Definition at line 113 of file MultiLayer.cpp.

114 {
116 }

References m_roughness_model, and roughnessModel().

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_crossCorrLength

double MultiLayer::m_crossCorrLength
private

cross correlation length (in z direction) between different layers

Definition at line 95 of file MultiLayer.h.

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

◆ m_ext_field

kvector_t MultiLayer::m_ext_field
private

external magnetic field (in A/m)

Definition at line 97 of file MultiLayer.h.

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

◆ m_interfaces

SafePointerVector<LayerInterface> MultiLayer::m_interfaces
private

stack of layer interfaces [nlayers-1]

Definition at line 93 of file MultiLayer.h.

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

◆ m_layers

SafePointerVector<Layer> MultiLayer::m_layers
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_roughness_model

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

Definition at line 99 of file MultiLayer.h.

Referenced by roughnessModel(), and setRoughnessModel().


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