BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SomeFormFactors.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/LibFF/SomeFormFactors.cpp
6 //! @brief Implements namespace someff with some form factor functions.
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 
17 //! Returns the form factor of a sphere of radius R.
18 //!
19 //! Used by the hard sphere and by several soft sphere classes.
20 
22 {
23  complex_t q1 =
24  sqrt(q.x() * q.x() + q.y() * q.y() + q.z() * q.z()); // NO sesquilinear dot product!
25  complex_t qR = q1 * R;
26 
27  if (std::abs(qR) < 1e-4) { // relative error is O(qR^4) with small prefactor
28  // expand sin(qR)-qR*cos(qR) up to qR^5
29  return 4 * M_PI / 3 * pow(R, 3) * (1. - 0.1 * pow(qR, 2));
30  }
31  return 4 * M_PI * pow(q1, -3) * (sin(qR) - qR * cos(qR));
32 }
std::complex< double > complex_t
Definition: Complex.h:20
#define M_PI
Definition: MathConstants.h:39
Declares namespace someff with some form factor functions.
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
complex_t ffSphere(cvector_t q, double R)
Returns the form factor of a sphere of radius R.