Skip to content
Snippets Groups Projects
Commit 1109ff9e authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

little optimization for Cone

parent 4f7a88b1
No related branches found
No related tags found
1 merge request!1145Optimize integrands in form factor quadrature
Pipeline #80701 failed
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment