BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorGauss.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/SoftParticle/FormFactorGauss.cpp
6 //! @brief Implements class FormFactorGaussSphere.
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 
17 #include "Sample/Shapes/Box.h"
18 #include <limits>
19 
21  : IFormFactorBorn({"FormFactorGaussSphere",
22  "class_tooltip",
23  {{"MeanRadius", "nm", "para_tooltip", 0, +INF, 0}}},
24  P),
25  m_mean_radius(m_P[0])
26 {
27  onChange();
28 }
29 
31  : FormFactorGaussSphere(std::vector<double>{mean_radius})
32 {
33 }
34 
36 {
37  const double max_ql = std::sqrt(-4 * M_PI * std::log(std::numeric_limits<double>::min()) / 3);
38 
39  double qzh = q.z().real() * m_mean_radius;
40  if (std::abs(qzh) > max_ql)
41  return 0.0;
42  double qxr = q.x().real() * m_mean_radius;
43  if (std::abs(qxr) > max_ql)
44  return 0.0;
45  double qyr = q.y().real() * m_mean_radius;
46  if (std::abs(qyr) > max_ql)
47  return 0.0;
48 
49  return pow(m_mean_radius, 3) * std::exp(-(qxr * qxr + qyr * qyr + qzh * qzh) / 4.0 / M_PI);
50 }
Defines class Box.
std::complex< double > complex_t
Definition: Complex.h:20
Defines class FormFactorGaussSphere.
const double INF
Definition: INode.h:24
Defines M_PI and some more mathematical constants.
#define M_PI
Definition: MathConstants.h:39
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64
The form factor of a Gaussian sphere.
FormFactorGaussSphere(const std::vector< double > P)
complex_t evaluate_for_q(cvector_t q) const override final
Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
void onChange() override final
Action to be taken in inherited class when a parameter has changed.
const double & m_mean_radius
Pure virtual base class for Born form factors.