BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Cylinder.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/Cylinder.cpp
6 //! @brief Implements class Cylinder.
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 Cylinder::Cylinder(const std::vector<double> P)
22  : IFormFactor(P)
23  , m_radius(m_P[0])
24  , m_height(m_P[1])
25 {
26  checkNodeArgs();
27  // TODO improve!
28  m_shape3D = std::make_unique<DoubleEllipseZ>(m_radius, m_radius, m_height, m_radius, m_radius);
29 }
30 
31 Cylinder::Cylinder(double radius, double height)
32  : Cylinder(std::vector<double>{radius, height})
33 {
34 }
35 
36 complex_t Cylinder::formfactor_at_bottom(C3 q) const
37 {
38  const double R = m_radius;
39  const double H = m_height;
40 
41  const complex_t qH2 = q.z() * H / 2.;
42  const complex_t qR = std::sqrt(q.x() * q.x() + q.y() * q.y()) * R;
43 
44  const complex_t axial_part = H * Math::sinc(qH2);
45  const complex_t radial_part = M_TWOPI * R * R * Math::Bessel::J1c(qR);
46 
47  return radial_part * axial_part * exp_I(qH2);
48 }
Defines Bessel functions in namespace Math.
Defines M_PI and some more mathematical constants.
#define M_TWOPI
Definition: Constants.h:54
Defines class Cylinder.
Defines class DoubleEllipse.
Defines namespace Math.
A circular cylinder.
Definition: Cylinder.h:23
const double & m_height
Definition: Cylinder.h:47
Cylinder(double radius, double height)
Definition: Cylinder.cpp:31
complex_t formfactor_at_bottom(C3 q) const override
Definition: Cylinder.cpp:36
double radius() const
Definition: Cylinder.h:39
double height() const
Definition: Cylinder.h:38
const double & m_radius
Definition: Cylinder.h:46
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
constexpr Double_t H()
Definition: TMath.h:140
constexpr Double_t R()
Definition: TMath.h:213