def test_ids(self): openmoc.reset_universe_id() lattice_2 = openmoc.Lattice() self.assertEqual(lattice_2.getId(), 1000016) openmoc.maximize_universe_id(10000000) lattice_3 = openmoc.Lattice() self.assertEqual(lattice_3.getId(), 10000000)
def test_ids(self): openmoc.reset_universe_id() universe_2 = openmoc.Universe() self.assertEqual(universe_2.getId(), 1000001) openmoc.maximize_universe_id(10000000) universe_3 = openmoc.Universe() self.assertEqual(universe_3.getId(), 10000000)
def get_openmoc_geometry(openmc_geometry): """Return an OpenMC geometry corresponding to an OpenMOC geometry. Parameters ---------- openmc_geometry : openmc.Geometry OpenMC geometry Returns ------- openmoc_geometry : openmoc.Geometry Equivalent OpenMOC geometry """ cv.check_type('openmc_geometry', openmc_geometry, openmc.Geometry) # Clear dictionaries and auto-generated IDs OPENMC_SURFACES.clear() OPENMOC_SURFACES.clear() OPENMC_CELLS.clear() OPENMOC_CELLS.clear() OPENMC_UNIVERSES.clear() OPENMOC_UNIVERSES.clear() OPENMC_LATTICES.clear() OPENMOC_LATTICES.clear() openmc_root_universe = openmc_geometry.root_universe openmoc_root_universe = get_openmoc_universe(openmc_root_universe) openmoc_geometry = openmoc.Geometry() openmoc_geometry.setRootUniverse(openmoc_root_universe) # Update OpenMOC's auto-generated object IDs (e.g., Surface, Material) # with the maximum of those created from the OpenMC objects all_materials = openmoc_geometry.getAllMaterials() all_surfaces = openmoc_geometry.getAllSurfaces() all_cells = openmoc_geometry.getAllCells() all_universes = openmoc_geometry.getAllUniverses() max_material_id = max(all_materials.keys()) max_surface_id = max(all_surfaces.keys()) max_cell_id = max(all_cells.keys()) max_universe_id = max(all_universes.keys()) openmoc.maximize_material_id(max_material_id+1) openmoc.maximize_surface_id(max_surface_id+1) openmoc.maximize_cell_id(max_cell_id+1) openmoc.maximize_universe_id(max_universe_id+1) return openmoc_geometry
def get_openmoc_geometry(openmc_geometry): """Return an OpenMC geometry corresponding to an OpenMOC geometry. Parameters ---------- openmc_geometry : openmc.Geometry OpenMC geometry Returns ------- openmoc_geometry : openmoc.Geometry Equivalent OpenMOC geometry """ cv.check_type('openmc_geometry', openmc_geometry, openmc.Geometry) # Clear dictionaries and auto-generated IDs OPENMC_SURFACES.clear() OPENMOC_SURFACES.clear() OPENMC_CELLS.clear() OPENMOC_CELLS.clear() OPENMC_UNIVERSES.clear() OPENMOC_UNIVERSES.clear() OPENMC_LATTICES.clear() OPENMOC_LATTICES.clear() openmc_root_universe = openmc_geometry.root_universe openmoc_root_universe = get_openmoc_universe(openmc_root_universe) openmoc_geometry = openmoc.Geometry() openmoc_geometry.setRootUniverse(openmoc_root_universe) # Update OpenMOC's auto-generated object IDs (e.g., Surface, Material) # with the maximum of those created from the OpenMC objects all_materials = openmoc_geometry.getAllMaterials() all_surfaces = openmoc_geometry.getAllSurfaces() all_cells = openmoc_geometry.getAllCells() all_universes = openmoc_geometry.getAllUniverses() max_material_id = max(all_materials.keys()) max_surface_id = max(all_surfaces.keys()) max_cell_id = max(all_cells.keys()) max_universe_id = max(all_universes.keys()) openmoc.maximize_material_id(max_material_id+1) openmoc.maximize_surface_id(max_surface_id+1) openmoc.maximize_cell_id(max_cell_id+1) openmoc.maximize_universe_id(max_universe_id+1) return openmoc_geometry
def get_openmoc_geometry(opencg_geometry): """Return an OpenMOC geometry corresponding to an OpenCG geometry. Parameters ---------- opencg_geometry : opencg.Geometry OpenCG geometry Returns ------- openmoc_geometry : openmoc.Geometry Equivalent OpenMOC geometry """ cv.check_type('opencg_geometry', opencg_geometry, opencg.Geometry) # Deep copy the goemetry since it may be modified to make all Surfaces # compatible with OpenMOC's specifications opencg_geometry.assign_auto_ids() opencg_geometry = copy.deepcopy(opencg_geometry) # Update Cell bounding boxes in Geometry opencg_geometry.update_bounding_boxes() # Clear dictionaries and auto-generated IDs OPENMOC_MATERIALS.clear() OPENCG_MATERIALS.clear() OPENMOC_SURFACES.clear() OPENCG_SURFACES.clear() OPENMOC_CELLS.clear() OPENCG_CELLS.clear() OPENMOC_UNIVERSES.clear() OPENCG_UNIVERSES.clear() OPENMOC_LATTICES.clear() OPENCG_LATTICES.clear() # Make the entire geometry "compatible" before assigning auto IDs universes = opencg_geometry.get_all_universes() for universe_id, universe in universes.items(): make_opencg_cells_compatible(universe) opencg_geometry.assign_auto_ids() opencg_root_universe = opencg_geometry.root_universe openmoc_root_universe = get_openmoc_universe(opencg_root_universe) openmoc_geometry = openmoc.Geometry() openmoc_geometry.setRootUniverse(openmoc_root_universe) # Update OpenMOC's auto-generated object IDs (e.g., Surface, Material) # with the maximum of those created from the OpenCG objects all_materials = openmoc_geometry.getAllMaterials() all_surfaces = openmoc_geometry.getAllSurfaces() all_cells = openmoc_geometry.getAllCells() all_universes = openmoc_geometry.getAllUniverses() max_material_id = max(all_materials.keys()) max_surface_id = max(all_surfaces.keys()) max_cell_id = max(all_cells.keys()) max_universe_id = max(all_universes.keys()) openmoc.maximize_material_id(max_material_id + 1) openmoc.maximize_surface_id(max_surface_id + 1) openmoc.maximize_cell_id(max_cell_id + 1) openmoc.maximize_universe_id(max_universe_id + 1) return openmoc_geometry
def get_openmoc_geometry(opencg_geometry): """Return an OpenMOC geometry corresponding to an OpenCG geometry. Parameters ---------- opencg_geometry : opencg.Geometry OpenCG geometry Returns ------- openmoc_geometry : openmoc.Geometry Equivalent OpenMOC geometry """ cv.check_type('opencg_geometry', opencg_geometry, opencg.Geometry) # Deep copy the goemetry since it may be modified to make all Surfaces # compatible with OpenMOC's specifications opencg_geometry.assign_auto_ids() opencg_geometry = copy.deepcopy(opencg_geometry) # Update Cell bounding boxes in Geometry opencg_geometry.update_bounding_boxes() # Clear dictionaries and auto-generated IDs OPENMOC_MATERIALS.clear() OPENCG_MATERIALS.clear() OPENMOC_SURFACES.clear() OPENCG_SURFACES.clear() OPENMOC_CELLS.clear() OPENCG_CELLS.clear() OPENMOC_UNIVERSES.clear() OPENCG_UNIVERSES.clear() OPENMOC_LATTICES.clear() OPENCG_LATTICES.clear() # Make the entire geometry "compatible" before assigning auto IDs universes = opencg_geometry.get_all_universes() for universe_id, universe in universes.items(): make_opencg_cells_compatible(universe) opencg_geometry.assign_auto_ids() opencg_root_universe = opencg_geometry.root_universe openmoc_root_universe = get_openmoc_universe(opencg_root_universe) openmoc_geometry = openmoc.Geometry() openmoc_geometry.setRootUniverse(openmoc_root_universe) # Update OpenMOC's auto-generated object IDs (e.g., Surface, Material) # with the maximum of those created from the OpenCG objects all_materials = openmoc_geometry.getAllMaterials() all_surfaces = openmoc_geometry.getAllSurfaces() all_cells = openmoc_geometry.getAllCells() all_universes = openmoc_geometry.getAllUniverses() max_material_id = max(all_materials.keys()) max_surface_id = max(all_surfaces.keys()) max_cell_id = max(all_cells.keys()) max_universe_id = max(all_universes.keys()) openmoc.maximize_material_id(max_material_id+1) openmoc.maximize_surface_id(max_surface_id+1) openmoc.maximize_cell_id(max_cell_id+1) openmoc.maximize_universe_id(max_universe_id+1) return openmoc_geometry