BornAgain  1.18.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 scattering at grazing incidence
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_CORE_MULTILAYER_MULTILAYER_H
16 #define BORNAGAIN_CORE_MULTILAYER_MULTILAYER_H
17 
21 #include <functional>
22 
23 class ILayout;
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 ISample
42 {
43 public:
44  MultiLayer();
45  ~MultiLayer() override;
46 
47  //! Returns a clone of multilayer with clones of all layers and
48  //! interfaces between layers
49  MultiLayer* clone() const final override;
50 
51  void accept(INodeVisitor* visitor) const final override { visitor->visit(this); }
52 
53  size_t numberOfLayers() const { return m_layers.size(); }
54 
55  //! Adds object to multilayer
56  void addLayer(const Layer& layer);
57 
58  //! Adds layer with top roughness
59  void addLayerWithTopRoughness(const Layer& layer, const LayerRoughness& roughness);
60 
61  //! Returns layer with given index
62  const Layer* layer(size_t i_layer) const;
63 
64  //! Returns interface with given index
65  const LayerInterface* layerInterface(size_t i_interface) const;
66 
67  //! Sets cross correlation length of roughnesses between interfaces
69 
70  //! Returns cross correlation length of roughnesses between interfaces
71  double crossCorrLength() const { return m_crossCorrLength; }
72 
73  //! Sets the external field applied to the multilayer (units: A/m)
74  void setExternalField(kvector_t ext_field);
75 
76  //! Returns the external field applied to the multilayer (units: A/m)
77  kvector_t externalField() const { return m_ext_field; }
78 
79  std::vector<const INode*> getChildren() const final override;
80 
81  void setRoughnessModel(RoughnessModel roughnessModel);
82 
83  RoughnessModel roughnessModel() const { return m_roughness_model; }
84 
85 private:
86  //! Adds the layer with simultaneous registration in parent class
87  void addAndRegisterLayer(Layer* child);
88 
89  //! Adds the interface with simultaneous registration in parent class
90  void addAndRegisterInterface(LayerInterface* child);
91 
92  //! Handles correct registration of layer thicknesses (not needed for top and bottom layer)
93  void handleLayerThicknessRegistration();
94 
95  //! Checks index of layer w.r.t. vector length
96  size_t check_layer_index(size_t i_layer) const;
97 
98  //! Checks index of interface w.r.t. vector length
99  size_t check_interface_index(size_t i_interface) const;
100 
101  //! stack of layers [nlayers]
102  SafePointerVector<Layer> m_layers;
103  //! stack of layer interfaces [nlayers-1]
105  //! cross correlation length (in z direction) between different layers
106  double m_crossCorrLength;
107  //! external magnetic field (in A/m)
108  kvector_t m_ext_field;
109 
110  RoughnessModel m_roughness_model{RoughnessModel::DEFAULT};
111 };
112 
113 #endif // BORNAGAIN_CORE_MULTILAYER_MULTILAYER_H
Defines interface class ISample.
Define RoughnessModels enumerator and Python wrapper.
Defines and implements template class SafePointerVector.
Pure virtual interface class to equip a sample layer with scattering properties.
Definition: ILayout.h:32
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
Pure virtual base class for sample components and properties related to scattering.
Definition: ISample.h:28
Interface between two layers, possibly with roughness.
A roughness of interface between two layers.
A layer, with thickness (in nanometer) and material.
Definition: Layer.h:28
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:42
const LayerInterface * layerInterface(size_t i_interface) const
Returns interface with given index.
Definition: MultiLayer.cpp:93
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
std::vector< const INode * > getChildren() const final override
Returns a vector of children (const).
Definition: MultiLayer.cpp:115
void setExternalField(kvector_t ext_field)
Sets the external field applied to the multilayer (units: A/m)
Definition: MultiLayer.cpp:105
void setCrossCorrLength(double crossCorrLength)
Sets cross correlation length of roughnesses between interfaces.
Definition: MultiLayer.cpp:98
void accept(INodeVisitor *visitor) const final override
Calls the INodeVisitor's visit method.
Definition: MultiLayer.h:51
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