BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SpecularScalarStrategy.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Specular/SpecularScalarStrategy.h
6 //! @brief Defines class SpecularScalarStrategy.
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_SPECULAR_SPECULARSCALARSTRATEGY_H
21 #define BORNAGAIN_SAMPLE_SPECULAR_SPECULARSCALARSTRATEGY_H
22 
25 #include <memory>
26 #include <vector>
27 
28 class Slice;
29 
30 //! Implements the scalar Fresnel computation
31 //!
32 //! Implements method 'execute' to compute refraction angles and transmission/reflection
33 //! coefficients for coherent wave propagation in a multilayer.
34 //!
35 //! Inherited by SpecularScalarNCStrategy, SpecularScalarTanhStrategy
36 //!
37 //! @ingroup algorithms_internal
39 public:
40  // TODO remove once external test code is not needed anmyore
41  // for the moment i need them!
43  using coefficient_pointer_type = std::unique_ptr<const coefficient_type>;
44  using coeffs_t = std::vector<coefficient_pointer_type>;
45 
46  //! Computes refraction angles and transmission/reflection coefficients
47  //! for given coherent wave propagation in a multilayer.
48  virtual ISpecularStrategy::coeffs_t Execute(const std::vector<Slice>& slices,
49  const kvector_t& k) const override;
50 
51  virtual ISpecularStrategy::coeffs_t Execute(const std::vector<Slice>& slices,
52  const std::vector<complex_t>& kz) const override;
53 
54  //! Computes the Fresnel R coefficient for the top layer only
55  //! Introduced in order to speed up pure reflectivity computations
56  virtual std::variant<complex_t, Eigen::Matrix2cd>
57  computeTopLayerR(const std::vector<Slice>& slices,
58  const std::vector<complex_t>& kz) const override;
59 
60 private:
61  virtual std::pair<complex_t, complex_t> transition(complex_t kzi, complex_t kzi1,
62  double sigma) const = 0;
63 
64  std::vector<ScalarRTCoefficients> computeTR(const std::vector<Slice>& slices,
65  const std::vector<complex_t>& kz) const;
66 
67  static void setZeroBelow(std::vector<ScalarRTCoefficients>& coeff, size_t current_layer);
68 
69  void calculateUpFromLayer(std::vector<ScalarRTCoefficients>& coeff,
70  const std::vector<Slice>& slices,
71  const std::vector<complex_t>& kz) const;
72 };
73 
74 #endif // BORNAGAIN_SAMPLE_SPECULAR_SPECULARSCALARSTRATEGY_H
75 #endif // USER_API
std::complex< double > complex_t
Definition: Complex.h:20
Defines and implements class ISpecularStrategy.
Defines class ScalarRTCoefficients.
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 scalar interactions between t...
Data structure containing the data of a single slice, for calculating the Fresnel coefficients.
Definition: Slice.h:32
Implements the scalar Fresnel computation.
virtual ISpecularStrategy::coeffs_t Execute(const std::vector< Slice > &slices, const kvector_t &k) const override
Computes refraction angles and transmission/reflection coefficients for given coherent wave propagati...
std::vector< ScalarRTCoefficients > computeTR(const std::vector< Slice > &slices, const std::vector< complex_t > &kz) const
std::unique_ptr< const coefficient_type > coefficient_pointer_type
virtual std::pair< complex_t, complex_t > transition(complex_t kzi, complex_t kzi1, double sigma) const =0
virtual std::variant< complex_t, Eigen::Matrix2cd > computeTopLayerR(const std::vector< Slice > &slices, const std::vector< complex_t > &kz) const override
Computes the Fresnel R coefficient for the top layer only Introduced in order to speed up pure reflec...
void calculateUpFromLayer(std::vector< ScalarRTCoefficients > &coeff, const std::vector< Slice > &slices, const std::vector< complex_t > &kz) const
static void setZeroBelow(std::vector< ScalarRTCoefficients > &coeff, size_t current_layer)