BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FootprintGauss.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Beam/FootprintGauss.cpp
6 //! @brief Implements class FootprintGauss.
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 
16 #include "Base/Math/Constants.h"
17 #include "Base/Math/Functions.h"
18 
19 FootprintGauss::FootprintGauss(const std::vector<double> P)
20  : IFootprintFactor({"FootprintGauss", "class_tooltip", {}}, P)
21 {
22 }
23 
24 FootprintGauss::FootprintGauss(double width_ratio)
25  : FootprintGauss(std::vector<double>{width_ratio})
26 {
27 }
28 
30 {
31  return new FootprintGauss(m_width_ratio);
32 }
33 
34 double FootprintGauss::calculate(double alpha) const
35 {
36  if (alpha < 0.0 || alpha > M_PI_2)
37  return 0.0;
38  if (widthRatio() == 0.0)
39  return 1.0;
40  const double arg = std::sin(alpha) * M_SQRT1_2 / widthRatio();
41  return Math::erf(arg);
42 }
43 
44 static_assert(!std::is_copy_constructible<FootprintGauss>::value,
45  "FootprintGauss should not be copy constructable");
46 static_assert(!std::is_copy_assignable<FootprintGauss>::value,
47  "FootprintGauss should not be copy assignable");
Defines M_PI and some more mathematical constants.
#define M_PI_2
Definition: Constants.h:45
#define M_SQRT1_2
Definition: Constants.h:51
Defines class FootprintGauss.
Defines functions in namespace Math.
Gaussian beam footprint.
FootprintGauss * clone() const override
FootprintGauss(const std::vector< double > P)
double calculate(double alpha) const override
Calculate footprint correction coefficient from the beam incident angle alpha.
Abstract base for classes that calculate the beam footprint factor.
double widthRatio() const
const double & m_width_ratio
double erf(double arg)
Error function of real-valued argument.
Definition: Functions.cpp:87
Definition: filesystem.h:81