Esempio n. 1
0
    def _create_geometry(self):
        """Instantiate materials and a pin cell Geometry."""

        self.input_set.create_materials()

        zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=1.0, name='pin')
        xmin = openmoc.XPlane(x=-2.0, name='xmin')
        xmax = openmoc.XPlane(x=+2.0, name='xmax')
        ymin = openmoc.YPlane(y=-2.0, name='ymin')
        ymax = openmoc.YPlane(y=+2.0, name='ymax')

        xmin.setBoundaryType(openmoc.VACUUM)
        xmax.setBoundaryType(openmoc.VACUUM)
        ymin.setBoundaryType(openmoc.VACUUM)
        ymax.setBoundaryType(openmoc.VACUUM)

        fuel = openmoc.Cell(name='fuel')
        fuel.setFill(self.input_set.materials['UO2'])
        fuel.addSurface(halfspace=-1, surface=zcylinder)

        moderator = openmoc.Cell(name='moderator')
        moderator.setFill(self.input_set.materials['Water'])
        moderator.addSurface(halfspace=+1, surface=zcylinder)
        moderator.addSurface(halfspace=+1, surface=xmin)
        moderator.addSurface(halfspace=-1, surface=xmax)
        moderator.addSurface(halfspace=+1, surface=ymin)
        moderator.addSurface(halfspace=-1, surface=ymax)

        root_universe = openmoc.Universe(name='root universe')
        root_universe.addCell(fuel)
        root_universe.addCell(moderator)

        self.input_set.geometry = openmoc.Geometry()
        self.input_set.geometry.setRootUniverse(root_universe)
Esempio n. 2
0
    def _create_geometry(self):
        """Inspired from SimpleLattice"""

        self.materials = \
            openmoc.materialize.load_from_hdf5(filename='c5g7-mgxs.h5',
                                               directory='../../sample-input/')

        xmin = openmoc.XPlane(x=-2.0, name='xmin')
        xmax = openmoc.XPlane(x=+2.0, name='xmax')
        ymin = openmoc.YPlane(y=-2.0, name='ymin')
        ymax = openmoc.YPlane(y=+2.0, name='ymax')
        boundaries = [xmin, xmax, ymin, ymax]
        if (self.dimensions == 3):
            zmin = openmoc.ZPlane(z=-5.0, name='zmin')
            zmax = openmoc.ZPlane(z=+5.0, name='zmax')
            boundaries = [xmin, xmax, ymin, ymax, zmin, zmax]

        large_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0,
                                            radius=0.4, name='large pin')
        medium_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0,
                                             radius=0.3, name='medium pin')
        small_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0,
                                            radius=0.2, name='small pin')
        xplane = openmoc.XPlane(x=0, name='mid-cell')
        yplane = openmoc.YPlane(y=0, name='mid-cell')

        for boundary in boundaries: boundary.setBoundaryType(openmoc.REFLECTIVE)
        if (self.dimensions == 3):
            boundaries[-1].setBoundaryType(openmoc.VACUUM)

        large_fuel = openmoc.Cell(name='large pin fuel')
        large_fuel.setNumRings(3)
        large_fuel.setNumSectors(8)
        large_fuel.setFill(self.materials['UO2'])
        large_fuel.addSurface(halfspace=-1, surface=large_zcylinder)

        large_moderator = openmoc.Cell(name='large pin moderator')
        large_moderator.setNumSectors(8)
        large_moderator.setFill(self.materials['Water'])
        large_moderator.addSurface(halfspace=+1, surface=large_zcylinder)

        medium_fuel = openmoc.Cell(name='medium pin fuel')
        medium_fuel.setNumRings(3)
        medium_fuel.setNumSectors(8)
        medium_fuel.setFill(self.materials['UO2'])
        medium_fuel.addSurface(halfspace=-1, surface=medium_zcylinder)

        medium_moderator = openmoc.Cell(name='medium pin moderator')
        medium_moderator.setNumSectors(8)
        medium_moderator.setFill(self.materials['Water'])
        medium_moderator.addSurface(halfspace=+1, surface=medium_zcylinder)

        small_fuel = openmoc.Cell(name='small pin fuel')
        small_fuel.setNumRings(3) # test may fail if fsrs are initialized
        small_fuel.setNumSectors(8)
        small_fuel.setFill(self.materials['UO2'])
        small_fuel.addSurface(halfspace=-1, surface=small_zcylinder)

        small_clad_q1 = openmoc.Cell(name='small pin cladding quarter')
        small_clad_q1.setFill(self.materials['Clad'])
        small_clad_q1.addSurface(halfspace=+1, surface=small_zcylinder)
        small_clad_q1.addSurface(halfspace=-1, surface=medium_zcylinder)
        small_clad_q1.addSurface(halfspace=+1, surface=xplane)
        small_clad_q1.addSurface(halfspace=-1, surface=yplane)

        small_moderator = openmoc.Cell(name='small pin moderator')
        small_moderator.setNumSectors(8)
        small_moderator.setFill(self.materials['Water'])
        small_moderator.addSurface(halfspace=+1, surface=medium_zcylinder)

        lattice_cell = openmoc.Cell(name='lattice cell')

        root_cell = openmoc.Cell(name='root cell')
        root_cell.addSurface(halfspace=+1, surface=boundaries[0])
        root_cell.addSurface(halfspace=-1, surface=boundaries[1])
        root_cell.addSurface(halfspace=+1, surface=boundaries[2])
        root_cell.addSurface(halfspace=-1, surface=boundaries[3])
        if (self.dimensions == 3):
            root_cell.addSurface(halfspace=+1, surface=boundaries[4])
            root_cell.addSurface(halfspace=-1, surface=boundaries[5])

        pin1 = openmoc.Universe(name='large pin cell')
        pin2 = openmoc.Universe(name='medium pin cell')
        pin3 = openmoc.Universe(name='small pin cell')
        assembly = openmoc.Universe(name='2x2 lattice')
        root_universe = openmoc.Universe(name='root universe')

        pin1.addCell(large_fuel)
        pin1.addCell(large_moderator)
        pin2.addCell(medium_fuel)
        pin2.addCell(medium_moderator)
        pin3.addCell(small_fuel)
        pin3.addCell(small_clad_q1)
        pin3.addCell(small_moderator)
        assembly.addCell(lattice_cell)
        root_universe.addCell(root_cell)

        # 2x2 assembly
        lattice = openmoc.Lattice(name='2x2 lattice')
        lattice.setWidth(width_x=1.0, width_y=1.0)
        lattice.setUniverses([[[pin1, pin2], [pin1, pin3]]])
        lattice_cell.setFill(lattice)

        # Rotate a lattice to test rotation of a fill cell
        assembly_c = openmoc.Cell(name='rotated cell containing a lattice')
        assembly_c.setFill(assembly)
        assembly_c.setRotation((0,0,90), 'degrees')
        assembly_r = openmoc.Universe(name='rotated lattice')
        assembly_r.addCell(assembly_c)

        # Translate a lattice to test translation of a fill cell
        assembly_c = openmoc.Cell(name='rotated cell containing a lattice')
        assembly_c.setFill(assembly)
        assembly_c.setTranslation((0.05,0,0))
        assembly_t = openmoc.Universe(name='translated lattice')
        assembly_t.addCell(assembly_c)

        # Rotate a lattice to test rotation of a fill cell
        assembly_c = openmoc.Cell(name='translated cell containing a lattice')
        assembly_c.setFill(assembly)
        assembly_c.setRotation((0,0,-90), 'degrees')
        assembly_c.setTranslation((-0.05,0,0))
        assembly_rt = openmoc.Universe(name='translate and rotated lattice')
        assembly_rt.addCell(assembly_c)

        # 2x2 core
        core = openmoc.Lattice(name='2x2 core')
        core.setWidth(width_x=2.0, width_y=2.0)
        core.setUniverses([[[assembly, assembly_rt], [assembly_t, assembly_r]]])
        root_cell.setFill(core)

        self.geometry = openmoc.Geometry()
        self.geometry.setRootUniverse(root_universe)
Esempio n. 3
0
###############################################################################
#                            Creating Surfaces
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating surfaces...')

left = openmoc.XPlane(x=-34.0, name='left')
right = openmoc.XPlane(x=34.0, name='right')
top = openmoc.YPlane(y=-34.0, name='top')
bottom = openmoc.YPlane(y=34.0, name='bottom')
boundaries = [left, right, top, bottom]
for boundary in boundaries: boundary.setBoundaryType(openmoc.REFLECTIVE)

zcylinders = list()
radii = [0.15, 0.2, 0.25, 0.3, 0.35, 0.4]
for r in radii: zcylinders.append(openmoc.ZCylinder(x=0.0, y=0.0, radius=r))


###############################################################################
#                             Creating Cells
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating cells...')

# Create a list of 12 Cell instances
cells = [openmoc.Cell() for i in range(12)]

# Append 3 CellFills for the assemblies and full core
assembly1 = openmoc.Cell(name='assembly 1')
assembly2 = openmoc.Cell(name='assembly 2')
root_cell = openmoc.Cell(name='full core')
Esempio n. 4
0
    def create_geometry(self):
        """Instantiate a 17x17 pin cell lattice Geometry."""

        # Create ZCylinder for the fuel and moderator
        fuel_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.54)

        # Create planes to bound the entire geometry
        xmin = openmoc.XPlane(x=-10.71, name='xmin')
        xmax = openmoc.XPlane(x=+10.71, name='xmax')
        ymin = openmoc.YPlane(y=-10.71, name='ymin')
        ymax = openmoc.YPlane(y=+10.71, name='xmax')

        xmin.setBoundaryType(openmoc.REFLECTIVE)
        xmax.setBoundaryType(openmoc.REFLECTIVE)
        ymin.setBoundaryType(openmoc.REFLECTIVE)
        ymax.setBoundaryType(openmoc.REFLECTIVE)

        # 4.3% MOX pin cell
        mox43_cell = openmoc.Cell()
        mox43_cell.setFill(self.materials['MOX-4.3%'])
        mox43_cell.setNumRings(3)
        mox43_cell.setNumSectors(8)
        mox43_cell.addSurface(-1, fuel_radius)

        mox43 = openmoc.Universe(name='MOX-4.3%')
        mox43.addCell(mox43_cell)

        # 7% MOX pin cell
        mox7_cell = openmoc.Cell()
        mox7_cell.setFill(self.materials['MOX-7%'])
        mox7_cell.setNumRings(3)
        mox7_cell.setNumSectors(8)
        mox7_cell.addSurface(-1, fuel_radius)

        mox7 = openmoc.Universe(name='MOX-7%')
        mox7.addCell(mox7_cell)

        # 8.7% MOX pin cell
        mox87_cell = openmoc.Cell()
        mox87_cell.setFill(self.materials['MOX-8.7%'])
        mox87_cell.setNumRings(3)
        mox87_cell.setNumSectors(8)
        mox87_cell.addSurface(-1, fuel_radius)

        mox87 = openmoc.Universe(name='MOX-8.7%')
        mox87.addCell(mox87_cell)

        # Fission chamber pin cell
        fission_chamber_cell = openmoc.Cell()
        fission_chamber_cell.setFill(self.materials['Fission Chamber'])
        fission_chamber_cell.setNumRings(3)
        fission_chamber_cell.setNumSectors(8)
        fission_chamber_cell.addSurface(-1, fuel_radius)

        fission_chamber = openmoc.Universe(name='Fission Chamber')
        fission_chamber.addCell(fission_chamber_cell)

        # Guide tube pin cell
        guide_tube_cell = openmoc.Cell()
        guide_tube_cell.setFill(self.materials['Guide Tube'])
        guide_tube_cell.setNumRings(3)
        guide_tube_cell.setNumSectors(8)
        guide_tube_cell.addSurface(-1, fuel_radius)

        guide_tube = openmoc.Universe(name='Guide Tube')
        guide_tube.addCell(guide_tube_cell)

        # Moderator cell
        moderator = openmoc.Cell()
        moderator.setFill(self.materials['Water'])
        moderator.addSurface(+1, fuel_radius)
        moderator.setNumRings(3)
        moderator.setNumSectors(8)

        # Add moderator to each pin cell
        pins = [mox43, mox7, mox87, fission_chamber, guide_tube]
        for pin in pins:
            pin.addCell(moderator)

        # CellFills for the assembly
        assembly1_cell = openmoc.Cell(name='Assembly 1')
        assembly1 = openmoc.Universe(name='Assembly 1')
        assembly1.addCell(assembly1_cell)

        # A mixed enrichment PWR MOX fuel assembly
        assembly = openmoc.Lattice(name='MOX Assembly')
        assembly.setWidth(width_x=1.26, width_y=1.26)

        # Create a template to map to pin cell types
        template = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
                    [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1],
                    [1, 2, 2, 2, 2, 4, 2, 2, 4, 2, 2, 4, 2, 2, 2, 2, 1],
                    [1, 2, 2, 4, 2, 3, 3, 3, 3, 3, 3, 3, 2, 4, 2, 2, 1],
                    [1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1],
                    [1, 2, 4, 3, 3, 4, 3, 3, 4, 3, 3, 4, 3, 3, 4, 2, 1],
                    [1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1],
                    [1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1],
                    [1, 2, 4, 3, 3, 4, 3, 3, 5, 3, 3, 4, 3, 3, 4, 2, 1],
                    [1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1],
                    [1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1],
                    [1, 2, 4, 3, 3, 4, 3, 3, 4, 3, 3, 4, 3, 3, 4, 2, 1],
                    [1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1],
                    [1, 2, 2, 4, 2, 3, 3, 3, 3, 3, 3, 3, 2, 4, 2, 2, 1],
                    [1, 2, 2, 2, 2, 4, 2, 2, 4, 2, 2, 4, 2, 2, 2, 2, 1],
                    [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1],
                    [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]

        universes = {1 : mox43, 2 : mox7, 3 : mox87,
                     4 : guide_tube, 5 : fission_chamber}

        for i in range(17):
            for j in range(17):
                template[i][j] = universes[template[i][j]]

        assembly.setUniverses([template])

        # Root Cell/Universe
        root_cell = openmoc.Cell(name='Full Geometry')
        root_cell.setFill(assembly)
        root_cell.addSurface(+1, xmin)
        root_cell.addSurface(-1, xmax)
        root_cell.addSurface(+1, ymin)
        root_cell.addSurface(-1, ymax)

        root_universe = openmoc.Universe(name='Root Universe')
        root_universe.addCell(root_cell)

        self.geometry = openmoc.Geometry()
        self.geometry.setRootUniverse(root_universe)

        super(PwrAssemblyInput, self).create_geometry()
