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)
示例#2
0
def get_openmoc_geometry(openmc_geometry):
    """Return an OpenMC geometry corresponding to an OpenMOC geometry.

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

    Returns
    -------
    openmoc_geometry : openmoc.Geometry
        Equivalent OpenMOC geometry

    """

    cv.check_type('openmc_geometry', openmc_geometry, openmc.Geometry)

    # Clear dictionaries and auto-generated IDs
    OPENMC_SURFACES.clear()
    OPENMOC_SURFACES.clear()
    OPENMC_CELLS.clear()
    OPENMOC_CELLS.clear()
    OPENMC_UNIVERSES.clear()
    OPENMOC_UNIVERSES.clear()
    OPENMC_LATTICES.clear()
    OPENMOC_LATTICES.clear()

    openmc_root_universe = openmc_geometry.root_universe
    openmoc_root_universe = get_openmoc_universe(openmc_root_universe)

    openmoc_geometry = openmoc.Geometry()
    openmoc_geometry.setRootUniverse(openmoc_root_universe)

    # Update OpenMOC's auto-generated object IDs (e.g., Surface, Material)
    # with the maximum of those created from the OpenMC objects
    all_materials = openmoc_geometry.getAllMaterials()
    all_surfaces = openmoc_geometry.getAllSurfaces()
    all_cells = openmoc_geometry.getAllCells()
    all_universes = openmoc_geometry.getAllUniverses()

    max_material_id = max(all_materials.keys())
    max_surface_id = max(all_surfaces.keys())
    max_cell_id = max(all_cells.keys())
    max_universe_id = max(all_universes.keys())

    openmoc.maximize_material_id(max_material_id+1)
    openmoc.maximize_surface_id(max_surface_id+1)
    openmoc.maximize_cell_id(max_cell_id+1)
    openmoc.maximize_universe_id(max_universe_id+1)

    return openmoc_geometry
示例#3
0
    def create_geometry(self):
        """Instantiate a 3x2 grid Geometry by making a lattice"""

        # Create the planes bounding the geometry
        xmin = openmoc.XPlane(x=-3.0, name='xmin')
        xmax = openmoc.XPlane(x=3.0, name='xmax')
        ymin = openmoc.YPlane(y=-2.0, name='ymin')
        ymax = openmoc.YPlane(y=2.0, name='ymax')

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

        # Create the root cell, bounded by the geometry bounds
        root_cell = openmoc.Cell(name='root cell')
        root_cell.addSurface(halfspace=+1, surface=xmin)
        root_cell.addSurface(halfspace=-1, surface=xmax)
        root_cell.addSurface(halfspace=+1, surface=ymin)
        root_cell.addSurface(halfspace=-1, surface=ymax)

        # Create UO2, water, and tube cells
        uo2_cell = openmoc.Cell(name='UO2 Cell')
        uo2_cell.setFill(self.materials['UO2'])
        water_cell = openmoc.Cell(name='Water Cell')
        water_cell.setFill(self.materials['Water'])
        tube_cell = openmoc.Cell(name='Tube Cell')
        tube_cell.setFill(self.materials['Guide Tube'])

        # Create universes and fill with the associated cell
        root_universe = openmoc.Universe(name='root universe')
        root_universe.addCell(root_cell)
        uo2 = openmoc.Universe(name='uo2 universe')
        uo2.addCell(uo2_cell)
        water = openmoc.Universe(name='water universe')
        water.addCell(water_cell)
        tube = openmoc.Universe(name='tube universe')
        tube.addCell(tube_cell)

        # Create the lattice and fill it with the appropriate universes
        lattice = openmoc.Lattice(name='3x2 lattice')
        lattice.setWidth(width_x=2.0, width_y=2.0)
        lattice.setUniverses([[[uo2, tube, water], [water, uo2, tube]]])
        root_cell.setFill(lattice)

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

        super(OblongLatticeGridInput, self).create_geometry()
    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')
        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=-2.0, name='zmin')
            zmax = openmoc.ZPlane(z=+2.0, name='zmax')
            boundaries = [xmin, xmax, ymin, ymax, zmin, zmax]
        for boundary in boundaries:
            boundary.setBoundaryType(openmoc.REFLECTIVE)
        if (self.dimensions == 3):
            boundaries[-1].setBoundaryType(openmoc.VACUUM)

        lat = self.create_lattice()

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

        lattice_cell = openmoc.Cell(name='lattice cell')
        assembly = openmoc.Universe(name='2x2 lattice')
        root_universe = openmoc.Universe(name='root universe')
        assembly.addCell(lattice_cell)
        root_universe.addCell(root_cell)
        lattice_cell.setFill(lat)
        # 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(SimplerLatticeInput, self).create_geometry()
示例#5
0
    def create_geometry(self):
        """Instantiate an infinite medium lattice Geometry."""

        length = 2.5
        num_cells_x = 10
        num_cells_y = 10

        xmin = openmoc.XPlane(x=-length / 2., name='xmin')
        xmax = openmoc.XPlane(x=+length / 2., name='xmax')
        ymin = openmoc.YPlane(y=-length / 2., name='ymin')
        ymax = openmoc.YPlane(y=+length / 2., name='ymax')

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

        fill = openmoc.Cell(name='fill')
        fill.setFill(self.materials['infinite medium'])

        root_cell = openmoc.Cell(name='root cell')
        root_cell.addSurface(halfspace=+1, surface=xmin)
        root_cell.addSurface(halfspace=-1, surface=xmax)
        root_cell.addSurface(halfspace=+1, surface=ymin)
        root_cell.addSurface(halfspace=-1, surface=ymax)

        fill_universe = openmoc.Universe(name='homogeneous fill cell')
        fill_universe.addCell(fill)

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

        lattice = openmoc.Lattice(name='MxN lattice')
        lattice.setWidth(width_x=length / num_cells_x,
                         width_y=length / num_cells_y)
        lattice.setUniverses([[[fill_universe] * num_cells_x] * num_cells_y])
        root_cell.setFill(lattice)

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

        super(HomInfMedInput, self).create_geometry()
示例#6
0
def get_openmoc_geometry(opencg_geometry):

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

    # Deep copy the goemetry since it may be modified to make all Surfaces
    # compatible with OpenMOC's specifications
    opencg_geometry.assignAutoIds()
    opencg_geometry = copy.deepcopy(opencg_geometry)

    # Update Cell bounding boxes in Geometry
    opencg_geometry.updateBoundingBoxes()

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

    # Make the entire geometry "compatible" before assigning auto IDs
    universes = opencg_geometry.getAllUniverses()
    for universe_id, universe in universes.items():
        make_opencg_cells_compatible(universe)

    opencg_geometry.assignAutoIds()

    opencg_root_universe = opencg_geometry._root_universe
    openmoc_root_universe = get_openmoc_universe(opencg_root_universe)

    openmoc_geometry = openmoc.Geometry()
    openmoc_geometry.setRootUniverse(openmoc_root_universe)

    # FIXME
    openmoc_geometry.thisown = 0

    return openmoc_geometry
示例#7
0
    def _create_trackgenerator(self):
        """Dump and load the geometry then instantiate a TrackGenerator."""

        # Geometry should be dumped before FSRs are initialized
        # Dump the geometry
        self.input_set.geometry.dumpToFile("geometry_file.geo")

        # Get rid of the geometry
        self.input_set.geometry = None

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

        # Instantiate a TrackGenerator
        geometry = self.input_set.geometry
        geometry.initializeFlatSourceRegions()

        self.track_generator = \
            openmoc.TrackGenerator(geometry, self.num_azim,
                                     self.spacing)
示例#8
0
    def create_geometry(self):
        """Instantiate a 3x3 grid Geometry."""

        # Create the planes that bound the cell and geometry
        xplanes = [None] * 4
        yplanes = [None] * 4
        for i in range(4):
            val = -3.0 + 6.0/3 * i
            xplanes[i] = openmoc.XPlane(x=val, name='xplane' + str(i))
            yplanes[i] = openmoc.YPlane(y=val, name='yplane' + str(i))

        xplanes[0].setBoundaryType(openmoc.REFLECTIVE)
        xplanes[-1].setBoundaryType(openmoc.REFLECTIVE)
        yplanes[0].setBoundaryType(openmoc.REFLECTIVE)
        yplanes[-1].setBoundaryType(openmoc.REFLECTIVE)

        # Create the cells and set the central cell to UO2, the rest as water
        cells = [[None]*3 for i in range(3)]
        for i in range(3):
            for j in range(3):
                cells[i][j] = openmoc.Cell(name='Cell ' + str(3*i+j))
                if i == 1 and j == 1:
                    cells[i][j].setFill(self.materials['UO2'])
                else:
                    cells[i][j].setFill(self.materials['Water'])
                cells[i][j].addSurface(halfspace=+1, surface=xplanes[i])
                cells[i][j].addSurface(halfspace=-1, surface=xplanes[i+1])
                cells[i][j].addSurface(halfspace=+1, surface=yplanes[j])
                cells[i][j].addSurface(halfspace=-1, surface=yplanes[j+1])

        # Add the cells to the universe
        root_universe = openmoc.Universe(name='root universe')
        for i in range(3):
            for j in range(3):
                root_universe.addCell(cells[i][j])

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

        super(GridInput, self).create_geometry()
    def _create_geometry(self):
        """Initialize CMFD and add it to the Geometry."""

        self.input_set.geometry = openmoc.Geometry()

        # load a geometry file with a non-uniform lattice
        self.input_set.geometry.loadFromFile('non-uniform-lattice.geo')

        # dump geometry file, to test compatibility with the load operation
        self.input_set.geometry.dumpToFile('log/dump.geo')

        # Initialize CMFD
        cmfd = openmoc.Cmfd()
        cmfd.setCMFDRelaxationFactor(0.7)
        cmfd.setSORRelaxationFactor(1.0)
        cmfd.setWidths([[0.05, 1.26, 1.26, 0.05], [0.05, 1.26, 1.26, 0.05],
                        [1., 1.5]])
        cmfd.setGroupStructure([[1, 2, 3], [4, 5, 6, 7]])
        cmfd.setCentroidUpdateOn(False)

        # Add CMFD to the Geometry
        self.input_set.geometry.setCmfd(cmfd)
示例#10
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)

###############################################################################
#                         Creating the Geometry
###############################################################################

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

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

###############################################################################
#                          Creating the TrackGenerator
###############################################################################

openmoc.log.py_printf('NORMAL', 'Initializing the track generator...')

track_generator = openmoc.TrackGenerator(geometry, opts.num_azim,
                                         opts.track_spacing)
track_generator.setNumThreads(opts.num_omp_threads)
track_generator.generateTracks()

###############################################################################
#                            Running a Simulation
示例#11
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()
示例#12
0
def get_openmoc_geometry(opencg_geometry):
    """Return an OpenMOC geometry corresponding to an OpenCG geometry.

    Parameters
    ----------
    opencg_geometry : opencg.Geometry
        OpenCG geometry

    Returns
    -------
    openmoc_geometry : openmoc.Geometry
        Equivalent OpenMOC geometry

    """

    cv.check_type('opencg_geometry', opencg_geometry, opencg.Geometry)

    # Deep copy the goemetry since it may be modified to make all Surfaces
    # compatible with OpenMOC's specifications
    opencg_geometry.assign_auto_ids()
    opencg_geometry = copy.deepcopy(opencg_geometry)

    # Update Cell bounding boxes in Geometry
    opencg_geometry.update_bounding_boxes()

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

    # Make the entire geometry "compatible" before assigning auto IDs
    universes = opencg_geometry.get_all_universes()
    for universe_id, universe in universes.items():
        make_opencg_cells_compatible(universe)

    opencg_geometry.assign_auto_ids()

    opencg_root_universe = opencg_geometry.root_universe
    openmoc_root_universe = get_openmoc_universe(opencg_root_universe)

    openmoc_geometry = openmoc.Geometry()
    openmoc_geometry.setRootUniverse(openmoc_root_universe)

    # Update OpenMOC's auto-generated object IDs (e.g., Surface, Material)
    # with the maximum of those created from the OpenCG objects
    all_materials = openmoc_geometry.getAllMaterials()
    all_surfaces = openmoc_geometry.getAllSurfaces()
    all_cells = openmoc_geometry.getAllCells()
    all_universes = openmoc_geometry.getAllUniverses()

    max_material_id = max(all_materials.keys())
    max_surface_id = max(all_surfaces.keys())
    max_cell_id = max(all_cells.keys())
    max_universe_id = max(all_universes.keys())

    openmoc.maximize_material_id(max_material_id + 1)
    openmoc.maximize_surface_id(max_surface_id + 1)
    openmoc.maximize_cell_id(max_cell_id + 1)
    openmoc.maximize_universe_id(max_universe_id + 1)

    return openmoc_geometry
示例#13
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()
示例#14
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)
示例#15
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")
示例#16
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()
示例#17
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()
示例#18
0
    def _run_openmoc(self):

        runtime = openmoc.RuntimeParameters()

        string_input = [
            '-debug', '1', '-log_level', 'NORMAL', '-domain_decompose',
            '2,2,2', '-num_domain_modules', '1,1,1', '-num_threads', '1',
            '-log_filename', 'test_problem.log', '-geo_filename',
            'geometry_file.geo', '-azim_spacing', '0.22 ', '-num_azim', '4',
            '-polar_spacing', '0.8', '-num_polar', '6', '-seg_zones',
            '-5.0,5.0', '-segmentation_type', '3', '-quadraturetype', '2',
            '-CMFD_group_structure', '1/2,3,4/5,6,7', '-CMFD_lattice', '2,3,3',
            '-widths_x', '1,2*1,1', '-widths_y', '1,2*1,1', '-widths_z',
            '3.5,2.5*2,1.5', '-CMFD_flux_update_on', '1', '-knearest', '2',
            '-CMFD_centroid_update_on', '1', '-use_axial_interpolation', '2',
            '-SOR_factor', '1.5', '-CMFD_relaxation_factor', '0.7',
            '-ls_solver', '1', '-max_iters', '15', '-MOC_src_residual_type',
            '1', '-MOC_src_tolerance', '1.0E-2', '-output_mesh_lattice',
            '-output_mesh_lattice', ' 5,5,9', ' -output_type', ' 0',
            '-output_mesh_lattice', '-output_mesh_lattice', ' 5,5,9',
            ' -output_type', ' 1', '-non_uniform_output',
            '1.26*3/1*3/4.*3/-1.,1.,-1.', ' -output_type 1  ',
            '-verbose_report', '1', '-time_report', '1'
        ]
        string_input = [s.encode('utf8') for s in string_input]

        runtime.setRuntimeParameters(string_input)
        print(string_input)

        # Define simulation parameters
        num_threads = runtime._num_threads

        # Set logging information
        if (runtime._log_filename):
            openmoc.set_log_filename(runtime._log_filename)
        openmoc.set_log_level(runtime._log_level)
        openmoc.set_line_length(120)

        py_printf('NORMAL', 'Geometry file = %s', runtime._geo_filename)
        py_printf('NORMAL', 'Azimuthal spacing = %f', runtime._azim_spacing)
        py_printf('NORMAL', 'Azimuthal angles = %d', runtime._num_azim)
        py_printf('NORMAL', 'Polar spacing = %f', runtime._polar_spacing)
        py_printf('NORMAL', 'Polar angles = %d', runtime._num_polar)

        # Create the geometry
        py_printf('NORMAL', 'Creating geometry...')
        geometry = openmoc.Geometry()
        self.input_set.geometry = geometry
        if (not runtime._geo_filename):
            py_printf('ERROR', 'No geometry file is provided')
        geometry.loadFromFile(runtime._geo_filename)
        if False:  #FIXME
            geometry.setDomainDecomposition(runtime._NDx, runtime._NDy,
                                            runtime._NDz, MPI_COMM_WORLD)

        geometry.setNumDomainModules(runtime._NMx, runtime._NMy, runtime._NMz)

        if ((runtime._NCx > 0 and runtime._NCy > 0 and runtime._NCz > 0)
                or (not runtime._cell_widths_x.empty()
                    and not runtime._cell_widths_y.empty()
                    and not runtime._cell_widths_z.empty())):

            # Create CMFD mesh
            py_printf('NORMAL', 'Creating CMFD mesh...')
            cmfd = openmoc.Cmfd()
            cmfd.setSORRelaxationFactor(runtime._SOR_factor)
            cmfd.setCMFDRelaxationFactor(runtime._CMFD_relaxation_factor)
            if (runtime._cell_widths_x.empty()
                    or runtime._cell_widths_y.empty()
                    or runtime._cell_widths_z.empty()):
                cmfd.setLatticeStructure(runtime._NCx, runtime._NCy,
                                         runtime._NCz)
            else:
                cmfd_widths = [
                    runtime._cell_widths_x, runtime._cell_widths_y,
                    runtime._cell_widths_z
                ]
                cmfd.setWidths(cmfd_widths)

            if (not runtime._CMFD_group_structure.empty()):
                cmfd.setGroupStructure(runtime._CMFD_group_structure)
            cmfd.setKNearest(runtime._knearest)
            cmfd.setCentroidUpdateOn(runtime._CMFD_centroid_update_on)
            cmfd.useAxialInterpolation(runtime._use_axial_interpolation)

            geometry.setCmfd(cmfd)

        geometry.initializeFlatSourceRegions()

        # Initialize track generator and generate tracks
        py_printf('NORMAL', 'Initializing the track generator...')
        if runtime._quadraturetype == 0:
            quad = openmoc.TYPolarQuad()
        if runtime._quadraturetype == 1:
            quad = openmoc.LeonardPolarQuad()
        if runtime._quadraturetype == 2:
            quad = openmoc.GLPolarQuad()
        if runtime._quadraturetype == 3:
            quad = openmoc.EqualWeightPolarQuad()
        if runtime._quadraturetype == 4:
            quad = openmoc.EqualAnglePolarQuad()

        quad.setNumAzimAngles(runtime._num_azim)
        quad.setNumPolarAngles(runtime._num_polar)
        track_generator = openmoc.TrackGenerator3D(geometry, runtime._num_azim,
                                                   runtime._num_polar,
                                                   runtime._azim_spacing,
                                                   runtime._polar_spacing)
        track_generator.setNumThreads(num_threads)
        track_generator.setQuadrature(quad)
        track_generator.setSegmentFormation(runtime._segmentation_type)
        if (len(runtime._seg_zones) > 0):
            track_generator.setSegmentationZones(runtime._seg_zones)
        track_generator.generateTracks()
        self.track_generator = track_generator

        # Initialize solver and run simulation
        if (runtime._linear_solver):
            self.solver = openmoc.CPULSSolver(track_generator)
        else:
            self.solver = openmoc.CPUSolver(track_generator)
        if (runtime._verbose_report):
            self.solver.setVerboseIterationReport()
        self.solver.setNumThreads(num_threads)
        self.solver.setConvergenceThreshold(runtime._tolerance)
        self.solver.computeEigenvalue(runtime._max_iters,
                                      runtime._MOC_src_residual_type)

        if (runtime._time_report):
            self.solver.printTimerReport()

        # Extract reaction rates
        my_rank = 0
        #if False: #FIXME
        #MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
        rxtype = {'FISSION_RX', 'TOTAL_RX', 'ABSORPTION_RX', 'FLUX_RX'}