BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ripples Namespace Reference

Computations for elongated particles. More...

Functions

complex_t factor_x_box (complex_t q, double l)
 
complex_t factor_x_Gauss (complex_t q, double l)
 
complex_t factor_x_Lorentz (complex_t q, double l)
 
complex_t profile_yz_bar (complex_t qy, complex_t qz, double width, double height)
 Complex form factor of rectangular ripple (bar). More...
 
complex_t profile_yz_cosine (complex_t qy, complex_t qz, double width, double height)
 Complex form factor of cosine ripple. More...
 
complex_t profile_yz_triangular (complex_t qy, complex_t qz, double width, double height, double asymmetry)
 Complex form factor of triangular ripple. More...
 

Detailed Description

Computations for elongated particles.

Function Documentation

◆ factor_x_box()

complex_t ripples::factor_x_box ( complex_t  q,
double  l 
)

Definition at line 20 of file Ripples.cpp.

21 {
22  return r * Math::sinc(q * r / 2.0);
23 }
double sinc(double x)
sinc function:
Definition: Functions.cpp:53

References Math::sinc().

Referenced by FormFactorCosineRippleBox::factor_x(), and FormFactorSawtoothRippleBox::factor_x().

Here is the call graph for this function:

◆ factor_x_Gauss()

complex_t ripples::factor_x_Gauss ( complex_t  q,
double  l 
)

Definition at line 25 of file Ripples.cpp.

26 {
27  return r * exp(-q * r / 8.0);
28 }

Referenced by FormFactorBarGauss::factor_x(), FormFactorCosineRippleGauss::factor_x(), and FormFactorSawtoothRippleGauss::factor_x().

◆ factor_x_Lorentz()

complex_t ripples::factor_x_Lorentz ( complex_t  q,
double  l 
)

Definition at line 30 of file Ripples.cpp.

31 {
32  return r / (1.0 + (q * r) * (q * r));
33 }

Referenced by FormFactorBarLorentz::factor_x(), FormFactorCosineRippleLorentz::factor_x(), and FormFactorSawtoothRippleLorentz::factor_x().

◆ profile_yz_bar()

complex_t ripples::profile_yz_bar ( complex_t  qy,
complex_t  qz,
double  width,
double  height 
)

Complex form factor of rectangular ripple (bar).

Definition at line 36 of file Ripples.cpp.

37 {
38  const complex_t qyWdiv2 = width * qy / 2.0;
39  const complex_t qzHdiv2 = height * qz / 2.0;
40 
41  return height * width * exp_I(qzHdiv2) * Math::sinc(qyWdiv2) * Math::sinc(qzHdiv2);
42 }
std::complex< double > complex_t
Definition: Complex.h:20
complex_t exp_I(complex_t z)
Returns exp(I*z), where I is the imaginary unit.
Definition: Complex.h:30

References exp_I(), and Math::sinc().

Referenced by IProfileRectangularRipple::factor_yz().

Here is the call graph for this function:

◆ profile_yz_cosine()

complex_t ripples::profile_yz_cosine ( complex_t  qy,
complex_t  qz,
double  width,
double  height 
)

Complex form factor of cosine ripple.

Definition at line 45 of file Ripples.cpp.

46 {
47  complex_t factor = width / M_PI;
48 
49  // analytical expressions for some particular cases
50  if (qz == 0.) {
51  if (qy == 0.)
52  return factor * M_PI_2 * height;
53  complex_t aaa = qy * width / (M_TWOPI);
54  complex_t aaa2 = aaa * aaa;
55  if (aaa2 == 1.)
56  return factor * M_PI_4 * height;
57  return factor * M_PI_2 * height * Math::sinc(qy * width * 0.5) / (1.0 - aaa2);
58  }
59 
60  // numerical integration otherwise
61  const complex_t ay = qy * width / M_TWOPI;
62  const complex_t az = qz * (height / 2);
63 
64  const auto integrand = [&](double u) -> complex_t {
65  return sin(u) * exp_I(az * std::cos(u)) * (ay == 0. ? u : sin(ay * u) / ay);
66  };
67  complex_t integral = ComplexIntegrator().integrate(integrand, 0, M_PI);
68  return factor * integral * exp_I(az) * (height / 2);
69 }
#define M_TWOPI
Definition: Constants.h:54
#define M_PI_2
Definition: Constants.h:45
#define M_PI
Definition: Constants.h:44
#define M_PI_4
Definition: Constants.h:46
To integrate a complex function of a real variable.
Definition: IntegratorGK.h:44
complex_t integrate(const std::function< complex_t(double)> &f, double lmin, double lmax)

References exp_I(), ComplexIntegrator::integrate(), M_PI, M_PI_2, M_PI_4, M_TWOPI, and Math::sinc().

Referenced by ICosineRipple::factor_yz().

Here is the call graph for this function:

◆ profile_yz_triangular()

complex_t ripples::profile_yz_triangular ( complex_t  qy,
complex_t  qz,
double  width,
double  height,
double  asymmetry 
)

Complex form factor of triangular ripple.

Definition at line 72 of file Ripples.cpp.

74 {
75  complex_t result;
76  const complex_t factor = height * width;
77  const complex_t qyW2 = qy * width * 0.5;
78  const complex_t qyd = qy * asymmetry;
79  const complex_t qzH = qz * height;
80  const complex_t a = qzH + qyd;
81  // dimensionless scale factors
82  const double a_scale = std::abs(a);
83  const double w_scale = std::abs(qyW2);
84 
85  if (w_scale < 1.e-5) { // |q_y*W| << 1
86  if (a_scale < 1e-5) { // |q_y*W| << 1 && |q_z*H + q_y*d| << 1
87  // relative error is O((q_y*W)^2) and O((q_z*H + q_y*d)^2)
88  result = exp_I(-qyd) * (0.5 + mul_I(a) / 6.);
89  } else {
90  // relative error is O((q_y*W)^2)
91  result = exp_I(-qyd) * (1.0 + mul_I(a) - exp_I(a)) / (a * a);
92  }
93  } else {
94  const complex_t gamma_p = (a + qyW2) * 0.5;
95  const complex_t gamma_m = (a - qyW2) * 0.5;
96  result = exp_I(gamma_m) * Math::sinc(gamma_p) - exp_I(gamma_p) * Math::sinc(gamma_m);
97  result = mul_I(exp_I(-qyd) * result / (qyW2 * 2.));
98  }
99  return factor * result;
100 }
complex_t mul_I(complex_t z)
Returns product I*z, where I is the imaginary unit.
Definition: Complex.h:24

References exp_I(), mul_I(), and Math::sinc().

Referenced by ISawtoothRipple::factor_yz().

Here is the call graph for this function: