Skip to content

Commit

Permalink
make exec_path a class attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
yardasol committed Nov 27, 2022
1 parent 5d98386 commit f23bc9b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
6 changes: 2 additions & 4 deletions saltproc/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Depcode(ABC):
step_metadata : dict of str to type
Holds depletion code depletion step metadata. Metadata labels are keys
and metadata values are values.
exec_path : str
Path to depletion code executable.
runtime_inputfile : str
Path to input file used to run depletion step.
runtime_matfile : str
Expand All @@ -25,7 +27,6 @@ class Depcode(ABC):

def __init__(self,
codename,
exec_path,
template_input_file_path,
geo_files=None,
npop=50,
Expand All @@ -37,8 +38,6 @@ def __init__(self,
----------
codename : str
Name of depletion code.
exec_path : str
Path to depletion code executable.
template_input_file_path : str or dict of str to str
Path(s) to depletion code input file(s), or a dictionary where
the input type (e.g. material, geometry, settings, etc.) as a
Expand All @@ -57,7 +56,6 @@ def __init__(self,
"""
self.codename = codename
self.exec_path = exec_path
self.template_input_file_path = template_input_file_path
self.geo_files = geo_files
self.npop = npop
Expand Down
5 changes: 3 additions & 2 deletions saltproc/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,13 @@ def _create_depcode_object(depcode_input):
raise ValueError(
f'{depcode_input["codename"]} is not a supported depletion code')

depcode = depcode(depcode_input['exec_path'],
depcode_input['template_input_file_path'],
depcode = depcode(depcode_input['template_input_file_path'],
geo_files=depcode_input['geo_file_paths'],
npop=depcode_input['npop'],
active_cycles=depcode_input['active_cycles'],
inactive_cycles=depcode_input['inactive_cycles'])
if codename != 'openmc':
depcode.exec_path = depcode_input['exec_path']

return depcode

Expand Down
3 changes: 3 additions & 0 deletions saltproc/input_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
},
"then": {
"properties": {
"exec_path": {
"description": "Path to depletion code executable",
"type": "string" },
"template_input_file_path": {
"description": "Path to Serpent template inputfile",
"type": "string",
Expand Down
7 changes: 3 additions & 4 deletions saltproc/openmc_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class OpenMCDepcode(Depcode):
step_metadata : dict of str to type
Holds OpenMC depletion step metadata. Metadata labels are keys
and metadata values are values.
exec_path : str
Path to OpenMC depletion script.
runtime_inputfile : dict of str to str
Paths to OpenMC input files used to run depletion step. Contains neutron
settings and geometry.
Expand All @@ -36,7 +38,6 @@ class OpenMCDepcode(Depcode):
"""

def __init__(self,
exec_path="openmc_deplete.py",
template_input_file_path={"geometry": "./geometry.xml",
"settings": "./settings.xml",
"chain_file": "./chain_simple.xml"},
Expand All @@ -48,8 +49,6 @@ def __init__(self,
Parameters
----------
exec_path : str
Path to OpenMC depletion script.
template_input_file_path : dict of str to str
Path to user input files (``.xml`` file for geometry,
material, and settings) for OpenMC. File type as strings
Expand All @@ -68,12 +67,12 @@ def __init__(self,
"""
super().__init__("openmc",
exec_path,
template_input_file_path,
geo_files,
npop,
active_cycles,
inactive_cycles)
self.exec_path='openmc_deplete.py'
self.runtime_inputfile = {'geometry': './geometry.xml',
'settings': './settings.xml'},
self.runtime_matfile = './materials.xml'
Expand Down
9 changes: 5 additions & 4 deletions saltproc/serpent_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class SerpentDepcode(Depcode):
step_metadata : dict of str to type
Holds Serpent2 depletion step metadata. Metadata labels are keys
and metadata values are values.
exec_path : str
Path to Serpent2 executable.
runtime_inputfile : str
Path to Serpent2 input file used to run depletion step. Contains neutron
settings and non-burnable materials.
Expand All @@ -35,7 +37,6 @@ class SerpentDepcode(Depcode):
"""

def __init__(self,
exec_path="sss2",
template_input_file_path="reactor.serpent",
geo_files=None,
npop=50,
Expand All @@ -45,8 +46,6 @@ def __init__(self,
Parameters
----------
exec_path : str
Path to Serpent2 executable.
template_input_file_path : str
Path to user input file for Serpent2
geo_files : str or list, optional
Expand All @@ -62,7 +61,6 @@ def __init__(self,
"""
super().__init__("serpent",
exec_path,
template_input_file_path,
geo_files=geo_files,
npop=npop,
Expand Down Expand Up @@ -414,6 +412,9 @@ def run_depletion_step(self, cores, nodes):
"""

if self.exec_path is None:
raise RuntimeError('Attribute exec_path needs to be set before'
'running depletion step')
args = (self.exec_path, '-omp', str(cores), self.runtime_inputfile)
print('Running %s' % (self.codename))
try:
Expand Down

0 comments on commit f23bc9b

Please sign in to comment.