BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Material.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Material/Material.h
6 //! @brief Defines and implements class Material.
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_MATERIAL_MATERIAL_H
16 #define BORNAGAIN_SAMPLE_MATERIAL_MATERIAL_H
17 
18 #include <heinz/Complex.h>
19 #include <heinz/Vectors3D.h>
20 #include <memory>
21 #include <ostream>
22 #include <vector>
23 
24 #ifndef SWIG
26 #endif // SWIG
27 
28 class RotMatrix;
29 class SpinMatrix;
30 class WavevectorInfo;
31 
32 //! A wrapper for underlying material implementation
33 //! @ingroup materials
34 
35 class Material {
36 public:
37 #ifndef SWIG
38  //! Creates material with particular material implementation
39  Material(std::unique_ptr<BaseMaterialImpl>&& material_impl);
40 #endif // SWIG
41 
42  Material(const Material& material);
43 #ifndef SWIG
44  Material(Material&& material) = default;
45 #endif // SWIG
46 
47  Material& operator=(const Material& other);
48 #ifndef SWIG
49  Material& operator=(Material&& other) = default;
50 #endif // SWIG
51 
52  //! Constructs a material with inverted magnetization
53  Material inverted() const;
54 
55  //! Returns refractive index
56  complex_t refractiveIndex(double wavelength) const;
57 
58  //! Returns squared refractive index
59  complex_t refractiveIndex2(double wavelength) const;
60 
61  //! Indicates whether the interaction with the material is scalar.
62  //! This means that different polarization states will be diffracted equally
63  bool isScalarMaterial() const;
64 
65  bool isMagneticMaterial() const;
66 
67  //! Returns the name of material
68  std::string materialName() const;
69 
70 #ifndef SWIG
71  //! Returns the type of underlying material implementation
72  MATERIAL_TYPES typeID() const;
73 #endif // USER_API
74 
75  //! Get the magnetization (in A/m)
76  R3 magnetization() const;
77 
78  //! Returns delta + i beta.
79  complex_t materialData() const;
80 
81  //! Returns true if material underlying data is nullptr
82  bool isEmpty() const;
83 
84  //! Returns true if material has refractive index of (1.0, 0.0) and zero magnetization.
85  bool isDefaultMaterial() const;
86 
87  //! Returns (\f$ \pi/\lambda^2 \f$ - sld),
88  //! sld (in \f$nm^{-2}\f$) being the scattering length density
89  complex_t scalarSubtrSLD(const WavevectorInfo& wavevectors) const;
90 
91  //! Returns (\f$ \pi/\lambda^2 \f$ - sld) matrix with magnetization corrections
92  SpinMatrix polarizedSubtrSLD(const WavevectorInfo& wavevectors) const;
93 
94  Material rotatedMaterial(const RotMatrix& transform) const;
95 
96  friend std::ostream& operator<<(std::ostream& ostr, const Material& mat);
97 
98 private:
99 #ifndef SWIG
100  std::unique_ptr<BaseMaterialImpl> m_material_impl;
101 #endif // SWIG
102 };
103 
104 //! Comparison operator for material wrapper (equality check)
105 bool operator==(const Material& left, const Material& right);
106 
107 //! Comparison operator for material wrapper (inequality check)
108 bool operator!=(const Material& left, const Material& right);
109 
110 #endif // BORNAGAIN_SAMPLE_MATERIAL_MATERIAL_H
Defines basic material implementation interface.
MATERIAL_TYPES
bool operator!=(const Material &left, const Material &right)
Comparison operator for material wrapper (inequality check)
Definition: Material.cpp:133
bool operator==(const Material &left, const Material &right)
Comparison operator for material wrapper (equality check)
Definition: Material.cpp:120
A wrapper for underlying material implementation.
Definition: Material.h:35
Material inverted() const
Constructs a material with inverted magnetization.
Definition: Material.cpp:42
R3 magnetization() const
Get the magnetization (in A/m)
Definition: Material.cpp:78
complex_t refractiveIndex(double wavelength) const
Returns refractive index.
Definition: Material.cpp:48
complex_t scalarSubtrSLD(const WavevectorInfo &wavevectors) const
Returns ( - sld), sld (in ) being the scattering length density.
Definition: Material.cpp:98
bool isScalarMaterial() const
Indicates whether the interaction with the material is scalar. This means that different polarization...
Definition: Material.cpp:58
bool isMagneticMaterial() const
Definition: Material.cpp:63
std::string materialName() const
Returns the name of material.
Definition: Material.cpp:68
complex_t refractiveIndex2(double wavelength) const
Returns squared refractive index.
Definition: Material.cpp:53
Material(Material &&material)=default
Material & operator=(Material &&other)=default
Material(std::unique_ptr< BaseMaterialImpl > &&material_impl)
Creates material with particular material implementation.
Definition: Material.cpp:22
std::unique_ptr< BaseMaterialImpl > m_material_impl
Definition: Material.h:100
MATERIAL_TYPES typeID() const
Returns the type of underlying material implementation.
Definition: Material.cpp:73
bool isDefaultMaterial() const
Returns true if material has refractive index of (1.0, 0.0) and zero magnetization.
Definition: Material.cpp:88
bool isEmpty() const
Returns true if material underlying data is nullptr.
Definition: Material.cpp:93
Material rotatedMaterial(const RotMatrix &transform) const
Definition: Material.cpp:108
SpinMatrix polarizedSubtrSLD(const WavevectorInfo &wavevectors) const
Returns ( - sld) matrix with magnetization corrections.
Definition: Material.cpp:103
complex_t materialData() const
Returns delta + i beta.
Definition: Material.cpp:83
friend std::ostream & operator<<(std::ostream &ostr, const Material &mat)
Definition: Material.cpp:114
Material & operator=(const Material &other)
Definition: Material.cpp:33
Rotation matrix in three dimensions. Represents group SO(3). Internal parameterization based on quate...
Definition: RotMatrix.h:25
Holds all wavevector information relevant for calculating form factors.