def test_ids(self): openmoc.reset_universe_id() lattice_2 = openmoc.Lattice() self.assertEqual(lattice_2.getId(), 1000016) openmoc.maximize_universe_id(10000000) lattice_3 = openmoc.Lattice() self.assertEqual(lattice_3.getId(), 10000000)
def __init__(self): # define fuel assembly basic parameters # CellFills for the assembly self.assembly1_cell = openmoc.Cell(name='Fuel Assembly') self.assembly1 = openmoc.Universe(name='Fuel Assembly') self.assembly1.addCell(self.assembly1_cell) # A mixed enrichment PWR MOX fuel assembly self.assembly = openmoc.Lattice(name='UOX Assembly') self.assembly.setWidth(width_x=1.26, width_y=1.26) # Create a template to map to pin cell types self.template = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 4, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 1], [1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 4, 1, 1, 4, 1, 1, 4, 1, 1, 4, 1, 1, 4, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 1, 4, 1, 1, 4, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 4, 1, 1, 4, 1, 1, 4, 1, 1, 4, 1, 1, 4, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1], [1, 1, 1, 1, 1, 4, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] self.root_cell = [] self.root_universe = []
def get_openmoc_lattice(opencg_lattice): """Return an OpenMOC lattice corresponding to an OpenCG lattice. Parameters ---------- opencg_lattice : opencg.Lattice OpenCG lattice Returns ------- openmoc_lattice : openmoc.Lattice Equivalent OpenMOC lattice """ cv.check_type('opencg_lattice', opencg_lattice, opencg.Lattice) global OPENMOC_LATTICES lattice_id = opencg_lattice.id # If this Lattice was already created, use it if lattice_id in OPENMOC_LATTICES: return OPENMOC_LATTICES[lattice_id] name = str(opencg_lattice.name) dimension = opencg_lattice.dimension width = opencg_lattice.width offset = opencg_lattice.offset universes = opencg_lattice.universes # Initialize an empty array for the OpenMOC nested Universes in this Lattice universe_array = np.ndarray(tuple(dimension[::-1]), dtype=openmoc.Universe) # Create OpenMOC Universes for each unique nested Universe in this Lattice unique_universes = opencg_lattice.get_unique_universes() for universe_id, universe in unique_universes.items(): unique_universes[universe_id] = get_openmoc_universe(universe) # Build the nested Universe array for z in range(dimension[2]): for y in range(dimension[1]): for x in range(dimension[0]): universe_id = universes[z][y][x].id universe_array[z][dimension[1] - y - 1][x] = unique_universes[universe_id] openmoc_lattice = openmoc.Lattice(lattice_id, name) openmoc_lattice.setWidth(width[0], width[1], width[2]) openmoc_lattice.setUniverses(universe_array.tolist()) openmoc_lattice.setOffset(offset[0], offset[1], offset[2]) # Add the OpenMOC Lattice to the global collection of all OpenMOC Lattices OPENMOC_LATTICES[lattice_id] = openmoc_lattice # Add the OpenCG Lattice to the global collection of all OpenCG Lattices OPENCG_LATTICES[lattice_id] = opencg_lattice return openmoc_lattice
def _create_geometry(self): """Put a box source in the cube.""" self.input_set.create_materials() self.input_set.create_geometry() # Get the root Cell cells = self.input_set.geometry.getAllCells() for cell_id in cells: cell = cells[cell_id] if cell.getName() == 'root cell': root_cell = cell # Apply VACUUM BCs on all bounding surfaces surfaces = root_cell.getSurfaces() for surface_id in surfaces: surface = surfaces[surface_id]._surface surface.setBoundaryType(openmoc.VACUUM) # Replace fissionable infinite medium material with C5G7 water self.materials = \ openmoc.materialize.load_from_hdf5(filename='c5g7-mgxs.h5', directory='../../sample-input/') lattice = openmoc.castUniverseToLattice(root_cell.getFillUniverse()) num_x = lattice.getNumX() num_y = lattice.getNumY() width_x = lattice.getWidthX() width_y = lattice.getWidthY() # Create cells filled with water to put in Lattice water_cell = openmoc.Cell(name='water') water_cell.setFill(self.materials['Water']) water_univ = openmoc.Universe(name='water') water_univ.addCell(water_cell) self.source_cell = openmoc.Cell(name='source') self.source_cell.setFill(self.materials['Water']) source_univ = openmoc.Universe(name='source') source_univ.addCell(self.source_cell) # Create 2D array of Universes in each lattice cell universes = [[[water_univ]*num_x for _ in range(num_y)]] # Place fixed source Universe at (x=0.5, y=0.5) source_x = 0.5 source_y = 0.5 lat_x = (root_cell.getMaxX() - source_x) / width_x lat_y = (root_cell.getMaxY() - source_y) / width_y universes[0][int(lat_x)][int(lat_y)] = source_univ # Create a new Lattice for the Universes lattice = openmoc.Lattice(name='{0}x{1} lattice'.format(num_x, num_y)) lattice.setWidth(width_x=width_x, width_y=width_y) lattice.setUniverses(universes) root_cell.setFill(lattice)
def setUp(self): self.lattice = openmoc.Lattice(id=12, name="test lattice") u1 = openmoc.Universe(name='Universe 1') self.universe = u1 u2 = openmoc.Universe(name='Universe 2') u3 = openmoc.Universe(name='Universe 3') self.lattice.setUniverses([[[u1, u2, u1, u2], [u2, u3, u2, u3], [u1, u2, u1, u2], [u2, u3, u2, u3]], [[u1, u2, u1, u2], [u2, u3, u2, u3], [u1, u2, u1, u2], [u2, u3, u2, u3]]]) self.cell = openmoc.Cell(name="test cell") self.lattice.addCell(self.cell)
def get_openmoc_lattice(opencg_lattice): if not isinstance(opencg_lattice, opencg.Lattice): msg = 'Unable to create an OpenMOC Lattice from {0} which ' \ 'is not an OpenCG Lattice'.format(opencg_lattice) raise ValueError(msg) global OPENMOC_LATTICES lattice_id = opencg_lattice._id # If this Lattice was already created, use it if lattice_id in OPENMOC_LATTICES: return OPENMOC_LATTICES[lattice_id] name = opencg_lattice._name dimension = opencg_lattice._dimension width = opencg_lattice._width offset = opencg_lattice._offset universes = opencg_lattice._universes # Initialize an empty array for the OpenMOC nested Universes in this Lattice universe_array = np.ndarray(tuple(np.array(dimension[0:2])), \ dtype=openmoc.Universe) # Create OpenMOC Universes for each unique nested Universe in this Lattice unique_universes = opencg_lattice.getUniqueUniverses() for universe_id, universe in unique_universes.items(): unique_universes[universe_id] = get_openmoc_universe(universe) # Build the nested Universe array for y in range(dimension[1]): for x in range(dimension[0]): universe_id = universes[0][y][x]._id universe_array[x][y] = unique_universes[universe_id] openmoc_lattice = openmoc.Lattice(lattice_id, name) openmoc_lattice.setWidth(width[0], width[1]) openmoc_lattice.setUniverses(universe_array.tolist()) openmoc_lattice.setOffset(offset[0], offset[1]) # Add the OpenMOC Lattice to the global collection of all OpenMOC Lattices OPENMOC_LATTICES[lattice_id] = openmoc_lattice # Add the OpenCG Lattice to the global collection of all OpenCG Lattices OPENCG_LATTICES[lattice_id] = opencg_lattice # FIXME openmoc_lattice.thisown = 0 return openmoc_lattice
def _get_results(self, num_iters=True, keff=True, fluxes=True, num_fsrs=True, num_tracks=True, num_segments=True, hash_output=True): """Digest info from the mesh tallies and return as a string.""" #NOTE Indexing in mesh tally is x,y,z and the mesh is a tuple # Create OpenMOC Mesh on which to tally fission rates mesh = openmoc.Mesh(self.solver) mesh.createLattice(4, 4) # List reaction rates wanted rxn_types = OrderedDict({ 'flux': openmoc.FLUX_RX, 'total': openmoc.TOTAL_RX, 'fission': openmoc.FISSION_RX, 'nu-fission': openmoc.NUFISSION_RX, 'absorption': openmoc.ABSORPTION_RX }) # Tally volume-integrated OpenMOC rates on the Mesh tallies = OrderedDict() for rxn, rxn_type in rxn_types.items(): tallies[rxn] = mesh.getReactionRates(rxn_types[rxn]) # Test defining a lattice from Python lattice = openmoc.Lattice() lattice.setNumX(4) lattice.setNumY(4) lattice.setNumZ(1) lattice.setWidth(10, 10, 1) lattice.computeSizes() mesh.setLattice(lattice) # Tally volume-averaged OpenMOC rates on the Mesh for rxn, rxn_type in rxn_types.items(): tallies[rxn + "-ave"] = mesh.getReactionRates(rxn_types[rxn], True) # Append reaction rates to the output string outstr = '' for rxn, rates in tallies.items(): outstr += rxn.title() + ' Rate Mesh Tally\n' rates = ['{0:12.6E}'.format(rate) for rate in rates] outstr += '\n'.join(rates) + '\n' return outstr
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()
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()
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
u5.addCell(cells[9]) u6.addCell(cells[10]) u6.addCell(cells[11]) u7.addCell(assembly1) u8.addCell(assembly2) root_universe.addCell(root_cell) ############################################################################### # Creating Lattices ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating 4 x 4 core of 17 x 17 assemblies...') # 1st 17x17 assembly a1 = openmoc.Lattice(name='assembly 1') a1.setWidth(width_x=1.0, width_y=1.0) a1.setUniverses([[ [u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1], [u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2], [u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1], [u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2], [u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1], [u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2], [u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1], [u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2], [u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1], [u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2], [u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1], [u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2, u3, u2], [u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1, u2, u1],
width_y = (root_universe.getMaxY() - root_universe.getMinY()) / num_x # Create 2D array of Universes in each lattice cell universes = [[[water_univ]*num_x for _ in range(num_y)]] # Place fixed source Universe at (x=10, y=10) source_x = 10 source_y = 10 lat_x = (root_universe.getMaxX() - source_x) / width_x lat_y = (root_universe.getMaxY() - source_y) / width_y universes[0][int(lat_x)][int(lat_y)] = source_univ openmoc.log.py_printf('NORMAL', \ 'Creating a {0}x{0} lattice...'.format(num_x, num_y)) lattice = openmoc.Lattice(name='{0}x{1} lattice'.format(num_x, num_y)) lattice.setWidth(width_x=width_x, width_y=width_y) lattice.setUniverses(universes) root_cell.setFill(lattice) ############################################################################### # Creating the Geometry ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating geometry...') geometry = openmoc.Geometry() geometry.setRootUniverse(root_universe)
pincell = openmoc.Universe(name='pin cell') root_universe = openmoc.Universe(name='root universe') pincell.addCell(fuel) pincell.addCell(moderator) root_universe.addCell(root_cell) ############################################################################### # Creating Lattices ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating simple 2 x 2 lattice...') lattice = openmoc.Lattice(name='2x2 lattice') lattice.setWidth(width_x=2.0, width_y=2.0) lattice.setUniverses([[[pincell, pincell], [pincell, pincell]]]) root_cell.setFill(lattice) ############################################################################### # Creating the Geometry ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating geometry...') geometry = openmoc.Geometry() geometry.setRootUniverse(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) root_universe.addCell(root_cell) ############################################################################### # Creating Lattices ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating simple 4 x 4 lattice...') lattice = openmoc.Lattice(name='4x4 lattice') lattice.setWidth(width_x=1.0, width_y=1.0) lattice.setUniverses([[[pin1, pin2, pin1, pin2], [pin2, pin3, pin2, pin3], [pin1, pin2, pin1, pin2], [pin2, pin3, pin2, pin3]]]) root_cell.setFill(lattice) ############################################################################### # Creating the Geometry ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating geometry...') geometry = openmoc.Geometry()
root_cell.addSurface(-1, boundaries[2]) root_cell.addSurface(+1, boundaries[3]) root_universe = openmoc.Universe(name='Root Universe') root_universe.addCell(root_cell) ############################################################################### # Creating Lattices ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating lattices...') lattices = list() # Top left, bottom right 17 x 17 assemblies lattices.append(openmoc.Lattice(name='Assembly 1')) lattices[-1].setWidth(width_x=1.26, width_y=1.26) template = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1], [1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 2, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 2, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1],
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)
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()
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()
def get_openmoc_lattice(openmc_lattice): """Return an OpenMOC lattice corresponding to an OpenMOC lattice. Parameters ---------- openmc_lattice : openmc.RectLattice OpenMC lattice Returns ------- openmoc_lattice : openmoc.Lattice Equivalent OpenMOC lattice """ cv.check_type('openmc_lattice', openmc_lattice, openmc.RectLattice) lattice_id = openmc_lattice.id # If this Lattice was already created, use it if lattice_id in OPENMOC_LATTICES: return OPENMOC_LATTICES[lattice_id] # Create an OpenMOC Lattice to represent this OpenMC Lattice name = openmc_lattice.name dimension = openmc_lattice.shape pitch = openmc_lattice.pitch lower_left = openmc_lattice.lower_left universes = openmc_lattice.universes # Convert 2D dimension to 3D for OpenMOC if len(dimension) == 2: new_dimension = np.ones(3, dtype=int) new_dimension[:2] = dimension dimension = new_dimension # Convert 2D pitch to 3D for OpenMOC if len(pitch) == 2: new_pitch = np.ones(3, dtype=np.float64) * np.finfo(np.float64).max new_pitch[:2] = pitch pitch = new_pitch # Convert 2D lower left to 3D for OpenMOC if len(lower_left) == 2: new_lower_left = np.ones(3, dtype=np.float64) new_lower_left *= np.finfo(np.float64).min / 2. new_lower_left[:2] = lower_left lower_left = new_lower_left # Convert 2D universes array to 3D for OpenMOC if len(universes.shape) == 2: new_universes = universes.copy() new_universes.shape = (1,) + universes.shape universes = new_universes # Initialize an empty array for the OpenMOC nested Universes in this Lattice universe_array = np.ndarray(tuple(dimension[::-1]), dtype=openmoc.Universe) # Create OpenMOC Universes for each unique nested Universe in this Lattice unique_universes = openmc_lattice.get_unique_universes() for universe_id, universe in unique_universes.items(): unique_universes[universe_id] = get_openmoc_universe(universe) # Build the nested Universe array for z in range(dimension[2]): for y in range(dimension[1]): for x in range(dimension[0]): universe_id = universes[z][y][x].id universe_array[z][y][x] = unique_universes[universe_id] openmoc_lattice = openmoc.Lattice(lattice_id, name) openmoc_lattice.setWidth(pitch[0], pitch[1], pitch[2]) openmoc_lattice.setUniverses(universe_array.tolist()) offset = np.array(lower_left, dtype=np.float64) - \ ((np.array(pitch, dtype=np.float64) * np.array(dimension, dtype=np.float64))) / -2.0 openmoc_lattice.setOffset(offset[0], offset[1], offset[2]) # Add the OpenMC Lattice to the global collection of all OpenMC Lattices OPENMC_LATTICES[lattice_id] = openmc_lattice # Add the OpenMOC Lattice to the global collection of all OpenMOC Lattices OPENMOC_LATTICES[lattice_id] = openmoc_lattice return openmoc_lattice
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()
pin = openmoc.Universe(name='pin cell') root_universe = openmoc.Universe(name='root universe') pin.addCell(fuel) pin.addCell(moderator) pin.addCell(grid_spacer) root_universe.addCell(root_cell) ############################################################################### # Creating Lattices ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating 4 x 4 lattice w/ grid spacers...') lattice = openmoc.Lattice(name='4x4 lattice w/ grid spacers') lattice.setWidth(width_x=1.0, width_y=1.0) lattice.setUniverses([[[pin, pin, pin, pin], [pin, pin, pin, pin], [pin, pin, pin, pin], [pin, pin, pin, pin]]]) root_cell.setFill(lattice) ############################################################################### # Creating the Geometry ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating geometry...') geometry = openmoc.Geometry() geometry.setRootUniverse(root_universe) ###############################################################################
import openmoc from universes import universes, cells ############################################################################### ########################### Creating Lattices ############################# ############################################################################### # The number of uniform refinements to perform on the assembly lattices refines = 10 lattices = {} # Instantiate Lattices lattices['Region 1 Assembly'] = openmoc.Lattice() lattices['Region 2 Assembly'] = openmoc.Lattice() lattices['Region 3 Assembly'] = openmoc.Lattice() lattices['Region 4 Assembly'] = openmoc.Lattice() lattices['Region 5 Assembly'] = openmoc.Lattice() lattices['Root'] = openmoc.Lattice() u1 = universes['Region 1'] u2 = universes['Region 2'] u3 = universes['Region 3'] u4 = universes['Region 4'] u5 = universes['Region 5'] lattices['Region 1 Assembly'].setWidth(15.0/refines, 15.0/refines) lattices['Region 1 Assembly'].setUniverses([[[u1] * refines] * refines]) lattices['Region 2 Assembly'].setWidth(15.0/refines, 15.0/refines) lattices['Region 2 Assembly'].setUniverses([[[u2] * refines] * refines])
root_cell.addSurface(halfspace=+1, surface=left) root_cell.addSurface(halfspace=-1, surface=right) root_cell.addSurface(halfspace=+1, surface=bottom) root_cell.addSurface(halfspace=-1, surface=top) ############################################################################# ########################## Creating Universes ########################## ############################################################################# fill_universe = openmoc.Universe(name='homogeneous fill cell') fill_universe.addCell(fill) root_universe = openmoc.Universe(name='root universe') root_universe.addCell(root_cell) ############################################################################# ########################### Creating Lattices ########################## ############################################################################# 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) ############################################################################# ######################### Creating the Geometry ######################### ############################################################################# geometry = openmoc.Geometry() geometry.setRootUniverse(root_universe)
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()
root_cell.addSurface(halfspace=+1, surface=left) root_cell.addSurface(halfspace=-1, surface=right) root_cell.addSurface(halfspace=+1, surface=bottom) root_cell.addSurface(halfspace=-1, surface=top) root_universe = openmoc.Universe(name='root universe') root_universe.addCell(root_cell) ############################################################################### # Creating Lattices ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating LRA lattices...') # Assembly 1 assembly1_lattice = openmoc.Lattice(name='assembly 1') assembly1_lattice.setWidth(width_x=1.5, width_y=1.5) template = [[region1] * 10] * 10 assembly1_lattice.setUniverses([template]) assembly1_cell.setFill(assembly1_lattice) # Assembly 2 assembly2_lattice = openmoc.Lattice(name='assembly 2') assembly2_lattice.setWidth(width_x=1.5, width_y=1.5) template = [[region2] * 10] * 10 assembly2_lattice.setUniverses([template]) assembly2_cell.setFill(assembly2_lattice) # Assembly 3 assembly3_lattice = openmoc.Lattice(name='assembly 3') assembly3_lattice.setWidth(width_x=1.5, width_y=1.5)
from surfaces import gap ############################################################################### ######################### Set Simulation Param ############################ ############################################################################### reflector_refines = 3 ############################################################################### ########################### Creating Lattices ############################# ############################################################################### lattices = {} # Instantiate Lattices lattices['Refined Reflector Mesh'] = openmoc.Lattice() lattices['Reflector Unrodded Assembly'] = openmoc.Lattice() lattices['Reflector Rodded Assembly'] = openmoc.Lattice() lattices['Reflector Right Assembly'] = openmoc.Lattice() lattices['Reflector Bottom Assembly'] = openmoc.Lattice() lattices['Reflector Corner Assembly'] = openmoc.Lattice() lattices['Reflector Assembly'] = openmoc.Lattice() lattices['UO2 Unrodded Assembly'] = openmoc.Lattice() lattices['UO2 Rodded Assembly'] = openmoc.Lattice() lattices['MOX Unrodded Assembly'] = openmoc.Lattice() lattices['MOX Rodded Assembly'] = openmoc.Lattice() lattices['Root'] = openmoc.Lattice() lattices['Gap Reflector Rodded Assembly'] = openmoc.Lattice() lattices['Gap Reflector Right Assembly'] = openmoc.Lattice() lattices['Gap Reflector Bottom Assembly'] = openmoc.Lattice()
import openmoc from universes import universes, cells ############################################################################### ########################### Creating Lattices ############################# ############################################################################### lattices = {} # Instantiate Lattices lattices['Root'] = openmoc.Lattice() # Fill cells with lattices cells['Root'].setFill(lattices['Root'])
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) ############################################################################### # Creating Lattices ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating nested 2 x 2 lattices...') # 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) ############################################################################### # Creating the Geometry ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating geometry...')
root_cell.addSurface(halfspace=+1, surface=zmin) root_cell.addSurface(halfspace=-1, surface=zmax) root_universe = openmoc.Universe(name='Root Universe') root_universe.addCell(root_cell) ############################################################################### ########################### Creating Lattices ############################# ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating lattices...') lattices = list() # Sliced up water cells - semi finely spaced lattices.append(openmoc.Lattice(name='Semi-Finely Spaced Reflector')) lattices[-1].setWidth(width_x=0.126, width_y=0.126) template = [[reflector] * 10] * 10 lattices[-1].setUniverses([template]) refined_reflector_cell.setFill(lattices[-1]) # UO2 unrodded 17 x 17 assemblies lattices.append(openmoc.Lattice(name='Assembly UO2 Unrodded')) lattices[-1].setWidth(width_x=1.26, width_y=1.26) template = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1], [1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],