mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Improve constructors for Universe and Cell
This commit is contained in:
parent
69ec73705b
commit
ff198abf3a
2 changed files with 16 additions and 5 deletions
|
|
@ -33,6 +33,10 @@ class Cell(object):
|
|||
automatically be assigned.
|
||||
name : str, optional
|
||||
Name of the cell. If not specified, the name is the empty string.
|
||||
fill : openmc.Material or openmc.Universe or openmc.Lattice or 'void' or iterable of openmc.Material, optional
|
||||
Indicates what the region of space is filled with
|
||||
region : openmc.Region, optional
|
||||
Region of space that is assigned to the cell.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -58,7 +62,7 @@ class Cell(object):
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, cell_id=None, name=''):
|
||||
def __init__(self, cell_id=None, name='', fill=None, region=None):
|
||||
# Initialize Cell class attributes
|
||||
self.id = cell_id
|
||||
self.name = name
|
||||
|
|
@ -70,6 +74,11 @@ class Cell(object):
|
|||
self._offsets = None
|
||||
self._distribcell_index = None
|
||||
|
||||
if fill is not None:
|
||||
self.fill = fill
|
||||
if region is not None:
|
||||
self.region = region
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Cell):
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ class Universe(object):
|
|||
automatically be assigned
|
||||
name : str, optional
|
||||
Name of the universe. If not specified, the name is the empty string.
|
||||
cells : Iterable of openmc.Cell
|
||||
Cells to add to the universe
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -49,7 +51,7 @@ class Universe(object):
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, universe_id=None, name=''):
|
||||
def __init__(self, universe_id=None, name='', cells=None):
|
||||
# Initialize Cell class attributes
|
||||
self.id = universe_id
|
||||
self.name = name
|
||||
|
|
@ -61,7 +63,9 @@ class Universe(object):
|
|||
# Keys - Cell IDs
|
||||
# Values - Offsets
|
||||
self._cell_offsets = OrderedDict()
|
||||
self._num_regions = 0
|
||||
|
||||
if cells is not None:
|
||||
self.add_cells(cells)
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Universe):
|
||||
|
|
@ -87,8 +91,6 @@ class Universe(object):
|
|||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tCells', '=\t',
|
||||
list(self._cells.keys()))
|
||||
string += '{0: <16}{1}{2}\n'.format('\t# Regions', '=\t',
|
||||
self._num_regions)
|
||||
return string
|
||||
|
||||
@property
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue