BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
FootprintSquare.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Beam/FootprintSquare.cpp
6 //! @brief Implements class FootprintSquare.
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 <algorithm>
18 #include <cmath>
19 #include <stdexcept>
20 
21 FootprintSquare::FootprintSquare(const std::vector<double> P)
22  : IFootprintFactor(P)
23 {
24  checkNodeArgs();
25 }
26 
28  : FootprintSquare(std::vector<double>{width_ratio})
29 {
30 }
31 
33 {
34  return new FootprintSquare(m_width_ratio);
35 }
36 
37 double FootprintSquare::calculate(double alpha) const
38 {
39  if (alpha < 0.0 || alpha > M_PI_2)
40  return 0.0;
41  if (widthRatio() == 0.0)
42  return 1.0;
43  const double arg = std::sin(alpha) / widthRatio();
44  return std::min(arg, 1.0);
45 }
46 
47 static_assert(!std::is_copy_constructible<FootprintSquare>::value,
48  "FootprintSquare should not be copy constructable");
49 static_assert(!std::is_copy_assignable<FootprintSquare>::value,
50  "FootprintSquare should not be copy assignable");
Defines M_PI and some more mathematical constants.
#define M_PI_2
Definition: Constants.h:45
Defines class FootprintSquare.
Rectangular beam footprint.
FootprintSquare(std::vector< double > P)
FootprintSquare * clone() const override
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
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27