BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SpecularMagneticStrategy_v2.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/LegacyRT/SpecularMagneticStrategy_v2.h
6 //! @brief Defines class SpecularMagneticStrategy_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 
15 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_SAMPLE_LEGACYRT_SPECULARMAGNETICSTRATEGY_V2_H
21 #define BORNAGAIN_SAMPLE_LEGACYRT_SPECULARMAGNETICSTRATEGY_V2_H
22 
25 #include <memory>
26 #include <vector>
27 
28 class Slice;
29 
30 //! Implements the magnetic Fresnel computation without roughness
31 //!
32 //! Implements the matrix formalism for the calculation of wave amplitudes of
33 //! the coherent wave solution in a multilayer with magnetization.
34 //! For a detailed description see internal document "Polarized Specular Reflectometry"
35 //!
36 //! @ingroup algorithms_internal
38 public:
39  // TODO remove once external test code is not needed anmyore
40  // for the moment i need them!
42  using coefficient_pointer_type = std::unique_ptr<const coefficient_type>;
43  using coeffs_t = std::vector<coefficient_pointer_type>;
44 
45  //! Computes refraction angle reflection/transmission coefficients
46  //! for given sliced multilayer and wavevector k
47  ISpecularStrategy::coeffs_t Execute(const std::vector<Slice>& slices, const kvector_t& k) const;
48 
49  //! Computes refraction angle reflection/transmission coefficients
50  //! for given sliced multilayer and a set of kz projections corresponding to each slice
51  ISpecularStrategy::coeffs_t Execute(const std::vector<Slice>& slices,
52  const std::vector<complex_t>& kz) const;
53 
54  virtual std::variant<complex_t, Eigen::Matrix2cd>
55  computeTopLayerR(const std::vector<Slice>& slices,
56  const std::vector<complex_t>& kz) const override;
57 
58 private:
59  static std::vector<MatrixRTCoefficients_v2> computeTR(const std::vector<Slice>& slices,
60  const std::vector<complex_t>& kzs);
61 
62  //! Computes frobenius matrices for multilayer solution
63  static void calculateTR(MatrixRTCoefficients_v2& coeff);
65 
66  static void setNoTransmission(MatrixRTCoefficients_v2& coeff);
67 
68  //! initializes reflectionless bottom boundary condition.
70 
71  //! Propagates boundary conditions from the bottom to the top of the layer stack.
72  //! Used to compute boundary conditions from the bottom one (with nullified reflection)
73  //! simultaneously propagates amplitudes forward again
74  //! Due to the use of temporary objects this is combined into one function now
75  static void propagateBackwardsForwards(std::vector<MatrixRTCoefficients_v2>& coeff,
76  const std::vector<Slice>& slices);
77 
78  //! finds linear coefficients for normalizing transmitted wave to unity.
79  //! The left column of the returned matrix corresponds to the coefficients for pure spin-up
80  //! wave, while the right column - to the coefficients for the spin-down one.
81  static std::pair<Eigen::Matrix2cd, complex_t>
83 };
84 
85 #endif // BORNAGAIN_SAMPLE_LEGACYRT_SPECULARMAGNETICSTRATEGY_V2_H
86 #endif // USER_API
Defines and implements class ISpecularStrategy.
Defines class MatrixRTCoefficients_v2.
Interface for the Fresnel computations, both in the scalar and magnetic case.
std::vector< std::unique_ptr< const ILayerRTCoefficients > > coeffs_t
Specular reflection and transmission coefficients in a layer in case of magnetic interactions between...
Data structure containing the data of a single slice, for calculating the Fresnel coefficients.
Definition: Slice.h:32
Implements the magnetic Fresnel computation without roughness.
static void propagateBackwardsForwards(std::vector< MatrixRTCoefficients_v2 > &coeff, const std::vector< Slice > &slices)
Propagates boundary conditions from the bottom to the top of the layer stack.
static std::pair< Eigen::Matrix2cd, complex_t > findNormalizationCoefficients(const MatrixRTCoefficients_v2 &coeff)
finds linear coefficients for normalizing transmitted wave to unity.
std::unique_ptr< const coefficient_type > coefficient_pointer_type
std::vector< coefficient_pointer_type > coeffs_t
virtual std::variant< complex_t, Eigen::Matrix2cd > computeTopLayerR(const std::vector< Slice > &slices, const std::vector< complex_t > &kz) const override
ISpecularStrategy::coeffs_t Execute(const std::vector< Slice > &slices, const kvector_t &k) const
Computes refraction angle reflection/transmission coefficients for given sliced multilayer and waveve...
static std::vector< MatrixRTCoefficients_v2 > computeTR(const std::vector< Slice > &slices, const std::vector< complex_t > &kzs)
static void setNoTransmission(MatrixRTCoefficients_v2 &coeff)
static void calculateTR(MatrixRTCoefficients_v2 &coeff)
Computes frobenius matrices for multilayer solution.
static void calculateZeroFieldTR(MatrixRTCoefficients_v2 &coeff)
static void nullifyBottomReflection(MatrixRTCoefficients_v2 &coeff)
initializes reflectionless bottom boundary condition.