mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Delegate Nuclide yield properties to FissionYieldDistribution
For consistency across the various fission yield helpers, the Nuclide object now sets the yield data to always be a FissionYieldDistribution or an empty dictionary. Nuclide.yield_energies is now a property that returns the energies from the FissionYieldDistribution. When setting the yield_data, the Nuclide enforces the object to be a Mapping instance. If the incoming yield_data is a FissionYieldDistribution, no conversions are made. Otherwise, a new distribution is created with the from_dict method. The Chain.from_xml method now creates the yield_data for nuclides using FissionYieldDistribution.from_dict Changes were made to some unit tests that attempted to set the yield_energies, which do not have a setter.
This commit is contained in:
parent
0931b58269
commit
f2fa86fd52
5 changed files with 37 additions and 17 deletions
|
|
@ -129,7 +129,7 @@ def test_from_xml(simple_chain):
|
|||
assert [r.branching_ratio for r in nuc.reactions] == [1.0, 0.7, 0.3]
|
||||
|
||||
# Yield tests
|
||||
assert nuc.yield_energies == [0.0253]
|
||||
assert nuc.yield_energies == (0.0253, )
|
||||
assert list(nuc.yield_data) == [0.0253]
|
||||
assert nuc.yield_data[0.0253].products == ("A", "B")
|
||||
assert (nuc.yield_data[0.0253].yields == [0.0292737, 0.002566345]).all()
|
||||
|
|
@ -163,7 +163,6 @@ def test_export_to_xml(run_in_tmpdir):
|
|||
nuclide.ReactionTuple("(n,gamma)", "A", 0.0, 0.7),
|
||||
nuclide.ReactionTuple("(n,gamma)", "B", 0.0, 0.3)
|
||||
]
|
||||
C.yield_energies = [0.0253]
|
||||
C.yield_data = nuclide.FissionYieldDistribution.from_dict({
|
||||
0.0253: {"A": 0.0292737, "B": 0.002566345}})
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,11 @@ def nuclide_bundle():
|
|||
1.40e7: {"Xe135": 4.54e-3, "Gd155": 5.83e-8}}
|
||||
u235 = Nuclide()
|
||||
u235.name = "U235"
|
||||
u235.yield_energies = (0.0253, 5.0e5, 1.40e7)
|
||||
u235.yield_data = FissionYieldDistribution.from_dict(u5yield_dict)
|
||||
|
||||
u8yield_dict = {5.00e5: {"Xe135": 1.12e-3, "Gd155": 1.32e-12}}
|
||||
u238 = Nuclide()
|
||||
u238.name = "U238"
|
||||
u238.yield_energies = (5.00e5,)
|
||||
u238.yield_data = FissionYieldDistribution.from_dict(u8yield_dict)
|
||||
|
||||
xe135 = Nuclide()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import xml.etree.ElementTree as ET
|
||||
|
||||
import numpy
|
||||
import pytest
|
||||
|
||||
from openmc.deplete import nuclide
|
||||
|
||||
|
|
@ -73,8 +74,12 @@ def test_from_xml():
|
|||
]
|
||||
expected_yield_data = nuclide.FissionYieldDistribution.from_dict({
|
||||
0.0253: {"Xe138": 0.0481413, "Zr100": 0.0497641, "Te134": 0.062155}})
|
||||
assert u235.yield_energies == [0.0253]
|
||||
assert u235.yield_data == expected_yield_data
|
||||
# test accessing the yield energies through the FissionYieldDistribution
|
||||
assert u235.yield_energies == (0.0253, )
|
||||
assert u235.yield_energies is u235.yield_data.energies
|
||||
with pytest.raises(AttributeError): # not settable
|
||||
u235.yield_energies = [0.0253, 5e5]
|
||||
|
||||
|
||||
def test_to_xml_element():
|
||||
|
|
@ -91,7 +96,6 @@ def test_to_xml_element():
|
|||
nuclide.ReactionTuple('fission', None, 2.0e8, 1.0),
|
||||
nuclide.ReactionTuple('(n,gamma)', 'A', 0.0, 1.0)
|
||||
]
|
||||
C.yield_energies = [0.0253]
|
||||
C.yield_data = nuclide.FissionYieldDistribution.from_dict(
|
||||
{0.0253: {"A": 0.0292737, "B": 0.002566345}})
|
||||
element = C.to_xml_element()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue