BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorFullSphere.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/FormFactorFullSphere.cpp
6 //! @brief Implements class FormFactorFullSphere.
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 FormFactorFullSphere::FormFactorFullSphere(const std::vector<double> P, bool position_at_center)
22  : IBornFF({"FullSphere", "sphere", {{"Radius", "nm", "radius", 0, +INF, 0}}}, P)
23  , m_radius(m_P[0])
24  , m_position_at_center(position_at_center)
25 {
26  onChange();
27 }
28 
29 FormFactorFullSphere::FormFactorFullSphere(double radius, bool position_at_center)
30  : FormFactorFullSphere(std::vector<double>{radius}, position_at_center)
31 {
32 }
33 
34 double FormFactorFullSphere::bottomZ(const IRotation& rotation) const
35 {
37  return -m_radius;
38  kvector_t centre(0.0, 0.0, m_radius);
39  kvector_t new_centre = rotation.transformed(centre);
40  return new_centre.z() - m_radius;
41 }
42 
43 double FormFactorFullSphere::topZ(const IRotation& rotation) const
44 {
46  return m_radius;
47  kvector_t centre(0.0, 0.0, m_radius);
48  kvector_t new_centre = rotation.transformed(centre);
49  return new_centre.z() + m_radius;
50 }
51 
53 {
56  ret *= exp_I(q.z() * m_radius);
57  return ret;
58 }
59 
61  kvector_t translation) const
62 {
63  kvector_t center(0.0, 0.0, m_radius);
64  kvector_t rotation_offset =
65  m_position_at_center ? kvector_t(0.0, 0.0, 0.0) : rot.transformed(center) - center;
66  kvector_t new_translation = translation + rotation_offset;
67  double height = 2.0 * m_radius;
68  auto effects = computeSlicingEffects(limits, new_translation, height);
69  FormFactorTruncatedSphere slicedff(m_radius, height - effects.dz_bottom, effects.dz_top);
70  return createTransformedFormFactor(slicedff, IdentityRotation(), effects.position);
71 }
72 
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
Defines M_PI and some more mathematical constants.
Defines class FormFactorFullSphere.
Defines class FormFactorTruncatedSphere.
const double INF
Definition: INode.h:25
Defines IRotation classes.
Declares namespace someff with some form factor functions.
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:67
double bottomZ(const IRotation &rotation) const final
Returns the z-coordinate of the lowest point in this shape after a given rotation.
complex_t evaluate_for_q(cvector_t q) const final
Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
void onChange() final
Action to be taken in inherited class when a parameter has changed.
IFormFactor * sliceFormFactor(ZLimits limits, const IRotation &rot, kvector_t translation) const final
Actually slices the form factor or throws an exception.
double topZ(const IRotation &rotation) const final
Returns the z-coordinate of the lowest point in this shape after a given rotation.
FormFactorFullSphere(const std::vector< double > P, bool position_at_center=false)
Abstract base class for Born form factors.
Definition: IBornFF.h:41
static SlicingEffects computeSlicingEffects(ZLimits limits, const kvector_t &position, double height)
Helper method for slicing.
Definition: IBornFF.cpp:66
Abstract base class for all form factors.
Definition: IFormFactor.h:36
static IFormFactor * createTransformedFormFactor(const IFormFactor &formfactor, const IRotation &rot, kvector_t translation)
Definition: IFormFactor.cpp:99
Abstract base class for rotations.
Definition: Rotations.h:28
kvector_t transformed(const kvector_t &v) const
Definition: Rotations.cpp:53
The identity rotation, which leaves everything in place.
Definition: Rotations.h:57
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:45
complex_t ffSphere(cvector_t q, double R)
Returns the form factor of a sphere of radius R.
Definition: filesystem.h:81