mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
updated tests to use units args by @eepeterson
Co-authored-by: Ethan Peterson <ethan.peterson@mit.edu>
This commit is contained in:
parent
a94fb43418
commit
63b517aebc
2 changed files with 14 additions and 13 deletions
|
|
@ -910,9 +910,10 @@ class Material(IDManagerMixin):
|
|||
units : {'Bq', 'Bq/g', 'Bq/cm3'}
|
||||
Specifies the type of activity to return, options include total
|
||||
activity [Bq], specific [Bq/g] or volumetric activity [Bq/cm3].
|
||||
Default is volumetric activity [Bq/cm3].
|
||||
by_nuclide : bool
|
||||
Specifies if the activity should be returned for the material as a
|
||||
whole or per nuclide.
|
||||
whole or per nuclide. Default is False.
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
|
|
|||
|
|
@ -480,37 +480,37 @@ def test_get_activity():
|
|||
m1.add_element("Li", 0.3)
|
||||
m1.set_density('g/cm3', 1.5)
|
||||
# activity in Bq/cc and Bq/g should not require volume setting
|
||||
assert m1.get_activity(normalization='volume') == 0
|
||||
assert m1.get_activity(normalization='mass') == 0
|
||||
assert m1.get_activity(units='Bq/cm3') == 0
|
||||
assert m1.get_activity(units='Bq/g') == 0
|
||||
m1.volume = 1
|
||||
assert m1.get_activity(normalization='total') == 0
|
||||
assert m1.get_activity(units='Bq') == 0
|
||||
|
||||
# Checks that 1g of tritium has the correct activity scaling
|
||||
m2 = openmc.Material()
|
||||
m2.add_nuclide("H3", 1)
|
||||
m2.set_density('g/cm3', 1)
|
||||
m2.volume = 1
|
||||
assert pytest.approx(m2.get_activity(normalization='total')) == 3.559778e14
|
||||
assert pytest.approx(m2.get_activity(units='Bq')) == 3.559778e14
|
||||
m2.set_density('g/cm3', 2)
|
||||
assert pytest.approx(m2.get_activity(normalization='total')) == 3.559778e14*2
|
||||
assert pytest.approx(m2.get_activity(units='Bq')) == 3.559778e14*2
|
||||
m2.volume = 3
|
||||
assert pytest.approx(m2.get_activity(normalization='total')) == 3.559778e14*2*3
|
||||
assert pytest.approx(m2.get_activity(units='Bq')) == 3.559778e14*2*3
|
||||
|
||||
# Checks that 1 mol of a metastable nuclides has the correct activity
|
||||
m3 = openmc.Material()
|
||||
m3.add_nuclide("Tc99_m1", 1)
|
||||
m3.set_density('g/cm3', 1)
|
||||
m3.volume = 98.9
|
||||
assert pytest.approx(m3.get_activity(normalization='total'), rel=0.001) == 1.93e19
|
||||
assert pytest.approx(m3.get_activity(units='Bq'), rel=0.001) == 1.93e19
|
||||
|
||||
# Checks that specific and volumetric activity of tritium are correct
|
||||
m4 = openmc.Material()
|
||||
m4.add_nuclide("H3", 1)
|
||||
m4.set_density('g/cm3', 1.5)
|
||||
assert pytest.approx(m4.get_activity(normalization='mass')) == 355978108155965.94 # [Bq/g]
|
||||
assert pytest.approx(m4.get_activity(normalization='mass', by_nuclide=True)["H3"]) == 355978108155965.94 # [Bq/g]
|
||||
assert pytest.approx(m4.get_activity(normalization='volume')) == 355978108155965.94*3/2 # [Bq/cc]
|
||||
assert pytest.approx(m4.get_activity(normalization='volume', by_nuclide=True)["H3"]) == 355978108155965.94*3/2 # [Bq/cc]
|
||||
assert pytest.approx(m4.get_activity(units='Bq/g')) == 355978108155965.94 # [Bq/g]
|
||||
assert pytest.approx(m4.get_activity(units='Bq/g', by_nuclide=True)["H3"]) == 355978108155965.94 # [Bq/g]
|
||||
assert pytest.approx(m4.get_activity(units='Bq/cm3')) == 355978108155965.94*3/2 # [Bq/cc]
|
||||
assert pytest.approx(m4.get_activity(units='Bq/cm3', by_nuclide=True)["H3"]) == 355978108155965.94*3/2 # [Bq/cc]
|
||||
# volume is required to calculate total activity
|
||||
m4.volume = 10.
|
||||
assert pytest.approx(m4.get_activity(normalization='total')) == 355978108155965.94*3/2*10 # [Bq]
|
||||
assert pytest.approx(m4.get_activity(units='Bq')) == 355978108155965.94*3/2*10 # [Bq]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue