From 67b312ed7a43d8de03f86614af49c81e0ecefc66 Mon Sep 17 00:00:00 2001 From: Jean-Marco Alameddine Date: Wed, 20 Apr 2022 15:39:33 +0200 Subject: [PATCH] Add InterpolationSettings::NODES_UTILITY to change number of nodes for utility interpolation tables --- src/PROPOSAL/PROPOSAL/Constants.h | 1 + src/PROPOSAL/detail/PROPOSAL/Constants.cxx | 1 + .../detail/PROPOSAL/propagation_utility/ContRandBuilder.cxx | 5 ++++- .../detail/PROPOSAL/propagation_utility/DecayBuilder.cxx | 4 +++- .../PROPOSAL/propagation_utility/DisplacmentBuilder.cxx | 4 +++- .../PROPOSAL/propagation_utility/InteractionBuilder.cxx | 4 +++- .../propagation_utility/PropagationUtilityInterpolant.cxx | 2 +- .../detail/PROPOSAL/propagation_utility/TimeBuilder.cxx | 3 ++- src/pyPROPOSAL/detail/pybindings.cxx | 4 +++- 9 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/PROPOSAL/PROPOSAL/Constants.h b/src/PROPOSAL/PROPOSAL/Constants.h index c74c690d7..3311fcaa7 100644 --- a/src/PROPOSAL/PROPOSAL/Constants.h +++ b/src/PROPOSAL/PROPOSAL/Constants.h @@ -56,6 +56,7 @@ struct InterpolationSettings { static unsigned int NODES_DE2DX; static unsigned int NODES_DNDX_E; static unsigned int NODES_DNDX_V; + static unsigned int NODES_UTILITY; }; // precision parameters diff --git a/src/PROPOSAL/detail/PROPOSAL/Constants.cxx b/src/PROPOSAL/detail/PROPOSAL/Constants.cxx index 3a1924f81..7bfdf3439 100644 --- a/src/PROPOSAL/detail/PROPOSAL/Constants.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/Constants.cxx @@ -30,6 +30,7 @@ unsigned int InterpolationSettings::NODES_DEDX = 500; unsigned int InterpolationSettings::NODES_DE2DX = 200; unsigned int InterpolationSettings::NODES_DNDX_E = 100; unsigned int InterpolationSettings::NODES_DNDX_V = 100; +unsigned int InterpolationSettings::NODES_UTILITY = 500; // precision parameters const double PROPOSAL::COMPUTER_PRECISION = 1.e-10; diff --git a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/ContRandBuilder.cxx b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/ContRandBuilder.cxx index f382ff5f6..25ce59735 100644 --- a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/ContRandBuilder.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/ContRandBuilder.cxx @@ -1,5 +1,7 @@ #include "PROPOSAL/propagation_utility/ContRandBuilder.h" #include "PROPOSAL/propagation_utility/PropagationUtilityInterpolant.h" +#include "PROPOSAL/Constants.h" + using namespace PROPOSAL; namespace PROPOSAL { @@ -7,7 +9,8 @@ template <> void ContRandBuilder::build_tables() { } template <> void ContRandBuilder::build_tables() { - cont_rand_integral.BuildTables("cont_rand_", 200, false); + cont_rand_integral.BuildTables("cont_rand_", + InterpolationSettings::NODES_UTILITY, false); } } // namespace PROPOSAL diff --git a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/DecayBuilder.cxx b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/DecayBuilder.cxx index 775b71d1d..2d3618a18 100644 --- a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/DecayBuilder.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/DecayBuilder.cxx @@ -1,5 +1,6 @@ #include "PROPOSAL/propagation_utility/DecayBuilder.h" #include "PROPOSAL/propagation_utility/PropagationUtilityInterpolant.h" +#include "PROPOSAL/Constants.h" using namespace PROPOSAL; @@ -19,7 +20,8 @@ DecayBuilder::DecayBuilder( [this](double E) { return FunctionToIntegral(E); }, disp->GetLowerLim(), this->GetHash())) { - decay_integral->BuildTables("decay_", 500, true); + decay_integral->BuildTables("decay_", InterpolationSettings::NODES_UTILITY, + true); } double DecayBuilder::EnergyDecay(double energy, double rnd, double density) diff --git a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/DisplacmentBuilder.cxx b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/DisplacmentBuilder.cxx index adb8ccb97..90a5c8fa8 100644 --- a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/DisplacmentBuilder.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/DisplacmentBuilder.cxx @@ -1,5 +1,6 @@ #include "PROPOSAL/propagation_utility/DisplacementBuilder.h" #include "PROPOSAL/propagation_utility/PropagationUtilityInterpolant.h" +#include "PROPOSAL/Constants.h" using namespace PROPOSAL; @@ -19,7 +20,8 @@ DisplacementBuilder::DisplacementBuilder( [this](double E) { return FunctionToIntegral(E); }, this->GetLowerLim(), this->GetHash())) { - disp_integral->BuildTables("disp_", 500, false); + disp_integral->BuildTables("disp_", InterpolationSettings::NODES_UTILITY, + false); } double DisplacementBuilder::SolveTrackIntegral( diff --git a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/InteractionBuilder.cxx b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/InteractionBuilder.cxx index 85e1f4c94..43825cddf 100644 --- a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/InteractionBuilder.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/InteractionBuilder.cxx @@ -2,6 +2,7 @@ #include "PROPOSAL/propagation_utility/DisplacementBuilder.h" #include "PROPOSAL/propagation_utility/PropagationUtilityInterpolant.h" #include "PROPOSAL/crosssection/CrossSection.h" +#include "PROPOSAL/Constants.h" using namespace PROPOSAL; @@ -21,7 +22,8 @@ InteractionBuilder::InteractionBuilder(std::shared_ptr _disp, [this](double E) { return FunctionToIntegral(E); }, _disp->GetLowerLim(), this->GetHash())) { - interaction_integral->BuildTables("inter_", 500, false); + interaction_integral->BuildTables("inter_", + InterpolationSettings::NODES_UTILITY, false); } double InteractionBuilder::EnergyInteraction(double energy, double rnd) diff --git a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/PropagationUtilityInterpolant.cxx b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/PropagationUtilityInterpolant.cxx index 5526bb1cf..8cb0b5d33 100644 --- a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/PropagationUtilityInterpolant.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/PropagationUtilityInterpolant.cxx @@ -40,7 +40,7 @@ void UtilityInterpolant::BuildTables(const std::string prefix, size_t nodes, reference_x = InterpolationSettings::UPPER_ENERGY_LIM; } - hash_combine(this->hash, reverse); + hash_combine(this->hash, nodes, reverse); if (reverse) { def.f = [&](double energy) { diff --git a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/TimeBuilder.cxx b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/TimeBuilder.cxx index 754c29738..01e784e3b 100644 --- a/src/PROPOSAL/detail/PROPOSAL/propagation_utility/TimeBuilder.cxx +++ b/src/PROPOSAL/detail/PROPOSAL/propagation_utility/TimeBuilder.cxx @@ -24,7 +24,8 @@ ExactTimeBuilder::ExactTimeBuilder( [this](double E) { return FunctionToIntegral(E); }, _disp->GetLowerLim(), this->GetHash())) { - time_integral->BuildTables("time_", 500, false); + time_integral->BuildTables("time_", InterpolationSettings::NODES_UTILITY, + false); } double ExactTimeBuilder::TimeElapsed(double initial_energy, double final_energy, diff --git a/src/pyPROPOSAL/detail/pybindings.cxx b/src/pyPROPOSAL/detail/pybindings.cxx index 1eb170892..430f19540 100644 --- a/src/pyPROPOSAL/detail/pybindings.cxx +++ b/src/pyPROPOSAL/detail/pybindings.cxx @@ -230,7 +230,9 @@ PYBIND11_MODULE(proposal, m) .def_readwrite_static( "nodes_dndx_e", &InterpolationSettings::NODES_DNDX_E) .def_readwrite_static( - "nodes_dndx_v", &InterpolationSettings::NODES_DNDX_V); + "nodes_dndx_v", &InterpolationSettings::NODES_DNDX_V) + .def_readwrite_static( + "nodes_utility", &InterpolationSettings::NODES_UTILITY); /* py::class_>(m, */ /* "InterpolationDef", */