def _build_inputs(self): # Define materials water = openmc.Material(1) water.add_nuclide('H1', 2.0) water.add_nuclide('O16', 1.0) water.add_s_alpha_beta('c_H_in_H2O') water.set_density('g/cc', 1.0) fuel = openmc.Material(2) fuel.add_nuclide('U235', 1.0) fuel.set_density('g/cc', 4.5) materials = openmc.Materials((water, fuel)) materials.default_temperature = '294K' materials.export_to_xml() # Define the geometry. Note that this geometry is somewhat non-sensical # (it essentially defines a circle of half-cylinders), but it is # designed so that periodic and reflective BCs will give different # answers. theta1 = (-1 / 6 + 1 / 2) * np.pi theta2 = (1 / 6 - 1 / 2) * np.pi plane1 = openmc.Plane(a=np.cos(theta1), b=np.sin(theta1), boundary_type='periodic') plane2 = openmc.Plane(a=np.cos(theta2), b=np.sin(theta2), boundary_type='periodic') x_max = openmc.XPlane(x0=5., boundary_type='reflective') z_cyl = openmc.ZCylinder(x0=3 * np.cos(np.pi / 6), y0=3 * np.sin(np.pi / 6), r=2.0) outside_cyl = openmc.Cell(1, fill=water, region=(+plane1 & +plane2 & -x_max & +z_cyl)) inside_cyl = openmc.Cell(2, fill=fuel, region=(+plane1 & +plane2 & -z_cyl)) root_universe = openmc.Universe(0, cells=(outside_cyl, inside_cyl)) geometry = openmc.Geometry() geometry.root_universe = root_universe geometry.export_to_xml() # Define settings settings = openmc.Settings() settings.particles = 1000 settings.batches = 4 settings.inactive = 0 settings.source = openmc.Source( space=openmc.stats.Box((0, 0, 0), (5, 5, 0))) settings.export_to_xml()
def build(self): x0 = openmc.XPlane(x0=0, boundary_type="reflective") right_inner_wall = openmc.Plane(A=cos(pi / 3), B=-cos(pi / 6), D=(RAD_MAJ - STEEL_THICK) * cos(pi / 6)) right_outer_wall = openmc.Plane(A=cos(pi / 3), B=-cos(pi / 6), D=RAD_MAJ * cos(pi / 6)) right_refl_edge = openmc.Plane(boundary_type="reflective", A=cos(pi / 6), B=cos(pi / 3), D=-GAP / 2 * cos(pi / 6) * 0) ymin = openmc.YPlane(y0=-RAD_MAJ, boundary_type="vacuum", name="YMIN") zmin = openmc.ZPlane(z0=-10, boundary_type="periodic", name="ZMIN") zmax = openmc.ZPlane(z0=+10, boundary_type="periodic", name="ZMAX") ru = openmc.Universe(name="root universe") radialu = openmc.Universe(name="radial universe") lattice = self.get_lattice() dist = RAD_MAJ - STEEL_THICK - sqrt(3) / 2 * self.pitch right_inner_water = openmc.Plane(A=cos(pi / 3), B=-cos(pi / 6), D=dist * cos(pi / 6)) # Fueled area inner = openmc.Cell() inner.region = -right_inner_water inner.fill = lattice radialu.add_cell(inner) # Water buffer buffer = openmc.Cell() buffer.region = +right_inner_water & -right_inner_wall buffer.fill = all_materials["Mod"] radialu.add_cell(buffer) # Reactor pressure vessel rpv = openmc.Cell() rpv.region = +right_inner_wall & -right_outer_wall rpv.fill = all_materials["SS316"] radialu.add_cell(rpv) outside = openmc.Cell() outside.region = +right_outer_wall outside.fill = all_materials["Air"] radialu.add_cell(outside) # Root Universe root_cell = openmc.Cell(name="root cell") root_cell.fill = radialu root_cell.region = +x0 & +ymin & +zmin & -zmax & -right_refl_edge ru.add_cell(root_cell) self._geometry = openmc.Geometry() self._geometry.root_universe = ru
def test_plane(): s = openmc.Plane(a=1, b=2, c=-1, d=3, name='my plane') assert s.a == 1 assert s.b == 2 assert s.c == -1 assert s.d == 3 assert s.boundary_type == 'transmission' assert s.name == 'my plane' assert s.type == 'plane' # Generic planes don't have well-defined bounding boxes assert_infinite_bb(s) # evaluate method x, y, z = (4, 3, 6) assert s.evaluate( (x, y, z)) == pytest.approx(s.a * x + s.b * y + s.c * z - s.d) # translate method st = s.translate((1.0, 0.0, 0.0)) assert (st.a, st.b, st.c, st.d) == (s.a, s.b, s.c, 4) # rotate method yp = openmc.YPlane(abs(s.d) / math.sqrt(s.a**2 + s.b**2 + s.c**2)) psi = math.degrees(math.atan2(1, 2)) phi = math.degrees(math.atan2(1, math.sqrt(5))) sr = s.rotate((phi, 0., psi), order='zyx') assert yp.normalize() == pytest.approx(sr.normalize()) # test rotation ordering phi = math.degrees(math.atan2(1, math.sqrt(2))) sr = s.rotate((0., -45., phi), order='xyz') assert yp.normalize() == pytest.approx(sr.normalize()) # Make sure repr works repr(s)
def _build_inputs(self): # Define materials water = openmc.Material(1) water.add_nuclide('H1', 2.0) water.add_nuclide('O16', 1.0) water.add_s_alpha_beta('c_H_in_H2O') water.set_density('g/cc', 1.0) fuel = openmc.Material(2) fuel.add_nuclide('U235', 1.0) fuel.set_density('g/cc', 4.5) materials = openmc.Materials((water, fuel)) materials.default_temperature = '294K' materials.export_to_xml() # Define geometry x_min = openmc.XPlane(surface_id=1, x0=0., boundary_type='periodic') x_max = openmc.XPlane(surface_id=2, x0=5., boundary_type='reflective') y_min = openmc.YPlane(surface_id=3, y0=0., boundary_type='periodic') y_max = openmc.YPlane(surface_id=4, y0=5., boundary_type='reflective') y_min.periodic_surface = x_min z_min = openmc.ZPlane(surface_id=5, z0=-5., boundary_type='periodic') z_max = openmc.Plane(surface_id=6, a=0, b=0, c=1, d=5., boundary_type='periodic') z_cyl = openmc.ZCylinder(surface_id=7, x0=2.5, y0=0., r=2.0) outside_cyl = openmc.Cell(1, fill=water, region=(+x_min & -x_max & +y_min & -y_max & +z_min & -z_max & +z_cyl)) inside_cyl = openmc.Cell(2, fill=fuel, region=(+y_min & +z_min & -z_max & -z_cyl)) root_universe = openmc.Universe(0, cells=(outside_cyl, inside_cyl)) geometry = openmc.Geometry() geometry.root_universe = root_universe geometry.export_to_xml() # Define settings settings = openmc.Settings() settings.particles = 1000 settings.batches = 4 settings.inactive = 0 settings.source = openmc.Source( space=openmc.stats.Box((0, 0, 0), (5, 5, 0))) settings.export_to_xml()
def box_model(): model = openmc.model.Model() # Define materials water = openmc.Material() water.add_nuclide('H1', 2.0) water.add_nuclide('O16', 1.0) water.add_s_alpha_beta('c_H_in_H2O') water.set_density('g/cc', 1.0) fuel = openmc.Material() fuel.add_nuclide('U235', 1.0) fuel.set_density('g/cc', 4.5) # Define geometry x_min = openmc.XPlane(surface_id=1, x0=0., boundary_type='periodic') x_max = openmc.XPlane(surface_id=2, x0=5., boundary_type='reflective') y_min = openmc.YPlane(surface_id=3, y0=0., boundary_type='periodic') y_max = openmc.YPlane(surface_id=4, y0=5., boundary_type='reflective') y_min.periodic_surface = x_min z_min = openmc.ZPlane(surface_id=5, z0=-5., boundary_type='periodic') z_max = openmc.Plane(surface_id=6, a=0, b=0, c=1, d=5., boundary_type='periodic') z_cyl = openmc.ZCylinder(surface_id=7, x0=2.5, y0=0., r=2.0) outside_cyl = openmc.Cell(1, fill=water, region=(+x_min & -x_max & +y_min & -y_max & +z_min & -z_max & +z_cyl)) inside_cyl = openmc.Cell(2, fill=fuel, region=(+y_min & +z_min & -z_max & -z_cyl)) root_universe = openmc.Universe(0, cells=(outside_cyl, inside_cyl)) model.geometry = openmc.Geometry(root_universe) # Define settings model.settings.particles = 1000 model.settings.batches = 4 model.settings.inactive = 0 model.settings.source = openmc.Source( space=openmc.stats.Box((0, 0, 0), (5, 5, 0))) return model
def plane(m, x, y, bc='transmission'): """ Creates openmc plane Parameters ---------- m: float gradient of plane x: float x-intercept y: float y-intercept bc: str boundary condition Returns ------- openmc.Plane """ return openmc.Plane(a=-m, b=1, d=-m * x + y, boundary_type=bc)
def test_plane(): s = openmc.Plane(a=1, b=2, c=-1, d=3, name='my plane') assert s.a == 1 assert s.b == 2 assert s.c == -1 assert s.d == 3 assert s.boundary_type == 'transmission' assert s.name == 'my plane' assert s.type == 'plane' # Generic planes don't have well-defined bounding boxes assert_infinite_bb(s) # evaluate method x, y, z = (4, 3, 6) assert s.evaluate((x, y, z)) == pytest.approx(s.a*x + s.b*y + s.c*z - s.d) # translate method st = s.translate((1.0, 0.0, 0.0)) assert (st.a, st.b, st.c, st.d) == (s.a, s.b, s.c, 4) # Make sure repr works repr(s)
def get_openmc_surface(opencg_surface): """Return an OpenMC surface corresponding to an OpenCG surface. Parameters ---------- opencg_surface : opencg.Surface OpenCG surface Returns ------- openmc_surface : openmc.surface.Surface Equivalent OpenMC surface """ if not isinstance(opencg_surface, opencg.Surface): msg = 'Unable to create an OpenMC Surface from "{0}" which ' \ 'is not an OpenCG Surface'.format(opencg_surface) raise ValueError(msg) global openmc_surface surface_id = opencg_surface._id # If this Surface was already created, use it if surface_id in OPENMC_SURFACES: return OPENMC_SURFACES[surface_id] # Create an OpenMC Surface to represent this OpenCG Surface name = opencg_surface._name # Correct for OpenMC's syntax for Surfaces dividing Cells boundary = opencg_surface._boundary_type if boundary == 'interface': boundary = 'transmission' if opencg_surface._type == 'plane': A = opencg_surface._coeffs['A'] B = opencg_surface._coeffs['B'] C = opencg_surface._coeffs['C'] D = opencg_surface._coeffs['D'] openmc_surface = openmc.Plane(surface_id, boundary, A, B, C, D, name) elif opencg_surface._type == 'x-plane': x0 = opencg_surface._coeffs['x0'] openmc_surface = openmc.XPlane(surface_id, boundary, x0, name) elif opencg_surface._type == 'y-plane': y0 = opencg_surface._coeffs['y0'] openmc_surface = openmc.YPlane(surface_id, boundary, y0, name) elif opencg_surface._type == 'z-plane': z0 = opencg_surface._coeffs['z0'] openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name) elif opencg_surface._type == 'x-cylinder': y0 = opencg_surface._coeffs['y0'] z0 = opencg_surface._coeffs['z0'] R = opencg_surface._coeffs['R'] openmc_surface = openmc.XCylinder(surface_id, boundary, y0, z0, R, name) elif opencg_surface._type == 'y-cylinder': x0 = opencg_surface._coeffs['x0'] z0 = opencg_surface._coeffs['z0'] R = opencg_surface._coeffs['R'] openmc_surface = openmc.YCylinder(surface_id, boundary, x0, z0, R, name) elif opencg_surface._type == 'z-cylinder': x0 = opencg_surface._coeffs['x0'] y0 = opencg_surface._coeffs['y0'] R = opencg_surface._coeffs['R'] openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R, name) else: msg = 'Unable to create an OpenMC Surface from an OpenCG ' \ 'Surface of type "{0}" since it is not a compatible ' \ 'Surface type in OpenMC'.format(opencg_surface._type) raise ValueError(msg) # Add the OpenMC Surface to the global collection of all OpenMC Surfaces OPENMC_SURFACES[surface_id] = openmc_surface # Add the OpenCG Surface to the global collection of all OpenCG Surfaces OPENCG_SURFACES[surface_id] = opencg_surface return openmc_surface
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
def get_openmc_surface(openmoc_surface): """Return an OpenMC surface corresponding to an OpenMOC surface. Parameters ---------- openmoc_surface : openmoc.Surface OpenMOC surface Returns ------- openmc_surface : openmc.Surface Equivalent OpenMC surface """ cv.check_type('openmoc_surface', openmoc_surface, openmoc.Surface) surface_id = openmoc_surface.getId() # If this Surface was already created, use it if surface_id in OPENMC_SURFACES: return OPENMC_SURFACES[surface_id] # Create an OpenMC Surface to represent this OpenMOC Surface name = openmoc_surface.getName() # Correct for OpenMC's syntax for Surfaces dividing Cells boundary = openmoc_surface.getBoundaryType() if boundary == openmoc.VACUUM: boundary = 'vacuum' elif boundary == openmoc.REFLECTIVE: boundary = 'reflective' elif boundary == openmoc.PERIODIC: boundary = 'periodic' else: boundary = 'transmission' if openmoc_surface.getSurfaceType() == openmoc.PLANE: openmoc_surface = openmoc.castSurfaceToPlane(openmoc_surface) A = openmoc_surface.getA() B = openmoc_surface.getB() C = openmoc_surface.getC() D = openmoc_surface.getD() # OpenMOC uses the opposite sign on D openmc_surface = openmc.Plane(surface_id, boundary, A, B, C, -D, name) elif openmoc_surface.getSurfaceType() == openmoc.XPLANE: openmoc_surface = openmoc.castSurfaceToXPlane(openmoc_surface) x0 = openmoc_surface.getX() openmc_surface = openmc.XPlane(surface_id, boundary, x0, name) elif openmoc_surface.getSurfaceType() == openmoc.YPLANE: openmoc_surface = openmoc.castSurfaceToYPlane(openmoc_surface) y0 = openmoc_surface.getY() openmc_surface = openmc.YPlane(surface_id, boundary, y0, name) elif openmoc_surface.getSurfaceType() == openmoc.ZPLANE: openmoc_surface = openmoc.castSurfaceToZPlane(openmoc_surface) z0 = openmoc_surface.getZ() openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name) elif openmoc_surface.getSurfaceType() == openmoc.ZCYLINDER: openmoc_surface = openmoc.castSurfaceToZCylinder(openmoc_surface) x0 = openmoc_surface.getX0() y0 = openmoc_surface.getY0() R = openmoc_surface.getRadius() openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R, name) # Add the OpenMC Surface to the global collection of all OpenMC Surfaces OPENMC_SURFACES[surface_id] = openmc_surface # Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces OPENMOC_SURFACES[surface_id] = openmoc_surface return openmc_surface
def _add_shield_panels(self): """ Adds BEAVRS shield panels """ # Shield panels self.s_neutronShieldIR = openmc.ZCylinder(name='Shield Panel IR', R=c.neutronShieldIR) self.s_ns_NWbot_SEtop = openmc.Plane(name='Shield Panel NWbot/SEtop', **c.neutronShield_NWbot_SEtop) self.s_ns_NWtop_SEbot = openmc.Plane(name='Shield Panel NWtop/SEbot', **c.neutronShield_NWtop_SEbot) self.s_ns_NEbot_SWtop = openmc.Plane(name='Shield Panel NEbot/SWtop', **c.neutronShield_NEbot_SWtop) self.s_ns_NEtop_SWbot = openmc.Plane(name='Shield Panel NEtop/SWbot', **c.neutronShield_NEtop_SWbot) self.c_shieldPanels = [] self.c_sp_NW = openmc.Cell(name='NW Shield Panel', fill=self.mats['SS304']) self.c_sp_NW.region = (+self.s_neutronShieldIR & -self.s_neutronShieldOR & +self.s_ns_NWbot_SEtop & -self.s_ns_NWtop_SEbot & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_NW) self.c_sp_SE = openmc.Cell(name='SE Shield Panel', fill=self.mats['SS304']) self.c_sp_SE.region = (+self.s_neutronShieldIR & -self.s_neutronShieldOR & -self.s_ns_NWbot_SEtop & +self.s_ns_NWtop_SEbot & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_SE) self.c_sp_NE = openmc.Cell(name='NE Shield Panel', fill=self.mats['SS304']) self.c_sp_NE.region = (+self.s_neutronShieldIR & -self.s_neutronShieldOR & +self.s_ns_NEbot_SWtop & -self.s_ns_NEtop_SWbot & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_NE) self.c_sp_SW = openmc.Cell(name='SW Shield Panel', fill=self.mats['SS304']) self.c_sp_SW.region = (+self.s_neutronShieldIR & -self.s_neutronShieldOR & -self.s_ns_NEbot_SWtop & +self.s_ns_NEtop_SWbot & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_SW) self.c_sp_N = openmc.Cell(name='N Shield Water', fill=self.mats['Borated Water']) self.c_sp_N.region = (+self.s_neutronShieldIR & -self.s_neutronShieldOR & +self.s_ns_NWtop_SEbot & -self.s_ns_NEtop_SWbot & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_N) self.c_sp_S = openmc.Cell(name='S Shield Water', fill=self.mats['Borated Water']) self.c_sp_S.region = (+self.s_neutronShieldIR & -self.s_neutronShieldOR & +self.s_ns_NEtop_SWbot & -self.s_ns_NWtop_SEbot & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_S) self.c_sp_E = openmc.Cell(name='E Shield Water', fill=self.mats['Borated Water']) self.c_sp_E.region = (+self.s_neutronShieldIR & -self.s_neutronShieldOR & +self.s_ns_NWbot_SEtop & +self.s_ns_NEbot_SWtop & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_E) self.c_sp_W = openmc.Cell(name='W Shield Water', fill=self.mats['Borated Water']) self.c_sp_W.region = (+self.s_neutronShieldIR & -self.s_neutronShieldOR & -self.s_ns_NWbot_SEtop & -self.s_ns_NEbot_SWtop & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_W) self.s_coreBarrelOR = openmc.ZCylinder(name='Core Barrel OR', R=c.coreBarrelOR) self.c_sp_inner = openmc.Cell(name='Water between barrel and shield', fill=self.mats['Borated Water']) self.c_sp_inner.region = (+self.s_coreBarrelOR & -self.s_neutronShieldIR & -self.s_upperBound & +self.s_lowerBound) self.c_shieldPanels.append(self.c_sp_inner)
def segment_pin(n_rings, n_wedges, r_fuel, r_gap, r_clad): """ Calculates a segmented pin. Separates a pin with n_rings and n_wedges. All cells have equal volume. Pin is centered at origin. """ # Calculate all the volumes of interest v_fuel = math.pi * r_fuel**2 v_gap = math.pi * r_gap**2 - v_fuel v_clad = math.pi * r_clad**2 - v_fuel - v_gap v_ring = v_fuel / n_rings v_segment = v_ring / n_wedges # Compute ring radiuses r_rings = np.zeros(n_rings) for i in range(n_rings): r_rings[i] = math.sqrt(1.0/(math.pi) * v_ring * (i+1)) # Compute thetas theta = np.linspace(0, 2*math.pi, n_wedges + 1) # Compute surfaces fuel_rings = [openmc.ZCylinder(x0=0, y0=0, r=r_rings[i]) for i in range(n_rings)] fuel_wedges = [openmc.Plane(a=math.cos(theta[i]), b=math.sin(theta[i])) for i in range(n_wedges)] gap_ring = openmc.ZCylinder(x0=0, y0=0, r=r_gap) clad_ring = openmc.ZCylinder(x0=0, y0=0, r=r_clad) # Create cells fuel_cells = [] if n_wedges == 1: for i in range(n_rings): cell = openmc.Cell(name='fuel') if i == 0: cell.region = -fuel_rings[0] else: cell.region = +fuel_rings[i-1] & -fuel_rings[i] fuel_cells.append(cell) else: for i in range(n_rings): for j in range(n_wedges): cell = openmc.Cell(name='fuel') if i == 0: if j != n_wedges-1: cell.region = (-fuel_rings[0] & +fuel_wedges[j] & -fuel_wedges[j+1]) else: cell.region = (-fuel_rings[0] & +fuel_wedges[j] & -fuel_wedges[0]) else: if j != n_wedges-1: cell.region = (+fuel_rings[i-1] & -fuel_rings[i] & +fuel_wedges[j] & -fuel_wedges[j+1]) else: cell.region = (+fuel_rings[i-1] & -fuel_rings[i] & +fuel_wedges[j] & -fuel_wedges[0]) fuel_cells.append(cell) # Gap ring gap_cell = openmc.Cell(name='gap') gap_cell.region = +fuel_rings[-1] & -gap_ring fuel_cells.append(gap_cell) # Clad ring clad_cell = openmc.Cell(name='clad') clad_cell.region = +gap_ring & -clad_ring fuel_cells.append(clad_cell) # Moderator mod_cell = openmc.Cell(name='cool') mod_cell.region = +clad_ring fuel_cells.append(mod_cell) # Form universe fuel_u = openmc.Universe() fuel_u.add_cells(fuel_cells) return fuel_u, v_segment, v_gap, v_clad
def _read_surfaces(self): self.n_surfaces = self._f['geometry/n_surfaces'].value # Initialize dictionary for each Surface # Keys - Surface keys # Values - Surfacee objects self.surfaces = {} for key in self._f['geometry/surfaces'].keys(): if key == 'n_surfaces': continue surface_id = int(key.lstrip('surface ')) index = self._f['geometry/surfaces'][key]['index'].value name = self._f['geometry/surfaces'][key]['name'].value.decode() surf_type = self._f['geometry/surfaces'][key]['type'].value.decode( ) bc = self._f['geometry/surfaces'][key][ 'boundary_condition'].value.decode() coeffs = self._f['geometry/surfaces'][key]['coefficients'][...] # Create the Surface based on its type if surf_type == 'x-plane': x0 = coeffs[0] surface = openmc.XPlane(surface_id, bc, x0, name) elif surf_type == 'y-plane': y0 = coeffs[0] surface = openmc.YPlane(surface_id, bc, y0, name) elif surf_type == 'z-plane': z0 = coeffs[0] surface = openmc.ZPlane(surface_id, bc, z0, name) elif surf_type == 'plane': A = coeffs[0] B = coeffs[1] C = coeffs[2] D = coeffs[3] surface = openmc.Plane(surface_id, bc, A, B, C, D, name) elif surf_type == 'x-cylinder': y0 = coeffs[0] z0 = coeffs[1] R = coeffs[2] surface = openmc.XCylinder(surface_id, bc, y0, z0, R, name) elif surf_type == 'y-cylinder': x0 = coeffs[0] z0 = coeffs[1] R = coeffs[2] surface = openmc.YCylinder(surface_id, bc, x0, z0, R, name) elif surf_type == 'z-cylinder': x0 = coeffs[0] y0 = coeffs[1] R = coeffs[2] surface = openmc.ZCylinder(surface_id, bc, x0, y0, R, name) elif surf_type == 'sphere': x0 = coeffs[0] y0 = coeffs[1] z0 = coeffs[2] R = coeffs[3] surface = openmc.Sphere(surface_id, bc, x0, y0, z0, R, name) elif surf_type in ['x-cone', 'y-cone', 'z-cone']: x0 = coeffs[0] y0 = coeffs[1] z0 = coeffs[2] R2 = coeffs[3] if surf_type == 'x-cone': surface = openmc.XCone(surface_id, bc, x0, y0, z0, R2, name) if surf_type == 'y-cone': surface = openmc.YCone(surface_id, bc, x0, y0, z0, R2, name) if surf_type == 'z-cone': surface = openmc.ZCone(surface_id, bc, x0, y0, z0, R2, name) elif surf_type == 'quadric': a, b, c, d, e, f, g, h, j, k = coeffs surface = openmc.Quadric(surface_id, bc, a, b, c, d, e, f, g, h, j, k, name) # Add Surface to global dictionary of all Surfaces self.surfaces[index] = surface
def get_openmc_surface(opencg_surface): """Return an OpenMC surface corresponding to an OpenCG surface. Parameters ---------- opencg_surface : opencg.Surface OpenCG surface Returns ------- openmc_surface : openmc.surface.Surface Equivalent OpenMC surface """ cv.check_type('opencg_surface', opencg_surface, opencg.Surface) surface_id = opencg_surface.id # If this Surface was already created, use it if surface_id in OPENMC_SURFACES: return OPENMC_SURFACES[surface_id] # Create an OpenMC Surface to represent this OpenCG Surface name = opencg_surface.name # Correct for OpenMC's syntax for Surfaces dividing Cells boundary = opencg_surface.boundary_type if boundary == 'interface': boundary = 'transmission' if opencg_surface.type == 'plane': A = opencg_surface.a B = opencg_surface.b C = opencg_surface.c D = opencg_surface.d openmc_surface = openmc.Plane(surface_id, boundary, A, B, C, D, name) elif opencg_surface.type == 'x-plane': x0 = opencg_surface.x0 openmc_surface = openmc.XPlane(surface_id, boundary, x0, name) elif opencg_surface.type == 'y-plane': y0 = opencg_surface.y0 openmc_surface = openmc.YPlane(surface_id, boundary, y0, name) elif opencg_surface.type == 'z-plane': z0 = opencg_surface.z0 openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name) elif opencg_surface.type == 'x-cylinder': y0 = opencg_surface.y0 z0 = opencg_surface.z0 R = opencg_surface.r openmc_surface = openmc.XCylinder(surface_id, boundary, y0, z0, R, name) elif opencg_surface.type == 'y-cylinder': x0 = opencg_surface.x0 z0 = opencg_surface.z0 R = opencg_surface.r openmc_surface = openmc.YCylinder(surface_id, boundary, x0, z0, R, name) elif opencg_surface.type == 'z-cylinder': x0 = opencg_surface.x0 y0 = opencg_surface.y0 R = opencg_surface.r openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R, name) else: msg = 'Unable to create an OpenMC Surface from an OpenCG ' \ 'Surface of type "{0}" since it is not a compatible ' \ 'Surface type in OpenMC'.format(opencg_surface.type) raise ValueError(msg) # Add the OpenMC Surface to the global collection of all OpenMC Surfaces OPENMC_SURFACES[surface_id] = openmc_surface # Add the OpenCG Surface to the global collection of all OpenCG Surfaces OPENCG_SURFACES[surface_id] = opencg_surface return openmc_surface
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()