BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ComputeDWBA.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/FFCompute/ComputeDWBA.cpp
6 //! @brief Implements class ComputeDWBA.
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 
19 
21 
22 ComputeDWBA::~ComputeDWBA() = default;
23 
25 {
26  ComputeDWBA* result = new ComputeDWBA(*m_ff);
27  std::unique_ptr<const ILayerRTCoefficients> p_in_coefs =
28  m_in_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(m_in_coeffs->clone()) : nullptr;
29  std::unique_ptr<const ILayerRTCoefficients> p_out_coefs =
30  m_out_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(m_out_coeffs->clone()) : nullptr;
31  result->setSpecularInfo(std::move(p_in_coefs), std::move(p_out_coefs));
32  return result;
33 }
34 
36 {
37  // Retrieve the two different incoming wavevectors in the layer
38  cvector_t k_i_T = wavevectors.getKi();
39  k_i_T.setZ(-m_in_coeffs->getScalarKz());
40  cvector_t k_i_R = k_i_T;
41  k_i_R.setZ(-k_i_T.z());
42 
43  // Retrieve the two different outgoing wavevector bins in the layer
44  cvector_t k_f_T = wavevectors.getKf();
45  k_f_T.setZ(m_out_coeffs->getScalarKz());
46  cvector_t k_f_R = k_f_T;
47  k_f_R.setZ(-k_f_T.z());
48 
49  // Construct the four different scattering contributions wavevector infos
50  double wavelength = wavevectors.wavelength();
51  WavevectorInfo k_TT(k_i_T, k_f_T, wavelength);
52  WavevectorInfo k_RT(k_i_R, k_f_T, wavelength);
53  WavevectorInfo k_TR(k_i_T, k_f_R, wavelength);
54  WavevectorInfo k_RR(k_i_R, k_f_R, wavelength);
55 
56  // Get the four R,T coefficients
57  complex_t T_in = m_in_coeffs->getScalarT();
58  complex_t R_in = m_in_coeffs->getScalarR();
59  complex_t T_out = m_out_coeffs->getScalarT();
60  complex_t R_out = m_out_coeffs->getScalarR();
61 
62  // The four different scattering contributions; S stands for scattering
63  // off the particle, R for reflection off the layer interface
64  complex_t term_S = T_in * m_ff->evaluate(k_TT) * T_out;
65  complex_t term_RS = R_in * m_ff->evaluate(k_RT) * T_out;
66  complex_t term_SR = T_in * m_ff->evaluate(k_TR) * R_out;
67  complex_t term_RSR = R_in * m_ff->evaluate(k_RR) * R_out;
68 
69  return term_S + term_RS + term_SR + term_RSR;
70 }
71 
72 void ComputeDWBA::setSpecularInfo(std::unique_ptr<const ILayerRTCoefficients> p_in_coeffs,
73  std::unique_ptr<const ILayerRTCoefficients> p_out_coeffs)
74 {
75  m_in_coeffs = std::move(p_in_coeffs);
76  m_out_coeffs = std::move(p_out_coeffs);
77 }
std::complex< double > complex_t
Definition: Complex.h:20
Defines class ComputeDWBA.
Defines and implements interface IFormFactor.
Defines and implements class ILayerRTCoefficients.
Defines WavevectorInfo.
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:67
void setZ(const T &a)
Sets z-component in cartesian coordinate system.
Definition: BasicVector3D.h:74
Provides scalar DWBA computation for given IFormFactor.
Definition: ComputeDWBA.h:32
ComputeDWBA * clone() const override
Definition: ComputeDWBA.cpp:24
void setSpecularInfo(std::unique_ptr< const ILayerRTCoefficients > p_in_coeffs, std::unique_ptr< const ILayerRTCoefficients > p_out_coeffs) override
Sets reflection/transmission info.
Definition: ComputeDWBA.cpp:72
std::unique_ptr< const ILayerRTCoefficients > m_out_coeffs
Definition: ComputeDWBA.h:49
complex_t evaluate(const WavevectorInfo &wavevectors) const override
Returns the coherent sum of the four DWBA terms for scalar scattering.
Definition: ComputeDWBA.cpp:35
std::unique_ptr< const ILayerRTCoefficients > m_in_coeffs
Definition: ComputeDWBA.h:48
~ComputeDWBA() override
ComputeDWBA(const IFormFactor &ff)
Definition: ComputeDWBA.cpp:20
Abstract base class for form factor evaluations.
Definition: IComputeFF.h:39
std::unique_ptr< IFormFactor > m_ff
Definition: IComputeFF.h:64
Abstract base class for all form factors.
Definition: IFormFactor.h:36
Holds all wavevector information relevant for calculating form factors.
cvector_t getKf() const
cvector_t getKi() const
double wavelength() const