Major updates to mgxs.py with preliminary testing. Scattering matrices not yet working

This commit is contained in:
Will Boyd 2015-09-09 19:32:26 -04:00
parent 13b3632c31
commit 9ebc5d6793
6 changed files with 472 additions and 205 deletions

View file

@ -1 +1,2 @@
from groups import EnergyGroups
from groups import EnergyGroups
from mgxs import *

View file

@ -11,6 +11,7 @@ import openmc.checkvalue as cv
if sys.version_info[0] >= 3:
basestring = str
class EnergyGroups(object):
"""An energy groups structure used for multi-group cross-sections.
@ -37,10 +38,10 @@ class EnergyGroups(object):
def __deepcopy__(self, memo):
existing = memo.get(id(self))
# If this is the first time we have tried to copy this object, create a copy
# If this is the first time we have tried to copy object, create copy
if existing is None:
clone = type(self).__new__(type(self))
clone.group_edges = copy.deepcopy(self._group_edges, memo)
clone.group_edges = copy.deepcopy(self.group_edges, memo)
memo[id(self)] = clone
@ -60,18 +61,18 @@ class EnergyGroups(object):
@group_edges.setter
def group_edges(self, edges):
cv.check_type('group edges', edges, Iterable, Integral)
cv.check_length('number of group edges', edges, 2)
cv.check_type('group edges', edges, Iterable, Real)
cv.check_greater_than('number of group edges', len(edges), 1)
self._group_edges = np.array(edges)
self._num_groups = len(edges)-1
def __eq__(self, other):
if not isinstance(other, EnergyGroups):
return False
elif self._group_edges != other._group_edges:
elif self.group_edges != other.group_edges:
return False
def generate_bin_edges(self, start, stop, num_groups, type='linear'):
def generate_bin_edges(self, start, stop, num_groups, spacing='linear'):
"""Generate equally or logarithmically-spaced energy group boundaries.
Parameters
@ -82,7 +83,7 @@ class EnergyGroups(object):
The highest energy in MeV
num_groups : Integral
The number of energy groups
type : str
spacing : str
The spacing between groups ('linear' or 'logarithmic')
"""
@ -90,15 +91,15 @@ class EnergyGroups(object):
cv.check_type('first edge', start, Real)
cv.check_type('last edge', stop, Real)
cv.check_type('number of groups', num_groups, Integral)
cv.check_type('type', type, basestring)
cv.check_type('spacing', spacing, basestring)
cv.check_greater_than('first edge', start, 0, True)
cv.check_greater_than('first edge', stop, start, False)
cv.check_greater_than('number of groups', num_groups, 0)
cv.check_value('type', type, ('linear', 'logarithmic'))
cv.check_value('spacing', spacing, ('linear', 'logarithmic'))
if type == 'linear':
if spacing == 'linear':
self.group_edges = np.linspace(start, stop, num_groups+1)
elif type == 'logarithmic':
elif spacing == 'logarithmic':
self.group_edges = \
np.logspace(np.log10(start), np.log10(stop), num_groups+1)
@ -160,7 +161,7 @@ class EnergyGroups(object):
lower = self.group_edges[self.num_groups-group]
upper = self.group_edges[self.num_groups-group+1]
return (lower, upper)
return lower, upper
def get_group_indices(self, groups='all'):
"""Returns the array indices for one or more energy groups.

File diff suppressed because it is too large Load diff

View file

@ -663,6 +663,8 @@ class StatePoint(object):
# Iterate over all tallies to find the appropriate one
for tally_id, test_tally in self.tallies.items():
print(test_tally)
# Determine if Tally has queried name
if name and name != test_tally.name:
continue
@ -673,6 +675,7 @@ class StatePoint(object):
# Determine if Tally has queried estimator
if estimator and not estimator == test_tally.estimator:
print('estimator')
continue
# Determine if Tally has the queried score(s)
@ -686,6 +689,7 @@ class StatePoint(object):
break
if not contains_scores:
print('scores')
continue
# Determine if Tally has the queried Filter(s)
@ -699,6 +703,7 @@ class StatePoint(object):
break
if not contains_filters:
print('filters')
continue
# Determine if Tally has the queried Nuclide(s)
@ -712,6 +717,7 @@ class StatePoint(object):
break
if not contains_nuclides:
print('nuclides')
continue
# If the current Tally met user's request, break loop and return it

View file

@ -264,7 +264,7 @@ class Summary(object):
if maps > 0:
offset = self._f['geometry/cells'][key]['offset'][...]
cell.set_offset(offset)
cell.offsets = offset
translated = self._f['geometry/cells'][key]['translated'][0]
if translated:

View file

@ -114,10 +114,10 @@ class Tally(object):
clone.estimator = self.estimator
clone.num_score_bins = self.num_score_bins
clone.num_realizations = self.num_realizations
clone._sum = copy.deepcopy(self.sum, memo)
clone._sum_sq = copy.deepcopy(self.sum_sq, memo)
clone._mean = copy.deepcopy(self.mean, memo)
clone._std_dev = copy.deepcopy(self.std_dev, memo)
clone._sum = copy.deepcopy(self._sum, memo)
clone._sum_sq = copy.deepcopy(self._sum_sq, memo)
clone._mean = copy.deepcopy(self._mean, memo)
clone._std_dev = copy.deepcopy(self._std_dev, memo)
clone._with_summary = self.with_summary
clone._with_batch_statistics = self.with_batch_statistics
clone._derived = self.derived
@ -828,7 +828,7 @@ class Tally(object):
parameter (e.g., [(1,), (0., 0.625e-6)]; default is []). Each bin
in the list is the integer ID for 'material', 'surface', 'cell',
'cellborn', and 'universe' Filters. Each bin is an integer for the
cell instance ID for 'distribcell Filters. Each bin is a 2-tuple of
cell instance ID for 'distribcell' Filters. Each bin is a 2-tuple of
floats for 'energy' and 'energyout' filters corresponding to the
energy boundaries of the bin of interest. The bin is a (x,y,z)
3-tuple for 'mesh' filters corresponding to the mesh cell of
@ -2128,6 +2128,14 @@ class TalliesFile(object):
self._meshes = []
self._tallies_file = ET.Element("tallies")
@property
def tallies(self):
return self._tallies
@property
def meshes(self):
return self._meshes
def add_tally(self, tally, merge=False):
"""Add a tally to the file