def get_openmc_cell(openmoc_cell): """Return an OpenMC cell corresponding to an OpenMOC cell. Parameters ---------- openmoc_cell : openmoc.Cell OpenMOC cell Returns ------- openmc_cell : openmc.Cell Equivalent OpenMC cell """ cv.check_type('openmoc_cell', openmoc_cell, openmoc.Cell) cell_id = openmoc_cell.getId() # If this Cell was already created, use it if cell_id in OPENMC_CELLS: return OPENMC_CELLS[cell_id] # Create an OpenMOC Cell to represent this OpenMC Cell name = openmoc_cell.getName() openmc_cell = openmc.Cell(cell_id, name) if openmoc_cell.getType() == openmoc.MATERIAL: fill = openmoc_cell.getFillMaterial() openmc_cell.fill = get_openmc_material(fill) elif openmoc_cell.getType() == openmoc.FILL: fill = openmoc_cell.getFillUniverse() if fill.getType() == openmoc.LATTICE: fill = openmoc.castUniverseToLattice(fill) openmc_cell.fill = get_openmc_lattice(fill) else: openmc_cell.fill = get_openmc_universe(fill) if openmoc_cell.isRotated(): # get rotation for each of 3 axes rotation = openmoc_cell.retrieveRotation(3) openmc_cell.rotation = rotation if openmoc_cell.isTranslated(): # get translation for each of 3 axes translation = openmoc_cell.retrieveTranslation(3) openmc_cell.translation = translation # Convert OpenMC's cell region to an equivalent OpenMOC region openmoc_region = openmoc_cell.getRegion() if openmoc_region is not None: openmc_cell.region = get_openmc_region(openmoc_region) # Add the OpenMC Cell to the global collection of all OpenMC Cells OPENMC_CELLS[cell_id] = openmc_cell # Add the OpenMOC Cell to the global collection of all OpenMOC Cells OPENMOC_CELLS[cell_id] = openmoc_cell return openmc_cell
def get_openmc_cell(openmoc_cell): """Return an OpenMC cell corresponding to an OpenMOC cell. Parameters ---------- openmoc_cell : openmoc.Cell OpenMOC cell Returns ------- openmc_cell : openmc.Cell Equivalent OpenMC cell """ cv.check_type('openmoc_cell', openmoc_cell, openmoc.Cell) cell_id = openmoc_cell.getId() # If this Cell was already created, use it if cell_id in OPENMC_CELLS: return OPENMC_CELLS[cell_id] # Create an OpenMOC Cell to represent this OpenMC Cell name = openmoc_cell.getName() openmc_cell = openmc.Cell(cell_id, name) if (openmoc_cell.getType() == openmoc.MATERIAL): fill = openmoc_cell.getFillMaterial() openmc_cell.fill = get_openmc_material(fill) elif (openmoc_cell.getType() == openmoc.FILL): fill = openmoc_cell.getFillUniverse() if fill.getType() == openmoc.LATTICE: fill = openmoc.castUniverseToLattice(fill) openmc_cell.fill = get_openmc_lattice(fill) else: openmc_cell.fill = get_openmc_universe(fill) if openmoc_cell.isRotated(): rotation = openmoc_cell.retrieveRotation(3) openmc_cell.rotation = rotation if openmoc_cell.isTranslated(): translation = openmoc_cell.retrieveTranslation(3) openmc_cell.translation = translation # Convert OpenMC's cell region to an equivalent OpenMOC region openmoc_region = openmoc_cell.getRegion() if openmoc_region is not None: openmc_cell.region = get_openmc_region(openmoc_region) # Add the OpenMC Cell to the global collection of all OpenMC Cells OPENMC_CELLS[cell_id] = openmc_cell # Add the OpenMOC Cell to the global collection of all OpenMOC Cells OPENMOC_CELLS[cell_id] = openmoc_cell return openmc_cell
def _create_geometry(self): """Put a box source """ self.input_set.create_materials() self.input_set.create_geometry() # Get the root Cell cells = self.input_set.geometry.getAllCells() for cell_id in cells: cell = cells[cell_id] if cell.getName() == 'root cell': root_cell = cell # Apply VACUUM BCs on all bounding surfaces surfaces = root_cell.getSurfaces() for surface_id in surfaces: surface = surfaces[surface_id]._surface surface.setBoundaryType(openmoc.VACUUM) # Replace fissionable infinite medium material with C5G7 water self.materials = \ openmoc.materialize.load_from_hdf5(filename='c5g7-mgxs.h5', directory='../../sample-input/') lattice = openmoc.castUniverseToLattice(root_cell.getFillUniverse()) num_x = lattice.getNumX() num_y = lattice.getNumY() width_x = lattice.getWidthX() width_y = lattice.getWidthY() # Create cells filled with water to put in Lattice water_cell = openmoc.Cell(name='water') water_cell.setFill(self.materials['Water']) water_univ = openmoc.Universe(name='water') water_univ.addCell(water_cell) self.source_cell = openmoc.Cell(name='source') self.source_cell.setFill(self.materials['Water']) source_univ = openmoc.Universe(name='source') source_univ.addCell(self.source_cell) # Create 2D array of Universes in each lattice cell universes = [[[water_univ]*num_x for _ in range(num_y)]] # Place fixed source Universe at (x=0.5, y=0.5) source_x = 0.5 source_y = 0.5 lat_x = (root_cell.getMaxX() - source_x) / width_x lat_y = (root_cell.getMaxY() - source_y) / width_y universes[0][int(lat_x)][int(lat_y)] = source_univ # Create a new Lattice for the Universes lattice = openmoc.Lattice(name='{0}x{1} lattice'.format(num_x, num_y)) lattice.setWidth(width_x=width_x, width_y=width_y) lattice.setUniverses(universes) root_cell.setFill(lattice)
def _create_geometry(self): """Put a box source in the cube.""" self.input_set.create_materials() self.input_set.create_geometry() # Get the root Cell cells = self.input_set.geometry.getAllCells() for cell_id in cells: cell = cells[cell_id] if cell.getName() == 'root cell': root_cell = cell # Apply VACUUM BCs on all bounding surfaces surfaces = root_cell.getSurfaces() for surface_id in surfaces: surface = surfaces[surface_id]._surface surface.setBoundaryType(openmoc.VACUUM) # Replace fissionable infinite medium material with C5G7 water self.materials = \ openmoc.materialize.load_from_hdf5(filename='c5g7-mgxs.h5', directory='../../sample-input/') lattice = openmoc.castUniverseToLattice(root_cell.getFillUniverse()) num_x = lattice.getNumX() num_y = lattice.getNumY() width_x = lattice.getWidthX() width_y = lattice.getWidthY() # Create cells filled with water to put in Lattice water_cell = openmoc.Cell(name='water') water_cell.setFill(self.materials['Water']) water_univ = openmoc.Universe(name='water') water_univ.addCell(water_cell) self.source_cell = openmoc.Cell(name='source') self.source_cell.setFill(self.materials['Water']) source_univ = openmoc.Universe(name='source') source_univ.addCell(self.source_cell) # Create 2D array of Universes in each lattice cell universes = [[[water_univ]*num_x for _ in range(num_y)]] # Place fixed source Universe at (x=0.5, y=0.5) source_x = 0.5 source_y = 0.5 lat_x = (root_cell.getMaxX() - source_x) / width_x lat_y = (root_cell.getMaxY() - source_y) / width_y universes[0][int(lat_x)][int(lat_y)] = source_univ # Create a new Lattice for the Universes lattice = openmoc.Lattice(name='{0}x{1} lattice'.format(num_x, num_y)) lattice.setWidth(width_x=width_x, width_y=width_y) lattice.setUniverses(universes) root_cell.setFill(lattice)
def _get_results(self, num_iters=False, keff=False, fluxes=False, num_fsrs=False, num_tracks=False, num_segments=False, hash_output=False): """Create Meshes from a lattice and return their shapes as a string""" # Find the test oblong lattice all_cells = harness.input_set.geometry.getAllCells().values() root_cell = get_cell_by_name(all_cells, "root cell") ulat = root_cell.getFillUniverse() lat = openmoc.castUniverseToLattice(ulat) meshes = [None] * 2 meshes[0] = process.Mesh.from_lattice(lat) meshes[1] = process.Mesh.from_lattice(lat, division=2) # Append mesh properties to the output string fmt_str = \ "Mesh {mesh_num}:\n" \ "{dimension}\n" \ "{width}\n" \ "{lleft}\n" \ "{uright}\n" outstr = "" for i, mesh in enumerate(meshes): outstr += fmt_str.format(mesh_num=i + 1, dimension=mesh.dimension, width=mesh.width, lleft=mesh.lower_left, uright=mesh.upper_right) return outstr