Skip to content

Commit

Permalink
write_mat_file() -> update_depleted_materials()
Browse files Browse the repository at this point in the history
- docstring changes
- associated testfile changes
  • Loading branch information
yardasol committed Nov 7, 2022
1 parent 93c0a1c commit ed7b8fb
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion doc/releasenotes/v0.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Python API Changes
- ``run_depcode()`` → ``run_depletion_step()``

- ``OpenMCDepcode`` is a ``Depcode`` subclass that interfaces with ``openmc``. This class implements the following functions
- ``run_depcode()``
- ``run_depletion_step()``
- ``switch_to_next_geometry()``
- ``write_depcode_input()``
- ``write_depletion_settings()``
Expand Down
2 changes: 1 addition & 1 deletion saltproc/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def write_depcode_input(self, reactor, dep_step, restart):
"""

@abstractmethod
def write_mat_file(self, dep_dict, dep_end_time):
def update_depleted_materials(self, dep_dict, dep_end_time):
"""Writes the iteration input file containing the burnable materials
composition used in depletion runs and updated after each depletion
step.
Expand Down
4 changes: 2 additions & 2 deletions saltproc/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def run():
print("Removed mass [g]:", extracted_mass)
# Store in DB after reprocessing and refill (right before next depl)
simulation.store_after_repr(mats, waste_and_feed_streams, dep_step)
depcode.write_mat_file(mats, simulation.burn_time)
depcode.update_depleted_materials(mats, simulation.burn_time)
del mats, waste_streams, waste_and_feed_streams, extracted_mass
gc.collect()
# Switch to another geometry?
Expand Down Expand Up @@ -520,7 +520,7 @@ def refill_materials(mats, extracted_mass, waste_streams, process_file):
process_file : str
Path to the `.json` file describing the fuel reprocessing components.
Returns
Returns
-------
waste_streams : dict of str to dict
Superset of the input parameter `waste_streams`. Dictionary has
Expand Down
2 changes: 1 addition & 1 deletion saltproc/openmc_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def write_depletion_settings(self, reactor, current_depstep_idx):
with open(self.iter_inputfile['depletion_settings'], 'w') as f:
f.writelines(json_dep_settings)

def write_mat_file(self, dep_dict, dep_end_time):
def update_depleted_materials(self, dep_dict, dep_end_time):
"""Writes the iteration input file containing the burnable materials
composition used in OpenMC depletion runs and updated after each
depletion step.
Expand Down
46 changes: 21 additions & 25 deletions saltproc/serpent_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,40 +518,36 @@ def write_depcode_input(self, reactor, dep_step, restart):
out_file.writelines(data)
out_file.close()

def write_mat_file(self, dep_dict, dep_end_time):
"""Writes the iteration input file containing the burnable materials
composition used in Serpent2 runs and updated after each depletion
step.
def update_depleted_materials(self, mats, dep_end_time):
"""Update material file with reprocessed material compositions.
Parameters
----------
dep_dict : dict of str to Materialflow
Dictionary that contains `Materialflow` objects.
mats : dict of str to Materialflow
Dictionary containing reprocessed material compositions
``key``
Name of burnable material.
``value``
`Materialflow` object holding composition and properties.
:class:`Materialflow` object holding composition and properties.
dep_end_time : float
Current time at the end of the depletion step (d).
"""

matf = open(self.iter_matfile, 'w')
matf.write('%% Material compositions (after %f days)\n\n'
% dep_end_time)
nuc_code_map = self.map_nuclide_code_zam_to_serpent()
for key, value in dep_dict.items():
matf.write('mat %s %5.9E burn 1 fix %3s %4i vol %7.5E\n' %
(key,
-dep_dict[key].density,
'09c',
dep_dict[key].temp,
dep_dict[key].vol))
for nuc_code, wt_frac in dep_dict[key].comp.items():
# Transforms iso name from zas to zzaaam and then to SERPENT
iso_name_serpent = pyname.zzaaam(nuc_code)
matf.write(' %9s %7.14E\n' %
(nuc_code_map[iso_name_serpent],
-wt_frac))
matf.close()
with open(self.iter_matfile, 'w') as f:
f.write('%% Material compositions (after %f days)\n\n'
% dep_end_time)
nuc_code_map = self.map_nuclide_code_zam_to_serpent()
for name, mat in mats.items():
f.write('mat %s %5.9E burn 1 fix %3s %4i vol %7.5E\n' %
(name,
-mat.density,
'09c',
mat.temp,
mat.vol))
for nuc_code, mass_fraction in mat.comp.items():
zam_code = pyname.zzaaam(nuc_code)
f.write(' %9s %7.14E\n' %
(nuc_code_map[zam_code],
-mass_fraction))
4 changes: 2 additions & 2 deletions tests/integration_tests/file_interface_serpent/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def test_iter_input_from_template(serpent_depcode, msr):
def test_write_iter_files(serpent_depcode, msr):
mats = serpent_depcode.read_depleted_materials(True)

# write_mat_file
serpent_depcode.write_mat_file(mats, 12.0)
# update_depleted_materials
serpent_depcode.update_depleted_materials(mats, 12.0)
file = serpent_depcode.iter_matfile
file_data = serpent_depcode.read_plaintext_file(file)
assert file_data[0] == '% Material compositions (after 12.000000 days)\n'
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/run_no_reprocessing/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ def runsim_no_reproc(simulation, reactor, nsteps):
True)
simulation.store_mat_data(mats, dep_step, False)
simulation.store_run_step_info()
simulation.sim_depcode.write_mat_file(
simulation.sim_depcode.update_depleted_materials(
mats,
simulation.burn_time)

0 comments on commit ed7b8fb

Please sign in to comment.