From 8bf8d9561b593e641ff6b83482c8281029489f41 Mon Sep 17 00:00:00 2001 From: Colin Josey Date: Mon, 22 May 2017 18:32:02 -0400 Subject: [PATCH] Revise to use MPI OpenDeplete This modifies the depletion codes to use the MPI branch of OpenDeplete. In addition, memory utilization was optimized such that the SMR simulation can actually be run. --- 2x2-periodic/build-depleted.py | 26 ++++++++++++++----------- 2x2-reflector/build-depleted.py | 26 ++++++++++++++----------- assembly/build-depleted.py | 26 ++++++++++++++----------- pin-cell/build-depleted.py | 34 +++++++++++++++------------------ smr/build-depleted.py | 22 ++++++++++----------- 5 files changed, 70 insertions(+), 64 deletions(-) diff --git a/2x2-periodic/build-depleted.py b/2x2-periodic/build-depleted.py index f633d0a..dff8fb3 100644 --- a/2x2-periodic/build-depleted.py +++ b/2x2-periodic/build-depleted.py @@ -17,7 +17,7 @@ radius = 0.39218 height = 5. # Count the number of instances for each cell and material -openmc_geometry.determine_paths() +num_instances = opendeplete.lomem_num_instances(openmc_geometry) # Extract all cells filled by a fuel material fuel_cells = openmc_geometry.get_cells_by_name( @@ -25,17 +25,21 @@ fuel_cells = openmc_geometry.get_cells_by_name( # Assign distribmats for each material for cell in fuel_cells: - new_materials = [] + old_fill = cell.fill.clone() - for i in range(cell.num_instances): - new_materials.append(cell.fill.clone()) + n = num_instances[cell.id] + cell.fill = [old_fill.clone() for i in range(n)] - # Store volume of burnable fuel rods cells - new_material.volume = np.pi * radius**2 * height - new_material.depletable = True - new_material.temperature = 300 + for i in range(n): + cell.fill[i].volume = np.pi * radius**2 * height + cell.fill[i].depletable = True + cell.fill[i].temperature = 300.0 - cell.fill = new_materials +# Set temperature for all cells +cells = openmc_geometry.get_all_cells() + +for cell_id in cells: + cells[cell_id].temperature = 300.0 # Create dt vector for 1 month with 5 day timesteps dt1 = 5*24*60*60 # 5 days @@ -45,7 +49,7 @@ dt = np.repeat([dt1], N) # Create settings variable settings = opendeplete.OpenMCSettings() -settings.openmc_call = ["mpirun", "openmc"] +settings.openmc_call = "openmc" settings.particles = 120000 settings.batches = 20 settings.inactive = 10 @@ -61,4 +65,4 @@ settings.output_dir = 'depleted' op = opendeplete.OpenMCOperator(openmc_geometry, settings) # Perform simulation using the MCNPX/MCNP6 algorithm -opendeplete.integrate(op, opendeplete.ce_cm_c1) +opendeplete.cecm(op) diff --git a/2x2-reflector/build-depleted.py b/2x2-reflector/build-depleted.py index fa98b41..131aad4 100644 --- a/2x2-reflector/build-depleted.py +++ b/2x2-reflector/build-depleted.py @@ -17,7 +17,7 @@ radius = 0.39218 height = 5. # Count the number of instances for each cell and material -openmc_geometry.determine_paths() +num_instances = opendeplete.lomem_num_instances(openmc_geometry) # Extract all cells filled by a fuel material fuel_cells = openmc_geometry.get_cells_by_name( @@ -25,17 +25,21 @@ fuel_cells = openmc_geometry.get_cells_by_name( # Assign distribmats for each material for cell in fuel_cells: - new_materials = [] + old_fill = cell.fill.clone() - for i in range(cell.num_instances): - new_materials.append(cell.fill.clone()) + n = num_instances[cell.id] + cell.fill = [old_fill.clone() for i in range(n)] - # Store volume of burnable fuel rods cells - new_material.volume = np.pi * radius**2 * height - new_material.depletable = True - new_material.temperature = 300 + for i in range(n): + cell.fill[i].volume = np.pi * radius**2 * height + cell.fill[i].depletable = True + cell.fill[i].temperature = 300.0 - cell.fill = new_materials +# Set temperature for all cells +cells = openmc_geometry.get_all_cells() + +for cell_id in cells: + cells[cell_id].temperature = 300.0 # Create dt vector for 1 month with 5 day timesteps dt1 = 5*24*60*60 # 5 days @@ -45,7 +49,7 @@ dt = np.repeat([dt1], N) # Create settings variable settings = opendeplete.OpenMCSettings() -settings.openmc_call = ["mpirun", "openmc"] +settings.openmc_call = "openmc" settings.particles = 120000 settings.batches = 30 settings.inactive = 20 @@ -61,4 +65,4 @@ settings.output_dir = 'depleted' op = opendeplete.OpenMCOperator(openmc_geometry, settings) # Perform simulation using the MCNPX/MCNP6 algorithm -opendeplete.integrate(op, opendeplete.ce_cm_c1) +opendeplete.cecm(op) diff --git a/assembly/build-depleted.py b/assembly/build-depleted.py index 7782663..4207c8a 100644 --- a/assembly/build-depleted.py +++ b/assembly/build-depleted.py @@ -17,7 +17,7 @@ radius = 0.39218 height = 5. # Count the number of instances for each cell and material -openmc_geometry.determine_paths() +num_instances = opendeplete.lomem_num_instances(openmc_geometry) # Extract all cells filled by a fuel material fuel_cells = openmc_geometry.get_cells_by_name( @@ -25,17 +25,21 @@ fuel_cells = openmc_geometry.get_cells_by_name( # Assign distribmats for each material for cell in fuel_cells: - new_materials = [] + old_fill = cell.fill.clone() - for i in range(cell.num_instances): - new_materials.append(cell.fill.clone()) + n = num_instances[cell.id] + cell.fill = [old_fill.clone() for i in range(n)] - # Store volume of burnable fuel rods cells - new_material.volume = np.pi * radius**2 * height - new_material.depletable = True - new_material.temperature = 300 + for i in range(n): + cell.fill[i].volume = np.pi * radius**2 * height + cell.fill[i].depletable = True + cell.fill[i].temperature = 300.0 - cell.fill = new_materials +# Set temperature for all cells +cells = openmc_geometry.get_all_cells() + +for cell_id in cells: + cells[cell_id].temperature = 300.0 # Create dt vector for 1 month with 5 day timesteps dt1 = 5*24*60*60 # 5 days @@ -45,7 +49,7 @@ dt = np.repeat([dt1], N) # Create settings variable settings = opendeplete.OpenMCSettings() -settings.openmc_call = ["mpirun", "openmc"] +settings.openmc_call = "openmc" settings.particles = 30000 settings.batches = 20 settings.inactive = 10 @@ -61,4 +65,4 @@ settings.output_dir = 'depleted' op = opendeplete.OpenMCOperator(openmc_geometry, settings) # Perform simulation using the MCNPX/MCNP6 algorithm -opendeplete.integrate(op, opendeplete.ce_cm_c1) +opendeplete.cecm(op) diff --git a/pin-cell/build-depleted.py b/pin-cell/build-depleted.py index ae048bf..c86af14 100644 --- a/pin-cell/build-depleted.py +++ b/pin-cell/build-depleted.py @@ -17,12 +17,7 @@ radius = 0.39218 height = 5. # Count the number of instances for each cell and material -openmc_geometry.determine_paths() - -# Determine the maximum material ID -max_material_id = 0 -for material in openmc_geometry.get_all_materials().values(): - max_material_id = max(max_material_id, material.id) +num_instances = opendeplete.lomem_num_instances(openmc_geometry) # Extract all cells filled by a fuel material fuel_cells = openmc_geometry.get_cells_by_name( @@ -30,20 +25,21 @@ fuel_cells = openmc_geometry.get_cells_by_name( # Assign distribmats for each material for cell in fuel_cells: - new_materials = [] + old_fill = cell.fill.clone() - for i in range(cell.num_instances): - new_material = copy.deepcopy(cell.fill) - new_material.id = max_material_id + 1 - max_material_id += 1 - new_materials.append(new_material) + n = num_instances[cell.id] + cell.fill = [old_fill.clone() for i in range(n)] - # Store volume of burnable fuel rods cells - new_material.volume = np.pi * radius**2 * height - new_material.depletable = True - new_material.temperature = 300 + for i in range(n): + cell.fill[i].volume = np.pi * radius**2 * height + cell.fill[i].depletable = True + cell.fill[i].temperature = 300.0 - cell.fill = new_materials +# Set temperature for all cells +cells = openmc_geometry.get_all_cells() + +for cell_id in cells: + cells[cell_id].temperature = 300.0 # Create dt vector for 1 month with 5 day timesteps dt1 = 5*24*60*60 # 5 days @@ -53,7 +49,7 @@ dt = np.repeat([dt1], N) # Create settings variable settings = opendeplete.OpenMCSettings() -settings.openmc_call = ["mpirun", "openmc"] +settings.openmc_call = "openmc" settings.particles = 10000 settings.batches = 20 settings.inactive = 10 @@ -69,4 +65,4 @@ settings.output_dir = 'depleted' op = opendeplete.OpenMCOperator(openmc_geometry, settings) # Perform simulation using the MCNPX/MCNP6 algorithm -opendeplete.integrate(op, opendeplete.ce_cm_c1) +opendeplete.cecm(op) diff --git a/smr/build-depleted.py b/smr/build-depleted.py index b2fb000..ffecd8f 100644 --- a/smr/build-depleted.py +++ b/smr/build-depleted.py @@ -19,7 +19,7 @@ radius = 0.39218 height = 200. # Count the number of instances for each cell and material -geometry.determine_paths() +num_instances = opendeplete.lomem_num_instances(geometry) # Extract all cells filled by a fuel material fuel_cells = geometry.get_cells_by_name( @@ -43,17 +43,15 @@ fuel_cells.extend(geometry.get_cells_by_name( # Assign distribmats for each material for cell in fuel_cells: - new_materials = [] + old_fill = cell.fill.clone() - for i in range(cell.num_instances): - new_materials.append(cell.fill.clone()) + n = num_instances[cell.id] + cell.fill = [old_fill.clone() for i in range(n)] - # Store volume of burnable fuel rods cells - new_material.volume = np.pi * radius**2 * height - new_material.depletable = True - new_material.temperature = 300 - - cell.fill = new_materials + for i in range(n): + cell.fill[i].volume = np.pi * radius**2 * height + cell.fill[i].depletable = True + cell.fill[i].temperature = 300.0 # Create dt vector for 1 month with 5 day timesteps dt1 = 5*24*60*60 # 5 days @@ -63,7 +61,7 @@ dt = np.repeat([dt1], N) # Create settings variable settings = opendeplete.OpenMCSettings() -settings.openmc_call = ["mpirun", "openmc"] +settings.openmc_call = "openmc" settings.particles = 1000000 settings.batches = 200 settings.inactive = 100 @@ -81,4 +79,4 @@ settings.output_dir = 'depleted' op = opendeplete.OpenMCOperator(geometry, settings) # Perform simulation using the MCNPX/MCNP6 algorithm -opendeplete.integrate(op, opendeplete.ce_cm_c1) +opendeplete.cecm(op)