Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Depcode class #172

Merged
merged 37 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4ea7e4f
read_depcode_info() -> read_step_metadata(); sim_info -> step_metadata
yardasol Nov 7, 2022
152806f
update depcode unit test filenames
yardasol Nov 7, 2022
4947cd7
read_depcode_step_param() -> read_neutronics_parameters(); param -> n…
yardasol Nov 7, 2022
94b2647
read_dep_comp() -> read_depleted_materials(); variable name adjustments
yardasol Nov 7, 2022
053b64a
create_nuclide_name_map_zam_to_serpent() -> map_nuclide_code_zam_to_s…
yardasol Nov 7, 2022
93c0a1c
run_depcode() -> run_depletion_step()
yardasol Nov 7, 2022
d823203
write_mat_file() -> update_depletable_materials()
yardasol Nov 7, 2022
94f1479
cleanup nuclide code handling functions
yardasol Nov 9, 2022
d4f19e8
Merge remote-tracking branch 'upstream/master' into cleanup-depcode
yardasol Nov 10, 2022
475ff1f
change_sim_par() -> apply_neutron_settings(); cleanup read_plaintext_…
yardasol Nov 26, 2022
9ab1823
create_iter_matfile() -> create_runtime_matfile()
yardasol Nov 26, 2022
abc61f3
replace_burnup_parameters() -> set_power_load()
yardasol Nov 26, 2022
69ee50d
cleanup switch_to_next_geometry()
yardasol Nov 26, 2022
be59037
cleanup insert_path_to_geometry()
yardasol Nov 26, 2022
f5aec4e
write_depcode_input() -> write_depletion_step_input()
yardasol Nov 26, 2022
87fed81
attribute name change: iter_* -> runtime_*
yardasol Nov 26, 2022
5d98386
write_depletion_step_input() -> write_runtime_input()
yardasol Nov 26, 2022
0d6aff4
remove default path values in depcode classes
yardasol Nov 27, 2022
f6962a6
remove npop, active_cycles, inactive_cycles
yardasol Nov 27, 2022
7d41cd3
fix redudnant path specifier for runtime filenames
yardasol Nov 27, 2022
accd451
add npop, active_cycles, inactive_cycles back in; fix some path-relat…
yardasol Nov 28, 2022
c2f0852
remove cruft commented code in app.py
yardasol Nov 28, 2022
623cda3
cleanup main docstrings for depcode classes
yardasol Nov 28, 2022
ec023d8
cleanup run_depletion_step() in OpenMCDepcode
yardasol Nov 28, 2022
213f498
cleanup write_depletion_settings() and write_runtime_input() in OpenM…
yardasol Nov 28, 2022
c690927
cleanup set_power_load() in SerpentDepcode
yardasol Nov 28, 2022
84d12b5
add missing comma
yardasol Nov 28, 2022
692c418
cleanup create_runtime_matfile()
yardasol Nov 29, 2022
ac78eec
fix integration tests
yardasol Nov 29, 2022
4a38449
Add test for get_neutron_settings()
yardasol Nov 29, 2022
2cb688a
Merge remote-tracking branch 'upstream/master' into cleanup-depcode
yardasol Nov 30, 2022
4db68bf
Path.as_posix() -> str(Path)
yardasol Nov 30, 2022
660e88f
set uniqueItems=false for geo_file_paths
yardasol Nov 30, 2022
8396c2b
fix typo in file_interface_openmc
yardasol Dec 1, 2022
4a49c11
Apply suggestions from @abachma2 code review
yardasol Dec 5, 2022
ae1a740
Apply suggestions from @abachma2 code review
yardasol Dec 5, 2022
647a1d1
Add @samgdotson suggestions.
yardasol Dec 5, 2022
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
45 changes: 39 additions & 6 deletions doc/releasenotes/v0.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,60 @@ Python API Changes
longer be initialized by the user during object creation.


- New/changed classes and methods:
- New/changed classes, methods, and attributes:

- ``Depcode``

- Add `output_path` parameter.
- ``template_inputfile_path`` → ``template_input_file_path``
- Changed `iter_inputfile` and `iter_matfile` to be attributes instead of parameters
- Removed default values for `geo_files`
- Changed `iter_inputfile`, `iter_matfile` to be attributes instead of parameters
- Changed `npop`, `active_cycles`, `inactive_cycles` to be attributes instead of
yardasol marked this conversation as resolved.
Show resolved Hide resolved
- ``read_depcode_info()`` → ``read_step_metadata()``
- ``sim_info`` → ``step_metadata``
- ``read_depcode_step_param()`` → ``read_neutronics_parameters()``
- ``param`` → ``neutronics_parameters``
- ``read_dep_comp()`` → ``read_depleted_materials()``
- ``run_depcode()`` → ``run_depletion_step()``
- ``write_mat_file()`` → ``update_depletable_materials()``
- ``write_depcode_input()`` → ``write_runtime_input()``
- ``iter_inputfile`` → ``runtime_inputfile``
- ``iter_matfile`` → ``runtime_matfile``

- ``DepcodeSerpent`` → ``SerpentDepcode``

- Add `output_path` parameter.
- ``template_inputfile_path`` → ``template_input_file_path``
- Changed `iter_inputfile` and `iter_matfile` to be attributes instead of parameters
- Removed default values for `exec_path`, `template_input_file_path`, `geo_files`
- Changed `iter_inputfile`, `iter_matfile` to be attributes instead of parameters
- Changed `npop`, `active_cycles`, `inactive_cycles` to be attributes instead of
yardasol marked this conversation as resolved.
Show resolved Hide resolved
- ``read_depcode_info()`` → ``read_depletion_step_metadata()``
- ``sim_info`` → ``step_metadata``
- ``read_depcode_step_param()`` → ``read_neutronics_parameters()``
- ``param`` → ``neutronics_parameters``
- ``read_dep_comp()`` → ``read_depleted_materials()``
- ``create_nuclide_name_map_zam_to_serpent()`` → ``map_nuclide_code_zam_to_serpent()``
- ``run_depcode()`` → ``run_depletion_step()``
- ``write_mat_file()`` → ``update_depletable_materials()``
- ``get_nuc_name()`` → ``convert_nuclide_code_to_name()``
- ``convert_nuclide_name_serpent_to_zam()`` → ``convert_nuclide_code_to_zam()``
- ``change_sim_par()`` → (deleted)
- (new function) → ``get_neutron_settings()``
- ``create_iter_matfile()`` → ``create_runtime_matfile()``
- ``replace_burnup_parameters()`` → ``set_power_load()``
- ``write_depcode_input()`` → ``write_runtime_input()``
- ``iter_inputfile`` → ``runtime_inputfile``
- ``iter_matfile`` → ``runtime_matfile``


- ``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_runtime_input()``
- ``write_depletion_settings()``
- ``write_saltproc_openmc_tallies()``


- ``app.py``

- ``reprocessing()`` → ``reprocess_materials()``
Expand Down
9 changes: 3 additions & 6 deletions examples/msbr/msbr_main.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"proc_input_file": "msbr_objects.json",
"dot_input_file": "msbr.dot",
"output_path": "./data",
"output_path": "data",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this change? Is it because you've added the output path as an input parameter to the Depcode class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change just cleans up the path itself. The ./ is not necessary.

