Skip to content

Commit ca45926

Browse files
committed
changes from @LukeSeifert's review
1 parent 398cb13 commit ca45926

File tree

4 files changed

+29
-38
lines changed

4 files changed

+29
-38
lines changed

doc/fileformatspec/reactor_input.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ Required properties: ``volume``, ``mass_flowrate``, ``power_levels``,
115115
``string``
116116

117117
:enum:
118-
``s``, ``sec``, ``min``, ``minute``, ``h``, ``hr``, ``hour``, ``d``, ``day``, ``a``, ``year``, ``MWd/kg``, ``mwd/kg``, ``MWD/KG``, ``MWD/kg``, ``MWd/KG``
118+
``s``, ``sec``, ``min``, ``minute``, ``h``, ``hr``, ``hour``, ``d``, ``day``, ``a``, ``year``, ``yr``, ``MWd/kg``, ``mwd/kg``, ``MWD/KG``, ``MWD/kg``, ``MWd/KG``

saltproc/app.py

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212

1313
from saltproc import SerpentDepcode, OpenMCDepcode, Simulation, Reactor
1414
from saltproc import Process, Sparger, Separator, Materialflow
15-
from ._schema_default import DefaultValidatingValidator
15+
from _schema_default import DefaultValidatingValidator
1616

1717

18+
_codename_map = {'serpent': SerpentDepcode,
19+
'openmc': OpenMCDepcode}
20+
1821
def run():
1922
""" Inititializes main run"""
2023
nodes, cores, saltproc_input = parse_arguments()
@@ -152,42 +155,40 @@ def read_main_input(main_inp_file):
152155

153156
input_schema = (Path(__file__).parents[0] / 'input_schema.json')
154157
with open(main_inp_file) as f:
155-
obj = json.load(f)
158+
input_parameters = json.load(f)
156159
with open(input_schema) as s:
157160
schema = json.load(s)
158161
try:
159-
DefaultValidatingValidator(schema).validate(obj)
162+
DefaultValidatingValidator(schema).validate(input_parameters)
160163
#jsonschema.validate(instance=j, schema=v)
161164
except jsonschema.exceptions.ValidationError:
162165
print("Your input file is improperly structured.\
163166
Please see saltproc/tests/test.json for an example.")
164167

165-
j = obj
166-
print(j['reactor']['timestep_type'])
167168
# Global input path
168169
input_path = (Path.cwd() / Path(f.name).parents[0])
169170

170171
# Saltproc settings
171172
process_file = str((input_path /
172-
j['proc_input_file']).resolve())
173+
input_parameters['proc_input_file']).resolve())
173174
dot_file = str((
174175
input_path /
175-
j['dot_input_file']).resolve())
176-
output_path = j['output_path']
177-
n_depletion_steps = j['n_depletion_steps']
176+
input_parameters['dot_input_file']).resolve())
177+
output_path = input_parameters['output_path']
178+
n_depletion_steps = input_parameters['n_depletion_steps']
178179

179180
# Global output path
180181
output_path = (input_path / output_path)
181-
j['output_path'] = output_path.resolve()
182+
input_parameters['output_path'] = output_path.resolve()
182183

183184
# Create output directoy if it doesn't exist
184-
if not Path(j['output_path']).exists():
185-
Path(j['output_path']).mkdir(parents=True)
185+
if not Path(input_parameters['output_path']).exists():
186+
Path(input_parameters['output_path']).mkdir(parents=True)
186187

187188
# Class settings
188-
depcode_input = j['depcode']
189-
simulation_input = j['simulation']
190-
reactor_input = j['reactor']
189+
depcode_input = input_parameters['depcode']
190+
simulation_input = input_parameters['simulation']
191+
reactor_input = input_parameters['reactor']
191192

192193
depcode_input['codename'] = depcode_input['codename'].lower()
193194
if depcode_input['codename'] == 'serpent':
@@ -243,21 +244,12 @@ def _print_simulation_input_info(simulation_input, depcode_input):
243244
def _create_depcode_object(depcode_input):
244245
"""Helper function for `run()` """
245246
codename = depcode_input.pop('codename')
246-
if codename == 'serpent':
247-
depcode = SerpentDepcode
248-
elif codename == 'openmc':
249-
depcode = OpenMCDepcode
250-
chain_file_path = depcode_input.pop('chain_file_path')
251-
depletion_settings = depcode_input.pop('depletion_settings')
252-
else:
253-
raise ValueError(
254-
f'{codename} is not a supported depletion code.'
255-
'Accepts: "serpent" or "openmc".')
247+
depcode = _codename_map[codename]
256248

257249
depcode = depcode(**depcode_input)
258250
if codename == 'openmc':
259-
depcode.chain_file_path = chain_file_path
260-
depcode.depletion_settings = depletion_settings
251+
depcode.chain_file_path = depcode_input.pop('chain_file_path')
252+
depcode.depletion_settings = depcode_input.pop('depletion_settings')
261253

262254
depcode_input['codename'] = codename
263255

@@ -298,11 +290,10 @@ def _process_main_input_reactor_params(reactor_input, n_depletion_steps, codenam
298290
raise ValueError('There must be a positive integer number'
299291
' of depletion steps. Provided'
300292
f' n_depletion_steps: {n_depletion_steps}')
301-
else:
302-
if len(depletion_timesteps) == 1:
303-
depletion_timesteps = depletion_timesteps * n_depletion_steps
304-
if len(power_levels) == 1:
305-
power_levels = power_levels * n_depletion_steps
293+
if len(depletion_timesteps) == 1:
294+
depletion_timesteps = depletion_timesteps * n_depletion_steps
295+
if len(power_levels) == 1:
296+
power_levels = power_levels * n_depletion_steps
306297

307298
if len(depletion_timesteps) != len(power_levels):
308299
raise ValueError('depletion_timesteps and power_levels length mismatch:'
@@ -323,7 +314,7 @@ def _process_main_input_reactor_params(reactor_input, n_depletion_steps, codenam
323314
depletion_timesteps /= 60 * 24
324315
elif timestep_units in ('h', 'hr', 'hour'):
325316
depletion_timesteps /= 24
326-
elif timestep_units in ('a', 'year'):
317+
elif timestep_units in ('a', 'year', 'yr'):
327318
depletion_timesteps *= 365.25
328319
else:
329320
raise IOError(f'Unrecognized time unit: {timestep_units}')

saltproc/input_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
"minItems": 1,
293293
"uniqueItems": false},
294294
"depletion_timesteps": {
295-
"description": "Depletion step length(s)",
295+
"description": "Depletion timestep size or list of timestep sizes",
296296
"type": "array",
297297
"items": { "type": "number", "minimum": 0},
298298
"minItems": 1,
@@ -305,7 +305,7 @@
305305
"timestep_units": {
306306
"description": "Timestep unit",
307307
"type": "string",
308-
"enum": ["s", "sec", "min", "minute", "h", "hr", "hour", "d", "day", "a", "year", "MWd/kg", "mwd/kg", "MWD/KG", "MWD/kg", "MWd/KG"]
308+
"enum": ["s", "sec", "min", "minute", "h", "hr", "hour", "d", "day", "a", "yr", "year", "MWd/kg", "mwd/kg", "MWD/KG", "MWD/kg", "MWd/KG"]
309309
}
310310
},
311311
"default": {},

saltproc/openmc_depcode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class OpenMCDepcode(Depcode):
3737
inactive_cycles : int
3838
Number of inactive cycles.
3939
depletion_settings : dict
40-
...
40+
Keyword arguments to pass to :func:`openmc.model.deplete()`.
4141
chain_file_path : str
4242
Path to depletion chain file
4343
@@ -143,7 +143,7 @@ def run_depletion_step(self, cores, nodes):
143143
self.runtime_inputfile['geometry'],
144144
'--settings',
145145
self.runtime_inputfile['settings'],
146-
'--tallites',
146+
'--tallies',
147147
self.runtime_inputfile['tallies'],
148148
'--directory',
149149
str(self.output_path))

0 commit comments

Comments
 (0)