BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MatrixRTCoefficients Class Reference

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

Inheritance diagram for MatrixRTCoefficients:
[legend]
Collaboration diagram for MatrixRTCoefficients:
[legend]

Public Member Functions

 MatrixRTCoefficients (const MatrixRTCoefficients &other)
 
 MatrixRTCoefficients (double kz_sign, Eigen::Vector2cd eigenvalues, kvector_t b, double magnetic_SLD)
 
 ~MatrixRTCoefficients () override
 
MatrixRTCoefficientsclone () const override
 
Eigen::Matrix2cd computeDeltaMatrix (double thickness)
 
Eigen::Matrix2cd computeInverseP () const
 
Eigen::Matrix2cd computeP () const
 
Eigen::Vector2cd getKz () const override
 Returns z-part of the two wavevector eigenmodes. More...
 
Eigen::Matrix2cd getReflectionMatrix () const override
 
virtual complex_t getScalarKz () const
 
virtual complex_t getScalarR () const
 
virtual complex_t getScalarT () const
 Scalar value getters; these throw errors by default as they should only be used when the derived object is really scalar. More...
 
double magneticSLD () const
 
MatrixRTCoefficientsoperator= (const MatrixRTCoefficients &)
 
Eigen::Vector2cd R1min () const override
 
Eigen::Vector2cd R1plus () const override
 
Eigen::Vector2cd R2min () const override
 
Eigen::Vector2cd R2plus () const override
 
Eigen::Vector2cd T1min () const override
 
Eigen::Vector2cd T1plus () const override
 The following functions return the transmitted and reflected amplitudes for different incoming beam polarizations and eigenmodes. More...
 
Eigen::Vector2cd T2min () const override
 
Eigen::Vector2cd T2plus () const override
 

Private Member Functions

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

Private Attributes

kvector_t m_b
 unit magnetic field vector More...
 
double m_kz_sign
 
Eigen::Vector2cd m_lambda
 wave propagation direction (-1 for direct one, 1 for time reverse) More...
 
double m_magnetic_SLD
 
Eigen::Matrix2cd m_R
 
Eigen::Matrix2cd m_T
 

Friends

class SpecularMagneticNCStrategy
 
class SpecularMagneticStrategy
 
class SpecularMagneticTanhStrategy
 

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 31 of file MatrixRTCoefficients.h.

Constructor & Destructor Documentation

◆ MatrixRTCoefficients() [1/2]

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

Definition at line 23 of file MatrixRTCoefficients.cpp.

25  : m_kz_sign(kz_sign)
26  , m_lambda(std::move(eigenvalues))
27  , m_b(std::move(b))
28  , m_magnetic_SLD(magnetic_SLD)
29 {
30  ASSERT(std::abs(m_b.mag() - 1) < eps || (m_b.mag() < eps && magnetic_SLD < eps));
31 
32  m_T << 1, 0, 0, 1;
33  m_R << -1, 0, 0, -1;
34 }
#define ASSERT(condition)
Definition: Assert.h:31
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

References ASSERT, m_b, m_R, m_T, and BasicVector3D< T >::mag().

Referenced by clone().

Here is the call graph for this function:

◆ MatrixRTCoefficients() [2/2]

MatrixRTCoefficients::MatrixRTCoefficients ( const MatrixRTCoefficients other)
default

◆ ~MatrixRTCoefficients()

MatrixRTCoefficients::~MatrixRTCoefficients ( )
overridedefault

Member Function Documentation

◆ clone()

MatrixRTCoefficients * MatrixRTCoefficients::clone ( ) const
overridevirtual

Implements ILayerRTCoefficients.

Definition at line 42 of file MatrixRTCoefficients.cpp.

43 {
44  return new MatrixRTCoefficients(*this);
45 }
MatrixRTCoefficients(double kz_sign, Eigen::Vector2cd eigenvalues, kvector_t b, double magnetic_SLD)

References MatrixRTCoefficients().

Here is the call graph for this function:

◆ computeDeltaMatrix()

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

Definition at line 153 of file MatrixRTCoefficients.cpp.