"num_depsteps": 12,
"depcode": {
"codename": "serpent",
"exec_path": "sss2",
"template_input_file_path": "./msbr.serpent",
"npop": 50,
"active_cycles": 20,
"inactive_cycles": 20,
"geo_file_paths": ["./geometry/msbr_full.ini"]
"template_input_file_path": "msbr.serpent",
"geo_file_paths": ["geometry/msbr_full.ini"]
},
"simulation": {
"sim_name": "msbr_example_simulation",
Expand Down
37 changes: 17 additions & 20 deletions examples/tap/tap_main.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
{
"proc_input_file": "tap_objects.json",
"dot_input_file": "tap.dot",
"output_path": "./data",
"output_path": "data",
"num_depsteps": 3,
"depcode": {
"codename": "serpent",
"exec_path": "sss2",
"template_input_file_path": "./tap.serpent",
"npop": 50,
"active_cycles": 20,
"inactive_cycles": 20,
"template_input_file_path": "tap.serpent",
"geo_file_paths": [
"./geometry/347_base.ini",
"./geometry/406.ini",
"./geometry/427.ini",
"./geometry/505.ini",
"./geometry/576.ini",
"./geometry/633.ini",
"./geometry/681.ini",
"./geometry/840.ini",
"./geometry/880.ini",
"./geometry/900.ini",
"./geometry/988.ini",
"./geometry/1126.ini",
"./geometry/1338.ini",
"./geometry/1498.ini",
"./geometry/1668_all.ini"
"geometry/347_base.ini",
"geometry/406.ini",
"geometry/427.ini",
"geometry/505.ini",
"geometry/576.ini",
"geometry/633.ini",
"geometry/681.ini",
"geometry/840.ini",
"geometry/880.ini",
"geometry/900.ini",
"geometry/988.ini",
"geometry/1126.ini",
"geometry/1338.ini",
"geometry/1498.ini",
"geometry/1668_all.ini"
]
},
"simulation": {
Expand Down
108 changes: 50 additions & 58 deletions saltproc/abc.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
from abc import ABC, abstractmethod

class Depcode(ABC):
"""Abstract class for interfacing with monte-carlo particle transport
codes. Contains information about input, output, geometry, and template
files for running depletion simulations. Also contains neutron
population, active, and inactive cycles. Contains methods to read template
and output files, and write new input files for the depletion code.
"""Abstract interface for running depletion steps.

Attributes
-----------
param : dict of str to type
Holds depletion step parameter information. Parameter names are keys
neutronics_parameters : dict of str to type
Holds depletion step neutronics parameters. Parameter names are keys
and parameter values are values.
sim_info : dict of str to type
Holds simulation settings information. Setting names are keys
and setting values are values.
iter_inputfile : str
Path to depletion code input file for depletion code rerunning.
iter_matfile : str
Path to iterative, rewritable material file for depletion code
rerunning. This file is modified during the simulation.
step_metadata : dict of str to type
Holds depletion code depletion step metadata. Metadata labels are keys
and metadata values are values.
runtime_inputfile : str
Path to input file used to run depletion step.
runtime_matfile : str
Path to material file containing burnable materials used to
run depletion step.
npop : int
Size of neutron population per cycle
active_cycles : int
Number of active cycles.
inactive_cycles : int
Number of inactive cycles.


"""

def __init__(self,
codename,
output_path,
exec_path,
template_input_file_path,
geo_files=None,
npop=50,
active_cycles=20,
inactive_cycles=20):
"""Initializes the Depcode object.
geo_files):
"""Initialize a Depcode object.

Parameters
----------
output_path : str
Path to results storage directory.
codename : str
Name of depletion code.
exec_path : str
Expand All @@ -48,67 +51,58 @@ def __init__(self,
Path to file that contains the reactor geometry.
List of `str` if reactivity control by
switching geometry is `On` or just `str` otherwise.
npop : int, optional
Size of neutron population per cycle for Monte Carlo.
active_cycles : int, optional
Number of active cycles.
inactive_cycles : int, optional
Number of inactive cycles.

"""
self.codename = codename
self.output_path = output_path
self.exec_path = exec_path
self.template_input_file_path = template_input_file_path
self.geo_files = geo_files
self.npop = npop
self.active_cycles = active_cycles
self.inactive_cycles = inactive_cycles
self.param = {}
self.sim_info = {}
self.iter_inputfile = './iter_input'
self.iter_matfile = './iter_mat'
self.neutronics_parameters = {}
self.step_metadata = {}
self.runtime_inputfile = None
self.runtime_matfile = None

@abstractmethod
def read_depcode_info(self):
"""Parses initial depletion code info data from depletion code
output and stores it in the `Depcode` object's ``sim_info`` attribute.
def read_step_metadata(self):
"""Reads depletion code's depletion step metadata and stores it in the
:class:`Depcode` object's :attr:`step_metadata` attribute.
"""

@abstractmethod
def read_depcode_step_param(self):
"""Parses data from depletion code output for each step and stores
it in `Depcode` object's ``param`` attributes.
def read_neutronics_parameters(self):
"""Reads depletion code's depletion step neutronics parameters and
stores them in :class:`Depcode` object's
:attr:`neutronics_parameters` attribute.
"""

@abstractmethod
def read_dep_comp(self, read_at_end=False):
"""Reads the depleted material data from the depcode simulation
and returns a dictionary with a `Materialflow` object for each
burnable material.
def read_depleted_materials(self, read_at_end=False):
"""Reads depleted materials from the depletion step results
and returns a dictionary containing them.

Parameters
----------
read_at_end : bool, optional
Controls at which moment in the depletion step to read the data.
If `True`, the function reads data at the end of the
depletion step. Otherwise, the function reads data at the
beginning of the depletion step.

Returns
-------
mats : dict of str to Materialflow
Dictionary that contains `Materialflow` objects.
depleted_materials : dict of str to Materialflow
Dictionary containing depleted materials.

``key``
Name of burnable material.
``value``
`Materialflow` object holding composition and properties.
:class:`Materialflow` object holding material composition and properties.

"""

@abstractmethod
def run_depcode(self, cores, nodes):
"""Runs depletion code as a subprocess with the given parameters.
def run_depletion_step(self, cores, nodes):
"""Runs a depletion step as a subprocess with the given parameters.

Parameters
----------
Expand All @@ -125,8 +119,8 @@ def switch_to_next_geometry(self):
"""

@abstractmethod
def write_depcode_input(self, reactor, dep_step, restart):
""" Writes prepared data into depletion code input file(s).
def write_runtime_input(self, reactor, dep_step, restart):
"""Write input file(s) for running depletion step

Parameters
----------
Expand All @@ -140,20 +134,18 @@ def write_depcode_input(self, reactor, dep_step, restart):
"""

@abstractmethod
def write_mat_file(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.
def update_depletable_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).

Expand Down
Loading