def set_fuel_depletion_tallies(self): """ Sets up distributed tallies needed for depletion of fresh fuel NOTE: this was so far created only for benchmarking openmc performance, and is not really what we'll end up doing for depletion """ scores = ["total", "absorption", "fission", "nu-fission"] for c,u in self.get_all_fuel_cells(): # Instantiate tally Filter filter_ = openmc.DistribcellFilter(c.id) # Instantiate the Tally tally = openmc.Tally() tally.filters = [filter_] tally.scores = scores nuclides = self.openmc_mats[c.fill.name].nuclides tally.nuclides = [nuc for nuc, ao, typ in nuclides] self.tallies.append(tally)
def define_Geo_Mat_Set(cells_num_dic, parameters_dic, settings_dic, temp_phy_mat, controlRod_deep, empty_reflector_height): # Check file if os.path.exists('geometry.xml'): os.remove('geometry.xml') if os.path.exists('materials.xml'): os.remove('materials.xml') if os.path.exists('settings.xml'): os.remove('settings.xml') if os.path.exists('tallies.xml'): os.remove('tallies.xml') # defualt temperature: 1073.5K if settings_dic['temperature_update'] == True: temp_defualt = temp_phy_mat.min() else: temp_defualt = 1073.5 # Parameters of reactor # Unit:cm fuel_r = parameters_dic['fuel_r'] fuel_h = parameters_dic['fuel_h'] controlRod_r = parameters_dic['controlRod_r'] controlRod_h_max = parameters_dic['controlRod_h_max'] controlRod_l = parameters_dic['controlRod_l'] reflector_r = parameters_dic['reflector_r'] reflector_h = parameters_dic['reflector_h'] heat_pipe_R = parameters_dic['heat_pipe_R'] heat_pipe_r = parameters_dic['heat_pipe_r'] top_distance = parameters_dic['top_distance'] bottom_distance = parameters_dic['bottom_distance'] # Structural Material HAYNES230 structure_HAY = openmc.Material(material_id=1, name='HAYNES230') structure_HAY.set_density('g/cm3', 8.97) structure_HAY.add_element('Ni', 0.57, 'wo') structure_HAY.add_element('Cr', 0.22, 'wo') structure_HAY.add_element('W', 0.14, 'wo') structure_HAY.add_element('Mo', 0.02, 'wo') structure_HAY.add_element('Fe', 0.01875, 'wo') structure_HAY.add_element('Co', 0.03125, 'wo') # Structural Material SS316 structure_SS = openmc.Material(material_id=2, name='SS316') structure_SS.set_density('g/cm3', 7.99) structure_SS.add_element('Ni', 0.12, 'wo') structure_SS.add_element('Cr', 0.17, 'wo') structure_SS.add_element('Mo', 0.025, 'wo') structure_SS.add_element('Mn', 0.02, 'wo') structure_SS.add_element('Fe', 0.665, 'wo') #Control Rod Material B4C ControlRod_B4C = openmc.Material(material_id=3, name='B4C') ControlRod_B4C.set_density('g/cm3', 2.52) ControlRod_B4C.add_nuclide('B10', 4, 'ao') ControlRod_B4C.add_element('C', 1, 'ao') #Reflector Material BeO Reflector_BeO = openmc.Material(material_id=4, name='BeO') Reflector_BeO.set_density('g/cm3', 3.025) Reflector_BeO.add_element('Be', 1, 'ao') Reflector_BeO.add_element('O', 1, 'ao') #Coolant Na Coolant_Na = openmc.Material(material_id=5, name='Na') Coolant_Na.set_density('g/cm3', 0.76) Coolant_Na.add_element('Na', 1, 'ao') # Instantiate a Materials collection materials_file = openmc.Materials([ structure_HAY, structure_SS, ControlRod_B4C, Reflector_BeO, Coolant_Na ]) # Number of cells n_r = cells_num_dic['n_r'] n_r_outer = cells_num_dic['n_r_outer'] n_h = cells_num_dic['n_h'] # Effect of Temperature on density of fuel density = calUMoDensity(temp_defualt) # Fuel U-10Mo Fuel = openmc.Material(material_id=6, name='U-10Mo fuel') Fuel.set_density('g/cm3', density) Fuel.add_element('Mo', 0.1, 'wo') # fuel.add_nuclide('U235',0.1773,'wo') # for LEU (19.7%) # fuel.add_nuclide('U238',0.7227,'wo') Fuel.add_nuclide('U235', 0.837, 'wo') # for HEU (93.0%) Fuel.add_nuclide('U238', 0.063, 'wo') Fuel.temperature = temp_defualt Fuel.volume = np.pi * (fuel_r**2 - controlRod_r**2) * fuel_h / 8 materials_file.append(Fuel) # Export to "materials.xml" materials_file.export_to_xml() num_heat_pipe = 8 # Create cylinders for the fuel control rod and reflector fuel_OD = openmc.ZCylinder(x0=0.0, y0=0.0, r=fuel_r) controlRod_OD = openmc.ZCylinder(x0=0.0, y0=0.0, r=controlRod_r) reflector_OD = openmc.ZCylinder(x0=0.0, y0=0.0, r=reflector_r, boundary_type='vacuum') # Create planes for fuel control rod and reflector reflector_TOP = openmc.ZPlane(z0=(top_distance + fuel_h / 2), boundary_type='vacuum') reflector_BOTTOM = openmc.ZPlane(z0=-(bottom_distance + fuel_h / 2), boundary_type='vacuum') reflector_empty_TOP = openmc.ZPlane( z0=-(bottom_distance + fuel_h / 2 - empty_reflector_height)) fuel_TOP = openmc.ZPlane(z0=fuel_h / 2) fuel_BOTTOM = openmc.ZPlane(z0=-fuel_h / 2) controlRodSpace_TOP = openmc.ZPlane(z0=(controlRod_h_max - bottom_distance - fuel_h / 2)) # Create cylinders for heat pipes heat_pipe_OD = openmc.ZCylinder(x0=fuel_r, y0=0, r=heat_pipe_R) n_ang = num_heat_pipe ang_mesh = np.pi / n_ang r_mesh = np.linspace(controlRod_r, (fuel_r - heat_pipe_R), n_r + 1) r_outer_mesh = np.linspace(fuel_r - heat_pipe_R, fuel_r, n_r_outer + 1) h_mesh = np.linspace(-fuel_h / 2, fuel_h / 2, n_h + 1) line_1 = openmc.Plane(a=np.tan(-ang_mesh), b=-1.0, c=0.0, d=0.0, boundary_type='reflective') line_2 = openmc.Plane(a=np.tan(ang_mesh), b=-1.0, c=0.0, d=0.0, boundary_type='reflective') # Create volume vector and matrix volume_vec = np.zeros(n_r + n_r_outer) d_h = fuel_h / n_h for i in range(n_r + n_r_outer): if i >= n_r: d = heat_pipe_R * (i - n_r) / n_r_outer x_i = np.sqrt(2 * heat_pipe_R * d - d * d) d = heat_pipe_R * (i - n_r + 1) / n_r_outer x_i1 = np.sqrt(2 * heat_pipe_R * d - d * d) s = (x_i + x_i1) * heat_pipe_R / n_r_outer volume_vec[i] = d_h * np.pi * ( r_outer_mesh[i + 1 - n_r] * r_outer_mesh[i + 1 - n_r] - r_outer_mesh[i - n_r] * r_outer_mesh[i - n_r]) / 8 - s else: volume_vec[i] = d_h * np.pi * (r_mesh[i + 1] * r_mesh[i + 1] - r_mesh[i] * r_mesh[i]) / 8 volume_mat = np.zeros((n_h, (n_r + n_r_outer))) for i in range(n_h): volume_mat[i, :] = volume_vec # Create heat_pipe universe heat_pipe_Inner = openmc.ZCylinder(r=heat_pipe_r) coolant_cell = openmc.Cell(fill=Coolant_Na, region=(-heat_pipe_Inner & -reflector_TOP & +reflector_BOTTOM)) pipe_cell = openmc.Cell(fill=structure_HAY, region=(+heat_pipe_Inner & -reflector_TOP & +reflector_BOTTOM)) heat_pipe_universe = openmc.Universe(cells=(coolant_cell, pipe_cell)) # Create a Universe to encapsulate a fuel pin pin_cell_universe = openmc.Universe(name='U-10Mo Pin') # fuel_cell_universe = openmc.Universe(name='fule cell') # Create fine-fuel-cell (num of cells: n_r + n_r_outer) fuel_cell_list = [] fuel_cell_ID_list = [] k = 0 for j in range(n_h): cir_top = openmc.ZPlane(z0=h_mesh[j + 1]) cir_bottom = openmc.ZPlane(z0=h_mesh[j]) for i in range(n_r): cir_in = openmc.ZCylinder(r=r_mesh[i]) cir_out = openmc.ZCylinder(r=r_mesh[i + 1]) fuel_cell = openmc.Cell() fuel_cell.fill = Fuel k = k + 1 fuel_cell.region = +cir_in & -cir_out & +cir_bottom & -cir_top fuel_cell.temperature = temp_phy_mat[j, i] fuel_cell.id = (j + 1) * 10000 + (i + 1) * 100 fuel_cell_ID_list.append((j + 1) * 10000 + (i + 1) * 100) fuel_cell_list.append(fuel_cell) pin_cell_universe.add_cell(fuel_cell) # fuel_cell_universe.add_cell(fuel_cell) for i in range(n_r_outer): cir_in = openmc.ZCylinder(r=r_outer_mesh[i]) cir_out = openmc.ZCylinder(r=r_outer_mesh[i + 1]) fuel_cell = openmc.Cell() fuel_cell.fill = Fuel k = k + 1 fuel_cell.region = +cir_in & -cir_out & +heat_pipe_OD & +cir_bottom & -cir_top fuel_cell.temperature = temp_phy_mat[j, i + n_r] fuel_cell.id = (j + 1) * 10000 + (n_r + i + 1) * 100 fuel_cell_ID_list.append((j + 1) * 10000 + (n_r + i + 1) * 100) fuel_cell_list.append(fuel_cell) pin_cell_universe.add_cell(fuel_cell) # fuel_cell_universe.add_cell(fuel_cell) # Create control rod Cell controlRod_TOP = openmc.ZPlane(z0=(controlRod_deep - fuel_h / 2 - bottom_distance)) controlRod_TOP.name = 'controlRod_TOP' if controlRod_deep < controlRod_h_max: controlRod_empty_cell = openmc.Cell(name='Control Rod Empty') controlRod_empty_cell.region = -controlRod_OD & +controlRod_TOP & -controlRodSpace_TOP pin_cell_universe.add_cell(controlRod_empty_cell) if controlRod_deep > 0: controlRod_cell = openmc.Cell(name='Control Rod') controlRod_cell.fill = ControlRod_B4C controlRod_cell.region = -controlRod_OD & +reflector_BOTTOM & -controlRod_TOP controlRod_cell.tempearture = temp_defualt pin_cell_universe.add_cell(controlRod_cell) # Create heat pipe Cell heat_pipe_cell = openmc.Cell(name='Heat Pipe') heat_pipe_cell.fill = heat_pipe_universe heat_pipe_cell.region = -heat_pipe_OD & +reflector_BOTTOM & -reflector_TOP heat_pipe_cell.temperature = temp_defualt heat_pipe_cell.translation = (fuel_r, 0, 0) pin_cell_universe.add_cell(heat_pipe_cell) # To be edited # Create reflector Cell if empty_reflector_height > 0: reflector_radial_empty_cell = openmc.Cell( name='Radial Reflector Empty') reflector_radial_empty_cell.region = +fuel_OD & +heat_pipe_OD & +reflector_BOTTOM & -reflector_empty_TOP pin_cell_universe.add_cell(reflector_radial_empty_cell) reflector_radial_cell = openmc.Cell(name='Radial Reflector') reflector_radial_cell.fill = Reflector_BeO reflector_radial_cell.region = +fuel_OD & +heat_pipe_OD & +reflector_empty_TOP & -reflector_TOP reflector_radial_cell.temperature = temp_defualt pin_cell_universe.add_cell(reflector_radial_cell) else: reflector_radial_cell = openmc.Cell(name='Radial Reflector') reflector_radial_cell.fill = Reflector_BeO reflector_radial_cell.region = +fuel_OD & +heat_pipe_OD & +reflector_BOTTOM & -reflector_TOP reflector_radial_cell.temperature = temp_defualt pin_cell_universe.add_cell(reflector_radial_cell) reflector_bottom_cell = openmc.Cell(name='Bottom Reflector') reflector_bottom_cell.fill = Reflector_BeO reflector_bottom_cell.region = +controlRod_OD & +heat_pipe_OD & -fuel_OD & -fuel_BOTTOM & +reflector_BOTTOM reflector_bottom_cell.temperature = temp_defualt pin_cell_universe.add_cell(reflector_bottom_cell) reflector_top_cell = openmc.Cell(name='Top Reflector') reflector_top_cell.fill = Reflector_BeO reflector_top_cell.region = +heat_pipe_OD & -fuel_OD & +controlRodSpace_TOP & -reflector_TOP reflector_top_cell.region = reflector_top_cell.region | ( +controlRod_OD & +heat_pipe_OD & -fuel_OD & +fuel_TOP & -controlRodSpace_TOP) reflector_top_cell.temperature = temp_defualt pin_cell_universe.add_cell(reflector_top_cell) # Create root Cell root_cell = openmc.Cell(name='root cell') root_cell.fill = pin_cell_universe # Add boundary planes root_cell.region = -reflector_OD & +line_2 & -line_1 & +reflector_BOTTOM & -reflector_TOP # Create root Universe root_universe = openmc.Universe(universe_id=0, name='root universe') root_universe.add_cell(root_cell) # Create Geometry and set root Universe geometry = openmc.Geometry(root_universe) # Export to "geometry.xml" geometry.export_to_xml() # plot = openmc.Plot.from_geometry(geometry,basis='xz', slice_coord=0.0) # plot.pixels = (1000, 1000) # plot.to_ipython_image() settings_MC_dic = settings_dic['settings_MC_dic'] # Instantiate a Settings object settings_file = openmc.Settings() settings_file.batches = settings_MC_dic['batches'] settings_file.inactive = settings_MC_dic['inactive'] settings_file.particles = settings_MC_dic['particles'] settings_file.temperature['multipole'] = True settings_file.temperature['method'] = 'interpolation' settings_file.source = openmc.Source(space=openmc.stats.Point((15, 0, 0))) # Export to "settings.xml" settings_file.export_to_xml() # Instantiate an empty Tallies object tallies_file = openmc.Tallies() for i in range(len(fuel_cell_ID_list)): tally = openmc.Tally(name='cell tally ' + str(fuel_cell_ID_list[i])) tally.filters = [openmc.DistribcellFilter(fuel_cell_ID_list[i])] tally.scores = ['heating', 'flux'] tallies_file.append(tally) # # Create energy tally to score flux # energy_bins = np.logspace(np.log10(1e-2), np.log10(20.0e6), 20) # fine_energy_filter = openmc.EnergyFilter(energy_bins) # tally = openmc.Tally(name='energy tally') # tally.filters.append(fine_energy_filter) # tally.filters.append(openmc.DistribcellFilter(810)) # tally.scores = ['flux'] # tallies_file.append(tally) # Export to "tallies.xml" tallies_file.export_to_xml() return volume_mat, fuel_cell_ID_list
# Fission rate mesh Tally mesh_fiss = openmc.Tally(name='mesh fission') mesh_fiss.filters = [mesh_filter] mesh_fiss.scores = ['fission'] mesh_fiss.nuclides = ['U235', 'U238'] # Fine energy flux Tally flux = openmc.Tally(name='flux') energies = np.logspace(-2, np.log10(8e6), 1000) flux.filters = [openmc.EnergyFilter(energies)] flux.scores = ['flux'] # U-238 capture and fission distribcell Tally distribcell = openmc.Tally(name='distribcell') distribcell.filters = [openmc.DistribcellFilter(fuel.id)] distribcell.nuclides = ['U235', 'U238'] distribcell.scores = ['absorption', 'fission'] # Resonance escape probability Tallies therm_abs = openmc.Tally(name='thermal absorption') therm_abs.scores = ['absorption'] therm_abs.filters = [openmc.EnergyFilter([0., 0.625])] tot_abs = openmc.Tally(name='total absorption') tot_abs.scores = ['absorption'] # Instantiate an 8-group structure for MGXS tallies groups8 = openmc.mgxs.EnergyGroups() groups8.group_edges = np.array( [0.0, 0.058, 0.14, 0.28, 0.625, 4.0, 5.53e3, 821e3, 20e6])
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Define nuclides and scores to add to both tallies self.nuclides = ['U235', 'U238'] self.scores = ['fission', 'nu-fission'] # Define filters for energy and spatial domain low_energy = openmc.EnergyFilter([0., 0.625]) high_energy = openmc.EnergyFilter([0.625, 20.e6]) merged_energies = low_energy.merge(high_energy) cell_21 = openmc.CellFilter(21) cell_27 = openmc.CellFilter(27) distribcell_filter = openmc.DistribcellFilter(21) mesh = openmc.RegularMesh(name='mesh') mesh.dimension = [2, 2] mesh.lower_left = [-50., -50.] mesh.upper_right = [+50., +50.] mesh_filter = openmc.MeshFilter(mesh) self.cell_filters = [cell_21, cell_27] self.energy_filters = [low_energy, high_energy] # Initialize cell tallies with filters, nuclides and scores tallies = [] for energy_filter in self.energy_filters: for cell_filter in self.cell_filters: for nuclide in self.nuclides: for score in self.scores: tally = openmc.Tally() tally.estimator = 'tracklength' tally.scores.append(score) tally.nuclides.append(nuclide) tally.filters.append(cell_filter) tally.filters.append(energy_filter) tallies.append(tally) # Merge all cell tallies together while len(tallies) != 1: halfway = len(tallies) // 2 zip_split = zip(tallies[:halfway], tallies[halfway:]) tallies = list(map(lambda xy: xy[0].merge(xy[1]), zip_split)) # Specify a name for the tally tallies[0].name = 'cell tally' # Initialize a distribcell tally distribcell_tally = openmc.Tally(name='distribcell tally') distribcell_tally.estimator = 'tracklength' distribcell_tally.filters = [distribcell_filter, merged_energies] for score in self.scores: distribcell_tally.scores.append(score) for nuclide in self.nuclides: distribcell_tally.nuclides.append(nuclide) mesh_tally = openmc.Tally(name='mesh tally') mesh_tally.estimator = 'tracklength' mesh_tally.filters = [mesh_filter, merged_energies] mesh_tally.scores = self.scores mesh_tally.nuclides = self.nuclides # Add tallies to a Tallies object self._model.tallies = [tallies[0], distribcell_tally, mesh_tally]
plot_xy.filename = 'plot_xy' plot_xy.origin = [0, 0, 0] plot_xy.width = [6, 6] plot_xy.pixels = [400, 400] plot_xy.color_by = 'material' plot_yz = openmc.Plot(plot_id=2) plot_yz.filename = 'plot_yz' plot_yz.basis = 'yz' plot_yz.origin = [0, 0, 0] plot_yz.width = [8, 8] plot_yz.pixels = [400, 400] plot_yz.color_by = 'material' # Instantiate a Plots collection, add plots, and export to XML plot_file = openmc.Plots((plot_xy, plot_yz)) plot_file.export_to_xml() ############################################################################### # Exporting to OpenMC tallies.xml File ############################################################################### # Instantiate a distribcell Tally tally = openmc.Tally(tally_id=1) tally.filters = [openmc.DistribcellFilter(cell2)] tally.scores = ['total'] # Instantiate a Tallies collection and export to XML tallies_file = openmc.Tallies([tally]) tallies_file.export_to_xml()
space=openmc.stats.Box((0.1, 0.1, 0), (0.49 * assembly_pitch, 0.49 * assembly_pitch, 0))) settings.batches = 50 settings.inactive = 10 settings.particles = 1000 settings.export_to_xml() # tallies tallies = openmc.Tallies() mesh = openmc.Mesh() mesh.dimension = [3, 3] mesh.lower_left = lattice.lower_left mesh.width = lattice.pitch mesh_filt = openmc.MeshFilter(mesh) t = openmc.Tally(1) t.filters = [mesh_filt] t.scores = ['total', 'fission'] t.nuclides = ['total', 'U235'] tallies.append(t) dist_filt = openmc.DistribcellFilter(fuel.id) t = openmc.Tally(2) t.filters = [dist_filt] t.scores = ['total', 'fission'] t.nuclides = ['total', 'U235'] tallies.append(t) tallies.export_to_xml() openmc.run()