Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions core_design/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def openmc_depletion(params, lattice_geometry, settings):
return fuel_lifetime_days, mass_U235, mass_U238


def run_depletion_analysis(params):
openmc.run()
def run_depletion_analysis(params, mpi_args=None):
openmc.run(mpi_args=mpi_args)
lattice_geometry = openmc.Geometry.from_xml()
settings = openmc.Settings.from_xml()
depletion_results = openmc_depletion(params, lattice_geometry, settings)
Expand All @@ -218,40 +218,40 @@ def monitor_heat_flux(params):
print(f"\033[91mERROR: HIGH HEAT FLUX IS TOO HIGH: {np.round(params['Heat Flux'],2)} MW/m^2.\033[0m")
return "High Heat Flux"

def run_openmc(build_openmc_model, heat_flux_monitor, params):
def run_openmc(build_openmc_model, heat_flux_monitor, params, mpi_args=None):
if heat_flux_monitor == "High Heat Flux":
print("ERROR: HIGH HEAT FLUX")
else:
try:
print(f"\n\nThe results/plots are saved at: {watts.Database().path}\n\n")
#openmc_plugin = watts.PluginOpenMC(build_openmc_model, show_stderr=True) # running the LTMR Model
#openmc_plugin(params, function=lambda: run_depletion_analysis(params))
#openmc_plugin(params, function=lambda: run_depletion_analysis(params, mpi_args))
if params['SD Margin Calc']:
if params['Isothermal Temperature Coefficients']:
params['SD Margin Calc'] = False
temp_T = copy.deepcopy(params['Common Temperature'])
params['Common Temperature'] = params['Common Temperature'] + 300
openmc_plugin = watts.PluginOpenMC(build_openmc_model, show_stderr=True) # running the LTMR Model
openmc_plugin(params, function=lambda: run_depletion_analysis(params))
openmc_plugin(params, function=lambda: run_depletion_analysis(params, mpi_args))

params['keff 2D high temp'] = params['keff 2D']
params['keff 3D (2D corrected) high temp'] = params['keff 3D (2D corrected)']

params['Common Temperature'] = temp_T

openmc_plugin = watts.PluginOpenMC(build_openmc_model, show_stderr=True) # running the LTMR Model
openmc_plugin(params, function=lambda: run_depletion_analysis(params))
openmc_plugin(params, function=lambda: run_depletion_analysis(params, mpi_args))
params['ITC 2D'] = np.max([(y - x) / (y*x) / (300)*1e5 for x,y in zip(params['keff 2D'],params['keff 2D high temp'])])
params['ITC 3D (2D corrected)'] = np.max([(y - x) / (y*x) / (300)*1e5 for x,y in zip(params['keff 3D (2D corrected)'],params['keff 3D (2D corrected) high temp'])])#(params['keff 3D (2D corrected)'] - params['keff 3D (2D corrected) ARI'])*1e5
params['SD Margin Calc'] = True

openmc_plugin = watts.PluginOpenMC(build_openmc_model, show_stderr=True) # running the LTMR Model
openmc_plugin(params, function=lambda: run_depletion_analysis(params))
openmc_plugin(params, function=lambda: run_depletion_analysis(params, mpi_args))
params['keff 2D ARI'] = params['keff 2D']
params['keff 3D (2D corrected) ARI'] = params['keff 3D (2D corrected)']
params['SD Margin Calc'] = False
openmc_plugin = watts.PluginOpenMC(build_openmc_model, show_stderr=True) # running the LTMR Model
openmc_plugin(params, function=lambda: run_depletion_analysis(params))
openmc_plugin(params, function=lambda: run_depletion_analysis(params, mpi_args))
params['SDM 2D'] = np.max([(y - x)*1e5 for x,y in zip(params['keff 2D'],params['keff 2D ARI'])])
params['SDM 3D (2D corrected)'] = np.max([(y - x)*1e5 for x,y in zip(params['keff 3D (2D corrected)'],params['keff 3D (2D corrected) ARI'])])#(params['keff 3D (2D corrected)'] - params['keff 3D (2D corrected) ARI'])*1e5
else:
Expand All @@ -261,22 +261,22 @@ def run_openmc(build_openmc_model, heat_flux_monitor, params):
temp_T = copy.deepcopy(params['Common Temperature'])
params['Common Temperature'] = params['Common Temperature'] + 300
openmc_plugin = watts.PluginOpenMC(build_openmc_model, show_stderr=True) # running the LTMR Model
openmc_plugin(params, function=lambda: run_depletion_analysis(params))
openmc_plugin(params, function=lambda: run_depletion_analysis(params, mpi_args))

params['keff 2D high temp'] = params['keff 2D']
params['keff 3D (2D corrected) high temp'] = params['keff 3D (2D corrected)']

params['Common Temperature'] = temp_T

openmc_plugin = watts.PluginOpenMC(build_openmc_model, show_stderr=True) # running the LTMR Model
openmc_plugin(params, function=lambda: run_depletion_analysis(params))
openmc_plugin(params, function=lambda: run_depletion_analysis(params, mpi_args))
params['ITC 2D'] = np.max([(y - x) / (y*x) / (300)*1e5 for x,y in zip(params['keff 2D'],params['keff 2D high temp'])])
params['ITC 3D (2D corrected)'] = np.max([(y - x) / (y*x) / (300)*1e5 for x,y in zip(params['keff 3D (2D corrected)'],params['keff 3D (2D corrected) high temp'])])#(params['keff 3D (2D corrected)'] - params['keff 3D (2D corrected) ARI'])*1e5
else:
params['ITC 2D'] = np.nan
params['ITC 3D (2D corrected)'] = np.nan
openmc_plugin = watts.PluginOpenMC(build_openmc_model, show_stderr=True) # running the LTMR Model
openmc_plugin(params, function=lambda: run_depletion_analysis(params))
openmc_plugin(params, function=lambda: run_depletion_analysis(params, mpi_args))
except Exception as e:
print("\n\n\033[91mAn error occurred while running the OpenMC simulation:\033[0m\n\n")
traceback.print_exc()
Expand Down
11 changes: 10 additions & 1 deletion examples/watts_GCMR_packing_fraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
from reactor_engineering_evaluation.vessels_calcs import *
from reactor_engineering_evaluation.tools import *
from cost.cost_estimation import parametric_studies
import os
import sys
try:
number_processes = sys.argv[1]
mpi_args = ['mpirun', '-np', f'{number_processes}']
print(f"\n\nMPI enabled with {number_processes} processes")
except IndexError:
mpi_args = None
print("\n\nMPI not used (no process count provided, running in serial)\n\n")

import warnings
warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -110,7 +119,7 @@ def update_params(updates):
# Sec. 5: Running OpenMC
# **************************************************************************************************************************
heat_flux_monitor = monitor_heat_flux(params)
run_openmc(build_openmc_model_GCMR, heat_flux_monitor, params)
run_openmc(build_openmc_model_GCMR, heat_flux_monitor, params, mpi_args)
fuel_calculations(params) # calculate the fuel mass and SWU

# **************************************************************************************************************************
Expand Down
11 changes: 10 additions & 1 deletion examples/watts_exec_GCMR_Design_A.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
from reactor_engineering_evaluation.vessels_calcs import *
from reactor_engineering_evaluation.tools import *
from cost.cost_estimation import detailed_bottom_up_cost_estimate
import os
import sys
try:
number_processes = sys.argv[1]
mpi_args = ['mpirun', '-np', f'{number_processes}']
print(f"\n\nMPI enabled with {number_processes} processes")
except IndexError:
mpi_args = None
print("\n\nMPI not used (no process count provided, running in serial)\n\n")

import warnings
warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -107,7 +116,7 @@ def update_params(updates):
# Sec. 5: Running OpenMC
# **************************************************************************************************************************
heat_flux_monitor = monitor_heat_flux(params)
run_openmc(build_openmc_model_GCMR, heat_flux_monitor, params)
run_openmc(build_openmc_model_GCMR, heat_flux_monitor, params, mpi_args)
fuel_calculations(params) # calculate the fuel mass and SWU
# **************************************************************************************************************************
# Sec. 6: Primary Loop + Balance of Plant
Expand Down
11 changes: 10 additions & 1 deletion examples/watts_exec_GCMR_Design_B.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
from reactor_engineering_evaluation.vessels_calcs import *
from reactor_engineering_evaluation.tools import *
from cost.cost_estimation import detailed_bottom_up_cost_estimate
import os
import sys
try:
number_processes = sys.argv[1]
mpi_args = ['mpirun', '-np', f'{number_processes}']
print(f"\n\nMPI enabled with {number_processes} processes")
except IndexError:
mpi_args = None
print("\n\nMPI not used (no process count provided, running in serial)\n\n")

import warnings
warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -111,7 +120,7 @@ def update_params(updates):
# Sec. 5: Running OpenMC
# **************************************************************************************************************************
heat_flux_monitor = monitor_heat_flux(params)
run_openmc(build_openmc_model_GCMR, heat_flux_monitor, params)
run_openmc(build_openmc_model_GCMR, heat_flux_monitor, params, mpi_args)
fuel_calculations(params) # calculate the fuel mass and SWU
# **************************************************************************************************************************
# Sec. 6: Primary Loop + Balance of Plant
Expand Down
11 changes: 10 additions & 1 deletion examples/watts_exec_HPMR.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
from reactor_engineering_evaluation.vessels_calcs import *
from reactor_engineering_evaluation.tools import *
from cost.cost_estimation import detailed_bottom_up_cost_estimate
import os
import sys
try:
number_processes = sys.argv[1]
mpi_args = ['mpirun', '-np', f'{number_processes}']
print(f"\n\nMPI enabled with {number_processes} processes")
except IndexError:
mpi_args = None
print("\n\nMPI not used (no process count provided, running in serial)\n\n")

import warnings
warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -113,7 +122,7 @@ def update_params(updates):
# Sec. 5: Running OpenMC
# **************************************************************************************************************************
heat_flux_monitor = monitor_heat_flux(params)
run_openmc(build_openmc_model_HPMR, heat_flux_monitor, params)
run_openmc(build_openmc_model_HPMR, heat_flux_monitor, params, mpi_args)
fuel_calculations(params) # calculate the fuel mass and SWU

# **************************************************************************************************************************
Expand Down
19 changes: 14 additions & 5 deletions examples/watts_exec_LTMR.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
from reactor_engineering_evaluation.vessels_calcs import *
from reactor_engineering_evaluation.tools import *
from cost.cost_estimation import detailed_bottom_up_cost_estimate
import os
import sys
try:
number_processes = sys.argv[1]
mpi_args = ['mpirun', '-np', f'{number_processes}']
print(f"\n\nMPI enabled with {number_processes} processes")
except IndexError:
mpi_args = None
print("\n\nMPI not used (no process count provided, running in serial)\n\n")

import warnings
warnings.filterwarnings("ignore")
Expand All @@ -33,9 +42,9 @@ def update_params(updates):
# **************************************************************************************************************************

update_params({
'plotting': "Y", # "Y" or "N": Yes or No
'cross_sections_xml_location': '/projects/MRP_MOUSE/openmc_data/endfb-viii.0-hdf5/cross_sections.xml', # on INL HPC
'simplified_chain_thermal_xml': '/projects/MRP_MOUSE/openmc_data/simplified_thermal_chain11.xml' # on INL HPC
'plotting': "N", # "Y" or "N": Yes or No
'cross_sections_xml_location': '/hpc-common/data/openmc/endfb-viii.0-hdf5/cross_sections.xml', # on INL HPC
'simplified_chain_thermal_xml': '/home/garcsamu/OpenMC/data/chain_casl_pwr.xml' # on INL HPC
})

# **************************************************************************************************************************
Expand Down Expand Up @@ -112,7 +121,7 @@ def update_params(updates):
# **************************************************************************************************************************

heat_flux_monitor = monitor_heat_flux(params)
run_openmc(build_openmc_model_LTMR, heat_flux_monitor, params)
run_openmc(build_openmc_model_LTMR, heat_flux_monitor, params, mpi_args)
fuel_calculations(params) # calculate the fuel mass and SWU

# **************************************************************************************************************************
Expand Down Expand Up @@ -280,6 +289,6 @@ def update_params(updates):
# **************************************************************************************************************************
params['Number of Samples'] = 100 # Accounting for cost uncertainties
# Estimate costs using the cost database file and save the output to an Excel file
estimate = detailed_bottom_up_cost_estimate('cost/Cost_Database.xlsx', params, "examples/output_LTMR.xlsx")
estimate = detailed_bottom_up_cost_estimate('/home/garcsamu/OpenMC/MOUSE/cost/Cost_Database.xlsx', params, "/home/garcsamu/OpenMC/MOUSE/examples/output_LTMR.xlsx")
elapsed_time = (time.time() - time_start) / 60 # Calculate execution time
print('Execution time:', np.round(elapsed_time, 1), 'minutes')
11 changes: 10 additions & 1 deletion examples/watts_exec_LTMR_UO2_vs_TRIGA.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
from reactor_engineering_evaluation.vessels_calcs import *
from reactor_engineering_evaluation.tools import *
from cost.cost_estimation import parametric_studies
import os
import sys
try:
number_processes = sys.argv[1]
mpi_args = ['mpirun', '-np', f'{number_processes}']
print(f"\n\nMPI enabled with {number_processes} processes")
except IndexError:
mpi_args = None
print("\n\nMPI not used (no process count provided, running in serial)\n\n")

import warnings
warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -111,7 +120,7 @@ def update_params(updates):
# **************************************************************************************************************************

heat_flux_monitor = monitor_heat_flux(params)
run_openmc(build_openmc_model_LTMR, heat_flux_monitor, params)
run_openmc(build_openmc_model_LTMR, heat_flux_monitor, params, mpi_args)
fuel_calculations(params) # calculate the fuel mass and SWU

# **************************************************************************************************************************
Expand Down
Loading