BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
SampleUtils::someff Namespace Reference

Description

Some form factor functions.

Functions

complex_t ffSphere (C3 q, double R)
 Returns the form factor of a sphere of radius R. More...
 

Function Documentation

◆ ffSphere()

complex_t SampleUtils::someff::ffSphere ( C3  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 }
#define M_PI
Definition: Constants.h:44
constexpr Double_t R()
Definition: TMath.h:213

References M_PI, and TMath::R().

Referenced by Sphere::formfactor_at_bottom(), and FuzzySphere::formfactor_at_bottom().

Here is the call graph for this function: