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

Depcode openmc init #132

Merged
merged 141 commits into from
Jun 29, 2022
Merged

Depcode openmc init #132

merged 141 commits into from
Jun 29, 2022

Conversation

yardasol
Copy link
Contributor

@yardasol yardasol commented Feb 16, 2022

Summary of changes

This PR is the first of a series that adds OpenMC support into SaltProc. The scope of this PR is running OpenMC and handiling input files. Specifically, this PR:

  • Removes non-critical parameters from the SaltProc input file:
    • iter_inputfile
    • iter_matfile
      • Relevant changes to the examples and test suite.
      • note: these parameters are now class attributes to avoid breaking the API
  • Changes the name of the template_inputfile_path input parameter to template_inputfiles_path.
    • Relevant changes to the test suite, examples, and app.py
  • Adds depletion-code-dependent type mutability for the template_inputfiles_path through use of the allOf keywork in the input schema
  • Makes the following changes depcode.py:
    • Proper documentation for the previously undocumentat param and sim_info attributes of Depcode and DepcodeSerpent
    • iter_inputfile and iter_matfile are now class attributes instead of class parameters for all classes.
      • Relevant changes to the test suite and app.py
    • A new class, DepcodeOpenMC
      • Fully implemented functions:
        • __init__()
        • run_depcode()
          • OpenMC's depletion functionality is all through the python API. Because of this, in order to use parallelism with MPI and OpenMP, this function runs a python script, openmc_deplete.py, that loads the input files and runs the depletion simulation through OpenMC.
        • switch_to_next_geometry()
        • write_depcode_input()
        • write_depletion_settings()
        • write_openmc_tallies()

Because this is such a large PR, we'll need to split up the review process:

  • @LukeSeifert (changes due to adjusting the input file JSON schema):
    • saltproc/input_schema.json
    • examples/
      • msbr/msbr_main.json
      • tap/tap_main.json
    • saltproc/tests/
      • integration_tests/
      • const_repr/tap_main_test.json
      • no_repro/test_no_reproc_run.py
      • test.json
      • test_app.py
      • test_materialflow.py
      • test_process.py
      • test_separator.py
      • test_simulation.py
      • test_sparger.py
  • @gwenchee (additions to depcode.py)
    • saltproc/
      • input_schema.json
      • depcode.py
      • openmc_deplete.py
      • app.py
  • @abachma2 (additions to depcode.py, alt)
    • saltproc/
      • input_schema.json
      • depcode.py
      • test_depcode.py
  • @smpark7 (formatting and documentation changes)
    • doc/releasenotes/v0.5.0.rst
    • saltproc/simulation.py
    • scripts/preprocessors/generate_mat_composition/README.md

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Required for Merging

  • Build OpenMC from source in GH Actions workflow #150 has been merged
    • Any merge conflicts that appear have been resolved
  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly -> non-apidoc changes in a separate PR Expand docs #144
  • My change is a source code change
    • I have added/modified tests to cover my changes
    • I have explained why my change does not require new/modified tests
  • All new and existing tests passed.
    • CI tests pass
    • Local tests pass (including Serpent2 integration tests)
  • I have recorded my changes in the changelog for the upcoming release

Associated Issues and PRs

Associated Developers

  • Dev: @

Checklist for Reviewers

Reviewers should use this link to get to the
Review Checklist before they begin their review.

…file and iter_matfile as input parameters but maintain in the DepcodeSerpent class
@pep8speaks
Copy link
Contributor

pep8speaks commented Feb 17, 2022

Hello @yardasol! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2022-06-12 20:37:55 UTC

Copy link
Contributor

@LukeSeifert LukeSeifert left a comment

Choose a reason for hiding this comment

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

Reviewer 1 Files Reviewed

Overall looks good. There are some minor things I noticed, but I would say these files look clean. I'm not familiar with OpenMC, so if there are any typos/errors in those input files, I may have missed them.

saltproc/input_schema.json Outdated Show resolved Hide resolved
saltproc/input_schema.json Show resolved Hide resolved
saltproc/tests/test_depcode.py Show resolved Hide resolved
saltproc/tests/test_depcode.py Show resolved Hide resolved
saltproc/tests/test_sparger.py Show resolved Hide resolved
@yardasol
Copy link
Contributor Author

I'll be reviewer 2

@gwenchee bump

@yardasol yardasol requested review from abachma2 and ZoeRichter April 26, 2022 20:14
@abachma2
Copy link
Contributor

I'll review section 3.

Copy link
Contributor

@abachma2 abachma2 left a comment

Choose a reason for hiding this comment

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

Review for Part 3

Overall this looks like some really good work @yardasol! I do have some questions about things that seem missing or inconsistent.

