BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MatrixRTCoefficients_v3 Class Reference
Inheritance diagram for MatrixRTCoefficients_v3:
Collaboration diagram for MatrixRTCoefficients_v3:

Public Member Functions

 MatrixRTCoefficients_v3 (double kz_sign, Eigen::Vector2cd eigenvalues, kvector_t b, double magnetic_SLD)
 
 MatrixRTCoefficients_v3 (const MatrixRTCoefficients_v3 &other)
 
 ~MatrixRTCoefficients_v3 () override
 
MatrixRTCoefficients_v3clone () const override
 
Eigen::Vector2cd T1plus () const override
 
Eigen::Vector2cd R1plus () const override
 
Eigen::Vector2cd T2plus () const override
 
Eigen::Vector2cd R2plus () const override
 
Eigen::Vector2cd T1min () const override
 
Eigen::Vector2cd R1min () const override
 
Eigen::Vector2cd T2min () const override
 
Eigen::Vector2cd R2min () const override
 
Eigen::Vector2cd getKz () const override
 
double magneticSLD () const
 
Eigen::Matrix2cd computeP () const
 
Eigen::Matrix2cd computeInverseP () const
 
Eigen::Matrix2cd computeDeltaMatrix (double thickness)
 
Eigen::Matrix2cd getReflectionMatrix () const override
 
virtual complex_t getScalarT () const
 
virtual complex_t getScalarR () const
 
virtual complex_t getScalarKz () const
 

Private Member Functions

Eigen::Matrix2cd TransformationMatrix (Eigen::Vector2d selection) const
 
Eigen::Matrix2cd T1Matrix () const
 
Eigen::Matrix2cd T2Matrix () const
 
Eigen::Matrix2cd pMatrixHelper (double sign) const
 

Private Attributes

double m_kz_sign
 
Eigen::Vector2cd m_lambda
 
kvector_t m_b
 
double m_magnetic_SLD
 
Eigen::Matrix2cd m_T
 
Eigen::Matrix2cd m_R
 

Friends

class SpecularMagneticNewStrategy
 
class SpecularMagneticNewNCStrategy
 
class SpecularMagneticNewNCTestingStrategy
 
class SpecularMagneticNewTanhStrategy
 
class SpecularMagnetic_v3ConsistencyTest
 
class SpecularMagnetic_v3ConsistencyTest_ScalarMagneticAmplitudes_Test
 
class SpecularMagnetic_v3ConsistencyTest_AmplitudesBackwardsBackwards_Test
 
template<class sampleClass >
class TestSimulation
 

Detailed Description

Specular reflection and transmission coefficients in a layer in case of magnetic interactions between the scattered particle and the layer.

Definition at line 26 of file MatrixRTCoefficients_v3.h.

Constructor & Destructor Documentation

◆ MatrixRTCoefficients_v3() [1/2]

MatrixRTCoefficients_v3::MatrixRTCoefficients_v3 ( double  kz_sign,
Eigen::Vector2cd  eigenvalues,
kvector_t  b,
double  magnetic_SLD 
)

Definition at line 24 of file MatrixRTCoefficients_v3.cpp.

26  : m_kz_sign(kz_sign), m_lambda(std::move(eigenvalues)), m_b(std::move(b)),
27  m_magnetic_SLD(magnetic_SLD)
28 {
29  ASSERT(std::abs(m_b.mag() - 1) < eps || (m_b.mag() < eps && magnetic_SLD < eps));
30 
31  m_T << 1, 0, 0, 1;
32  m_R << -1, 0, 0, -1;
33 }
#define ASSERT(condition)
Definition: Assert.h:26
double mag() const
Returns magnitude of the vector.
Eigen::Vector2cd m_lambda
wave propagation direction (-1 for direct one, 1 for time reverse)
kvector_t m_b
unit magnetic field vector
Eigen::Vector2cd eigenvalues(complex_t kz, double b_mag)

