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 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 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 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)
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 ############################################################################### log.py_printf('NORMAL', 'Creating cells...')
def _create_geometry(self): """Inspired from SimpleLattice""" self.materials = \ openmoc.materialize.load_from_hdf5(filename='c5g7-mgxs.h5', directory='../../sample-input/') xmin = openmoc.XPlane(x=-2.0, name='xmin') xmax = openmoc.XPlane(x=+2.0, name='xmax') ymin = openmoc.YPlane(y=-2.0, name='ymin') ymax = openmoc.YPlane(y=+2.0, name='ymax') boundaries = [xmin, xmax, ymin, ymax] if (self.dimensions == 3): zmin = openmoc.ZPlane(z=-5.0, name='zmin') zmax = openmoc.ZPlane(z=+5.0, name='zmax') boundaries = [xmin, xmax, ymin, ymax, zmin, zmax] large_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.4, name='large pin') medium_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.3, name='medium pin') small_zcylinder = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.2, name='small pin') xplane = openmoc.XPlane(x=0, name='mid-cell') yplane = openmoc.YPlane(y=0, name='mid-cell') for boundary in boundaries: boundary.setBoundaryType(openmoc.REFLECTIVE) if (self.dimensions == 3): boundaries[-1].setBoundaryType(openmoc.VACUUM) large_fuel = openmoc.Cell(name='large pin fuel') large_fuel.setNumRings(3) large_fuel.setNumSectors(8) large_fuel.setFill(self.materials['UO2']) large_fuel.addSurface(halfspace=-1, surface=large_zcylinder) large_moderator = openmoc.Cell(name='large pin moderator') large_moderator.setNumSectors(8) large_moderator.setFill(self.materials['Water']) large_moderator.addSurface(halfspace=+1, surface=large_zcylinder) medium_fuel = openmoc.Cell(name='medium pin fuel') medium_fuel.setNumRings(3) medium_fuel.setNumSectors(8) medium_fuel.setFill(self.materials['UO2']) medium_fuel.addSurface(halfspace=-1, surface=medium_zcylinder) medium_moderator = openmoc.Cell(name='medium pin moderator') medium_moderator.setNumSectors(8) medium_moderator.setFill(self.materials['Water']) medium_moderator.addSurface(halfspace=+1, surface=medium_zcylinder) small_fuel = openmoc.Cell(name='small pin fuel') small_fuel.setNumRings(3) # test may fail if fsrs are initialized small_fuel.setNumSectors(8) small_fuel.setFill(self.materials['UO2']) small_fuel.addSurface(halfspace=-1, surface=small_zcylinder) small_clad_q1 = openmoc.Cell(name='small pin cladding quarter') small_clad_q1.setFill(self.materials['Clad']) small_clad_q1.addSurface(halfspace=+1, surface=small_zcylinder) small_clad_q1.addSurface(halfspace=-1, surface=medium_zcylinder) small_clad_q1.addSurface(halfspace=+1, surface=xplane) small_clad_q1.addSurface(halfspace=-1, surface=yplane) small_moderator = openmoc.Cell(name='small pin moderator') small_moderator.setNumSectors(8) small_moderator.setFill(self.materials['Water']) small_moderator.addSurface(halfspace=+1, surface=medium_zcylinder) lattice_cell = openmoc.Cell(name='lattice cell') root_cell = openmoc.Cell(name='root cell') root_cell.addSurface(halfspace=+1, surface=boundaries[0]) root_cell.addSurface(halfspace=-1, surface=boundaries[1]) root_cell.addSurface(halfspace=+1, surface=boundaries[2]) root_cell.addSurface(halfspace=-1, surface=boundaries[3]) if (self.dimensions == 3): root_cell.addSurface(halfspace=+1, surface=boundaries[4]) root_cell.addSurface(halfspace=-1, surface=boundaries[5]) pin1 = openmoc.Universe(name='large pin cell') pin2 = openmoc.Universe(name='medium pin cell') pin3 = openmoc.Universe(name='small pin cell') assembly = openmoc.Universe(name='2x2 lattice') root_universe = openmoc.Universe(name='root universe') pin1.addCell(large_fuel) pin1.addCell(large_moderator) pin2.addCell(medium_fuel) pin2.addCell(medium_moderator) pin3.addCell(small_fuel) pin3.addCell(small_clad_q1) pin3.addCell(small_moderator) assembly.addCell(lattice_cell) root_universe.addCell(root_cell) # 2x2 assembly lattice = openmoc.Lattice(name='2x2 lattice') lattice.setWidth(width_x=1.0, width_y=1.0) lattice.setUniverses([[[pin1, pin2], [pin1, pin3]]]) lattice_cell.setFill(lattice) # Rotate a lattice to test rotation of a fill cell assembly_c = openmoc.Cell(name='rotated cell containing a lattice') assembly_c.setFill(assembly) assembly_c.setRotation((0,0,90), 'degrees') assembly_r = openmoc.Universe(name='rotated lattice') assembly_r.addCell(assembly_c) # Translate a lattice to test translation of a fill cell assembly_c = openmoc.Cell(name='rotated cell containing a lattice') assembly_c.setFill(assembly) assembly_c.setTranslation((0.05,0,0)) assembly_t = openmoc.Universe(name='translated lattice') assembly_t.addCell(assembly_c) # Rotate a lattice to test rotation of a fill cell assembly_c = openmoc.Cell(name='translated cell containing a lattice') assembly_c.setFill(assembly) assembly_c.setRotation((0,0,-90), 'degrees') assembly_c.setTranslation((-0.05,0,0)) assembly_rt = openmoc.Universe(name='translate and rotated lattice') assembly_rt.addCell(assembly_c) # 2x2 core core = openmoc.Lattice(name='2x2 core') core.setWidth(width_x=2.0, width_y=2.0) core.setUniverses([[[assembly, assembly_rt], [assembly_t, assembly_r]]]) root_cell.setFill(core) self.geometry = openmoc.Geometry() self.geometry.setRootUniverse(root_universe)
def create_geometry(self): """Instantiate a 4x4 non-uniform simple lattice Geometry.""" fuel_rings = 1 moderator_rings = 1 num_sectors = 8 openmoc.set_line_length(120) r_fuel = 0.54 r_clad = 0.57 r_large = 0.60 pin_pitch = 1.26 gap_size = 0.05 surfaces = {} surfaces['Pin Cell ZCylinder'] = openmoc.ZCylinder( x=0, y=0, radius=r_fuel, name='Pin Cell ZCylinder') surfaces['Clad Cell ZCylinder'] = openmoc.ZCylinder( x=0, y=0, radius=r_clad, name='Clad Cell ZCylinder') surfaces['large'] = openmoc.ZCylinder(x=0, y=0, radius=r_large, name='large') surfaces['z-inf'] = openmoc.ZPlane(z=-1.0E10) surfaces['z+inf'] = openmoc.ZPlane(z=1.0E10) cells = {} cells['fuel'] = openmoc.Cell() cells['clad'] = openmoc.Cell() cells['mod'] = openmoc.Cell() cells['uniform gap'] = openmoc.Cell() cells['large_fuel'] = openmoc.Cell() cells['large_mod'] = openmoc.Cell() cells['fuel'].addSurface(halfspace=-1, surface=surfaces['Pin Cell ZCylinder']) cells['fuel'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['fuel'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['fuel'].setFill(self.materials['UO2']) cells['fuel'].setNumSectors(num_sectors) cells['fuel'].setNumRings(fuel_rings) cells['clad'].addSurface(halfspace=+1, surface=surfaces['Pin Cell ZCylinder']) cells['clad'].addSurface(halfspace=-1, surface=surfaces['Clad Cell ZCylinder']) cells['clad'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['clad'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['clad'].setFill(self.materials['Clad']) cells['clad'].setNumSectors(num_sectors) cells['mod'].addSurface(halfspace=+1, surface=surfaces['Clad Cell ZCylinder']) cells['mod'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['mod'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['mod'].setFill(self.materials['Water']) cells['mod'].setNumSectors(num_sectors) cells['mod'].setNumRings(moderator_rings) cells['uniform gap'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['uniform gap'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['uniform gap'].setFill(self.materials['Clad']) cells['large_fuel'].addSurface(halfspace=-1, surface=surfaces['large']) cells['large_fuel'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['large_fuel'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['large_fuel'].setFill(self.materials['UO2']) cells['large_fuel'].setNumSectors(num_sectors) cells['large_mod'].addSurface(halfspace=+1, surface=surfaces['large']) cells['large_mod'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['large_mod'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['large_mod'].setFill(self.materials['Water']) cells['large_mod'].setNumSectors(num_sectors) universes = {} universes['pin'] = openmoc.Universe() universes['pin'].addCell(cells['fuel']) universes['pin'].addCell(cells['clad']) universes['pin'].addCell(cells['mod']) universes['uniform gap'] = openmoc.Universe() universes['uniform gap'].addCell(cells['uniform gap']) universes['large_pin'] = openmoc.Universe() universes['large_pin'].addCell(cells['large_fuel']) universes['large_pin'].addCell(cells['large_mod']) lower_left = [0., 0., 0.] width = ([gap_size, pin_pitch, pin_pitch, gap_size], [gap_size, pin_pitch, pin_pitch, gap_size], [1.0, 1.5]) lattice = openmoc.Lattice(name='lattice with gap') lattice.setWidths(width[0], width[1], width[2]) lattice.setOffset(lower_left[0] + sum(width[0]) / 2., lower_left[1] + sum(width[1]) / 2., lower_left[2] + sum(width[2]) / 2.) f = universes['pin'] g = universes['uniform gap'] l = universes['large_pin'] lattice.setUniverses([[[g, g, g, g], [g, f, f, g], [g, f, f, g], [g, g, g, g]], [[g, g, g, g], [g, f, f, g], [g, f, f, g], [g, g, g, g]]]) surfaces['Global x-'] = openmoc.XPlane(x=lower_left[0]) surfaces['Global x+'] = openmoc.XPlane(x=lower_left[0] + sum(width[0])) surfaces['Global y-'] = openmoc.YPlane(y=lower_left[1]) surfaces['Global y+'] = openmoc.YPlane(y=lower_left[1] + sum(width[1])) surfaces['Global z-'] = openmoc.ZPlane(z=lower_left[2]) surfaces['Global z+'] = openmoc.ZPlane(z=lower_left[2] + sum(width[2])) surfaces['Global x-'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global x+'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global y-'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global y+'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global z-'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global z+'].setBoundaryType(openmoc.REFLECTIVE) root_cell = openmoc.Cell() root_cell.setFill(lattice) root_cell.addSurface(halfspace=+1, surface=surfaces['Global x-']) root_cell.addSurface(halfspace=-1, surface=surfaces['Global x+']) root_cell.addSurface(halfspace=+1, surface=surfaces['Global y-']) root_cell.addSurface(halfspace=-1, surface=surfaces['Global y+']) root_cell.addSurface(halfspace=+1, surface=surfaces['Global z-']) root_cell.addSurface(halfspace=-1, surface=surfaces['Global z+']) root_universe = openmoc.Universe() root_universe.addCell(root_cell) self.geometry = openmoc.Geometry() self.geometry.setRootUniverse(root_universe) super(NonUniformLatticeInput, self).create_geometry()
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
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) ############################################################################### ###################### Creating Cells and Universes #######################
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', '')
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
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)
import openmoc ############################################################################### ########################### Creating Surfaces ############################# ############################################################################### gap = 0.5 surfaces = {} # Instantiate surfaces surfaces['Root x-min'] = openmoc.XPlane(x=-32.13, name='Root x-min') surfaces['Root x-max'] = openmoc.XPlane(x=32.13, name='Root x-max') surfaces['Root y-min'] = openmoc.YPlane(y=-32.13, name='Root y-min') surfaces['Root y-max'] = openmoc.YPlane(y=32.13, name='Root y-max') surfaces['Root Small z-min'] = openmoc.ZPlane(z=-32.13, name='Root Small z-min') surfaces['Root Small z-max'] = openmoc.ZPlane(z=32.13, name='Root Small z-max') surfaces['Root Big z-min'] = openmoc.ZPlane(z=-107.1, name='Root Big z-min') surfaces['Root Big z-max'] = openmoc.ZPlane(z=107.1, name='Root Big z-max') surfaces['Fuel Cylinder'] = openmoc.ZCylinder(x=0.0, y=0.0, radius=0.54, name='Fuel Cylinder') surfaces['Gap Root x-min'] = openmoc.XPlane(x=-32.13 - 3 * gap, name='Gap Root x-min') surfaces['Gap Root x-max'] = openmoc.XPlane(x=32.13 + 3 * gap, name='Gap Root x-max') surfaces['Gap Root y-min'] = openmoc.YPlane(y=-32.13 - 3 * gap, name='Gap Root y-min') surfaces['Gap Root y-max'] = openmoc.YPlane(y=32.13 + 3 * gap, name='Gap Root y-max')
def create_geometry(self): """Instantiate 4x4 non-uniform and axially extended lattice problem.""" fuel_rings = 1 moderator_rings = 1 num_sectors = 8 openmoc.set_line_length(120) r_fuel = 0.54 r_clad = 0.57 r_large = 0.60 pin_pitch = 1.26 gap_size = 0.05 surfaces = {} surfaces['Pin Cell ZCylinder'] = openmoc.ZCylinder( x=0, y=0, radius=r_fuel, name='Pin Cell ZCylinder') surfaces['Clad Cell ZCylinder'] = openmoc.ZCylinder( x=0, y=0, radius=r_clad, name='Clad Cell ZCylinder') surfaces['large'] = openmoc.ZCylinder(x=0, y=0, radius=r_large, name='large') surfaces['z-inf'] = openmoc.ZPlane(z=-1.0E10) surfaces['z+inf'] = openmoc.ZPlane(z=1.0E10) cells = {} cells['fuel'] = openmoc.Cell() cells['clad'] = openmoc.Cell() cells['mod'] = openmoc.Cell() cells['uniform gap'] = openmoc.Cell() cells['large_fuel'] = openmoc.Cell() cells['large_mod'] = openmoc.Cell() cells['fuel'].addSurface(halfspace=-1, surface=surfaces['Pin Cell ZCylinder']) cells['fuel'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['fuel'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['fuel'].setFill(self.materials['UO2']) cells['fuel'].setNumSectors(num_sectors) cells['fuel'].setNumRings(fuel_rings) cells['clad'].addSurface(halfspace=+1, surface=surfaces['Pin Cell ZCylinder']) cells['clad'].addSurface(halfspace=-1, surface=surfaces['Clad Cell ZCylinder']) cells['clad'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['clad'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['clad'].setFill(self.materials['Clad']) cells['clad'].setNumSectors(num_sectors) cells['mod'].addSurface(halfspace=+1, surface=surfaces['Clad Cell ZCylinder']) cells['mod'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['mod'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['mod'].setFill(self.materials['Water']) cells['mod'].setNumSectors(num_sectors) cells['mod'].setNumRings(moderator_rings) cells['uniform gap'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['uniform gap'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['uniform gap'].setFill(self.materials['Clad']) cells['large_fuel'].addSurface(halfspace=-1, surface=surfaces['large']) cells['large_fuel'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['large_fuel'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['large_fuel'].setFill(self.materials['UO2']) cells['large_fuel'].setNumSectors(num_sectors) cells['large_mod'].addSurface(halfspace=+1, surface=surfaces['large']) cells['large_mod'].addSurface(halfspace=+1, surface=surfaces['z-inf']) cells['large_mod'].addSurface(halfspace=-1, surface=surfaces['z+inf']) cells['large_mod'].setFill(self.materials['Water']) cells['large_mod'].setNumSectors(num_sectors) universes = {} universes['pin'] = openmoc.Universe() universes['pin'].addCell(cells['fuel']) universes['pin'].addCell(cells['clad']) universes['pin'].addCell(cells['mod']) universes['uniform gap'] = openmoc.Universe() universes['uniform gap'].addCell(cells['uniform gap']) universes['large_pin'] = openmoc.Universe() universes['large_pin'].addCell(cells['large_fuel']) universes['large_pin'].addCell(cells['large_mod']) lower_left = [0., 0., 0.] # set the XYZ widths of non-uniform lattice width = ([gap_size, pin_pitch, pin_pitch, gap_size], [gap_size, pin_pitch, pin_pitch, gap_size], [1.0] * 20) lattice = openmoc.Lattice(name='lattice with gap') lattice.setWidths(width[0], width[1], width[2]) lattice.setOffset(lower_left[0] + sum(width[0]) / 2., lower_left[1] + sum(width[1]) / 2., lower_left[2] + sum(width[2]) / 2.) f = universes['pin'] g = universes['uniform gap'] l = universes['large_pin'] a = numpy.array([[g, g, g, g], [g, f, f, g], [g, f, f, g], [g, g, g, g]]) fill_universes = numpy.tile(a, (20, 1, 1)) # make the geometry axially heterogeneous fill_universes[2][1][1] = g fill_universes = fill_universes.tolist() lattice.setUniverses(fill_universes) surfaces['Global x-'] = openmoc.XPlane(x=lower_left[0]) surfaces['Global x+'] = openmoc.XPlane(x=lower_left[0] + sum(width[0])) surfaces['Global y-'] = openmoc.YPlane(y=lower_left[1]) surfaces['Global y+'] = openmoc.YPlane(y=lower_left[1] + sum(width[1])) surfaces['Global z-'] = openmoc.ZPlane(z=lower_left[2]) surfaces['Global z+'] = openmoc.ZPlane(z=lower_left[2] + sum(width[2])) surfaces['Global x-'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global x+'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global y-'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global y+'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global z-'].setBoundaryType(openmoc.REFLECTIVE) surfaces['Global z+'].setBoundaryType(openmoc.REFLECTIVE) root_cell = openmoc.Cell() root_cell.setFill(lattice) root_cell.addSurface(halfspace=+1, surface=surfaces['Global x-']) root_cell.addSurface(halfspace=-1, surface=surfaces['Global x+']) root_cell.addSurface(halfspace=+1, surface=surfaces['Global y-']) root_cell.addSurface(halfspace=-1, surface=surfaces['Global y+']) root_cell.addSurface(halfspace=+1, surface=surfaces['Global z-']) root_cell.addSurface(halfspace=-1, surface=surfaces['Global z+']) root_universe = openmoc.Universe() root_universe.addCell(root_cell) self.geometry = openmoc.Geometry() self.geometry.setRootUniverse(root_universe) super(AxialExtendedInput, self).create_geometry()
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 ############################################################################### log.py_printf('NORMAL', 'Creating cells...')
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 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 _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")
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): """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=-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') 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) 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]) 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_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()