Skip to content

Commit

Permalink
read_depcode_info() -> read_step_metadata(); sim_info -> step_metadata
Browse files Browse the repository at this point in the history
consistency changes associated with this name changes
  • Loading branch information
yardasol committed Nov 7, 2022
1 parent 5edaf3a commit 4ea7e4f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 64 deletions.
8 changes: 6 additions & 2 deletions doc/releasenotes/v0.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,25 @@ Python API Changes
longer be initialized by the user during object creation.


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

- ``Depcode``

- ``template_inputfile_path`` → ``template_input_file_path``
- Changed `iter_inputfile` and `iter_matfile` to be attributes instead of parameters
- ``read_depcode_info()`` → ``read_step_metadata()``
- ``sim_info`` → ``step_metadata``

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

- ``template_inputfile_path`` → ``template_input_file_path``
- Changed `iter_inputfile` and `iter_matfile` to be attributes instead of parameters
- ``read_depcode_info()`` → ``read_depletion_step_metadata()``
- ``sim_info`` → ``step_metadata``


- ``OpenMCDepcode`` is a ``Depcode`` subclass that interfaces with ``openmc``. This class implements the following functions

- ``read_depletion_step_metadata()``
- ``run_depcode()``
- ``switch_to_next_geometry()``
- ``write_depcode_input()``
Expand Down
14 changes: 7 additions & 7 deletions saltproc/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class Depcode(ABC):
param : dict of str to type
Holds depletion step parameter information. 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.
step_metadata : dict of str to type
Holds depletion code depletion step metadata. Metadata labels are keys
and metadata values are values.
iter_inputfile : str
Path to depletion code input file for depletion code rerunning.
iter_matfile : str
Expand Down Expand Up @@ -64,14 +64,14 @@ def __init__(self,
self.active_cycles = active_cycles
self.inactive_cycles = inactive_cycles
self.param = {}
self.sim_info = {}
self.step_metadata = {}
self.iter_inputfile = './iter_input'
self.iter_matfile = './iter_mat'

@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
Expand Down
12 changes: 6 additions & 6 deletions saltproc/openmc_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class OpenMCDepcode(Depcode):
param : dict of str to type
Holds depletion step parameter information. 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.
step_metadata : dict of str to type
Holds OpenMC depletion step metadata. Metadata labels are keys
and metadata values are values.
iter_inputfile : dict of str to str
Paths to OpenMC input files for OpenMC rerunning.
iter_matfile : str
Expand Down Expand Up @@ -79,9 +79,9 @@ def __init__(self,
'settings': './settings.xml'},
self.iter_matfile = './materials.xml'

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

def read_depcode_step_param(self):
Expand Down
34 changes: 17 additions & 17 deletions saltproc/serpent_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class SerpentDepcode(Depcode):
param : dict of str to type
Holds Serpent depletion step parameter information. Parameter names are
keys and parameter values are values.
sim_info : dict of str to type
Holds Serpent simulation settings information. Setting names are keys
and setting values are values.
step_metadata : dict of str to type
Holds Serpent2 depletion step metadata. Metadata labels are keys
and metadata values are values.
iter_inputfile : str
Path to Serpent2 input file for Serpent2 rerunning.
iter_matfile : str
Expand Down Expand Up @@ -302,26 +302,26 @@ def read_dep_comp(self, read_at_end=False):
self.create_nuclide_name_map_zam_to_serpent()
return mats

def read_depcode_info(self):
"""Parses initial simulation info data from Serpent2 output and stores
it in the `SerpentDepcode` object's ``sim_info`` attributes.
def read_step_metadata(self):
"""Reads Serpent2 depletion step metadata and stores it in the
:class:`SerpentDepcode` object's :attr:`step_metadata` attribute.
"""
res = serpent.parse_res(self.iter_inputfile + "_res.m")
depcode_name, depcode_ver = res['VERSION'][0].decode('utf-8').split()
self.sim_info['depcode_name'] = depcode_name
self.sim_info['depcode_version'] = depcode_ver
self.sim_info['title'] = res['TITLE'][0].decode('utf-8')
self.sim_info['depcode_input_filename'] = \
self.step_metadata['depcode_name'] = depcode_name
self.step_metadata['depcode_version'] = depcode_ver
self.step_metadata['title'] = res['TITLE'][0].decode('utf-8')
self.step_metadata['depcode_input_filename'] = \
res['INPUT_FILE_NAME'][0].decode('utf-8')
self.sim_info['depcode_working_dir'] = \
self.step_metadata['depcode_working_dir'] = \
res['WORKING_DIRECTORY'][0].decode('utf-8')
self.sim_info['xs_data_path'] = \
self.step_metadata['xs_data_path'] = \
res['XS_DATA_FILE_PATH'][0].decode('utf-8')
self.sim_info['OMP_threads'] = res['OMP_THREADS'][0]
self.sim_info['MPI_tasks'] = res['MPI_TASKS'][0]
self.sim_info['memory_optimization_mode'] = res['OPTIMIZATION_MODE'][0]
self.sim_info['depletion_timestep'] = res['BURN_DAYS'][1][0]
self.sim_info['depletion_timestep'] = res['BURN_DAYS'][1][0]
self.step_metadata['OMP_threads'] = res['OMP_THREADS'][0]
self.step_metadata['MPI_tasks'] = res['MPI_TASKS'][0]
self.step_metadata['memory_optimization_mode'] = res['OPTIMIZATION_MODE'][0]
self.step_metadata['depletion_timestep'] = res['BURN_DAYS'][1][0]
self.step_metadata['depletion_timestep'] = res['BURN_DAYS'][1][0]

def read_depcode_step_param(self):
"""Parses data from Serpent2 output for each step and stores it in
Expand Down
36 changes: 18 additions & 18 deletions saltproc/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def store_run_init_info(self):
# numpy arraw row storage for run info
# delete and make this datatype specific
# to Depcode subclasses
sim_info_dtype = np.dtype([
step_metadata_dtype = np.dtype([
('neutron_population', int),
('active_cycles', int),
('inactive_cycles', int),
Expand All @@ -383,39 +383,39 @@ def store_run_init_info(self):
('depletion_timestep', float)
])
# Read info from depcode _res.m File
self.sim_depcode.read_depcode_info()
self.sim_depcode.read_step_metadata()
# Store information about material properties in new array row
sim_info_row = (
step_metadata_row = (
self.sim_depcode.npop,
self.sim_depcode.active_cycles,
self.sim_depcode.inactive_cycles, # delete the below
self.sim_depcode.sim_info['depcode_name'],
self.sim_depcode.sim_info['depcode_version'],
self.sim_depcode.sim_info['title'],
self.sim_depcode.sim_info['depcode_input_filename'],
self.sim_depcode.sim_info['depcode_working_dir'],
self.sim_depcode.sim_info['xs_data_path'],
self.sim_depcode.sim_info['OMP_threads'],
self.sim_depcode.sim_info['MPI_tasks'],
self.sim_depcode.sim_info['memory_optimization_mode'],
self.sim_depcode.sim_info['depletion_timestep']
self.sim_depcode.step_metadata['depcode_name'],
self.sim_depcode.step_metadata['depcode_version'],
self.sim_depcode.step_metadata['title'],
self.sim_depcode.step_metadata['depcode_input_filename'],
self.sim_depcode.step_metadata['depcode_working_dir'],
self.sim_depcode.step_metadata['xs_data_path'],
self.sim_depcode.step_metadata['OMP_threads'],
self.sim_depcode.step_metadata['MPI_tasks'],
self.sim_depcode.step_metadata['memory_optimization_mode'],
self.sim_depcode.step_metadata['depletion_timestep']
)
sim_info_array = np.array([sim_info_row], dtype=sim_info_dtype)
step_metadata_array = np.array([step_metadata_row], dtype=step_metadata_dtype)

# Open or restore db and append datat to it
db = tb.open_file(
self.db_path,
mode='a',
filters=self.compression_params)
try:
sim_info_table = db.get_node(db.root, 'initial_depcode_siminfo')
step_metadata_table = db.get_node(db.root, 'initial_depcode_siminfo')
except Exception:
sim_info_table = db.create_table(
step_metadata_table = db.create_table(
db.root,
'initial_depcode_siminfo',
sim_info_array,
step_metadata_array,
"Initial depletion code simulation parameters")
sim_info_table.flush()
step_metadata_table.flush()
db.close()

def read_k_eds_delta(self, current_timestep):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/database_storage/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ def test_store_run_init_info(simulation):
"""

# read data
simulation.sim_depcode.read_depcode_info()
init_info = simulation.sim_depcode.sim_info
simulation.sim_depcode.read_step_metadata()
init_info = simulation.sim_depcode.step_metadata

# we want to keep the old path for other sims, but for this
# test we'll want a fresh db
Expand Down
24 changes: 12 additions & 12 deletions tests/unit_tests/test_depcode_serpent.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ def test_get_nuc_name(serpent_depcode):
assert serpent_depcode.get_nuc_name('491142')[0] == 'In114m2'


def test_read_depcode_info(serpent_depcode):
serpent_depcode.read_depcode_info()
assert serpent_depcode.sim_info['depcode_name'] == 'Serpent'
assert serpent_depcode.sim_info['depcode_version'] == '2.1.31'
assert serpent_depcode.sim_info['title'] == 'Untitled'
assert serpent_depcode.sim_info['depcode_input_filename'] == \
def test_read_step_metadata(serpent_depcode):
serpent_depcode.read_step_metadata()
assert serpent_depcode.step_metadata['depcode_name'] == 'Serpent'
assert serpent_depcode.step_metadata['depcode_version'] == '2.1.31'
assert serpent_depcode.step_metadata['title'] == 'Untitled'
assert serpent_depcode.step_metadata['depcode_input_filename'] == \
'/home/andrei2/Desktop/git/saltproc/develop/saltproc/data/saltproc_tap'
assert serpent_depcode.sim_info['depcode_working_dir'] == \
assert serpent_depcode.step_metadata['depcode_working_dir'] == \
'/home/andrei2/Desktop/git/saltproc/develop/saltproc'
assert serpent_depcode.sim_info['xs_data_path'] == \
assert serpent_depcode.step_metadata['xs_data_path'] == \
'/home/andrei2/serpent/xsdata/jeff312/sss_jeff312.xsdata'

assert serpent_depcode.sim_info['MPI_tasks'] == 1
assert serpent_depcode.sim_info['OMP_threads'] == 4
assert serpent_depcode.sim_info['memory_optimization_mode'] == 4
assert serpent_depcode.sim_info['depletion_timestep'] == 3.0
assert serpent_depcode.step_metadata['MPI_tasks'] == 1
assert serpent_depcode.step_metadata['OMP_threads'] == 4
assert serpent_depcode.step_metadata['memory_optimization_mode'] == 4
assert serpent_depcode.step_metadata['depletion_timestep'] == 3.0


def test_read_depcode_step_param(serpent_depcode):
Expand Down

0 comments on commit 4ea7e4f

Please sign in to comment.