Updating check to log-log

This commit is contained in:
Patrick Shriwise 2022-07-30 00:34:37 -05:00
parent 2ef49a9c9b
commit c09f539cd5
3 changed files with 17 additions and 9 deletions

View file

@ -1959,9 +1959,9 @@ class EnergyFunctionFilter(Filter):
filter_id = int(group.name.split('/')[-1].lstrip('filter '))
out = cls(energy, y, filter_id=filter_id)
if 'interpolation' in group.attrs:
if 'interpolation' in group:
out.interpolation = \
openmc.data.INTERPOLATION_SCHEME[group.attrs['interpolation']]
openmc.data.INTERPOLATION_SCHEME[group['interpolation'][()]]
return out

View file

@ -29,6 +29,16 @@ void EnergyFunctionFilter::from_xml(pugi::xml_node node)
interpolation_ = Interpolation::lin_lin;
if (check_for_node(node, "interpolation")) {
std::string interpolation = get_node_value(node, "interpolation");
if (interpolation == "linear-linear") {
interpolation_ = Interpolation::lin_lin;
} else if (interpolation == "log-log") {
interpolation_ = Interpolation::log_log;
} else {
fatal_error(fmt::format(
"Invalid interpolation type '{}' specified on EnergyFunctionFilter {}. "
"Must be 'linear-linear' or 'log-log'.",
interpolation, id()));
}
}
this->set_data(energy, y);
@ -90,7 +100,7 @@ void EnergyFunctionFilter::to_statepoint(hid_t filter_group) const
Filter::to_statepoint(filter_group);
write_dataset(filter_group, "energy", energy_);
write_dataset(filter_group, "y", y_);
write_attribute<int>(
write_dataset(
filter_group, "interpolation", static_cast<int>(interpolation_));
}

View file

@ -52,8 +52,6 @@ def model():
tallies[2].filters = [filt3]
model.tallies.extend(tallies)
return model
@ -74,15 +72,15 @@ class FilterEnergyFunHarness(PyAPITestHarness):
# Read the statepoint file.
sp = openmc.StatePoint(self._sp_name)
# check that values are round-tripped correctly from
# check that information is round-tripped correctly from
# the statepoint file
sp_tally = sp.get_tally(id=2)
sp_tally = sp.get_tally(id=3)
sp_filt = sp_tally.find_filter(openmc.EnergyFunctionFilter)
model_tally = self._model.tallies[1]
model_tally = self._model.tallies[2]
model_filt = model_tally.find_filter(openmc.EnergyFunctionFilter)
assert sp_filt.interpolation == 'linear-linear'
assert sp_filt.interpolation == 'log-log'
assert all(sp_filt.energy == model_filt.energy)
assert all(sp_filt.y == model_filt.y)