-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
b2a849b
to
fc06882
Compare
consistency changes associated with this name changes
fc06882
to
4ea7e4f
Compare
…eutronics_parameters conistency changes associated with function and attribute name change
associated changes to relevant files
4a82500
to
94b2647
Compare
…erpent() - variable name adjustments in function - consitency changes in relevant test files - docstring changes
- adjust docstrings - associated changes in other files
ed7b8fb
to
0568fc6
Compare
- docstring changes - associated testfile changes
0568fc6
to
d823203
Compare
- get_nuc_name() -> convert_nuclide_code_to_name() - convert_nuclide_name_serpent_to_zam() -> convert_nuclide_code_to_zam() - docstring cleanup and fixes - consitency changes in other relevant files
a388626
to
475ff1f
Compare
3ae72f1
to
5d98386
Compare
f23bc9b
to
0d6aff4
Compare
9c9a426
to
2cb688a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few changes that I made as suggestions. This PR is 90+% renaming variables. The one change I really wanted was for saltproc/abc.py
to be renamed to something else.
saltproc/app.py
Outdated
@@ -247,12 +240,10 @@ def _create_depcode_object(depcode_input): | |||
raise ValueError( | |||
f'{depcode_input["codename"]} is not a supported depletion code') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f'{depcode_input["codename"]} is not a supported depletion code') | |
f'{codename} is not a supported depletion code. Accepts: "serpent" or "openmc".') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't make a suggestion for code that isn't modified in this PR, but you should use (on line 234)
codename = depcode_input["codename"].lower()
# instead of
codename = depcode_input["codename"]
That way your code isn't case sensitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this gets handled by JSON Schema verification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code suggestion in the first comment is still valid. Forcing lower
doesn't add any overhead really, but if you're confident then okay.
saltproc/input_schema.json
Outdated
"geo_file_paths": { | ||
"description": "Path(s) to geometry file(s) to switch to in depletion code runs", | ||
"type": "array", | ||
"items": { "type": "string"}, | ||
"minItems": 1, | ||
"uniqueItems": false | ||
"uniqueItems": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My rationale was that we will not want to switch to a geometry that we've already cycled through, but that may not actually be the case; we could 'oscillate' between a set of particular geometries. I'll change this back to false
saltproc/openmc_depcode.py
Outdated
{'geometry': (output_path / 'geometry.xml').resolve().as_posix(), | ||
'settings': (output_path / 'settings.xml').resolve().as_posix()} | ||
self.runtime_matfile = (output_path / 'materials.xml').resolve().as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it have to be posix? What if a user has a Windows machine? I think .resolve()
automatically provides the correct format.
{'geometry': (output_path / 'geometry.xml').resolve().as_posix(), | |
'settings': (output_path / 'settings.xml').resolve().as_posix()} | |
self.runtime_matfile = (output_path / 'materials.xml').resolve().as_posix() | |
{'geometry': (output_path / 'geometry.xml').resolve(), | |
'settings': (output_path / 'settings.xml').resolve()} | |
self.runtime_matfile = (output_path / 'materials.xml').resolve() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the paths as strings. I didn't think about what would happen if a user was on windows. I'll change this to str()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been changed? It's not showing up for me
parser.add_argument('--materials', | ||
type=str, | ||
default=1, | ||
help='path to openmc material \ | ||
material xml file') | ||
parser.add_argument('-geo', | ||
parser.add_argument('--geometry', | ||
type=str, | ||
default=1, | ||
help='path to openmc geometry \ | ||
xml file') | ||
parser.add_argument('-set', | ||
parser.add_argument('--settings', | ||
type=str, | ||
default=None, | ||
help='path to openmc settings \ | ||
xml file') | ||
parser.add_argument('-tal', | ||
parser.add_argument('--tallies', | ||
type=str, | ||
default=None, | ||
help='path to openmc tallies \ | ||
xml file') | ||
parser.add_argument('-dep', | ||
parser.add_argument('--depletion_settings', | ||
type=str, | ||
default=None, | ||
help='path to saltproc depletion \ | ||
settings json file') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create single-letter flags? I agree that it's clearer but you're making the CLI more cumbersome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CLI is not for the user. It is used internally for running openmc depletion via a script.
I will do this in a future PR, otherwise the changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yardasol, great work on this PR. I agree with Sam that the vast majority of this PR is documentation and function names. Things seem to be consistent across your code, and the changes do improve the readability of the documentation. I am really curious as to the benefit of making the npop
, active_cycles
, and inactive_cycles
attributes instead of in the input schema.
The two changes I requested are very small and are regarding the release notes.
@@ -1,16 +1,13 @@ | |||
{ | |||
"proc_input_file": "msbr_objects.json", | |||
"dot_input_file": "msbr.dot", | |||
"output_path": "./data", | |||
"output_path": "data", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Nuclide code in Serpent2 format (`47310.09c`) | ||
|
||
Returns | ||
------- | ||
nuc_name : str | ||
Name of nuclide in human-readable notation (`Am-242m1`). | ||
nuc_zzaaam : str | ||
Name of nuclide in `zzaaam` form (`952421`). | ||
Symbolic nuclide name (`Am242m1`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using the nuclide code for Am-242m1? Just want to make sure you're being consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. That's just a very unexpected nuclide code for Am-242m1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 3
in 47310
is Serpent's convention for metastable nuclides:
The library directory includes two entries for each nuclide, one using the standard MCNP convention (ZA.id) and another one using the element symbol and the isotope mass (e.g. 92235.03c and U-235.03c for U-235). Either name can be used to identify the nuclide in the material compositions.
The script assumes that nuclides in isomeric states are identified by setting the third digit in the ZA to 3 (e.g. 61348 for Pm-148m or 95342 for Am-242m). If other convention is used, the isomeric state number (5. entry) must be set manually.
file_lines.insert(line_idx, # Insert on 9th line | ||
'set power %5.9E dep daystep %7.5E\n' % | ||
(current_power, step_length)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these values hardcoded into the file lines? Is there any reason someone would need to use different values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The set power
card is the only way to specify depletion steps in Serpent to my knowledge. Right now, we can only use the daystep
option, but in #177 I fix this to enable use of every potential time unit a user might want to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, but what about the 5.9E and 7.5E values in there? Are those values, or a way to read in a variable value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is string formatting. The 5
in 5.9E
indicates we want to display a maximum of 5 digits before the decimal, the 9
indicates we want to display 9 digits after the decimal, and the E
indicates we display the number in scientific notation:
>>> '%5.9f' % (2.0e-2)
'0.020000000'
>>> '%5.9E' % (2.0e-2)
'2.000000000E-02'
assert nuc_code_map[380880] == '38088.09c' | ||
assert nuc_code_map[962400] == '96240.09c' | ||
assert nuc_code_map[952421] == '95342.09c' | ||
assert nuc_code_map[340831] == '340831' | ||
assert nuc_code_map[300732] == '300732' | ||
assert nuc_code_map[511262] == '511262' | ||
assert nuc_code_map[420931] == '420931' | ||
assert nuc_code_map[410911] == '410911' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious. Is there any reason you chose to test these nuclides?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are holdovers from Andrei's tests.
Co-authored-by: Amanda Bachmann <amandab7@illinois.edu>
@samgdotson bump |
Co-authored-by: Amanda Bachmann <amandab7@illinois.edu>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some changes to be addressed. In particular everywhere that forces a posix path. You're losing one of the key benefits of pathlib!
saltproc/openmc_depcode.py
Outdated
{'geometry': (output_path / 'geometry.xml').resolve().as_posix(), | ||
'settings': (output_path / 'settings.xml').resolve().as_posix()} | ||
self.runtime_matfile = (output_path / 'materials.xml').resolve().as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been changed? It's not showing up for me
file_lines.insert(line_idx, # Insert on 9th line | ||
'set power %5.9E dep daystep %7.5E\n' % | ||
(current_power, step_length)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
tests/conftest.py
Outdated
depcode.iter_inputfile = openmc_iter_inputfiles | ||
depcode.iter_matfile = (openmc_input_path / 'materials.xml').as_posix() | ||
depcode.runtime_inputfile = openmc_runtime_inputfiles | ||
depcode.runtime_matfile = (openmc_input_path / 'materials.xml').as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't catch this before, but this should also consider non-unix operating systems.
depcode.runtime_matfile = (openmc_input_path / 'materials.xml').as_posix() | |
depcode.runtime_matfile = str(openmc_input_path / 'materials.xml') |
tests/conftest.py
Outdated
@@ -28,7 +28,7 @@ def serpent_depcode(cwd): | |||
saltproc_input = (cwd / 'serpent_data' / 'tap_input.json').as_posix() | |||
_, _, _, object_input = read_main_input(saltproc_input) | |||
depcode = _create_depcode_object(object_input[0]) | |||
depcode.iter_inputfile = (cwd / 'serpent_data' / 'tap_reference').as_posix() | |||
depcode.runtime_inputfile = (cwd / 'serpent_data' / 'tap_reference').as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depcode.runtime_inputfile = (cwd / 'serpent_data' / 'tap_reference').as_posix() | |
depcode.runtime_inputfile = str(cwd / 'serpent_data' / 'tap_reference') |
tests/conftest.py
Outdated
(openmc_input_path / openmc_iter_inputfiles[key]).as_posix() | ||
for key in openmc_runtime_inputfiles: | ||
openmc_runtime_inputfiles[key] = \ | ||
(openmc_input_path / openmc_runtime_inputfiles[key]).as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(openmc_input_path / openmc_runtime_inputfiles[key]).as_posix() | |
str(openmc_input_path / openmc_runtime_inputfiles[key]) |
j = json.load(f) | ||
assert j['directory'] == Path( | ||
openmc_depcode.iter_inputfile['settings']).parents[0].as_posix() | ||
openmc_depcode.runtime_inputfile['settings']).parents[0].as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't suggest on non edited lines, but posix...
That's weird, I fixed this in this commit. Try looking at it again? |
Co-authored-by: Sam Dotson <sgd2@illinois.edu>
9db670d
to
647a1d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making changes
…depcode Cleanup `Depcode` class 5b6bf0c
Summary of changes
This PR makes several changes and improvements to the
Depcode
family of classes with the goal of improving code and documentation readability, as well as making future development and use easier by tweaking the program flow.Specifically, this PR does the following:
Remove junk default paths from depcode class parameters
Makes
npop
,active_cycles
,inactive_cycles
Depcode class attributes and removes them from the input schema.Add some default values to the input schema
Depcode
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_depcode_input()
->write_runtime_input()
write_mat_file()
->update_depletable_materials()
iter_inputfile
->runtime_inputfile
iter_matfile
->runtime_matfile
SerpentDepcode
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()
create_nuclide_name_map_zam_to_serpent()
->map_nuclide_code_zam_to_serpent()
convert_nuclide_name_serpent_to_zam()
->convert_nuclide_code_to_zam()
get_nuc_name()
->convert_nuclide_code_to_name()
removechange_sim_par()
->apply_neutron_settings()
change_sim_par()
get_neutron_settings()
create_iter_matfile()
->create_runtime_matfile()
replace_burnup_parameters()
->set_power_load()
write_depcode_input()
->write_runtime_input()
switch_to_next_geometry()
insert_path_to_geometry()
iter_inputfile
->runtime_inputfile
iter_matfile
->runtime_matfile
OpenMCDepcode
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
The following changes will be made in a PR after this one is merged:
abc.py
toabstract_depcode.py
(TODO)Types of changes
Required for Merging
Associated Issues and PRs
depcode.py
and related files #162Associated Developers
Checklist for Reviewers
Reviewers should use this link to get to the
Review Checklist before they begin their review.