BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
IFormFactorPolyhedron.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/IFormFactorPolyhedron.cpp
6 //! @brief Implements interface IFormFactorPolyhedron.
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 
15 //! The mathematics implemented here is described in full detail in a paper
16 //! by Joachim Wuttke, entitled
17 //! "Form factor (Fourier shape transform) of polygon and polyhedron."
18 
21 #include <ff/PolyhedralComponents.h>
22 #include <ff/Polyhedron.h>
23 
24 // #ifdef ALGORITHM_DIAGNOSTIC // TODO restore
25 // void IFormFactorPolyhedron::setLimits(double _q, int _n)
26 // {
27 // q_limit_series = _q;
28 // n_limit_series = _n;
29 // }
30 // #endif
31 
32 IFormFactorPolyhedron::IFormFactorPolyhedron(const std::vector<double>& PValues)
33  : IFormFactor(PValues)
34 {
35 }
36 
38 
39 //! Called by child classes to set faces and other internal variables.
40 
41 void IFormFactorPolyhedron::setPolyhedron(const ff::PolyhedralTopology& topology, double z_bottom,
42  const std::vector<R3>& vertices)
43 {
44  m_z_bottom = z_bottom;
45 
46  m_vertices.clear();
47  for (const R3& vertex : vertices)
48  m_vertices.push_back(vertex - R3{0, 0, z_bottom});
49 
50  pimpl = std::make_unique<ff::Polyhedron>(topology, vertices);
51 }
52 
53 double IFormFactorPolyhedron::bottomZ(const IRotation* rotation) const
54 {
55  return PolyhedralUtil::BottomZ(m_vertices, rotation);
56 }
57 
58 double IFormFactorPolyhedron::topZ(const IRotation* rotation) const
59 {
60  return PolyhedralUtil::TopZ(m_vertices, rotation);
61 }
62 
64 {
65  return exp_I(-m_z_bottom * q.z()) * pimpl->formfactor(q);
66 }
67 
69 {
70  return pimpl->volume();
71 }
73 {
74  return pimpl->radius();
75 }
76 
77 //! Assertions for Platonic solid.
78 
80 {
81  pimpl->assert_platonic();
82 }
Defines interface IFormFactorPolyhedron.
Defines interface IDecoratableBorn.
double bottomZ(const IRotation *rotation) const override
std::unique_ptr< ff::Polyhedron > pimpl
double m_z_bottom
for topZ, bottomZ computation only
void assert_platonic() const
Assertions for Platonic solid.
complex_t formfactor_at_bottom(C3 q) const override
void setPolyhedron(const ff::PolyhedralTopology &topology, double z_bottom, const std::vector< R3 > &vertices)
Called by child classes to set faces and other internal variables.
double volume() const override
std::vector< R3 > m_vertices
IFormFactorPolyhedron(const std::vector< double > &PValues)
The mathematics implemented here is described in full detail in a paper by Joachim Wuttke,...
~IFormFactorPolyhedron() override
double topZ(const IRotation *rotation) const override
double radialExtension() const override
Returns the (approximate in some cases) radial size of the particle of this form factor's shape....
Abstract base class for Born form factors.
Definition: IFormFactor.h:36
Abstract base class for rotations.
Definition: Rotations.h:29
double BottomZ(const std::vector< R3 > &vertices, const IRotation *rotation)
Calculates the z-coordinate of the lowest vertex after rotation.
double TopZ(const std::vector< R3 > &vertices, const IRotation *rotation)
Calculates the z-coordinate of the highest vertex after rotation.