2020-03-04 11:41:52 +00:00
|
|
|
import openmc
|
2024-04-24 17:05:10 -04:00
|
|
|
from pytest import approx, raises, warns
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
from openmc.data import NATURAL_ABUNDANCE, atomic_mass
|
|
|
|
|
|
|
|
|
|
|
2020-02-26 12:18:19 +00:00
|
|
|
def test_expand_no_enrichment():
|
2020-02-14 17:54:01 +00:00
|
|
|
""" Expand Li in natural compositions"""
|
2020-03-04 11:41:52 +00:00
|
|
|
lithium = openmc.Element('Li')
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# Verify the expansion into ATOMIC fraction against natural composition
|
|
|
|
|
for isotope in lithium.expand(100.0, 'ao'):
|
2020-03-04 11:58:46 +00:00
|
|
|
assert isotope[1] == approx(NATURAL_ABUNDANCE[isotope[0]] * 100.0)
|
2020-02-14 17:54:01 +00:00
|
|
|
|
2020-02-26 12:18:19 +00:00
|
|
|
# Verify the expansion into WEIGHT fraction against natural composition
|
2020-02-14 17:54:01 +00:00
|
|
|
natural = {'Li6': NATURAL_ABUNDANCE['Li6'] * atomic_mass('Li6'),
|
|
|
|
|
'Li7': NATURAL_ABUNDANCE['Li7'] * atomic_mass('Li7')}
|
|
|
|
|
li_am = sum(natural.values())
|
2020-03-04 11:41:52 +00:00
|
|
|
for key in natural:
|
2020-02-14 17:54:01 +00:00
|
|
|
natural[key] /= li_am
|
|
|
|
|
|
|
|
|
|
for isotope in lithium.expand(100.0, 'wo'):
|
2020-03-04 11:58:46 +00:00
|
|
|
assert isotope[1] == approx(natural[isotope[0]] * 100.0)
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_expand_enrichment():
|
|
|
|
|
""" Expand and verify enrichment of Li """
|
2020-03-04 11:41:52 +00:00
|
|
|
lithium = openmc.Element('Li')
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# Verify the enrichment by atoms
|
|
|
|
|
ref = {'Li6': 75.0, 'Li7': 25.0}
|
|
|
|
|
for isotope in lithium.expand(100.0, 'ao', 25.0, 'Li7', 'ao'):
|
2020-03-04 11:58:46 +00:00
|
|
|
assert isotope[1] == approx(ref[isotope[0]])
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# Verify the enrichment by weight
|
|
|
|
|
for isotope in lithium.expand(100.0, 'wo', 25.0, 'Li7', 'wo'):
|
2020-03-04 11:58:46 +00:00
|
|
|
assert isotope[1] == approx(ref[isotope[0]])
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
|
2024-04-24 17:05:10 -04:00
|
|
|
def test_expand_no_isotopes():
|
|
|
|
|
"""Test that correct warning is raised for elements with no isotopes"""
|
|
|
|
|
with warns(UserWarning, match='No naturally occurring'):
|
|
|
|
|
element = openmc.Element('Tc')
|
|
|
|
|
element.expand(100.0, 'ao')
|
|
|
|
|
|
|
|
|
|
|
2025-06-18 18:10:03 +03:00
|
|
|
def test_expand_ta():
|
2026-01-26 11:09:58 -06:00
|
|
|
ref = {'Ta181': 100.0}
|
2025-06-18 18:10:03 +03:00
|
|
|
element = openmc.Element('Ta')
|
|
|
|
|
for isotope in element.expand(100.0, 'ao'):
|
|
|
|
|
assert isotope[1] == approx(ref[isotope[0]])
|
2026-01-26 11:09:58 -06:00
|
|
|
|
2025-06-18 18:10:03 +03:00
|
|
|
|
2020-02-14 17:54:01 +00:00
|
|
|
def test_expand_exceptions():
|
2020-02-26 12:18:19 +00:00
|
|
|
""" Test that correct exceptions are raised for invalid input """
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# 1 Isotope Element
|
2020-03-04 11:41:52 +00:00
|
|
|
with raises(ValueError):
|
|
|
|
|
element = openmc.Element('Be')
|
|
|
|
|
element.expand(70.0, 'ao', 4.0, 'Be9')
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# 3 Isotope Element
|
2020-03-04 11:41:52 +00:00
|
|
|
with raises(ValueError):
|
|
|
|
|
element = openmc.Element('Cr')
|
|
|
|
|
element.expand(70.0, 'ao', 4.0, 'Cr52')
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# Non-present Enrichment Target
|
2020-03-04 11:41:52 +00:00
|
|
|
with raises(ValueError):
|
|
|
|
|
element = openmc.Element('H')
|
|
|
|
|
element.expand(70.0, 'ao', 4.0, 'H4')
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# Enrichment Procedure for Uranium if not Uranium
|
2020-03-04 11:41:52 +00:00
|
|
|
with raises(ValueError):
|
|
|
|
|
element = openmc.Element('Li')
|
|
|
|
|
element.expand(70.0, 'ao', 4.0)
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# Missing Enrichment Target
|
2020-03-04 11:41:52 +00:00
|
|
|
with raises(ValueError):
|
|
|
|
|
element = openmc.Element('Li')
|
|
|
|
|
element.expand(70.0, 'ao', 4.0, enrichment_type='ao')
|
2020-02-14 17:54:01 +00:00
|
|
|
|
|
|
|
|
# Invalid Enrichment Type Entry
|
2020-03-04 11:41:52 +00:00
|
|
|
with raises(ValueError):
|
|
|
|
|
element = openmc.Element('Li')
|
|
|
|
|
element.expand(70.0, 'ao', 4.0, 'Li7', 'Grand Moff Tarkin')
|
2020-02-14 17:54:01 +00:00
|
|
|
|
2020-02-26 12:18:19 +00:00
|
|
|
# Trying to enrich Uranium
|
2020-03-04 11:41:52 +00:00
|
|
|
with raises(ValueError):
|
|
|
|
|
element = openmc.Element('U')
|
|
|
|
|
element.expand(70.0, 'ao', 4.0, 'U235', 'wo')
|
2020-02-29 20:34:05 +00:00
|
|
|
|
|
|
|
|
# Trying to enrich Uranium with wrong enrichment_target
|
2020-03-04 11:41:52 +00:00
|
|
|
with raises(ValueError):
|
|
|
|
|
element = openmc.Element('U')
|
|
|
|
|
element.expand(70.0, 'ao', 4.0, enrichment_type='ao')
|