Moved get_thermal_name(...) from scripts to openmc.data.thermal

This commit is contained in:
Will Boyd 2016-08-11 13:38:56 -04:00
parent 12c8672804
commit fe63a59c5b
3 changed files with 25 additions and 21 deletions

View file

@ -40,6 +40,26 @@ _THERMAL_NAMES = {'al': 'c_Al27', 'al27': 'c_Al27',
'zrzrh': 'c_Zr_in_ZrH', 'zr-h': 'c_Zr_in_ZrH', 'zr/h': 'c_Zr_in_ZrH'}
def get_thermal_name(name):
"""Get proper S(a,b) table name, e.g. 'HH2O' -> 'c_H_in_H2O'"""
if name.lower() in _THERMAL_NAMES:
return _THERMAL_NAMES[name.lower()]
else:
# Make an educated guess?? This actually works well for
# JEFF-3.2 which stupidly uses names like lw00.32t,
# lw01.32t, etc. for different temperatures
matches = get_close_matches(
name.lower(), _THERMAL_NAMES.keys(), cutoff=0.5)
if len(matches) > 0:
return _THERMAL_NAMES[matches[0]] + '.' + xs
else:
# OK, we give up. Just use the ACE name.
return 'c_' + name
return name
class CoherentElastic(object):
r"""Coherent elastic scattering data from a crystalline material
@ -394,4 +414,4 @@ class ThermalScattering(object):
pairs = np.fromiter(map(lambda p: p[0], ace.pairs), int)
table.zaids = pairs[np.nonzero(pairs)]
return table
return table

View file

@ -6,6 +6,7 @@ from xml.etree import ElementTree as ET
import sys
import openmc
import openmc.data
import openmc.checkvalue as cv
from openmc.clean_xml import sort_xml_elements, clean_xml_indentation
@ -484,7 +485,7 @@ class Material(object):
'non-string cross-section identifier "{1}"'.format(self._id, xs)
raise ValueError(msg)
self._sab.append((name, xs))
self._sab.append((openmc.data.get_thermal_name(name), xs))
def make_isotropic_in_lab(self):
for nuclide, percent, percent_type in self._nuclides:

View file

@ -253,23 +253,6 @@ def update_geometry(geometry_root):
return was_updated
def get_thermal_name(name):
"""Get proper S(a,b) table name, e.g. 'HH2O' -> 'c_H_in_H2O'"""
if name.lower() in _THERMAL_NAMES:
return _THERMAL_NAMES[name.lower()]
else:
# Make an educated guess?? This actually works well for
# JEFF-3.2 which stupidly uses names like lw00.32t,
# lw01.32t, etc. for different temperatures
matches = get_close_matches(
name.lower(), _THERMAL_NAMES.keys(), cutoff=0.5)
if len(matches) > 0:
return _THERMAL_NAMES[matches[0]] + '.' + xs
else:
# OK, we give up. Just use the ACE name.
return 'c_' + name
return name
def update_materials(root):
"""Update the given XML materials tree. Return True if changes were made."""
was_updated = False
@ -298,13 +281,13 @@ def update_materials(root):
for sab in material.findall('sab'):
if 'name' in sab.attrib:
sabname = sab.attrib['name']
sab.set('name', get_thermal_name(sabname))
sab.set('name', openmc.data.get_thermal_name(sabname))
was_updated = True
elif sab.find('name') is not None:
name_elem = sab.find('name')
sabname = name_elem.text
name_elem.text = get_thermal(sabname)
name_elem.text = openmc.data.get_thermal_name(sabname)
was_updated = True
return was_updated