BornAgain  1.18.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 scattering at grazing incidence
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 
18 #include "Base/Utils/PyFmt.h"
19 
20 FootprintGauss::FootprintGauss(const std::vector<double> P)
21  : IFootprintFactor({"FootprintGauss", "class_tooltip", {}}, P)
22 {
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 MathFunctions::erf(arg);
43 }
44 
45 std::string FootprintGauss::print() const
46 {
47  std::stringstream result;
48  result << "\n" << pyfmt::indent() << "# Defining footprint:\n";
49  result << pyfmt::indent() << "footprint = ";
50  result << "ba.FootprintGauss";
51  result << "(" << pyfmt::printDouble(widthRatio()) << ")";
52  return result.str();
53 }
54 
55 static_assert(!std::is_copy_constructible<FootprintGauss>::value,
56  "FootprintGauss should not be copy constructable");
57 static_assert(!std::is_copy_assignable<FootprintGauss>::value,
58  "FootprintGauss should not be copy assignable");
Defines class FootprintGauss.
Defines M_PI and some more mathematical constants.
#define M_PI_2
Definition: MathConstants.h:40
#define M_SQRT1_2
Definition: MathConstants.h:46
Defines namespace MathFunctions.
Defines functions in namespace pyfmt.
Calculates footprint coefficient for a gaussian beam Beam width is interpreted as the full width on t...
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.
std::string print() const override
Print python-formatted footprint definition.
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.
std::string printDouble(double input)
Definition: PyFmt.cpp:43
std::string indent(size_t width)
Returns a string of blanks with given width.
Definition: PyFmt.cpp:141