BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Material.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
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_CORE_MATERIAL_MATERIAL_H
16 #define BORNAGAIN_CORE_MATERIAL_MATERIAL_H
17 
19 #include <memory>
20 #include <vector>
21 
22 class Transform3D;
23 class WavevectorInfo;
24 
25 //! A wrapper for underlying material implementation
26 //! @ingroup materials
27 
28 class Material
29 {
30 public:
31 #ifndef SWIG
32  //! Creates material with particular material implementation
33  Material(std::unique_ptr<BaseMaterialImpl> material_impl);
34 #endif // SWIG
35 
36  Material(const Material& material);
37 #ifndef SWIG
38  Material(Material&& material) = default;
39 #endif // SWIG
40 
41  Material& operator=(const Material& other);
42 #ifndef SWIG
43  Material& operator=(Material&& other) = default;
44 #endif // SWIG
45 
46  //! Constructs a material with inverted magnetization
47  Material inverted() const;
48 
49  //! Returns refractive index
50  complex_t refractiveIndex(double wavelength) const;
51 
52  //! Returns squared refractive index
54 
55  //! Indicates whether the interaction with the material is scalar.
56  //! This means that different polarization states will be diffracted equally
57  bool isScalarMaterial() const;
58 
59  bool isMagneticMaterial() const;
60 
61  //! Returns the name of material
62  std::string getName() const;
63 
64 #ifndef SWIG
65  //! Returns the type of underlying material implementation
66  MATERIAL_TYPES typeID() const;
67 #endif // SWIG
68 
69  //! Get the magnetization (in A/m)
70  kvector_t magnetization() const;
71 
72  //! Returns underlying material data. The units of returned values
73  //! are the same as the ones passed to material factory functions
74  complex_t materialData() const;
75 
76  //! Returns true if material underlying data is nullptr
77  bool isEmpty() const { return !m_material_impl; }
78 
79  //! Returns true if material has refractive index of (1.0, 0.0)
80  //! and zero magnetization.
81  bool isDefaultMaterial() const;
82 
83  //! Returns (\f$ \pi/\lambda^2 \f$ - sld), sld (in \f$nm^{-2}\f$) being the scattering length
84  //! density
85  complex_t scalarSubtrSLD(const WavevectorInfo& wavevectors) const;
86 
87 #ifndef SWIG
88  //! Returns (\f$ \pi/\lambda^2 \f$ - sld) matrix with magnetization corrections
89  Eigen::Matrix2cd polarizedSubtrSLD(const WavevectorInfo& wavevectors) const;
90 #endif
91 
92  Material rotatedMaterial(const Transform3D& transform) const;
93 
94  friend std::ostream& operator<<(std::ostream& ostr, const Material& mat);
95 
96 private:
97  std::unique_ptr<BaseMaterialImpl> m_material_impl;
98 };
99 
100 //! Comparison operator for material wrapper (equality check)
101 bool operator==(const Material& left, const Material& right);
102 
103 //! Comparison operator for material wrapper (inequality check)
104 bool operator!=(const Material& left, const Material& right);
105 
106 #endif // BORNAGAIN_CORE_MATERIAL_MATERIAL_H
Defines basic material implementation interface.
MATERIAL_TYPES
std::complex< double > complex_t
Definition: Complex.h:20
bool operator!=(const BasicVector3D< T > &a, const BasicVector3D< T > &b)
Comparison of two vectors for inequality.
bool operator==(const BasicVector3D< T > &a, const BasicVector3D< T > &b)
Comparison of two vectors for equality.
A wrapper for underlying material implementation.
Definition: Material.h:29
kvector_t magnetization() const
Get the magnetization (in A/m)
Definition: Material.cpp:79
Material inverted() const
Constructs a material with inverted magnetization.
Definition: Material.cpp:43
Eigen::Matrix2cd polarizedSubtrSLD(const WavevectorInfo &wavevectors) const
Returns ( - sld) matrix with magnetization corrections.
Definition: Material.cpp:99
complex_t refractiveIndex(double wavelength) const
Returns refractive index.
Definition: Material.cpp:49
complex_t scalarSubtrSLD(const WavevectorInfo &wavevectors) const
Returns ( - sld), sld (in ) being the scattering length density.
Definition: Material.cpp:94
bool isScalarMaterial() const
Indicates whether the interaction with the material is scalar.
Definition: Material.cpp:59
Material rotatedMaterial(const Transform3D &transform) const
Definition: Material.cpp:104
bool isMagneticMaterial() const
Definition: Material.cpp:64
complex_t refractiveIndex2(double wavelength) const
Returns squared refractive index.
Definition: Material.cpp:54
Material(Material &&material)=default
Material & operator=(Material &&other)=default
std::string getName() const
Returns the name of material.
Definition: Material.cpp:69
std::unique_ptr< BaseMaterialImpl > m_material_impl
Definition: Material.h:97
MATERIAL_TYPES typeID() const
Returns the type of underlying material implementation.
Definition: Material.cpp:74
bool isDefaultMaterial() const
Returns true if material has refractive index of (1.0, 0.0) and zero magnetization.
Definition: Material.cpp:89
bool isEmpty() const
Returns true if material underlying data is nullptr.
Definition: Material.h:77
complex_t materialData() const
Returns underlying material data.
Definition: Material.cpp:84
friend std::ostream & operator<<(std::ostream &ostr, const Material &mat)
Definition: Material.cpp:110
Material(std::unique_ptr< BaseMaterialImpl > material_impl)
Creates material with particular material implementation.
Definition: Material.cpp:21
Material & operator=(const Material &other)
Definition: Material.cpp:34
Vector transformations in three dimensions.
Definition: Transform3D.h:28
Holds all wavevector information relevant for calculating form factors.