From 967b2e2b77764ffc453af2b5e3fb35edde6a7ffe Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Tue, 22 Nov 2022 11:10:09 +0100 Subject: [PATCH] Optimize TruncatedSphere ff --- Sample/HardParticle/TruncatedSphere.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sample/HardParticle/TruncatedSphere.cpp b/Sample/HardParticle/TruncatedSphere.cpp index 9df0dd19681..7f39a2fd444 100644 --- a/Sample/HardParticle/TruncatedSphere.cpp +++ b/Sample/HardParticle/TruncatedSphere.cpp @@ -43,13 +43,13 @@ complex_t TruncatedSphere::formfactor_at_bottom(C3 q) const * (m_height * m_height * (3. * m_radius - m_height) - m_dh * m_dh * (3. * m_radius - m_dh)); + const complex_t Q2 = std::sqrt(q.x() * q.x() + q.y() * q.y()); // NOT the modulus! + const double R2 = m_radius * m_radius; + complex_t integral = ComplexIntegrator().integrate( [=](double Z) { - double Rz = std::sqrt(m_radius * m_radius - Z * Z); - complex_t qx = q.x(); - complex_t qy = q.y(); - complex_t q_p = std::sqrt(qx * qx + qy * qy); // NOT the modulus! - return Rz * Rz * Math::Bessel::J1c(q_p * Rz) * exp_I(q.z() * Z); + const double R2Z2 = R2 - Z * Z; + return R2Z2 * Math::Bessel::J1c(Q2 * sqrt(R2Z2)) * exp_I(q.z() * Z); }, m_radius - m_height, m_radius - m_dh); return M_TWOPI * integral * exp_I(q.z() * (m_height - m_radius)); -- GitLab