BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PolyhedralEdge Class Reference
Collaboration diagram for PolyhedralEdge:

Public Member Functions

 PolyhedralEdge (const kvector_t _Vlow, const kvector_t _Vhig)
 
kvector_t E () const
 
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
 

Private Attributes

kvector_t m_E
 
kvector_t m_R
 

Detailed Description

One edge of a polygon, for form factor computation.

Definition at line 24 of file PolyhedralComponents.h.

Constructor & Destructor Documentation

◆ PolyhedralEdge()

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

Definition at line 31 of file PolyhedralComponents.cpp.

32  : m_E((_Vhig - _Vlow) / 2), m_R((_Vhig + _Vlow) / 2)
33 {
34  if (m_E.mag2() == 0)
35  throw std::invalid_argument("At least one edge has zero length");
36 };
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

◆ E()

kvector_t PolyhedralEdge::E ( ) const
inline

Definition at line 29 of file PolyhedralComponents.h.

29 { return m_E; }

References m_E.

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

◆ R()

kvector_t PolyhedralEdge::R ( ) const
inline

Definition at line 30 of file PolyhedralComponents.h.

30 { return m_R; }

References m_R.

◆ qE()

complex_t PolyhedralEdge::qE ( cvector_t  q) const
inline

Definition at line 31 of file PolyhedralComponents.h.

31 { return m_E.dot(q); }
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).

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 32 of file PolyhedralComponents.h.

32 { 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:

◆ 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 40 of file PolyhedralComponents.cpp.

41 {
42  complex_t u = qE(qpa);
43  complex_t v2 = m_R.dot(qpa);
44  complex_t v1 = qrperp;
45  complex_t v = v2 + v1;
46 #ifdef POLYHEDRAL_DIAGNOSTIC
47  if (diagnosis.debmsg >= 5)
48  std::cout << std::scientific << std::showpos << std::setprecision(16) << "contrib: u=" << u
49  << " v1=" << v1 << " v2=" << v2 << "\n";
50 #endif
51  if (v == 0.) { // only 2l=M contributes
52  if (M & 1) // M is odd
53  return 0.;
54  else
55  return ReciprocalFactorialArray[M] * (pow(u, M) / (M + 1.) - pow(v1, M));
56  }
57  complex_t ret = 0;
58  // the l=0 term, minus (qperp.R)^M, which cancels under the sum over E*contrib()
59  if (v1 == 0.) {
60  ret = ReciprocalFactorialArray[M] * pow(v2, M);
61  } else if (v2 == 0.) {
62  ; // leave ret=0
63  } else {
64  // binomial expansion
65  for (int mm = 1; mm <= M; ++mm) {
67  * pow(v2, mm) * pow(v1, M - mm);
68  ret += term;
69 #ifdef POLYHEDRAL_DIAGNOSTIC
70  if (diagnosis.debmsg >= 6)
71  std::cout << "contrib mm=" << mm << " t=" << term << " s=" << ret << "\n";
72 #endif
73  }
74  }
75  if (u == 0.)
76  return ret;
77  for (int l = 1; l <= M / 2; ++l) {
78  complex_t term = ReciprocalFactorialArray[M - 2 * l] * ReciprocalFactorialArray[2 * l + 1]
79  * pow(u, 2 * l) * pow(v, M - 2 * l);
80  ret += term;
81 #ifdef POLYHEDRAL_DIAGNOSTIC
82  if (diagnosis.debmsg >= 6)
83  std::cout << "contrib l=" << l << " t=" << term << " s=" << ret << "\n";
84 #endif
85  }
86  return ret;
87 }
std::complex< double > complex_t
Definition: Complex.h:20
complex_t qE(cvector_t q) const
std::string scientific(const T value, int n=10)
Returns scientific string representing given value of any numeric type.
Definition: StringUtils.h:54

References BasicVector3D< T >::dot(), m_R, qE(), anonymous_namespace{PolyhedralComponents.cpp}::ReciprocalFactorialArray, and StringUtils::scientific().

Referenced by PolyhedralFace::ff_n_core().

Here is the call graph for this function:

Member Data Documentation

◆ m_E

kvector_t PolyhedralEdge::m_E
private

vector pointing from mid of edge to upper vertex

Definition at line 37 of file PolyhedralComponents.h.

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

◆ m_R

kvector_t PolyhedralEdge::m_R
private

position vector of edge midpoint

Definition at line 38 of file PolyhedralComponents.h.

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


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