BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Sphere.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/Sphere.cpp
6 //! @brief Implements class Sphere.
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/Constants.h"
20 
21 Sphere::Sphere(const std::vector<double> P, bool position_at_center)
22  : IFormFactor(P)
23  , m_radius(m_P[0])
24  , m_position_at_center(position_at_center)
25 {
26  checkNodeArgs();
27 }
28 
29 Sphere::Sphere(double radius, bool position_at_center)
30  : Sphere(std::vector<double>{radius}, position_at_center)
31 {
32 }
33 
34 double Sphere::bottomZ(const IRotation* rotation) const
35 {
37  return -m_radius;
38  if (!rotation)
39  return 0;
40  R3 centre(0.0, 0.0, m_radius);
41  R3 new_centre = rotation->transformed(centre);
42  return new_centre.z() - m_radius;
43 }
44 
45 double Sphere::topZ(const IRotation* rotation) const
46 {
48  return m_radius;
49  if (!rotation)
50  return 2 * m_radius;
51  R3 centre(0.0, 0.0, m_radius);
52  R3 new_centre = rotation->transformed(centre);
53  return new_centre.z() + m_radius;
54 }
55 
56 complex_t Sphere::formfactor_at_bottom(C3 q) const
57 {
58  complex_t result = SampleUtils::someff::ffSphere(q, m_radius);
60  result *= exp_I(q.z() * m_radius);
61  return result;
62 }
Defines M_PI and some more mathematical constants.
Defines IRotation classes.
Declares namespace someff with some form factor functions.
Defines class Sphere.
Defines class TruncatedSphere.
Abstract base class for Born form factors.
Definition: IFormFactor.h:36
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27
Abstract base class for rotations.
Definition: Rotations.h:29
R3 transformed(const R3 &v) const
Definition: Rotations.cpp:42
A full sphere.
Definition: Sphere.h:23
const double & m_radius
Definition: Sphere.h:48
double topZ(const IRotation *rotation) const override
Definition: Sphere.cpp:45
double radius() const
Definition: Sphere.h:34
bool m_position_at_center
Definition: Sphere.h:49
Sphere(double radius, bool position_at_center=false)
Definition: Sphere.cpp:29
double bottomZ(const IRotation *rotation) const override
Definition: Sphere.cpp:34
complex_t formfactor_at_bottom(C3 q) const override
Definition: Sphere.cpp:56
complex_t ffSphere(C3 q, double R)
Returns the form factor of a sphere of radius R.