def test_ids(self): openmoc.reset_universe_id() universe_2 = openmoc.Universe() self.assertEqual(universe_2.getId(), 1000001) openmoc.maximize_universe_id(10000000) universe_3 = openmoc.Universe() self.assertEqual(universe_3.getId(), 10000000)
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 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 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)
def test_rotations(self): # Test setting a rotation angle rotation = np.array([6, 2, 1]) with self.assertRaises(Exception): self.cell.setRotation(np.array([0, 2.])) with self.assertRaises(Exception): self.cell.setRotation(rotation, "fake") material = openmoc.Material() self.cell.setFill(material) with self.assertRaises(Exception): self.cell.setRotation(rotation) universe = openmoc.Universe() self.cell.setFill(universe) self.cell.setRotation(rotation, "radians") # Test retrieving a rotation angle with self.assertRaises(Exception): self.cell.retrieveRotation(3, "fake") degrees = self.cell.retrieveRotation(3, "degrees") radians = self.cell.retrieveRotation(3, "radians") np.testing.assert_array_almost_equal(degrees, rotation / np.pi * 180, 10) np.testing.assert_array_almost_equal(radians, rotation, 10)
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 setRootUniverse(self, boundary): # Root Cell self.root_cell = openmoc.Cell(name='Full Geometry') self.root_cell.setFill(self.assembly) self.root_cell.setRegion(boundary) # Root Universe self.root_universe = openmoc.Universe(name='Root Universe') self.root_universe.addCell(self.root_cell)
def test_universes(self): u4 = openmoc.Universe(name="Universe 4") self.lattice.updateUniverse(3, 3, 1, u4) self.assertEqual( self.lattice.getUniverse(3, 3, 1).getName(), "Universe 4") self.lattice.removeUniverse(self.universe) self.assertEqual(self.lattice.getUniverse(0, 1, 0), None)
def _to_openmoc_universe(self, name=""): if name: mesh_name = "x".join(np.array(self.division, dtype=str)) name += " (subdivided " + mesh_name + ")" uout = openmoc.Universe(name=name) cout = openmoc.Cell() cout.setFill(self) uout.addCell(cout) return uout
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 get_openmoc_universe(opencg_universe): """Return an OpenMOC universe corresponding to an OpenCG universe. Parameters ---------- opencg_universe : opencg.Universe OpenCG universe Returns ------- openmoc_universe : openmoc.Universe Equivalent OpenMOC universe """ cv.check_type('opencg_universe', opencg_universe, opencg.Universe) global OPENMOC_UNIVERSES universe_id = opencg_universe.id # If this Universe was already created, use it if universe_id in OPENMOC_UNIVERSES: return OPENMOC_UNIVERSES[universe_id] # Make all OpenCG Cells and Surfaces in this Universe compatible with OpenMOC make_opencg_cells_compatible(opencg_universe) # Create an OpenMOC Universe to represent this OpenCG Universe name = str(opencg_universe.name) openmoc_universe = openmoc.Universe(universe_id, name) # Convert all OpenCG Cells in this Universe to OpenMOC Cells opencg_cells = opencg_universe.cells for cell_id, opencg_cell in opencg_cells.items(): openmoc_cell = get_openmoc_cell(opencg_cell) openmoc_universe.addCell(openmoc_cell) # Add the OpenMOC Universe to the global collection of all OpenMOC Universes OPENMOC_UNIVERSES[universe_id] = openmoc_universe # Add the OpenCG Universe to the global collection of all OpenCG Universes OPENCG_UNIVERSES[universe_id] = opencg_universe return openmoc_universe
def test_translations(self): # Test setting a rotation angle translation = np.array([6, 2, 1]) with self.assertRaises(Exception): self.cell.setTranslation(np.array([0, 2.])) material = openmoc.Material() self.cell.setFill(material) with self.assertRaises(Exception): self.cell.setTranslation(translation) universe = openmoc.Universe() self.cell.setFill(universe) self.cell.setTranslation(translation) # Test retrieving a rotation angle output = self.cell.retrieveTranslation(3) np.testing.assert_array_almost_equal(translation, output, 10)
def get_openmoc_universe(openmc_universe): """Return an OpenMOC universe corresponding to an OpenMC universe. Parameters ---------- openmc_universe : openmc.Universe OpenMC universe Returns ------- openmoc_universe : openmoc.Universe Equivalent OpenMOC universe """ cv.check_type('openmc_universe', openmc_universe, openmc.Universe) universe_id = openmc_universe.id # If this Universe was already created, use it if universe_id in OPENMOC_UNIVERSES: return OPENMOC_UNIVERSES[universe_id] # Create an OpenMOC Universe to represent this OpenMC Universe name = openmc_universe.name openmoc_universe = openmoc.Universe(universe_id, name) # Convert all OpenMC Cells in this Universe to OpenMOC Cells openmc_cells = openmc_universe.cells for openmc_cell in openmc_cells.values(): openmoc_cell = get_openmoc_cell(openmc_cell) openmoc_universe.addCell(openmoc_cell) # Add the OpenMC Universe to the global collection of all OpenMC Universes OPENMC_UNIVERSES[universe_id] = openmc_universe # Add the OpenMOC Universe to the global collection of all OpenMOC Universes OPENMOC_UNIVERSES[universe_id] = openmoc_universe return openmoc_universe
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 get_openmoc_universe(opencg_universe): if not isinstance(opencg_universe, opencg.Universe): msg = 'Unable to create an OpenMOC Universe from {0} which ' \ 'is not an OpenCG Universe'.format(opencg_universe) raise ValueError(msg) global OPENMOC_UNIVERSES universe_id = opencg_universe._id # If this Universe was already created, use it if universe_id in OPENMOC_UNIVERSES: return OPENMOC_UNIVERSES[universe_id] # Make all OpenCG Cells and Surfaces in this Universe compatible with OpenMOC make_opencg_cells_compatible(opencg_universe) # Create an OpenMOC Universe to represent this OpenCG Universe name = opencg_universe._name openmoc_universe = openmoc.Universe(universe_id, name) # Convert all OpenCG Cells in this Universe to OpenMOC Cells opencg_cells = opencg_universe._cells for cell_id, opencg_cell in opencg_cells.items(): openmoc_cell = get_openmoc_cell(opencg_cell) openmoc_universe.addCell(openmoc_cell) # Add the OpenMOC Universe to the global collection of all OpenMOC Universes OPENMOC_UNIVERSES[universe_id] = openmoc_universe # Add the OpenCG Universe to the global collection of all OpenCG Universes OPENCG_UNIVERSES[universe_id] = opencg_universe # FIXME openmoc_universe.thisown = 0 return openmoc_universe
def _subdivide2d(self, target): nx, ny = self.division dx, dy = self.deltas x0 = nx * dx / 2 y0 = -ny * dy / 2 universes = [[None for _ in range(nx)] for _ in range(ny)] # for 2D, no translation in z tz = 0 for j in range(ny): # translation in y ty = y0 + dy * (j + .5) for i in range(nx): # translation in x tx = x0 - dx * (i + .5) t_vector = np.array([tx, ty, tz]) cell = openmoc.Cell() cell.setFill(target) cell.setTranslation(t_vector) univ = openmoc.Universe() univ.addCell(cell) universes[j][i] = univ self.setUniverses([universes]) return self._to_openmoc_universe(name=target.getName())
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")
import openmoc from cells import cells ############################################################################### # Creating Universes ############################################################################### universes = {} universes['Region 1'] = openmoc.Universe(name='Region 1') universes['Region 2'] = openmoc.Universe(name='Region 2') universes['Region 3'] = openmoc.Universe(name='Region 3') universes['Region 4'] = openmoc.Universe(name='Region 4') universes['Region 5'] = openmoc.Universe(name='Region 5') universes['Region 1 Assembly'] = openmoc.Universe(name='Region 1 Assembly') universes['Region 2 Assembly'] = openmoc.Universe(name='Region 2 Assembly') universes['Region 3 Assembly'] = openmoc.Universe(name='Region 3 Assembly') universes['Region 4 Assembly'] = openmoc.Universe(name='Region 4 Assembly') universes['Region 5 Assembly'] = openmoc.Universe(name='Region 5 Assembly') universes['Root'] = openmoc.Universe(name='Root') # Add cells to universes universes['Region 1'] .addCell(cells['Region 1']) universes['Region 2'] .addCell(cells['Region 2']) universes['Region 3'] .addCell(cells['Region 3']) universes['Region 4'] .addCell(cells['Region 4']) universes['Region 5'] .addCell(cells['Region 5']) universes['Region 1 Assembly'].addCell(cells['Region 1 Assembly']) universes['Region 2 Assembly'].addCell(cells['Region 2 Assembly']) universes['Region 3 Assembly'].addCell(cells['Region 3 Assembly']) universes['Region 4 Assembly'].addCell(cells['Region 4 Assembly'])
source_cell.setFill(materials['Water']) root_cell = openmoc.Cell(name='root cell') 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 ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating universes...') water_univ = openmoc.Universe(name='water') source_univ = openmoc.Universe(name='source') root_universe = openmoc.Universe(name='root universe') water_univ.addCell(water_cell) source_univ.addCell(source_cell) root_universe.addCell(root_cell) ############################################################################### # Creating Lattices ############################################################################### # Number of lattice cells num_x = 200 num_y = 200
cells[11].setFill(materials['Water']) # Add the boundary Planes to the "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]) ############################################################################### # Creating Universes ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating universes...') u1 = openmoc.Universe(name='pin 1') u2 = openmoc.Universe(name='pin 2') u3 = openmoc.Universe(name='pin 3') u4 = openmoc.Universe(name='pin 4') u5 = openmoc.Universe(name='pin 5') u6 = openmoc.Universe(name='pin 6') u7 = openmoc.Universe(name='2x2 lattice') u8 = openmoc.Universe(name='2x2 lattice') root_universe = openmoc.Universe(name='root universe') # Add the appropriate Cells to each Universe u1.addCell(cells[0]) u1.addCell(cells[1]) u2.addCell(cells[2]) u2.addCell(cells[3]) u3.addCell(cells[4])
small_moderator.addSurface(halfspace=+1, surface=small_zcylinder) 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]) ############################################################################### # Creating Universes ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating universes...') pin1 = openmoc.Universe(name='large pin cell') pin2 = openmoc.Universe(name='medium pin cell') pin3 = openmoc.Universe(name='small pin cell') 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) root_universe.addCell(root_cell) ############################################################################### # Creating Lattices
import openmoc from cells import cells ############################################################################### # Creating Universes ############################################################################### universes = {} universes['Core'] = openmoc.Universe(name='Core') universes['Reflector'] = openmoc.Universe(name='Reflector') universes['Control Rod'] = openmoc.Universe(name='Control Rod') universes['Void'] = openmoc.Universe(name='Void') universes['Root'] = openmoc.Universe(name='Root') # Add cells to universes universes['Core'].addCell(cells['Core']) universes['Control Rod'].addCell(cells['Control Rod']) universes['Reflector'].addCell(cells['Reflector']) universes['Void'].addCell(cells['Void']) universes['Root'].addCell(cells['Root'])
import openmoc from cells import cells, surfaces from surfaces import gap ############################################################################### ########################## Creating Universes ############################# ############################################################################### universes = {} # Instantiate Cells universes['Root'] = openmoc.Universe() universes['Gap Root'] = openmoc.Universe() universes['UO2'] = openmoc.Universe() universes['MOX 4.3%'] = openmoc.Universe() universes['MOX 7.0%'] = openmoc.Universe() universes['MOX 8.7%'] = openmoc.Universe() universes['Guide Tube'] = openmoc.Universe() universes['Fission Chamber'] = openmoc.Universe() universes['Control Rod'] = openmoc.Universe() universes['Moderator Pin'] = openmoc.Universe() universes['Reflector'] = openmoc.Universe() universes['Refined Reflector Mesh'] = openmoc.Universe() universes['UO2 Unrodded Assembly'] = openmoc.Universe() universes['UO2 Rodded Assembly'] = openmoc.Universe() universes['MOX Unrodded Assembly'] = openmoc.Universe() universes['MOX Rodded Assembly'] = openmoc.Universe() universes['Reflector Unrodded Assembly'] = openmoc.Universe() universes['Reflector Rodded Assembly'] = openmoc.Universe() universes['Reflector Right Assembly'] = openmoc.Universe() universes['Reflector Bottom Assembly'] = openmoc.Universe()
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]) ############################################################################### # Creating Universes ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating universes...') 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) ###############################################################################
openmoc.log.py_printf('NORMAL', 'Creating cells...') cell = openmoc.Cell() cell.setFill(infinite_medium) cell.addSurface(halfspace=+1, surface=left) cell.addSurface(halfspace=-1, surface=right) cell.addSurface(halfspace=+1, surface=bottom) cell.addSurface(halfspace=-1, surface=top) ############################################################################### # Creating Universes ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating universes...') root_universe = openmoc.Universe(name='root universe') root_universe.addCell(cell) ############################################################################### # Creating the Geometry ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating geometry...') geometry = openmoc.Geometry() geometry.setRootUniverse(root_universe) ############################################################################### # Creating the TrackGenerator ###############################################################################
top = openmoc.YPlane(y=82.5) left.setBoundaryType(openmoc.REFLECTIVE) right.setBoundaryType(openmoc.VACUUM) bottom.setBoundaryType(openmoc.REFLECTIVE) top.setBoundaryType(openmoc.VACUUM) ############################################################################### # Creating Cells and Universes ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating cells...') # Region 1 region1_cell = openmoc.Cell(name='region 1') region1_cell.setFill(materials['region_1']) region1 = openmoc.Universe(name='region 1') region1.addCell(region1_cell) # Region 2 region2_cell = openmoc.Cell(name='region 2') region2_cell.setFill(materials['region_2']) region2 = openmoc.Universe(name='region 2') region2.addCell(region2_cell) # Region 3 region3_cell = openmoc.Cell(name='region 3') region3_cell.setFill(materials['region_3']) region3 = openmoc.Universe(name='region 3') region3.addCell(region3_cell) # Region 4
def _run_openmoc(self): openmoc.set_log_level('NORMAL') c1 = openmoc.Cell() c2 = openmoc.Cell() s1 = openmoc.XPlane(-40.) s2 = openmoc.XPlane(-50.) s3 = openmoc.XPlane(-60.) s1.setBoundaryType(openmoc.VACUUM) s2.setBoundaryType(openmoc.PERIODIC) s3.setBoundaryType(openmoc.REFLECTIVE) c1.addSurface(+1, s1) c2.addSurface(+1, s2) c2.addSurface(+1, s3) u = openmoc.Universe() u.addCell(c1) u.addCell(c2) boundary = u.getMinXBoundaryType() if boundary == 0: boundary = 'VACUUM' elif boundary == 1: boundary = 'REFLECTIVE' elif boundary == 2: boundary = 'PERIODIC' else: boundary = 'BOUNDARY_NONE' py_printf('NORMAL', 'MinX: %f', u.getMinX()) py_printf('NORMAL', 'MinXBoundaryType: %s', boundary) py_printf('SEPARATOR', '') c1 = openmoc.Cell() c2 = openmoc.Cell() s1 = openmoc.YPlane(-40.) s2 = openmoc.YPlane(-50.) s3 = openmoc.YPlane(-60.) s1.setBoundaryType(openmoc.VACUUM) s2.setBoundaryType(openmoc.PERIODIC) s3.setBoundaryType(openmoc.REFLECTIVE) c1.addSurface(+1, s1) c2.addSurface(+1, s2) c2.addSurface(+1, s3) u = openmoc.Universe() u.addCell(c1) u.addCell(c2) boundary = u.getMinYBoundaryType() if boundary == 0: boundary = 'VACUUM' elif boundary == 1: boundary = 'REFLECTIVE' elif boundary == 2: boundary = 'PERIODIC' else: boundary = 'BOUNDARY_NONE' py_printf('NORMAL', 'MinY: %f', u.getMinY()) py_printf('NORMAL', 'MinYBoundaryType: %s', boundary) py_printf('SEPARATOR', '') c1 = openmoc.Cell() c2 = openmoc.Cell() s1 = openmoc.ZPlane(-40.) s2 = openmoc.ZPlane(-50.) s3 = openmoc.ZPlane(-60.) s1.setBoundaryType(openmoc.VACUUM) s2.setBoundaryType(openmoc.PERIODIC) s3.setBoundaryType(openmoc.REFLECTIVE) c1.addSurface(+1, s1) c2.addSurface(+1, s2) c2.addSurface(+1, s3) u = openmoc.Universe() u.addCell(c1) u.addCell(c2) boundary = u.getMinZBoundaryType() if boundary == 0: boundary = 'VACUUM' elif boundary == 1: boundary = 'REFLECTIVE' elif boundary == 2: boundary = 'PERIODIC' else: boundary = 'BOUNDARY_NONE' py_printf('NORMAL', 'MinZ: %f', u.getMinZ()) py_printf('NORMAL', 'MinZBoundaryType: %s', boundary) py_printf('SEPARATOR', '') c1 = openmoc.Cell() c2 = openmoc.Cell() s1 = openmoc.XPlane(40.) s2 = openmoc.XPlane(50.) s3 = openmoc.XPlane(60.) s1.setBoundaryType(openmoc.VACUUM) s2.setBoundaryType(openmoc.PERIODIC) s3.setBoundaryType(openmoc.REFLECTIVE) c1.addSurface(-1, s1) c2.addSurface(-1, s2) c2.addSurface(-1, s3) u = openmoc.Universe() u.addCell(c1) u.addCell(c2) boundary = u.getMaxXBoundaryType() if boundary == 0: boundary = 'VACUUM' elif boundary == 1: boundary = 'REFLECTIVE' elif boundary == 2: boundary = 'PERIODIC' else: boundary = 'BOUNDARY_NONE' py_printf('NORMAL', 'MaxX: %f', u.getMaxX()) py_printf('NORMAL', 'MaxXBoundaryType: %s', boundary) py_printf('SEPARATOR', '') c1 = openmoc.Cell() c2 = openmoc.Cell() s1 = openmoc.YPlane(40.) s2 = openmoc.YPlane(50.) s3 = openmoc.YPlane(60.) s1.setBoundaryType(openmoc.VACUUM) s2.setBoundaryType(openmoc.PERIODIC) s3.setBoundaryType(openmoc.REFLECTIVE) c1.addSurface(-1, s1) c2.addSurface(-1, s2) c2.addSurface(-1, s3) u = openmoc.Universe() u.addCell(c1) u.addCell(c2) boundary = u.getMaxYBoundaryType() if boundary == 0: boundary = 'VACUUM' elif boundary == 1: boundary = 'REFLECTIVE' elif boundary == 2: boundary = 'PERIODIC' else: boundary = 'BOUNDARY_NONE' py_printf('NORMAL', 'MaxY: %f', u.getMaxY()) py_printf('NORMAL', 'MaxYBoundaryType: %s', boundary) py_printf('SEPARATOR', '') c1 = openmoc.Cell() c2 = openmoc.Cell() s1 = openmoc.ZPlane(40.) s2 = openmoc.ZPlane(50.) s3 = openmoc.ZPlane(60.) s1.setBoundaryType(openmoc.VACUUM) s2.setBoundaryType(openmoc.PERIODIC) s3.setBoundaryType(openmoc.REFLECTIVE) c1.addSurface(-1, s1) c2.addSurface(-1, s2) c2.addSurface(-1, s3) u = openmoc.Universe() u.addCell(c1) u.addCell(c2) boundary = u.getMaxZBoundaryType() if boundary == 0: boundary = 'VACUUM' elif boundary == 1: boundary = 'REFLECTIVE' elif boundary == 2: boundary = 'PERIODIC' else: boundary = 'BOUNDARY_NONE' py_printf('NORMAL', 'MaxZ: %f', u.getMaxZ()) py_printf('NORMAL', 'MaxZBoundaryType: %s', boundary) py_printf('SEPARATOR', '') sW = openmoc.XPlane(10) sE = openmoc.XPlane(20) sS = openmoc.YPlane(30) sN = openmoc.YPlane(40) sB = openmoc.ZPlane(50) sT = openmoc.ZPlane(60) sW.setBoundaryType(openmoc.VACUUM) sE.setBoundaryType(openmoc.REFLECTIVE) sS.setBoundaryType(openmoc.VACUUM) sN.setBoundaryType(openmoc.REFLECTIVE) sB.setBoundaryType(openmoc.PERIODIC) sT.setBoundaryType(openmoc.REFLECTIVE) sX_mid = openmoc.XPlane(15) sY_mid = openmoc.YPlane(35) sZ_mid = openmoc.ZPlane(55) sX_mid.setBoundaryType(openmoc.BOUNDARY_NONE) sY_mid.setBoundaryType(openmoc.BOUNDARY_NONE) sZ_mid.setBoundaryType(openmoc.BOUNDARY_NONE) cell = openmoc.Cell() cell.addSurface(+1, sW) cell.addSurface(-1, sE) cell.addSurface(+1, sS) cell.addSurface(-1, sN) cell.addSurface(+1, sB) cell.addSurface(-1, sT) cell.addSurface(+1, sX_mid) cell.addSurface(-1, sX_mid) cell.addSurface(+1, sY_mid) cell.addSurface(-1, sY_mid) cell.addSurface(+1, sZ_mid) cell.addSurface(-1, sZ_mid) univ = openmoc.Universe() univ.addCell(cell) py_printf('NORMAL', 'MinX: %f', univ.getMinX()) py_printf('NORMAL', 'MinXBoundaryType: %s', univ.getMinXBoundaryType()) py_printf('NORMAL', 'MinY: %f', univ.getMinY()) py_printf('NORMAL', 'MinYBoundaryType: %s', univ.getMinYBoundaryType()) py_printf('NORMAL', 'MinZ: %f', univ.getMinZ()) py_printf('NORMAL', 'MinZBoundaryType: %s', univ.getMinZBoundaryType()) py_printf('NORMAL', 'MaxX: %f', univ.getMaxX()) py_printf('NORMAL', 'MaxXBoundaryType: %s', univ.getMaxXBoundaryType()) py_printf('NORMAL', 'MaxY: %f', univ.getMaxY()) py_printf('NORMAL', 'MaxYBoundaryType: %s', univ.getMaxYBoundaryType()) py_printf('NORMAL', 'MaxZ: %f', univ.getMaxZ()) py_printf('NORMAL', 'MaxZBoundaryType: %s', univ.getMaxZBoundaryType())
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)