Remove offsets, distribcell_index, distribcell_paths

This commit is contained in:
Paul Romano 2017-03-06 12:19:26 -06:00
parent 4cd527cb16
commit 2d1897a051
15 changed files with 41 additions and 187 deletions

View file

@ -38,9 +38,6 @@ The current version of the summary file format is 5.0.
is an array if the cell uses distributed materials, otherwise it is
a scalar.
- **temperature** (*double[]*) -- Temperature of the cell in Kelvin.
- **offset** (*int[]*) -- Offsets used for distribcell tally
filter. This dataset is present only if fill_type is set to
'universe'.
- **translation** (*double[3]*) -- Translation applied to the fill
universe. This dataset is present only if fill_type is set to
'universe'.
@ -50,15 +47,6 @@ The current version of the summary file format is 5.0.
- **lattice** (*int*) -- Unique ID of the lattice which fills the
cell. Only present if fill_type is set to 'lattice'.
- **region** (*char[]*) -- Region specification for the cell.
- **distribcell_index** (*int*) -- Index of this cell in distribcell
arrays. Only present if this cell is listed in a distribcell filter
or if it uses distributed materials.
- **paths** (*char[][]*) -- The paths traversed through the CSG tree
to reach each distribcell instance. This consists of the integer
IDs for each universe, cell and lattice delimited by '->'. Each
lattice cell is specified by its (x,y) or (x,y,z) indices. Only
present if this cell is listed in a distribcell filter or if it
uses distributed materials.
**/geometry/surfaces/surface <uid>/**
@ -87,7 +75,6 @@ The current version of the summary file format is 5.0.
- **pitch** (*double[]*) -- Pitch of the lattice in centimeters.
- **outer** (*int*) -- Outer universe assigned to lattice cells
outside the defined range.
- **offsets** (*int[]*) -- Offsets used for distribcell tally filter.
- **universes** (*int[][][]*) -- Three-dimensional array of universes
assigned to each cell of the lattice.
- **dimension** (*int[]*) -- The number of lattice cells in each

View file

@ -79,13 +79,8 @@ class Cell(object):
translation : Iterable of float
If the cell is filled with a universe, this array specifies a vector
that is used to translate (shift) the universe.
offsets : ndarray
Array of offsets used for distributed cell searches
distribcell_index : int
Index of this cell in distribcell arrays
distribcell_paths : list of str
The paths traversed through the CSG tree to reach each distribcell
instance
paths : list of str
The paths traversed through the CSG tree to reach each cell instance
num_instances : int
The number of instances of this cell throughout the geometry. This
property is initialized by calling the
@ -107,9 +102,6 @@ class Cell(object):
self._rotation_matrix = None
self._temperature = None
self._translation = None
self._offsets = None
self._distribcell_index = None
self._distribcell_paths = None
self._paths = []
self._volume = None
self._atoms = None
@ -167,8 +159,6 @@ class Cell(object):
string += '\t{0: <15}=\t{1}\n'.format('Temperature',
self.temperature)
string += '{: <16}=\t{}\n'.format('\tTranslation', self.translation)
string += '{: <16}=\t{}\n'.format('\tOffset', self.offsets)
string += '{: <16}=\t{}\n'.format('\tDistribcell index', self.distribcell_index)
return string
@ -217,18 +207,6 @@ class Cell(object):
def translation(self):
return self._translation
@property
def offsets(self):
return self._offsets
@property
def distribcell_index(self):
return self._distribcell_index
@property
def distribcell_paths(self):
return self._distribcell_paths
@property
def volume(self):
return self._volume
@ -332,11 +310,6 @@ class Cell(object):
else:
self._temperature = temperature
@offsets.setter
def offsets(self, offsets):
cv.check_type('cell offsets', offsets, Iterable)
self._offsets = offsets
@region.setter
def region(self, region):
if region is not None:
@ -349,17 +322,6 @@ class Cell(object):
cv.check_type('cell volume', volume, Real)
self._volume = volume
@distribcell_index.setter
def distribcell_index(self, ind):
cv.check_type('distribcell index', ind, Integral)
self._distribcell_index = ind
@distribcell_paths.setter
def distribcell_paths(self, distribcell_paths):
cv.check_iterable_type('distribcell_paths', distribcell_paths,
string_types)
self._distribcell_paths = distribcell_paths
def add_surface(self, surface, halfspace):
"""Add a half-space to the list of half-spaces whose intersection defines the
cell.

View file

@ -395,7 +395,7 @@ class Filter(object):
Keyword arguments
-----------------
distribcell_paths : bool
paths : bool
Only used for DistirbcellFilter. If True (default), expand
distribcell indices into multi-index columns describing the path
to that distribcell through the CSG tree. NOTE: This option assumes
@ -1095,14 +1095,14 @@ class DistribcellFilter(Filter):
stride : Integral
The number of filter, nuclide and score bins within each of this
filter's bins.
distribcell_paths : list of str
paths : list of str
The paths traversed through the CSG tree to reach each distribcell
instance (for 'distribcell' filters only)
"""
def __init__(self, bins):
self._distribcell_paths = None
self._paths = None
super(DistribcellFilter, self).__init__(bins)
@classmethod
@ -1115,20 +1115,16 @@ class DistribcellFilter(Filter):
out = cls(group['bins'].value)
out.num_bins = group['n_bins'].value
if 'paths' in group:
out.distribcell_paths = [str(path.decode()) for path in
group['paths'].value]
return out
@property
def distribcell_paths(self):
return self._distribcell_paths
def paths(self):
return self._paths
@distribcell_paths.setter
def distribcell_paths(self, distribcell_paths):
cv.check_iterable_type('distribcell_paths', distribcell_paths, str)
self._distribcell_paths = distribcell_paths
@paths.setter
def paths(self, paths):
cv.check_iterable_type('paths', paths, str)
self._paths = paths
def check_bins(self, bins):
if not len(bins) == 1:
@ -1163,7 +1159,7 @@ class DistribcellFilter(Filter):
Keyword arguments
-----------------
distribcell_paths : bool
paths : bool
If True (default), expand distribcell indices into multi-index
columns describing the path to that distribcell through the CSG
tree. NOTE: This option assumes that all distribcell paths are of
@ -1201,21 +1197,21 @@ class DistribcellFilter(Filter):
level_df = None
distribcell_paths = kwargs.setdefault('distribcell_paths', True)
paths = kwargs.setdefault('paths', True)
# Create Pandas Multi-index columns for each level in CSG tree
if distribcell_paths:
if paths:
# Distribcell paths require linked metadata from the Summary
if self.distribcell_paths is None:
if self.paths is None:
msg = 'Unable to construct distribcell paths since ' \
'the Summary is not linked to the StatePoint'
raise ValueError(msg)
# Make copy of array of distribcell paths to use in
# Pandas Multi-index column construction
num_offsets = len(self.distribcell_paths)
paths = [_path_to_levels(p) for p in self.distribcell_paths]
num_offsets = len(self.paths)
paths = [_path_to_levels(p) for p in self.paths]
# Loop over CSG levels in the distribcell paths
num_levels = len(paths[0])
@ -1561,7 +1557,7 @@ class AzimuthalFilter(RealFilter):
'increasing'.format(bins, type(self))
raise ValueError(msg)
def get_pandas_dataframe(self, data_size, distribcell_paths=True):
def get_pandas_dataframe(self, data_size, paths=True):
"""Builds a Pandas DataFrame for the Filter's bins.
This method constructs a Pandas DataFrame object for the filter with

View file

@ -132,11 +132,6 @@ class Lattice(object):
name = group['name'].value.decode() if 'name' in group else ''
lattice_type = group['type'].value.decode()
if 'offsets' in group:
offsets = group['offsets'][...]
else:
offsets = None
if lattice_type == 'rectangular':
dimension = group['dimension'][...]
lower_left = group['lower_left'][...]
@ -169,10 +164,6 @@ class Lattice(object):
# Set the universes for the lattice
lattice.universes = uarray
# Set the distribcell offsets for the lattice
if offsets is not None:
lattice.offsets = offsets
elif lattice_type == 'hexagonal':
n_rings = group['n_rings'].value
n_axial = group['n_axial'].value
@ -256,9 +247,6 @@ class Lattice(object):
# Lattice is 2D; extract the only axial level
lattice.universes = uarray[0]
if offsets is not None:
lattice.offsets = offsets
return lattice
def get_unique_universes(self):
@ -488,7 +476,6 @@ class RectLattice(Lattice):
# Initialize Lattice class attributes
self._lower_left = None
self._offsets = None
def __eq__(self, other):
if not isinstance(other, RectLattice):
@ -537,19 +524,6 @@ class RectLattice(Lattice):
string = string.rstrip('\n')
if self._offsets is not None:
string += '{0: <16}\n'.format('\tOffsets')
# Lattice cell offsets
for i, offset in enumerate(np.ravel(self._offsets)):
string += '{0} '.format(offset)
# Add a newline character when we reach end of row of cells
if (i+1) % self.shape[0] == 0:
string += '\n'
string = string.rstrip('\n')
return string
@property
@ -578,10 +552,6 @@ class RectLattice(Lattice):
def ndim(self):
return len(self.pitch)
@property
def offsets(self):
return self._offsets
@property
def shape(self):
return self._universes.shape[::-1]
@ -592,11 +562,6 @@ class RectLattice(Lattice):
cv.check_length('lattice lower left corner', lower_left, 2, 3)
self._lower_left = lower_left
@offsets.setter
def offsets(self, offsets):
cv.check_type('lattice offsets', offsets, Iterable)
self._offsets = offsets
@Lattice.pitch.setter
def pitch(self, pitch):
cv.check_type('lattice pitch', pitch, Iterable, Real)

View file

@ -774,7 +774,7 @@ class MDGXS(MGXS):
modified.write('\n\\end{document}')
def get_pandas_dataframe(self, groups='all', nuclides='all',
xs_type='macro', distribcell_paths=True,
xs_type='macro', paths=True,
delayed_groups='all'):
"""Build a Pandas DataFrame for the MDGXS data.
@ -795,7 +795,7 @@ class MDGXS(MGXS):
xs_type: {'macro', 'micro'}
Return macro or micro cross section in units of cm^-1 or barns.
Defaults to 'macro'.
distribcell_paths : bool, optional
paths : bool, optional
Construct columns for distribcell tally filters (default is True).
The geometric information in the Summary object is embedded into
a Multi-index column with a geometric "path" to each distribcell
@ -830,8 +830,7 @@ class MDGXS(MGXS):
# Use tally summation to sum across all nuclides
xs_tally = self.xs_tally.summation(nuclides=self.get_nuclides())
df = xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
df = xs_tally.get_pandas_dataframe(paths=paths)
# Remove nuclide column since it is homogeneous and redundant
if self.domain_type == 'mesh':
@ -842,13 +841,11 @@ class MDGXS(MGXS):
# If the user requested a specific set of nuclides
elif self.by_nuclide and nuclides != 'all':
xs_tally = self.xs_tally.get_slice(nuclides=nuclides)
df = xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
df = xs_tally.get_pandas_dataframe(paths=paths)
# If the user requested all nuclides, keep nuclide column in dataframe
else:
df = self.xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
df = self.xs_tally.get_pandas_dataframe(paths=paths)
# Remove the score column since it is homogeneous and redundant
if self.domain_type == 'mesh':

View file

@ -1828,7 +1828,7 @@ class MGXS(object):
modified.write('\n\\end{document}')
def get_pandas_dataframe(self, groups='all', nuclides='all',
xs_type='macro', distribcell_paths=True):
xs_type='macro', paths=True):
"""Build a Pandas DataFrame for the MGXS data.
This method leverages :meth:`openmc.Tally.get_pandas_dataframe`, but
@ -1848,7 +1848,7 @@ class MGXS(object):
xs_type: {'macro', 'micro'}
Return macro or micro cross section in units of cm^-1 or barns.
Defaults to 'macro'.
distribcell_paths : bool, optional
paths : bool, optional
Construct columns for distribcell tally filters (default is True).
The geometric information in the Summary object is embedded into
a Multi-index column with a geometric "path" to each distribcell
@ -1878,8 +1878,7 @@ class MGXS(object):
# Use tally summation to sum across all nuclides
xs_tally = self.xs_tally.summation(nuclides=self.get_nuclides())
df = xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
df = xs_tally.get_pandas_dataframe(paths=paths)
# Remove nuclide column since it is homogeneous and redundant
if self.domain_type == 'mesh':
@ -1890,13 +1889,11 @@ class MGXS(object):
# If the user requested a specific set of nuclides
elif self.by_nuclide and nuclides != 'all':
xs_tally = self.xs_tally.get_slice(nuclides=nuclides)
df = xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
df = xs_tally.get_pandas_dataframe(paths=paths)
# If the user requested all nuclides, keep nuclide column in dataframe
else:
df = self.xs_tally.get_pandas_dataframe(
distribcell_paths=distribcell_paths)
df = self.xs_tally.get_pandas_dataframe(paths=paths)
# Remove the score column since it is homogeneous and redundant
if self.domain_type == 'mesh':
@ -4136,7 +4133,7 @@ class ScatterMatrixXS(MatrixMGXS):
return xs
def get_pandas_dataframe(self, groups='all', nuclides='all', moment='all',
xs_type='macro', distribcell_paths=True):
xs_type='macro', paths=True):
"""Build a Pandas DataFrame for the MGXS data.
This method leverages :meth:`openmc.Tally.get_pandas_dataframe`, but
@ -4160,7 +4157,7 @@ class ScatterMatrixXS(MatrixMGXS):
xs_type: {'macro', 'micro'}
Return macro or micro cross section in units of cm^-1 or barns.
Defaults to 'macro'.
distribcell_paths : bool, optional
paths : bool, optional
Construct columns for distribcell tally filters (default is True).
The geometric information in the Summary object is embedded into a
Multi-index column with a geometric "path" to each distribcell
@ -4180,7 +4177,7 @@ class ScatterMatrixXS(MatrixMGXS):
"""
df = super(ScatterMatrixXS, self).get_pandas_dataframe(
groups, nuclides, xs_type, distribcell_paths)
groups, nuclides, xs_type, paths)
if self.scatter_format == 'legendre':
# Add a moment column to dataframe
@ -5188,7 +5185,7 @@ class Chi(MGXS):
return xs
def get_pandas_dataframe(self, groups='all', nuclides='all',
xs_type='macro', distribcell_paths=False):
xs_type='macro', paths=False):
"""Build a Pandas DataFrame for the MGXS data.
This method leverages :meth:`openmc.Tally.get_pandas_dataframe`, but
@ -5208,7 +5205,7 @@ class Chi(MGXS):
xs_type: {'macro', 'micro'}
Return macro or micro cross section in units of cm^-1 or barns.
Defaults to 'macro'.
distribcell_paths : bool, optional
paths : bool, optional
Construct columns for distribcell tally filters (default is True).
The geometric information in the Summary object is embedded into
a Multi-index column with a geometric "path" to each distribcell
@ -5229,7 +5226,7 @@ class Chi(MGXS):
# Build the dataframe using the parent class method
df = super(Chi, self).get_pandas_dataframe(
groups, nuclides, xs_type, distribcell_paths=distribcell_paths)
groups, nuclides, xs_type, paths=paths)
# If user requested micro cross sections, multiply by the atom
# densities to cancel out division made by the parent class method

View file

@ -649,6 +649,6 @@ class StatePoint(object):
if isinstance(tally_filter, (openmc.DistribcellFilter)):
cell_id = tally_filter.bins[0]
cell = cells[cell_id]
tally_filter.distribcell_paths = cell.paths
tally_filter.paths = cell.paths
self._summary = summary

View file

@ -121,10 +121,6 @@ class Summary(object):
cell = openmc.Cell(cell_id=cell_id, name=name)
if fill_type == 'universe':
if 'offset' in group:
offset = group['offset'][...]
cell.offsets = offset
if 'translation' in group:
translation = group['translation'][...]
translation = np.asarray(translation, dtype=np.float64)
@ -145,14 +141,6 @@ class Summary(object):
if region:
cell.region = Region.from_expression(region, surfaces)
# Get the distribcell data
if 'distribcell_index' in group:
ind = group['distribcell_index'].value
cell.distribcell_index = ind
paths = group['paths'][...]
paths = [str(path.decode()) for path in paths]
cell.distribcell_paths = paths
# Add the Cell to the global dictionary of all Cells
cells[cell.id] = cell

View file

@ -1517,8 +1517,7 @@ class Tally(object):
return data
def get_pandas_dataframe(self, filters=True, nuclides=True, scores=True,
derivative=True, distribcell_paths=True,
float_format='{:.2e}'):
derivative=True, paths=True, float_format='{:.2e}'):
"""Build a Pandas DataFrame for the Tally data.
This method constructs a Pandas DataFrame object for the Tally data
@ -1538,7 +1537,7 @@ class Tally(object):
Include columns with score bin information (default is True).
derivative : bool
Include columns with differential tally info (default is True).
distribcell_paths : bool, optional
paths : bool, optional
Construct columns for distribcell tally filters (default is True).
The geometric information in the Summary object is embedded into a
Multi-index column with a geometric "path" to each distribcell
@ -1581,7 +1580,7 @@ class Tally(object):
# Append each Filter's DataFrame to the overall DataFrame
for self_filter in self.filters:
filter_df = self_filter.get_pandas_dataframe(
data_size, distribcell_paths=distribcell_paths)
data_size, paths=paths)
df = pd.concat([df, filter_df], axis=1)
# Include DataFrame column for nuclides if user requested it

View file

@ -60,10 +60,6 @@ class Universe(object):
# Values - Cells
self._cells = OrderedDict()
# Keys - Cell IDs
# Values - Offsets
self._cell_offsets = OrderedDict()
if cells is not None:
self.add_cells(cells)

View file

@ -123,8 +123,6 @@ contains
integer(HID_T) :: lattices_group, lattice_group
real(8), allocatable :: coeffs(:)
character(:), allocatable :: region_spec
character(MAX_LINE_LEN), allocatable :: paths(:)
character(MAX_LINE_LEN) :: path
type(Cell), pointer :: c
class(Surface), pointer :: s
class(Lattice), pointer :: lat
@ -226,22 +224,6 @@ contains
end do
call write_dataset(cell_group, "region", adjustl(region_spec))
! Write distribcell data
if (c % distribcell_index /= NONE) then
call write_dataset(cell_group, "distribcell_index", &
c % distribcell_index)
allocate(paths(c % instances))
do k = 1, c % instances
path = ''
offset = 1
call find_offset(i, universes(root_universe), k, offset, path)
paths(k) = path
end do
call write_dataset(cell_group, "paths", paths)
deallocate(paths)
end if
call close_group(cell_group)
end do CELL_LOOP
@ -393,13 +375,6 @@ contains
call write_dataset(lattice_group, "outer", lat % outer)
end if
! Write distribcell offsets if present
if (allocated(lat%offset)) then
if (size(lat%offset) > 0) then
call write_dataset(lattice_group, "offsets", lat%offset)
end if
end if
select type (lat)
type is (RectLattice)
! Write lattice type.

View file

@ -1 +1 @@
3a43588f986f577151b488f64d8e7ef8e568bf9b3df923d2b8267d662d176360c99c4f3788d95676861fdb0f2ef8eb7569db37b8c6f0a849de05ae96a5844e5b
f388c07481a7333bde8044d2e8805954ec41cc3e73d00f1b92b6acff03dad06e62a74e8b7595994e877f69a051ff34d8e498de69ac0efec6e396434007c10b0c

View file

@ -90,14 +90,10 @@ class AsymmetricLatticeTestHarness(PyAPITestHarness):
# Extract fuel assembly lattices from the summary
cells = sp.summary.geometry.get_all_cells()
core = cells[1]
fuel = cells[80]
fuel = fuel.fill
core = core.fill
fuel_cell = cells[27]
# Append a string of lattice distribcell offsets to the string
outstr += ', '.join(map(str, fuel.offsets.flatten())) + '\n'
outstr += ', '.join(map(str, core.offsets.flatten())) + '\n'
outstr += '\n'.join(fuel_cell.paths) + '\n'
# Hash the results if necessary
if hash_output:

View file

@ -7,5 +7,3 @@ Cell
Region = -10000
Rotation = None
Translation = None
Offset = None
Distribcell index= 1

View file

@ -8,5 +8,3 @@ Cell
Rotation = None
Temperature = [ 500. 0. 700. 800.]
Translation = None
Offset = None
Distribcell index= 1