BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
someff Namespace Reference

Functions

complex_t ffSphere (cvector_t q, double R)
 

Detailed Description

Some form factor functions.

Function Documentation

◆ ffSphere()

complex_t someff::ffSphere ( cvector_t  q,
double  R 
)

Returns the form factor of a sphere of radius R.

Used by the hard sphere and by several soft sphere classes.

Definition at line 21 of file SomeFormFactors.cpp.

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
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

References M_PI, BasicVector3D< T >::x(), BasicVector3D< T >::y(), and BasicVector3D< T >::z().

Referenced by FormFactorFullSphere::evaluate_for_q(), FormFactorSphereGaussianRadius::evaluate_for_q(), and FormFactorSphereLogNormalRadius::evaluate_for_q().

Here is the call graph for this function: