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

Prepare Simulation and App classes for OpenMC support, rework input file structure #98

Merged
merged 120 commits into from
Feb 7, 2022

Conversation

yardasol
Copy link
Contributor

@yardasol yardasol commented Jan 13, 2022

Summary of changes

This PR has ballooned to be non-atomic. It was quicker when making the changes to do it all at once, but in the future I should
really try to keep the number of changes in a single PR down.

Because this PR is so big, we can divvy up the work into assignments.

  • Assignment 1:

  • doc/installation.rst

  • environment.yml

  • examples/msbr/msbr.serpent

  • examples/tap/tap.serpent

  • examples/tap/tap_plot.serpent

  • requirements.txt

  • saltproc/reactor.py

  • Assignment 2:

  • saltproc/input_schema.json

  • saltproc/version.py

  • saltproc/app.py

  • saltproc/tests/test.json

  • saltproc/tests/test_app.py

  • saltproc/tests/integration_tests/const_repr/test_const_reproc_run.py

  • saltproc/tests/integration_tests/const_repr/tap_main_test.json

  • saltproc/examples/tap/tap_main.json

  • saltproc/examples/msbr/msbr_main.json

  • Assignment 3:

  • saltproc/depcode.py

  • saltproc/tests/test_depcode.py

  • saltproc/tests/test_materialflow.py

  • saltproc/tests/test_process.py

  • saltproc/tests/test_separator.py

  • saltproc/tests/test_sparger.py

  • Assignment 4:

  • saltproc/simulation.py

  • saltproc/tests/test_simulation.py

  • saltproc/tests/integration_tests/no_repro/test_no_reproc_run.py

This PR addresses the issues and snags listed in #96 and #97.
This PR also resolves #77 and #42.
Resolves the rest of #44

The changes this PR makes do not preserve the current API. A comprehensive list of changes is below.

This PR adds the following tests for previously untested functions in simulation.py:

  • test_check_switch_geo_trigger
  • test_store_after_repr
  • test_store_mat_data
  • test_store_run_init_info
  • test_store_run_step_info

This PR completely restructures the input file structure using a verifiable JSON schema. I have updated all examples, unit tests, and integration tests accordingly

API change
This PR adds, edits, and changes the location of, the following class methods:

  • App.check_restart() -> Simulation.check_restart()
  • Simulation.switch_to_next_geometry -> DepcodeSerpent.switch_to_next_geometry
  • Simulation.runsim_no_reproc -> test/integration_tests/test_no_reproc_run.py::runsim_no_reproc
  • Simulation.store_run_step_info
  • Simulation.store_run_init_info
  • (new) -> Depcode.switch_to_next_geometry
  • (new) -> Depcode.read_depcode_info
  • (new) -> Depcode.read_repcode_step_param
  • DepcodeSerpent.sss_meta_zzz -> DepcodeSerpent.convert_nuclide_name_serpent_to_zam
  • DepcodeSerpent.get_tra_or_dec -> DepcodeSerpent.create_nuclide_name_map_zam_to_serpent
  • DepcodeSerpent.read_depcode_template -> DepcodeSerpent.read_plaintext_file`

API change
This PR moves (renames/adds where applicable) the following global variables from the saltproc input file into the:

  • App.depcode_inp dictionary
    • (new) -> App.depcode_inp['codename']
    • App.exec_path
    • App.template_file
    • App.neutron_pop -> App.depcode_inp['npop']
    • App.active_cycles
    • App.inactive_cycles
    • App.geo_file -> App.depcode_inp['geo_file_paths']
  • App.simulation_inp dictionary:
    • (new) -> App.simulation['sim_name']
    • App.db_file -> App.simulation['db_name']
    • App.restart_flag
    • App.adjust_geo
  • App.reactor_inp dictionary
    • (new) -> App.reactor_inp['volume']
    • (new) -> App.reactor_inp['mass_flowrate']
    • App.power_levels
    • App.depl_hist -> App.reactor_inp['dep_step_length_cumulative']

This PR also renames the following global variables in app.py:
-depsteps -> num_depsteps

This PR changes, adds, and removes (where needed) the following attributes of the

  • Depcode class:
    • template_path -> template_inputfile_path
    • input_path -> iter_inputfile
    • geo_file -> geo_files
  • Simulation class:
    • h5_file -> db_path
    • (new) -> restart_flag
    • (new) -> adjust_geo
    • iter_matfile -> (removed)

API change
This PR changes the signatures of the following functions to better make use of object data encapsulation (breaks backwards compatibility:

  • Depcode.read_dep_comp
  • Depcode.write_depcode_input
  • Depcode.write_mat_file
  • DepcodeSerpent.read_plaintext_file
  • DepcodeSerpent.create_nuclide_map_serpent_to_zam

This PR also fixes a previously unknown bug that wrote material data to the incorrect field in the .h5 database. This bug was caused by a typo I made in app.py in the second call to store_mat_data.

This PR also renames test_no_reproc_run.py::test_integration_3step_saltproc_no_reproc_heavy() to test_no_reproc_run.py::test_integration_2step_saltproc_no_reproc_heavy() because this integration test actually is checking the composition bases on two depletion steps rather than three.

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

  • 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.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
    • CI tests pass
    • Local tests pass (including Serpent2 integration tests)

Associated Issues and PRs

Associated Developers

Checklist for Reviewers

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

@pep8speaks
Copy link
Contributor

pep8speaks commented Jan 13, 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-02-07 21:09:28 UTC

@gwenchee
Copy link
Contributor

gwenchee commented Feb 4, 2022

@gwenchee raised the point that the function get_tra_or_dec isn't very well named. I agree and looked into it. In the function body, this line indicates that the function reads the .out file created by Serpent:

out_file = os.path.join('%s.out' % input_file)
        file = open(out_file, 'r')

The corresponding page on the serpent wiki tells us that this file contains the nuclide and material data. Looking inside a sample .out file, these lines give us some insight into the meaning of the function's name:

 Columns:

  1. Index
  2. Level (first occurence in transmutation paths)
  3. Name (nuclide identifier data)
  4. Library ID
  5. Primary data type: TRA = transport
                        DOS = dosimetry
                        SAB = thermal scattering
                        DEC = only decay data
                        STR = only structural data (mass)
                        PHO = photon interaction data

As stated in the function's docstring, get_tra_or_dec creates an isotope map to transform the serpent2 naming convention (zzzaaa.ttc) to "zzaaam" format.

So perhaps instead of get_tra_or_dec, a more appropriate name would be create_nuclide_map_zam_to_serpent or something similar? Thoughts @gwenchee?

Based on your description, shouldn't it be create_nuclide_map_serpent_to_zam?

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.

Assignment 2 files look good!

@yardasol
Copy link
Contributor Author

yardasol commented Feb 4, 2022

@gwenchee raised the point that the function get_tra_or_dec isn't very well named. I agree and looked into it. In the function body, this line indicates that the function reads the .out file created by Serpent:

out_file = os.path.join('%s.out' % input_file)
        file = open(out_file, 'r')

The corresponding page on the serpent wiki tells us that this file contains the nuclide and material data. Looking inside a sample .out file, these lines give us some insight into the meaning of the function's name:

 Columns:

  1. Index
  2. Level (first occurence in transmutation paths)
  3. Name (nuclide identifier data)
  4. Library ID
  5. Primary data type: TRA = transport
                        DOS = dosimetry
                        SAB = thermal scattering
                        DEC = only decay data
                        STR = only structural data (mass)
                        PHO = photon interaction data

As stated in the function's docstring, get_tra_or_dec creates an isotope map to transform the serpent2 naming convention (zzzaaa.ttc) to "zzaaam" format.
So perhaps instead of get_tra_or_dec, a more appropriate name would be create_nuclide_map_zam_to_serpent or something similar? Thoughts @gwenchee?

Based on your description, shouldn't it be create_nuclide_map_serpent_to_zam?

I made a mistake when I wrote that description. The function does indeed map nuclide names of 'zzaaam' format into Serpent 2 format:

.
.
.
                 line = line.split() 
                 iname, zzaaam = self.get_nuc_name(line[2]) 
                 map_dict.update({zzaaam: line[2]})
.
.
.

@gwenchee
Copy link
Contributor

gwenchee commented Feb 4, 2022

@yardasol Once, you rename the function, assignment 3 looks good to me for merging

@yardasol
Copy link
Contributor Author

yardasol commented Feb 7, 2022

Will merge once I verify integration tests still work with the new changes.

@ZoeRichter
Copy link
Contributor

I think my biggest question/comment was about indexing in the testing functions, so if those comments are resolved/not applicable, or you think it would be better to fix in a different PR, I think everything looks good to go.

@yardasol
Copy link
Contributor Author

yardasol commented Feb 7, 2022

@ZoeRichter can you check over the most recent commits and then merge?

@ZoeRichter
Copy link
Contributor

I think I only have the comment I just left - once that gets cleared up we should be good!

@ZoeRichter ZoeRichter merged commit d82e4f4 into arfc:master Feb 7, 2022
github-actions bot pushed a commit that referenced this pull request Feb 7, 2022
…e-simulation

Prepare `Simulation` and `App` classes for OpenMC support, rework input file structure d82e4f4
@yardasol yardasol deleted the generalize-simulation branch March 9, 2022 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants