diff --git a/openmc/material.py b/openmc/material.py index e495357b5..4f60abc67 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -132,9 +132,12 @@ class Material(object): @name.setter def name(self, name): - check_type('name for Material ID="{0}"'.format(self._id), - name, basestring) - self._name = name + if name is not None: + check_type('name for Material ID="{0}"'.format(self._id), + name, basestring) + self._name = name + else: + self._name = None def set_density(self, units, density=NO_DENSITY): """Set the density of the material diff --git a/openmc/mesh.py b/openmc/mesh.py index 3c5bef848..7c2a62583 100644 --- a/openmc/mesh.py +++ b/openmc/mesh.py @@ -150,8 +150,12 @@ class Mesh(object): @name.setter def name(self, name): - cv.check_type('name for mesh ID="{0}"'.format(self._id), name, basestring) - self._name = name + if name is not None: + check_type('name for mesh ID="{0}"'.format(self._id), + name, basestring) + self._name = name + else: + self._name = None @type.setter def type(self, meshtype): diff --git a/openmc/opencg_compatible.py b/openmc/opencg_compatible.py index 65e980c00..9448ff29a 100644 --- a/openmc/opencg_compatible.py +++ b/openmc/opencg_compatible.py @@ -83,14 +83,14 @@ def get_opencg_material(openmc_material): raise ValueError(msg) global OPENCG_MATERIALS - material_id = openmc_material._id + material_id = openmc_material.id # If this Material was already created, use it if material_id in OPENCG_MATERIALS: return OPENCG_MATERIALS[material_id] # Create an OpenCG Material to represent this OpenMC Material - name = openmc_material._name + name = openmc_material.name opencg_material = opencg.Material(material_id=material_id, name=name) # Add the OpenMC Material to the global collection of all OpenMC Materials @@ -123,14 +123,14 @@ def get_openmc_material(opencg_material): raise ValueError(msg) global OPENMC_MATERIALS - material_id = opencg_material._id + material_id = opencg_material.id # If this Material was already created, use it if material_id in OPENMC_MATERIALS: return OPENMC_MATERIALS[material_id] # Create an OpenMC Material to represent this OpenCG Material - name = opencg_material._name + name = opencg_material.name openmc_material = openmc.Material(material_id=material_id, name=name) # Add the OpenMC Material to the global collection of all OpenMC Materials @@ -168,8 +168,8 @@ def is_opencg_surface_compatible(opencg_surface): 'since "{0}" is not a Surface'.format(opencg_surface) raise ValueError(msg) - if opencg_surface._type in ['x-squareprism', - 'y-squareprism', 'z-squareprism']: + if opencg_surface.type in ['x-squareprism', + 'y-squareprism', 'z-squareprism']: return False else: return True @@ -196,59 +196,59 @@ def get_opencg_surface(openmc_surface): raise ValueError(msg) global OPENCG_SURFACES - surface_id = openmc_surface._id + surface_id = openmc_surface.id # If this Material was already created, use it if surface_id in OPENCG_SURFACES: return OPENCG_SURFACES[surface_id] # Create an OpenCG Surface to represent this OpenMC Surface - name = openmc_surface._name + name = openmc_surface.name # Correct for OpenMC's syntax for Surfaces dividing Cells - boundary = openmc_surface._boundary_type + boundary = openmc_surface.boundary_type if boundary == 'transmission': boundary = 'interface' opencg_surface = None - if openmc_surface._type == 'plane': - A = openmc_surface._coeffs['A'] - B = openmc_surface._coeffs['B'] - C = openmc_surface._coeffs['C'] - D = openmc_surface._coeffs['D'] + if openmc_surface.type == 'plane': + A = openmc_surface.coeffs['A'] + B = openmc_surface.coeffs['B'] + C = openmc_surface.coeffs['C'] + D = openmc_surface.coeffs['D'] opencg_surface = opencg.Plane(surface_id, name, boundary, A, B, C, D) - elif openmc_surface._type == 'x-plane': - x0 = openmc_surface._coeffs['x0'] + elif openmc_surface.type == 'x-plane': + x0 = openmc_surface.coeffs['x0'] opencg_surface = opencg.XPlane(surface_id, name, boundary, x0) - elif openmc_surface._type == 'y-plane': - y0 = openmc_surface._coeffs['y0'] + elif openmc_surface.type == 'y-plane': + y0 = openmc_surface.coeffs['y0'] opencg_surface = opencg.YPlane(surface_id, name, boundary, y0) - elif openmc_surface._type == 'z-plane': - z0 = openmc_surface._coeffs['z0'] + elif openmc_surface.type == 'z-plane': + z0 = openmc_surface.coeffs['z0'] opencg_surface = opencg.ZPlane(surface_id, name, boundary, z0) - elif openmc_surface._type == 'x-cylinder': - y0 = openmc_surface._coeffs['y0'] - z0 = openmc_surface._coeffs['z0'] - R = openmc_surface._coeffs['R'] + elif openmc_surface.type == 'x-cylinder': + y0 = openmc_surface.coeffs['y0'] + z0 = openmc_surface.coeffs['z0'] + R = openmc_surface.coeffs['R'] opencg_surface = opencg.XCylinder(surface_id, name, boundary, y0, z0, R) - elif openmc_surface._type == 'y-cylinder': - x0 = openmc_surface._coeffs['x0'] - z0 = openmc_surface._coeffs['z0'] - R = openmc_surface._coeffs['R'] + elif openmc_surface.type == 'y-cylinder': + x0 = openmc_surface.coeffs['x0'] + z0 = openmc_surface.coeffs['z0'] + R = openmc_surface.coeffs['R'] opencg_surface = opencg.YCylinder(surface_id, name, boundary, x0, z0, R) - elif openmc_surface._type == 'z-cylinder': - x0 = openmc_surface._coeffs['x0'] - y0 = openmc_surface._coeffs['y0'] - R = openmc_surface._coeffs['R'] + elif openmc_surface.type == 'z-cylinder': + x0 = openmc_surface.coeffs['x0'] + y0 = openmc_surface.coeffs['y0'] + R = openmc_surface.coeffs['R'] opencg_surface = opencg.ZCylinder(surface_id, name, boundary, x0, y0, R) @@ -282,61 +282,61 @@ def get_openmc_surface(opencg_surface): raise ValueError(msg) global openmc_surface - surface_id = opencg_surface._id + surface_id = opencg_surface.id # If this Surface was already created, use it if surface_id in OPENMC_SURFACES: return OPENMC_SURFACES[surface_id] # Create an OpenMC Surface to represent this OpenCG Surface - name = opencg_surface._name + name = opencg_surface.name # Correct for OpenMC's syntax for Surfaces dividing Cells - boundary = opencg_surface._boundary_type + boundary = opencg_surface.boundary_type if boundary == 'interface': boundary = 'transmission' - if opencg_surface._type == 'plane': - A = opencg_surface._coeffs['A'] - B = opencg_surface._coeffs['B'] - C = opencg_surface._coeffs['C'] - D = opencg_surface._coeffs['D'] + if opencg_surface.type == 'plane': + A = opencg_surface.coeffs['A'] + B = opencg_surface.coeffs['B'] + C = opencg_surface.coeffs['C'] + D = opencg_surface.coeffs['D'] openmc_surface = openmc.Plane(surface_id, boundary, A, B, C, D, name) - elif opencg_surface._type == 'x-plane': - x0 = opencg_surface._coeffs['x0'] + elif opencg_surface.type == 'x-plane': + x0 = opencg_surface.coeffs['x0'] openmc_surface = openmc.XPlane(surface_id, boundary, x0, name) - elif opencg_surface._type == 'y-plane': - y0 = opencg_surface._coeffs['y0'] + elif opencg_surface.type == 'y-plane': + y0 = opencg_surface.coeffs['y0'] openmc_surface = openmc.YPlane(surface_id, boundary, y0, name) - elif opencg_surface._type == 'z-plane': - z0 = opencg_surface._coeffs['z0'] + elif opencg_surface.type == 'z-plane': + z0 = opencg_surface.coeffs['z0'] openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name) - elif opencg_surface._type == 'x-cylinder': - y0 = opencg_surface._coeffs['y0'] - z0 = opencg_surface._coeffs['z0'] - R = opencg_surface._coeffs['R'] + elif opencg_surface.type == 'x-cylinder': + y0 = opencg_surface.coeffs['y0'] + z0 = opencg_surface.coeffs['z0'] + R = opencg_surface.coeffs['R'] openmc_surface = openmc.XCylinder(surface_id, boundary, y0, z0, R, name) - elif opencg_surface._type == 'y-cylinder': - x0 = opencg_surface._coeffs['x0'] - z0 = opencg_surface._coeffs['z0'] - R = opencg_surface._coeffs['R'] + elif opencg_surface.type == 'y-cylinder': + x0 = opencg_surface.coeffs['x0'] + z0 = opencg_surface.coeffs['z0'] + R = opencg_surface.coeffs['R'] openmc_surface = openmc.YCylinder(surface_id, boundary, x0, z0, R, name) - elif opencg_surface._type == 'z-cylinder': - x0 = opencg_surface._coeffs['x0'] - y0 = opencg_surface._coeffs['y0'] - R = opencg_surface._coeffs['R'] + elif opencg_surface.type == 'z-cylinder': + x0 = opencg_surface.coeffs['x0'] + y0 = opencg_surface.coeffs['y0'] + R = opencg_surface.coeffs['R'] openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R, name) else: msg = 'Unable to create an OpenMC Surface from an OpenCG ' \ 'Surface of type "{0}" since it is not a compatible ' \ - 'Surface type in OpenMC'.format(opencg_surface._type) + 'Surface type in OpenMC'.format(opencg_surface.type) raise ValueError(msg) # Add the OpenMC Surface to the global collection of all OpenMC Surfaces @@ -373,20 +373,20 @@ def get_compatible_opencg_surfaces(opencg_surface): raise ValueError(msg) global OPENMC_SURFACES - surface_id = opencg_surface._id + surface_id = opencg_surface.id # If this Surface was already created, use it if surface_id in OPENMC_SURFACES: return OPENMC_SURFACES[surface_id] # Create an OpenMC Surface to represent this OpenCG Surface - name = opencg_surface._name - boundary = opencg_surface._boundary_type + name = opencg_surface.name + boundary = opencg_surface.boundary_type - if opencg_surface._type == 'x-squareprism': - y0 = opencg_surface._coeffs['y0'] - z0 = opencg_surface._coeffs['z0'] - R = opencg_surface._coeffs['R'] + if opencg_surface.type == 'x-squareprism': + y0 = opencg_surface.coeffs['y0'] + z0 = opencg_surface.coeffs['z0'] + R = opencg_surface.coeffs['R'] # Create a list of the four planes we need left = opencg.YPlane(name=name, boundary=boundary, y0=y0-R) @@ -395,10 +395,10 @@ def get_compatible_opencg_surfaces(opencg_surface): top = opencg.ZPlane(name=name, boundary=boundary, z0=z0+R) surfaces = [left, right, bottom, top] - elif opencg_surface._type == 'y-squareprism': - x0 = opencg_surface._coeffs['x0'] - z0 = opencg_surface._coeffs['z0'] - R = opencg_surface._coeffs['R'] + elif opencg_surface.type == 'y-squareprism': + x0 = opencg_surface.coeffs['x0'] + z0 = opencg_surface.coeffs['z0'] + R = opencg_surface.coeffs['R'] # Create a list of the four planes we need left = opencg.XPlane(name=name, boundary=boundary, x0=x0-R) @@ -407,10 +407,10 @@ def get_compatible_opencg_surfaces(opencg_surface): top = opencg.ZPlane(name=name, boundary=boundary, z0=z0+R) surfaces = [left, right, bottom, top] - elif opencg_surface._type == 'z-squareprism': - x0 = opencg_surface._coeffs['x0'] - y0 = opencg_surface._coeffs['y0'] - R = opencg_surface._coeffs['R'] + elif opencg_surface.type == 'z-squareprism': + x0 = opencg_surface.coeffs['x0'] + y0 = opencg_surface.coeffs['y0'] + R = opencg_surface.coeffs['R'] # Create a list of the four planes we need left = opencg.XPlane(name=name, boundary=boundary, x0=x0-R) @@ -422,7 +422,7 @@ def get_compatible_opencg_surfaces(opencg_surface): else: msg = 'Unable to create a compatible OpenMC Surface an OpenCG ' \ 'Surface of type "{0}" since it already a compatible ' \ - 'Surface type in OpenMC'.format(opencg_surface._type) + 'Surface type in OpenMC'.format(opencg_surface.type) raise ValueError(msg) # Add the OpenMC Surface(s) to the global collection of all OpenMC Surfaces @@ -455,37 +455,39 @@ def get_opencg_cell(openmc_cell): raise ValueError(msg) global OPENCG_CELLS - cell_id = openmc_cell._id + cell_id = openmc_cell.id # If this Cell was already created, use it if cell_id in OPENCG_CELLS: return OPENCG_CELLS[cell_id] # Create an OpenCG Cell to represent this OpenMC Cell - name = openmc_cell._name + name = openmc_cell.name opencg_cell = opencg.Cell(cell_id, name) - fill = openmc_cell._fill + fill = openmc_cell.fill - if (openmc_cell._type == 'normal'): - opencg_cell.setFill(get_opencg_material(fill)) - elif (openmc_cell._type == 'fill'): - opencg_cell.setFill(get_opencg_universe(fill)) + print(openmc_cell.fill_type) + + if (openmc_cell.fill_type == 'material'): + opencg_cell.fill = get_opencg_material(fill) + elif (openmc_cell.fill_type == 'universe'): + opencg_cell.fill = get_opencg_universe(fill) else: - opencg_cell.setFill(get_opencg_lattice(fill)) + opencg_cell.fill = get_opencg_lattice(fill) - if openmc_cell._rotation is not None: - opencg_cell.setRotation(openmc_cell._rotation) + if openmc_cell.rotation is not None: + opencg_cell.rotation = openmc_cell.rotation - if openmc_cell._translation is not None: - opencg_cell.setTranslation(openmc_cell._translation) + if openmc_cell.translation is not None: + opencg_cell.translation = openmc_cell.translation - surfaces = openmc_cell._surfaces + surfaces = openmc_cell.surfaces for surface_id in surfaces: surface = surfaces[surface_id][0] halfspace = surfaces[surface_id][1] - opencg_cell.addSurface(get_opencg_surface(surface), halfspace) + opencg_cell.add_surface(get_opencg_surface(surface), halfspace) # Add the OpenMC Cell to the global collection of all OpenMC Cells OPENMC_CELLS[cell_id] = openmc_cell @@ -536,8 +538,8 @@ def get_compatible_opencg_cells(opencg_cell, opencg_surface, halfspace): compatible_cells = [] # SquarePrism Surfaces - if opencg_surface._type in ['x-squareprism', 'y-squareprism', - 'z-squareprism']: + if opencg_surface.type in ['x-squareprism', 'y-squareprism', + 'z-squareprism']: # Get the compatible Surfaces (XPlanes and YPlanes) compatible_surfaces = get_compatible_opencg_surfaces(opencg_surface) @@ -546,10 +548,10 @@ def get_compatible_opencg_cells(opencg_cell, opencg_surface, halfspace): # If Cell is inside SquarePrism, add "inside" of Surface halfspaces if halfspace == -1: - opencg_cell.addSurface(compatible_surfaces[0], +1) - opencg_cell.addSurface(compatible_surfaces[1], -1) - opencg_cell.addSurface(compatible_surfaces[2], +1) - opencg_cell.addSurface(compatible_surfaces[3], -1) + opencg_cell.add_surface(compatible_surfaces[0], +1) + opencg_cell.add_surface(compatible_surfaces[1], -1) + opencg_cell.add_surface(compatible_surfaces[2], +1) + opencg_cell.add_surface(compatible_surfaces[3], -1) compatible_cells.append(opencg_cell) # If Cell is outside SquarePrism, add "outside" of Surface halfspaces @@ -631,12 +633,12 @@ def make_opencg_cells_compatible(opencg_universe): raise ValueError(msg) # Check all OpenCG Cells in this Universe for compatibility with OpenMC - opencg_cells = opencg_universe._cells + opencg_cells = opencg_universe.cells for cell_id, opencg_cell in opencg_cells.items(): # Check each of the OpenCG Surfaces for OpenMC compatibility - surfaces = opencg_cell._surfaces + surfaces = opencg_cell.surfaces for surface_id in surfaces: surface = surfaces[surface_id][0] @@ -659,7 +661,7 @@ def make_opencg_cells_compatible(opencg_universe): opencg_universe.removeCell(opencg_cell) # Add the compatible OpenCG Cells to the Universe - opencg_universe.addCells(cells) + opencg_universe.add_cells(cells) # Make recursive call to look at the updated state of the # OpenCG Universe and return @@ -690,34 +692,34 @@ def get_openmc_cell(opencg_cell): raise ValueError(msg) global OPENMC_CELLS - cell_id = opencg_cell._id + cell_id = opencg_cell.id # If this Cell was already created, use it if cell_id in OPENMC_CELLS: return OPENMC_CELLS[cell_id] # Create an OpenCG Cell to represent this OpenMC Cell - name = opencg_cell._name + name = opencg_cell.name openmc_cell = openmc.Cell(cell_id, name) - fill = opencg_cell._fill + fill = opencg_cell.fill - if (opencg_cell._type == 'universe'): + if (opencg_cell.type == 'universe'): openmc_cell.fill = get_openmc_universe(fill) - elif (opencg_cell._type == 'lattice'): + elif (opencg_cell.type == 'lattice'): openmc_cell.fill = get_openmc_lattice(fill) else: openmc_cell.fill = get_openmc_material(fill) - if opencg_cell._rotation: - rotation = np.asarray(opencg_cell._rotation, dtype=np.int) + if opencg_cell.rotation: + rotation = np.asarray(opencg_cell.rotation, dtype=np.int) openmc_cell.rotation = rotation - if opencg_cell._translation: - translation = np.asarray(opencg_cell._translation, dtype=np.float64) + if opencg_cell.translation: + translation = np.asarray(opencg_cell.translation, dtype=np.float64) openmc_cell.setTranslation(translation) - surfaces = opencg_cell._surfaces + surfaces = opencg_cell.surfaces for surface_id in surfaces: surface = surfaces[surface_id][0] @@ -754,22 +756,22 @@ def get_opencg_universe(openmc_universe): raise ValueError(msg) global OPENCG_UNIVERSES - universe_id = openmc_universe._id + universe_id = openmc_universe.id # If this Universe was already created, use it if universe_id in OPENCG_UNIVERSES: return OPENCG_UNIVERSES[universe_id] # Create an OpenCG Universe to represent this OpenMC Universe - name = openmc_universe._name + name = openmc_universe.name opencg_universe = opencg.Universe(universe_id, name) # Convert all OpenMC Cells in this Universe to OpenCG Cells - openmc_cells = openmc_universe._cells + openmc_cells = openmc_universe.cells for cell_id, openmc_cell in openmc_cells.items(): opencg_cell = get_opencg_cell(openmc_cell) - opencg_universe.addCell(opencg_cell) + opencg_universe.add_cell(opencg_cell) # Add the OpenMC Universe to the global collection of all OpenMC Universes OPENMC_UNIVERSES[universe_id] = openmc_universe @@ -801,7 +803,7 @@ def get_openmc_universe(opencg_universe): raise ValueError(msg) global OPENMC_UNIVERSES - universe_id = opencg_universe._id + universe_id = opencg_universe.id # If this Universe was already created, use it if universe_id in OPENMC_UNIVERSES: @@ -811,11 +813,11 @@ def get_openmc_universe(opencg_universe): make_opencg_cells_compatible(opencg_universe) # Create an OpenMC Universe to represent this OpenCSg Universe - name = opencg_universe._name + name = opencg_universe.name openmc_universe = openmc.Universe(universe_id, name) # Convert all OpenCG Cells in this Universe to OpenMC Cells - opencg_cells = opencg_universe._cells + opencg_cells = opencg_universe.cells for cell_id, opencg_cell in opencg_cells.items(): openmc_cell = get_openmc_cell(opencg_cell) @@ -851,7 +853,7 @@ def get_opencg_lattice(openmc_lattice): raise ValueError(msg) global OPENCG_LATTICES - lattice_id = openmc_lattice._id + lattice_id = openmc_lattice.id # If this Lattice was already created, use it if lattice_id in OPENCG_LATTICES: @@ -888,7 +890,7 @@ def get_opencg_lattice(openmc_lattice): for z in range(dimension[2]): for y in range(dimension[1]): for x in range(dimension[0]): - universe_id = universes[x][dimension[1]-y-1][z]._id + universe_id = universes[x][dimension[1]-y-1][z].id universe_array[z][y][x] = unique_universes[universe_id] opencg_lattice = opencg.Lattice(lattice_id, name) @@ -931,23 +933,23 @@ def get_openmc_lattice(opencg_lattice): raise ValueError(msg) global OPENMC_LATTICES - lattice_id = opencg_lattice._id + lattice_id = opencg_lattice.id # If this Lattice was already created, use it if lattice_id in OPENMC_LATTICES: return OPENMC_LATTICES[lattice_id] - dimension = opencg_lattice._dimension - width = opencg_lattice._width - offset = opencg_lattice._offset - universes = opencg_lattice._universes + dimension = opencg_lattice.dimension + width = opencg_lattice.width + offset = opencg_lattice.offset + universes = opencg_lattice.universes # Initialize an empty array for the OpenMC nested Universes in this Lattice universe_array = np.ndarray(tuple(np.array(dimension)), dtype=openmc.Universe) # Create OpenMC Universes for each unique nested Universe in this Lattice - unique_universes = opencg_lattice.getUniqueUniverses() + unique_universes = opencg_lattice.get_unique_universes() for universe_id, universe in unique_universes.items(): unique_universes[universe_id] = get_openmc_universe(universe) @@ -956,7 +958,7 @@ def get_openmc_lattice(opencg_lattice): for z in range(dimension[2]): for y in range(dimension[1]): for x in range(dimension[0]): - universe_id = universes[z][y][x]._id + universe_id = universes[z][y][x].id universe_array[x][y][z] = unique_universes[universe_id] # Reverse y-dimension in array to match ordering in OpenCG @@ -1011,12 +1013,12 @@ def get_opencg_geometry(openmc_geometry): OPENMC_LATTICES.clear() OPENCG_LATTICES.clear() - openmc_root_universe = openmc_geometry._root_universe + openmc_root_universe = openmc_geometry.root_universe opencg_root_universe = get_opencg_universe(openmc_root_universe) opencg_geometry = opencg.Geometry() - opencg_geometry.setRootUniverse(opencg_root_universe) - opencg_geometry.initializeCellOffsets() + opencg_geometry.root_universe = opencg_root_universe + opencg_geometry.initialize_cell_offsets() return opencg_geometry @@ -1043,11 +1045,11 @@ def get_openmc_geometry(opencg_geometry): # Deep copy the goemetry since it may be modified to make all Surfaces # compatible with OpenMC's specifications - opencg_geometry.assignAutoIds() + opencg_geometry.assign_auto_ids() opencg_geometry = copy.deepcopy(opencg_geometry) # Update Cell bounding boxes in Geometry - opencg_geometry.updateBoundingBoxes() + opencg_geometry.update_bounding_boxes() # Clear dictionaries and auto-generated ID OPENMC_SURFACES.clear() @@ -1060,14 +1062,14 @@ def get_openmc_geometry(opencg_geometry): OPENCG_LATTICES.clear() # Make the entire geometry "compatible" before assigning auto IDs - universes = opencg_geometry.getAllUniverses() + universes = opencg_geometry.get_all_universes() for universe_id, universe in universes.items(): if not isinstance(universe, opencg.Lattice): make_opencg_cells_compatible(universe) - opencg_geometry.assignAutoIds() + opencg_geometry.assign_auto_ids() - opencg_root_universe = opencg_geometry._root_universe + opencg_root_universe = opencg_geometry.root_universe openmc_root_universe = get_openmc_universe(opencg_root_universe) openmc_geometry = openmc.Geometry() diff --git a/openmc/surface.py b/openmc/surface.py index 653754d30..164bbd09b 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -101,8 +101,11 @@ class Surface(object): @name.setter def name(self, name): - check_type('surface name', name, basestring) - self._name = name + if name is not None: + check_type('surface name', name, basestring) + self._name = name + else: + self._name = None @boundary_type.setter def boundary_type(self, boundary_type): diff --git a/openmc/tallies.py b/openmc/tallies.py index d15be7983..5ea0aa8ea 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -379,8 +379,11 @@ class Tally(object): @name.setter def name(self, name): - cv.check_type('tally name', name, basestring) - self._name = name + if name is not None: + cv.check_type('tally name', name, basestring) + self._name = name + else: + self._name = None def add_filter(self, filter): """Add a filter to the tally diff --git a/openmc/universe.py b/openmc/universe.py index bab10f5df..ef89780e1 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -85,8 +85,15 @@ class Cell(object): return self._fill @property - def type(self): - return self._fill + def fill_type(self): + if isinstance(self.fill, openmc.Material): + return 'material' + elif isinstance(self.fill, openmc.Universe): + return 'universe' + elif isinstance(self.fill, openmc.Lattice): + return 'lattice' + else: + return None @property def surfaces(self): @@ -117,8 +124,11 @@ class Cell(object): @name.setter def name(self, name): - cv.check_type('cell name', name, basestring) - self._name = name + if name is not None: + cv.check_type('cell name', name, basestring) + self._name = name + else: + self._name = None @fill.setter def fill(self, fill): @@ -438,8 +448,11 @@ class Universe(object): @name.setter def name(self, name): - cv.check_type('universe name', name, basestring) - self._name = name + if name is not None: + cv.check_type('universe name', name, basestring) + self._name = name + else: + self._name = None def add_cell(self, cell): """Add a cell to the universe. @@ -677,8 +690,11 @@ class Lattice(object): @name.setter def name(self, name): - cv.check_type('lattice name', name, basestring) - self._name = name + if name is not None: + cv.check_type('lattice name', name, basestring) + self._name = name + else: + self._name = None @outer.setter def outer(self, outer):