BornAgain  1.19.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 reflection and scattering
4 //
5 //! @file Sample/LegacyRT/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 Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix,
19  const Eigen::Vector4cd& boundary_cond);
20 } // namespace
21 
22 MatrixRTCoefficients_v2::MatrixRTCoefficients_v2(double kz_sign, Eigen::Vector2cd eigenvalues,
23  kvector_t b)
24  : m_kz_sign(kz_sign), m_lambda(std::move(eigenvalues)), m_b(std::move(b))
25 {
26 }
27 
29 
31 
33 {
34  return new MatrixRTCoefficients_v2(*this);
35 }
36 
37 Eigen::Vector2cd MatrixRTCoefficients_v2::T1plus() const
38 {
39  const Eigen::Vector2cd result = waveVector(T1, m_w_plus);
40  if (m_lambda(0) == 0.0 && result == Eigen::Vector2cd::Zero())
41  return {0.5, 0.0};
42  return result;
43 }
44 
45 Eigen::Vector2cd MatrixRTCoefficients_v2::R1plus() const
46 {
47  if (m_lambda(0) == 0.0 && waveVector(T1, m_w_plus) == Eigen::Vector2cd::Zero())
48  return {-0.5, 0.0};
49  return waveVector(R1, m_w_plus);
50 }
51 
52 Eigen::Vector2cd MatrixRTCoefficients_v2::T2plus() const
53 {
54  const Eigen::Vector2cd result = waveVector(T2, m_w_plus);
55  if (m_lambda(1) == 0.0 && result == Eigen::Vector2cd::Zero())
56  return {0.5, 0.0};
57  return result;
58 }
59 
60 Eigen::Vector2cd MatrixRTCoefficients_v2::R2plus() const
61 {
62  if (m_lambda(1) == 0.0 && waveVector(T2, m_w_plus) == Eigen::Vector2cd::Zero())
63  return {-0.5, 0.0};
64  return waveVector(R2, m_w_plus);
65 }
66 
67 Eigen::Vector2cd MatrixRTCoefficients_v2::T1min() const
68 {
69  const Eigen::Vector2cd result = waveVector(T1, m_w_min);
70  if (m_lambda(0) == 0.0 && result == Eigen::Vector2cd::Zero())
71  return {0.0, 0.5};
72  return result;
73 }
74 
75 Eigen::Vector2cd MatrixRTCoefficients_v2::R1min() const
76 {
77  if (m_lambda(0) == 0.0 && waveVector(T1, m_w_min) == Eigen::Vector2cd::Zero())
78  return {0.0, -0.5};
79  return waveVector(R1, m_w_min);
80 }
81 
82 Eigen::Vector2cd MatrixRTCoefficients_v2::T2min() const
83 {
84  const Eigen::Vector2cd result = waveVector(T2, m_w_min);
85  if (m_lambda(1) == 0.0 && result == Eigen::Vector2cd::Zero())
86  return {0.0, 0.5};
87  return result;
88 }
89 
90 Eigen::Vector2cd MatrixRTCoefficients_v2::R2min() const
91 {
92  if (m_lambda(1) == 0.0 && waveVector(T2, m_w_min) == Eigen::Vector2cd::Zero())
93  return {0.0, -0.5};
94  return waveVector(R2, m_w_min);
95 }
96 
97 Eigen::Vector2cd MatrixRTCoefficients_v2::getKz() const
98 {
99  return -I * m_kz_sign * m_lambda;
100 }
101 
103 {
104  Eigen::Matrix2cd R;
105  R.col(0) = R1plus() + R2plus();
106  R.col(1) = R1min() + R2min();
107 
108  return R;
109 }
110 
111 namespace {
112 Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix,
113  const Eigen::Vector4cd& boundary_cond)
114 {
115  Eigen::Matrix<complex_t, 4, 1> m = frob_matrix * boundary_cond;
116  return {m(2), m(3)};
117 }
118 } // 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
Definition: filesystem.h:81