diff --git a/docs/source/io_formats/depletion_chain.rst b/docs/source/io_formats/depletion_chain.rst index b0dd72eb9a..89c76525f8 100644 --- a/docs/source/io_formats/depletion_chain.rst +++ b/docs/source/io_formats/depletion_chain.rst @@ -82,7 +82,7 @@ element has the following attributes: ------------------------------------ The ```` element provides yields of fission products for -fissionable nuclides. It has the follow sub-elements: +fissionable nuclides. Normally, it has the follow sub-elements: :energies: Energies in [eV] at which yields for products are tabulated @@ -100,3 +100,11 @@ fissionable nuclides. It has the follow sub-elements: :data: Independent yields for each fission product + +In the event that a nuclide doesn't have any known fission product yields, it is +possible to have that nuclide borrow yields from another nuclide by indicating +the other nuclide in a single `parent` attribute. For example: + +.. code-block:: xml + + diff --git a/openmc/deplete/nuclide.py b/openmc/deplete/nuclide.py index 0b089e0e2c..aedacc6a3a 100644 --- a/openmc/deplete/nuclide.py +++ b/openmc/deplete/nuclide.py @@ -155,15 +155,16 @@ class Nuclide: return self.yield_data.energies @classmethod - def from_xml(cls, element, root, fission_q=None): + def from_xml(cls, element, root=None, fission_q=None): """Read nuclide from an XML element. Parameters ---------- element : xml.etree.ElementTree.Element XML element to read nuclide data from - root : xml.etree.ElementTree.Element - Root XML element for chain file + root : None or xml.etree.ElementTree.Element + Root XML element for chain file (only used when fission product + yields are borrowed from another parent) fission_q : None or float User-supplied fission Q value [eV]. Will be read from the element if not given diff --git a/tests/unit_tests/test_deplete_nuclide.py b/tests/unit_tests/test_deplete_nuclide.py index 126206cc70..4bbdf08101 100644 --- a/tests/unit_tests/test_deplete_nuclide.py +++ b/tests/unit_tests/test_deplete_nuclide.py @@ -2,7 +2,7 @@ import xml.etree.ElementTree as ET -import numpy +import numpy as np import pytest from openmc.deplete import nuclide @@ -81,6 +81,44 @@ def test_from_xml(): u235.yield_energies = [0.0253, 5e5] +def test_fpy_parent(): + """Test reading nuclide data with FPY borrowed from another nuclide.""" + + data = """ + + + + + 0.0253 + + Te134 Zr100 Xe138 + 0.062155 0.0497641 0.0481413 + + + + + + + + + """ + + root = ET.fromstring(data) + elems = root.findall('nuclide') + u235 = nuclide.Nuclide.from_xml(elems[0], root) + u238 = nuclide.Nuclide.from_xml(elems[1], root) + + # Make sure U238 yield is same as U235 + assert np.array_equal(u238.yield_data.energies, u235.yield_data.energies) + assert np.array_equal(u238.yield_data.yield_matrix, u235.yield_data.yield_matrix) + + # Make sure XML element created has single attribute + elem = u238.to_xml_element() + fpy_elem = elem.find('neutron_fission_yields') + assert fpy_elem.get('parent') == 'U235' + assert len(fpy_elem) == 0 + + def test_to_xml_element(): """Test writing nuclide data to an XML element.""" @@ -134,11 +172,11 @@ def test_fission_yield_distribution(): act_dist = yield_dict[exp_ene] for exp_prod, exp_yield in exp_dist.items(): assert act_dist[exp_prod] == exp_yield - exp_yield = numpy.array([ + exp_yield = np.array([ [4.08e-12, 1.71e-12, 7.85e-4], [1.32e-12, 0.0, 1.12e-3], [5.83e-8, 2.69e-8, 4.54e-3]]) - assert numpy.array_equal(yield_dist.yield_matrix, exp_yield) + assert np.array_equal(yield_dist.yield_matrix, exp_yield) # Test the operations / special methods for fission yield orig_yields = yield_dist[0.0253] @@ -151,18 +189,18 @@ def test_fission_yield_distribution(): # Scale and increment fission yields mod_yields = orig_yields * 2 - assert numpy.array_equal(orig_yields.yields * 2, mod_yields.yields) + assert np.array_equal(orig_yields.yields * 2, mod_yields.yields) mod_yields += orig_yields - assert numpy.array_equal(orig_yields.yields * 3, mod_yields.yields) + assert np.array_equal(orig_yields.yields * 3, mod_yields.yields) mod_yields = 2.0 * orig_yields - assert numpy.array_equal(orig_yields.yields * 2, mod_yields.yields) + assert np.array_equal(orig_yields.yields * 2, mod_yields.yields) - mod_yields = numpy.float64(2.0) * orig_yields - assert numpy.array_equal(orig_yields.yields * 2, mod_yields.yields) + mod_yields = np.float64(2.0) * orig_yields + assert np.array_equal(orig_yields.yields * 2, mod_yields.yields) # Failure modes for adding, multiplying yields - similar = numpy.empty_like(orig_yields.yields) + similar = np.empty_like(orig_yields.yields) with pytest.raises(TypeError): orig_yields + similar with pytest.raises(TypeError):