Пример #1
0
def get_opencg_universe(openmoc_universe):

    if not isinstance(openmoc_universe, openmoc.Universe):
        msg = 'Unable to create an OpenCG Universe from {0} which ' \
              'is not an OpenMOC Universe'.format(openmoc_universe)
        raise ValueError(msg)

    global OPENCG_UNIVERSES
    universe_id = openmoc_universe.getId()

    # 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 OpenMOC Universe
    name = openmoc_universe.getName()
    opencg_universe = opencg.Universe(universe_id, name)

    # Convert all OpenMOC Cells in this Universe to OpenCG Cells
    openmoc_cells = openmoc_universe.getCells()

    for cell_id, openmoc_cell in openmoc_cells.items():
        opencg_cell = get_opencg_cell(openmoc_cell)
        opencg_universe.addCell(opencg_cell)

    # Add the OpenMOC Universe to the global collection of all OpenMOC Universes
    OPENMOC_UNIVERSES[universe_id] = openmoc_universe

    # Add the OpenCG Universe to the global collection of all OpenCG Universes
    OPENCG_UNIVERSES[universe_id] = opencg_universe

    return opencg_universe
Пример #2
0
def get_opencg_universe(openmc_universe):
    """Return an OpenCG universe corresponding to an OpenMC universe.

    Parameters
    ----------
    openmc_universe : openmc.universe.Universe
        OpenMC universe

    Returns
    -------
    opencg_universe : opencg.Universe
        Equivalent OpenCG universe

    """

    if not isinstance(openmc_universe, openmc.Universe):
        msg = 'Unable to create an OpenCG Universe from "{0}" which ' \
              'is not an OpenMC Universe'.format(openmc_universe)
        raise ValueError(msg)

    global OPENCG_UNIVERSES
    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
    opencg_universe = opencg.Universe(universe_id, name)

    # Convert all OpenMC Cells in this Universe to OpenCG 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)

    # Add the OpenMC Universe to the global collection of all OpenMC Universes
    OPENMC_UNIVERSES[universe_id] = openmc_universe

    # Add the OpenCG Universe to the global collection of all OpenCG Universes
    OPENCG_UNIVERSES[universe_id] = opencg_universe

    return opencg_universe
Пример #3
0
def get_opencg_universe(openmoc_universe):
    """Return an OpenCG universe corresponding to an OpenMOC universe.

    Parameters
    ----------
    openmoc_universe : openmoc.Universe
        OpenMOC universe

    Returns
    -------
    opencg_universe : opencg.Universe
        Equivalent OpenCG universe

    """

    cv.check_type('openmoc_universe', openmoc_universe, openmoc.Universe)

    global OPENCG_UNIVERSES
    universe_id = openmoc_universe.getId()

    # 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 OpenMOC Universe
    name = openmoc_universe.getName()
    opencg_universe = opencg.Universe(universe_id, name)

    # Convert all OpenMOC Cells in this Universe to OpenCG Cells
    openmoc_cells = openmoc_universe.getCells()

    for cell_id, openmoc_cell in openmoc_cells.items():
        opencg_cell = get_opencg_cell(openmoc_cell)
        opencg_universe.add_cell(opencg_cell)

    # Add the OpenMOC Universe to the global collection of all OpenMOC Universes
    OPENMOC_UNIVERSES[universe_id] = openmoc_universe

    # Add the OpenCG Universe to the global collection of all OpenCG Universes
    OPENCG_UNIVERSES[universe_id] = opencg_universe

    return opencg_universe
Пример #4
0
###############################################################################

# Create bounding surfaces
min_x = opencg.XPlane(boundary='reflective', x0=0.0)
max_x = opencg.XPlane(boundary='reflective', x0=5.0)
min_y = opencg.YPlane(boundary='reflective', y0=0.0)
max_y = opencg.YPlane(boundary='reflective', y0=10.0)
min_z = opencg.ZPlane(boundary='reflective', z0=0.0)
max_z = opencg.ZPlane(boundary='reflective', z0=10.0)

# Create material interfacial surfaces
left = opencg.XPlane(surface_id=1, boundary='interface', x0=2.0)
right = opencg.XPlane(surface_id=2, boundary='interface', x0=2.4)

# Create a Universe to encapsulate the 1D slab
slab_universe = opencg.Universe(name='1D slab')

# Create fuel Cell
fuel_cell = opencg.Cell(name='fuel')
fuel_cell.fill = opencg_fuel
fuel_cell.add_surface(halfspace=+1, surface=min_x)
fuel_cell.add_surface(halfspace=-1, surface=left)
slab_universe.add_cell(fuel_cell)

# Create clad Cell
clad_cell = opencg.Cell(name='clad')
clad_cell.fill = opencg_clad
clad_cell.add_surface(halfspace=+1, surface=left)
clad_cell.add_surface(halfspace=-1, surface=right)
slab_universe.add_cell(clad_cell)