From 3a6d2b1aeec30334db4d810f3aef17a4b4a8a85e Mon Sep 17 00:00:00 2001 From: samuel shaner Date: Sat, 30 Jul 2016 19:59:07 +0000 Subject: [PATCH] changed np.arange to range in mgxs.py and added mesh domain to library.py --- openmc/mgxs/library.py | 14 ++++++++++++-- openmc/mgxs/mgxs.py | 10 +++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index bf822017c1..3675571584 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -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): diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index ad55f9a241..0dadab38ab 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -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]