Esempio n. 5
0
    def _run_openmoc(self):
        """Instantiate a complex region Geometry."""
        root_universe = openmoc.Universe(name='root universe')
        root_cell = openmoc.Cell(name='root cell')
        root_universe.addCell(root_cell)
        u1 = openmoc.Universe(name='universe 1')
        u2 = openmoc.Universe(name='universe 2 in c2')
        root_cell.setFill(u1)

        # Z-bounds at root level
        p1 = openmoc.ZPlane(z=-2.0, name='zmin')
        p1.setBoundaryType(openmoc.REFLECTIVE)
        p2 = openmoc.ZPlane(z=+2.0, name='zmax')
        p2.setBoundaryType(openmoc.INTERFACE)
        root_cell.addSurface(halfspace=+1, surface=p1)
        root_cell.addSurface(halfspace=-1, surface=p2)

        # Cells in the root cell
        c1 = openmoc.Cell(name='intersection cell')
        c2 = openmoc.Cell(name='union cell')
        c2a = openmoc.Cell(name='union cell 2')
        c3 = openmoc.Cell(name='unbound cell')
        u1.addCell(c1)
        u1.addCell(c2)
        u1.addCell(c3)
        # Setting the parent cell helps to find boundaries (in Z here)
        c3.setParent(root_cell)

        # Cell c2a in c2, to further test arborescence
        c2.setFill(u2)
        u2.addCell(c2a)
        c2.setParent(root_cell)
        c2a.setParent(c2)  # to test transitivity

        # Bounds for cell 1 : intersection region cell
        p11 = openmoc.XPlane(x=-2.0, name='xmin')
        p11.setBoundaryType(openmoc.REFLECTIVE)
        p12 = openmoc.YPlane(y=-2.0, name='ymin')
        p12.setBoundaryType(openmoc.VACUUM)
        p13 = openmoc.ZCylinder(x=0, y=0, radius=2.5, name='cylinder')
        p13.setBoundaryType(openmoc.INTERFACE)

        # addSurface assumes an intersection, which is what we want here
        c1.addSurface(halfspace=+1, surface=p11)
        c1.addSurface(halfspace=+1, surface=p12)
        c1.addSurface(halfspace=-1, surface=p13)

        # Bounds for cell 2 : union region cell
        p22 = openmoc.ZCylinder(x=4, y=4, radius=2.5, name='cylinder')
        p22.setBoundaryType(openmoc.INTERFACE)
        p23 = openmoc.ZCylinder(x=-2, y=-8, radius=3, name='cylinder')
        p23.setBoundaryType(openmoc.VACUUM)

        # To have a union, we need to use addLogicalNode and addSurfaceInRegion
        c2.addLogicalNode(1)
        c2.addSurfaceInRegion(halfspace=-1, surface=p22)
        c2.addSurfaceInRegion(halfspace=-1, surface=p23)

        # Plane limits area even more
        c2a.addLogicalNode(1)
        c2a.addSurfaceInRegion(halfspace=+1, surface=p11)

        # Add a material to a cell to know the number of groups
        c1.setFill(self.materials['UO2'])

        self.geometry = openmoc.Geometry()
        self.geometry.setRootUniverse(root_universe)

        # Dump geometry
        self.geometry.dumpToFile("geometry_file.geo")

        # Get rid of the geometry
        self.geometry = None

        # Reload the geometry
        self.geometry = openmoc.Geometry()
        self.geometry.loadFromFile("geometry_file.geo")

        # Dump geometry again
        self.geometry.dumpToFile("geometry_file_second.geo")
Esempio n. 6
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
Esempio n. 7
0
    def create_geometry(self):
        """Instantiate a 4x4 non-uniform simple lattice Geometry."""

        fuel_rings = 1
        moderator_rings = 1
        num_sectors = 8
        openmoc.set_line_length(120)

        r_fuel = 0.54
        r_clad = 0.57
        r_large = 0.60
        pin_pitch = 1.26
        gap_size = 0.05
        surfaces = {}
        surfaces['Pin Cell ZCylinder'] = openmoc.ZCylinder(
            x=0, y=0, radius=r_fuel, name='Pin Cell ZCylinder')
        surfaces['Clad Cell ZCylinder'] = openmoc.ZCylinder(
            x=0, y=0, radius=r_clad, name='Clad Cell ZCylinder')
        surfaces['large'] = openmoc.ZCylinder(x=0,
                                              y=0,
                                              radius=r_large,
                                              name='large')
        surfaces['z-inf'] = openmoc.ZPlane(z=-1.0E10)
        surfaces['z+inf'] = openmoc.ZPlane(z=1.0E10)

        cells = {}
        cells['fuel'] = openmoc.Cell()
        cells['clad'] = openmoc.Cell()
        cells['mod'] = openmoc.Cell()
        cells['uniform gap'] = openmoc.Cell()
        cells['large_fuel'] = openmoc.Cell()
        cells['large_mod'] = openmoc.Cell()

        cells['fuel'].addSurface(halfspace=-1,
                                 surface=surfaces['Pin Cell ZCylinder'])
        cells['fuel'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['fuel'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['fuel'].setFill(self.materials['UO2'])
        cells['fuel'].setNumSectors(num_sectors)
        cells['fuel'].setNumRings(fuel_rings)

        cells['clad'].addSurface(halfspace=+1,
                                 surface=surfaces['Pin Cell ZCylinder'])
        cells['clad'].addSurface(halfspace=-1,
                                 surface=surfaces['Clad Cell ZCylinder'])
        cells['clad'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['clad'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['clad'].setFill(self.materials['Clad'])
        cells['clad'].setNumSectors(num_sectors)

        cells['mod'].addSurface(halfspace=+1,
                                surface=surfaces['Clad Cell ZCylinder'])
        cells['mod'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['mod'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['mod'].setFill(self.materials['Water'])
        cells['mod'].setNumSectors(num_sectors)
        cells['mod'].setNumRings(moderator_rings)

        cells['uniform gap'].addSurface(halfspace=+1,
                                        surface=surfaces['z-inf'])
        cells['uniform gap'].addSurface(halfspace=-1,
                                        surface=surfaces['z+inf'])
        cells['uniform gap'].setFill(self.materials['Clad'])

        cells['large_fuel'].addSurface(halfspace=-1, surface=surfaces['large'])
        cells['large_fuel'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['large_fuel'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['large_fuel'].setFill(self.materials['UO2'])
        cells['large_fuel'].setNumSectors(num_sectors)

        cells['large_mod'].addSurface(halfspace=+1, surface=surfaces['large'])
        cells['large_mod'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['large_mod'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['large_mod'].setFill(self.materials['Water'])
        cells['large_mod'].setNumSectors(num_sectors)

        universes = {}
        universes['pin'] = openmoc.Universe()
        universes['pin'].addCell(cells['fuel'])
        universes['pin'].addCell(cells['clad'])
        universes['pin'].addCell(cells['mod'])

        universes['uniform gap'] = openmoc.Universe()
        universes['uniform gap'].addCell(cells['uniform gap'])

        universes['large_pin'] = openmoc.Universe()
        universes['large_pin'].addCell(cells['large_fuel'])
        universes['large_pin'].addCell(cells['large_mod'])

        lower_left = [0., 0., 0.]
        width = ([gap_size, pin_pitch, pin_pitch,
                  gap_size], [gap_size, pin_pitch, pin_pitch,
                              gap_size], [1.0, 1.5])
        lattice = openmoc.Lattice(name='lattice with gap')
        lattice.setWidths(width[0], width[1], width[2])
        lattice.setOffset(lower_left[0] + sum(width[0]) / 2.,
                          lower_left[1] + sum(width[1]) / 2.,
                          lower_left[2] + sum(width[2]) / 2.)

        f = universes['pin']
        g = universes['uniform gap']
        l = universes['large_pin']
        lattice.setUniverses([[[g, g, g, g], [g, f, f, g], [g, f, f, g],
                               [g, g, g, g]],
                              [[g, g, g, g], [g, f, f, g], [g, f, f, g],
                               [g, g, g, g]]])

        surfaces['Global x-'] = openmoc.XPlane(x=lower_left[0])
        surfaces['Global x+'] = openmoc.XPlane(x=lower_left[0] + sum(width[0]))
        surfaces['Global y-'] = openmoc.YPlane(y=lower_left[1])
        surfaces['Global y+'] = openmoc.YPlane(y=lower_left[1] + sum(width[1]))
        surfaces['Global z-'] = openmoc.ZPlane(z=lower_left[2])
        surfaces['Global z+'] = openmoc.ZPlane(z=lower_left[2] + sum(width[2]))

        surfaces['Global x-'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global x+'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global y-'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global y+'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global z-'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global z+'].setBoundaryType(openmoc.REFLECTIVE)

        root_cell = openmoc.Cell()
        root_cell.setFill(lattice)
        root_cell.addSurface(halfspace=+1, surface=surfaces['Global x-'])
        root_cell.addSurface(halfspace=-1, surface=surfaces['Global x+'])
        root_cell.addSurface(halfspace=+1, surface=surfaces['Global y-'])
        root_cell.addSurface(halfspace=-1, surface=surfaces['Global y+'])
        root_cell.addSurface(halfspace=+1, surface=surfaces['Global z-'])
        root_cell.addSurface(halfspace=-1, surface=surfaces['Global z+'])

        root_universe = openmoc.Universe()
        root_universe.addCell(root_cell)

        self.geometry = openmoc.Geometry()
        self.geometry.setRootUniverse(root_universe)

        super(NonUniformLatticeInput, self).create_geometry()
Esempio n. 8
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
Esempio n. 9
0
    def _run_openmoc(self):
        """Instantiate a complex region Geometry."""
        #                                ----------------
        #                              /                 \
        #             --------------- c2 (p22,p23) - u2 - c2a (p11)
        #           /               /
        #  u_r <- c_r (p1,p2) - u1 - c1 (p11,p12,p13)
        #           \             \
        #            ------------- c3
        root_universe = openmoc.Universe(name='root universe')
        root_cell = openmoc.Cell(name='root cell')
        u1 = openmoc.Universe(name='universe 1')
        u2 = openmoc.Universe(name='universe 2 in c2')
        root_cell.setFill(u1)

        # Z-bounds at root level
        p1 = openmoc.ZPlane(z=-2.0, name='zmin')
        p1.setBoundaryType(openmoc.REFLECTIVE)
        p2 = openmoc.ZPlane(z=+2.0, name='zmax')
        p2.setBoundaryType(openmoc.INTERFACE)
        root_cell.addSurface(halfspace=+1, surface=p1)
        root_cell.addSurface(halfspace=-1, surface=p2)

        # Cells in the root cell
        c1 = openmoc.Cell(name='intersection cell')
        c2 = openmoc.Cell(name='union cell')
        c2a = openmoc.Cell(name='union cell 2')
        c3 = openmoc.Cell(name='unbound cell')
        u1.addCell(c1)
        u1.addCell(c2)
        u1.addCell(c3)
        # Setting the parent cell helps to find boundaries (in Z here)
        c3.setParent(root_cell)

        # Cell c2a in c2, to further test arborescence
        c2.setFill(u2)
        u2.addCell(c2a)
        c2.setParent(root_cell)
        c2a.setParent(c2)  # to test transitivity

        # Bounds for cell 1 : intersection region cell
        p11 = openmoc.XPlane(x=-2.0, name='xmin')
        p11.setBoundaryType(openmoc.REFLECTIVE)
        p12 = openmoc.YPlane(y=-2.0, name='ymin')
        p12.setBoundaryType(openmoc.VACUUM)
        p13 = openmoc.ZCylinder(x=0, y=0, radius=2.5, name='cylinder')
        p13.setBoundaryType(openmoc.INTERFACE)

        # addSurface assumes an intersection, which is what we want here
        c1.addSurface(halfspace=+1, surface=p11)
        c1.addSurface(halfspace=+1, surface=p12)
        c1.addSurface(halfspace=-1, surface=p13)

        # Bounds for cell 2 : union region cell
        p22 = openmoc.ZCylinder(x=4, y=4, radius=2.5, name='cylinder')
        p22.setBoundaryType(openmoc.INTERFACE)
        p23 = openmoc.ZCylinder(x=-2, y=-8, radius=3, name='cylinder')
        p23.setBoundaryType(openmoc.VACUUM)

        # To have a union, we need to use addLogicalNode and addSurfaceInRegion
        c2.addLogicalNode(1)
        c2.addSurfaceInRegion(halfspace=-1, surface=p22)
        c2.addSurfaceInRegion(halfspace=-1, surface=p23)

        # Plane limits area even more
        c2a.addLogicalNode(1)
        c2a.addSurfaceInRegion(halfspace=+1, surface=p11)

        openmoc.set_log_level('NORMAL')
        for cell in [root_cell, c1, c2, c2a, c3]:
            py_printf('NORMAL', 'Cell: %s', cell.getName())
            py_printf('NORMAL', 'MinX: %f', cell.getMinX())
            py_printf('NORMAL', 'MinXBoundaryType: %s',
                      cell.getMinXBoundaryType())
            py_printf('NORMAL', 'MinY: %f', cell.getMinY())
            py_printf('NORMAL', 'MinYBoundaryType: %s',
                      cell.getMinYBoundaryType())
            py_printf('NORMAL', 'MinZ: %f', cell.getMinZ())
            py_printf('NORMAL', 'MinZBoundaryType: %s',
                      cell.getMinZBoundaryType())
            py_printf('NORMAL', 'MaxX: %f', cell.getMaxX())
            py_printf('NORMAL', 'MaxXBoundaryType: %s',
                      cell.getMaxXBoundaryType())
            py_printf('NORMAL', 'MaxY: %f', cell.getMaxY())
            py_printf('NORMAL', 'MaxYBoundaryType: %s',
                      cell.getMaxYBoundaryType())
            py_printf('NORMAL', 'MaxZ: %f', cell.getMaxZ())
            py_printf('NORMAL', 'MaxZBoundaryType: %s',
                      cell.getMaxZBoundaryType())
            py_printf('NORMAL', '')
Esempio n. 10
0
###############################################################################

openmoc.log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../')

###############################################################################
#                            Creating Surfaces
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating surfaces...')

boundary = openmoc.RectangularPrism(4., 4.)
boundary.setBoundaryType(openmoc.PERIODIC)

zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.3, name='fuel pin')

###############################################################################
#                            Creating Grid Spacer
###############################################################################

outer_box = openmoc.RectangularPrism(1.00, 1.00)
inner_box = openmoc.RectangularPrism(0.96, 0.96)
inner_complement = openmoc.Complement()
inner_complement.addNode(inner_box)

grid_spacer_region = openmoc.Intersection()
grid_spacer_region.addNode(outer_box)
grid_spacer_region.addNode(inner_complement)

###############################################################################
Esempio n. 11
0
fuel.setSigmaS(numpy.array([0.38259177]))
fuel.setChi(numpy.array([1.0]))

moderator.setSigmaT(numpy.array([0.841545641]))
moderator.setSigmaF(numpy.array([0.0]))
moderator.setNuSigmaF(numpy.array([0.0]))
moderator.setSigmaS(numpy.array([0.837794542]))
moderator.setChi(numpy.array([1.0]))

###############################################################################
#                            Creating Surfaces
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating surfaces...')

zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.4)
left = openmoc.XPlane(x=-0.635)
right = openmoc.XPlane(x=0.635)
top = openmoc.YPlane(y=0.635)
bottom = openmoc.YPlane(y=-0.635)

left.setBoundaryType(openmoc.REFLECTIVE)
right.setBoundaryType(openmoc.REFLECTIVE)
top.setBoundaryType(openmoc.REFLECTIVE)
bottom.setBoundaryType(openmoc.REFLECTIVE)

###############################################################################
#                             Creating Cells
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating cells...')
Esempio n. 12
0
gap = 0.5
surfaces = {}

# Instantiate surfaces
surfaces['Root x-min'] = openmoc.XPlane(x=-32.13, name='Root x-min')
surfaces['Root x-max'] = openmoc.XPlane(x=32.13, name='Root x-max')
surfaces['Root y-min'] = openmoc.YPlane(y=-32.13, name='Root y-min')
surfaces['Root y-max'] = openmoc.YPlane(y=32.13, name='Root y-max')
surfaces['Root Small z-min'] = openmoc.ZPlane(z=-32.13,
                                              name='Root Small z-min')
surfaces['Root Small z-max'] = openmoc.ZPlane(z=32.13, name='Root Small z-max')
surfaces['Root Big z-min'] = openmoc.ZPlane(z=-107.1, name='Root Big z-min')
surfaces['Root Big z-max'] = openmoc.ZPlane(z=107.1, name='Root Big z-max')
surfaces['Fuel Cylinder'] = openmoc.ZCylinder(x=0.0,
                                              y=0.0,
                                              radius=0.54,
                                              name='Fuel Cylinder')
surfaces['Gap Root x-min'] = openmoc.XPlane(x=-32.13 - 3 * gap,
                                            name='Gap Root x-min')
surfaces['Gap Root x-max'] = openmoc.XPlane(x=32.13 + 3 * gap,
                                            name='Gap Root x-max')
surfaces['Gap Root y-min'] = openmoc.YPlane(y=-32.13 - 3 * gap,
                                            name='Gap Root y-min')
surfaces['Gap Root y-max'] = openmoc.YPlane(y=32.13 + 3 * gap,
                                            name='Gap Root y-max')

surfaces['Root x-min'].setBoundaryType(openmoc.REFLECTIVE)
surfaces['Root x-max'].setBoundaryType(openmoc.VACUUM)
surfaces['Root y-min'].setBoundaryType(openmoc.VACUUM)
surfaces['Root y-max'].setBoundaryType(openmoc.REFLECTIVE)
surfaces['Root Small z-min'].setBoundaryType(openmoc.REFLECTIVE)
 def create_lattice(self):
 
     large_zcylinder = openmoc.ZCylinder(
         x=0.0, y=0.0, radius=0.4, name='large pin')
     medium_zcylinder = openmoc.ZCylinder(
         x=0.0, y=0.0, radius=0.3, name='medium pin')
     small_zcylinder = openmoc.ZCylinder(
         x=0.0, y=0.0, radius=0.2, name='small pin')
     x0_plane = openmoc.XPlane(x=0)
     y0_plane = openmoc.YPlane(y=0)
 
     large_fuel = openmoc.Cell(name='large pin fuel')
     large_fuel.setFill(self.materials['UO2'])
     large_fuel.addSurface(halfspace=-1, surface=large_zcylinder)
 
     large_moderator = openmoc.Cell(name='large pin moderator')
     large_moderator.setFill(self.materials['Water'])
     large_moderator.addSurface(halfspace=+1, surface=large_zcylinder)
     
     fuel_quads = [None]*4
     mod_quads = [None]*4
     for i in range(4):
         qname = " (quadrant {})".format(i + 1)
         fcell = openmoc.Cell(name='large fuel' + qname)
         fcell.setFill(self.materials['UO2'])
         fcell.addSurface(halfspace=-1, surface=large_zcylinder)
         mcell = openmoc.Cell(name='large mod' + qname)
         mcell.setFill(self.materials['Water'])
         mcell.addSurface(halfspace=+1, surface=large_zcylinder)
         # Add the appropriate quadrants
         xspace = 1 if i in (0, 3) else -1
         yspace = 1 if i in (0, 1) else -1
         fcell.addSurface(halfspace=xspace, surface=x0_plane)
         fcell.addSurface(halfspace=yspace, surface=y0_plane)
         mcell.addSurface(halfspace=xspace, surface=x0_plane)
         mcell.addSurface(halfspace=yspace, surface=y0_plane)
         fuel_quads[i] = fcell
         mod_quads[i] = mcell
 
     medium_fuel = openmoc.Cell(name='medium pin fuel')
     medium_fuel.setFill(self.materials['UO2'])
     medium_fuel.addSurface(halfspace=-1, surface=medium_zcylinder)
 
     medium_moderator = openmoc.Cell(name='medium pin moderator')
     medium_moderator.setFill(self.materials['Water'])
     medium_moderator.addSurface(halfspace=+1, surface=medium_zcylinder)
 
     small_fuel = openmoc.Cell(name='small pin fuel')
     small_fuel.setFill(self.materials['UO2'])
     small_fuel.addSurface(halfspace=-1, surface=small_zcylinder)
 
     small_moderator = openmoc.Cell(name='small pin moderator')
     small_moderator.setFill(self.materials['Water'])
     small_moderator.addSurface(halfspace=+1, surface=small_zcylinder)
 
     pin1 = openmoc.Universe(name='large pin cell')
     pin2 = openmoc.Universe(name='medium pin cell')
     pin3 = openmoc.Universe(name='small pin cell')
     pin4 = openmoc.Universe(name='large pin cell (quadrants)')
    
     pin1.addCell(large_fuel)
     pin1.addCell(large_moderator)
     pin2.addCell(medium_fuel)
     pin2.addCell(medium_moderator)
     pin3.addCell(small_fuel)
     pin3.addCell(small_moderator)
     for c in fuel_quads + mod_quads:
         pin4.addCell(c)
     
     ###################
     # SUBDIVIDE PINS  #
     ###################
     lleft = [-0.5]*2
     uright = [0.5]*2
     DIV = (2, 2)
     div1 = openmoc.Subdivider(DIV, lleft, uright)
     pin1_div = div1.get_subdivided_universe(pin1)
     div4 = openmoc.Subdivider(DIV, lleft, uright)
     pin4_div = div4.get_subdivided_universe(pin4)
 
     # 2x2 assembly
     lattice = openmoc.Lattice(name='2x2 lattice')
     lattice.setWidth(width_x=1.0, width_y=1.0)
     lattice.setUniverses([[[pin4_div,     pin3],
                            [pin1,     pin1_div]]])
     
     return lattice
Esempio n. 14
0
    def create_geometry(self):
        """Instantiate 4x4 non-uniform and axially extended lattice problem."""

        fuel_rings = 1
        moderator_rings = 1
        num_sectors = 8
        openmoc.set_line_length(120)

        r_fuel = 0.54
        r_clad = 0.57
        r_large = 0.60
        pin_pitch = 1.26
        gap_size = 0.05
        surfaces = {}
        surfaces['Pin Cell ZCylinder'] = openmoc.ZCylinder(
            x=0, y=0, radius=r_fuel, name='Pin Cell ZCylinder')
        surfaces['Clad Cell ZCylinder'] = openmoc.ZCylinder(
            x=0, y=0, radius=r_clad, name='Clad Cell ZCylinder')
        surfaces['large'] = openmoc.ZCylinder(x=0,
                                              y=0,
                                              radius=r_large,
                                              name='large')
        surfaces['z-inf'] = openmoc.ZPlane(z=-1.0E10)
        surfaces['z+inf'] = openmoc.ZPlane(z=1.0E10)

        cells = {}
        cells['fuel'] = openmoc.Cell()
        cells['clad'] = openmoc.Cell()
        cells['mod'] = openmoc.Cell()
        cells['uniform gap'] = openmoc.Cell()
        cells['large_fuel'] = openmoc.Cell()
        cells['large_mod'] = openmoc.Cell()

        cells['fuel'].addSurface(halfspace=-1,
                                 surface=surfaces['Pin Cell ZCylinder'])
        cells['fuel'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['fuel'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['fuel'].setFill(self.materials['UO2'])
        cells['fuel'].setNumSectors(num_sectors)
        cells['fuel'].setNumRings(fuel_rings)

        cells['clad'].addSurface(halfspace=+1,
                                 surface=surfaces['Pin Cell ZCylinder'])
        cells['clad'].addSurface(halfspace=-1,
                                 surface=surfaces['Clad Cell ZCylinder'])
        cells['clad'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['clad'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['clad'].setFill(self.materials['Clad'])
        cells['clad'].setNumSectors(num_sectors)

        cells['mod'].addSurface(halfspace=+1,
                                surface=surfaces['Clad Cell ZCylinder'])
        cells['mod'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['mod'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['mod'].setFill(self.materials['Water'])
        cells['mod'].setNumSectors(num_sectors)
        cells['mod'].setNumRings(moderator_rings)

        cells['uniform gap'].addSurface(halfspace=+1,
                                        surface=surfaces['z-inf'])
        cells['uniform gap'].addSurface(halfspace=-1,
                                        surface=surfaces['z+inf'])
        cells['uniform gap'].setFill(self.materials['Clad'])

        cells['large_fuel'].addSurface(halfspace=-1, surface=surfaces['large'])
        cells['large_fuel'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['large_fuel'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['large_fuel'].setFill(self.materials['UO2'])
        cells['large_fuel'].setNumSectors(num_sectors)

        cells['large_mod'].addSurface(halfspace=+1, surface=surfaces['large'])
        cells['large_mod'].addSurface(halfspace=+1, surface=surfaces['z-inf'])
        cells['large_mod'].addSurface(halfspace=-1, surface=surfaces['z+inf'])
        cells['large_mod'].setFill(self.materials['Water'])
        cells['large_mod'].setNumSectors(num_sectors)

        universes = {}
        universes['pin'] = openmoc.Universe()
        universes['pin'].addCell(cells['fuel'])
        universes['pin'].addCell(cells['clad'])
        universes['pin'].addCell(cells['mod'])

        universes['uniform gap'] = openmoc.Universe()
        universes['uniform gap'].addCell(cells['uniform gap'])

        universes['large_pin'] = openmoc.Universe()
        universes['large_pin'].addCell(cells['large_fuel'])
        universes['large_pin'].addCell(cells['large_mod'])

        lower_left = [0., 0., 0.]
        # set the XYZ widths of non-uniform lattice
        width = ([gap_size, pin_pitch, pin_pitch,
                  gap_size], [gap_size, pin_pitch, pin_pitch,
                              gap_size], [1.0] * 20)
        lattice = openmoc.Lattice(name='lattice with gap')
        lattice.setWidths(width[0], width[1], width[2])
        lattice.setOffset(lower_left[0] + sum(width[0]) / 2.,
                          lower_left[1] + sum(width[1]) / 2.,
                          lower_left[2] + sum(width[2]) / 2.)
        f = universes['pin']
        g = universes['uniform gap']
        l = universes['large_pin']
        a = numpy.array([[g, g, g, g], [g, f, f, g], [g, f, f, g],
                         [g, g, g, g]])
        fill_universes = numpy.tile(a, (20, 1, 1))

        # make the geometry axially heterogeneous
        fill_universes[2][1][1] = g
        fill_universes = fill_universes.tolist()
        lattice.setUniverses(fill_universes)

        surfaces['Global x-'] = openmoc.XPlane(x=lower_left[0])
        surfaces['Global x+'] = openmoc.XPlane(x=lower_left[0] + sum(width[0]))
        surfaces['Global y-'] = openmoc.YPlane(y=lower_left[1])
        surfaces['Global y+'] = openmoc.YPlane(y=lower_left[1] + sum(width[1]))
        surfaces['Global z-'] = openmoc.ZPlane(z=lower_left[2])
        surfaces['Global z+'] = openmoc.ZPlane(z=lower_left[2] + sum(width[2]))

        surfaces['Global x-'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global x+'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global y-'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global y+'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global z-'].setBoundaryType(openmoc.REFLECTIVE)
        surfaces['Global z+'].setBoundaryType(openmoc.REFLECTIVE)

        root_cell = openmoc.Cell()
        root_cell.setFill(lattice)
        root_cell.addSurface(halfspace=+1, surface=surfaces['Global x-'])
        root_cell.addSurface(halfspace=-1, surface=surfaces['Global x+'])
        root_cell.addSurface(halfspace=+1, surface=surfaces['Global y-'])
        root_cell.addSurface(halfspace=-1, surface=surfaces['Global y+'])
        root_cell.addSurface(halfspace=+1, surface=surfaces['Global z-'])
        root_cell.addSurface(halfspace=-1, surface=surfaces['Global z+'])

        root_universe = openmoc.Universe()
        root_universe.addCell(root_cell)

        self.geometry = openmoc.Geometry()
        self.geometry.setRootUniverse(root_universe)

        super(AxialExtendedInput, self).create_geometry()
Esempio n. 15
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
Esempio n. 16
0
xmin = openmoc.XPlane(x=-32.13, name='xmin')
xmax = openmoc.XPlane(x=32.13, name='xmax')
ymin = openmoc.YPlane(y=-32.13, name='ymin')
ymax = openmoc.YPlane(y=32.13, name='ymax')
zmin = openmoc.ZPlane(z=-32.13, name='zmin')
zmax = openmoc.ZPlane(z=32.13, name='zmax')

xmin.setBoundaryType(openmoc.REFLECTIVE)
xmax.setBoundaryType(openmoc.VACUUM)
ymin.setBoundaryType(openmoc.VACUUM)
ymax.setBoundaryType(openmoc.REFLECTIVE)

# Create ZCylinders for the fuel as well as to discretize the moderator into
# rings
fuel_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.54)
moderator_inner_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.58)
moderator_outer_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.62)

###############################################################################
######################   Creating Cells and Universes   #######################
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating cells...')

# Moderator rings
moderator_ring1 = openmoc.Cell()
moderator_ring2 = openmoc.Cell()
moderator_ring3 = openmoc.Cell()
moderator_ring1.setNumSectors(8)
moderator_ring2.setNumSectors(8)
Esempio n. 17
0
###############################################################################
#                            Creating Materials
###############################################################################

openmoc.log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../')

###############################################################################
#                            Creating Surfaces
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating surfaces...')

zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=1.0, name='pin')
left = openmoc.XPlane(x=-2.0, name='left')
right = openmoc.XPlane(x=2.0, name='right')
top = openmoc.YPlane(y=2.0, name='top')
bottom = openmoc.YPlane(y=-2.0, name='bottom')

left.setBoundaryType(openmoc.REFLECTIVE)
right.setBoundaryType(openmoc.REFLECTIVE)
top.setBoundaryType(openmoc.REFLECTIVE)
bottom.setBoundaryType(openmoc.REFLECTIVE)

###############################################################################
#                             Creating Cells
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating cells...')
Esempio n. 18
0
    def create_geometry(self):
        """Instantiate a 4x4 pin cell lattice Geometry."""

        xmin = openmoc.XPlane(x=-2.0, name='xmin')
        xmax = openmoc.XPlane(x=+2.0, name='xmax')
        ymax = openmoc.YPlane(y=+2.0, name='ymin')
        ymin = openmoc.YPlane(y=-2.0, name='ymax')
        boundaries = [xmin, xmax, ymin, ymax]

        large_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0,
                                            radius=0.4, name='large pin')
        medium_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0,
                                             radius=0.3, name='medium pin')
        small_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0,
                                            radius=0.2, name='small pin')

        for boundary in boundaries: boundary.setBoundaryType(openmoc.REFLECTIVE)

        large_fuel = openmoc.Cell(name='large pin fuel')
        large_fuel.setNumRings(3)
        large_fuel.setNumSectors(8)
        large_fuel.setFill(self.materials['UO2'])
        large_fuel.addSurface(halfspace=-1, surface=large_zcylinder)

        large_moderator = openmoc.Cell(name='large pin moderator')
        large_moderator.setNumSectors(8)
        large_moderator.setFill(self.materials['Water'])
        large_moderator.addSurface(halfspace=+1, surface=large_zcylinder)

        medium_fuel = openmoc.Cell(name='medium pin fuel')
        medium_fuel.setNumRings(3)
        medium_fuel.setNumSectors(8)
        medium_fuel.setFill(self.materials['UO2'])
        medium_fuel.addSurface(halfspace=-1, surface=medium_zcylinder)

        medium_moderator = openmoc.Cell(name='medium pin moderator')
        medium_moderator.setNumSectors(8)
        medium_moderator.setFill(self.materials['Water'])
        medium_moderator.addSurface(halfspace=+1, surface=medium_zcylinder)

        small_fuel = openmoc.Cell(name='small pin fuel')
        small_fuel.setNumRings(3)
        small_fuel.setNumSectors(8)
        small_fuel.setFill(self.materials['UO2'])
        small_fuel.addSurface(halfspace=-1, surface=small_zcylinder)

        small_moderator = openmoc.Cell(name='small pin moderator')
        small_moderator.setNumSectors(8)
        small_moderator.setFill(self.materials['Water'])
        small_moderator.addSurface(halfspace=+1, surface=small_zcylinder)

        lattice_cell = openmoc.Cell(name='lattice cell')

        root_cell = openmoc.Cell(name='root cell')
        root_cell.addSurface(halfspace=+1, surface=boundaries[0])
        root_cell.addSurface(halfspace=-1, surface=boundaries[1])
        root_cell.addSurface(halfspace=+1, surface=boundaries[2])
        root_cell.addSurface(halfspace=-1, surface=boundaries[3])

        pin1 = openmoc.Universe(name='large pin cell')
        pin2 = openmoc.Universe(name='medium pin cell')
        pin3 = openmoc.Universe(name='small pin cell')
        assembly = openmoc.Universe(name='2x2 lattice')
        root_universe = openmoc.Universe(name='root universe')

        pin1.addCell(large_fuel)
        pin1.addCell(large_moderator)
        pin2.addCell(medium_fuel)
        pin2.addCell(medium_moderator)
        pin3.addCell(small_fuel)
        pin3.addCell(small_moderator)
        assembly.addCell(lattice_cell)
        root_universe.addCell(root_cell)

        # 2x2 assembly
        lattice = openmoc.Lattice(name='2x2 lattice')
        lattice.setWidth(width_x=1.0, width_y=1.0)
        lattice.setUniverses([[[pin1, pin2], [pin1, pin3]]])
        lattice_cell.setFill(lattice)

        # 2x2 core
        core = openmoc.Lattice(name='2x2 core')
        core.setWidth(width_x=2.0, width_y=2.0)
        core.setUniverses([[[assembly, assembly], [assembly, assembly]]])
        root_cell.setFill(core)

        self.geometry = openmoc.Geometry()
        self.geometry.setRootUniverse(root_universe)

        super(SimpleLatticeInput, self).create_geometry()
Esempio n. 19
0
materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../')

###############################################################################
#                            Creating Surfaces
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating surfaces...')

left = openmoc.XPlane(x=-2.0, name='left')
right = openmoc.XPlane(x=2.0, name='right')
top = openmoc.YPlane(y=-2.0, name='top')
bottom = openmoc.YPlane(y=2.0, name='bottom')
boundaries = [left, right, top, bottom]

large_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.4, name='large pin')
medium_zcylinder = openmoc.ZCylinder(x=0.0,
                                     y=0.0,
                                     radius=0.3,
                                     name='medium pin')
small_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.2, name='small pin')

for boundary in boundaries:
    boundary.setBoundaryType(openmoc.REFLECTIVE)

###############################################################################
#                             Creating Cells
###############################################################################

openmoc.log.py_printf('NORMAL', 'Creating cells...')
max_iters = 50

# ## Initialize Materials

# In[3]:

materials = load_from_hdf5(filename='c5g7-mgxs-ensemble-uo2.h5',
                           directory='..')
print(materials.keys())

# ## Create Bounding Surfaces

# In[4]:

# Create ZCylinder for the fuel
fuel_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.54)

# ## Create Fuel Pins

# In[6]:

# Create ensemble of fuel pins
# 4.0%  UOX pin cell base case
Nmat = 100  # number of UO2 pin materials in the ensemble
uox40_array = []
gd_array = []

for n in range(Nmat):
    uo2_name = 'UO2-' + str(n)
    uox40_cell = openmoc.Cell()
    uox40_cell.setFill(materials[uo2_name])