BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Gauss.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/SoftParticle/Gauss.cpp
6 //! @brief Implements class GaussSphere.
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 "Sample/Shapes/BoxNet.h"
18 #include <limits>
19 
20 GaussSphere::GaussSphere(const std::vector<double> P)
21  : IFormFactor(P)
22  , m_mean_radius(m_P[0])
23 {
24  checkNodeArgs();
25 }
26 
27 GaussSphere::GaussSphere(double mean_radius)
28  : GaussSphere(std::vector<double>{mean_radius})
29 {
30 }
31 
32 complex_t GaussSphere::formfactor_at_bottom(C3 q) const
33 {
34  const double max_ql = std::sqrt(-4 * M_PI * std::log(std::numeric_limits<double>::min()) / 3);
35 
36  double qzh = q.z().real() * m_mean_radius;
37  if (std::abs(qzh) > max_ql)
38  return 0.0;
39  double qxr = q.x().real() * m_mean_radius;
40  if (std::abs(qxr) > max_ql)
41  return 0.0;
42  double qyr = q.y().real() * m_mean_radius;
43  if (std::abs(qyr) > max_ql)
44  return 0.0;
45 
46  return pow(m_mean_radius, 3) * std::exp(-(qxr * qxr + qyr * qyr + qzh * qzh) / 4.0 / M_PI);
47 }
Defines class BoxNet.
Defines M_PI and some more mathematical constants.
#define M_PI
Definition: Constants.h:44
Defines class GaussSphere.
The form factor of a Gaussian sphere.
Definition: Gauss.h:23
GaussSphere(std::vector< double > P)
Definition: Gauss.cpp:20
const double & m_mean_radius
Definition: Gauss.h:43
complex_t formfactor_at_bottom(C3 q) const override
Definition: Gauss.cpp:32
Abstract base class for Born form factors.
Definition: IFormFactor.h:36
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27