def make_geometry_tallies(batches, nps, inner_radius, thickness): first_wall_inner_surface = openmc.Sphere(r=inner_radius) first_wall_outer_surface = openmc.Sphere(r=inner_radius + thickness, boundary_type='vacuum') first_wall = +first_wall_inner_surface & -first_wall_outer_surface first_wall = openmc.Cell(region=first_wall) first_wall.fill = eurofer inner_vac_cell = -first_wall_inner_surface inner_vac_cell = openmc.Cell(region=inner_vac_cell) universe = openmc.Universe(cells=[first_wall, inner_vac_cell]) geom = openmc.Geometry(universe) geom.export_to_xml('geometry') vox_plot = openmc.Plot() vox_plot.type = 'voxel' vox_plot.width = (10, 10, 10) vox_plot.pixels = (200, 200, 200) vox_plot.filename = 'plot_3d' vox_plot.color_by = 'material' vox_plot.colors = {eurofer: 'blue'} plots = openmc.Plots([vox_plot]) plots.export_to_xml() openmc.plot_geometry() os.system('openmc-voxel-to-vtk plot_3d.h5 -o plot_3d.vti') os.system('paraview plot_3d.vti') sett = openmc.Settings() sett.batches = batches sett.inactive = 0 sett.particles = nps sett.run_mode = 'fixed source' source = openmc.Source() source.space = openmc.stats.Point((0, 0, 0)) source.angle = openmc.stats.Isotropic() source.energy = openmc.stats.Discrete([14.08e6], [1]) #source.energy = openmc.stats.Muir(e0=14080000.0, m_rat=5.0, kt=20000.0) sett.source = source sett.export_to_xml('settings.xml') #tallies particle_filter = openmc.ParticleFilter([1]) surface_filter_front = openmc.SurfaceFilter(first_wall_inner_surface) surface_filter_rear = openmc.SurfaceFilter(first_wall_outer_surface) bins = openmc.mgxs.GROUP_STRUCTURES['VITAMIN-J-175'] #think will need to change this energy_filter = openmc.EnergyFilter(bins) tallies = openmc.Tallies() tally = openmc.Tally(name='wall_leakage') tally.filters = [surface_filter_rear, particle_filter] tally.scores = ['current'] tallies.append(tally) tally = openmc.Tally(name='incident_neutron_spectrum') tally.filters = [surface_filter_rear, particle_filter, energy_filter] tally.scores = ['flux'] tallies.append(tally) tally = openmc.Tally(name='leakage_neutron_spectrum') tally.filters = [surface_filter_front, particle_filter, energy_filter] tally.scores = ['flux'] tallies.append(tally) model = openmc.model.Model(geom, mats, sett, tallies) model.run() sp = openmc.StatePoint('statepoint.' + str(batches) + '.h5') tallies_to_retrieve = ['wall_leakage'] #at the moment, we only have one tally to retrieve, but we will set it up in a list anyway so we know how to do it for tally_name in tallies_to_retrieve: tally = sp.get_tally(name=tally_name) df = tally.get_pandas_dataframe() #defining something that stands for dataframe, need to investigate this #its basically something that we use to obtain the mean value and the std deviation value of the tally tally_result = df['mean'].sum() tally_std_dev = df['std. dev.'].sum() #for now, we will just try to print these values #get spectra spectra_tallies_to_retrieve = [ 'incident_neutron_spectrum', 'leakage_neutron_spectrum' ] for spectra_name in spectra_tallies_to_retrieve: spectra_tally = sp.get_tally(name=spectra_name) spectra_tally_result = [entry[0][0] for entry in spectra_tally.mean] spectra_tally_std_dev = [ entry[0][0] for entry in spectra_tally.std_dev ]
# Instantiate a SettingsFile, set all runtime parameters, and export to XML settings_file = openmc.SettingsFile() settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles settings_file.set_source_space('box', [-1, -1, -1, 1, 1, 1]) settings_file.keff_trigger = {'type': 'std_dev', 'threshold': 5E-4} settings_file.trigger_active = True settings_file.trigger_max_batches = 100 settings_file.export_to_xml() ############################################################################### # Exporting to OpenMC plots.xml File ############################################################################### plot_xy = openmc.Plot(plot_id=1) plot_xy.filename = 'plot_xy' plot_xy.origin = [0, 0, 0] plot_xy.width = [6, 6] plot_xy.pixels = [400, 400] plot_xy.color = 'mat' 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 = 'mat' # Instantiate a PlotsFile, add Plot, and export to XML
def hexfunction(pitch, pack_frac): settings = openmc.Settings() # Set high tolerance to allow use of lower temperature xs settings.temperature['tolerance'] = 1000 settings.temperature['method'] = 'nearest' settings.temperature['multipole'] = True settings.cutoff = {'energy': 1e-8} #energy cutoff in eV ############################# ### MATERIALS ### ############################# mat_list = [] enrichment = 20.0 uo2 = openmc.Material(1, "uo2") uo2.add_element('U', 1.0, enrichment=enrichment) uo2.add_element('O', 2.0) uo2.set_density('g/cm3', 10.97) uo2.temperature = 900 #kelvin mat_list.append(uo2) graphite = openmc.Material(2, "graphite") graphite.set_density('g/cm3', 1.1995) graphite.add_element('C', 1.0) graphite.add_s_alpha_beta('c_Graphite') graphite.temperature = 900 #kelvin mat_list.append(graphite) # sodium = openmc.Material(3, "sodium") sodium = openmc.Material() sodium.set_density('g/cm3', 0.8017) # 900 K sodium.add_element('Na', 1.0) # sodium.add_s_alpha_beta('c_Graphite') sodium.temperature = 900 #kelvin mat_list.append(sodium) # naoh = openmc.Material(6, "naoh") naoh = openmc.Material() naoh.set_density('g/cm3', 1.5) # 900 K naoh.add_element('Na', 1.0) naoh.add_element('O', 1.0) naoh.add_element('H', 1.0) # sodium.add_s_alpha_beta('c_Graphite') naoh.temperature = 900 #kelvin mat_list.append(naoh) # TRISO Materials fuel = openmc.Material(name='Fuel') fuel.set_density('g/cm3', 10.5) # fuel.add_nuclide('U235', 4.6716e-02) fuel.add_nuclide('U235', 0.0667372) # fuel.add_nuclide('U238', 2.8697e-01) fuel.add_nuclide('U238', 0.2669488) fuel.add_nuclide('O16', 5.0000e-01) fuel.add_element('C', 1.6667e-01) mat_list.append(fuel) buff = openmc.Material(name='Buffer') buff.set_density('g/cm3', 1.0) buff.add_element('C', 1.0) buff.add_s_alpha_beta('c_Graphite') mat_list.append(buff) PyC1 = openmc.Material(name='PyC1') PyC1.set_density('g/cm3', 1.9) PyC1.add_element('C', 1.0) PyC1.add_s_alpha_beta('c_Graphite') mat_list.append(PyC1) PyC2 = openmc.Material(name='PyC2') PyC2.set_density('g/cm3', 1.87) PyC2.add_element('C', 1.0) PyC2.add_s_alpha_beta('c_Graphite') mat_list.append(PyC2) SiC = openmc.Material(name='SiC') SiC.set_density('g/cm3', 3.2) SiC.add_element('C', 0.5) SiC.add_element('Si', 0.5) mat_list.append(SiC) fuel_temp = 900 homogeneous_fuel = build_fuel_material(fuel_temp, pack_frac) mat_list.append(homogeneous_fuel) mats = openmc.Materials(mat_list) mats.export_to_xml() ############################# ### GEOMETRY ### ############################# pitch = 17.4 fuel_bottom = -pitch / 2 fuel_top = pitch / 2 coolant_r = 4 # fuel_r = (pitch/2 - coolant_r)/2 fuel_r = (pitch / (3**(1 / 2)) - coolant_r) / 2 hex_universe = openmc.Universe() top = openmc.ZPlane(z0=fuel_top, boundary_type='reflective') bottom = openmc.ZPlane(z0=fuel_bottom, boundary_type='reflective') surf_fuel = openmc.ZCylinder(r=fuel_r) # Make TRISOS to be filled in fuel cylinders by chopping up # fuel cylinder into segments n_cyls = 40 fuel_segment_heights = np.linspace(fuel_bottom, fuel_top, n_cyls) segment_height = fuel_segment_heights[1] - fuel_segment_heights[0] fuel_planes = [bottom] fuel_cells = [] for i, height in enumerate(fuel_segment_heights[1:-1]): this_plane = openmc.ZPlane(z0=height) fuel_planes.append(this_plane) this_cell = openmc.Cell() this_cell.region = +fuel_planes[i] & -fuel_planes[i + 1] & -surf_fuel fuel_cells.append(copy.deepcopy(this_cell)) # last cell fuel_planes.append(top) this_cell = openmc.Cell() this_cell.region = +fuel_planes[-2] & -fuel_planes[-1] & -surf_fuel fuel_cells.append(copy.deepcopy(this_cell)) # Make fuel cylinder fuel_cyl_top = openmc.ZPlane(z0=segment_height / 2) fuel_cyl_bottom = openmc.ZPlane(z0=-segment_height / 2) fuel_triso_region = -surf_fuel & +fuel_cyl_bottom & -fuel_cyl_top outer_radius = 425. * 1e-4 # openmc.model.triso._Cylinder.from_region(fuel_region, outer_radius) spheres = [openmc.Sphere(r=r * 1e-4) for r in [215., 315., 350., 385.]] cells = [ openmc.Cell(fill=fuel, region=-spheres[0]), openmc.Cell(fill=buff, region=+spheres[0] & -spheres[1]), openmc.Cell(fill=PyC1, region=+spheres[1] & -spheres[2]), openmc.Cell(fill=SiC, region=+spheres[2] & -spheres[3]), openmc.Cell(fill=PyC2, region=+spheres[3]) ] triso_univ = openmc.Universe(cells=cells) outer_radius = 425. * 1e-4 centers = openmc.model.pack_spheres(radius=outer_radius, region=fuel_triso_region, pf=pack_frac) trisos = [openmc.model.TRISO(outer_radius, triso_univ, c) for c in centers] outside_trisos = openmc.Intersection(~t.region for t in trisos) # background_region = outside_trisos & +fuel_cyl_bottom & \ # -fuel_cyl_top & -surf_fuel background_region = outside_trisos background_cell = openmc.Cell(fill=graphite, region=background_region) fuel_triso_univ = openmc.Universe() fuel_triso_univ.add_cell(background_cell) for idx, triso in enumerate(trisos): fuel_triso_univ.add_cell(triso) # Fill in fuel cells with triso cells and translate to location for i, cell in enumerate(fuel_cells): cell_height = segment_height * (i + 1 / 2) + fuel_bottom cell.translation = [0, 0, cell_height] cell.fill = fuel_triso_univ fuel_cell_univ = openmc.Universe(cells=fuel_cells) # For testing solid fuel # test_region = +bottom & -top & -surf_fuel # fuel_cell = openmc.Cell(region=test_region, fill=fuel) # fuel_cell_univ = openmc.Universe(cells=[fuel_cell]) coolant_cyl = openmc.ZCylinder(r=coolant_r) coolant_region = -coolant_cyl coolant_cell = openmc.Cell() coolant_cell.fill = naoh coolant_cell.region = coolant_region hex_universe.add_cell(coolant_cell) hex_prism = openmc.get_hexagonal_prism(edge_length=pitch / (3**1 / 2), boundary_type='reflective') graphite_region = hex_prism & +coolant_cyl & -top & +bottom graphite_cell = openmc.Cell() graphite_cell.fill = graphite graphite_cell.region = graphite_region hex_universe.add_cell(graphite_cell) fuel_cells = [] root3 = 3**(1 / 2) half_to_vertex = pitch / root3 / 2 half_to_edge = pitch / 4 # fuel_id = 100 offset_angle = 30 n_pins = 6 for i in range(n_pins): theta = (offset_angle + i / n_pins * 360) * pi / 180 r = coolant_r + fuel_r + 0.01 x = r * np.cos(theta) y = r * np.sin(theta) fuel_cyl_bound = openmc.ZCylinder(x0=x, y0=y, r=fuel_r) graphite_cell.region &= +fuel_cyl_bound fuel_cell = openmc.Cell() fuel_cell.fill = copy.deepcopy(fuel_cell_univ) fuel_cell.translation = [x, y, 0] fuel_cell.region = -fuel_cyl_bound & -top & +bottom # fuel_cell.id = fuel_id # fuel_id += 1 fuel_cells.append(fuel_cell) hex_universe.add_cell(fuel_cell) geom = openmc.Geometry(hex_universe) # geom = openmc.Geometry(fuel_cell_univ) geom.export_to_xml() ##################################### ### SOURCE/BATCHES ### ##################################### point = openmc.stats.Point((0, 0, 0)) src = openmc.Source(space=point) settings.source = src settings.batches = 50 settings.inactive = 10 settings.particles = 200 settings.export_to_xml() ############################# ### TALLIES ### ############################# # Instantiate an empty Tallies object tallies_file = openmc.Tallies() # K-Eigenvalue (infinity) tallies fiss_rate = openmc.Tally(name='fiss. rate') fiss_rate.scores = ['nu-fission'] tallies_file.append(fiss_rate) abs_rate = openmc.Tally(name='abs. rate') abs_rate.scores = ['absorption'] tallies_file.append(abs_rate) # Resonance Escape Probability tallies therm_abs_rate = openmc.Tally(name='therm. abs. rate') therm_abs_rate.scores = ['absorption'] therm_abs_rate.filters = [openmc.EnergyFilter([0., 0.625])] tallies_file.append(therm_abs_rate) # Thermal Flux Utilization tallies # fuel_therm_abs_rate = openmc.Tally(name='fuel therm. abs. rate') # fuel_therm_abs_rate.scores = ['absorption'] # fuel_therm_abs_rate.filters = [openmc.EnergyFilter([0., 0.625]), # openmc.CellFilter([fuel_cell])] # tallies_file.append(fuel_therm_abs_rate) # Fast Fission Factor tallies therm_fiss_rate = openmc.Tally(name='therm. fiss. rate') therm_fiss_rate.scores = ['nu-fission'] therm_fiss_rate.filters = [openmc.EnergyFilter([0., 0.625])] tallies_file.append(therm_fiss_rate) tallies_file.export_to_xml() ############################# ### PLOTTING ### ############################# zs = np.linspace(0, 1, 2) plots = [] for z in zs: p = openmc.Plot() p.filename = 'pinplot' + str(z) p.width = (1.4 * pitch, 1.4 * pitch) p.pixels = (2000, 2000) p.color_by = 'material' p.origin = [0, 0, z] # p.color_by = 'cell' # p.colors = {homogeneous_fuel: 'yellow', naoh: 'grey', graphite: 'black'} p.colors = {fuel: 'yellow', naoh: 'grey', graphite: 'black'} plots.append(copy.deepcopy(p)) plots = openmc.Plots(plots) plots.export_to_xml() # openmc.plot_geometry(output = False) openmc.plot_geometry() # pngstring = 'pinplot{}.png'.format(str(pitch)) # subprocess.call(['convert','pinplot.ppm',pngstring]) # subprocess.call(['mv',pngstring,'figures/'+pngstring]) ############################# ### EXECUTION ### ############################# # openmc.run(output=False) openmc.run() sp = openmc.StatePoint('statepoint.{}.h5'.format(settings.batches)) # Collect all the tallies fiss_rate = sp.get_tally(name='fiss. rate') fiss_rate_df = fiss_rate.get_pandas_dataframe() abs_rate = sp.get_tally(name='abs. rate') abs_rate_df = abs_rate.get_pandas_dataframe() therm_abs_rate = sp.get_tally(name='therm. abs. rate') therm_abs_rate_df = therm_abs_rate.get_pandas_dataframe() fuel_therm_abs_rate = sp.get_tally(name='fuel therm. abs. rate') fuel_therm_abs_rate_df = fuel_therm_abs_rate.get_pandas_dataframe() therm_fiss_rate = sp.get_tally(name='therm. fiss. rate') therm_fiss_rate_df = therm_fiss_rate.get_pandas_dataframe() # Compute k-infinity kinf = fiss_rate / abs_rate kinf_df = kinf.get_pandas_dataframe() # Compute resonance escape probability res_esc = (therm_abs_rate) / (abs_rate) res_esc_df = res_esc.get_pandas_dataframe() # Compute fast fission factor fast_fiss = fiss_rate / therm_fiss_rate fast_fiss_df = fast_fiss.get_pandas_dataframe() # Compute thermal flux utilization therm_util = fuel_therm_abs_rate / therm_abs_rate therm_util_df = therm_util.get_pandas_dataframe() # Compute neutrons produced per absorption eta = therm_fiss_rate / fuel_therm_abs_rate eta_df = eta.get_pandas_dataframe() columns = [ 'pitch', 'enrichment', 'kinf mean', 'kinf sd', 'res_esc mean', 'res_esc sd', 'fast_fiss mean', 'fast_fiss sd', 'therm_util mean', 'therm_util sd', 'eta mean', 'eta sd' ] data = [[ pitch, enrichment, kinf_df['mean'][0], kinf_df['std. dev.'][0], res_esc_df['mean'][0], res_esc_df['std. dev.'][0], fast_fiss_df['mean'][0], fast_fiss_df['std. dev.'][0], therm_util_df['mean'][0], therm_util_df['std. dev.'][0], eta_df['mean'][0], eta_df['std. dev.'][0] ]] all_tallies = pd.DataFrame(data, columns=columns) return all_tallies
def shield(rad, major, coil, bool, outer, m_batches, m_error, neutrons): #MATERIALS# min = coil max = outer+coil major_rad = major + outer R1 = rad[0] R2 = rad[1] mats = openmc.Materials() tungsten = openmc.Material(name='Tungsten carbide') tungsten.set_density('g/cm3', 15.63) tungsten.add_element('W', 1.0) tungsten.add_element('C', 1.0) mats.append(tungsten) water = openmc.Material(name='Water') water.set_density('g/cm3', 1.0) water.add_element('H', 2.0) water.add_element('O', 1.0) mats.append(water) copper = openmc.Material(name='Copper') copper.set_density('g/cm3', 8.5) copper.add_element('Cu', 1.0) mats.append(copper) eurofer = openmc.Material(name='EUROFER97') eurofer.set_density('g/cm3', 7.75) eurofer.add_element('Fe', 89.067, percent_type='wo') eurofer.add_element('C', 0.11, percent_type='wo') eurofer.add_element('Mn', 0.4, percent_type='wo') eurofer.add_element('Cr', 9.0, percent_type='wo') eurofer.add_element('Ta', 0.12, percent_type='wo') eurofer.add_element('W', 1.1, percent_type='wo') eurofer.add_element('N', 0.003, percent_type='wo') eurofer.add_element('V', 0.2, percent_type='wo') mats.append(eurofer) #GEOMETRY# cylinder = openmc.ZCylinder(R=min) shield1 = openmc.ZCylinder(R=R1) shield2 = openmc.ZCylinder(R=R2) shield3 = openmc.ZCylinder(R=max) top = major_rad-(max-min) shield_sph1 = openmc.Sphere(R=top) shield_sph2 = openmc.Sphere(R=major_rad-(max-min)+(max-R2)) shield_sph3 = openmc.Sphere(R=major_rad-(max-min)+(max-R2)+(R2-R1)) pit = sqrt(top**2+top**2) max_shield = sqrt(top**2+pit**2)+1 vessel_in = openmc.Sphere(R=major_rad) vessel_out = openmc.Sphere(R=max_shield, boundary_type='vacuum') magnet = -cylinder & -vessel_in mat1 = -shield1 & +cylinder & -shield_sph3 #work on this mat2 = -shield2 & +shield1 & -shield_sph2 #work on this mat3 = -shield3 & +shield2 & -shield_sph1 #work on this plasma = +shield3 & -shield_sph1 a = +shield_sph1 & -shield_sph2 & +shield2 #work on this b = +shield_sph2 & -shield_sph3 & +shield1 #work on this c = +shield_sph3 & -vessel_in & +cylinder #work on this vessel = +vessel_in & -vessel_out plasma_cell = openmc.Cell(region=plasma) #1 cop_mag = openmc.Cell(region=magnet) #2 cop_mag.fill = copper tung1 = openmc.Cell(region=mat1) #3 tung1.fill = tungsten wat = openmc.Cell(region=mat2) #4 wat.fill = water tung2 = openmc.Cell(region=mat3) #5 tung2.fill = tungsten ste_ves = openmc.Cell(region=vessel) #6 ste_ves.fill = eurofer tung_sph1 = openmc.Cell(region=a) #7 tung_sph1.fill = tungsten wat_sph = openmc.Cell(region=b) #8 wat_sph.fill = water tung_sph2 = openmc.Cell(region=c) #9 tung_sph2.fill = tungsten root = openmc.Universe(cells=(plasma_cell, cop_mag, tung1, wat, tung2, ste_ves, tung_sph1, wat_sph, tung_sph2)) geom = openmc.Geometry(root) root.plot(width=(600.0, 600.0), basis='xz') #SETTINGS# batch = 2 max_batches = m_batches inactive = 0 particles = neutrons source = openmc.Source() source.space = openmc.stats.Box((-top,-top,-top),(top,top,top)) source.angle = openmc.stats.Isotropic() source.energy = openmc.stats.Discrete([14e6], [1]) sett = openmc.Settings() sett.batches = batch sett.trigger_active = True sett.trigger_max_batches = m_batches sett.inactive = inactive sett.particles = particles sett.output = {'tallies': True} sett.run_mode = 'fixed source' sett.source = source #PLOT# plots = openmc.Plots() plot = openmc.Plot() #plot.type = 'voxel' plot.basis = 'xz' plot.origin = (0, 0, 0) plot.width = (600, 600) plot.pixels = (1000, 1000) plot.color_by = 'material' plot.colors = {tungsten: 'black', water: 'blue', eurofer: 'grey', copper: 'brown'} plots.append(plot) plots.export_to_xml() #TALLIES# tallies = openmc.Tallies() filter = openmc.CellFilter(cop_mag) tally = openmc.Tally(name='total') tally.scores = ['total'] tally.filters = [filter] trigger = openmc.Trigger('rel_err', m_error/100) tally.triggers = [trigger] tallies.append(tally) model = openmc.model.Model(geom, mats, sett, tallies) #RUN# model.run(output=bool) for i in reversed(range(batch,max_batches+1)): filename = 'statepoint.' +str(i).zfill(len(str(max_batches)))+ '.h5' if os.path.isfile(filename): sp = openmc.StatePoint(filename) break #print('file:',filename) leakage = sp.get_tally(name='total') leakage_mean = leakage.mean[0][0][0] leakage_error = leakage.std_dev[0][0][0] #print(leakage_mean) #print(leakage_error) dir = '/home/emiralle/shield_git' for zippath in glob.iglob(os.path.join(dir, '*.h5')): os.remove(zippath) return leakage_mean, leakage_error
root = openmc.Universe(cells=(cell12, cell13, cell14, cell15)) geom = openmc.Geometry(root) geom.export_to_xml() src = openmc.Source() bounds = [-58, 0, 0, 0, 75.6, 91] src.space = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True) settings = openmc.Settings() settings.source = src settings.batches = 500 settings.inactive = 100 settings.particles = 2500 settings.output = {'tallies': False} settings.export_to_xml() plot = openmc.Plot() plot.origin = [-18.9, 40, 67.5] plot.width = [150, 150] plot.pixels = [800, 800] plot.color_by = 'material' plot1 = openmc.Plot() plot1.origin = [-17.955, 36.855, 67.5] plot1.width = [150, 180] plot1.pixels = [800, 800] plot1.color_by = 'material' plot1.basis = 'yz' plot_file = openmc.Plots([plot, plot1]) plot_file.export_to_xml()
def hexfunction(pitch, pack_frac): settings = openmc.Settings() # Set high tolerance to allow use of lower temperature xs settings.temperature['tolerance'] = 1000 settings.temperature['method'] = 'nearest' settings.temperature['multipole'] = True settings.cutoff = {'energy': 1e-8} #energy cutoff in eV ############################# ### MATERIALS ### ############################# enrichment = 20.0 uo2 = openmc.Material(1, "uo2") uo2.add_element('U', 1.0, enrichment=enrichment) uo2.add_element('O', 2.0) uo2.set_density('g/cm3', 10.97) uo2.temperature = 900 #kelvin graphite = openmc.Material(2, "graphite") graphite.set_density('g/cm3', 1.1995) graphite.add_element('C', 1.0) graphite.add_s_alpha_beta('c_Graphite') graphite.temperature = 900 #kelvin sodium = openmc.Material(3, "sodium") sodium.set_density('g/cm3', 0.8017) # 900 K sodium.add_element('Na', 1.0) # sodium.add_s_alpha_beta('c_Graphite') sodium.temperature = 900 #kelvin naoh = openmc.Material(6, "naoh") naoh.set_density('g/cm3', 1.5) # 900 K naoh.add_element('Na', 1.0) naoh.add_element('O', 1.0) naoh.add_element('H', 1.0) # sodium.add_s_alpha_beta('c_Graphite') naoh.temperature = 900 #kelvin uo2 = openmc.Material(1, "uo2") uo2.add_element('U', 1.0, enrichment=enrichment) uo2.add_element('O', 2.0) uo2.set_density('g/cm3', 10.97) uo2.temperature = 900 #kelvin fuel_temp = 900 homogeneous_fuel = build_fuel_material(4, fuel_temp, pack_frac) mats = openmc.Materials([uo2, graphite, sodium, naoh, homogeneous_fuel]) mats.export_to_xml() ############################# ### GEOMETRY ### ############################# universe = openmc.Universe() coolant_cyl = openmc.ZCylinder(R=0.5) coolant_region = -coolant_cyl coolant_cell = openmc.Cell(1, 'coolant') coolant_cell.fill = naoh coolant_cell.region = coolant_region hex_prism = openmc.get_hexagonal_prism(edge_length=pitch / (3**1 / 2), boundary_type='reflective') top = openmc.YPlane(y0=pitch) bottom = openmc.YPlane(y0=-pitch) fuel_region = hex_prism & -top & +bottom fuel_cell = openmc.Cell(2, 'moderator') fuel_cell.fill = homogeneous_fuel fuel_cell.region = fuel_region root = openmc.Universe(cells=(fuel_cell, coolant_cell)) geom = openmc.Geometry(root) geom.export_to_xml() ##################################### ### SOURCE/BATCHES ### ##################################### point = openmc.stats.Point((0, 0, 0)) src = openmc.Source(space=point) settings.source = src settings.batches = 50 settings.inactive = 10 settings.particles = 200 settings.export_to_xml() ############################# ### TALLIES ### ############################# # Instantiate an empty Tallies object tallies_file = openmc.Tallies() # K-Eigenvalue (infinity) tallies fiss_rate = openmc.Tally(name='fiss. rate') fiss_rate.scores = ['nu-fission'] tallies_file.append(fiss_rate) abs_rate = openmc.Tally(name='abs. rate') abs_rate.scores = ['absorption'] tallies_file.append(abs_rate) # Resonance Escape Probability tallies therm_abs_rate = openmc.Tally(name='therm. abs. rate') therm_abs_rate.scores = ['absorption'] therm_abs_rate.filters = [openmc.EnergyFilter([0., 0.625])] tallies_file.append(therm_abs_rate) # Thermal Flux Utilization tallies fuel_therm_abs_rate = openmc.Tally(name='fuel therm. abs. rate') fuel_therm_abs_rate.scores = ['absorption'] fuel_therm_abs_rate.filters = [ openmc.EnergyFilter([0., 0.625]), openmc.CellFilter([fuel_cell]) ] tallies_file.append(fuel_therm_abs_rate) # Fast Fission Factor tallies therm_fiss_rate = openmc.Tally(name='therm. fiss. rate') therm_fiss_rate.scores = ['nu-fission'] therm_fiss_rate.filters = [openmc.EnergyFilter([0., 0.625])] tallies_file.append(therm_fiss_rate) tallies_file.export_to_xml() ############################# ### PLOTTING ### ############################# p = openmc.Plot() p.filename = 'pinplot' p.width = (2 * pitch, 2 * pitch) p.pixels = (200, 200) p.color_by = 'material' p.colors = {homogeneous_fuel: 'yellow', sodium: 'grey'} plots = openmc.Plots([p]) plots.export_to_xml() # openmc.plot_geometry(output = False) openmc.plot_geometry() pngstring = 'pinplot{}.png'.format(str(pitch)) subprocess.call(['convert', 'pinplot.ppm', pngstring]) subprocess.call(['mv', pngstring, 'figures/' + pngstring]) ############################# ### EXECUTION ### ############################# # openmc.run(output=False) openmc.run() sp = openmc.StatePoint('statepoint.{}.h5'.format(settings.batches)) # Collect all the tallies fiss_rate = sp.get_tally(name='fiss. rate') fiss_rate_df = fiss_rate.get_pandas_dataframe() abs_rate = sp.get_tally(name='abs. rate') abs_rate_df = abs_rate.get_pandas_dataframe() therm_abs_rate = sp.get_tally(name='therm. abs. rate') therm_abs_rate_df = therm_abs_rate.get_pandas_dataframe() fuel_therm_abs_rate = sp.get_tally(name='fuel therm. abs. rate') fuel_therm_abs_rate_df = fuel_therm_abs_rate.get_pandas_dataframe() therm_fiss_rate = sp.get_tally(name='therm. fiss. rate') therm_fiss_rate_df = therm_fiss_rate.get_pandas_dataframe() # Compute k-infinity kinf = fiss_rate / abs_rate kinf_df = kinf.get_pandas_dataframe() # Compute resonance escape probability res_esc = (therm_abs_rate) / (abs_rate) res_esc_df = res_esc.get_pandas_dataframe() # Compute fast fission factor fast_fiss = fiss_rate / therm_fiss_rate fast_fiss_df = fast_fiss.get_pandas_dataframe() # Compute thermal flux utilization therm_util = fuel_therm_abs_rate / therm_abs_rate therm_util_df = therm_util.get_pandas_dataframe() # Compute neutrons produced per absorption eta = therm_fiss_rate / fuel_therm_abs_rate eta_df = eta.get_pandas_dataframe() columns = [ 'pitch', 'enrichment', 'kinf mean', 'kinf sd', 'res_esc mean', 'res_esc sd', 'fast_fiss mean', 'fast_fiss sd', 'therm_util mean', 'therm_util sd', 'eta mean', 'eta sd' ] data = [[ pitch, enrichment, kinf_df['mean'][0], kinf_df['std. dev.'][0], res_esc_df['mean'][0], res_esc_df['std. dev.'][0], fast_fiss_df['mean'][0], fast_fiss_df['std. dev.'][0], therm_util_df['mean'][0], therm_util_df['std. dev.'][0], eta_df['mean'][0], eta_df['std. dev.'][0] ]] all_tallies = pd.DataFrame(data, columns=columns) return all_tallies
def _add_plots(self): H = c.struct_HighestExtent - c.struct_LowestExtent res = 1000 # BPRA positions plot = openmc.Plot() plot.filename = 'bpra_positions' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [0, 0, H / 2] plot.width = [c.rpvOR * 2, c.rpvOR * 2] plot.pixels = [res, res] plot.mask_components = [self.mats['Borosilicate Glass']] self.plots.append(plot) plot = openmc.Plot() plot.filename = 'radial_cells_midplane' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [0, 0, H / 2] plot.width = [c.rpvOR * 2, c.rpvOR * 2] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'radial_mats_midplane' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [0, 0, H / 2] plot.width = [c.rpvOR * 2, c.rpvOR * 2] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'radial_mats_grid1_center' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [0, 0, c.grid1_bot + (c.grid1_top - c.grid1_bot) / 2] plot.width = [c.rpvOR * 2, c.rpvOR * 2] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'radial_mats_grid4_center' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [0, 0, c.grid4_bot + (c.grid4_top - c.grid4_bot) / 2] plot.width = [c.rpvOR * 2, c.rpvOR * 2] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'axial_mats_row_8' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, 0, H / 2] plot.width = [H, H] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'axial_mats_row_8_topzoom' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, 0, H / 2 + H / 4] plot.width = [H / 2, H / 2] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'axial_mats_row_8_topzoom2' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, 0, H / 2 + H / 3] plot.width = [H / 4, H / 4] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'axial_mats_row_8_topzoom3' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, 0, c.fuel_Rod_top] plot.width = [H / 8, H / 8] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'axial_mats_row_8_botzoom' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, 0, H / 2 - H / 4] plot.width = [H / 2, H / 2] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'axial_mats_row_8_botzoom2' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, 0, H / 2 - H / 3] plot.width = [H / 4, H / 4] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'axial_mats_row_8_botzoom3' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, 0, c.fuel_Rod_bot] plot.width = [H / 8, H / 8] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'grid5_mats_H7' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [ 0, c.latticePitch, c.grid5_bot + (c.grid5_top - c.grid5_bot) / 2 ] plot.width = [c.latticePitch, c.latticePitch] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'grid8_mats_J14' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [-c.latticePitch+c.latticePitch/3, \ -6*c.latticePitch+c.latticePitch/3, \ c.grid8_bot+(c.grid8_top-c.grid8_bot)/2] plot.width = [c.latticePitch, c.latticePitch] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'grid5_mats_J14' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [-c.latticePitch+c.latticePitch/3, \ -6*c.latticePitch+c.latticePitch/3, \ c.grid5_bot+(c.grid5_top-c.grid5_bot)/2] plot.width = [c.latticePitch, c.latticePitch] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'midplane_mats_J14' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [-c.latticePitch+c.latticePitch/3, \ -6*c.latticePitch+c.latticePitch/3, H/2] plot.width = [c.latticePitch, c.latticePitch] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) h = 4 * (c.struct_LowerNozzle_top - c.struct_SupportPlate_bot) / c.latticePitch plot = openmc.Plot() plot.filename = 'J8_axial_bot' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, c.latticePitch, c.struct_LowerNozzle_top] plot.width = [c.latticePitch, h] plot.pixels = [res, int(res * h)] plot.colors = self.colors_mat self.plots.append(plot) h = 4 * (c.struct_UpperNozzle_top - c.fuel_Rod_top) / c.latticePitch plot = openmc.Plot() plot.filename = 'J8_axial_top' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, c.latticePitch, c.fuel_Rod_top] plot.width = [c.latticePitch, h] plot.pixels = [res, int(res * h)] plot.colors = self.colors_mat self.plots.append(plot) plot = openmc.Plot() plot.filename = 'J8_nozzle' plot.color_by = 'material' plot.basis = 'xy' plot.origin = [0, c.latticePitch, c.struct_SupportPlate_bot + 2.0] plot.width = [c.latticePitch, c.latticePitch] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot) h = 2 * (c.struct_UpperNozzle_top - c.fuel_Rod_top) plot = openmc.Plot() plot.filename = 'H8_axial_top' plot.color_by = 'material' plot.basis = 'xz' plot.origin = [0, c.latticePitch, c.fuel_Rod_top] plot.width = [h, h] plot.pixels = [res, res] plot.colors = self.colors_mat self.plots.append(plot)
#add surfaces here using https://openmc.readthedocs.io/en/stable/usersguide/geometry.html#surfaces-and-regions #example cell cell1 = openmc.Cell(region=volume_sph1) cell1.fill = natural_lead #add another cell here universe = openmc.Universe( cells=[cell1]) #hint, this list will need to include the new cell geom = openmc.Geometry(universe) geom.export_to_xml() p = openmc.Plot() p.basis = 'xz' p.filename = 'plot' p.width = ( 850, 850 ) #hint, this might need to be increased to see the new large geometry p.pixels = (400, 400) p.color_by = 'material' p.colors = {natural_lead: 'blue'} plots = openmc.Plots([p]) plots.export_to_xml() openmc.plot_geometry() os.system('convert plot.ppm plot.png') #os.system('eog plot.png')
def make_model_mg_by_nuclide(nameoflib): nuclist, conc, temp, rodnuclist, concrod, temprod, dzz, hss, rods, type_fuel, type_assembly = make_datas() nkas = len(rods) diction_mg = translate_mg(nkas, rods, dzz, [sum(dzz)], nameoflib, nuclist, conc, rodnuclist, concrod) outuniv, outsurface = _make_outer_mg_universe(diction_mg[(1,1)]) assemblies = {} load_dict = {} hexsurf, rodfaces = make_surfaces([sum(dzz)], HPITCH) hexsurf, zfaces = make_surfaces(dzz, HPITCH) for i in range(NASS): if (rods[i]): assemblies[i+1] = make_abl_mg_cells(diction_mg, hexsurf, rodfaces, i+1, temprod) load_dict[i+1] = [i+1] else: assemblies[i+1] = make_abl_mg_cells(diction_mg, hexsurf, zfaces, i+1, temp) load_dict[i+1] = [i+1] print("Making load ..") ################################################################################## load = make_load("BN-800", outuniv, assemblies, NRING, HPITCH, sum(dzz), load_dict) root_cell = openmc.Cell(cell_id=0, region=-outsurface, fill=load) root_univ = openmc.Universe(universe_id=0, cells = [root_cell]) # Instantiate a Geometry, register the root Universe, and export to XML openmc_geometry = openmc.Geometry() openmc_geometry.root_universe = root_univ openmc_geometry.export_to_xml() materials_list = openmc_geometry.get_all_materials() materials_file = openmc.Materials([v for v in materials_list.values()]) materials_file.cross_sections = nameoflib materials_file.export_to_xml() # Instantiate a Settings object, set all runtime parameters, and export to XML settings_file = openmc.Settings() ##########################SETTINGS settings_file.batches = 120 settings_file.inactive = 20 settings_file.particles = 1000 ########################### settings_file.temperature = {'range':(250,2500)} # Tell OpenMC this is a multi-group problem settings_file.energy_mode = 'multi-group' #settings_file.survival_biasing = True #settings_file.cutoff = {'energy_neutron' : 1.0,'weight':1.e-10} settings_file.source = openmc.Source(space=openmc.stats.Box( [-160.04, -160.04, 0.0], [160.04, 160.04, 170], only_fissionable=True)) settings_file.export_to_xml() plot_1 = openmc.Plot(plot_id=1) plot_1.filename = 'plot_1' plot_1.origin = [0.0, 0.0, 8.] plot_1.width = [520.26, 520.26] plot_1.pixels = [2400, 2400] plot_1.color = 'mat' plot_1.basis = 'xy' plot_2 = openmc.Plot(plot_id=2) plot_2.filename = 'plot_2' plot_2.origin = [0.0, 0.0, 0.0] plot_2.width = [520.26, 350.2] plot_2.pixels = [1200, 1200] plot_2.color = 'mat' plot_2.basis = 'xz'
tallies_file.export_to_xml() settings.export_to_xml() # # Geometry plotting # In[10]: ############################################################################### # Make some plots of the geometry ############################################################################### plot1 = openmc.Plot() plot1.filename = 'materials-xy' plot1.origin = [0, 0, 0] plot1.basis = 'xy' plot1.width = [200.0, 200.0] plot1.pixels = [3000, 3000] plot1.color = "material" plot2 = openmc.Plot() plot2.filename = 'materials-xz' plot2.origin = [0, 0, 0] plot2.basis = 'xz' plot2.width = [200.0, 200.0] plot2.pixels = [1000, 1000] plot2.color = "material"
def make_model_mg(nameoflib): element = name_el(PATH_INOUT_DATA) nuclide = xml_f(PATH_REACTION_XML) print("Start") print(nuclide, element) diction_1, diction_2, diction_3, dzz, hss, rods, densna, type_fuel, type_assembly = run(PATH_INOUT_DATA) print('First point', dzz, hss,rods) nkas = len(rods) diction_mg = translate_mg(nkas, rods, dzz, [sum(dzz)]) outuniv, outsurface = _make_outer_mg_universe(diction_mg[(1,1)]) # assemblies = {} load_dict = {} hexsurf, rodfaces = make_surfaces([sum(dzz)], HPITCH) hexsurf, zfaces = make_surfaces(dzz, HPITCH) for i in range(NASS): if (rods[i]): assemblies[i+1] = make_abl_mg_cells(diction_mg, hexsurf, rodfaces, i+1) load_dict[i+1] = [i+1] else: assemblies[i+1] = make_abl_mg_cells(diction_mg, hexsurf, zfaces, i+1) load_dict[i+1] = [i+1] print("Making load ..") ################################################################################## load = make_load("BN-800", outuniv, assemblies, NRING, HPITCH, sum(dzz), load_dict) root_cell = openmc.Cell(cell_id=0, region=-outsurface, fill=load) root_univ = openmc.Universe(universe_id=0, cells = [root_cell]) # Instantiate a Geometry, register the root Universe, and export to XML openmc_geometry = openmc.Geometry() openmc_geometry.root_universe = root_univ openmc_geometry.export_to_xml() materials_list = openmc_geometry.get_all_materials() materials_file = openmc.Materials([v for v in materials_list.values()]) materials_file.cross_sections = nameoflib materials_file.export_to_xml() # Instantiate a Settings object, set all runtime parameters, and export to XML settings_file = openmc.Settings() ##########################SETTINGS settings_file.batches = 120 settings_file.inactive = 20 settings_file.particles = 1000 ########################### settings_file.temperature = {'range':(250,2500)} # Tell OpenMC this is a multi-group problem settings_file.energy_mode = 'multi-group' settings_file.source = openmc.Source(space=openmc.stats.Box( [-160.04, -160.04, 0.0], [160.04, 160.04, 170], only_fissionable=True)) settings_file.export_to_xml() return openmc plot_1 = openmc.Plot(plot_id=1) plot_1.filename = 'plot_1' plot_1.origin = [0.0, 0.0, 8.] plot_1.width = [520.26, 520.26] plot_1.pixels = [2400, 2400] plot_1.color = 'mat' plot_1.basis = 'xy' plot_2 = openmc.Plot(plot_id=2) plot_2.filename = 'plot_2' plot_2.origin = [0.0, 0.0, 0.0] plot_2.width = [520.26, 350.2] plot_2.pixels = [1200, 1200] plot_2.color = 'mat' plot_2.basis = 'xz' # Instantiate a Plots collection and export to XML plot_file = openmc.Plots([plot_1, plot_2])
def _build_inputs(self): #################### # Materials #################### moderator = openmc.Material(material_id=1) moderator.set_density('g/cc', 1.0) moderator.add_nuclide('H1', 2.0) moderator.add_nuclide('O16', 1.0) dense_fuel = openmc.Material(material_id=2) dense_fuel.set_density('g/cc', 4.5) dense_fuel.add_nuclide('U235', 1.0) light_fuel = openmc.Material(material_id=3) light_fuel.set_density('g/cc', 2.0) light_fuel.add_nuclide('U235', 1.0) mats_file = openmc.Materials([moderator, dense_fuel, light_fuel]) mats_file.export_to_xml() #################### # Geometry #################### c1 = openmc.Cell(cell_id=1, fill=moderator) mod_univ = openmc.Universe(universe_id=1, cells=[c1]) r0 = openmc.ZCylinder(r=0.3) c11 = openmc.Cell(cell_id=11, region=-r0) c11.fill = [dense_fuel, None, light_fuel, dense_fuel] c12 = openmc.Cell(cell_id=12, region=+r0, fill=moderator) fuel_univ = openmc.Universe(universe_id=11, cells=[c11, c12]) lat = openmc.RectLattice(lattice_id=101) lat.lower_left = [-2.0, -2.0] lat.pitch = [2.0, 2.0] lat.universes = [[fuel_univ]*2]*2 lat.outer = mod_univ x0 = openmc.XPlane(x0=-3.0) x1 = openmc.XPlane(x0=3.0) y0 = openmc.YPlane(y0=-3.0) y1 = openmc.YPlane(y0=3.0) for s in [x0, x1, y0, y1]: s.boundary_type = 'reflective' c101 = openmc.Cell(cell_id=101, fill=lat) c101.region = +x0 & -x1 & +y0 & -y1 root_univ = openmc.Universe(universe_id=0, cells=[c101]) geometry = openmc.Geometry(root_univ) geometry.export_to_xml() #################### # Settings #################### sets_file = openmc.Settings() sets_file.batches = 5 sets_file.inactive = 0 sets_file.particles = 1000 sets_file.source = openmc.Source(space=openmc.stats.Box( [-1, -1, -1], [1, 1, 1])) sets_file.export_to_xml() #################### # Plots #################### plot1 = openmc.Plot(plot_id=1) plot1.basis = 'xy' plot1.color_by = 'cell' plot1.filename = 'cellplot' plot1.origin = (0, 0, 0) plot1.width = (7, 7) plot1.pixels = (400, 400) plot2 = openmc.Plot(plot_id=2) plot2.basis = 'xy' plot2.color_by = 'material' plot2.filename = 'matplot' plot2.origin = (0, 0, 0) plot2.width = (7, 7) plot2.pixels = (400, 400) plots = openmc.Plots([plot1, plot2]) plots.export_to_xml()
def initial(self, opt, Mesh): #, nthreads): ##################################### # Create OpenMC geometry ##################################### FuelOR = opt.FuelOR * 100 #[cm] CladIR = opt.CladIR * 100 #[cm] CladOR = opt.CladOR * 100 #[cm] # ExtraCladOR = opt.ExtraCladOR*100 #[cm] Pitch = opt.PinPitch * 100 #[cm] # Construct uniform initial source distribution over fissionable zones lower_left = [-Pitch / 2, -Pitch / 2, 0] upper_right = [+Pitch / 2, +Pitch / 2, +365.76] uniform_dist = openmc.stats.Box(lower_left, upper_right, only_fissionable=True) # Settings file self.settings_file = openmc.Settings() self.settings_file.batches = 1100 self.settings_file.inactive = 100 self.settings_file.particles = 20000 self.settings_file.generations_per_batch = 5 self.settings_file.output = {'tallies': False} self.settings_file.temperature = {'multipole': True, 'tolerance': 3000} self.settings_file.source = openmc.source.Source(space=uniform_dist) self.settings_file.seed = np.random.randint(1, 100) # for correlation self.settings_file.export_to_xml() #Removed for correlation # Materials file uo2 = openmc.Material(material_id=1, name='UO2 fuel at 2.4% wt enrichment') uo2.temperature = 900. #opt.Tin uo2.set_density('g/cm3', 10.29769) uo2.add_element('U', 1., enrichment=2.4) uo2.add_element('O', 2.) # helium = openmc.Material(material_id=2, name='Helium for gap') # helium.temperature = opt.Tin # helium.set_density('g/cm3', 0.001598) # helium.add_element('He', 2.4044e-4) zircaloy = openmc.Material(material_id=3, name='Zircaloy 4') zircaloy.temperature = opt.Tin zircaloy.set_density('g/cm3', 6.55) zircaloy.add_element('Sn', 0.014, 'wo') zircaloy.add_element('Fe', 0.00165, 'wo') zircaloy.add_element('Cr', 0.001, 'wo') zircaloy.add_element('Zr', 0.98335, 'wo') # borated_water = openmc.Material() # borated_water.temperature = opt.Tin # borated_water.set_density('g/cm3', 0.7406) # borated_water.add_element('B', 4.0e-5) # borated_water.add_element('H', 5.0e-2) # borated_water.add_element('O', 2.4e-2) # borated_water.add_s_alpha_beta('c_H_in_H2O') borated_water = openmc.model.borated_water(boron_ppm=432.473, temperature=opt.Tin, pressure=15) self.materials_file = openmc.Materials([uo2, zircaloy, borated_water]) #helium self.materials_file.export_to_xml() #Removed for correlation # Geometry file fuel_or = openmc.ZCylinder(x0=0, y0=0, R=FuelOR) # clad_ir = openmc.ZCylinder(x0=0, y0=0, R=CladIR) clad_or = openmc.ZCylinder(x0=0, y0=0, R=CladOR) # extra_clad_or = openmc.ZCylinder(x0=0, y0=0, R=ExtraCladOR) left = openmc.XPlane(x0=-Pitch / 2) right = openmc.XPlane(x0=Pitch / 2) back = openmc.YPlane(y0=-Pitch / 2) front = openmc.YPlane(y0=Pitch / 2) top = openmc.ZPlane(z0=396.24) bottom = openmc.ZPlane(z0=-30.48) z_list = [] for i in range(0, len(Mesh)): z_list.append(openmc.ZPlane(z0=Mesh[i])) left.boundary_type = 'reflective' right.boundary_type = 'reflective' front.boundary_type = 'reflective' back.boundary_type = 'reflective' top.boundary_type = 'vacuum' bottom.boundary_type = 'vacuum' # z_list[-1].boundary_type = 'vacuum' # z_list[0].boundary_type = 'vacuum' self.reflectTOP = openmc.Cell() self.reflectBOT = openmc.Cell() self.fuel_list = [] # self.gap_list = [] self.clad_list = [] # self.extra_clad_list = [] self.water_list = [] for i in range(0, len(Mesh) - 1): self.fuel_list.append(openmc.Cell()) # self.gap_list.append(openmc.Cell()) self.clad_list.append(openmc.Cell()) # self.extra_clad_list.append(openmc.Cell()) self.water_list.append(openmc.Cell()) self.reflectTOP.region = +left & -right & +back & -front & +z_list[ -1] & -top self.reflectBOT.region = +left & -right & +back & -front & +bottom & -z_list[ 0] self.reflectTOP.fill = borated_water self.reflectBOT.fill = borated_water j = 0 for fuels in self.fuel_list: fuels.region = -fuel_or & +z_list[j] & -z_list[j + 1] fuels.fill = uo2 j = j + 1 # j = 0 # for gaps in self.gap_list: # gaps.region = +fuel_or & -clad_ir & +z_list[j] & -z_list[j+1] # gaps.fill = helium # j = j+1 j = 0 for clads in self.clad_list: clads.region = +fuel_or & -clad_or & +z_list[j] & -z_list[ j + 1] #clad_ir instead of fuel_or clads.fill = zircaloy j = j + 1 # j = 0 # for extra_clads in self.extra_clad_list: # extra_clads.region = +clad_or & -extra_clad_or & +left & -right & +back & -front & +z_list[j] & -z_list[j+1] # grid_flag = 0 # for i in range(0,len(opt.GridBot_z)): # if z_list[j].z0 == opt.GridBot_z[i]: # extra_clads.fill = zircaloy # grid_flag = 1 # if grid_flag == 1: # extra_clads.fill = zircaloy # else: # extra_clads.fill = borated_water # extra_clads.fill = borated_water # j = j+1 j = 0 for waters in self.water_list: waters.region = +clad_or & +left & -right & +back & -front & +z_list[ j] & -z_list[j + 1] waters.fill = borated_water j = j + 1 self.root = openmc.Universe(universe_id=0, name='root universe') self.root.add_cells(self.fuel_list) # self.root.add_cells(self.gap_list) self.root.add_cells(self.clad_list) # self.root.add_cells(self.extra_clad_list) self.root.add_cells(self.water_list) self.root.add_cells([self.reflectTOP, self.reflectBOT]) self.geometry_file = openmc.Geometry(self.root) self.geometry_file.export_to_xml() #Removed for correlation # Tallies # power distribution: fission q recoverable (Sterling's note: starts 0, might be data pb) # openmc accounts for incoming neutron energy and isotope cell_filter = openmc.CellFilter(self.fuel_list) t = openmc.Tally(tally_id=1) t.filters.append(cell_filter) t.scores = ['fission-q-recoverable'] tallies = openmc.Tallies([t]) tallies.export_to_xml() #Removed for correlation # Plots plot = openmc.Plot() plot.width = [Pitch + 45, Pitch + 45] plot.origin = [0., 0., -20] plot.color_by = 'material' plot.filename = 'fuel-pin' plot.pixels = [1000, 1000] plot.basis = 'yz' # openmc.plot_inline(plot) # Move Files to PinGeo folder #Removed for correlation shutil.move('settings.xml', 'PinGeo/settings.xml') shutil.move('materials.xml', 'PinGeo/materials.xml') shutil.move('geometry.xml', 'PinGeo/geometry.xml') shutil.move('tallies.xml', 'PinGeo/tallies.xml') # shutil.move('plots.xml', 'PinGeo/plots.xml') openmc.run( cwd='PinGeo') #, threads=nthreads, mpi_args=['mpiexec','-n','2']) sp = openmc.StatePoint('PinGeo/statepoint.' + str(self.settings_file.batches) + '.h5') tally = sp.get_tally(scores=['fission-q-recoverable']) self.Tally = np.ndarray.flatten(tally.sum) Pfactor = 66945.4 / sum(np.ndarray.flatten(tally.sum)) # print("Pfactor: ", Pfactor) self.Tally = np.ndarray.flatten(tally.sum) * Pfactor self.Var = np.divide(np.ndarray.flatten(tally.std_dev), np.ndarray.flatten(tally.mean))
settings.source = openmc.Source(space=openmc.stats.Box([-50.0,-50.0,-50.0], [50.0,50.0,50.0])) ############################################## settings.photon_transport = True ############################################## settings.export_to_xml() geometry.export_to_xml() tallies_file.export_to_xml() p1 = openmc.Plot() p1.filename = 'materials-xy' p1.origin = [0, 0, 0] p1.basis = 'xy' p1.width = [200.0, 200.0] p1.pixels = [3000, 3000] p1.color = "material" #p1.colors = {steel: 'lightsteelblue', fuel_material: 'magenta', shielding: 'black', #clad: 'burlywood', helium: 'limegreen', uo2_2: 'yellow', heavy_water: 'teal', #cold_water: 'lightskyblue', hot_water: 'blue', borated_water: 'cyan'} p2 = openmc.Plot() p2.filename = 'materials-xz' p2.origin = [0, 0, 0] p2.basis = 'xz'
def pwr_assembly(): """Create a PWR assembly model. This model is a reflected 17x17 fuel assembly from the the `BEAVRS <http://crpg.mit.edu/research/beavrs>`_ benchmark. The fuel is 2.4 w/o enriched UO2 corresponding to a beginning-of-cycle condition. Note that the number of particles/batches is initially set very low for testing purposes. Returns ------- model : openmc.model.Model A PWR assembly model """ model = openmc.model.Model() # Define materials. fuel = openmc.Material(name='Fuel') fuel.set_density('g/cm3', 10.29769) fuel.add_nuclide("U234", 4.4843e-6) fuel.add_nuclide("U235", 5.5815e-4) fuel.add_nuclide("U238", 2.2408e-2) fuel.add_nuclide("O16", 4.5829e-2) clad = openmc.Material(name='Cladding') clad.set_density('g/cm3', 6.55) clad.add_nuclide("Zr90", 2.1827e-2) clad.add_nuclide("Zr91", 4.7600e-3) clad.add_nuclide("Zr92", 7.2758e-3) clad.add_nuclide("Zr94", 7.3734e-3) clad.add_nuclide("Zr96", 1.1879e-3) hot_water = openmc.Material(name='Hot borated water') hot_water.set_density('g/cm3', 0.740582) hot_water.add_nuclide("H1", 4.9457e-2) hot_water.add_nuclide("O16", 2.4672e-2) hot_water.add_nuclide("B10", 8.0042e-6) hot_water.add_nuclide("B11", 3.2218e-5) hot_water.add_s_alpha_beta('c_H_in_H2O') # Define the materials file. model.materials = (fuel, clad, hot_water) # Instantiate ZCylinder surfaces fuel_or = openmc.ZCylinder(x0=0, y0=0, R=0.39218, name='Fuel OR') clad_or = openmc.ZCylinder(x0=0, y0=0, R=0.45720, name='Clad OR') # Create boundary planes to surround the geometry pitch = 21.42 min_x = openmc.XPlane(x0=-pitch/2, boundary_type='reflective') max_x = openmc.XPlane(x0=+pitch/2, boundary_type='reflective') min_y = openmc.YPlane(y0=-pitch/2, boundary_type='reflective') max_y = openmc.YPlane(y0=+pitch/2, boundary_type='reflective') # Create a fuel pin universe fuel_pin_universe = openmc.Universe(name='Fuel Pin') fuel_cell = openmc.Cell(name='fuel', fill=fuel, region=-fuel_or) clad_cell = openmc.Cell(name='clad', fill=clad, region=+fuel_or & -clad_or) hot_water_cell = openmc.Cell(name='hot water', fill=hot_water, region=+clad_or) fuel_pin_universe.add_cells([fuel_cell, clad_cell, hot_water_cell]) # Create a control rod guide tube universe guide_tube_universe = openmc.Universe(name='Guide Tube') gt_inner_cell = openmc.Cell(name='guide tube inner water', fill=hot_water, region=-fuel_or) gt_clad_cell = openmc.Cell(name='guide tube clad', fill=clad, region=+fuel_or & -clad_or) gt_outer_cell = openmc.Cell(name='guide tube outer water', fill=hot_water, region=+clad_or) guide_tube_universe.add_cells([gt_inner_cell, gt_clad_cell, gt_outer_cell]) # Create fuel assembly Lattice assembly = openmc.RectLattice(name='Fuel Assembly') assembly.pitch = (pitch/17, pitch/17) assembly.lower_left = (-pitch/2, -pitch/2) # Create array indices for guide tube locations in lattice template_x = np.array([5, 8, 11, 3, 13, 2, 5, 8, 11, 14, 2, 5, 8, 11, 14, 2, 5, 8, 11, 14, 3, 13, 5, 8, 11]) template_y = np.array([2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11, 13, 13, 14, 14, 14]) # Create 17x17 array of universes assembly.universes = np.tile(fuel_pin_universe, (17, 17)) assembly.universes[template_x, template_y] = guide_tube_universe # Create root Cell root_cell = openmc.Cell(name='root cell', fill=assembly) root_cell.region = +min_x & -max_x & +min_y & -max_y # Create root Universe model.geometry.root_universe = openmc.Universe(name='root universe') model.geometry.root_universe.add_cell(root_cell) model.settings.batches = 10 model.settings.inactive = 5 model.settings.particles = 100 model.settings.source = openmc.Source(space=openmc.stats.Box( [-pitch/2, -pitch/2, -1], [pitch/2, pitch/2, 1], only_fissionable=True)) plot = openmc.Plot() plot.origin = (0.0, 0.0, 0) plot.width = (21.42, 21.42) plot.pixels = (300, 300) plot.color_by = 'material' model.plots.append(plot) return model
breeder_blanket_region = +first_wall_outer_surface & -breeder_blanket_outer_surface & +central_shield_outer_surface breeder_blanket_cell = openmc.Cell(region=breeder_blanket_region) breeder_blanket_cell.fill = breeder_material universe = openmc.Universe(cells=[ central_sol_cell, central_shield_cell, first_wall_cell, breeder_blanket_cell ]) geom = openmc.Geometry(universe) geom.export_to_xml() # makes the 3d "cube" style geometry vox_plot = openmc.Plot() vox_plot.type = 'voxel' vox_plot.width = (1500., 1500., 1500.) vox_plot.pixels = (200, 200, 200) vox_plot.filename = 'plot_3d_tokamak' vox_plot.color_by = 'material' #vox_plot.colors = {copper: 'blue'} # materials can be coloured using this command plots = openmc.Plots([vox_plot]) plots.export_to_xml() openmc.plot_geometry() # this converts the h5 file to a vti os.system('openmc-voxel-to-vtk plot_3d_tokamak.h5 -o plot_3d_tokamak.vti') os.system('paraview plot_3d_tokamak.vti') # or visit might work better
def slab_mg(reps=None, as_macro=True): """Create a one-group, 1D slab model. Parameters ---------- reps : list, optional List of angular representations. Each item corresponds to materials and dictates the angular representation of the multi-group cross sections---isotropic ('iso') or angle-dependent ('ang'), and if Legendre scattering or tabular scattering ('mu') is used. Thus, items can be 'ang', 'ang_mu', 'iso', or 'iso_mu'. as_macro : bool, optional Whether :class:`openmc.Macroscopic` is used Returns ------- model : openmc.model.Model One-group, 1D slab model """ model = openmc.model.Model() # Define materials needed for 1D/1G slab problem mat_names = ['uo2', 'clad', 'lwtr'] mgxs_reps = ['ang', 'ang_mu', 'iso', 'iso_mu'] if reps is None: reps = mgxs_reps xs = [] i = 0 for mat in mat_names: for rep in reps: i += 1 name = mat + '_' + rep xs.append(name) if as_macro: m = openmc.Material(name=str(i)) m.set_density('macro', 1.) m.add_macroscopic(name) else: m = openmc.Material(name=str(i)) m.set_density('atom/b-cm', 1.) m.add_nuclide(name, 1.0, 'ao') model.materials.append(m) # Define the materials file model.xs_data = xs model.materials.cross_sections = "../1d_mgxs.h5" # Define surfaces. # Assembly/Problem Boundary left = openmc.XPlane(x0=0.0, boundary_type='reflective') right = openmc.XPlane(x0=10.0, boundary_type='reflective') bottom = openmc.YPlane(y0=0.0, boundary_type='reflective') top = openmc.YPlane(y0=10.0, boundary_type='reflective') # for each material add a plane planes = [openmc.ZPlane(z0=0.0, boundary_type='reflective')] dz = round(5. / float(len(model.materials)), 4) for i in range(len(model.materials) - 1): planes.append(openmc.ZPlane(z0=dz * float(i + 1))) planes.append(openmc.ZPlane(z0=5.0, boundary_type='reflective')) # Define cells for each material model.geometry.root_universe = openmc.Universe(name='root universe') xy = +left & -right & +bottom & -top for i, mat in enumerate(model.materials): c = openmc.Cell(fill=mat, region=xy & +planes[i] & -planes[i + 1]) model.geometry.root_universe.add_cell(c) model.settings.batches = 10 model.settings.inactive = 5 model.settings.particles = 100 model.settings.source = openmc.Source(space=openmc.stats.Box( [0.0, 0.0, 0.0], [10.0, 10.0, 5.])) model.settings.energy_mode = "multi-group" plot = openmc.Plot() plot.filename = 'mat' plot.origin = (5.0, 5.0, 2.5) plot.width = (2.5, 2.5) plot.basis = 'xz' plot.pixels = (3000, 3000) plot.color_by = 'material' model.plots.append(plot) return model
settings_file.resonance_scattering = {'enable': False, 'method': 'dbrc'} # Create an initial uniform spatial source distribution over fissionable zones bounds = [-0.6300, -0.6300, -1, 0.6300, 0.6300, 1] uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True) settings_file.source = openmc.source.Source(space=uniform_dist) entropy_mesh = openmc.RegularMesh() entropy_mesh.lower_left = [-0.4096, -0.4096, -1.e50] entropy_mesh.upper_right = [0.4096, 0.4096, 1.e50] entropy_mesh.dimension = [10, 10, 1] settings_file.entropy_mesh = entropy_mesh settings_file.export_to_xml() # plot setting plot = openmc.Plot(plot_id=1) plot.origin = [0, 0, 0] plot.width = [1.26, 1.26] plot.pixels = [500, 500] plot.color_by = 'material' # Instantiate a Plots object and export to XML plot_file = openmc.Plots([plot]) plot_file.export_to_xml() ############################################################################### # Set volumes of depletable materials ############################################################################### # Compute cell areas area = {} #area[fuel] = np.pi * fuel_or.coefficients['r'] ** 2
def pwr_core(): """Create a PWR full-core model. This model is the OECD/NEA Monte Carlo Performance benchmark which is a grossly simplified pressurized water reactor (PWR) with 241 fuel assemblies. Note that the number of particles/batches is initially set very low for testing purposes. Returns ------- model : openmc.model.Model Full-core PWR model """ model = openmc.model.Model() # Define materials. fuel = openmc.Material(1, name='UOX fuel') fuel.set_density('g/cm3', 10.062) fuel.add_nuclide("U234", 4.9476e-6) fuel.add_nuclide("U235", 4.8218e-4) fuel.add_nuclide("U238", 2.1504e-2) fuel.add_nuclide("Xe135", 1.0801e-8) fuel.add_nuclide("O16", 4.5737e-2) clad = openmc.Material(2, name='Zircaloy') clad.set_density('g/cm3', 5.77) clad.add_nuclide("Zr90", 0.5145) clad.add_nuclide("Zr91", 0.1122) clad.add_nuclide("Zr92", 0.1715) clad.add_nuclide("Zr94", 0.1738) clad.add_nuclide("Zr96", 0.0280) cold_water = openmc.Material(3, name='Cold borated water') cold_water.set_density('atom/b-cm', 0.07416) cold_water.add_nuclide("H1", 2.0) cold_water.add_nuclide("O16", 1.0) cold_water.add_nuclide("B10", 6.490e-4) cold_water.add_nuclide("B11", 2.689e-3) cold_water.add_s_alpha_beta('c_H_in_H2O') hot_water = openmc.Material(4, name='Hot borated water') hot_water.set_density('atom/b-cm', 0.06614) hot_water.add_nuclide("H1", 2.0) hot_water.add_nuclide("O16", 1.0) hot_water.add_nuclide("B10", 6.490e-4) hot_water.add_nuclide("B11", 2.689e-3) hot_water.add_s_alpha_beta('c_H_in_H2O') rpv_steel = openmc.Material(5, name='Reactor pressure vessel steel') rpv_steel.set_density('g/cm3', 7.9) rpv_steel.add_nuclide("Fe54", 0.05437098, 'wo') rpv_steel.add_nuclide("Fe56", 0.88500663, 'wo') rpv_steel.add_nuclide("Fe57", 0.0208008, 'wo') rpv_steel.add_nuclide("Fe58", 0.00282159, 'wo') rpv_steel.add_nuclide("Ni58", 0.0067198, 'wo') rpv_steel.add_nuclide("Ni60", 0.0026776, 'wo') rpv_steel.add_nuclide("Mn55", 0.01, 'wo') rpv_steel.add_nuclide("Cr52", 0.002092475, 'wo') rpv_steel.add_nuclide("C0", 0.0025, 'wo') rpv_steel.add_nuclide("Cu63", 0.0013696, 'wo') lower_rad_ref = openmc.Material(6, name='Lower radial reflector') lower_rad_ref.set_density('g/cm3', 4.32) lower_rad_ref.add_nuclide("H1", 0.0095661, 'wo') lower_rad_ref.add_nuclide("O16", 0.0759107, 'wo') lower_rad_ref.add_nuclide("B10", 3.08409e-5, 'wo') lower_rad_ref.add_nuclide("B11", 1.40499e-4, 'wo') lower_rad_ref.add_nuclide("Fe54", 0.035620772088, 'wo') lower_rad_ref.add_nuclide("Fe56", 0.579805982228, 'wo') lower_rad_ref.add_nuclide("Fe57", 0.01362750048, 'wo') lower_rad_ref.add_nuclide("Fe58", 0.001848545204, 'wo') lower_rad_ref.add_nuclide("Ni58", 0.055298376566, 'wo') lower_rad_ref.add_nuclide("Mn55", 0.0182870, 'wo') lower_rad_ref.add_nuclide("Cr52", 0.145407678031, 'wo') lower_rad_ref.add_s_alpha_beta('c_H_in_H2O') upper_rad_ref = openmc.Material(7, name='Upper radial reflector / Top plate region') upper_rad_ref.set_density('g/cm3', 4.28) upper_rad_ref.add_nuclide("H1", 0.0086117, 'wo') upper_rad_ref.add_nuclide("O16", 0.0683369, 'wo') upper_rad_ref.add_nuclide("B10", 2.77638e-5, 'wo') upper_rad_ref.add_nuclide("B11", 1.26481e-4, 'wo') upper_rad_ref.add_nuclide("Fe54", 0.035953677186, 'wo') upper_rad_ref.add_nuclide("Fe56", 0.585224740891, 'wo') upper_rad_ref.add_nuclide("Fe57", 0.01375486056, 'wo') upper_rad_ref.add_nuclide("Fe58", 0.001865821363, 'wo') upper_rad_ref.add_nuclide("Ni58", 0.055815129186, 'wo') upper_rad_ref.add_nuclide("Mn55", 0.0184579, 'wo') upper_rad_ref.add_nuclide("Cr52", 0.146766614995, 'wo') upper_rad_ref.add_s_alpha_beta('c_H_in_H2O') bot_plate = openmc.Material(8, name='Bottom plate region') bot_plate.set_density('g/cm3', 7.184) bot_plate.add_nuclide("H1", 0.0011505, 'wo') bot_plate.add_nuclide("O16", 0.0091296, 'wo') bot_plate.add_nuclide("B10", 3.70915e-6, 'wo') bot_plate.add_nuclide("B11", 1.68974e-5, 'wo') bot_plate.add_nuclide("Fe54", 0.03855611055, 'wo') bot_plate.add_nuclide("Fe56", 0.627585036425, 'wo') bot_plate.add_nuclide("Fe57", 0.014750478, 'wo') bot_plate.add_nuclide("Fe58", 0.002000875025, 'wo') bot_plate.add_nuclide("Ni58", 0.059855207342, 'wo') bot_plate.add_nuclide("Mn55", 0.0197940, 'wo') bot_plate.add_nuclide("Cr52", 0.157390026871, 'wo') bot_plate.add_s_alpha_beta('c_H_in_H2O') bot_nozzle = openmc.Material(9, name='Bottom nozzle region') bot_nozzle.set_density('g/cm3', 2.53) bot_nozzle.add_nuclide("H1", 0.0245014, 'wo') bot_nozzle.add_nuclide("O16", 0.1944274, 'wo') bot_nozzle.add_nuclide("B10", 7.89917e-5, 'wo') bot_nozzle.add_nuclide("B11", 3.59854e-4, 'wo') bot_nozzle.add_nuclide("Fe54", 0.030411411144, 'wo') bot_nozzle.add_nuclide("Fe56", 0.495012237964, 'wo') bot_nozzle.add_nuclide("Fe57", 0.01163454624, 'wo') bot_nozzle.add_nuclide("Fe58", 0.001578204652, 'wo') bot_nozzle.add_nuclide("Ni58", 0.047211231662, 'wo') bot_nozzle.add_nuclide("Mn55", 0.0156126, 'wo') bot_nozzle.add_nuclide("Cr52", 0.124142524198, 'wo') bot_nozzle.add_s_alpha_beta('c_H_in_H2O') top_nozzle = openmc.Material(10, name='Top nozzle region') top_nozzle.set_density('g/cm3', 1.746) top_nozzle.add_nuclide("H1", 0.0358870, 'wo') top_nozzle.add_nuclide("O16", 0.2847761, 'wo') top_nozzle.add_nuclide("B10", 1.15699e-4, 'wo') top_nozzle.add_nuclide("B11", 5.27075e-4, 'wo') top_nozzle.add_nuclide("Fe54", 0.02644016154, 'wo') top_nozzle.add_nuclide("Fe56", 0.43037146399, 'wo') top_nozzle.add_nuclide("Fe57", 0.0101152584, 'wo') top_nozzle.add_nuclide("Fe58", 0.00137211607, 'wo') top_nozzle.add_nuclide("Ni58", 0.04104621835, 'wo') top_nozzle.add_nuclide("Mn55", 0.0135739, 'wo') top_nozzle.add_nuclide("Cr52", 0.107931450781, 'wo') top_nozzle.add_s_alpha_beta('c_H_in_H2O') top_fa = openmc.Material(11, name='Top of fuel assemblies') top_fa.set_density('g/cm3', 3.044) top_fa.add_nuclide("H1", 0.0162913, 'wo') top_fa.add_nuclide("O16", 0.1292776, 'wo') top_fa.add_nuclide("B10", 5.25228e-5, 'wo') top_fa.add_nuclide("B11", 2.39272e-4, 'wo') top_fa.add_nuclide("Zr90", 0.43313403903, 'wo') top_fa.add_nuclide("Zr91", 0.09549277374, 'wo') top_fa.add_nuclide("Zr92", 0.14759527104, 'wo') top_fa.add_nuclide("Zr94", 0.15280552077, 'wo') top_fa.add_nuclide("Zr96", 0.02511169542, 'wo') top_fa.add_s_alpha_beta('c_H_in_H2O') bot_fa = openmc.Material(12, name='Bottom of fuel assemblies') bot_fa.set_density('g/cm3', 1.762) bot_fa.add_nuclide("H1", 0.0292856, 'wo') bot_fa.add_nuclide("O16", 0.2323919, 'wo') bot_fa.add_nuclide("B10", 9.44159e-5, 'wo') bot_fa.add_nuclide("B11", 4.30120e-4, 'wo') bot_fa.add_nuclide("Zr90", 0.3741373658, 'wo') bot_fa.add_nuclide("Zr91", 0.0824858164, 'wo') bot_fa.add_nuclide("Zr92", 0.1274914944, 'wo') bot_fa.add_nuclide("Zr94", 0.1319920622, 'wo') bot_fa.add_nuclide("Zr96", 0.0216912612, 'wo') bot_fa.add_s_alpha_beta('c_H_in_H2O') # Define the materials file. model.materials = (fuel, clad, cold_water, hot_water, rpv_steel, lower_rad_ref, upper_rad_ref, bot_plate, bot_nozzle, top_nozzle, top_fa, bot_fa) # Define surfaces. s1 = openmc.ZCylinder(R=0.41, surface_id=1) s2 = openmc.ZCylinder(R=0.475, surface_id=2) s3 = openmc.ZCylinder(R=0.56, surface_id=3) s4 = openmc.ZCylinder(R=0.62, surface_id=4) s5 = openmc.ZCylinder(R=187.6, surface_id=5) s6 = openmc.ZCylinder(R=209.0, surface_id=6) s7 = openmc.ZCylinder(R=229.0, surface_id=7) s8 = openmc.ZCylinder(R=249.0, surface_id=8, boundary_type='vacuum') s31 = openmc.ZPlane(z0=-229.0, surface_id=31, boundary_type='vacuum') s32 = openmc.ZPlane(z0=-199.0, surface_id=32) s33 = openmc.ZPlane(z0=-193.0, surface_id=33) s34 = openmc.ZPlane(z0=-183.0, surface_id=34) s35 = openmc.ZPlane(z0=0.0, surface_id=35) s36 = openmc.ZPlane(z0=183.0, surface_id=36) s37 = openmc.ZPlane(z0=203.0, surface_id=37) s38 = openmc.ZPlane(z0=215.0, surface_id=38) s39 = openmc.ZPlane(z0=223.0, surface_id=39, boundary_type='vacuum') # Define pin cells. fuel_cold = openmc.Universe(name='Fuel pin, cladding, cold water', universe_id=1) c21 = openmc.Cell(cell_id=21, fill=fuel, region=-s1) c22 = openmc.Cell(cell_id=22, fill=clad, region=+s1 & -s2) c23 = openmc.Cell(cell_id=23, fill=cold_water, region=+s2) fuel_cold.add_cells((c21, c22, c23)) tube_cold = openmc.Universe(name='Instrumentation guide tube, ' 'cold water', universe_id=2) c24 = openmc.Cell(cell_id=24, fill=cold_water, region=-s3) c25 = openmc.Cell(cell_id=25, fill=clad, region=+s3 & -s4) c26 = openmc.Cell(cell_id=26, fill=cold_water, region=+s4) tube_cold.add_cells((c24, c25, c26)) fuel_hot = openmc.Universe(name='Fuel pin, cladding, hot water', universe_id=3) c27 = openmc.Cell(cell_id=27, fill=fuel, region=-s1) c28 = openmc.Cell(cell_id=28, fill=clad, region=+s1 & -s2) c29 = openmc.Cell(cell_id=29, fill=hot_water, region=+s2) fuel_hot.add_cells((c27, c28, c29)) tube_hot = openmc.Universe(name='Instrumentation guide tube, hot water', universe_id=4) c30 = openmc.Cell(cell_id=30, fill=hot_water, region=-s3) c31 = openmc.Cell(cell_id=31, fill=clad, region=+s3 & -s4) c32 = openmc.Cell(cell_id=32, fill=hot_water, region=+s4) tube_hot.add_cells((c30, c31, c32)) # Set positions occupied by guide tubes tube_x = np.array([5, 8, 11, 3, 13, 2, 5, 8, 11, 14, 2, 5, 8, 11, 14, 2, 5, 8, 11, 14, 3, 13, 5, 8, 11]) tube_y = np.array([2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11, 13, 13, 14, 14, 14]) # Define fuel lattices. l100 = openmc.RectLattice(name='Fuel assembly (lower half)', lattice_id=100) l100.lower_left = (-10.71, -10.71) l100.pitch = (1.26, 1.26) l100.universes = np.tile(fuel_cold, (17, 17)) l100.universes[tube_x, tube_y] = tube_cold l101 = openmc.RectLattice(name='Fuel assembly (upper half)', lattice_id=101) l101.lower_left = (-10.71, -10.71) l101.pitch = (1.26, 1.26) l101.universes = np.tile(fuel_hot, (17, 17)) l101.universes[tube_x, tube_y] = tube_hot # Define assemblies. fa_cw = openmc.Universe(name='Water assembly (cold)', universe_id=5) c50 = openmc.Cell(cell_id=50, fill=cold_water, region=+s34 & -s35) fa_cw.add_cell(c50) fa_hw = openmc.Universe(name='Water assembly (hot)', universe_id=7) c70 = openmc.Cell(cell_id=70, fill=hot_water, region=+s35 & -s36) fa_hw.add_cell(c70) fa_cold = openmc.Universe(name='Fuel assembly (cold)', universe_id=6) c60 = openmc.Cell(cell_id=60, fill=l100, region=+s34 & -s35) fa_cold.add_cell(c60) fa_hot = openmc.Universe(name='Fuel assembly (hot)', universe_id=8) c80 = openmc.Cell(cell_id=80, fill=l101, region=+s35 & -s36) fa_hot.add_cell(c80) # Define core lattices l200 = openmc.RectLattice(name='Core lattice (lower half)', lattice_id=200) l200.lower_left = (-224.91, -224.91) l200.pitch = (21.42, 21.42) l200.universes = [ [fa_cw]*21, [fa_cw]*21, [fa_cw]*7 + [fa_cold]*7 + [fa_cw]*7, [fa_cw]*5 + [fa_cold]*11 + [fa_cw]*5, [fa_cw]*4 + [fa_cold]*13 + [fa_cw]*4, [fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3, [fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3, [fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2, [fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2, [fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2, [fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2, [fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2, [fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2, [fa_cw]*2 + [fa_cold]*17 + [fa_cw]*2, [fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3, [fa_cw]*3 + [fa_cold]*15 + [fa_cw]*3, [fa_cw]*4 + [fa_cold]*13 + [fa_cw]*4, [fa_cw]*5 + [fa_cold]*11 + [fa_cw]*5, [fa_cw]*7 + [fa_cold]*7 + [fa_cw]*7, [fa_cw]*21, [fa_cw]*21] l201 = openmc.RectLattice(name='Core lattice (lower half)', lattice_id=201) l201.lower_left = (-224.91, -224.91) l201.pitch = (21.42, 21.42) l201.universes = [ [fa_hw]*21, [fa_hw]*21, [fa_hw]*7 + [fa_hot]*7 + [fa_hw]*7, [fa_hw]*5 + [fa_hot]*11 + [fa_hw]*5, [fa_hw]*4 + [fa_hot]*13 + [fa_hw]*4, [fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3, [fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3, [fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2, [fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2, [fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2, [fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2, [fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2, [fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2, [fa_hw]*2 + [fa_hot]*17 + [fa_hw]*2, [fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3, [fa_hw]*3 + [fa_hot]*15 + [fa_hw]*3, [fa_hw]*4 + [fa_hot]*13 + [fa_hw]*4, [fa_hw]*5 + [fa_hot]*11 + [fa_hw]*5, [fa_hw]*7 + [fa_hot]*7 + [fa_hw]*7, [fa_hw]*21, [fa_hw]*21] # Define root universe. root = openmc.Universe(universe_id=0, name='root universe') c1 = openmc.Cell(cell_id=1, fill=l200, region=-s6 & +s34 & -s35) c2 = openmc.Cell(cell_id=2, fill=l201, region=-s6 & +s35 & -s36) c3 = openmc.Cell(cell_id=3, fill=bot_plate, region=-s7 & +s31 & -s32) c4 = openmc.Cell(cell_id=4, fill=bot_nozzle, region=-s5 & +s32 & -s33) c5 = openmc.Cell(cell_id=5, fill=bot_fa, region=-s5 & +s33 & -s34) c6 = openmc.Cell(cell_id=6, fill=top_fa, region=-s5 & +s36 & -s37) c7 = openmc.Cell(cell_id=7, fill=top_nozzle, region=-s5 & +s37 & -s38) c8 = openmc.Cell(cell_id=8, fill=upper_rad_ref, region=-s7 & +s38 & -s39) c9 = openmc.Cell(cell_id=9, fill=bot_nozzle, region=+s6 & -s7 & +s32 & -s38) c10 = openmc.Cell(cell_id=10, fill=rpv_steel, region=+s7 & -s8 & +s31 & -s39) c11 = openmc.Cell(cell_id=11, fill=lower_rad_ref, region=+s5 & -s6 & +s32 & -s34) c12 = openmc.Cell(cell_id=12, fill=upper_rad_ref, region=+s5 & -s6 & +s36 & -s38) root.add_cells((c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12)) # Assign root universe to geometry model.geometry.root_universe = root model.settings.batches = 10 model.settings.inactive = 5 model.settings.particles = 100 model.settings.source = openmc.Source(space=openmc.stats.Box( [-160, -160, -183], [160, 160, 183])) plot = openmc.Plot() plot.origin = (125, 125, 0) plot.width = (250, 250) plot.pixels = (3000, 3000) plot.color_by = 'material' model.plots.append(plot) return model
settings_file.batches = batches settings_file.inactive = inactive settings_file.particles = particles settings_file.output = {'tallies': True, 'summary': True} settings_file.source = openmc.Source(space=openmc.stats.Box( [-32.13, -10.71, -32.13], [10.71, 32.13, 10.71], only_fissionable=True)) settings_file.entropy_lower_left = [-32.13, -32.13, -107.1] settings_file.entropy_upper_right = [32.13, 32.13, 107.1] settings_file.entropy_dimension = [51, 51, 30] settings_file.export_to_xml() ############################################################################### # Exporting to OpenMC plots.xml File ############################################################################### plot_1 = openmc.Plot(plot_id=1) plot_1.filename = 'plot_1' plot_1.origin = [0.0, 0.0, 0.0] plot_1.width = [64.26, 64.26] plot_1.pixels = [500, 500] plot_1.color = 'mat' plot_1.basis = 'xy' plot_2 = openmc.Plot(plot_id=2) plot_2.filename = 'plot_2' plot_2.origin = [0.0, 21.42, 0.0] plot_2.width = [64.26, 64.26] plot_2.pixels = [500, 500] plot_2.color = 'mat' plot_2.basis = 'xz'
def pincellfunction(pitch, enrichment): settings = openmc.Settings() # Set high tolerance to allow use of lower temperature xs settings.temperature['tolerance'] = 10000 settings.temperature['method'] = 'nearest' settings.temperature['multipole'] = True settings.cutoff = {'energy': 1e-8} #energy cutoff in eV ############################# ### MATERIALS ### ############################# uo2 = openmc.Material(1, "uo2") uo2.add_element('U', 1.0, enrichment=enrichment) uo2.add_element('O', 2.0) uo2.set_density('g/cm3', 10.97) uo2.temperature = 900 #kelvin water = openmc.Material(3, "h2o") water.add_nuclide('H1', 2.0) water.add_nuclide('O16', 1.0) #Using P = 15.5 Mpa water.set_density('g/cm3', 0.66) water.add_s_alpha_beta('c_H_in_H2O') water.temperature = 600 #kelvin mats = openmc.Materials([uo2, water]) mats.export_to_xml() ############################# ### GEOMETRY ### ############################# universe = openmc.Universe() fuel_or = openmc.ZCylinder(R=0.5) fuel_region = -fuel_or fuel_cell = openmc.Cell(1, 'fuel') fuel_cell.fill = uo2 fuel_cell.region = fuel_region hexagon = openmc.get_hexagonal_prism(edge_length=1 / 3**(1 / 2) * pitch, orientation='y', boundary_type='reflective') bottom = openmc.ZPlane(z0=-pitch / 2, boundary_type='reflective') top = openmc.ZPlane(z0=pitch / 2, boundary_type='reflective') water_region = hexagon & +fuel_or moderator = openmc.Cell(2, 'moderator') moderator.fill = water moderator.region = water_region root = openmc.Universe(cells=(fuel_cell, moderator)) geom = openmc.Geometry(root) geom.export_to_xml() ##################################### ### SOURCE/BATCHES ### ##################################### point = openmc.stats.Point((0, 0, 0)) src = openmc.Source(space=point) settings.source = src settings.batches = 100 settings.inactive = 10 settings.particles = 1000 settings.export_to_xml() ############################# ### TALLIES ### ############################# # Instantiate an empty Tallies object tallies_file = openmc.Tallies() # K-Eigenvalue (infinity) tallies fiss_rate = openmc.Tally(name='fiss. rate') fiss_rate.scores = ['nu-fission'] tallies_file.append(fiss_rate) abs_rate = openmc.Tally(name='abs. rate') abs_rate.scores = ['absorption'] tallies_file.append(abs_rate) # Resonance Escape Probability tallies therm_abs_rate = openmc.Tally(name='therm. abs. rate') therm_abs_rate.scores = ['absorption'] therm_abs_rate.filters = [openmc.EnergyFilter([0., 0.625])] tallies_file.append(therm_abs_rate) # Thermal Flux Utilization tallies fuel_therm_abs_rate = openmc.Tally(name='fuel therm. abs. rate') fuel_therm_abs_rate.scores = ['absorption'] fuel_therm_abs_rate.filters = [ openmc.EnergyFilter([0., 0.625]), openmc.CellFilter([fuel_cell]) ] tallies_file.append(fuel_therm_abs_rate) # Fast Fission Factor tallies therm_fiss_rate = openmc.Tally(name='therm. fiss. rate') therm_fiss_rate.scores = ['nu-fission'] therm_fiss_rate.filters = [openmc.EnergyFilter([0., 0.625])] tallies_file.append(therm_fiss_rate) tallies_file.export_to_xml() ############################# ### PLOTTING ### ############################# p = openmc.Plot() p.filename = 'pinplot' p.width = (1.5 * pitch, 1.5 * pitch) p.pixels = (200, 200) p.color_by = 'material' p.colors = {uo2: 'yellow', water: 'blue'} plots = openmc.Plots([p]) plots.export_to_xml() openmc.plot_geometry() pngstring = 'pinplot{}.png'.format(str(pitch)) subprocess.call(['convert', 'pinplot.ppm', pngstring]) subprocess.call(['mv', pngstring, 'figures/' + pngstring]) ############################# ### EXECUTION ### ############################# openmc.run() sp = openmc.StatePoint('statepoint.{}.h5'.format(settings.batches)) # Collect all the tallies fiss_rate = sp.get_tally(name='fiss. rate') fiss_rate_df = fiss_rate.get_pandas_dataframe() abs_rate = sp.get_tally(name='abs. rate') abs_rate_df = abs_rate.get_pandas_dataframe() therm_abs_rate = sp.get_tally(name='therm. abs. rate') therm_abs_rate_df = therm_abs_rate.get_pandas_dataframe() fuel_therm_abs_rate = sp.get_tally(name='fuel therm. abs. rate') fuel_therm_abs_rate_df = fuel_therm_abs_rate.get_pandas_dataframe() therm_fiss_rate = sp.get_tally(name='therm. fiss. rate') therm_fiss_rate_df = therm_fiss_rate.get_pandas_dataframe() # Compute k-infinity kinf = fiss_rate / abs_rate kinf_df = kinf.get_pandas_dataframe() # Compute resonance escape probability res_esc = (therm_abs_rate) / (abs_rate) res_esc_df = res_esc.get_pandas_dataframe() # Compute fast fission factor fast_fiss = fiss_rate / therm_fiss_rate fast_fiss_df = fast_fiss.get_pandas_dataframe() # Compute thermal flux utilization therm_util = fuel_therm_abs_rate / therm_abs_rate therm_util_df = therm_util.get_pandas_dataframe() # Compute neutrons produced per absorption eta = therm_fiss_rate / fuel_therm_abs_rate eta_df = eta.get_pandas_dataframe() columns = [ 'pitch', 'enrichment', 'kinf mean', 'kinf sd', 'res_esc mean', 'res_esc sd', 'fast_fiss mean', 'fast_fiss sd', 'therm_util mean', 'therm_util sd', 'eta mean', 'eta sd' ] data = [[ pitch, enrichment, kinf_df['mean'][0], kinf_df['std. dev.'][0], res_esc_df['mean'][0], res_esc_df['std. dev.'][0], fast_fiss_df['mean'][0], fast_fiss_df['std. dev.'][0], therm_util_df['mean'][0], therm_util_df['std. dev.'][0], eta_df['mean'][0], eta_df['std. dev.'][0] ]] all_tallies = pd.DataFrame(data, columns=columns) return all_tallies
cell16 = openmc.Cell() cell16.region = -xp24 & +xp25 & -yp26 & +yp27 & -zp28 & +zp35 & ~region14 & ~region15 & ~region8 & ~region9 & ~region10 & ~region13 cell16.fill = water root = openmc.Universe(cells=(cell8, cell9, cell10, cell13, cell14, cell15, cell16)) geom = openmc.Geometry(root) geom.export_to_xml() src = openmc.Source() bounds = [0, 0, 0, 138, 20, 92] src.space = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True) settings = openmc.Settings() settings.source = src settings.batches = 160 settings.inactive = 60 settings.particles = 1500 settings.output = {'tallies': False} settings.export_to_xml() plot = openmc.Plot() plot.origin = [60, 10.16, 50] plot.width = [200, 200] plot.pixels = [800, 800] plot.color_by = 'material' plot_file = openmc.Plots([plot]) plot_file.export_to_xml() openmc.run()
def build_inputs(n_mesh_bins, energy_bins, n_azim_bins, **kwargs): """Build OpenMC input XML files for a pincell with detailed flux tallying""" if n_azim_bins % 8 != 0: raise ValueError("The number of azimuthal bins " "must be divisible by eight") pitch = 0.62992 * 2 #################### # Define materials #################### uo2 = openmc.Material(material_id=9201, name='UO2 fuel at 2.4% wt enrichment') uo2.set_density('g/cm3', 10.29769) uo2.add_nuclide('U-234', 4.4842e-06) uo2.add_nuclide('U-235', 5.5814e-04) uo2.add_nuclide('U-238', 2.2407e-02) uo2.add_nuclide('O-16', 4.5828e-02) uo2.add_nuclide('O-17', 1.7457e-05 + 9.4176e-05) borated_water = openmc.Material(material_id=101, name='Borated water at 975 ppm') borated_water.set_density('g/cm3', 0.740582) borated_water.add_nuclide('B-10', 8.0042e-6) borated_water.add_nuclide('B-11', 3.2218e-5) borated_water.add_nuclide('H-1', 4.9457e-2) borated_water.add_nuclide('H-2', 7.4196e-6) borated_water.add_nuclide('O-16', 2.4672e-2) borated_water.add_nuclide('O-17', 9.3982e-06 + 5.0701e-05) borated_water.add_s_alpha_beta('HH2O', '71t') helium = openmc.Material(material_id=201, name='Helium for gap') helium.set_density('g/cm3', 0.001598) helium.add_nuclide('He-4', 2.4044e-4) zircaloy = openmc.Material(material_id=4001, name='Zircaloy 4') zircaloy.set_density('g/cm3', 6.55) zircaloy.add_nuclide('O-16', 3.0743e-04) zircaloy.add_nuclide('O-17', 1.1711e-07 + 6.3176e-07) zircaloy.add_nuclide('Cr-50', 3.2962e-06) zircaloy.add_nuclide('Cr-52', 6.3564e-05) zircaloy.add_nuclide('Cr-53', 7.2076e-06) zircaloy.add_nuclide('Cr-54', 1.7941e-06) zircaloy.add_nuclide('Fe-54', 8.6699e-06) zircaloy.add_nuclide('Fe-56', 1.3610e-04) zircaloy.add_nuclide('Fe-57', 3.1431e-06) zircaloy.add_nuclide('Fe-58', 4.1829e-07) zircaloy.add_nuclide('Zr-90', 2.1827e-02) zircaloy.add_nuclide('Zr-91', 4.7600e-03) zircaloy.add_nuclide('Zr-92', 7.2758e-03) zircaloy.add_nuclide('Zr-94', 7.3734e-03) zircaloy.add_nuclide('Zr-96', 1.1879e-03) zircaloy.add_nuclide('Sn-112', 4.6735e-06) zircaloy.add_nuclide('Sn-114', 3.1799e-06) zircaloy.add_nuclide('Sn-115', 1.6381e-06) zircaloy.add_nuclide('Sn-116', 7.0055e-05) zircaloy.add_nuclide('Sn-117', 3.7003e-05) zircaloy.add_nuclide('Sn-118', 1.1669e-04) zircaloy.add_nuclide('Sn-119', 4.1387e-05) zircaloy.add_nuclide('Sn-120', 1.5697e-04) zircaloy.add_nuclide('Sn-122', 2.2308e-05) zircaloy.add_nuclide('Sn-124', 2.7897e-05) materials_file = openmc.MaterialsFile() materials_file.default_xs = '71c' materials_file.add_materials([uo2, helium, zircaloy, borated_water]) materials_file.export_to_xml() #################### # Define geometry #################### # Surfaces. fuel_or = openmc.ZCylinder(R=0.39218, name='Fuel OR') clad_ir = openmc.ZCylinder(R=0.40005, name='Clad IR') clad_or = openmc.ZCylinder(R=0.45720, name='Clad OR') bottom = openmc.YPlane(y0=0.0, name='bottom') right = openmc.XPlane(x0=pitch / 2.0, name='right') top = openmc.Plane(A=1, B=-1, name='top') # 45 degree angle lower = openmc.ZPlane(z0=-10, name='lower') upper = openmc.ZPlane(z0=10, name='upper') for s in (bottom, right, top, lower, upper): s.boundary_type = 'reflective' # Cells. fuel_cell = openmc.Cell() gap_cell = openmc.Cell() clad_cell = openmc.Cell() water_cell = openmc.Cell() # Cell regions. fuel_cell.region = -fuel_or gap_cell.region = +fuel_or & -clad_ir clad_cell.region = +clad_ir & -clad_or water_cell.region = +clad_or & -right for c in (fuel_cell, gap_cell, clad_cell, water_cell): c.region = c.region & +bottom & +top & +lower & -upper # Cell fills. fuel_cell.fill = uo2 gap_cell.fill = helium clad_cell.fill = zircaloy water_cell.fill = borated_water # Universe, geometry, and XML. root = openmc.Universe(universe_id=0, name='Root universe') root.add_cells([fuel_cell, gap_cell, clad_cell, water_cell]) geometry = openmc.Geometry() geometry.root_universe = root geometry_file = openmc.GeometryFile() geometry_file.geometry = geometry geometry_file.export_to_xml() #################### # Define settings #################### settings_file = openmc.SettingsFile() settings_file.batches = kwargs.setdefault('batches', 25) settings_file.inactive = kwargs.setdefault('inactive', 5) settings_file.particles = kwargs.setdefault('particles', 1000) settings_file.source = openmc.source.Source( openmc.stats.Point((0.2, 0.1, 0.0))) settings_file.export_to_xml() #################### # Define tallies #################### mesh = openmc.Mesh(mesh_id=1) delta = pitch / 2.0 / (n_mesh_bins + 1) mesh.dimension = [n_mesh_bins, n_mesh_bins, 1] mesh.lower_left = [-delta / 2.0, -delta / 2.0, -1.e50] mesh.upper_right = [ pitch / 2.0 + delta / 2.0, pitch / 2.0 + delta / 2.0, 1.e50 ] energy_filter = openmc.Filter(type='energy', bins=energy_bins) mesh_filter = openmc.Filter() mesh_filter.mesh = mesh azim_filter = openmc.Filter(type='azimuthal', bins=n_azim_bins) tally = openmc.Tally(tally_id=1) tally.add_filter(energy_filter) tally.add_filter(mesh_filter) tally.add_filter(azim_filter) tally.add_score('flux') tallies_file = openmc.TalliesFile() tallies_file.add_mesh(mesh) tallies_file.add_tally(tally) tallies_file.export_to_xml() #################### # Define plots #################### plotfile = openmc.PlotsFile() plot = openmc.Plot() plot.filename = 'matplot' plot.origin = (pitch / 4.0, pitch / 4.0, 0) plot.width = (0.5 * pitch, 0.5 * pitch) plot.pixels = (400, 400) plot.color = 'mat' plot.col_spec = { 101: (100, 200, 200), 201: (220, 220, 220), 4001: (150, 150, 150), 9201: (255, 50, 50) } plotfile.add_plot(plot) plot = openmc.Plot() plot.filename = 'cellplot' plot.origin = (pitch / 4.0, pitch / 4.0, 0) plot.width = (0.5 * pitch, 0.5 * pitch) plot.pixels = (400, 400) plot.color = 'cell' plotfile.add_plot(plot) plotfile.export_to_xml()