23 FormFactorCone::FormFactorCone(
const std::vector<double> P)
25 "frustum with circular base",
26 {{
"Radius",
"nm",
"radius of base", 0, +INF, 0},
27 {
"Height",
"nm",
"height", 0, +INF, 0},
28 {
"Alpha",
"rad",
"angle between base and side", 0., M_PI_2, 0}}},
30 m_radius(m_P[0]), m_height(m_P[1]), m_alpha(m_P[2])
33 if (!std::isfinite(m_cot_alpha) || m_cot_alpha < 0)
35 if (m_cot_alpha * m_height > m_radius) {
36 std::ostringstream ostr;
37 ostr <<
"FormFactorCone() -> Error in class initialization ";
38 ostr <<
"with parameters radius:" << m_radius;
39 ostr <<
" m_height:" << m_height;
40 ostr <<
" alpha[rad]:" << m_alpha <<
"\n\n";
41 ostr <<
"Check for 'height <= radius*tan(alpha)' failed.";
47 FormFactorCone::FormFactorCone(
double radius,
double height,
double alpha)
53 complex_t FormFactorCone::Integrand(
double Z)
const
55 double Rz = m_radius - Z * m_cot_alpha;
56 complex_t q_p = std::sqrt(m_q.
x() * m_q.
x() + m_q.
y() * m_q.
y());
63 if (std::abs(m_q.
mag()) < std::numeric_limits<double>::epsilon()) {
66 if (m_cot_alpha == 0.0)
67 return M_PI * R * R * H;
68 double R2 = R - H * m_cot_alpha;
69 double apex_height = R / m_cot_alpha;
70 return M_PI / 3. * (R * R * H + (R * R - R2 * R2) * (apex_height - H));
73 ComplexIntegrator().integrate([&](
double Z) {
return Integrand(Z); }, 0., m_height);
74 return M_TWOPI * integral;
82 double dradius = effects.dz_bottom * m_cot_alpha;
83 FormFactorCone slicedff(m_radius - dradius, m_height - effects.dz_bottom - effects.dz_top,
85 return createTransformedFormFactor(slicedff, rot, effects.position);
91 double radius2 = m_radius - m_height * m_cot_alpha;
92 mP_shape = std::make_unique<DoubleEllipse>(m_radius, m_radius, m_height, radius2, radius2);
complex_t exp_I(complex_t z)
Returns exp(I*z), where I is the imaginary unit.
Defines class DoubleEllipse.
Defines many exception classes in namespace Exceptionss.
Defines classes RealIntegrator, ComplexIntegrator.
Defines M_PI and some more mathematical constants.
Defines namespace MathFunctions.
double mag() const
Returns magnitude of the vector.
T z() const
Returns z-component in cartesian coordinate system.
T y() const
Returns y-component in cartesian coordinate system.
T x() const
Returns x-component in cartesian coordinate system.
To integrate a complex function of a real variable.
Pure virtual interface for rotations.
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
double cot(double x)
cotangent function:
double Bessel_J1c(double x)
Bessel function Bessel_J1(x)/x.