Address @wbinventor comments on #821

This commit is contained in:
Paul Romano 2017-03-06 19:54:23 -06:00
parent b19a4c5ec4
commit cda58c9e8f
7 changed files with 455 additions and 510 deletions

File diff suppressed because one or more lines are too long

View file

@ -80,11 +80,11 @@ class Cell(object):
If the cell is filled with a universe, this array specifies a vector
that is used to translate (shift) the universe.
paths : list of str
The paths traversed through the CSG tree to reach each cell instance
The paths traversed through the CSG tree to reach each cell
instance. This property is initialized by calling the
:meth:`Geometry.determine_paths` method.
num_instances : int
The number of instances of this cell throughout the geometry. This
property is initialized by calling the
:meth:`Geometry.count_cell_instances` method.
The number of instances of this cell throughout the geometry.
volume : float
Volume of the cell in cm^3. This can either be set manually or
calculated in a stochastic volume calculation and added via the

View file

@ -43,7 +43,7 @@ class Geometry(object):
def root_universe(self, root_universe):
check_type('root universe', root_universe, openmc.Universe)
self._root_universe = root_universe
self.determine_paths()
self._determine_paths()
def add_volume_information(self, volume_calc):
"""Add volume information from a stochastic volume calculation.
@ -114,7 +114,6 @@ class Geometry(object):
Parameters
----------
path : str
The path traversed through the CSG tree to reach a cell or material
instance. For example, 'u0->c10->l20(2,2,1)->u5->c5' would indicate
the cell instance whose first level is universe 0 and cell 10,
@ -441,10 +440,14 @@ class Geometry(object):
lattices.sort(key=lambda x: x.id)
return lattices
def determine_paths(self):
"""Count the number of instances for each cell in the Geometry, and
record the count in the :attr:`Cell.num_instances` properties."""
def _determine_paths(self):
"""Determine paths through CSG tree for cells and materials.
This method recursively traverses the CSG tree to determine each unique
path that reaches every cell and material. The paths are stored in the
:attr:`Cell.paths` and :attr:`Material.paths` attributes.
"""
# (Re-)initialize all cell instances to 0
for cell in self.get_all_cells().values():
cell._paths = []

View file

@ -372,7 +372,10 @@ class Lattice(object):
Parameters
----------
idx : Iterable of int
Lattice element indices in the :math:`(x,y,z)` coordinate system
Lattice element indices. For a rectangular lattice, the indices are
given in the :math:`(x,y)` or :math:`(x,y,z)` coordinate system. For
hexagonal lattices, they are given in the :math:`x,\alpha` or
:math:`x,\alpha,z` coordinate systems.
Returns
-------
@ -392,7 +395,7 @@ class Lattice(object):
Parameters
----------
point : 3-tuple of float
Cartesian coordinatesof the point
Cartesian coordinates of the point
Returns
-------
@ -537,6 +540,13 @@ class RectLattice(Lattice):
@property
def _natural_indices(self):
"""Iterate over all possible (x,y) or (x,y,z) lattice element indices.
This property is used when constructing distributed cell and material
paths. Most importantly, the iteration order matches that used on the
Fortran side.
"""
if self.ndim == 2:
nx, ny = self.shape
return np.broadcast(*np.ogrid[:nx, :ny])
@ -889,6 +899,14 @@ class HexLattice(Lattice):
@property
def _natural_indices(self):
"""Iterate over all possible (x,alpha) or (x,alpha,z) lattice element
indices.
This property is used when constructing distributed cell and material
paths. Most importantly, the iteration order matches that used on the
Fortran side.
"""
r = self.num_rings
if self.num_axial is None:
for a in range(-r + 1, r):

View file

@ -75,10 +75,12 @@ class Material(object):
Volume of the material in cm^3. This can either be set manually or
calculated in a stochastic volume calculation and added via the
:meth:`Material.add_volume_information` method.
paths : list of str
The paths traversed through the CSG tree to reach each material
instance. This property is initialized by calling the
:meth:`Geometry.determine_paths` method.
num_instances : int
The number of instances of this material throughout the geometry. This
property is initialized by calling the
:meth:`Geometry.count_material_instances` method.
The number of instances of this material throughout the geometry.
"""

View file

@ -1333,8 +1333,6 @@ contains
n = size(univ % cells)
do i = 1, n
! get pointer to cell
associate (c => cells(univ % cells(i)))
c % instances = c % instances + 1

View file

@ -2020,7 +2020,7 @@ contains
do i = 1, n_cells
! Get index in universes array
j = universe_dict%get_key(cells(i) % universe)
j = universe_dict % get_key(cells(i) % universe)
! Set the first zero entry in the universe cells array to the index in the
! global cells array