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_intersection(self): intersection = openmoc.Intersection() # Define surfaces p1x = openmoc.XPlane(x=3) p2x = openmoc.XPlane(x=-2) p1y = openmoc.YPlane(y=1) p2y = openmoc.YPlane(y=-0.5) p1z = openmoc.ZPlane(z=8) p2z = openmoc.ZPlane(z=-4) # Define boundary types p1x.setBoundaryType(openmoc.VACUUM) p2x.setBoundaryType(openmoc.REFLECTIVE) p1y.setBoundaryType(openmoc.PERIODIC) p2y.setBoundaryType(openmoc.REFLECTIVE) p1z.setBoundaryType(openmoc.PERIODIC) p2z.setBoundaryType(openmoc.VACUUM) # Define halfspaces h1x = openmoc.Halfspace(-1, p1x) h2x = openmoc.Halfspace(+1, p2x) h1y = openmoc.Halfspace(-1, p1y) h2y = openmoc.Halfspace(+1, p2y) h1z = openmoc.Halfspace(-1, p1z) h2z = openmoc.Halfspace(+1, p2z) # Add halfspaces intersection.addNode(h1x) intersection.addNode(h2x) intersection.addNode(h1y) intersection.addNode(h2y) intersection.addNode(h1z) intersection.addNode(h2z) # Test getMaxXYZ + MaxXYZboundary self.assertEqual(intersection.getMaxX(), 3) self.assertEqual(intersection.getMaxXBoundaryType(), openmoc.VACUUM) self.assertEqual(intersection.getMaxY(), 1) self.assertEqual(intersection.getMaxYBoundaryType(), openmoc.PERIODIC) self.assertEqual(intersection.getMaxZ(), 8) self.assertEqual(intersection.getMaxZBoundaryType(), openmoc.PERIODIC) # Test getMinXYZ + MinXYZboundary self.assertEqual(intersection.getMinX(), -2) self.assertEqual(intersection.getMinXBoundaryType(), openmoc.REFLECTIVE) self.assertEqual(intersection.getMinY(), -0.5) self.assertEqual(intersection.getMinYBoundaryType(), openmoc.REFLECTIVE) self.assertEqual(intersection.getMinZ(), -4) self.assertEqual(intersection.getMinZBoundaryType(), openmoc.VACUUM)
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_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()
basic_material = openmoc.Material(name='1-group infinite medium') basic_material.setNumEnergyGroups(1) basic_material.setSigmaF([0.0414198575]) basic_material.setNuSigmaF([0.0994076580]) basic_material.setSigmaS([0.383259177]) basic_material.setChi([1.0]) basic_material.setSigmaT([0.452648699]) ############################################################################# ########################## Creating Surfaces ############################ ############################################################################# left = openmoc.XPlane(x=-length / 2, name='left') right = openmoc.XPlane(x=length / 2, name='right') top = openmoc.YPlane(y=length / 2, name='top') bottom = openmoc.YPlane(y=-length / 2, name='bottom') left.setBoundaryType(openmoc.REFLECTIVE) right.setBoundaryType(openmoc.REFLECTIVE) top.setBoundaryType(openmoc.REFLECTIVE) bottom.setBoundaryType(openmoc.REFLECTIVE) ############################################################################# ############################ Creating Cells ############################# ############################################################################# fill = openmoc.Cell(name='fill') fill.setFill(basic_material) root_cell = openmoc.Cell(name='root cell')
def test_complement(self): complement = openmoc.Complement() intersection = openmoc.Intersection() # Define surfaces p1x = openmoc.XPlane(x=3) p2x = openmoc.XPlane(x=-2) p1y = openmoc.YPlane(y=1) p2y = openmoc.YPlane(y=-0.5) p1z = openmoc.ZPlane(z=8) p2z = openmoc.ZPlane(z=-4) # Define boundary types p1x.setBoundaryType(openmoc.VACUUM) p2x.setBoundaryType(openmoc.REFLECTIVE) p1y.setBoundaryType(openmoc.PERIODIC) p2y.setBoundaryType(openmoc.REFLECTIVE) p1z.setBoundaryType(openmoc.PERIODIC) p2z.setBoundaryType(openmoc.VACUUM) # Define halfspaces h1x = openmoc.Halfspace(-1, p1x) h2x = openmoc.Halfspace(+1, p2x) h1y = openmoc.Halfspace(-1, p1y) h2y = openmoc.Halfspace(+1, p2y) h1z = openmoc.Halfspace(-1, p1z) h2z = openmoc.Halfspace(+1, p2z) # Add halfspaces intersection.addNode(h1x) intersection.addNode(h2x) intersection.addNode(h1y) intersection.addNode(h2y) intersection.addNode(h1z) intersection.addNode(h2z) complement.addNode(intersection) # Test getMaxXYZ + MaxXYZboundary #FIXME Implement boundary type getter for complement regions self.assertEqual(complement.getMaxX(), 3) with self.assertRaises(Exception): self.assertEqual(complement.getMaxXBoundaryType(), openmoc.VACUUM) self.assertEqual(complement.getMaxY(), 1) with self.assertRaises(Exception): self.assertEqual(complement.getMaxYBoundaryType(), openmoc.PERIODIC) self.assertEqual(complement.getMaxZ(), 8) with self.assertRaises(Exception): self.assertEqual(complement.getMaxZBoundaryType(), openmoc.PERIODIC) # Test getMinXYZ + MinXYZboundary self.assertEqual(complement.getMinX(), -2) with self.assertRaises(Exception): self.assertEqual(complement.getMinXBoundaryType(), openmoc.REFLECTIVE) self.assertEqual(complement.getMinY(), -0.5) with self.assertRaises(Exception): self.assertEqual(complement.getMinYBoundaryType(), openmoc.REFLECTIVE) self.assertEqual(complement.getMinZ(), -4) with self.assertRaises(Exception): self.assertEqual(complement.getMinZBoundaryType(), openmoc.VACUUM)
def test_union(self): union = openmoc.Union() # Define surfaces p1x = openmoc.XPlane(x=3) p2x = openmoc.XPlane(x=-2) p1y = openmoc.YPlane(y=1) p2y = openmoc.YPlane(y=-0.5) p1z = openmoc.ZPlane(z=8) p2z = openmoc.ZPlane(z=-4) # Define boundary types p1x.setBoundaryType(openmoc.VACUUM) p2x.setBoundaryType(openmoc.REFLECTIVE) p1y.setBoundaryType(openmoc.PERIODIC) p2y.setBoundaryType(openmoc.REFLECTIVE) p1z.setBoundaryType(openmoc.PERIODIC) p2z.setBoundaryType(openmoc.VACUUM) # Define halfspaces h1x = openmoc.Halfspace(-1, p1x) h2x = openmoc.Halfspace(+1, p2x) h1y = openmoc.Halfspace(-1, p1y) h2y = openmoc.Halfspace(+1, p2y) h1z = openmoc.Halfspace(-1, p1z) h2z = openmoc.Halfspace(+1, p2z) # Test getMaxXYZ + MaxXYZboundary union.addNode(h1x, True) self.assertEqual(union.getMaxX(), 3) self.assertEqual(union.getMaxXBoundaryType(), openmoc.VACUUM) #union.removeHalfspace(p1x, -1) #FIXME seg faults union = openmoc.Union() union.addNode(h1y) self.assertEqual(union.getMaxY(), 1) self.assertEqual(union.getMaxYBoundaryType(), openmoc.PERIODIC) #union.removeHalfspace(p1y, -1) union = openmoc.Union() union.addNode(h1z) self.assertEqual(union.getMaxZ(), 8) self.assertEqual(union.getMaxZBoundaryType(), openmoc.PERIODIC) #union.removeHalfspace(p1z, -1) # Test getMinXYZ + MinXYZboundary union = openmoc.Union() union.addNode(h2x) self.assertEqual(union.getMinX(), -2) self.assertEqual(union.getMinXBoundaryType(), openmoc.REFLECTIVE) #union.removeHalfspace(h2x) union = openmoc.Union() union.addNode(h2y) self.assertEqual(union.getMinY(), -0.5) self.assertEqual(union.getMinYBoundaryType(), openmoc.REFLECTIVE) #union.removeHalfspace(h2y) union = openmoc.Union() union.addNode(h2z) self.assertEqual(union.getMinZ(), -4) self.assertEqual(union.getMinZBoundaryType(), openmoc.VACUUM)
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)
############################################################################### log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../') ############################################################################### # Creating Surfaces ############################################################################### log.py_printf('NORMAL', 'Creating surfaces...') xmin = openmoc.XPlane(x=-5.0, name='xmin') xmax = openmoc.XPlane(x= 5.0, name='xmax') ymin = openmoc.YPlane(y=-5.0, name='ymin') ymax = openmoc.YPlane(y= 5.0, name='ymax') zmin = openmoc.ZPlane(z=-5.0, name='zmin') zmax = openmoc.ZPlane(z= 5.0, name='zmax') xmin.setBoundaryType(openmoc.VACUUM) xmax.setBoundaryType(openmoc.VACUUM) ymin.setBoundaryType(openmoc.VACUUM) ymax.setBoundaryType(openmoc.VACUUM) zmin.setBoundaryType(openmoc.VACUUM) zmax.setBoundaryType(openmoc.VACUUM) ############################################################################### # Creating Cells ###############################################################################
# Creating Materials ############################################################################### openmoc.log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../../') ############################################################################### # Creating Surfaces ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') left = openmoc.XPlane(x=-32.13, name='left') right = openmoc.XPlane(x=32.13, name='right') top = openmoc.YPlane(y=32.13, name='top') bottom = openmoc.YPlane(y=-32.13, name='bottom') left.setBoundaryType(openmoc.REFLECTIVE) right.setBoundaryType(openmoc.VACUUM) top.setBoundaryType(openmoc.REFLECTIVE) bottom.setBoundaryType(openmoc.VACUUM) boundaries = [left, right, top, bottom] # Create ZCylinders for the fuel as well as to discretize the moderator into # rings fuel_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.54) moderator_inner_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.58) moderator_outer_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.62) ############################################################################### # Creating Cells and Universes
# Creating Materials ############################################################################### openmoc.log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('LRA-mgxs.h5', '') ############################################################################### # Creating Surfaces ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') left = openmoc.XPlane(x=-82.5) right = openmoc.XPlane(x=82.5) bottom = openmoc.YPlane(y=-82.5) 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'])
def get_openmoc_surface(openmc_surface): """Return an OpenMOC surface corresponding to an OpenMC surface. Parameters ---------- openmc_surface : openmc.Surface OpenMC surface Returns ------- openmoc_surface : openmoc.Surface Equivalent OpenMOC surface """ cv.check_type('openmc_surface', openmc_surface, openmc.Surface) surface_id = openmc_surface.id # If this Material was already created, use it if surface_id in OPENMOC_SURFACES: return OPENMOC_SURFACES[surface_id] # Create an OpenMOC Surface to represent this OpenMC Surface name = openmc_surface.name # Determine the type of boundary conditions applied to the Surface if openmc_surface.boundary_type == 'vacuum': boundary = openmoc.VACUUM elif openmc_surface.boundary_type == 'reflective': boundary = openmoc.REFLECTIVE elif openmc_surface.boundary_type == 'periodic': boundary = openmoc.PERIODIC else: boundary = openmoc.BOUNDARY_NONE if openmc_surface.type == 'plane': A = openmc_surface.a B = openmc_surface.b C = openmc_surface.c D = openmc_surface.d # OpenMOC uses the opposite sign on D openmoc_surface = openmoc.Plane(A, B, C, -D, surface_id, name) elif openmc_surface.type == 'x-plane': x0 = openmc_surface.x0 openmoc_surface = openmoc.XPlane(x0, surface_id, name) elif openmc_surface.type == 'y-plane': y0 = openmc_surface.y0 openmoc_surface = openmoc.YPlane(y0, surface_id, name) elif openmc_surface.type == 'z-plane': z0 = openmc_surface.z0 openmoc_surface = openmoc.ZPlane(z0, surface_id, name) elif openmc_surface.type == 'z-cylinder': x0 = openmc_surface.x0 y0 = openmc_surface.y0 R = openmc_surface.r openmoc_surface = openmoc.ZCylinder(x0, y0, R, surface_id, name) else: msg = 'Unable to create an OpenMOC Surface from an OpenMC ' \ 'Surface of type "{}" since it is not a compatible ' \ 'Surface type in OpenMOC'.format(type(openmc_surface)) raise ValueError(msg) # Set the boundary condition for this Surface openmoc_surface.setBoundaryType(boundary) # Add the OpenMC Surface to the global collection of all OpenMC Surfaces OPENMC_SURFACES[surface_id] = openmc_surface # Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces OPENMOC_SURFACES[surface_id] = openmoc_surface return openmoc_surface
# Creating Materials ############################################################################### openmoc.log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../') ############################################################################### # Creating Surfaces ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') left = openmoc.XPlane(x=-2.0, name='left') right = openmoc.XPlane(x=2.0, name='right') top = openmoc.YPlane(y=-2.0, name='top') bottom = openmoc.YPlane(y=2.0, name='bottom') boundaries = [left, right, top, bottom] large_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.4, name='large pin') medium_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.3, name='medium pin') small_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.2, name='small pin') for boundary in boundaries: boundary.setBoundaryType(openmoc.REFLECTIVE) ############################################################################### # Creating Cells
############################################################################### openmoc.log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../') ############################################################################### # Creating Surfaces ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') left = openmoc.XPlane(x=-34.0, name='left') right = openmoc.XPlane(x=34.0, name='right') top = openmoc.YPlane(y=-34.0, name='top') bottom = openmoc.YPlane(y=34.0, name='bottom') boundaries = [left, right, top, bottom] for boundary in boundaries: boundary.setBoundaryType(openmoc.REFLECTIVE) zcylinders = list() radii = [0.15, 0.2, 0.25, 0.3, 0.35, 0.4] for r in radii: zcylinders.append(openmoc.ZCylinder(x=0.0, y=0.0, radius=r)) ############################################################################### # Creating Cells ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating cells...')
import openmoc ############################################################################### # Create dictionary of common surfaces ############################################################################### surfaces = {} # Instantiate surfaces surfaces['Root x-min'] = openmoc.XPlane(x=-12.5, name='Root x-min') surfaces['Root y-min'] = openmoc.YPlane(y=-12.5, name='Root y-min') surfaces['Root z-min'] = openmoc.ZPlane(z=-12.5, name='Root z-min') surfaces['Root x-max'] = openmoc.XPlane(x=12.5, name='Root x-max') surfaces['Root y-max'] = openmoc.YPlane(y=12.5, name='Root y-max') surfaces['Root z-max'] = openmoc.ZPlane(z=12.5, name='Root z-max') surfaces['Root x-min'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Root y-min'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Root z-min'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Root x-max'].setBoundaryType(openmoc.VACUUM) surfaces['Root y-max'].setBoundaryType(openmoc.VACUUM) surfaces['Root z-max'].setBoundaryType(openmoc.VACUUM)
########################### Creating Materials ############################ ############################################################################### openmoc.log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../../') ############################################################################### ########################### Creating Surfaces ############################# ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') xmin = openmoc.XPlane(x=-32.13, name='xmin') xmax = openmoc.XPlane(x=32.13, name='xmax') ymin = openmoc.YPlane(y=-32.13, name='ymin') ymax = openmoc.YPlane(y=32.13, name='ymax') zmin = openmoc.ZPlane(z=-32.13, name='zmin') zmax = openmoc.ZPlane(z=32.13, name='zmax') xmin.setBoundaryType(openmoc.REFLECTIVE) xmax.setBoundaryType(openmoc.VACUUM) ymin.setBoundaryType(openmoc.VACUUM) ymax.setBoundaryType(openmoc.REFLECTIVE) # Create ZCylinders for the fuel as well as to discretize the moderator into # rings fuel_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.54) moderator_inner_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.58) moderator_outer_radius = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.62)
def _run_openmoc(self): """Instantiate a complex region Geometry.""" # ---------------- # / \ # --------------- c2 (p22,p23) - u2 - c2a (p11) # / / # u_r <- c_r (p1,p2) - u1 - c1 (p11,p12,p13) # \ \ # ------------- c3 root_universe = openmoc.Universe(name='root universe') root_cell = openmoc.Cell(name='root cell') u1 = openmoc.Universe(name='universe 1') u2 = openmoc.Universe(name='universe 2 in c2') root_cell.setFill(u1) # Z-bounds at root level p1 = openmoc.ZPlane(z=-2.0, name='zmin') p1.setBoundaryType(openmoc.REFLECTIVE) p2 = openmoc.ZPlane(z=+2.0, name='zmax') p2.setBoundaryType(openmoc.INTERFACE) root_cell.addSurface(halfspace=+1, surface=p1) root_cell.addSurface(halfspace=-1, surface=p2) # Cells in the root cell c1 = openmoc.Cell(name='intersection cell') c2 = openmoc.Cell(name='union cell') c2a = openmoc.Cell(name='union cell 2') c3 = openmoc.Cell(name='unbound cell') u1.addCell(c1) u1.addCell(c2) u1.addCell(c3) # Setting the parent cell helps to find boundaries (in Z here) c3.setParent(root_cell) # Cell c2a in c2, to further test arborescence c2.setFill(u2) u2.addCell(c2a) c2.setParent(root_cell) c2a.setParent(c2) # to test transitivity # Bounds for cell 1 : intersection region cell p11 = openmoc.XPlane(x=-2.0, name='xmin') p11.setBoundaryType(openmoc.REFLECTIVE) p12 = openmoc.YPlane(y=-2.0, name='ymin') p12.setBoundaryType(openmoc.VACUUM) p13 = openmoc.ZCylinder(x=0, y=0, radius=2.5, name='cylinder') p13.setBoundaryType(openmoc.INTERFACE) # addSurface assumes an intersection, which is what we want here c1.addSurface(halfspace=+1, surface=p11) c1.addSurface(halfspace=+1, surface=p12) c1.addSurface(halfspace=-1, surface=p13) # Bounds for cell 2 : union region cell p22 = openmoc.ZCylinder(x=4, y=4, radius=2.5, name='cylinder') p22.setBoundaryType(openmoc.INTERFACE) p23 = openmoc.ZCylinder(x=-2, y=-8, radius=3, name='cylinder') p23.setBoundaryType(openmoc.VACUUM) # To have a union, we need to use addLogicalNode and addSurfaceInRegion c2.addLogicalNode(1) c2.addSurfaceInRegion(halfspace=-1, surface=p22) c2.addSurfaceInRegion(halfspace=-1, surface=p23) # Plane limits area even more c2a.addLogicalNode(1) c2a.addSurfaceInRegion(halfspace=+1, surface=p11) openmoc.set_log_level('NORMAL') for cell in [root_cell, c1, c2, c2a, c3]: py_printf('NORMAL', 'Cell: %s', cell.getName()) py_printf('NORMAL', 'MinX: %f', cell.getMinX()) py_printf('NORMAL', 'MinXBoundaryType: %s', cell.getMinXBoundaryType()) py_printf('NORMAL', 'MinY: %f', cell.getMinY()) py_printf('NORMAL', 'MinYBoundaryType: %s', cell.getMinYBoundaryType()) py_printf('NORMAL', 'MinZ: %f', cell.getMinZ()) py_printf('NORMAL', 'MinZBoundaryType: %s', cell.getMinZBoundaryType()) py_printf('NORMAL', 'MaxX: %f', cell.getMaxX()) py_printf('NORMAL', 'MaxXBoundaryType: %s', cell.getMaxXBoundaryType()) py_printf('NORMAL', 'MaxY: %f', cell.getMaxY()) py_printf('NORMAL', 'MaxYBoundaryType: %s', cell.getMaxYBoundaryType()) py_printf('NORMAL', 'MaxZ: %f', cell.getMaxZ()) py_printf('NORMAL', 'MaxZBoundaryType: %s', cell.getMaxZBoundaryType()) py_printf('NORMAL', '')
# Creating Materials ############################################################################### openmoc.log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../') ############################################################################### # Creating Surfaces ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') left = openmoc.XPlane(x=-5.0, name='left') right = openmoc.XPlane(x=5.0, name='right') bottom = openmoc.YPlane(y=-5.0, name='bottom') top = openmoc.YPlane(y=5.0, name='top') boundaries = [left, right, top, bottom] for boundary in boundaries: boundary.setBoundaryType(openmoc.VACUUM) ############################################################################### # Creating Cells ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating cells...') water_cell = openmoc.Cell(name='water') water_cell.setFill(materials['Water'])
def get_openmoc_surface(opencg_surface): if not isinstance(opencg_surface, opencg.Surface): msg = 'Unable to create an OpenMoC Surface from {0} which ' \ 'is not an OpenCG Surface'.format(opencg_surface) raise ValueError(msg) global OPENMOC_SURFACES surface_id = opencg_surface._id # If this Surface was already created, use it if surface_id in OPENMOC_SURFACES: return OPENMOC_SURFACES[surface_id] # Create an OpenMOC Surface to represent this OpenCG Surface name = opencg_surface._name # Correct for OpenMOC's syntax for Surfaces dividing Cells boundary = opencg_surface._boundary_type if boundary == 'vacuum': boundary = openmoc.VACUUM elif boundary == 'reflective': boundary = openmoc.REFLECTIVE elif boundary == 'interface': boundary = openmoc.BOUNDARY_NONE if opencg_surface._type == 'plane': A = opencg_surface._coeffs['A'] B = opencg_surface._coeffs['B'] D = opencg_surface._coeffs['D'] openmoc_surface = openmoc.Plane(A, B, D, surface_id, name) elif opencg_surface._type == 'x-plane': x0 = opencg_surface._coeffs['x0'] openmoc_surface = openmoc.XPlane(x0, int(surface_id), name) elif opencg_surface._type == 'y-plane': y0 = opencg_surface._coeffs['y0'] openmoc_surface = openmoc.YPlane(y0, surface_id, name) elif opencg_surface._type == 'z-plane': z0 = opencg_surface._coeffs['z0'] openmoc_surface = openmoc.ZPlane(z0, surface_id, name) elif opencg_surface._type == 'z-cylinder': x0 = opencg_surface._coeffs['x0'] y0 = opencg_surface._coeffs['y0'] R = opencg_surface._coeffs['R'] openmoc_surface = openmoc.ZCylinder(x0, y0, R, surface_id, name) else: msg = 'Unable to create an OpenMOC Surface from an OpenCG ' \ 'Surface of type {0} since it is not a compatible ' \ 'Surface type in OpenMOC'.format(opencg_surface._type) raise ValueError(msg) # Set the boundary condition for this Surface openmoc_surface.setBoundaryType(boundary) # Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces OPENMOC_SURFACES[surface_id] = openmoc_surface # Add the OpenCG Surface to the global collection of all OpenCG Surfaces OPENCG_SURFACES[surface_id] = opencg_surface # FIXME openmoc_surface.thisown = 0 return openmoc_surface
moderator.setSigmaT(numpy.array([0.841545641])) moderator.setSigmaF(numpy.array([0.0])) moderator.setNuSigmaF(numpy.array([0.0])) moderator.setSigmaS(numpy.array([0.837794542])) moderator.setChi(numpy.array([1.0])) ############################################################################### # Creating Surfaces ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.4) left = openmoc.XPlane(x=-0.635) right = openmoc.XPlane(x=0.635) top = openmoc.YPlane(y=0.635) bottom = openmoc.YPlane(y=-0.635) left.setBoundaryType(openmoc.REFLECTIVE) right.setBoundaryType(openmoc.REFLECTIVE) top.setBoundaryType(openmoc.REFLECTIVE) bottom.setBoundaryType(openmoc.REFLECTIVE) ############################################################################### # Creating Cells ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating cells...') fuel_cell = openmoc.Cell(name='fuel') fuel_cell.setFill(fuel)
# Creating Materials ############################################################################### log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../') ############################################################################### # Creating Surfaces ############################################################################### log.py_printf('NORMAL', 'Creating surfaces...') xmin = openmoc.XPlane(x=-20.0, name='xmin') xmax = openmoc.XPlane(x=20.0, name='xmax') ymin = openmoc.YPlane(y=-20.0, name='ymin') ymax = openmoc.YPlane(y=20.0, name='ymax') zmin = openmoc.ZPlane(z=-20.0, name='zmin') zmax = openmoc.ZPlane(z=20.0, name='zmax') xmin.setBoundaryType(openmoc.VACUUM) xmax.setBoundaryType(openmoc.VACUUM) ymin.setBoundaryType(openmoc.VACUUM) ymax.setBoundaryType(openmoc.VACUUM) zmin.setBoundaryType(openmoc.VACUUM) zmax.setBoundaryType(openmoc.VACUUM) ############################################################################### # Creating Cells ###############################################################################
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 get_openmoc_surface(opencg_surface): """Return an OpenMOC surface corresponding to an OpenCG surface. Parameters ---------- opencg_surface : opencg.Surface OpenCG surface Returns ------- openmoc_surface : openmoc.Surface Equivalent OpenMOC surface """ cv.check_type('opencg_surface', opencg_surface, opencg.Surface) global OPENMOC_SURFACES surface_id = opencg_surface.id # If this Surface was already created, use it if surface_id in OPENMOC_SURFACES: return OPENMOC_SURFACES[surface_id] # Create an OpenMOC Surface to represent this OpenCG Surface name = str(opencg_surface.name) # Correct for OpenMOC's syntax for Surfaces dividing Cells boundary = opencg_surface.boundary_type if boundary == 'vacuum': boundary = openmoc.VACUUM elif boundary == 'reflective': boundary = openmoc.REFLECTIVE elif boundary == 'interface': boundary = openmoc.BOUNDARY_NONE if opencg_surface.type == 'plane': A = opencg_surface.a B = opencg_surface.b C = opencg_surface.c D = opencg_surface.d openmoc_surface = openmoc.Plane(A, B, C, D, surface_id, name) elif opencg_surface.type == 'x-plane': x0 = opencg_surface.x0 openmoc_surface = openmoc.XPlane(x0, int(surface_id), name) elif opencg_surface.type == 'y-plane': y0 = opencg_surface.y0 openmoc_surface = openmoc.YPlane(y0, surface_id, name) elif opencg_surface.type == 'z-plane': z0 = opencg_surface.z0 openmoc_surface = openmoc.ZPlane(z0, surface_id, name) elif opencg_surface.type == 'z-cylinder': x0 = opencg_surface.x0 y0 = opencg_surface.y0 R = opencg_surface.r openmoc_surface = openmoc.ZCylinder(x0, y0, R, surface_id, name) else: msg = 'Unable to create an OpenMOC Surface from an OpenCG ' \ 'Surface of type {0} since it is not a compatible ' \ 'Surface type in OpenMOC'.format(opencg_surface.type) raise ValueError(msg) # Set the boundary condition for this Surface openmoc_surface.setBoundaryType(boundary) # Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces OPENMOC_SURFACES[surface_id] = openmoc_surface # Add the OpenCG Surface to the global collection of all OpenCG Surfaces OPENCG_SURFACES[surface_id] = opencg_surface return openmoc_surface
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()
infinite_medium.setNumEnergyGroups(2) infinite_medium.setSigmaF(sigma_f) infinite_medium.setNuSigmaF(nu_sigma_f) infinite_medium.setSigmaS(sigma_s.flat) infinite_medium.setChi(chi) infinite_medium.setSigmaT(sigma_t) ############################################################################### # Creating Surfaces ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') left = openmoc.XPlane(x=-100.0, name='left') right = openmoc.XPlane(x=100.0, name='right') top = openmoc.YPlane(y=100.0, name='top') bottom = openmoc.YPlane(y=-100.0, name='bottom') left.setBoundaryType(openmoc.REFLECTIVE) right.setBoundaryType(openmoc.REFLECTIVE) top.setBoundaryType(openmoc.REFLECTIVE) bottom.setBoundaryType(openmoc.REFLECTIVE) ############################################################################### # Creating Cells ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating cells...') cell = openmoc.Cell() cell.setFill(infinite_medium)
############################################################################### log.py_printf('NORMAL', 'Importing materials data from HDF5...') materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../') ############################################################################### # Creating Surfaces ############################################################################### log.py_printf('NORMAL', 'Creating surfaces...') xmin = openmoc.XPlane(x=-34.0, name='xmin') xmax = openmoc.XPlane(x= 34.0, name='xmax') ymin = openmoc.YPlane(y=-34.0, name='ymin') ymax = openmoc.YPlane(y= 34.0, name='ymax') zmin = openmoc.ZPlane(z=-0.5, name='zmin') zmax = openmoc.ZPlane(z= 0.5, name='zmax') xmin.setBoundaryType(openmoc.REFLECTIVE) xmax.setBoundaryType(openmoc.REFLECTIVE) ymin.setBoundaryType(openmoc.REFLECTIVE) ymax.setBoundaryType(openmoc.REFLECTIVE) zmin.setBoundaryType(openmoc.REFLECTIVE) zmax.setBoundaryType(openmoc.REFLECTIVE) zcylinders = list() radii = [0.15, 0.2, 0.25, 0.3, 0.35, 0.4] for r in radii: zcylinders.append(openmoc.ZCylinder(x=0.0, y=0.0, radius=r))
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 _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")