BornAgain  1.18.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 scattering at grazing incidence
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 
20 
21 FormFactorFullSphere::FormFactorFullSphere(const std::vector<double> P, bool position_at_center)
22  : IFormFactorBorn({"FullSphere", "sphere", {{"Radius", "nm", "radius", 0, +INF, 0}}}, P),
23  m_radius(m_P[0]), m_position_at_center(position_at_center)
24 {
25  onChange();
26 }
27 
28 FormFactorFullSphere::FormFactorFullSphere(double radius, bool position_at_center)
29  : FormFactorFullSphere(std::vector<double>{radius}, position_at_center)
30 {
31 }
32 
33 double FormFactorFullSphere::bottomZ(const IRotation& rotation) const
34 {
36  return -m_radius;
37  kvector_t centre(0.0, 0.0, m_radius);
38  kvector_t new_centre = rotation.transformed(centre);
39  return new_centre.z() - m_radius;
40 }
41 
42 double FormFactorFullSphere::topZ(const IRotation& rotation) const
43 {
45  return m_radius;
46  kvector_t centre(0.0, 0.0, m_radius);
47  kvector_t new_centre = rotation.transformed(centre);
48  return new_centre.z() + m_radius;
49 }
50 
52 {
55  ret *= exp_I(q.z() * m_radius);
56  return ret;
57 }
58 
60  kvector_t translation) const
61 {
62  kvector_t center(0.0, 0.0, m_radius);
63  kvector_t rotation_offset =
64  m_position_at_center ? kvector_t(0.0, 0.0, 0.0) : rot.transformed(center) - center;
65  kvector_t new_translation = translation + rotation_offset;
66  std::unique_ptr<IRotation> P_identity(IRotation::createIdentity());
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, *P_identity, 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 class FormFactorFullSphere.
Defines class FormFactorTruncatedSphere.
IFormFactor * createTransformedFormFactor(const IFormFactor &formfactor, const IRotation &rot, kvector_t translation)
Definition: IFormFactor.cpp:77
const double INF
Definition: INode.h:24
Defines M_PI and some more mathematical constants.
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:68
double bottomZ(const IRotation &rotation) const override 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 override final
Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
IFormFactor * sliceFormFactor(ZLimits limits, const IRotation &rot, kvector_t translation) const override final
Actually slices the form factor or throws an exception.
void onChange() override final
Action to be taken in inherited class when a parameter has changed.
double topZ(const IRotation &rotation) const override 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)
Pure virtual base class for Born form factors.
SlicingEffects computeSlicingEffects(ZLimits limits, const kvector_t &position, double height) const
Helper method for slicing.
Pure virtual base class for all form factors.
Definition: IFormFactor.h:40
Pure virtual interface for rotations.
Definition: Rotations.h:27
static IRotation * createIdentity()
Definition: Rotations.cpp:53
kvector_t transformed(const kvector_t &v) const
Definition: Rotations.cpp:58
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:41
const double radius(5 *Units::nanometer)
complex_t ffSphere(cvector_t q, double R)
Returns the form factor of a sphere of radius R.