Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finding number of atoms #41

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/openmc_depletion_plotter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from .utils import get_atoms_activity_from_material
from .utils import find_most_abundant_nuclides_in_material
from .utils import find_most_abundant_nuclides_in_materials
from .utils import get_nuclide_atom_densities_from_materials
from .utils import get_nuclide_atoms_from_materials
from .utils import find_most_active_nuclides_in_material
from .utils import find_most_active_nuclides_in_materials
from .utils import get_nuclide_activities_from_materials
Expand Down
4 changes: 2 additions & 2 deletions src/openmc_depletion_plotter/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .utils import find_total_activity_in_materials
from .utils import stable_nuclides
from .utils import create_base_plot
from .utils import get_nuclide_atom_densities_from_materials
from .utils import get_nuclide_atoms_from_materials
from .utils import find_most_abundant_nuclides_in_materials
from .utils import find_total_nuclides_in_materials
import plotly.graph_objects as go
Expand Down Expand Up @@ -184,7 +184,7 @@ def plot_atoms_vs_time(
else:
nuclides = most_abundant

all_nuclides_with_atoms = get_nuclide_atom_densities_from_materials(
all_nuclides_with_atoms = get_nuclide_atoms_from_materials(
nuclides=nuclides, materials=all_materials
)

Expand Down
10 changes: 6 additions & 4 deletions src/openmc_depletion_plotter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ def find_most_abundant_nuclides_in_material(
excluded_isotopes = exclude.get_nuclides()

non_excluded_nucs = {}
# get_nuclide_atom_densities does not need volume and can be used instead
# of get_nuclide_atoms here as have a single material
for key, value in material.get_nuclide_atom_densities().items():
if key not in excluded_isotopes:
if key not in non_excluded_nucs.keys():
Expand Down Expand Up @@ -271,7 +273,7 @@ def find_total_nuclides_in_materials(

for material in materials:
material_atom_densities = 0
for key, value in material.get_nuclide_atom_densities().items():
for key, value in material.get_nuclide_atoms().items():
if key not in excluded_isotopes:
material_atom_densities += value
materials_atom_densities.append(material_atom_densities)
Expand All @@ -293,7 +295,7 @@ def find_most_abundant_nuclides_in_materials(
excluded_isotopes = exclude.get_nuclides()

for material in materials:
for key, value in material.get_nuclide_atom_densities().items():
for key, value in material.get_nuclide_atoms().items():
if key not in excluded_isotopes:
if key not in non_excluded_nucs.keys():
non_excluded_nucs[key] = value
Expand All @@ -310,12 +312,12 @@ def find_most_abundant_nuclides_in_materials(
return list(sorted_dict.keys())


def get_nuclide_atom_densities_from_materials(nuclides, materials):
def get_nuclide_atoms_from_materials(nuclides, materials):
all_nuclides_with_atoms = {}
for isotope in nuclides:
all_quants = []
for material in materials:
quants = material.get_nuclide_atom_densities() # units are atom/b-cm
quants = material.get_nuclide_atoms()
if isotope in quants.keys():
quant = quants[isotope]
else:
Expand Down
16 changes: 13 additions & 3 deletions tests/test_python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from openmc_depletion_plotter import find_most_abundant_nuclides_in_materials
from openmc_depletion_plotter import find_most_active_nuclides_in_material
from openmc_depletion_plotter import find_most_active_nuclides_in_materials
from openmc_depletion_plotter import get_nuclide_atom_densities_from_materials
from openmc_depletion_plotter import get_nuclide_atoms_from_materials
import openmc


Expand Down Expand Up @@ -64,10 +64,12 @@ def test_two_identical_materials():
my_mat = openmc.Material()
my_mat.add_nuclide("Li6", 1)
my_mat.add_nuclide("Li7", 0.5)
my_mat.volume = 1

my_mat_2 = openmc.Material()
my_mat_2.add_nuclide("Li6", 1)
my_mat_2.add_nuclide("Li7", 0.5)
my_mat_2.volume = 1

nucs = find_most_abundant_nuclides_in_materials(
materials=[my_mat, my_mat_2],
Expand All @@ -81,10 +83,12 @@ def test_two_similar_materials():
my_mat = openmc.Material()
my_mat.add_nuclide("Li6", 0.5)
my_mat.add_nuclide("Li7", 0.5)
my_mat.volume = 1

my_mat_2 = openmc.Material()
my_mat_2.add_nuclide("Li6", 0.6)
my_mat_2.add_nuclide("Li7", 0.7)
my_mat_2.volume = 1

nucs = find_most_abundant_nuclides_in_materials(
materials=[my_mat, my_mat_2],
Expand All @@ -98,10 +102,12 @@ def test_openmc_material():
my_mat = openmc.Material()
my_mat.add_nuclide("Li6", 0.5)
my_mat.add_nuclide("Li7", 0.5)
my_mat.volume = 1

my_mat_2 = openmc.Material()
my_mat_2.add_nuclide("Fe56", 0.6)
my_mat_2.add_nuclide("Be9", 0.6)
my_mat_2.volume = 1

nucs = find_most_abundant_nuclides_in_materials(
materials=[my_mat, my_mat_2], exclude=my_mat
Expand All @@ -115,10 +121,12 @@ def test_openmc_material_shared_isotope():
my_mat = openmc.Material()
my_mat.add_nuclide("Li6", 0.5)
my_mat.add_nuclide("Li7", 0.5)
my_mat.volume = 1

my_mat_2 = openmc.Material()
my_mat_2.add_nuclide("Fe56", 0.6)
my_mat_2.add_nuclide("Li7", 0.6)
my_mat_2.volume = 1

nucs = find_most_abundant_nuclides_in_materials(
materials=[my_mat, my_mat_2], exclude=my_mat
Expand All @@ -127,17 +135,19 @@ def test_openmc_material_shared_isotope():
assert nucs == ["Fe56"]


def test_get_nuclide_atom_densities_from_materials():
def test_get_nuclide_atoms_from_materials():

my_mat = openmc.Material()
my_mat.add_nuclide("Li6", 0.5)
my_mat.add_nuclide("Li7", 0.5)
my_mat.volume = 1

my_mat_2 = openmc.Material()
my_mat_2.add_nuclide("Fe56", 0.6)
my_mat_2.add_nuclide("Li7", 0.6)
my_mat_2.volume = 1

nucs = get_nuclide_atom_densities_from_materials(
nucs = get_nuclide_atoms_from_materials(
nuclides=["Li6", "Fe56"], materials=[my_mat, my_mat_2]
)

Expand Down