BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MatrixRTCoefficients_v2.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/RT/MatrixRTCoefficients_v2.cpp
6 //! @brief Implements class MatrixRTCoefficients_v2.
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 
16 
17 namespace
18 {
19 Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix,
20  const Eigen::Vector4cd& boundary_cond);
21 } // namespace
22 
24  kvector_t b)
25  : m_kz_sign(kz_sign), m_lambda(std::move(eigenvalues)), m_b(std::move(b))
26 {
27 }
28 
30 
32 
34 {
35  return new MatrixRTCoefficients_v2(*this);
36 }
37 
38 Eigen::Vector2cd MatrixRTCoefficients_v2::T1plus() const
39 {
40  const Eigen::Vector2cd result = waveVector(T1, m_w_plus);
41  if (m_lambda(0) == 0.0 && result == Eigen::Vector2cd::Zero())
42  return {0.5, 0.0};
43  return result;
44 }
45 
46 Eigen::Vector2cd MatrixRTCoefficients_v2::R1plus() const
47 {
48  if (m_lambda(0) == 0.0 && waveVector(T1, m_w_plus) == Eigen::Vector2cd::Zero())
49  return {-0.5, 0.0};
50  return waveVector(R1, m_w_plus);
51 }
52 
53 Eigen::Vector2cd MatrixRTCoefficients_v2::T2plus() const
54 {
55  const Eigen::Vector2cd result = waveVector(T2, m_w_plus);
56  if (m_lambda(1) == 0.0 && result == Eigen::Vector2cd::Zero())
57  return {0.5, 0.0};
58  return result;
59 }
60 
61 Eigen::Vector2cd MatrixRTCoefficients_v2::R2plus() const
62 {
63  if (m_lambda(1) == 0.0 && waveVector(T2, m_w_plus) == Eigen::Vector2cd::Zero())
64  return {-0.5, 0.0};
65  return waveVector(R2, m_w_plus);
66 }
67 
68 Eigen::Vector2cd MatrixRTCoefficients_v2::T1min() const
69 {
70  const Eigen::Vector2cd result = waveVector(T1, m_w_min);
71  if (m_lambda(0) == 0.0 && result == Eigen::Vector2cd::Zero())
72  return {0.0, 0.5};
73  return result;
74 }
75 
76 Eigen::Vector2cd MatrixRTCoefficients_v2::R1min() const
77 {
78  if (m_lambda(0) == 0.0 && waveVector(T1, m_w_min) == Eigen::Vector2cd::Zero())
79  return {0.0, -0.5};
80  return waveVector(R1, m_w_min);
81 }
82 
83 Eigen::Vector2cd MatrixRTCoefficients_v2::T2min() const
84 {
85  const Eigen::Vector2cd result = waveVector(T2, m_w_min);
86  if (m_lambda(1) == 0.0 && result == Eigen::Vector2cd::Zero())
87  return {0.0, 0.5};
88  return result;
89 }
90 
91 Eigen::Vector2cd MatrixRTCoefficients_v2::R2min() const
92 {
93  if (m_lambda(1) == 0.0 && waveVector(T2, m_w_min) == Eigen::Vector2cd::Zero())
94  return {0.0, -0.5};
95  return waveVector(R2, m_w_min);
96 }
97 
98 Eigen::Vector2cd MatrixRTCoefficients_v2::getKz() const
99 {
100  return -I * m_kz_sign * m_lambda;
101 }
102 
104 {
105  Eigen::Matrix2cd R;
106  R.col(0) = R1plus() + R2plus();
107  R.col(1) = R1min() + R2min();
108 
109  return R;
110 }
111 
112 namespace
113 {
114 Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix,
115  const Eigen::Vector4cd& boundary_cond)
116 {
117  Eigen::Matrix<complex_t, 4, 1> m = frob_matrix * boundary_cond;
118  return {m(2), m(3)};
119 }
120 } // namespace
constexpr complex_t I
Definition: Complex.h:21
Defines class MatrixRTCoefficients_v2.
Specular reflection and transmission coefficients in a layer in case of magnetic interactions between...
MatrixRTCoefficients_v2 * clone() const override
Eigen::Vector2cd T2plus() const override
Eigen::Vector2cd R2min() const override
~MatrixRTCoefficients_v2() override
Eigen::Vector2cd R2plus() const override
Eigen::Vector2cd getKz() const override
Returns z-part of the two wavevector eigenmodes.
Eigen::Vector2cd m_lambda
wave propagation direction (-1 for direct one, 1 for time reverse)
Eigen::Matrix4cd T2
matrix selecting the transmitted part of the second eigenmode
Eigen::Vector2cd T2min() const override
Eigen::Matrix4cd R1
matrix selecting the reflected part of the first eigenmode
Eigen::Vector2cd T1plus() const override
The following functions return the transmitted and reflected amplitudes for different incoming beam p...
Eigen::Vector4cd m_w_plus
boundary values for up-polarization
Eigen::Vector4cd m_w_min
boundary values for down-polarization
MatrixRTCoefficients_v2(double kz_sign, Eigen::Vector2cd eigenvalues, kvector_t b)
Eigen::Vector2cd T1min() const override
Eigen::Vector2cd R1min() const override
Eigen::Vector2cd R1plus() const override
Eigen::Matrix2cd getReflectionMatrix() const override
Eigen::Matrix4cd T1
matrix selecting the transmitted part of the first eigenmode
Eigen::Matrix4cd R2
matrix selecting the reflected part of the second eigenmode
Eigen::Vector2cd waveVector(const Eigen::Matrix4cd &frob_matrix, const Eigen::Vector4cd &boundary_cond)
Eigen::Vector2cd eigenvalues(complex_t kz, double b_mag)