Fix EnergyFunctionFilter.from_xml_element

This commit is contained in:
Paul Romano 2022-10-18 12:02:02 -05:00
parent 0587aeeaa4
commit 2ae5ccb031
2 changed files with 16 additions and 1 deletions

View file

@ -2095,7 +2095,7 @@ class EnergyFunctionFilter(Filter):
y = [float(x) for x in get_text(elem, 'y').split()]
out = cls(energy, y, filter_id=filter_id)
if elem.find('interpolation') is not None:
out.interpolation = elem.find('interpolation')
out.interpolation = elem.find('interpolation').text
return out
def can_merge(self, other):

View file

@ -254,3 +254,18 @@ def test_lethargy_bin_width():
energy_bins = openmc.mgxs.GROUP_STRUCTURES['VITAMIN-J-175']
assert f.lethargy_bin_width[0] == np.log10(energy_bins[1]/energy_bins[0])
assert f.lethargy_bin_width[-1] == np.log10(energy_bins[-1]/energy_bins[-2])
def test_energyfunc():
f = openmc.EnergyFunctionFilter(
[0.0, 10.0, 2.0e3, 1.0e6, 20.0e6],
[1.0, 0.9, 0.8, 0.7, 0.6],
'histogram'
)
# Make sure XML roundtrip works
elem = f.to_xml_element()
new_f = openmc.EnergyFunctionFilter.from_xml_element(elem)
np.testing.assert_allclose(f.energy, new_f.energy)
np.testing.assert_allclose(f.y, new_f.y)
assert f.interpolation == new_f.interpolation