Skip to content

Commit

Permalink
Merge pull request #281 from tudo-astroparticlephysics/nodes_utility
Browse files Browse the repository at this point in the history
Add InterpolationSettings::NODES_UTILITY
  • Loading branch information
Jean1995 authored Apr 27, 2022
2 parents 9b4ec00 + 67b312e commit d78118e
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/PROPOSAL/PROPOSAL/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/PROPOSAL/detail/PROPOSAL/Constants.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include "PROPOSAL/propagation_utility/ContRandBuilder.h"
#include "PROPOSAL/propagation_utility/PropagationUtilityInterpolant.h"
#include "PROPOSAL/Constants.h"

using namespace PROPOSAL;

namespace PROPOSAL {
template <> void ContRandBuilder<UtilityIntegral>::build_tables() { }

template <> void ContRandBuilder<UtilityInterpolant>::build_tables()
{
cont_rand_integral.BuildTables("cont_rand_", 200, false);
cont_rand_integral.BuildTables("cont_rand_",
InterpolationSettings::NODES_UTILITY, false);
}
} // namespace PROPOSAL

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "PROPOSAL/propagation_utility/DecayBuilder.h"
#include "PROPOSAL/propagation_utility/PropagationUtilityInterpolant.h"
#include "PROPOSAL/Constants.h"

using namespace PROPOSAL;

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "PROPOSAL/propagation_utility/DisplacementBuilder.h"
#include "PROPOSAL/propagation_utility/PropagationUtilityInterpolant.h"
#include "PROPOSAL/Constants.h"

using namespace PROPOSAL;

Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -21,7 +22,8 @@ InteractionBuilder::InteractionBuilder(std::shared_ptr<Displacement> _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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/pyPROPOSAL/detail/pybindings.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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_<InterpolationDef, std::shared_ptr<InterpolationDef>>(m, */
/* "InterpolationDef", */
Expand Down

0 comments on commit d78118e

Please sign in to comment.