Skip to content

Commit

Permalink
Update nonthermal.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Sep 1, 2024
1 parent aa12138 commit fa543bb
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions nonthermal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,27 +585,15 @@ void zero_all_effionpot(const int modelgridindex) {
{
const int index = std::floor((energy_ev - SF_EMIN) / DELTA_E);

if (index < 0) {
return 0;
}
if (index > SFPTS - 1) {
return SFPTS - 1;
}
return index;
return std::clamp(index, 0, SFPTS - 1);
}

[[nodiscard]] constexpr auto get_energyindex_ev_gteq(const double energy_ev) -> int
// finds the highest energy point <= energy_ev
{
const int index = std::ceil((energy_ev - SF_EMIN) / DELTA_E);

if (index < 0) {
return 0;
}
if (index > SFPTS - 1) {
return SFPTS - 1;
}
return index;
return std::clamp(index, 0, SFPTS - 1);
}

// interpolate the y flux values to get the value at a given energy
Expand Down

0 comments on commit fa543bb

Please sign in to comment.