diff --git a/openmc/filter.py b/openmc/filter.py index f5268ad81..432ea1599 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -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 diff --git a/src/tallies/filter_energyfunc.cpp b/src/tallies/filter_energyfunc.cpp index 819b5d13e..fb76fb215 100644 --- a/src/tallies/filter_energyfunc.cpp +++ b/src/tallies/filter_energyfunc.cpp @@ -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( + write_dataset( filter_group, "interpolation", static_cast(interpolation_)); } diff --git a/tests/regression_tests/filter_energyfun/test.py b/tests/regression_tests/filter_energyfun/test.py index cb658b902..e0a191ce8 100644 --- a/tests/regression_tests/filter_energyfun/test.py +++ b/tests/regression_tests/filter_energyfun/test.py @@ -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)