References ASSERT, anonymous_namespace{MatrixRTCoefficients_v3.cpp}::eps, m_b, m_R, m_T, and BasicVector3D< T >::mag().

Referenced by clone().

Here is the call graph for this function:

◆ MatrixRTCoefficients_v3() [2/2]

MatrixRTCoefficients_v3::MatrixRTCoefficients_v3 ( const MatrixRTCoefficients_v3 other)
default

◆ ~MatrixRTCoefficients_v3()

MatrixRTCoefficients_v3::~MatrixRTCoefficients_v3 ( )
overridedefault

Member Function Documentation

◆ clone()

MatrixRTCoefficients_v3 * MatrixRTCoefficients_v3::clone ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 39 of file MatrixRTCoefficients_v3.cpp.

40 {
41  return new MatrixRTCoefficients_v3(*this);
42 }
MatrixRTCoefficients_v3(double kz_sign, Eigen::Vector2cd eigenvalues, kvector_t b, double magnetic_SLD)

References MatrixRTCoefficients_v3().

Here is the call graph for this function:

◆ T1plus()

Eigen::Vector2cd MatrixRTCoefficients_v3::T1plus ( ) const
overridevirtual

The following functions return the transmitted and reflected amplitudes for different incoming beam polarizations and eigenmodes.

Implements ILayerRTCoefficients.

Definition at line 70 of file MatrixRTCoefficients_v3.cpp.

71 {
72  return T1Matrix() * m_T.col(0);
73 }
Eigen::Matrix2cd T1Matrix() const

References m_T, and T1Matrix().

Here is the call graph for this function:

◆ R1plus()

Eigen::Vector2cd MatrixRTCoefficients_v3::R1plus ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 75 of file MatrixRTCoefficients_v3.cpp.

76 {
77  return T1Matrix() * m_R.col(0);
78 }

References m_R, and T1Matrix().

Here is the call graph for this function:

◆ T2plus()

Eigen::Vector2cd MatrixRTCoefficients_v3::T2plus ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 80 of file MatrixRTCoefficients_v3.cpp.

81 {
82  return T2Matrix() * m_T.col(0);
83 }
Eigen::Matrix2cd T2Matrix() const

References m_T, and T2Matrix().

Here is the call graph for this function:

◆ R2plus()

Eigen::Vector2cd MatrixRTCoefficients_v3::R2plus ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 85 of file MatrixRTCoefficients_v3.cpp.

86 {
87  return T2Matrix() * m_R.col(0);
88 }

References m_R, and T2Matrix().

Here is the call graph for this function:

◆ T1min()

Eigen::Vector2cd MatrixRTCoefficients_v3::T1min ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 90 of file MatrixRTCoefficients_v3.cpp.

91 {
92  return T1Matrix() * m_T.col(1);
93 }

References m_T, and T1Matrix().

Here is the call graph for this function:

◆ R1min()

Eigen::Vector2cd MatrixRTCoefficients_v3::R1min ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 95 of file MatrixRTCoefficients_v3.cpp.

96 {
97  return T1Matrix() * m_R.col(1);
98 }

References m_R, and T1Matrix().

Here is the call graph for this function:

◆ T2min()

Eigen::Vector2cd MatrixRTCoefficients_v3::T2min ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 100 of file MatrixRTCoefficients_v3.cpp.

101 {
102  return T2Matrix() * m_T.col(1);
103 }

References m_T, and T2Matrix().

Here is the call graph for this function:

◆ R2min()

Eigen::Vector2cd MatrixRTCoefficients_v3::R2min ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 105 of file MatrixRTCoefficients_v3.cpp.

106 {
107  return T2Matrix() * m_R.col(1);
108 }

References m_R, and T2Matrix().

Here is the call graph for this function:

◆ getKz()

Eigen::Vector2cd MatrixRTCoefficients_v3::getKz ( ) const
overridevirtual

Returns z-part of the two wavevector eigenmodes.

