From 38bcb139000af234dc8935b0688b29303c43a17d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 10 Apr 2018 14:45:31 -0500 Subject: [PATCH 1/4] Use lattice in Z to create universe for fuel pins --- smr/smr/pins.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/smr/smr/pins.py b/smr/smr/pins.py index fce0bab..6204f2a 100644 --- a/smr/smr/pins.py +++ b/smr/smr/pins.py @@ -716,16 +716,26 @@ def pin_universes(num_rings=10, num_axial=196, depleted=False): def subdivided_fuel(fill): # Create universe for UO2 alone with axial/radial subdivision - uo2_cells = [] if num_axial > 1: - for axial_region in subdivide(axial_surfs): + univs = np.empty((num_axial, 1, 1), dtype=openmc.Universe) + for i in range(num_axial): + univ_i = openmc.Universe() if num_rings > 1: for ring_region in subdivide(rings): - cell = openmc.Cell(fill=fill, region=axial_region & ring_region) - uo2_cells.append(cell) + cell = openmc.Cell(fill=fill, region=ring_region) + univ_i.add_cell(cell) else: - uo2_cells.append(openmc.Cell(fill=fill, region=axial_region)) + univ_i.add_cell(openmc.Cell(fill=fill)) + univs[i, 0, 0] = univ_i + + zlattice = openmc.RectLattice() + zlattice.lower_left = (-100., -100., bottom_fuel_rod) + zlattice.pitch = (200., 200., (top_active_core - bottom_fuel_rod)/num_axial) + zlattice.dimension = (1, 1, num_axial) + zlattice.universes = univs + return zlattice else: + uo2_cells = [] if num_rings > 1: for ring_region in subdivide(rings): cell = openmc.Cell(fill=fill, region=ring_region) @@ -733,7 +743,7 @@ def pin_universes(num_rings=10, num_axial=196, depleted=False): else: raise RuntimeError("Shouldn't call with 1 ring and 1 axial segment") - return openmc.Universe(cells=uo2_cells) + return openmc.Universe(cells=uo2_cells) # If rings/axial segments are present, create a universe for the subdivided # fuel. Otherwise just use a plain material. From 7dbc5489d1bef0d60e0feff5fe0a33a850e70b53 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Tue, 10 Apr 2018 15:04:38 -0500 Subject: [PATCH 2/4] Improve z-lattice by using same universe in each level --- smr/smr/pins.py | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/smr/smr/pins.py b/smr/smr/pins.py index 6204f2a..2994d57 100644 --- a/smr/smr/pins.py +++ b/smr/smr/pins.py @@ -700,12 +700,6 @@ def pin_universes(num_rings=10, num_axial=196, depleted=False): #### 1.6% ENRICHED FUEL PIN CELL - if num_axial > 1: - # Determine z position between each fuel pellet, omitting the surfaces - # corresponding to the very bottom and top of the active fuel length - axial_splits = np.linspace(bottom_fuel_rod, top_active_core, num_axial + 1)[1:-1] - axial_surfs = [openmc.ZPlane(z0=z) for z in axial_splits] - if num_rings > 1: # Get z-cylinder surfaces for each ring rings = [] @@ -715,35 +709,27 @@ def pin_universes(num_rings=10, num_axial=196, depleted=False): rings.append(cyl) def subdivided_fuel(fill): - # Create universe for UO2 alone with axial/radial subdivision - if num_axial > 1: - univs = np.empty((num_axial, 1, 1), dtype=openmc.Universe) - for i in range(num_axial): - univ_i = openmc.Universe() - if num_rings > 1: - for ring_region in subdivide(rings): - cell = openmc.Cell(fill=fill, region=ring_region) - univ_i.add_cell(cell) - else: - univ_i.add_cell(openmc.Cell(fill=fill)) - univs[i, 0, 0] = univ_i + """Create universe for UO2 alone with axial/radial subdivision""" + # Create universe with radial rings + univ = openmc.Universe() + if num_rings > 1: + for ring_region in subdivide(rings): + cell = openmc.Cell(fill=fill, region=ring_region) + univ.add_cell(cell) + else: + univ.add_cell(openmc.Cell(fill=fill)) + # If multiple axial segments are needed, use a lattice to avoid + # performance cost of neighbor lookups + if num_axial > 1: zlattice = openmc.RectLattice() zlattice.lower_left = (-100., -100., bottom_fuel_rod) zlattice.pitch = (200., 200., (top_active_core - bottom_fuel_rod)/num_axial) zlattice.dimension = (1, 1, num_axial) - zlattice.universes = univs + zlattice.universes = np.full((num_axial, 1, 1), univ) return zlattice else: - uo2_cells = [] - if num_rings > 1: - for ring_region in subdivide(rings): - cell = openmc.Cell(fill=fill, region=ring_region) - uo2_cells.append(cell) - else: - raise RuntimeError("Shouldn't call with 1 ring and 1 axial segment") - - return openmc.Universe(cells=uo2_cells) + return univ # If rings/axial segments are present, create a universe for the subdivided # fuel. Otherwise just use a plain material. From 4af7da2ea7297843477fa00c57586755c64a85ef Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 2 May 2018 22:03:40 -0500 Subject: [PATCH 3/4] Use shallow copy of material for differentiation --- smr/build-core-fresh.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/smr/build-core-fresh.py b/smr/build-core-fresh.py index 0a48194..b53fd4f 100644 --- a/smr/build-core-fresh.py +++ b/smr/build-core-fresh.py @@ -15,6 +15,13 @@ from smr.surfaces import lattice_pitch, bottom_fuel_stack, top_active_core from smr.core import core_geometry +def clone(mat): + """Make a shallow copy of a material (sharing compositions).""" + mat_copy = copy.copy(mat) + mat_copy.id = None + return mat_copy + + # Define command-line options parser = argparse.ArgumentParser() parser.add_argument('-m', '--multipole', action='store_true', @@ -53,7 +60,7 @@ if args.tallies == 'mat': for cell in geometry.get_all_cells().values(): if cell.fill in fuel_mats: # Fill cell with list of "differentiated" materials - cell.fill = [cell.fill.clone() for i in range(cell.num_instances)] + cell.fill = [clone(cell.fill) for i in range(cell.num_instances)] #### Create OpenMC "materials.xml" file all_materials = geometry.get_all_materials() From 2b175b44113ebbb3748f477b6834c6671f9b7781 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 2 May 2018 22:04:10 -0500 Subject: [PATCH 4/4] Fix subdivided fuel (position of lower z-plane, add outer universe) --- smr/smr/pins.py | 7 ++++--- smr/smr/surfaces.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/smr/smr/pins.py b/smr/smr/pins.py index 2994d57..1062166 100644 --- a/smr/smr/pins.py +++ b/smr/smr/pins.py @@ -7,7 +7,7 @@ import openmc from openmc.model import subdivide from .materials import mats -from .surfaces import surfs, pellet_OR, bottom_fuel_rod, top_active_core +from .surfaces import surfs, pellet_OR, bottom_fuel_stack, top_active_core def make_pin(name, surfaces, materials, grid=None): @@ -723,10 +723,11 @@ def pin_universes(num_rings=10, num_axial=196, depleted=False): # performance cost of neighbor lookups if num_axial > 1: zlattice = openmc.RectLattice() - zlattice.lower_left = (-100., -100., bottom_fuel_rod) - zlattice.pitch = (200., 200., (top_active_core - bottom_fuel_rod)/num_axial) + zlattice.lower_left = (-100., -100., bottom_fuel_stack) + zlattice.pitch = (200., 200., (top_active_core - bottom_fuel_stack)/num_axial) zlattice.dimension = (1, 1, num_axial) zlattice.universes = np.full((num_axial, 1, 1), univ) + zlattice.outer = univ return zlattice else: return univ diff --git a/smr/smr/surfaces.py b/smr/smr/surfaces.py index 3aa13a8..b8cd90b 100644 --- a/smr/smr/surfaces.py +++ b/smr/smr/surfaces.py @@ -192,7 +192,7 @@ surfs['bot active core'] = openmc.ZPlane( surfs['top active core'] = openmc.ZPlane( z0=top_active_core, name='top active core') -surfs['top lower thimble'] = copy.deepcopy(surfs['bot active core']) +surfs['top lower thimble'] = surfs['bot active core'] surfs['BA bot'] = openmc.ZPlane( z0=bot_burn_abs, name='bottom of BA')