BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PolyhedralComponents.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/HardParticle/PolyhedralComponents.h
6 //! @brief Defines classes PolyhedralEdge, PolyhedralFace
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 #ifndef BORNAGAIN_CORE_HARDPARTICLE_POLYHEDRALCOMPONENTS_H
16 #define BORNAGAIN_CORE_HARDPARTICLE_POLYHEDRALCOMPONENTS_H
17 
18 #include "Base/Types/Complex.h"
19 #include "Base/Vector/Vectors3D.h"
20 #include <vector>
21 
22 //! One edge of a polygon, for form factor computation.
23 
25 {
26 public:
27  PolyhedralEdge(const kvector_t _Vlow, const kvector_t _Vhig);
28 
29  kvector_t E() const { return m_E; }
30  kvector_t R() const { return m_R; }
31  complex_t qE(cvector_t q) const { return m_E.dot(q); }
32  complex_t qR(cvector_t q) const { return m_R.dot(q); }
33 
34  complex_t contrib(int m, cvector_t qpa, complex_t qrperp) const;
35 
36 private:
37  kvector_t m_E; //!< vector pointing from mid of edge to upper vertex
38  kvector_t m_R; //!< position vector of edge midpoint
39 };
40 
41 //! A polygon, for form factor computation.
42 
44 {
45 public:
46  static double diameter(const std::vector<kvector_t>& V);
47 #ifdef POLYHEDRAL_DIAGNOSTIC
48  static void setLimits(double _qpa, int _n);
49 #endif // BORNAGAIN_CORE_HARDPARTICLE_POLYHEDRALCOMPONENTS_H
50 
51  PolyhedralFace(const std::vector<kvector_t>& _V = std::vector<kvector_t>(),
52  bool _sym_S2 = false);
53 
54  double area() const { return m_area; }
55  double pyramidalVolume() const { return m_rperp * m_area / 3; }
56  double radius3d() const { return m_radius_3d; }
57  //! Returns conj(q)*normal [BasicVector3D::dot is antilinear in 'this' argument]
59  complex_t ff_n(int m, cvector_t q) const;
60  complex_t ff(cvector_t q, bool sym_Ci) const;
61  complex_t ff_2D(cvector_t qpa) const;
62  void assert_Ci(const PolyhedralFace& other) const;
63 
64 private:
65  static double qpa_limit_series; //!< determines when use power series
66  static int n_limit_series;
67 
68  bool sym_S2; //!< if true, then edges obtainable by inversion are not provided
69  std::vector<PolyhedralEdge> edges;
70  double m_area;
71  kvector_t m_normal; //!< normal vector of this polygon's plane
72  double m_rperp; //!< distance of this polygon's plane from the origin, along 'm_normal'
73  double m_radius_2d; //!< radius of enclosing cylinder
74  double m_radius_3d; //!< radius of enclosing sphere
75 
76  void decompose_q(cvector_t q, complex_t& qperp, cvector_t& qpa) const;
77  complex_t ff_n_core(int m, cvector_t qpa, complex_t qperp) const;
78  complex_t edge_sum_ff(cvector_t q, cvector_t qpa, bool sym_Ci) const;
79  complex_t expansion(complex_t fac_even, complex_t fac_odd, cvector_t qpa,
80  double abslevel) const;
81 };
82 
83 #endif // BORNAGAIN_CORE_HARDPARTICLE_POLYHEDRALCOMPONENTS_H
Defines complex_t, and a few elementary functions.
std::complex< double > complex_t
Definition: Complex.h:20
Defines basic vectors in R^3 and C^3.
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
One edge of a polygon, for form factor computation.
PolyhedralEdge(const kvector_t _Vlow, const kvector_t _Vhig)
kvector_t E() const
kvector_t m_R
position vector of edge midpoint
kvector_t R() const
complex_t qE(cvector_t q) const
complex_t qR(cvector_t q) const
complex_t contrib(int m, cvector_t qpa, complex_t qrperp) const
Returns sum_l=0^M/2 u^2l v^(M-2l) / (2l+1)!(M-2l)! - vperp^M/M!
kvector_t m_E
vector pointing from mid of edge to upper vertex
A polygon, for form factor computation.
complex_t ff_n(int m, cvector_t q) const
Returns contribution qn*f_n [of order q^(n+1)] from this face to the polyhedral form factor.
complex_t normalProjectionConj(cvector_t q) const
Returns conj(q)*normal [BasicVector3D::dot is antilinear in 'this' argument].
bool sym_S2
if true, then edges obtainable by inversion are not provided
complex_t ff_n_core(int m, cvector_t qpa, complex_t qperp) const
Returns core contribution to f_n.
static int n_limit_series
static double qpa_limit_series
determines when use power series
double radius3d() const
double m_radius_2d
radius of enclosing cylinder
double m_rperp
distance of this polygon's plane from the origin, along 'm_normal'
static double diameter(const std::vector< kvector_t > &V)
Static method, returns diameter of circle that contains all vertices.
double pyramidalVolume() const
complex_t ff_2D(cvector_t qpa) const
Returns the two-dimensional form factor of this face, for use in a prism.
complex_t expansion(complex_t fac_even, complex_t fac_odd, cvector_t qpa, double abslevel) const
Returns sum of n>=1 terms of qpa expansion of 2d form factor.
PolyhedralFace(const std::vector< kvector_t > &_V=std::vector< kvector_t >(), bool _sym_S2=false)
Sets internal variables for given vertex chain.
std::vector< PolyhedralEdge > edges
void decompose_q(cvector_t q, complex_t &qperp, cvector_t &qpa) const
Sets qperp and qpa according to argument q and to this polygon's normal.
double area() const
kvector_t m_normal
normal vector of this polygon's plane
void assert_Ci(const PolyhedralFace &other) const
Throws if deviation from inversion symmetry is detected. Does not check vertices.
complex_t edge_sum_ff(cvector_t q, cvector_t qpa, bool sym_Ci) const
Returns core contribution to analytic 2d form factor.
complex_t ff(cvector_t q, bool sym_Ci) const
Returns the contribution ff(q) of this face to the polyhedral form factor.
double m_radius_3d
radius of enclosing sphere