BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorDWBA.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Scattering/FormFactorDWBA.cpp
6 //! @brief Implements class FormFactorDWBA.
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 
18 
19 FormFactorDWBA::FormFactorDWBA(const IFormFactor& form_factor) : mP_form_factor(form_factor.clone())
20 {
21  setName("FormFactorDWBA");
22 }
23 
25 
27 {
29  std::unique_ptr<const ILayerRTCoefficients> p_in_coefs =
30  mp_in_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_in_coeffs->clone()) : nullptr;
31  std::unique_ptr<const ILayerRTCoefficients> p_out_coefs =
32  mp_out_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_out_coeffs->clone())
33  : nullptr;
34  result->setSpecularInfo(std::move(p_in_coefs), std::move(p_out_coefs));
35  return result;
36 }
37 
39 {
40  // Retrieve the two different incoming wavevectors in the layer
41  cvector_t k_i_T = wavevectors.getKi();
42  k_i_T.setZ(-mp_in_coeffs->getScalarKz());
43  cvector_t k_i_R = k_i_T;
44  k_i_R.setZ(-k_i_T.z());
45 
46  // Retrieve the two different outgoing wavevector bins in the layer
47  cvector_t k_f_T = wavevectors.getKf();
48  k_f_T.setZ(mp_out_coeffs->getScalarKz());
49  cvector_t k_f_R = k_f_T;
50  k_f_R.setZ(-k_f_T.z());
51 
52  // Construct the four different scattering contributions wavevector infos
53  double wavelength = wavevectors.getWavelength();
54  WavevectorInfo k_TT(k_i_T, k_f_T, wavelength);
55  WavevectorInfo k_RT(k_i_R, k_f_T, wavelength);
56  WavevectorInfo k_TR(k_i_T, k_f_R, wavelength);
57  WavevectorInfo k_RR(k_i_R, k_f_R, wavelength);
58 
59  // Get the four R,T coefficients
60  complex_t T_in = mp_in_coeffs->getScalarT();
61  complex_t R_in = mp_in_coeffs->getScalarR();
62  complex_t T_out = mp_out_coeffs->getScalarT();
63  complex_t R_out = mp_out_coeffs->getScalarR();
64 
65  // The four different scattering contributions; S stands for scattering
66  // off the particle, R for reflection off the layer interface
67  complex_t term_S = T_in * mP_form_factor->evaluate(k_TT) * T_out;
68  complex_t term_RS = R_in * mP_form_factor->evaluate(k_RT) * T_out;
69  complex_t term_SR = T_in * mP_form_factor->evaluate(k_TR) * R_out;
70  complex_t term_RSR = R_in * mP_form_factor->evaluate(k_RR) * R_out;
71 
72  return term_S + term_RS + term_SR + term_RSR;
73 }
74 
75 double FormFactorDWBA::bottomZ(const IRotation& rotation) const
76 {
77  return mP_form_factor->bottomZ(rotation);
78 }
79 
80 double FormFactorDWBA::topZ(const IRotation& rotation) const
81 {
82  return mP_form_factor->topZ(rotation);
83 }
84 
85 void FormFactorDWBA::setSpecularInfo(std::unique_ptr<const ILayerRTCoefficients> p_in_coeffs,
86  std::unique_ptr<const ILayerRTCoefficients> p_out_coeffs)
87 {
88  mp_in_coeffs = std::move(p_in_coeffs);
89  mp_out_coeffs = std::move(p_out_coeffs);
90 }
std::complex< double > complex_t
Definition: Complex.h:20
Defines class FormFactorDWBA.
Defines and implements class ILayerRTCoefficients.
Defines WavevectorInfo.
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
void setZ(const T &a)
Sets z-component in cartesian coordinate system.
Definition: BasicVector3D.h:75
Evaluates the coherent sum of the four DWBA terms in a scalar IFormFactor.
std::unique_ptr< IFormFactor > mP_form_factor
The form factor for BA.
complex_t evaluate(const WavevectorInfo &wavevectors) const override
Calculates and returns a form factor calculation in DWBA.
FormFactorDWBA * clone() const override
Returns a clone of this ISample object.
double topZ(const IRotation &rotation) const override
Returns the z-coordinate of the lowest point in this shape after a given rotation.
~FormFactorDWBA() override
void setSpecularInfo(std::unique_ptr< const ILayerRTCoefficients > p_in_coeffs, std::unique_ptr< const ILayerRTCoefficients > p_out_coeffs) override
Sets reflection/transmission info.
double bottomZ(const IRotation &rotation) const override
Returns the z-coordinate of the lowest point in this shape after a given rotation.
FormFactorDWBA(const IFormFactor &form_factor)
std::unique_ptr< const ILayerRTCoefficients > mp_out_coeffs
std::unique_ptr< const ILayerRTCoefficients > mp_in_coeffs
Pure virtual base class for all form factors.
Definition: IFormFactor.h:40
void setName(const std::string &name)
Pure virtual interface for rotations.
Definition: Rotations.h:27
Holds all wavevector information relevant for calculating form factors.
cvector_t getKf() const
cvector_t getKi() const
double getWavelength() const