mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
added optional nuclide to atom densities
This commit is contained in:
parent
2805060ddd
commit
085125ef86
2 changed files with 21 additions and 7 deletions
|
|
@ -825,9 +825,15 @@ class Material(IDManagerMixin):
|
|||
|
||||
return nuclides
|
||||
|
||||
def get_nuclide_atom_densities(self):
|
||||
"""Returns all nuclides in the material and their atomic densities in
|
||||
units of atom/b-cm
|
||||
def get_nuclide_atom_densities(self, nuclide: Optional[str] = None):
|
||||
"""Returns one or all nuclides in the material and their atomic
|
||||
densities in units of atom/b-cm
|
||||
|
||||
Parameters
|
||||
----------
|
||||
nuclides : str, optional
|
||||
Nuclide for which atom density is desired. If not specified, the
|
||||
atom density for the all the material is given.
|
||||
|
||||
.. versionchanged:: 0.13.1
|
||||
The values in the dictionary were changed from a tuple containing
|
||||
|
|
@ -862,10 +868,11 @@ class Material(IDManagerMixin):
|
|||
nuc_densities = []
|
||||
nuc_density_types = []
|
||||
|
||||
for nuclide in self.nuclides:
|
||||
nucs.append(nuclide.name)
|
||||
nuc_densities.append(nuclide.percent)
|
||||
nuc_density_types.append(nuclide.percent_type)
|
||||
for loop_nuclide in self.nuclides:
|
||||
if nuclide is None or nuclide == loop_nuclide.name:
|
||||
nucs.append(loop_nuclide.name)
|
||||
nuc_densities.append(loop_nuclide.percent)
|
||||
nuc_density_types.append(loop_nuclide.percent_type)
|
||||
|
||||
nucs = np.array(nucs)
|
||||
nuc_densities = np.array(nuc_densities)
|
||||
|
|
|
|||
|
|
@ -339,6 +339,13 @@ def test_get_nuclide_atom_densities(uo2):
|
|||
assert density > 0
|
||||
|
||||
|
||||
def test_get_specific_nuclide_atom_densities(uo2):
|
||||
print(uo2)
|
||||
nuc = uo2.get_nuclide_atom_densities(nuclide='O16')
|
||||
assert list(nuc.keys()) == ['O16']
|
||||
assert list(nuc.values())[0] > 0
|
||||
|
||||
|
||||
def test_get_nuclide_atoms():
|
||||
mat = openmc.Material()
|
||||
mat.add_nuclide('Li6', 1.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue