From 827efd3cf288217c00d404541f42d68ec3cf264c Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sat, 18 Mar 2017 21:42:59 -0400 Subject: [PATCH] Updated scripts per comments by @paulromano --- 2x2-periodic/build-fresh.py | 8 ++++---- 2x2-periodic/geometry.py | 21 +++++---------------- 2x2-reflector/build-fresh.py | 8 ++++---- 2x2-reflector/geometry.py | 18 ++++-------------- assembly/build-fresh.py | 8 ++++---- assembly/geometry.py | 11 +++-------- pin-cell/build-fresh.py | 6 +++--- pin-cell/geometry.py | 8 ++------ smr/build-fresh.py | 2 +- smr/smr/plots.py | 8 ++++---- 10 files changed, 34 insertions(+), 64 deletions(-) diff --git a/2x2-periodic/build-fresh.py b/2x2-periodic/build-fresh.py index af253c3..fce6e8a 100644 --- a/2x2-periodic/build-fresh.py +++ b/2x2-periodic/build-fresh.py @@ -21,7 +21,7 @@ openmc_geometry.export_to_xml() # Query the user on whether to use multipole cross sections multipole = input('Use multipole cross sections? (y/n): ').lower() -multipole = True if multipole == 'y' else False +multipole = (multipole == 'y') # Construct uniform initial source distribution over fissionable zones lower_left = [-21.41728, -21.41728, +192.5] @@ -52,9 +52,9 @@ beavrs.write_openmc_plots() plot = openmc.Plot() plot.width = [21.41728*2, 21.41728*2] plot.origin = [0., 0., 195.] -plot.color = 'mat' +plot.color_by = 'material' plot.filename = '2x2-periodic' -plot.col_spec = beavrs.plots.colspec_mat +plot.colors = beavrs.plots.colors_mat plot.pixels = [1000, 1000] plot_file = openmc.Plots([plot]) @@ -106,7 +106,7 @@ mesh.type = 'regular' mesh.dimension = [34, 34, 1] mesh.lower_left = lower_left mesh.width = (np.array(upper_right) - np.array(lower_left)) -mesh.width[:2] /= 34 +mesh.width[:2] /= mesh.dimension mesh_filter = openmc.MeshFilter(mesh) # Instantiate energy-integrated fission rate mesh Tally diff --git a/2x2-periodic/geometry.py b/2x2-periodic/geometry.py index 9ed0d11..da2bdd3 100644 --- a/2x2-periodic/geometry.py +++ b/2x2-periodic/geometry.py @@ -44,20 +44,15 @@ def find_assembly(assembly_name, wrap_geometry=True): min_z = openmc.ZPlane(z0=192.5, boundary_type='reflective') # Add boundaries to the root Cell - root_cell.add_surface(surface=min_x, halfspace=+1) - root_cell.add_surface(surface=max_x, halfspace=-1) - root_cell.add_surface(surface=min_y, halfspace=+1) - root_cell.add_surface(surface=max_y, halfspace=-1) - root_cell.add_surface(surface=min_z, halfspace=+1) - root_cell.add_surface(surface=max_z, halfspace=-1) + root_cell.region = \ + +min_x & -max_x & +min_y & -max_y & +min_z & -max_z # Create a root Universe root_univ = openmc.Universe(universe_id=0, name='root universe') root_univ.add_cell(root_cell) # Create a Geometry - fuel_assembly = openmc.Geometry() - fuel_assembly.root_universe = root_univ + fuel_assembly = openmc.Geometry(root_univ) return fuel_assembly @@ -122,20 +117,14 @@ def build_two_by_two(assembly1_name, assembly2_name): max_z = openmc.ZPlane(z0=197.5, boundary_type='reflective') # Add boundaries to the root Cell - root_cell.add_surface(surface=min_x, halfspace=+1) - root_cell.add_surface(surface=max_x, halfspace=-1) - root_cell.add_surface(surface=min_y, halfspace=+1) - root_cell.add_surface(surface=max_y, halfspace=-1) - root_cell.add_surface(surface=min_z, halfspace=+1) - root_cell.add_surface(surface=max_z, halfspace=-1) + root_cell.region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z # Create a root Universe for this fuel assembly root_univ = openmc.Universe(universe_id=0, name='root universe') root_univ.add_cell(root_cell) # Create an OpenMC Geometry for this fuel assembly - two_by_two = openmc.Geometry() - two_by_two.root_universe = root_univ + two_by_two = openmc.Geometry(root_univ) return two_by_two diff --git a/2x2-reflector/build-fresh.py b/2x2-reflector/build-fresh.py index 7fa6ac4..63075db 100644 --- a/2x2-reflector/build-fresh.py +++ b/2x2-reflector/build-fresh.py @@ -21,7 +21,7 @@ openmc_geometry.export_to_xml() # Query the user on whether to use multipole cross sections multipole = input('Use multipole cross sections? (y/n): ').lower() -multipole = True if multipole == 'y' else False +multipole = (multipole == 'y') # Construct uniform initial source distribution over fissionable zones lower_left = [-32.12592, -32.12592, 192.5] @@ -55,9 +55,9 @@ beavrs.write_openmc_plots() plot = openmc.Plot() plot.width = [64.25184, 64.25184] plot.origin = [0., 0., 195.] -plot.color = 'mat' +plot.color_by = 'material' plot.filename = '2x2-reflector' -plot.col_spec = beavrs.plots.colspec_mat +plot.colors = beavrs.plots.colors_mat plot.pixels = [1000, 1000] plot_file = openmc.Plots([plot]) @@ -109,7 +109,7 @@ mesh.type = 'regular' mesh.dimension = [34, 34, 1] mesh.lower_left = [lower_left[0], lower_left[1] + lat_width[1], lower_left[2]] mesh.width = np.array(lat_width) -mesh.width[:2] /= 17. +mesh.width[:2] /= mesh.dimension mesh_filter = openmc.MeshFilter(mesh) # Instantiate energy-integrated fission rate mesh Tally diff --git a/2x2-reflector/geometry.py b/2x2-reflector/geometry.py index 41be407..c7d1636 100644 --- a/2x2-reflector/geometry.py +++ b/2x2-reflector/geometry.py @@ -44,20 +44,15 @@ def find_assembly(assembly_name, wrap_geometry=True): min_z = openmc.ZPlane(z0=192.5, boundary_type='reflective') # Add boundaries to the root Cell - root_cell.add_surface(surface=min_x, halfspace=+1) - root_cell.add_surface(surface=max_x, halfspace=-1) - root_cell.add_surface(surface=min_y, halfspace=+1) - root_cell.add_surface(surface=max_y, halfspace=-1) - root_cell.add_surface(surface=min_z, halfspace=+1) - root_cell.add_surface(surface=max_z, halfspace=-1) + root_cell.region = \ + +min_x & -max_x & +min_y & -max_y & +min_z & -max_z # Create a root Universe root_univ = openmc.Universe(universe_id=0, name='root universe') root_univ.add_cell(root_cell) # Create a Geometry - fuel_assembly = openmc.Geometry() - fuel_assembly.root_universe = root_univ + fuel_assembly = openmc.Geometry(root_univ) return fuel_assembly @@ -130,12 +125,7 @@ def build_reflector(assembly1_name, assembly2_name): max_z = openmc.ZPlane(z0=197.5, boundary_type='reflective') # Add boundaries to the root Cell - root_cell.add_surface(surface=min_x, halfspace=+1) - root_cell.add_surface(surface=max_x, halfspace=-1) - root_cell.add_surface(surface=min_y, halfspace=+1) - root_cell.add_surface(surface=max_y, halfspace=-1) - root_cell.add_surface(surface=min_z, halfspace=+1) - root_cell.add_surface(surface=max_z, halfspace=-1) + root_cell.region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z # Create a root Universe for this fuel assembly root_univ = openmc.Universe(universe_id=0, name='root universe') diff --git a/assembly/build-fresh.py b/assembly/build-fresh.py index 3aa058e..00b0831 100644 --- a/assembly/build-fresh.py +++ b/assembly/build-fresh.py @@ -21,7 +21,7 @@ openmc_geometry.export_to_xml() # Query the user on whether to use multipole cross sections multipole = input('Use multipole cross sections? (y/n): ').lower() -multipole = True if multipole == 'y' else False +multipole = (multipole == 'y') # Construct uniform initial source distribution over fissionable zones lower_left = [-10.70864, -10.70864, +192.5] @@ -52,9 +52,9 @@ beavrs.write_openmc_plots() plot = openmc.Plot() plot.width = [10.70864*2, 10.70864*2] plot.origin = [0., 0., 195.] -plot.color = 'mat' +plot.color_by = 'material' plot.filename = 'assembly' -plot.col_spec = beavrs.plots.colspec_mat +plot.colors = beavrs.plots.colors_mat plot.pixels = [1000, 1000] plot_file = openmc.Plots([plot]) @@ -106,7 +106,7 @@ mesh.type = 'regular' mesh.dimension = [17, 17, 1] mesh.lower_left = lower_left mesh.width = (np.array(upper_right) - np.array(lower_left)) -mesh.width[:2] /= 17 +mesh.width[:2] /= mesh.dimension mesh_filter = openmc.MeshFilter(mesh) # Instantiate energy-integrated fission rate mesh Tally diff --git a/assembly/geometry.py b/assembly/geometry.py index f110074..c8eca52 100644 --- a/assembly/geometry.py +++ b/assembly/geometry.py @@ -44,20 +44,15 @@ def find_assembly(assembly_name, wrap_geometry=True): min_z = openmc.ZPlane(z0=192.5, boundary_type='reflective') # Add boundaries to the root Cell - root_cell.add_surface(surface=min_x, halfspace=+1) - root_cell.add_surface(surface=max_x, halfspace=-1) - root_cell.add_surface(surface=min_y, halfspace=+1) - root_cell.add_surface(surface=max_y, halfspace=-1) - root_cell.add_surface(surface=min_z, halfspace=+1) - root_cell.add_surface(surface=max_z, halfspace=-1) + root_cell.region = \ + +min_x & -max_x & +min_y & -max_y & +min_z & -max_z # Create a root Universe root_univ = openmc.Universe(universe_id=0, name='root universe') root_univ.add_cell(root_cell) # Create a Geometry - fuel_assembly = openmc.Geometry() - fuel_assembly.root_universe = root_univ + fuel_assembly = openmc.Geometry(root_univ) return fuel_assembly diff --git a/pin-cell/build-fresh.py b/pin-cell/build-fresh.py index aacfd13..83708a5 100644 --- a/pin-cell/build-fresh.py +++ b/pin-cell/build-fresh.py @@ -21,7 +21,7 @@ openmc_geometry.export_to_xml() # Query the user on whether to use multipole cross sections multipole = input('Use multipole cross sections? (y/n): ').lower() -multipole = True if multipole == 'y' else False +multipole = (multipole == 'y') # Construct uniform initial source distribution over fissionable zones lower_left = [-0.62992, -0.62992, -10.0] @@ -52,9 +52,9 @@ beavrs.write_openmc_plots() plot = openmc.Plot() plot.width = [1.25984, 1.25984] plot.origin = [0., 0., np.inf] -plot.color = 'mat' +plot.color_by = 'material' plot.filename = 'fuel-pin' -plot.col_spec = beavrs.plots.colspec_mat +plot.colors = beavrs.plots.colors_mat plot.pixels = [1000, 1000] plot_file = openmc.Plots([plot]) diff --git a/pin-cell/geometry.py b/pin-cell/geometry.py index f8f0dc9..38f8d23 100644 --- a/pin-cell/geometry.py +++ b/pin-cell/geometry.py @@ -52,18 +52,14 @@ def find_pin(pin_name, wrap_geometry=True): root_cell.fill = fuel_pin # Add boundaries to the root Cell - root_cell.add_surface(surface=min_x, halfspace=+1) - root_cell.add_surface(surface=max_x, halfspace=-1) - root_cell.add_surface(surface=min_y, halfspace=+1) - root_cell.add_surface(surface=max_y, halfspace=-1) + root_cell.region = +min_x & -max_x & +min_y & -max_y # Create a root Universe root_univ = openmc.Universe(universe_id=0, name='root universe') root_univ.add_cell(root_cell) # Create a Geometry - fuel_pin = openmc.Geometry() - fuel_pin.root_universe = root_univ + fuel_pin = openmc.Geometry(root_univ) return fuel_pin diff --git a/smr/build-fresh.py b/smr/build-fresh.py index 8b103bd..bdc0fc0 100644 --- a/smr/build-fresh.py +++ b/smr/build-fresh.py @@ -87,7 +87,7 @@ mesh.type = 'regular' mesh.dimension = [7*17, 7*17, 100] mesh.lower_left = lower_left mesh.width = (np.array(upper_right) - np.array(lower_left)) -mesh.width[:2] /= (7*17) +mesh.width[:2] /= mesh.dimension mesh_filter = openmc.MeshFilter(mesh) # Instantiate energy-integrated fission rate mesh Tally diff --git a/smr/smr/plots.py b/smr/smr/plots.py index 9a08715..ce317c1 100644 --- a/smr/smr/plots.py +++ b/smr/smr/plots.py @@ -26,7 +26,7 @@ plots = openmc.Plots() plot = openmc.Plot(name='radial slice ') plot.basis = 'xy' -plot.color = 'mat' +plot.color_by = 'material' plot.origin = [0., 0., (highest_extent-lowest_extent)/2.] plot.width = [25*lattice_pitch/2, 25*lattice_pitch/2.] plot.filename = 'radial_xy_slice' @@ -37,7 +37,7 @@ plots += [plot] plot = openmc.Plot(name='axial slice') plot.basis = 'xz' -plot.color = 'mat' +plot.color_by = 'material' plot.origin = [0., 0., (highest_extent-lowest_extent)/2.] plot.width = [rpv_OR*2., (highest_extent-lowest_extent)] plot.filename = 'axial_xz_slice' @@ -48,7 +48,7 @@ plots += [plot] plot = openmc.Plot(name='assembly grid spacer') plot.basis = 'xy' -plot.color = 'mat' +plot.color_by = 'material' plot.origin = [0., 0., 102.021] plot.width = [lattice_pitch*1.5, lattice_pitch*1.5] plot.filename = 'assm_grid_spacer' @@ -59,7 +59,7 @@ plots += [plot] plot = openmc.Plot(name='assembly no spacer') plot.basis = 'xy' -plot.color = 'mat' +plot.color_by = 'material' plot.origin = [0., 0., 90.] plot.width = [lattice_pitch*1.5, lattice_pitch*1.5] plot.filename = 'assm_no_spacer'