BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PolyhedralEdge Class Reference

One edge of a polygon, for form factor computation. More...

Collaboration diagram for PolyhedralEdge:
[legend]

Public Member Functions

 PolyhedralEdge (const kvector_t _Vlow, const kvector_t _Vhig)
 
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! More...
 
kvector_t E () const
 
complex_t qE (cvector_t q) const
 
complex_t qR (cvector_t q) const
 
kvector_t R () const
 

Private Attributes

kvector_t m_E
 vector pointing from mid of edge to upper vertex More...
 
kvector_t m_R
 position vector of edge midpoint More...
 

Detailed Description

One edge of a polygon, for form factor computation.

Definition at line 42 of file PolyhedralComponents.h.

Constructor & Destructor Documentation

◆ PolyhedralEdge()

PolyhedralEdge::PolyhedralEdge ( const kvector_t  _Vlow,
const kvector_t  _Vhig 
)

Definition at line 54 of file PolyhedralComponents.cpp.

55  : m_E((_Vhig - _Vlow) / 2), m_R((_Vhig + _Vlow) / 2)
56 {
57  if (m_E.mag2() == 0)
58  throw std::invalid_argument("At least one edge has zero length");
59 };
double mag2() const
Returns magnitude squared of the vector.
kvector_t m_R
position vector of edge midpoint
kvector_t m_E
vector pointing from mid of edge to upper vertex

References m_E, and BasicVector3D< T >::mag2().

Here is the call graph for this function:

Member Function Documentation

◆ contrib()

complex_t PolyhedralEdge::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!

Definition at line 63 of file PolyhedralComponents.cpp.

64 {
65  complex_t u = qE(qpa);
66  complex_t v2 = m_R.dot(qpa);
67  complex_t v1 = qrperp;
68  complex_t v = v2 + v1;
69  // std::cout << std::scientific << std::showpos << std::setprecision(16) << "contrib: u=" << u
70  // << " v1=" << v1 << " v2=" << v2 << "\n";
71  if (v == 0.) { // only 2l=M contributes
72  if (M & 1) // M is odd
73  return 0.;
74  else
75  return ReciprocalFactorialArray[M] * (pow(u, M) / (M + 1.) - pow(v1, M));
76  }
77  complex_t ret = 0;
78  // the l=0 term, minus (qperp.R)^M, which cancels under the sum over E*contrib()
79  if (v1 == 0.) {
80  ret = ReciprocalFactorialArray[M] * pow(v2, M);
81  } else if (v2 == 0.) {
82  ; // leave ret=0
83  } else {
84  // binomial expansion
85  for (int mm = 1; mm <= M; ++mm) {
86  complex_t term = ReciprocalFactorialArray[mm] * ReciprocalFactorialArray[M - mm]
87  * pow(v2, mm) * pow(v1, M - mm);
88  ret += term;
89  // std::cout << "contrib mm=" << mm << " t=" << term << " s=" << ret << "\n";
90  }
91  }
92  if (u == 0.)
93  return ret;
94  for (int l = 1; l <= M / 2; ++l) {
95  complex_t term = ReciprocalFactorialArray[M - 2 * l] * ReciprocalFactorialArray[2 * l + 1]
96  * pow(u, 2 * l) * pow(v, M - 2 * l);
97  ret += term;
98  // std::cout << "contrib l=" << l << " t=" << term << " s=" << ret << "\n";
99  }
100  return ret;
101 }
std::complex< double > complex_t
Definition: Complex.h:20
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
complex_t qE(cvector_t q) const

References BasicVector3D< T >::dot(), m_R, and qE().

Referenced by PolyhedralFace::ff_n_core().

Here is the call graph for this function:

◆ E()

kvector_t PolyhedralEdge::E ( ) const
inline

Definition at line 46 of file PolyhedralComponents.h.

46 { return m_E; }

References m_E.

Referenced by PolyhedralFace::edge_sum_ff(), and PolyhedralFace::ff_n_core().

◆ qE()

complex_t PolyhedralEdge::qE ( cvector_t  q) const
inline

Definition at line 48 of file PolyhedralComponents.h.

48 { return m_E.dot(q); }

References BasicVector3D< T >::dot(), and m_E.

Referenced by contrib(), and PolyhedralFace::edge_sum_ff().

Here is the call graph for this function:

◆ qR()

complex_t PolyhedralEdge::qR ( cvector_t  q) const
inline

Definition at line 49 of file PolyhedralComponents.h.

49 { return m_R.dot(q); }

References BasicVector3D< T >::dot(), and m_R.

Referenced by PolyhedralFace::edge_sum_ff().

Here is the call graph for this function:

◆ R()

kvector_t PolyhedralEdge::R ( ) const
inline

Definition at line 47 of file PolyhedralComponents.h.

47 { return m_R; }

References m_R.

Member Data Documentation

◆ m_E

kvector_t PolyhedralEdge::m_E
private

vector pointing from mid of edge to upper vertex

Definition at line 54 of file PolyhedralComponents.h.

Referenced by PolyhedralEdge(), E(), and qE().

◆ m_R

kvector_t PolyhedralEdge::m_R
private

position vector of edge midpoint

Definition at line 55 of file PolyhedralComponents.h.

Referenced by contrib(), qR(), and R().


The documentation for this class was generated from the following files: