import openmoc import openmoc.plotter as plotter import openmoc.process as process from openmoc.materialize import materialize import matplotlib import matplotlib.pyplot as plt plt.rcParams.update({'figure.figsize': (10,10)}) matplotlib.use('Agg') %pylab inline num_threads = 8 track_spacing = 0.01 num_azim = 64 tolerance = 1E-7 max_iters = 50 materials = materialize('../../c5g7-materials.h5') print materials.keys() # Create Circles for the fuel as well as to discretize the moderator into rings fuel_radius = openmoc.Circle(x=0.0, y=0.0, radius=0.54) moderator_inner_radius = openmoc.Circle(x=0.0, y=0.0, radius=0.62) moderator_outer_radius = openmoc.Circle(x=0.0, y=0.0, radius=0.58) # Create planes to bound the entire geometry left = openmoc.XPlane(x=-10.71, name='left') right = openmoc.XPlane(x=10.71, name='right') top = openmoc.YPlane(y=10.71, name='top') bottom = openmoc.YPlane(y=-10.71, name='bottom') left.setBoundaryType(openmoc.REFLECTIVE) right.setBoundaryType(openmoc.REFLECTIVE) top.setBoundaryType(openmoc.REFLECTIVE) bottom.setBoundaryType(openmoc.REFLECTIVE) # 4.3% MOX pin cell mox43_cell = openmoc.CellBasic(rings=3, sectors=8) mox43_cell.setMaterial(materials['MOX-4.3%']) mox43_cell.addSurface(-1, fuel_radius) mox43 = openmoc.Universe(name='MOX-4.3%') mox43.addCell(mox43_cell) # 7% MOX pin cell mox7_cell = openmoc.CellBasic(rings=3, sectors=8) mox7_cell.setMaterial(materials['MOX-7%']) mox7_cell.addSurface(-1, fuel_radius) mox7 = openmoc.Universe(name='MOX-7%') mox7.addCell(mox7_cell) # 8.7% MOX pin cell mox87_cell = openmoc.CellBasic(rings=3, sectors=8) mox87_cell.setMaterial(materials['MOX-8.7%']) 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.CellBasic(rings=3, sectors=8) fission_chamber_cell.setMaterial(materials['Fission Chamber']) 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.CellBasic(rings=3, sectors=8) guide_tube_cell.setMaterial(materials['Guide Tube']) guide_tube_cell.addSurface(-1, fuel_radius) guide_tube = openmoc.Universe(name='Guide Tube') guide_tube.addCell(guide_tube_cell) # Moderator rings moderator_ring1 = openmoc.CellBasic(sectors=8) moderator_ring2 = openmoc.CellBasic(sectors=8) moderator_ring3 = openmoc.CellBasic(sectors=8) moderator_ring1.setMaterial(materials['Water']) moderator_ring2.setMaterial(materials['Water']) moderator_ring3.setMaterial(materials['Water']) moderator_ring1.addSurface(+1, fuel_radius) moderator_ring1.addSurface(-1, moderator_inner_radius) moderator_ring2.addSurface(+1, moderator_inner_radius) moderator_ring2.addSurface(-1, moderator_outer_radius) moderator_ring3.addSurface(+1, moderator_outer_radius) # Add moderator rings to each pin cell pins = [mox43, mox7, mox87, fission_chamber, guide_tube] for pin in pins: pin.addCell(moderator_ring1) pin.addCell(moderator_ring2) pin.addCell(moderator_ring3) # CellFills for the assembly assembly1_cell = openmoc.CellFill(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.CellFill(name='Full Geometry') root_cell.setFill(assembly) root_cell.addSurface(+1, left) root_cell.addSurface(-1, right) root_cell.addSurface(-1, top) root_cell.addSurface(+1, bottom) root_universe = openmoc.Universe(name='Root Universe') root_universe.addCell(root_cell) cmfd = openmoc.Cmfd() cmfd.setMOCRelaxationFactor(0.6) cmfd.setSORRelaxationFactor(1.5) cmfd.setLatticeStructure(51,51) cmfd.setGroupStructure([1,4,8]) geometry = openmoc.Geometry() geometry.setRootUniverse(root_universe) geometry.setCmfd(cmfd) geometry.initializeFlatSourceRegions() # Plot the geometry color-coded by materials plotter.plot_materials(geometry, gridsize=500) # Load the figure into Matplotlib plt.imshow(plt.imread('plots/materials.png')) plt.axis('off') # Plot the geometry color-coded by cells plotter.plot_cells(geometry, gridsize=500) # Load the figure into Matplotlib plt.imshow(plt.imread('plots/cells.png')) plt.axis('off') track_generator = openmoc.TrackGenerator(geometry, num_azim, track_spacing) track_generator.setNumThreads(num_threads) track_generator.generateTracks() # Plot the geometry color-coded by flat source region plotter.plot_flat_source_regions(geometry, gridsize=500) # Load the figure into Matplotlib plt.imshow(plt.imread('plots/flat-source-regions.png')) plt.axis('off') # Plot the geometry color-coded by CMFD cells plotter.plot_cmfd_cells(geometry, cmfd, gridsize=500) # Load the figure into Matplotlib plt.imshow(plt.imread('plots/cmfd-cells.png')) plt.axis('off') solver = openmoc.CPUSolver(track_generator) solver.setConvergenceThreshold(tolerance) solver.setNumThreads(num_threads) solver.computeEigenvalue(max_iters) plotter.plot_spatial_fluxes(solver, energy_groups=[1,3,7], gridsize=500) # Load fast flux figure into Matplotlib plt.imshow(plt.imread('plots/fsr-flux-group-1.png')) plt.axis('off') # Load epithermal flux figure into Matplotlib plt.imshow(plt.imread('plots/fsr-flux-group-3.png')) plt.axis('off') # Load thermal flux figure into Matplotlib plt.imshow(plt.imread('plots/fsr-flux-group-7.png')) plt.axis('off') plotter.plot_fission_rates(solver, gridsize=500) # Load FSR fission rates figure into Matplotlib plt.imshow(plt.imread('plots/fission-rates.png')) plt.axis('off')