BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
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(P)
21 {
22  checkNodeArgs();
23 }
24 
25 FootprintGauss::FootprintGauss(double width_ratio)
26  : FootprintGauss(std::vector<double>{width_ratio})
27 {
28 }
29 
31 {
32  return new FootprintGauss(m_width_ratio);
33 }
34 
35 double FootprintGauss::calculate(double alpha) const
36 {
37  if (alpha < 0.0 || alpha > M_PI_2)
38  return 0.0;
39  if (widthRatio() == 0.0)
40  return 1.0;
41  const double arg = std::sin(alpha) * M_SQRT1_2 / widthRatio();
42  return Math::erf(arg);
43 }
44 
45 static_assert(!std::is_copy_constructible<FootprintGauss>::value,
46  "FootprintGauss should not be copy constructable");
47 static_assert(!std::is_copy_assignable<FootprintGauss>::value,
48  "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 namespace Math.
Gaussian beam footprint.
FootprintGauss * clone() const override
double calculate(double alpha) const override
Calculate footprint correction coefficient from the beam incident angle alpha.
FootprintGauss(std::vector< double > P)
Abstract base for classes that calculate the beam footprint factor.
double widthRatio() const
const double & m_width_ratio
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27
double erf(double arg)
Error function of real-valued argument.
Definition: Functions.cpp:88