Skip to content

Commit

Permalink
Use temperature bounds in multigroup mode temperature refs #2402
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Aug 29, 2024
1 parent 5bc04b5 commit 424cddb
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/mgxs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,32 @@ void Mgxs::metadata_from_hdf5(hid_t xs_id, const vector<double>& temperature,
settings::temperature_method = TemperatureMethod::NEAREST;
}

// Determine actual temperatures to read -- start by checking whether a
// temperature range was given (indicated by T_max > 0), in which case all
// temperatures in the range are loaded irrespective of what temperatures
// actually appear in the model
int n = temperature.size();
double T_min = n > 0 ? settings::temperature_range[0] : 0.0;
double T_max = n > 0 ? settings::temperature_range[1] : INFTY;
if (T_max > 0.0) {
// Determine first available temperature below or equal to T_min
auto T_min_it =
std::upper_bound(available_temps.begin(), available_temps.end(), T_min);
if (T_min_it != available_temps.begin())
--T_min_it;

// Determine first available temperature above or equal to T_max
auto T_max_it =
std::lower_bound(available_temps.begin(), available_temps.end(), T_max);
if (T_max_it != available_temps.end())
++T_max_it;

// Add corresponding temperatures to vector
for (auto it = T_min_it; it != T_max_it; ++it) {
temps_to_read.push_back(std::round(*it));
}
}

switch (settings::temperature_method) {
case TemperatureMethod::NEAREST:
// Determine actual temperatures to read
Expand Down

0 comments on commit 424cddb

Please sign in to comment.