Skip to content

Commit

Permalink
implement OpenMCDepcode.update_depletable_materials
Browse files Browse the repository at this point in the history
  • Loading branch information
yardasol committed Feb 2, 2023
1 parent 0c73c42 commit ff248ff
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 3,223 deletions.
18 changes: 18 additions & 0 deletions saltproc/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,23 @@ def update_depletable_materials(self, mats, dep_end_time):
"""

def read_plaintext_file(self, file_path):
"""Reads the content of a plaintext file for use by other methods.
Parameters
----------
file_path : str
Path to file.
Returns
-------
file_lines : list of str
File lines.
"""
file_lines = []
with open(file_path, 'r') as file:
file_lines = file.readlines()
return file_lines


22 changes: 22 additions & 0 deletions saltproc/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ def run():
mats = depcode.read_depleted_materials(True)
simulation.store_mat_data(mats, step_idx, False)
simulation.store_run_step_info()

# Preserve depletion and statepoint results files if using OpenMC
if depcode.codename == 'openmc':
depletion_results_path = \
depcode.output_path / f'depletion_results_{step_idx}.h5'
(depcode.output_path / 'depletion_results.h5').rename(depletion_results_path)

if step_idx != 0:
statepoint_fname = f'openmc_simulation_n0.h5'
statepoint_path = \
depcode.output_path / f'openmc_simulation_n{step_idx}.h5'
# rename "base" to "0"
if step_idx == len(msr.depletion_timesteps) - 1:
statepoint_path = \
depcode.output_path / f'openmc_simulation_n0.h5'
(depcode.output_path / 'openmc_simulation_base.h5').rename(statepoint_path)

else:
statepoint_path = depletion_results_path = \
depcode.output_path / f'openmc_simulation_base.h5'
(depcode.output_path / statepoint_fname).rename(statepoint_path)

# Reprocessing here
print("\nMass and volume of fuel before reproc: %f g, %f cm3" %
(mats['fuel'].mass,
Expand Down
29 changes: 27 additions & 2 deletions saltproc/openmc_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self,
'settings': str((output_path / 'settings.xml').resolve())}
self.runtime_matfile = str((output_path / 'materials.xml').resolve())

self._check_for_material_names(self.runtime_matfile)
self._check_for_material_names(self.template_input_file_path['materials'])

def _check_for_material_names(self, filename):
"""Checks that all materials in the material file
Expand Down Expand Up @@ -186,6 +186,7 @@ def read_depleted_materials(self, read_at_end=False):
else:
burnup = 0
depleted_materials[name].burnup = burnup
del openmc_materials, depleted_openmc_materials, starting_openmc_materials
return depleted_materials

def _create_mass_percents_dictionary(self, mat):
Expand Down Expand Up @@ -311,10 +312,11 @@ def write_runtime_input(self, reactor, depletion_step, restart):
"""

if depletion_step == 0 and not restart:
geo_file = self.geo_file_paths.pop(0)
materials = openmc.Materials.from_xml(
self.template_input_file_path['materials'])
geometry = openmc.Geometry.from_xml(
self.geo_file_paths[0], materials=materials)
geo_file, materials=materials)
settings = openmc.Settings.from_xml(
self.template_input_file_path['settings'])
self.npop = settings.particles
Expand Down Expand Up @@ -393,6 +395,29 @@ def update_depletable_materials(self, mats, dep_end_time):
Current time at the end of the depletion step (d).
"""
runtime_materials = openmc.Materials.from_xml(self.runtime_matfile)

for material in runtime_materials:
# depletable materials only
if material.name in mats.keys():
components = {}
for nuc_code, mass_fraction in mats[material.name].comp.items():
nuc_name = pyname.name(nuc_code)
# Convert nuclide names from PyNE format to OpenMC format
if nuc_name[-1] == 'M':
nuc_name = nuc_name[:-1] + '_m1'
components[nuc_name] = mass_fraction

material.set_density(mats[material.name].density)
material.volume = mats[material.name].vol
for element in material.get_elements():
material.remove_element(element)
material.add_components(components, percent_type='wo')

runtime_materials.export_to_xml(path=self.runtime_materials)
del runtime_materials
del material


def write_saltproc_openmc_tallies(self, materials, geometry):
"""
Expand Down
19 changes: 0 additions & 19 deletions saltproc/serpent_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,25 +395,6 @@ def read_neutronics_parameters(self):
self.neutronics_parameters['fission_mass_eds'] = \
res['TOT_FMASS'][1]

def read_plaintext_file(self, file_path):
"""Reads the content of a plaintext file for use by other methods.
Parameters
----------
file_path : str
Path to file.
Returns
-------
file_lines : list of str
File lines.
"""
file_lines = []
with open(file_path, 'r') as file:
file_lines = file.readlines()
return file_lines

def set_power_load(self,
file_lines,
reactor,
Expand Down
Loading

0 comments on commit ff248ff

Please sign in to comment.