Skip to content
Snippets Groups Projects

Optimize integrands in form factor quadrature

Merged Wuttke, Joachim requested to merge hemi into main
1 file
+ 9
7
Compare changes
  • Side-by-side
  • Inline
@@ -38,23 +38,25 @@ Cone::Cone(double radius, double height, double alpha)
complex_t Cone::formfactor_at_bottom(C3 q) const
{
ASSERT(m_validated);
const double R = m_radius;
const double H = m_height;
if (std::abs(q.mag()) < std::numeric_limits<double>::epsilon()) {
double R = m_radius;
double H = m_height;
if (m_cot_alpha == 0.0)
return M_PI * R * R * H; // cylinder case
double R2 = R - H * m_cot_alpha;
double apex_height = R / m_cot_alpha;
return M_PI / 3. * (R * R * H + (R * R - R2 * R2) * (apex_height - H));
}
complex_t integral = ComplexIntegrator().integrate(
const complex_t q_p = std::sqrt(q.x() * q.x() + q.y() * q.y());
return M_TWOPI * ComplexIntegrator().integrate(
[=](double Z) {
double Rz = m_radius - Z * m_cot_alpha;
complex_t q_p = std::sqrt(q.x() * q.x() + q.y() * q.y()); // sqrt(x*x + y*y)
const double Rz = R - Z * m_cot_alpha;
return Rz * Rz * Math::Bessel::J1c(q_p * Rz) * exp_I(q.z() * Z);
},
0., m_height);
return M_TWOPI * integral;
0., H);
}
std::string Cone::validate() const
Loading