Implements ILayerRTCoefficients.

Definition at line 110 of file MatrixRTCoefficients_v3.cpp.

111 {
112  return m_kz_sign * m_lambda;
113 }

References m_kz_sign, and m_lambda.

◆ magneticSLD()

double MatrixRTCoefficients_v3::magneticSLD ( ) const
inline

Definition at line 57 of file MatrixRTCoefficients_v3.h.

57 { return m_magnetic_SLD; }

References m_magnetic_SLD.

◆ computeP()

Eigen::Matrix2cd MatrixRTCoefficients_v3::computeP ( ) const

Definition at line 130 of file MatrixRTCoefficients_v3.cpp.

131 {
132  Eigen::Matrix2cd result = pMatrixHelper(1.);
133  result *= 0.5;
134 
135  return result;
136 }
Eigen::Matrix2cd pMatrixHelper(double sign) const

References pMatrixHelper().

Referenced by SpecularMagneticNewNCStrategy::computeBackwardsSubmatrices(), and SpecularMagneticNewTanhStrategy::computeBackwardsSubmatrices().

Here is the call graph for this function:

◆ computeInverseP()

Eigen::Matrix2cd MatrixRTCoefficients_v3::computeInverseP ( ) const

Definition at line 138 of file MatrixRTCoefficients_v3.cpp.

139 {
140  const complex_t alpha = m_lambda(1) + m_lambda(0);
141  const complex_t beta = m_lambda(1) - m_lambda(0);
142 
143  if (std::abs(alpha * alpha - beta * beta) == 0.)
144  return Eigen::Matrix2cd::Zero();
145 
146  Eigen::Matrix2cd result = pMatrixHelper(-1.);
147  result *= 2. / (alpha * alpha - beta * beta);
148 
149  return result;
150 }
std::complex< double > complex_t
Definition: Complex.h:20

References m_lambda, and pMatrixHelper().

Referenced by SpecularMagneticNewNCStrategy::computeBackwardsSubmatrices(), and SpecularMagneticNewTanhStrategy::computeBackwardsSubmatrices().

Here is the call graph for this function:

◆ computeDeltaMatrix()

Eigen::Matrix2cd MatrixRTCoefficients_v3::computeDeltaMatrix ( double  thickness)

Definition at line 152 of file MatrixRTCoefficients_v3.cpp.

153 {
154  Eigen::Matrix2cd result;
155  const complex_t alpha = 0.5 * thickness * (m_lambda(1) + m_lambda(0));
156 
157  const Eigen::Matrix2cd exp2 = Eigen::DiagonalMatrix<complex_t, 2>(
158  {GetImExponential(thickness * m_lambda(1)), GetImExponential(thickness * m_lambda(0))});
159 
160  // Compute resulting phase matrix according to exp(i p_m d_m) = exp1 * Q * exp2 * Q.adjoint();
161  if (std::abs(m_b.mag() - 1.) < eps) {
162  Eigen::Matrix2cd Q;
163  const double factor1 = 2. * (1. + m_b.z());
164  Q << (1. + m_b.z()), (I * m_b.y() - m_b.x()), (m_b.x() + I * m_b.y()), (m_b.z() + 1.);
165 
166  return Q * exp2 * Q.adjoint() / factor1;
167 
168  } else if (m_b.mag() < eps)
169  return Eigen::Matrix2cd::Identity() * GetImExponential(alpha);
170 
171  throw std::runtime_error("Broken magnetic field vector");
172 }
constexpr complex_t I
Definition: Complex.h:21
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64

References anonymous_namespace{MatrixRTCoefficients_v3.cpp}::eps, anonymous_namespace{MatrixRTCoefficients_v3.cpp}::GetImExponential(), I, m_b, m_lambda, BasicVector3D< T >::mag(), BasicVector3D< T >::x(), BasicVector3D< T >::y(), and BasicVector3D< T >::z().

