mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Adding data_type kwarg to DataLibrary.get_by_material
Co-Authored-By: Paul Romano <paul.k.romano@gmail.com> Update tests/unit_tests/test_data_misc.py Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
abe5596cb3
commit
2b1380519d
3 changed files with 11 additions and 6 deletions
|
|
@ -23,13 +23,16 @@ class DataLibrary(EqualityMixin):
|
|||
def __init__(self):
|
||||
self.libraries = []
|
||||
|
||||
def get_by_material(self, name):
|
||||
def get_by_material(self, name, data_type='neutron'):
|
||||
"""Return the library dictionary containing a given material.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
name : str
|
||||
Name of material, e.g. 'Am241'
|
||||
data_type : str
|
||||
Name of data type, e.g. 'neutron', 'photon', 'wmp',
|
||||
or 'thermal'
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
|
@ -39,7 +42,7 @@ class DataLibrary(EqualityMixin):
|
|||
|
||||
"""
|
||||
for library in self.libraries:
|
||||
if name in library['materials']:
|
||||
if name in library['materials'] and data_type in library['type']:
|
||||
return library
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -562,14 +562,16 @@ def _calculate_cexs_elem_mat(this, types, temperature=294.,
|
|||
if isinstance(this, openmc.Material):
|
||||
for sab_name in this._sab:
|
||||
sab = openmc.data.ThermalScattering.from_hdf5(
|
||||
library.get_by_material(sab_name)['path'])
|
||||
library.get_by_material(sab_name, data_type='thermal')['path'])
|
||||
for nuc in sab.nuclides:
|
||||
sabs[nuc] = library.get_by_material(sab_name)['path']
|
||||
sabs[nuc] = library.get_by_material(sab_name,
|
||||
data_type='thermal')['path']
|
||||
else:
|
||||
if sab_name:
|
||||
sab = openmc.data.ThermalScattering.from_hdf5(sab_name)
|
||||
for nuc in sab.nuclides:
|
||||
sabs[nuc] = library.get_by_material(sab_name)['path']
|
||||
sabs[nuc] = library.get_by_material(sab_name,
|
||||
data_type='thermal')['path']
|
||||
|
||||
# Now we can create the data sets to be plotted
|
||||
xs = {}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ def test_data_library(tmpdir):
|
|||
assert f['type'] == 'neutron'
|
||||
assert 'U235' in f['materials']
|
||||
|
||||
f = lib.get_by_material('c_H_in_H2O')
|
||||
f = lib.get_by_material('c_H_in_H2O', data_type='thermal')
|
||||
assert f['type'] == 'thermal'
|
||||
assert 'c_H_in_H2O' in f['materials']
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue