def get_openmc_surface(openmoc_surface):
    """Return an OpenMC surface corresponding to an OpenMOC surface.

    Parameters
    ----------
    openmoc_surface : openmoc.Surface
        OpenMOC surface

    Returns
    -------
    openmc_surface : openmc.Surface
        Equivalent OpenMC surface

    """

    cv.check_type('openmoc_surface', openmoc_surface, openmoc.Surface)

    surface_id = openmoc_surface.getId()

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

    # Create an OpenMC Surface to represent this OpenMOC Surface
    name = openmoc_surface.getName()

    # Correct for OpenMC's syntax for Surfaces dividing Cells
    boundary = openmoc_surface.getBoundaryType()
    if boundary == openmoc.VACUUM:
        boundary = 'vacuum'
    elif boundary == openmoc.REFLECTIVE:
        boundary = 'reflective'
    elif boundary == openmoc.PERIODIC:
        boundary = 'periodic'
    else:
        boundary = 'transmission'

    if openmoc_surface.getSurfaceType() == openmoc.PLANE:
        openmoc_surface = openmoc.castSurfaceToPlane(openmoc_surface)
        A = openmoc_surface.getA()
        B = openmoc_surface.getB()
        C = openmoc_surface.getC()
        D = openmoc_surface.getD()

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

    elif openmoc_surface.getSurfaceType() == openmoc.XPLANE:
        openmoc_surface = openmoc.castSurfaceToXPlane(openmoc_surface)
        x0 = openmoc_surface.getX()
        openmc_surface = openmc.XPlane(surface_id, boundary, x0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.YPLANE:
        openmoc_surface = openmoc.castSurfaceToYPlane(openmoc_surface)
        y0 = openmoc_surface.getY()
        openmc_surface = openmc.YPlane(surface_id, boundary, y0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.ZPLANE:
        openmoc_surface = openmoc.castSurfaceToZPlane(openmoc_surface)
        z0 = openmoc_surface.getZ()
        openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.ZCYLINDER:
        openmoc_surface = openmoc.castSurfaceToZCylinder(openmoc_surface)
        x0 = openmoc_surface.getX0()
        y0 = openmoc_surface.getY0()
        R = openmoc_surface.getRadius()
        openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R, name)

    # 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 openmc_surface
def get_opencg_surface(openmoc_surface):
    """Return an OpenCG surface corresponding to an OpenMOC surface.

    Parameters
    ----------
    openmc_surface : openmoc.Surface
        OpenMOC surface

    Returns
    -------
    opencg_surface : opencg.Surface
        Equivalent OpenCG surface

    """

    cv.check_type('openmoc_surface', openmoc_surface, openmoc.Surface)

    global OPENCG_SURFACES
    surface_id = openmoc_surface.getId()

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

    # Create an OpenCG Surface to represent this OpenMOC Surface
    name = openmoc_surface.getName()

    # Correct for OpenMOC's syntax for Surfaces dividing Cells
    boundary = openmoc_surface.getBoundaryType()
    if boundary == openmoc.VACUUM:
        boundary = 'vacuum'
    elif boundary == openmoc.REFLECTIVE:
        boundary = 'reflective'
    elif boundary == openmoc.BOUNDARY_NONE:
        boundary = 'interface'

    opencg_surface = None
    surface_type = openmoc_surface.getSurfaceType()

    if surface_type == openmoc.PLANE:
        openmoc_surface = openmoc.castSurfaceToPlane(openmoc_surface)
        A = openmoc_surface.getA()
        B = openmoc_surface.getB()
        C = openmoc_surface.getC()
        D = openmoc_surface.getD()
        opencg_surface = opencg.Plane(surface_id, name, boundary, A, B, C, D)

    elif surface_type == openmoc.XPLANE:
        openmoc_surface = openmoc.castSurfaceToXPlane(openmoc_surface)
        x0 = openmoc_surface.getX()
        opencg_surface = opencg.XPlane(surface_id, name, boundary, x0)

    elif surface_type == openmoc.YPLANE:
        openmoc_surface = openmoc.castSurfaceToYPlane(openmoc_surface)
        y0 = openmoc_surface.getY()
        opencg_surface = opencg.YPlane(surface_id, name, boundary, y0)

    elif surface_type == openmoc.ZPLANE:
        openmoc_surface = openmoc.castSurfaceToZPlane(openmoc_surface)
        z0 = openmoc_surface.getZ()
        opencg_surface = opencg.ZPlane(surface_id, name, boundary, z0)

    elif surface_type == openmoc.ZCYLINDER:
        openmoc_surface = openmoc.castSurfaceToZCylinder(openmoc_surface)
        x0 = openmoc_surface.getX0()
        y0 = openmoc_surface.getY0()
        R = openmoc_surface.getRadius()
        opencg_surface = opencg.ZCylinder(surface_id, name, boundary, x0, y0,
                                          R)

    # 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 opencg_surface
def get_opencg_surface(openmoc_surface):
    """Return an OpenCG surface corresponding to an OpenMOC surface.

    Parameters
    ----------
    openmc_surface : openmoc.Surface
        OpenMOC surface

    Returns
    -------
    opencg_surface : opencg.Surface
        Equivalent OpenCG surface

    """

    cv.check_type('openmoc_surface', openmoc_surface, openmoc.Surface)

    global OPENCG_SURFACES
    surface_id = openmoc_surface.getId()

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

    # Create an OpenCG Surface to represent this OpenMOC Surface
    name = openmoc_surface.getName()

    # Correct for OpenMOC's syntax for Surfaces dividing Cells
    boundary = openmoc_surface.getBoundaryType()
    if boundary == openmoc.VACUUM:
        boundary = 'vacuum'
    elif boundary == openmoc.REFLECTIVE:
        boundary = 'reflective'
    elif boundary == openmoc.BOUNDARY_NONE:
        boundary = 'interface'

    opencg_surface = None
    surface_type = openmoc_surface.getSurfaceType()

    if surface_type == openmoc.PLANE:
        openmoc_surface = openmoc.castSurfaceToPlane(openmoc_surface)
        A = openmoc_surface.getA()
        B = openmoc_surface.getB()
        C = openmoc_surface.getC()
        D = openmoc_surface.getD()
        opencg_surface = opencg.Plane(surface_id, name, boundary, A, B, C, D)

    elif surface_type == openmoc.XPLANE:
        openmoc_surface = openmoc.castSurfaceToXPlane(openmoc_surface)
        x0 = openmoc_surface.getX()
        opencg_surface = opencg.XPlane(surface_id, name, boundary, x0)

    elif surface_type == openmoc.YPLANE:
        openmoc_surface = openmoc.castSurfaceToYPlane(openmoc_surface)
        y0 = openmoc_surface.getY()
        opencg_surface = opencg.YPlane(surface_id, name, boundary, y0)

    elif surface_type == openmoc.ZPLANE:
        openmoc_surface = openmoc.castSurfaceToZPlane(openmoc_surface)
        z0 = openmoc_surface.getZ()
        opencg_surface = opencg.ZPlane(surface_id, name, boundary, z0)

    elif surface_type == openmoc.ZCYLINDER:
        openmoc_surface = openmoc.castSurfaceToZCylinder(openmoc_surface)
        x0 = openmoc_surface.getX0()
        y0 = openmoc_surface.getY0()
        R = openmoc_surface.getRadius()
        opencg_surface = opencg.ZCylinder(surface_id, name, boundary, x0, y0, R)

    # 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 opencg_surface
def get_openmc_surface(openmoc_surface):
    """Return an OpenMC surface corresponding to an OpenMOC surface.

    Parameters
    ----------
    openmoc_surface : openmoc.Surface
        OpenMOC surface

    Returns
    -------
    openmc_surface : openmc.Surface
        Equivalent OpenMC surface

    """

    cv.check_type('openmoc_surface', openmoc_surface, openmoc.Surface)

    surface_id = openmoc_surface.getId()

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

    # Create an OpenMC Surface to represent this OpenMOC Surface
    name = openmoc_surface.getName()

    # Correct for OpenMC's syntax for Surfaces dividing Cells
    boundary = openmoc_surface.getBoundaryType()
    if boundary == openmoc.VACUUM:
        boundary = 'vacuum'
    elif boundary == openmoc.REFLECTIVE:
        boundary = 'reflective'
    elif boundary == openmoc.PERIODIC:
        boundary = 'periodic'
    else:
        boundary = 'transmission'

    if openmoc_surface.getSurfaceType() == openmoc.PLANE:
        openmoc_surface = openmoc.castSurfaceToPlane(openmoc_surface)
        A = openmoc_surface.getA()
        B = openmoc_surface.getB()
        C = openmoc_surface.getC()
        D = openmoc_surface.getD()

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

    elif openmoc_surface.getSurfaceType() == openmoc.XPLANE:
        openmoc_surface = openmoc.castSurfaceToXPlane(openmoc_surface)
        x0 = openmoc_surface.getX()
        openmc_surface = openmc.XPlane(surface_id, boundary, x0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.YPLANE:
        openmoc_surface = openmoc.castSurfaceToYPlane(openmoc_surface)
        y0 = openmoc_surface.getY()
        openmc_surface = openmc.YPlane(surface_id, boundary, y0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.ZPLANE:
        openmoc_surface = openmoc.castSurfaceToZPlane(openmoc_surface)
        z0 = openmoc_surface.getZ()
        openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.ZCYLINDER:
        openmoc_surface = openmoc.castSurfaceToZCylinder(openmoc_surface)
        x0 = openmoc_surface.getX0()
        y0 = openmoc_surface.getY0()
        R = openmoc_surface.getRadius()
        openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R, name)

    # 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 openmc_surface
Exemple #5
0
def get_opencg_surface(openmoc_surface):

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

    global OPENCG_SURFACES
    surface_id = openmoc_surface.getId()

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

    # Create an OpenCG Surface to represent this OpenMOC Surface
    name = openmoc_surface.getName()

    # Correct for OpenMOC's syntax for Surfaces dividing Cells
    boundary = openmoc_surface.getBoundaryType()
    if boundary == openmoc.VACUUM:
        boundary = 'vacuum'
    elif boundary == openmoc.REFLECTIVE:
        boundary = 'reflective'
    elif boundary == openmoc.BOUNDARY_NONE:
        boundary = 'interface'

    opencg_surface = None

    surface_type = openmoc_surface.getSurfaceType()

    if surface_type == openmoc.PLANE:
        openmoc_surface = openmoc.castSurfaceToPlane(openmoc_surface)
        A = openmoc_surface.getA()
        B = openmoc_surface.getB()
        C = openmoc_surface.getC()
        opencg_surface = opencg.Plane(surface_id, name, boundary, A, B, 0, C)

    elif surface_type == openmoc.XPLANE:
        openmoc_surface = openmoc.castSurfaceToXPlane(openmoc_surface)
        x0 = openmoc_surface.getX()
        opencg_surface = opencg.XPlane(surface_id, name, boundary, x0)

    elif surface_type == openmoc.YPLANE:
        openmoc_surface = openmoc.castSurfaceToYPlane(openmoc_surface)
        y0 = openmoc_surface.getY()
        opencg_surface = opencg.YPlane(surface_id, name, boundary, y0)

    elif surface_type == openmoc.ZPLANE:
        openmoc_surface = openmoc.castSurfaceToZPlane(openmoc_surface)
        z0 = openmoc_surface.getZ()
        opencg_surface = opencg.ZPlane(surface_id, name, boundary, z0)

    elif surface_type == openmoc.ZYCLINDER:
        openmoc_surface = openmoc.castSurfaceToZCylinder(openmoc_surface)
        x0 = openmoc_surface.getX0()
        y0 = openmoc_surface.getY0()
        R = openmoc_surface.getRadius()
        opencg_surface = opencg.ZCylinder(surface_id, name, boundary, x0, y0,
                                          R)

    # 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 opencg_surface
def get_opencg_surface(openmoc_surface):

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

  global OPENCG_SURFACES
  surface_id = openmoc_surface.getId()

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

  # Create an OpenCG Surface to represent this OpenMOC Surface
  name = openmoc_surface.getName()

  # Correct for OpenMOC's syntax for Surfaces dividing Cells
  boundary = openmoc_surface.getBoundaryType()
  if boundary == openmoc.VACUUM:
    boundary = 'vacuum'
  elif boundary == openmoc.REFLECTIVE:
    boundary = 'reflective'
  elif boundary == openmoc.BOUNDARY_NONE:
    boundary = 'interface'

  opencg_surface = None

  surface_type = openmoc_surface.getSurfaceType()

  if surface_type == openmoc.PLANE:
    openmoc_surface = openmoc.castSurfaceToPlane(openmoc_surface)
    A = openmoc_surface.getA()
    B = openmoc_surface.getB()
    C = openmoc_surface.getC()
    opencg_surface = opencg.Plane(surface_id, name, boundary, A, B, 0, C)

  elif surface_type == openmoc.XPLANE:
    openmoc_surface = openmoc.castSurfaceToXPlane(openmoc_surface)
    x0 = openmoc_surface.getX()
    opencg_surface = opencg.XPlane(surface_id, name, boundary, x0)

  elif surface_type == openmoc.YPLANE:
    openmoc_surface = openmoc.castSurfaceToYPlane(openmoc_surface)
    y0 = openmoc_surface.getY()
    opencg_surface = opencg.YPlane(surface_id, name, boundary, y0)

  elif surface_type == openmoc.ZPLANE:
    openmoc_surface = openmoc.castSurfaceToZPlane(openmoc_surface)
    z0 = openmoc_surface.getZ()
    opencg_surface = opencg.ZPlane(surface_id, name, boundary, z0)

  elif surface_type == openmoc.CIRCLE:
    openmoc_surface = openmoc.castSurfaceToCircle(openmoc_surface)
    x0 = openmoc_surface.getX0()
    y0 = openmoc_surface.getY0()
    R = openmoc_surface.getRadius()
    opencg_surface = opencg.ZCylinder(surface_id, name, boundary, x0, y0, R)

  # 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 opencg_surface