BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
DiffuseElement.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Resample/Element/DiffuseElement.h
6 //! @brief Defines class DiffuseElement.
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_RESAMPLE_ELEMENT_DIFFUSEELEMENT_H
21 #define BORNAGAIN_RESAMPLE_ELEMENT_DIFFUSEELEMENT_H
22 
23 #include "Base/Element/IElement.h"
24 #include <heinz/Vectors3D.h>
25 #include <memory>
26 #include <vector>
27 
28 class IFlux;
29 class IPixel;
30 class WavevectorInfo;
31 
32 using Fluxes = std::vector<std::unique_ptr<const IFlux>>;
33 
34 //! Data stucture containing both input and output of a single detector cell.
35 //! @ingroup simulation
36 
37 class DiffuseElement : public IElement {
38 public:
39  DiffuseElement(double wavelength, double alpha_i, double phi_i, std::unique_ptr<IPixel> pixel,
40  const SpinMatrix& beam_polMatrices, const SpinMatrix& analyzer, bool isSpecular_,
41  const Fluxes* fluxes_in = nullptr, const Fluxes* fluxes_out = nullptr);
42  DiffuseElement(const DiffuseElement&) = delete;
45 
46  void setFluxes(const Fluxes* fluxes_in, const Fluxes* fluxes_out);
47  const IFlux* fluxIn(size_t i_layer) const;
48  const IFlux* fluxOut(size_t i_layer) const;
49 
50  //! Returns copy of this DiffuseElement with k_f given by in-pixel coordinate x,y.
51  DiffuseElement pointElement(double x, double y) const;
52 
53  double wavelength() const { return m_wavelength; }
54  double alphaI() const { return m_alpha_i; }
55  double getPhiI() const { return m_phi_i; }
56  double alphaMean() const { return alpha(0.5, 0.5); }
57  double getPhiMean() const { return getPhi(0.5, 0.5); }
60  double intensity() const { return m_intensity; }
61  R3 getKi() const;
62  R3 meanKf() const;
63  R3 meanQ() const;
64  R3 getQ(double x, double y) const;
65 
66  double integrationFactor(double x, double y) const;
67 
68  double solidAngle() const;
69 
70  double alpha(double x, double y) const;
71  double getPhi(double x, double y) const;
72 
74 
75  //! Tells if simulation element corresponds to a specular peak
76  bool isSpecular() const { return m_is_specular; }
77 
78 private:
79  R3 getKf(double x, double y) const;
80 
81  const double m_wavelength; //!< wavelength of beam
82  const double m_alpha_i; //!< incident grazing angle
83  const double m_phi_i; //!< incident angle in xy plane
84  const R3 m_k_i; //!< cached value of k_i
85  const R3 m_mean_kf; //!< cached value of mean_kf
86  std::unique_ptr<IPixel> m_pixel;
87  const bool m_is_specular;
90  double m_intensity; //!< simulated intensity for detector cell
91 };
92 
93 #endif // BORNAGAIN_RESAMPLE_ELEMENT_DIFFUSEELEMENT_H
94 #endif // USER_API
std::vector< std::unique_ptr< const IFlux > > Fluxes
Defines class DiffuseElement.
Data stucture containing both input and output of a single detector cell.
double alphaI() const
double getPhiMean() const
double m_intensity
simulated intensity for detector cell
double alphaMean() const
double getPhiI() const
double solidAngle() const
const Fluxes * m_fluxes_in
const R3 m_k_i
cached value of k_i
const IFlux * fluxIn(size_t i_layer) const
double getPhi(double x, double y) const
bool isSpecular() const
Tells if simulation element corresponds to a specular peak.
const double m_alpha_i
incident grazing angle
double integrationFactor(double x, double y) const
const Fluxes * m_fluxes_out
const IFlux * fluxOut(size_t i_layer) const
DiffuseElement pointElement(double x, double y) const
Returns copy of this DiffuseElement with k_f given by in-pixel coordinate x,y.
double wavelength() const
void addIntensity(double intensity)
DiffuseElement(double wavelength, double alpha_i, double phi_i, std::unique_ptr< IPixel > pixel, const SpinMatrix &beam_polMatrices, const SpinMatrix &analyzer, bool isSpecular_, const Fluxes *fluxes_in=nullptr, const Fluxes *fluxes_out=nullptr)
const double m_wavelength
wavelength of beam
DiffuseElement(const DiffuseElement &)=delete
std::unique_ptr< IPixel > m_pixel
double alpha(double x, double y) const
WavevectorInfo wavevectorInfo() const
R3 getQ(double x, double y) const
Returns scattering vector Q, with Kf determined from in-pixel coordinates x,y. In-pixel coordinates t...
R3 getKi() const
double intensity() const
R3 meanKf() const
const R3 m_mean_kf
cached value of mean_kf
void setFluxes(const Fluxes *fluxes_in, const Fluxes *fluxes_out)
void setIntensity(double intensity)
const bool m_is_specular
R3 getKf(double x, double y) const
Returns outgoing wavevector Kf for in-pixel coordinates x,y. In-pixel coordinates take values from 0 ...
const double m_phi_i
incident angle in xy plane
Interface to access reflection/transmission coefficients. Realized by ScalarFlux and MatrixFlux.
Definition: IFlux.h:30
Interface for a function that maps [0,1]x[0,1] to the kvectors in a pixel. Abstract base class for Sp...
Definition: IPixel.h:29
Holds all wavevector information relevant for calculating form factors.