From c54c03e79016be658dca790c39e236394deb92e3 Mon Sep 17 00:00:00 2001 From: Alan Coleman <alanc@udel.edu> Date: Wed, 14 Jun 2023 14:19:28 +0200 Subject: [PATCH] Move the constants to an internal variable --- corsika/detail/modules/radio/CoREAS.inl | 3 +-- corsika/detail/modules/radio/ZHS.inl | 2 +- corsika/modules/radio/CoREAS.hpp | 2 ++ corsika/modules/radio/ZHS.hpp | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/corsika/detail/modules/radio/CoREAS.inl b/corsika/detail/modules/radio/CoREAS.inl index 317d3febf..2d5a75cf0 100644 --- a/corsika/detail/modules/radio/CoREAS.inl +++ b/corsika/detail/modules/radio/CoREAS.inl @@ -50,8 +50,7 @@ namespace corsika { auto const thinningWeight{step.getParticlePre().getWeight()}; // constants for electric field vector calculation - auto const constants_{(charge_ / (4 * M_PI) / (constants::epsilonZero) / - constants::c) * thinningWeight}; + auto const constants_{charge_ * emConstant_ * thinningWeight}; // set threshold for application of ZHS-like approximation. const double approxThreshold_{1.0e-3}; diff --git a/corsika/detail/modules/radio/ZHS.inl b/corsika/detail/modules/radio/ZHS.inl index db6971c5f..28d45f0ff 100644 --- a/corsika/detail/modules/radio/ZHS.inl +++ b/corsika/detail/modules/radio/ZHS.inl @@ -44,7 +44,7 @@ namespace corsika { // get thinning weight auto const thinningWeight{step.getParticlePre().getWeight()}; - auto const constants{(charge / (4 * M_PI) / (constants::epsilonZero) / constants::c) * thinningWeight}; + auto const constants{charge * emConstant_ * thinningWeight}; // we loop over each antenna in the collection for (auto& antenna : antennas_.getAntennas()) { diff --git a/corsika/modules/radio/CoREAS.hpp b/corsika/modules/radio/CoREAS.hpp index 058126aa7..dc2f81d5c 100644 --- a/corsika/modules/radio/CoREAS.hpp +++ b/corsika/modules/radio/CoREAS.hpp @@ -47,6 +47,8 @@ namespace corsika { */ template <typename Particle> ProcessReturn simulate(Step<Particle> const& step); + static constexpr auto emConstant_{1.0 / (4.0 * M_PI) / (constants::epsilonZero) / + constants::c}; using Base = RadioProcess<TRadioDetector, CoREAS<TRadioDetector, TPropagator>, TPropagator>; diff --git a/corsika/modules/radio/ZHS.hpp b/corsika/modules/radio/ZHS.hpp index 49153ba25..6da01f888 100644 --- a/corsika/modules/radio/ZHS.hpp +++ b/corsika/modules/radio/ZHS.hpp @@ -49,6 +49,8 @@ namespace corsika { */ template <typename Particle> ProcessReturn simulate(Step<Particle> const& step) const; + static constexpr auto emConstant_{1.0 / (4.0 * M_PI) / (constants::epsilonZero) / + constants::c}; private: using Base = -- GitLab