changed np.arange to range in mgxs.py and added mesh domain to library.py

This commit is contained in:
samuel shaner 2016-07-30 19:59:07 +00:00
parent ef0cbebbaa
commit 3a6d2b1aee
2 changed files with 17 additions and 7 deletions

View file

@ -54,9 +54,10 @@ class Library(object):
If true, computes cross sections for each nuclide in each domain
mgxs_types : Iterable of str
The types of cross sections in the library (e.g., ['total', 'scatter'])
domain_type : {'material', 'cell', 'distribcell', 'universe'}
domain_type : {'material', 'cell', 'distribcell', 'universe', 'mesh'}
Domain type for spatial homogenization
domains : Iterable of openmc.Material, openmc.Cell or openmc.Universe
domains : Iterable of openmc.Material, openmc.Cell, openmc.Universe or
openmc.Mesh
The spatial domain(s) for which MGXS in the Library are computed
correction : {'P0', None}
Apply the P0 correction to scattering matrices if set to 'P0'
@ -183,6 +184,8 @@ class Library(object):
return self.openmc_geometry.get_all_material_cells()
elif self.domain_type == 'universe':
return self.openmc_geometry.get_all_universes()
elif self.domain_type == 'mesh':
raise ValueError('Unable to get domains for Mesh domain type')
else:
raise ValueError('Unable to get domains without a domain type')
else:
@ -273,6 +276,11 @@ class Library(object):
elif self.domain_type == 'universe':
cv.check_iterable_type('domain', domains, openmc.Universe)
all_domains = self.openmc_geometry.get_all_universes()
elif self.domain_type == 'mesh':
cv.check_iterable_type('domain', domains, openmc.Mesh)
# The mesh and geometry are independent, so just return
return
else:
raise ValueError('Unable to set domains with domain '
'type "{}"'.format(self.domain_type))
@ -474,6 +482,8 @@ class Library(object):
cv.check_type('domain', domain, (openmc.Cell, Integral))
elif self.domain_type == 'universe':
cv.check_type('domain', domain, (openmc.Universe, Integral))
elif self.domain_type == 'mesh':
cv.check_type('domain', domain, (openmc.Mesh, Integral))
# Check that requested domain is included in library
if isinstance(domain, Integral):

View file

@ -694,7 +694,7 @@ class MGXS(object):
# NOTE: This is important if tally merging was used
if self.domain_type == 'mesh':
filters = [self.domain_type]
xyz = [np.arange(1, x+1) for x in self.domain.dimension]
xyz = [range(1, x+1) for x in self.domain.dimension]
filter_bins = [tuple(itertools.product(*xyz))]
elif self.domain_type != 'distribcell':
filters = [self.domain_type]
@ -1157,7 +1157,7 @@ class MGXS(object):
elif self.domain_type == 'distribcell':
subdomains = np.arange(self.num_subdomains, dtype=np.int)
elif self.domain_type == 'mesh':
xyz = [np.arange(1, x+1) for x in self.domain.dimension]
xyz = [range(1, x+1) for x in self.domain.dimension]
subdomains = list(itertools.product(*xyz))
else:
subdomains = [self.domain.id]
@ -1295,7 +1295,7 @@ class MGXS(object):
domain_filter = self.xs_tally.find_filter('avg(distribcell)')
subdomains = domain_filter.bins
elif self.domain_type == 'mesh':
xyz = [np.arange(1, x+1) for x in self.domain.dimension]
xyz = [range(1, x+1) for x in self.domain.dimension]
subdomains = list(itertools.product(*xyz))
else:
subdomains = [self.domain.id]
@ -1924,7 +1924,7 @@ class MatrixMGXS(MGXS):
elif self.domain_type == 'distribcell':
subdomains = np.arange(self.num_subdomains, dtype=np.int)
elif self.domain_type == 'mesh':
xyz = [np.arange(1, x+1) for x in self.domain.dimension]
xyz = [range(1, x+1) for x in self.domain.dimension]
subdomains = list(itertools.product(*xyz))
else:
subdomains = [self.domain.id]
@ -3773,7 +3773,7 @@ class ScatterMatrixXS(MatrixMGXS):
elif self.domain_type == 'distribcell':
subdomains = np.arange(self.num_subdomains, dtype=np.int)
elif self.domain_type == 'mesh':
xyz = [np.arange(1, x+1) for x in self.domain.dimension]
xyz = [range(1, x+1) for x in self.domain.dimension]
subdomains = list(itertools.product(*xyz))
else:
subdomains = [self.domain.id]