BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
EllipsoidalCylinder.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/EllipsoidalCylinder.cpp
6 //! @brief Implements class EllipsoidalCylinder.
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/Bessel.h"
17 #include "Base/Math/Constants.h"
18 #include "Base/Math/Functions.h"
20 
21 EllipsoidalCylinder::EllipsoidalCylinder(const std::vector<double> P)
22  : IFormFactor(P)
23  , m_radius_x(m_P[0])
24  , m_radius_y(m_P[1])
25  , m_height(m_P[2])
26 {
27  checkNodeArgs();
28  m_shape3D =
29  std::make_unique<DoubleEllipseZ>(m_radius_x, m_radius_y, m_height, m_radius_x, m_radius_y);
30 }
31 
32 EllipsoidalCylinder::EllipsoidalCylinder(double radius_x, double radius_y, double height)
33  : EllipsoidalCylinder(std::vector<double>{radius_x, radius_y, height})
34 {
35 }
36 
38 {
39  return (m_radius_x + m_radius_y) / 2.0;
40 }
41 
43 {
44  complex_t qxRa = q.x() * m_radius_x;
45  complex_t qyRb = q.y() * m_radius_y;
46  complex_t qzHdiv2 = m_height / 2 * q.z();
47 
48  complex_t Fz = exp_I(qzHdiv2) * Math::sinc(qzHdiv2);
49  complex_t gamma = std::sqrt((qxRa) * (qxRa) + (qyRb) * (qyRb));
50  complex_t J1_gamma_div_gamma = Math::Bessel::J1c(gamma);
51 
52  return M_TWOPI * m_radius_x * m_radius_y * m_height * Fz * J1_gamma_div_gamma;
53 }
Defines Bessel functions in namespace Math.
Defines M_PI and some more mathematical constants.
#define M_TWOPI
Definition: Constants.h:54
Defines class DoubleEllipse.
Defines class EllipsoidalCylinder.
Defines namespace Math.
A cylinder with elliptical base.
const double & m_radius_y
double radialExtension() const override
Returns the (approximate in some cases) radial size of the particle of this form factor's shape....
const double & m_radius_x
EllipsoidalCylinder(double radius_x, double radius_y, double height)
complex_t formfactor_at_bottom(C3 q) const override
Abstract base class for Born form factors.
Definition: IFormFactor.h:36
std::unique_ptr< IShape3D > m_shape3D
IShape3D object, used to retrieve vertices (which may be approximate in the case of round shapes)....
Definition: IFormFactor.h:74
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27
double J1c(double x)
Bessel function J1(x)/x.
Definition: Bessel.cpp:172
double sinc(double x)
sinc function:
Definition: Functions.cpp:52
double gamma(double x)