BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiLayer.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Multilayer/MultiLayer.h
6 //! @brief Defines class MultiLayer.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_SAMPLE_MULTILAYER_MULTILAYER_H
16 #define BORNAGAIN_SAMPLE_MULTILAYER_MULTILAYER_H
17 
21 #include <functional>
22 
23 class ParticleLayout;
24 class Layer;
25 class LayerInterface;
26 class LayerRoughness;
27 
28 //! Our sample model: a stack of layers one below the other.
29 //! @ingroup samples
30 
31 //! Example of system of 4 layers (3 interfaces):
32 //!
33 //! ambience layer #0
34 //! --------- interface #0 z=0.0
35 //! Fe, 20A layer #1
36 //! --------- interface #1 z=-20.0
37 //! Cr, 40A layer #2
38 //! --------- interface #2 z=-60.0
39 //! substrate layer #3
40 
41 class MultiLayer : public ISampleNode {
42 public:
43  MultiLayer();
44  ~MultiLayer() override;
45 
46  MultiLayer* clone() const final;
47 
48  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
49 
50  size_t numberOfLayers() const { return m_layers.size(); }
51 
52  void addLayer(const Layer& layer);
53  void addLayerWithTopRoughness(const Layer& layer, const LayerRoughness& roughness);
55  //! Sets cross correlation length of roughnesses between interfaces
57  //! Sets the external field applied to the multilayer (units: A/m)
58  void setExternalField(kvector_t ext_field);
59 
60  //! Returns layer with given index
61  const Layer* layer(size_t i_layer) const;
62 
63  //! Returns interface with given index
64  const LayerInterface* layerInterface(size_t i_interface) const;
65 
67  //! Returns cross correlation length of roughnesses between interfaces
68  double crossCorrLength() const { return m_crossCorrLength; }
69  //! Returns the external field applied to the multilayer (units: A/m)
70  kvector_t externalField() const { return m_ext_field; }
71 
72  std::vector<const INode*> getChildren() const final;
73 
74 private:
75  //! Adds the layer with simultaneous registration in parent class
76  void addAndRegisterLayer(Layer* child);
77 
78  //! Adds the interface with simultaneous registration in parent class
80 
81  //! Handles correct registration of layer thicknesses (not needed for top and bottom layer)
83 
84  //! Checks index of layer w.r.t. vector length
85  size_t check_layer_index(size_t i_layer) const;
86 
87  //! Checks index of interface w.r.t. vector length
88  size_t check_interface_index(size_t i_interface) const;
89 
90  //! stack of layers [nlayers]
92  //! stack of layer interfaces [nlayers-1]
94  //! cross correlation length (in z direction) between different layers
96  //! external magnetic field (in A/m)
98 
99  RoughnessModel m_roughness_model{RoughnessModel::DEFAULT};
100 };
101 
102 #endif // BORNAGAIN_SAMPLE_MULTILAYER_MULTILAYER_H
Defines interface class ISampleNode.
Define RoughnessModels enumerator and Python wrapper.
Defines and implements template class SafePointerVector.
Visitor interface to visit ISampleNode objects.
Definition: INodeVisitor.h:146
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:28
Interface between two layers, possibly with roughness.
A roughness of interface between two layers.
A layer in a MultiLayer sample.
Definition: Layer.h:27
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
size_t check_layer_index(size_t i_layer) const
Checks index of layer w.r.t. vector length.
Definition: MultiLayer.cpp:155
SafePointerVector< LayerInterface > m_interfaces
stack of layer interfaces [nlayers-1]
Definition: MultiLayer.h:93
double m_crossCorrLength
cross correlation length (in z direction) between different layers
Definition: MultiLayer.h:95
void setRoughnessModel(RoughnessModel roughnessModel)
Definition: MultiLayer.cpp:113
const LayerInterface * layerInterface(size_t i_interface) const
Returns interface with given index.
Definition: MultiLayer.cpp:96
const Layer * layer(size_t i_layer) const
Returns layer with given index.
Definition: MultiLayer.cpp:91
kvector_t externalField() const
Returns the external field applied to the multilayer (units: A/m)
Definition: MultiLayer.h:70
void addAndRegisterLayer(Layer *child)
Adds the layer with simultaneous registration in parent class.
Definition: MultiLayer.cpp:133
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
std::vector< const INode * > getChildren() const final
Returns a vector of children.
Definition: MultiLayer.cpp:118
size_t check_interface_index(size_t i_interface) const
Checks index of interface w.r.t. vector length.
Definition: MultiLayer.cpp:162
void setExternalField(kvector_t ext_field)
Sets the external field applied to the multilayer (units: A/m)
Definition: MultiLayer.cpp:108
kvector_t m_ext_field
external magnetic field (in A/m)
Definition: MultiLayer.h:97
RoughnessModel roughnessModel() const
Definition: MultiLayer.h:66
void setCrossCorrLength(double crossCorrLength)
Sets cross correlation length of roughnesses between interfaces.
Definition: MultiLayer.cpp:101
RoughnessModel m_roughness_model
Definition: MultiLayer.h:99
size_t numberOfLayers() const
Definition: MultiLayer.h:50
~MultiLayer() override
void addLayer(const Layer &layer)
Adds layer with default (zero) roughness.
Definition: MultiLayer.cpp:53
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
Definition: MultiLayer.h:48
void addLayerWithTopRoughness(const Layer &layer, const LayerRoughness &roughness)
Adds layer with top roughness.
Definition: MultiLayer.cpp:60
double crossCorrLength() const
Returns cross correlation length of roughnesses between interfaces.
Definition: MultiLayer.h:68
void addAndRegisterInterface(LayerInterface *child)
Adds the interface with simultaneous registration in parent class.
Definition: MultiLayer.cpp:140
MultiLayer * clone() const final
Returns a clone of this ISampleNode object.
Definition: MultiLayer.cpp:36
Decorator class that adds particles to ISampleNode objects.
A vector of pointers, owned by *this, with methods to handle them safely.
size_t size() const