BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
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 #include <heinz/Vectors3D.h>
23 
24 class ParticleLayout;
25 class Layer;
26 class LayerInterface;
27 class LayerRoughness;
28 
29 //! Our sample model: a stack of layers one below the other.
30 //! @ingroup samples
31 
32 //! Example of system of 4 layers (3 interfaces):
33 //! @verbatim
34 //! vacuum layer 0
35 //! --------- interface 0 z=0.0
36 //! Fe, 20A layer 1
37 //! --------- interface 1 z=-20.0
38 //! Cr, 40A layer 2
39 //! --------- interface 2 z=-60.0
40 //! substrate layer 3
41 //! @endverbatim
42 
43 class MultiLayer : public ISampleNode {
44 public:
45  MultiLayer(std::string name = "Unnamed");
46  ~MultiLayer() override;
47 
48  MultiLayer* clone() const override;
49  std::string className() const final { return "MultiLayer"; }
50 
51  size_t numberOfLayers() const { return m_layers.size(); }
52 
53  void addLayer(const Layer& layer);
54  void addLayerWithTopRoughness(const Layer& layer, const LayerRoughness& roughness);
56  //! Sets cross correlation length of roughnesses between interfaces
58  //! Sets the external field applied to the sample (units: A/m)
59  void setExternalField(R3 ext_field);
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 
68  //! Returns cross correlation length of roughnesses between interfaces
69  double crossCorrLength() const { return m_crossCorrLength; }
70  //! Returns the external field applied to the sample (units: A/m)
71  R3 externalField() const { return m_ext_field; }
72 
73  std::vector<const INode*> nodeChildren() const override;
74 
75  void setSampleName(const std::string& name) { m_sample_name = name; }
76  const std::string& sampleName() const { return m_sample_name; }
77 
78 private:
79  //! Adds the layer with simultaneous registration in parent class
80  void addLayer(Layer* child);
81 
82  //! Adds the interface with simultaneous registration in parent class
83  void addInterface(LayerInterface* child);
84 
85  //! stack of layers [nlayers]
87  //! stack of layer interfaces [nlayers-1]
89  //! cross correlation length (in z direction) between different layers
91  //! external magnetic field (in A/m)
93 
94  std::string m_sample_name{"Unnamed"};
95  RoughnessModel m_roughness_model{RoughnessModel::DEFAULT};
96 };
97 
98 #endif // BORNAGAIN_SAMPLE_MULTILAYER_MULTILAYER_H
Defines interface class ISampleNode.
Defines and implements templated class OwningVector.
Define RoughnessModels enumerator and Python wrapper.
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:27
Interface between two layers, possibly with roughness.
A roughness of interface between two layers.
A layer in a MultiLayer sample.
Definition: Layer.h:26
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:43
MultiLayer(std::string name="Unnamed")
Definition: MultiLayer.cpp:27
double m_crossCorrLength
cross correlation length (in z direction) between different layers
Definition: MultiLayer.h:90
R3 m_ext_field
external magnetic field (in A/m)
Definition: MultiLayer.h:92
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
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: MultiLayer.h:49
OwningVector< LayerInterface > m_interfaces
stack of layer interfaces [nlayers-1]
Definition: MultiLayer.h:88
MultiLayer * clone() const override
Returns a clone of this ISampleNode object.
Definition: MultiLayer.cpp:36
R3 externalField() const
Returns the external field applied to the sample (units: A/m)
Definition: MultiLayer.h:71
std::string m_sample_name
Definition: MultiLayer.h:94
RoughnessModel roughnessModel() const
Definition: MultiLayer.h:67
void setCrossCorrLength(double crossCorrLength)
Sets cross correlation length of roughnesses between interfaces.
Definition: MultiLayer.cpp:101
RoughnessModel m_roughness_model
Definition: MultiLayer.h:95
size_t numberOfLayers() const
Definition: MultiLayer.h:51
~MultiLayer() override
void addLayer(const Layer &layer)
Adds layer with default (zero) roughness.
Definition: MultiLayer.cpp:53
void setExternalField(R3 ext_field)
Sets the external field applied to the sample (units: A/m)
Definition: MultiLayer.cpp:108
void setSampleName(const std::string &name)
Definition: MultiLayer.h:75
void addInterface(LayerInterface *child)
Adds the interface with simultaneous registration in parent class.
Definition: MultiLayer.cpp:138
void addLayerWithTopRoughness(const Layer &layer, const LayerRoughness &roughness)
Adds layer with top roughness.
Definition: MultiLayer.cpp:60
const std::string & sampleName() const
Definition: MultiLayer.h:76
double crossCorrLength() const
Returns cross correlation length of roughnesses between interfaces.
Definition: MultiLayer.h:69
OwningVector< Layer > m_layers
stack of layers [nlayers]
Definition: MultiLayer.h:86
std::vector< const INode * > nodeChildren() const override
Returns all children.
Definition: MultiLayer.cpp:118
size_t size() const
Definition: OwningVector.h:70
Decorator class that adds particles to ISampleNode objects.