saltproc/depcode.py Outdated Show resolved Hide resolved
saltproc/depcode.py Outdated Show resolved Hide resolved
Comment on lines +182 to +186
iter_inputfile : dict of str to str
Paths to OpenMC input files for OpenMC rerunning.
iter_matfile : str
Path to iterative, rewritable material file for OpenMC
rerunning. This file is modified during the simulation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these still used? I looks like earlier on in the file all mentions of these attributes are removed from the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are used. They used to be function parameters, but since they don't change within a simulation it makes sense to have them as attributes. Not sure where "earlier on in the file" refers to.

saltproc/depcode.py Outdated Show resolved Hide resolved
Comment on lines +237 to +245
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_depcode_step_param(self):
"""Parses data from OpenMC depletion output for each step and stores
it in `Depcode` object's ``param`` attributes.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these functions supposed to do anything? I don't see any text for them to do anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are uninplemented right now. They must be at least defined because they are abstract funtions in the Depcode abstract class.

Comment on lines +247 to +248
def read_dep_comp(self, read_at_end=False):
"""Reads the depleted material data from the OpenMC depletion
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see response above

Comment on lines +416 to +417
def write_mat_file(self, dep_dict, dep_end_time):
"""Writes the iteration input file containing the burnable materials
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see response above

saltproc/depcode.py Outdated Show resolved Hide resolved
saltproc/tests/test_depcode.py Outdated Show resolved Hide resolved
Copy link
Contributor

@gwenchee gwenchee left a comment

Choose a reason for hiding this comment

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

Hey @yardasol, overall looks good. I have some comments about some software decisions and documentation. Sorry for the delay

saltproc/depcode.py Outdated Show resolved Hide resolved
@@ -16,14 +17,24 @@ class Depcode(ABC):
population, active, and inactive cycles. Contains methods to read template
and output files, and write new input files for the depletion code.

Attributes
-----------
param : dict of str to type
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not clear what this str or type is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've expanded the docstring.

iter_matfile : str
Name of iterative, rewritable material file for depletion code
rerunning. This file is modified during the simulation.
template_inputfiles_path: str or dict of str to str
Copy link
Contributor

Choose a reason for hiding this comment

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

This description is also not clear. What str?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

template_inputfiles_path is a string or a dict where the key is a string and the value is a string.

Copy link
Contributor

@gwenchee gwenchee Apr 29, 2022

Choose a reason for hiding this comment

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

I meant that it's not clear what the str is or dict. If str, is it the solver name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've expanded the docstring.


Attributes:
-----------
param : dict of str to type
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, not clear. What str and what type? Could provide more info in the next line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I expanded the docstring.

saltproc/depcode.py Outdated Show resolved Hide resolved
class DepcodeSerpent(Depcode):
r"""Class contains information about input, output, geometry, and
template files for running Serpent2 depletion simulations.
Also contains neutrons population, active, and inactive cycles.
Contains methods to read template and output files,
write new input files for Serpent2.

Attributes
-----------
param : dict of str to type
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment. Not clear what str and type are

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I expanded the docstring.

-----------
param : dict of str to type
Holds Serpent depletion step parameter information
sim_info : dict of str to type
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment. Not clear what str and type are

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I expanded the docstring.

template_inputfile_path="reactor.serpent",
iter_inputfile="data/saltproc_reactor",
iter_matfile="data/saltproc_mat",
template_inputfiles_path="reactor.serpent",
Copy link
Contributor

Choose a reason for hiding this comment

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

I second what Amanda said about adding an _ between input and files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay it has been done

saltproc/openmc_deplete.py Outdated Show resolved Hide resolved
import argparse


def parse_arguments():
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you allowing the XML files to be in different locations? With normal OpenMC runs, users are expected to have XML files in the same path no?

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 is just for flexibility. In practice, the user doesn't call this function at all. See the DepcodeOpenMC.run_depcode function for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's also an artifact of how I've defined the template_inputfiles_path variable, which has a path for each input file. Normally OpenMC expects the material, geometry, and settings files to be names materials.xml, geometry.xml, and settings.xml respectively. In order for geometry changing to work, we need to be able to have multiple different geomery files in one directory, so they can't all be names geometry.xml. Similar, we have an initial material composition that we start the simulation with, but we also have an iteration material file for each depletion step. If both of these had the name materials.xml, they could overwrite each other.

Copy link
Contributor

@smpark7 smpark7 left a comment

Choose a reason for hiding this comment

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

Review for part 4.

Looks mostly good and clean. I added some comments for typos and for clarification on the non-critical input parameters that you're removing.

doc/releasenotes/v0.5.0.rst Outdated Show resolved Hide resolved
doc/releasenotes/v0.5.0.rst Outdated Show resolved Hide resolved
doc/releasenotes/v0.5.0.rst Outdated Show resolved Hide resolved
@yardasol
Copy link
Contributor Author

@LukeSeifert @gwenchee @smpark7 @abachma2 now that the CI is working, is this good for merge?

@yardasol
Copy link
Contributor Author

Actually this should probably be rebased since it's been open for months

@yardasol
Copy link
Contributor Author

@smpark7 I think I made the requested changes

@smpark7 smpark7 merged commit 25b85c4 into arfc:master Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants