Пример #1
0
def get_opencg_geometry(openmoc_geometry):

    if not isinstance(openmoc_geometry, openmoc.Geometry):
        msg = 'Unable to get OpenCG geometry from {0} which is ' \
              'not an OpenMOC Geometry object'.format(openmoc_geometry)
        raise ValueError(msg)

    # Clear dictionaries and auto-generated IDs
    OPENMOC_SURFACES.clear()
    OPENCG_SURFACES.clear()
    OPENMOC_CELLS.clear()
    OPENCG_CELLS.clear()
    OPENMOC_UNIVERSES.clear()
    OPENCG_UNIVERSES.clear()
    OPENMOC_LATTICES.clear()
    OPENCG_LATTICES.clear()

    openmoc_root_universe = openmoc_geometry.getRootUniverse()
    opencg_root_universe = get_opencg_universe(openmoc_root_universe)

    opencg_geometry = opencg.Geometry()
    opencg_geometry.setRootUniverse(opencg_root_universe)
    opencg_geometry.initializeCellOffsets()

    return opencg_geometry
Пример #2
0
def get_opencg_geometry(openmc_geometry):
    """Return an OpenCG geometry corresponding to an OpenMC geometry.

    Parameters
    ----------
    openmc_geometry : openmc.universe.Geometry
        OpenMC geometry

    Returns
    -------
    opencg_geometry : opencg.Geometry
        Equivalent OpenCG geometry

    """

    if not isinstance(openmc_geometry, openmc.Geometry):
        msg = 'Unable to get OpenCG geometry from "{0}" which is ' \
              'not an OpenMC Geometry object'.format(openmc_geometry)
        raise ValueError(msg)

    # Clear dictionaries and auto-generated IDs
    OPENMC_SURFACES.clear()
    OPENCG_SURFACES.clear()
    OPENMC_CELLS.clear()
    OPENCG_CELLS.clear()
    OPENMC_UNIVERSES.clear()
    OPENCG_UNIVERSES.clear()
    OPENMC_LATTICES.clear()
    OPENCG_LATTICES.clear()

    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()

    return opencg_geometry
Пример #3
0
def get_opencg_geometry(openmoc_geometry):
    """Return an OpenCG geometry corresponding to an OpenMOC geometry.

    Parameters
    ----------
    openmoc_geometry : openmoc.Geometry
        OpenMOC geometry

    Returns
    -------
    opencg_geometry : opencg.Geometry
        Equivalent OpenCG geometry

    """

    cv.check_type('openmoc_geometry', openmoc_geometry, openmoc.Geometry)

    # 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()

    openmoc_root_universe = openmoc_geometry.getRootUniverse()
    opencg_root_universe = get_opencg_universe(openmoc_root_universe)

    opencg_geometry = opencg.Geometry()
    opencg_geometry.root_universe = opencg_root_universe
    opencg_geometry.initialize_cell_offsets()

    return opencg_geometry
Пример #4
0
# Create root Universe
root_universe = opencg.Universe(universe_id=0, name='root universe')
root_universe.add_cell(root_cell)

# Instantiate OpenCG's linear mesh operators for spatial discretization
fuel_mesh = opencg.LinearMesh('x', fuel_cell.min_x, fuel_cell.max_x, 40)
clad_mesh = opencg.LinearMesh('x', clad_cell.min_x, clad_cell.max_x, 20)
water_mesh = opencg.LinearMesh('x', water_cell.min_x, water_cell.max_x, 40)

# Discretize the fuel, clad and water cells
fuel_cells = fuel_mesh.subdivide_cell(fuel_cell, slab_universe)
clad_cells = clad_mesh.subdivide_cell(clad_cell, slab_universe)
water_cells = water_mesh.subdivide_cell(water_cell, slab_universe)

# Create Geometry and set root Universe
opencg_geometry = opencg.Geometry()
opencg_geometry.root_universe = root_universe

# Get an OpenMC version of this OpenCG geometry
openmc_geometry = openmc.opencg_compatible.get_openmc_geometry(opencg_geometry)

# Instantiate a GeometryFile, register Geometry, and export to XML
geometry_file = openmc.GeometryFile()
geometry_file.geometry = openmc_geometry
geometry_file.export_to_xml()

###############################################################################
#                   Exporting to OpenMC settings.xml File
###############################################################################

# Construct uniform initial source distribution over fissionable zones