BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Slice.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Slice/Slice.cpp
6 //! @brief Implements class Slice.
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 #include "Sample/Slice/Slice.h"
18 
19 Slice::Slice(double thickness, const Material& material)
20  : m_thickness{thickness}, m_material{material}, m_B_field{}, m_top_roughness{nullptr}
21 {
22 }
23 
24 Slice::Slice(double thickness, const Material& material, const LayerRoughness& top_roughness)
25  : m_thickness{thickness}
26  , m_material{material}
27  , m_B_field{}
28  , m_top_roughness{top_roughness.clone()}
29 {
30 }
31 
32 Slice::Slice(const Slice& other)
33  : m_thickness{other.m_thickness}
34  , m_material{other.m_material}
35  , m_B_field{other.m_B_field}
36  , m_top_roughness{}
37 {
38  if (other.m_top_roughness) {
39  m_top_roughness.reset(other.m_top_roughness->clone());
40  }
41 }
42 
44  : m_thickness{other.m_thickness}
45  , m_material{std::move(other.m_material)}
46  , m_B_field{other.m_B_field}
47  , m_top_roughness{std::move(other.m_top_roughness)}
48 {
49 }
50 
52 {
53  m_thickness = other.m_thickness;
54  m_material = other.m_material;
55  m_B_field = other.m_B_field;
56  if (other.m_top_roughness) {
57  m_top_roughness.reset(other.m_top_roughness->clone());
58  }
59  return *this;
60 }
61 
62 Slice::~Slice() = default;
63 
64 void Slice::setMaterial(const Material& material)
65 {
67 }
68 
69 const Material& Slice::material() const
70 {
71  return m_material;
72 }
73 
74 double Slice::thickness() const
75 {
76  return m_thickness;
77 }
78 
80 {
81  return m_top_roughness.get();
82 }
83 
85 {
86  complex_t n = m_material.refractiveIndex(2.0 * M_PI / k.mag());
87  return MaterialUtils::ScalarReducedPotential(n, k, n_ref);
88 }
89 
90 Eigen::Matrix2cd Slice::polarizedReducedPotential(kvector_t k, double n_ref) const
91 {
92  complex_t n = m_material.refractiveIndex(2.0 * M_PI / k.mag());
94 }
95 
96 void Slice::initBField(kvector_t h_field, double b_z)
97 {
99  m_B_field.setZ(b_z);
100 }
101 
103 {
104  m_B_field = -m_B_field;
105 }
std::complex< double > complex_t
Definition: Complex.h:20
#define M_PI
Definition: Constants.h:44
Defines class LayerRoughness.
Declares functions in namespace MaterialUtils.
Defines class Slice.
double mag() const
Returns magnitude of the vector.
void setZ(const T &a)
Sets z-component in cartesian coordinate system.
Definition: BasicVector3D.h:74
A roughness of interface between two layers.
A wrapper for underlying material implementation.
Definition: Material.h:29
kvector_t magnetization() const
Get the magnetization (in A/m)
Definition: Material.cpp:76
complex_t refractiveIndex(double wavelength) const
Returns refractive index.
Definition: Material.cpp:46
Data structure containing the data of a single slice, for calculating the Fresnel coefficients.
Definition: Slice.h:32
Slice & operator=(const Slice &other)
Definition: Slice.cpp:51
std::unique_ptr< LayerRoughness > m_top_roughness
Definition: Slice.h:68
kvector_t m_B_field
cached value of magnetic induction
Definition: Slice.h:67
complex_t scalarReducedPotential(kvector_t k, double n_ref) const
Return the potential term that is used in the one-dimensional Fresnel calculations.
Definition: Slice.cpp:84
void invertBField()
Definition: Slice.cpp:102
void setMaterial(const Material &material)
Definition: Slice.cpp:64
const Material & material() const
Definition: Slice.cpp:69
double thickness() const
Definition: Slice.cpp:74
Slice(double thickness, const Material &material)
Definition: Slice.cpp:19
const LayerRoughness * topRoughness() const
Definition: Slice.cpp:79
Material m_material
Definition: Slice.h:66
double m_thickness
Definition: Slice.h:65
static constexpr double Magnetic_Permeability
Definition: Slice.h:62
Eigen::Matrix2cd polarizedReducedPotential(kvector_t k, double n_ref) const
Return the potential term that is used in the one-dimensional Fresnel calculations in the presence of...
Definition: Slice.cpp:90
void initBField(kvector_t h_field, double b_z)
Initializes the magnetic B field from a given ambient field strength H.
Definition: Slice.cpp:96
complex_t ScalarReducedPotential(complex_t n, kvector_t k, double n_ref)
Function for calculating the reduced potential, used for obtaining the Fresnel coefficients (non-pola...
Eigen::Matrix2cd PolarizedReducedPotential(complex_t n, kvector_t b_field, kvector_t k, double n_ref)
Function for calculating the reduced potential, used for obtaining the Fresnel coefficients (polarize...
Definition: filesystem.h:81