Here is the call graph for this function:

◆ getReflectionMatrix()

Eigen::Matrix2cd MatrixRTCoefficients_v3::getReflectionMatrix ( ) const
inlineoverridevirtual

Reimplemented from ILayerRTCoefficients.

Definition at line 64 of file MatrixRTCoefficients_v3.h.

64 { return m_R; };

References m_R.

◆ TransformationMatrix()

Eigen::Matrix2cd MatrixRTCoefficients_v3::TransformationMatrix ( Eigen::Vector2d  selection) const
private

Definition at line 44 of file MatrixRTCoefficients_v3.cpp.

45 {
46  const Eigen::Matrix2cd exp2 = Eigen::DiagonalMatrix<complex_t, 2>(selection);
47 
48  if (std::abs(m_b.mag() - 1.) < eps) {
49  Eigen::Matrix2cd Q;
50  const double factor1 = 2. * (1. + m_b.z());
51  Q << (1. + m_b.z()), (I * m_b.y() - m_b.x()), (m_b.x() + I * m_b.y()), (m_b.z() + 1.);
52  return Q * exp2 * Q.adjoint() / factor1;
53 
54  } else if (m_b.mag() < eps)
55  return exp2;
56 
57  throw std::runtime_error("Broken magnetic field vector");
58 }

References anonymous_namespace{MatrixRTCoefficients_v3.cpp}::eps, I, m_b, BasicVector3D< T >::mag(), BasicVector3D< T >::x(), BasicVector3D< T >::y(), and BasicVector3D< T >::z().

Referenced by T1Matrix(), and T2Matrix().

Here is the call graph for this function:

◆ T1Matrix()

Eigen::Matrix2cd MatrixRTCoefficients_v3::T1Matrix ( ) const
private

Definition at line 60 of file MatrixRTCoefficients_v3.cpp.

61 {
62  return TransformationMatrix({0., 1.});
63 }
Eigen::Matrix2cd TransformationMatrix(Eigen::Vector2d selection) const

References TransformationMatrix().

Referenced by R1min(), R1plus(), T1min(), and T1plus().

Here is the call graph for this function:

◆ T2Matrix()

Eigen::Matrix2cd MatrixRTCoefficients_v3::T2Matrix ( ) const
private

Definition at line 65 of file MatrixRTCoefficients_v3.cpp.

66 {
67  return TransformationMatrix({1., 0.});
68 }

References TransformationMatrix().

Referenced by R2min(), R2plus(), T2min(), and T2plus().

Here is the call graph for this function:

◆ pMatrixHelper()

Eigen::Matrix2cd MatrixRTCoefficients_v3::pMatrixHelper ( double  sign) const
private

Definition at line 115 of file MatrixRTCoefficients_v3.cpp.

116 {
117  const complex_t alpha = m_lambda(1) + m_lambda(0);
118  const complex_t beta = m_lambda(1) - m_lambda(0);
119 
120  Eigen::Matrix2cd result;
121 
122  kvector_t b = m_b;
123 
124  result << alpha + sign * beta * b.z(), sign * beta * (b.x() - I * b.y()),
125  sign * beta * (b.x() + I * b.y()), alpha - sign * beta * b.z();
126 
127  return result;
128 }

References I, m_b, m_lambda, BasicVector3D< T >::x(), BasicVector3D< T >::y(), and BasicVector3D< T >::z().

Referenced by computeInverseP(), and computeP().

Here is the call graph for this function:

◆ getScalarT()

virtual complex_t ILayerRTCoefficients::getScalarT ( ) const
inlinevirtualinherited

Scalar value getters; these throw errors by default as they should only be used when the derived object is really scalar.

Reimplemented in ScalarRTCoefficients.

Definition at line 48 of file ILayerRTCoefficients.h.

49  {
50  throw Exceptions::NotImplementedException("ILayerRTCoefficients::"
51  "getScalarT(): coefficients are not scalar.");
52  }

