Incorporating Legendre scattering to Library and Mgxs_library modules (and example nbook).

This commit is contained in:
Adam Nelson 2016-05-17 05:35:55 -04:00
parent 058ba68895
commit 16886a41d9
3 changed files with 198 additions and 142 deletions

File diff suppressed because one or more lines are too long

View file

@ -460,7 +460,7 @@ class Library(object):
----------
domain : Material or Cell or Universe or Integral
The material, cell, or universe object of interest (or its ID)
mgxs_type : {'total', 'transport', 'absorption', 'capture', 'fission', 'nu-fission', 'kappa-fission', 'scatter', 'nu-scatter', 'scatter matrix', 'nu-scatter matrix', 'chi'}
mgxs_type : {'total', 'transport', 'nu-transport', 'absorption', 'capture', 'fission', 'nu-fission', 'kappa-fission', 'scatter', 'nu-scatter', 'scatter matrix', 'nu-scatter matrix', 'chi'}
The type of multi-group cross section object to return
Returns
@ -773,9 +773,9 @@ class Library(object):
nuclide this will be set to 'macro' regardless.
xs_ids : str
Cross section set identifier. Defaults to '1m'.
order : Scattering order for this dataset entry. Default is None,
which will force the XSdata object to use whatever the maximum
order available.
order : Scattering order for this data entry. Default is None,
which will force the XSdata object to use whatever the order of the
Library object is.
Returns
-------
@ -801,7 +801,8 @@ class Library(object):
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
cv.check_type('xs_id', xs_id, basestring)
cv.check_type('order', order, (type(None), Integral))
cv.check_greater_than('order', order, -1, equality=True)
if order is not None:
cv.check_greater_than('order', order, 0, equality=True)
# Make sure statepoint has been loaded
if self._sp_filename is None:
@ -819,20 +820,22 @@ class Library(object):
name += '_' + nuclide
name += '.' + xs_id
xsdata = openmc.XSdata(name, self.energy_groups)
if order is 0:
xsdata.order = order
if order is None:
# Set the order to the Library's order (the defualt behavior)
xsdata.order = self.legendre_order
else:
msg = 'Generating anisotropic scattering from openmc.Library' \
'objects has not yet been implemented.'
raise NotImplementedError(msg)
# Set the order of the xsdata object to the minimum of
# the provided order or the Library's order.
xsdata.order = min(order, self.legendre_order)
if nuclide is not 'total':
xsdata.zaid = self._nuclides[nuclide][0]
xsdata.awr = self._nuclides[nuclide][1]
# Now get xs data itself
if 'transport' in self.mgxs_types:
mymgxs = self.get_mgxs(domain, 'transport')
if ('nu-transport' in self.mgxs_types) and (self.correction == 'P0'):
mymgxs = self.get_mgxs(domain, 'nu-transport')
xsdata.set_total_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide])
elif 'total' in self.mgxs_types:
mymgxs = self.get_mgxs(domain, 'total')
@ -949,10 +952,6 @@ class Library(object):
# Initialize file
mgxs_file = openmc.MGXSLibrary(self.energy_groups)
# Set the scattering order as isotropic until
# support for higher orders are included in openmc.mgxs
order = 0
# Create the xsdata object and add it to the mgxs_file
for i, domain in enumerate(self.domains):
if self.by_nuclide:
@ -969,8 +968,7 @@ class Library(object):
xsdata_name += '_' + nuclide
xsdata = self.get_xsdata(domain, xsdata_name, nuclide=nuclide,
xs_type=xs_type, xs_id=xs_ids[i],
order=order)
xs_type=xs_type, xs_id=xs_ids[i])
mgxs_file.add_xsdata(xsdata)
@ -1031,10 +1029,10 @@ class Library(object):
# Total or transport can be present, but if using
# self.correction=="P0", then we should use transport.
if (((self.correction is "P0") and
('transport' not in self.mgxs_types))):
('nu-transport' not in self.mgxs_types))):
error_flag = True
msg = 'Transport MGXS type is required since a "P0" correction ' \
'is applied, but a Transport MGXS is not provided.'
msg = 'NuTransport MGXS type is required since a "P0" correction' \
' is applied, but a Transport MGXS is not provided.'
warn(msg)
elif (((self.correction is None) and
('total' not in self.mgxs_types))):

View file

@ -829,7 +829,8 @@ class XSdata(object):
def set_scatter_mgxs(self, scatter, nuclide='total', xs_type='macro'):
"""This method allows for an openmc.mgxs.ScatterMatrixXS
to be used to set the scatter matrix cross section for this XSdata
object.
object. If the XsData.order attribute has not yet been set, then
it will be set based on the properties of scatter.
Parameters
----------
@ -856,9 +857,35 @@ class XSdata(object):
check_value('domain_type', scatter.domain_type,
['universe', 'cell', 'material'])
# Methods of representing anisotropic scattering besides
# Legendre expansions have not been implemented yet in openmc.mgxs.
# Therefore check to make sure the XsData has been set to
# legendre scattering.
if (self.scatt_type != 'legendre'):
msg = 'Anisotrpic scattering representations other than ' \
'Legendre expansions have not yet been implemented in ' \
'openmc.mgxs.'
raise ValueError(msg)
# If the user has not defined XsData.order, then we will set
# the order based on the data within scatter.
# Otherwise, we will check to see that XsData.order to match
# the order of scatter
if self.order is None:
self.order = scatter.legendre_order
else:
check_value('legendre_order', scatter.legendre_order,
[self.order])
if self._representation is 'isotropic':
self._scatter = np.array([scatter.get_xs(nuclides=nuclide,
xs_type=xs_type)])
# Get the scattering orders in the outermost dimension
self._scatter = np.zeros((self.num_orders,
self.energy_groups.num_groups,
self.energy_groups.num_groups))
for moment in range(self.num_orders):
self._scatter[moment, :, :] = scatter.get_xs(nuclides=nuclide,
xs_type=xs_type,
moment=moment)
elif self._representation is 'angle':
msg = 'Angular-Dependent MGXS have not yet been implemented'
@ -908,10 +935,12 @@ class XSdata(object):
['universe', 'cell', 'material'])
if self._representation is 'isotropic':
# import pdb; pdb.set_trace()
nuscatt = nuscatter.get_xs(nuclides=nuclide,
xs_type=xs_type)
xs_type=xs_type, moment=0)
scatt = scatter.get_xs(nuclides=nuclide,
xs_type=xs_type)
xs_type=xs_type, moment=0)
self._multiplicity = np.divide(nuscatt, scatt)
elif self._representation is 'angle':
msg = 'Angular-Dependent MGXS have not yet been implemented'
@ -969,7 +998,8 @@ class XSdata(object):
if self._tabular_legendre is not None:
subelement = ET.SubElement(element, 'tabular_legendre')
subelement.set('enable', str(self._tabular_legendre['enable']))
subelement.set('num_points', str(self._tabular_legendre['num_points']))
subelement.set('num_points',
str(self._tabular_legendre['num_points']))
if self._total is not None:
subelement = ET.SubElement(element, 'total')