154 {
155  const complex_t alpha = 0.5 * thickness * (m_lambda(1) + m_lambda(0));
156 
157  // Compute resulting phase matrix according to exp(i p_m d_m) = exp1 * Q * exp2 * Q.adjoint();
158  if (std::abs(m_b.mag() - 1.) < eps) {
159  const Eigen::Matrix2cd exp2 = Eigen::DiagonalMatrix<complex_t, 2>(
160  {GetImExponential(m_kz_sign * thickness * m_lambda(1)),
161  GetImExponential(m_kz_sign * thickness * m_lambda(0))});
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(m_kz_sign * alpha);
170 
171  throw std::runtime_error("Broken magnetic field vector");
172 }
constexpr complex_t I
Definition: Complex.h:21
std::complex< double > complex_t
Definition: Complex.h:20
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:67
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:65
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:63

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

Here is the call graph for this function:

◆ computeInverseP()

Eigen::Matrix2cd MatrixRTCoefficients::computeInverseP ( ) const

Definition at line 139 of file MatrixRTCoefficients.cpp.

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

References m_lambda, and pMatrixHelper().

Referenced by SpecularMagneticNCStrategy::computeBackwardsSubmatrices(), and SpecularMagneticTanhStrategy::computeBackwardsSubmatrices().

Here is the call graph for this function:

◆ computeP()

Eigen::Matrix2cd MatrixRTCoefficients::computeP ( ) const

Definition at line 131 of file MatrixRTCoefficients.cpp.

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

References pMatrixHelper().

Referenced by SpecularMagneticNCStrategy::computeBackwardsSubmatrices(), and SpecularMagneticTanhStrategy::computeBackwardsSubmatrices().

Here is the call graph for this function:

◆ getKz()

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

Returns z-part of the two wavevector eigenmodes.

Implements ILayerRTCoefficients.

Definition at line 113 of file MatrixRTCoefficients.cpp.

114 {
115  return m_kz_sign * m_lambda;
116 }

References m_kz_sign, and m_lambda.

◆ getReflectionMatrix()

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

Reimplemented from ILayerRTCoefficients.

Definition at line 64 of file MatrixRTCoefficients.h.

64 { return m_R; };

References m_R.

◆ getScalarKz()

virtual complex_t ILayerRTCoefficients::getScalarKz ( ) const
inlinevirtualinherited

Reimplemented in ScalarRTCoefficients.

Definition at line 61 of file ILayerRTCoefficients.h.

62  {
63  throw std::runtime_error("ILayerRTCoefficients::"
64  "getScalarKz(): coefficients are not scalar.");
65  }

◆ getScalarR()

virtual complex_t ILayerRTCoefficients::getScalarR ( ) const
inlinevirtualinherited

Reimplemented in ScalarRTCoefficients.

Definition at line 56 of file ILayerRTCoefficients.h.

57  {
58  throw std::runtime_error("ILayerRTCoefficients::"
59  "getScalarR(): coefficients are not scalar.");
60  }

◆ 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 51 of file ILayerRTCoefficients.h.

52  {
53  throw std::runtime_error("ILayerRTCoefficients::"
54  "getScalarT(): coefficients are not scalar.");
55  }

◆ magneticSLD()

double MatrixRTCoefficients::magneticSLD ( ) const
inline

Definition at line 57 of file MatrixRTCoefficients.h.

57 { return m_magnetic_SLD; }

References m_magnetic_SLD.

◆ operator=()

MatrixRTCoefficients & MatrixRTCoefficients::operator= ( const MatrixRTCoefficients )
default

◆ pMatrixHelper()

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

Definition at line 118 of file MatrixRTCoefficients.cpp.

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

References I, m_b, m_kz_sign, 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:

◆ R1min()

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

Implements ILayerRTCoefficients.

Definition at line 98 of file MatrixRTCoefficients.cpp.

99 {
100  return T1Matrix() * m_R.col(1);
101 }
Eigen::Matrix2cd T1Matrix() const

References m_R, and T1Matrix().

Here is the call graph for this function:

◆ R1plus()

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

Implements ILayerRTCoefficients.

Definition at line 78 of file MatrixRTCoefficients.cpp.

79 {
80  return T1Matrix() * m_R.col(0);
81 }

References m_R, and T1Matrix().

Here is the call graph for this function:

◆ R2min()

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

Implements ILayerRTCoefficients.

Definition at line 108 of file MatrixRTCoefficients.cpp.

109 {
110  return T2Matrix() * m_R.col(1);
111 }
Eigen::Matrix2cd T2Matrix() const

References m_R, and T2Matrix().

Here is the call graph for this function:

◆ R2plus()

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

Implements ILayerRTCoefficients.

Definition at line 88 of file MatrixRTCoefficients.cpp.

89 {
90  return T2Matrix() * m_R.col(0);
91 }

References m_R, and T2Matrix().

Here is the call graph for this function:

◆ T1Matrix()

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

Definition at line 63 of file MatrixRTCoefficients.cpp.

64 {
65  return TransformationMatrix({0., 1.});
66 }
Eigen::Matrix2cd TransformationMatrix(Eigen::Vector2d selection) const

References TransformationMatrix().

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

Here is the call graph for this function:

◆ T1min()

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

Implements ILayerRTCoefficients.

Definition at line 93 of file MatrixRTCoefficients.cpp.

94 {
95  return T1Matrix() * m_T.col(1);
96 }

References m_T, and T1Matrix().

Here is the call graph for this function:

◆ T1plus()

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

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

Implements ILayerRTCoefficients.

Definition at line 73 of file MatrixRTCoefficients.cpp.

74 {
75  return T1Matrix() * m_T.col(0);
76 }

References m_T, and T1Matrix().

Here is the call graph for this function:

◆ T2Matrix()

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

Definition at line 68 of file MatrixRTCoefficients.cpp.

69 {
70  return TransformationMatrix({1., 0.});
71 }

References TransformationMatrix().

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

Here is the call graph for this function:

◆ T2min()

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

Implements ILayerRTCoefficients.

Definition at line 103 of file MatrixRTCoefficients.cpp.

104 {
105  return T2Matrix() * m_T.col(1);
106 }

References m_T, and T2Matrix().

Here is the call graph for this function:

◆ T2plus()

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

Implements ILayerRTCoefficients.

Definition at line 83 of file MatrixRTCoefficients.cpp.

84 {
85  return T2Matrix() * m_T.col(0);
86 }

References m_T, and T2Matrix().

Here is the call graph for this function:

◆ TransformationMatrix()

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

Definition at line 47 of file MatrixRTCoefficients.cpp.

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

References 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:

Friends And Related Function Documentation

◆ SpecularMagneticNCStrategy

friend class SpecularMagneticNCStrategy
friend

Definition at line 34 of file MatrixRTCoefficients.h.

◆ SpecularMagneticStrategy

friend class SpecularMagneticStrategy
friend

Definition at line 33 of file MatrixRTCoefficients.h.

◆ SpecularMagneticTanhStrategy

friend class SpecularMagneticTanhStrategy
friend

Definition at line 35 of file MatrixRTCoefficients.h.

Member Data Documentation

◆ m_b

◆ m_kz_sign

double MatrixRTCoefficients::m_kz_sign
private

Definition at line 67 of file MatrixRTCoefficients.h.

Referenced by computeDeltaMatrix(), getKz(), and pMatrixHelper().

◆ m_lambda

Eigen::Vector2cd MatrixRTCoefficients::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.h.

Referenced by computeDeltaMatrix(), computeInverseP(), SpecularMagneticNCStrategy::computeRoughnessMatrices(), SpecularMagneticTanhStrategy::computeRoughnessMatrix(), getKz(), and pMatrixHelper().

◆ m_magnetic_SLD

double MatrixRTCoefficients::m_magnetic_SLD
private

Definition at line 70 of file MatrixRTCoefficients.h.

Referenced by magneticSLD().

◆ m_R

Eigen::Matrix2cd MatrixRTCoefficients::m_R
private

◆ m_T

Eigen::Matrix2cd MatrixRTCoefficients::m_T
private

Definition at line 72 of file MatrixRTCoefficients.h.

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


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