Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use temperature bounds in multigroup mode temperature #3059

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a place in OpenMC to place this which can allow us to consolidate this code and the identical lines from nuclide.cpp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like a util header? I'm not sure which one, maybe if there is one for std::vector

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could put a utility function in settings.h that sets temps_to_read?

Copy link
Contributor Author

@GiudGiud GiudGiud Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with any luck we might be able to include from line 98 to 178 in this utility. @meltawila do you want to give it a try?

// 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