◆ getScalarR()

virtual complex_t ILayerRTCoefficients::getScalarR ( ) const
inlinevirtualinherited

Reimplemented in ScalarRTCoefficients.

Definition at line 53 of file ILayerRTCoefficients.h.

54  {
55  throw Exceptions::NotImplementedException("ILayerRTCoefficients::"
56  "getScalarR(): coefficients are not scalar.");
57  }

◆ getScalarKz()

virtual complex_t ILayerRTCoefficients::getScalarKz ( ) const
inlinevirtualinherited

Reimplemented in ScalarRTCoefficients.

Definition at line 58 of file ILayerRTCoefficients.h.

59  {
60  throw Exceptions::NotImplementedException("ILayerRTCoefficients::"
61  "getScalarKz(): coefficients are not scalar.");
62  }

Friends And Related Function Documentation

◆ SpecularMagneticNewStrategy

friend class SpecularMagneticNewStrategy
friend

Definition at line 29 of file MatrixRTCoefficients_v3.h.

◆ SpecularMagneticNewNCStrategy

friend class SpecularMagneticNewNCStrategy
friend

Definition at line 30 of file MatrixRTCoefficients_v3.h.

◆ SpecularMagneticNewNCTestingStrategy

friend class SpecularMagneticNewNCTestingStrategy
friend

Definition at line 31 of file MatrixRTCoefficients_v3.h.

◆ SpecularMagneticNewTanhStrategy

friend class SpecularMagneticNewTanhStrategy
friend

Definition at line 32 of file MatrixRTCoefficients_v3.h.

◆ SpecularMagnetic_v3ConsistencyTest

friend class SpecularMagnetic_v3ConsistencyTest
friend

Definition at line 33 of file MatrixRTCoefficients_v3.h.

◆ SpecularMagnetic_v3ConsistencyTest_ScalarMagneticAmplitudes_Test

friend class SpecularMagnetic_v3ConsistencyTest_ScalarMagneticAmplitudes_Test
friend

Definition at line 34 of file MatrixRTCoefficients_v3.h.

◆ SpecularMagnetic_v3ConsistencyTest_AmplitudesBackwardsBackwards_Test

friend class SpecularMagnetic_v3ConsistencyTest_AmplitudesBackwardsBackwards_Test
friend

Definition at line 35 of file MatrixRTCoefficients_v3.h.

◆ TestSimulation

template<class sampleClass >
friend class TestSimulation
friend

Definition at line 36 of file MatrixRTCoefficients_v3.h.

Member Data Documentation

◆ m_kz_sign

double MatrixRTCoefficients_v3::m_kz_sign
private

Definition at line 67 of file MatrixRTCoefficients_v3.h.

Referenced by getKz().

◆ m_lambda

Eigen::Vector2cd MatrixRTCoefficients_v3::m_lambda
private

wave propagation direction (-1 for direct one, 1 for time reverse)

eigenvalues for wave propagation

Definition at line 68 of file MatrixRTCoefficients_v3.h.

Referenced by computeDeltaMatrix(), computeInverseP(), SpecularMagneticNewNCStrategy::computeRoughnessMatrices(), SpecularMagneticNewTanhStrategy::computeRoughnessMatrix(), getKz(), and pMatrixHelper().

◆ m_b

◆ m_magnetic_SLD

double MatrixRTCoefficients_v3::m_magnetic_SLD
private

Definition at line 70 of file MatrixRTCoefficients_v3.h.

Referenced by magneticSLD().

◆ m_T

Eigen::Matrix2cd MatrixRTCoefficients_v3::m_T
private

Definition at line 72 of file MatrixRTCoefficients_v3.h.

Referenced by MatrixRTCoefficients_v3(), T1min(), T1plus(), T2min(), and T2plus().

◆ m_R

Eigen::Matrix2cd MatrixRTCoefficients_v3::m_R
private

The documentation for this class was generated from the following files: