예제 #1
0
def get_openmoc_surface(opencg_surface):
    """Return an OpenMOC surface corresponding to an OpenCG surface.

    Parameters
    ----------
    opencg_surface : opencg.Surface
        OpenCG surface

    Returns
    -------
    openmoc_surface : openmoc.Surface
        Equivalent OpenMOC surface

    """

    cv.check_type('opencg_surface', opencg_surface, opencg.Surface)

    global OPENMOC_SURFACES
    surface_id = opencg_surface.id

    # If this Surface was already created, use it
    if surface_id in OPENMOC_SURFACES:
        return OPENMOC_SURFACES[surface_id]

    # Create an OpenMOC Surface to represent this OpenCG Surface
    name = str(opencg_surface.name)

    # Correct for OpenMOC's syntax for Surfaces dividing Cells
    boundary = opencg_surface.boundary_type
    if boundary == 'vacuum':
        boundary = openmoc.VACUUM
    elif boundary == 'reflective':
        boundary = openmoc.REFLECTIVE
    elif boundary == 'interface':
        boundary = openmoc.BOUNDARY_NONE

    if opencg_surface.type == 'plane':
        A = opencg_surface.a
        B = opencg_surface.b
        C = opencg_surface.c
        D = opencg_surface.d
        openmoc_surface = openmoc.Plane(A, B, C, D, surface_id, name)

    elif opencg_surface.type == 'x-plane':
        x0 = opencg_surface.x0
        openmoc_surface = openmoc.XPlane(x0, int(surface_id), name)

    elif opencg_surface.type == 'y-plane':
        y0 = opencg_surface.y0
        openmoc_surface = openmoc.YPlane(y0, surface_id, name)

    elif opencg_surface.type == 'z-plane':
        z0 = opencg_surface.z0
        openmoc_surface = openmoc.ZPlane(z0, surface_id, name)

    elif opencg_surface.type == 'z-cylinder':
        x0 = opencg_surface.x0
        y0 = opencg_surface.y0
        R = opencg_surface.r
        openmoc_surface = openmoc.ZCylinder(x0, y0, R, surface_id, name)

    else:
        msg = 'Unable to create an OpenMOC Surface from an OpenCG ' \
              'Surface of type {0} since it is not a compatible ' \
              'Surface type in OpenMOC'.format(opencg_surface.type)
        raise ValueError(msg)

    # Set the boundary condition for this Surface
    openmoc_surface.setBoundaryType(boundary)

    # Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces
    OPENMOC_SURFACES[surface_id] = openmoc_surface

    # Add the OpenCG Surface to the global collection of all OpenCG Surfaces
    OPENCG_SURFACES[surface_id] = opencg_surface

    return openmoc_surface
예제 #2
0
def get_openmoc_surface(openmc_surface):
    """Return an OpenMOC surface corresponding to an OpenMC surface.

    Parameters
    ----------
    openmc_surface : openmc.Surface
        OpenMC surface

    Returns
    -------
    openmoc_surface : openmoc.Surface
        Equivalent OpenMOC surface

    """

    cv.check_type('openmc_surface', openmc_surface, openmc.Surface)

    surface_id = openmc_surface.id

    # If this Material was already created, use it
    if surface_id in OPENMOC_SURFACES:
        return OPENMOC_SURFACES[surface_id]

    # Create an OpenMOC Surface to represent this OpenMC Surface
    name = openmc_surface.name

    # Determine the type of boundary conditions applied to the Surface
    if openmc_surface.boundary_type == 'vacuum':
        boundary = openmoc.VACUUM
    elif openmc_surface.boundary_type == 'reflective':
        boundary = openmoc.REFLECTIVE
    elif openmc_surface.boundary_type == 'periodic':
        boundary = openmoc.PERIODIC
    else:
        boundary = openmoc.BOUNDARY_NONE

    if openmc_surface.type == 'plane':
        A = openmc_surface.a
        B = openmc_surface.b
        C = openmc_surface.c
        D = openmc_surface.d

        # OpenMOC uses the opposite sign on D
        openmoc_surface = openmoc.Plane(A, B, C, -D, surface_id, name)

    elif openmc_surface.type == 'x-plane':
        x0 = openmc_surface.x0
        openmoc_surface = openmoc.XPlane(x0, surface_id, name)

    elif openmc_surface.type == 'y-plane':
        y0 = openmc_surface.y0
        openmoc_surface = openmoc.YPlane(y0, surface_id, name)

    elif openmc_surface.type == 'z-plane':
        z0 = openmc_surface.z0
        openmoc_surface = openmoc.ZPlane(z0, surface_id, name)

    elif openmc_surface.type == 'z-cylinder':
        x0 = openmc_surface.x0
        y0 = openmc_surface.y0
        R = openmc_surface.r
        openmoc_surface = openmoc.ZCylinder(x0, y0, R, surface_id, name)

    else:
        msg = 'Unable to create an OpenMOC Surface from an OpenMC ' \
              'Surface of type "{}" since it is not a compatible ' \
              'Surface type in OpenMOC'.format(type(openmc_surface))
        raise ValueError(msg)

    # Set the boundary condition for this Surface
    openmoc_surface.setBoundaryType(boundary)

    # Add the OpenMC Surface to the global collection of all OpenMC Surfaces
    OPENMC_SURFACES[surface_id] = openmc_surface

    # Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces
    OPENMOC_SURFACES[surface_id] = openmoc_surface

    return openmoc_surface
예제 #3
0
def get_openmoc_surface(opencg_surface):

    if not isinstance(opencg_surface, opencg.Surface):
        msg = 'Unable to create an OpenMoC Surface from {0} which ' \
              'is not an OpenCG Surface'.format(opencg_surface)
        raise ValueError(msg)

    global OPENMOC_SURFACES
    surface_id = opencg_surface._id

    # If this Surface was already created, use it
    if surface_id in OPENMOC_SURFACES:
        return OPENMOC_SURFACES[surface_id]

    # Create an OpenMOC Surface to represent this OpenCG Surface
    name = opencg_surface._name

    # Correct for OpenMOC's syntax for Surfaces dividing Cells
    boundary = opencg_surface._boundary_type
    if boundary == 'vacuum':
        boundary = openmoc.VACUUM
    elif boundary == 'reflective':
        boundary = openmoc.REFLECTIVE
    elif boundary == 'interface':
        boundary = openmoc.BOUNDARY_NONE

    if opencg_surface._type == 'plane':
        A = opencg_surface._coeffs['A']
        B = opencg_surface._coeffs['B']
        D = opencg_surface._coeffs['D']
        openmoc_surface = openmoc.Plane(A, B, D, surface_id, name)

    elif opencg_surface._type == 'x-plane':
        x0 = opencg_surface._coeffs['x0']
        openmoc_surface = openmoc.XPlane(x0, int(surface_id), name)

    elif opencg_surface._type == 'y-plane':
        y0 = opencg_surface._coeffs['y0']
        openmoc_surface = openmoc.YPlane(y0, surface_id, name)

    elif opencg_surface._type == 'z-plane':
        z0 = opencg_surface._coeffs['z0']
        openmoc_surface = openmoc.ZPlane(z0, surface_id, name)

    elif opencg_surface._type == 'z-cylinder':
        x0 = opencg_surface._coeffs['x0']
        y0 = opencg_surface._coeffs['y0']
        R = opencg_surface._coeffs['R']
        openmoc_surface = openmoc.ZCylinder(x0, y0, R, surface_id, name)

    else:
        msg = 'Unable to create an OpenMOC Surface from an OpenCG ' \
              'Surface of type {0} since it is not a compatible ' \
              'Surface type in OpenMOC'.format(opencg_surface._type)
        raise ValueError(msg)

    # Set the boundary condition for this Surface
    openmoc_surface.setBoundaryType(boundary)

    # Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces
    OPENMOC_SURFACES[surface_id] = openmoc_surface

    # Add the OpenCG Surface to the global collection of all OpenCG Surfaces
    OPENCG_SURFACES[surface_id] = opencg_surface

    # FIXME
    openmoc_surface.thisown = 0

    return openmoc_surface