-
Notifications
You must be signed in to change notification settings - Fork 6
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
Uq workflow #24
Open
SteSeg
wants to merge
23
commits into
eepeterson:master
Choose a base branch
from
SteSeg:uq_workflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Uq workflow #24
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added the engine for the TMC (and fTMC) UQ method. The code is almost all in
ofb.data
. Moreover there is theResultsFromTMC
class inread_results.py
.Here some key features:
In
data_conventions.py
it is possible to convert nuclide ids from ZAID to ZAM to GNDS formats (and vice versa) as often sandy, openmc and NJOY2016 take in different nuclide id formats (zaid_to_zam()
,get_nuclide_zaid()
,get_nuclide_gnds()
)In
sandy_wrapper.py
it is possible to call sandy to perturb cross sections. It is possible to generate perturbed ace withget_ace_files()
. It is possible to specify the reaction channel to perturb, the number of samples to generate and from which nuclear data library take the nuclear data. It is necessary to have NJOY as environment variable pointing to NJOY's package folder. Tested with NJOY2016. Theace_to_hdf5()
function deploys the openmc python api to convert the perturbed ace file to openmc-friendly hdf5 files. It is possible to have it remove the ace files in the process (remove_ace=True
).Perturb_to_hdf5()
automatically runs these two functions. The whole process generates a given amount of perturbed cross sections file for a given nuclide in a folder named after the nuclide and the nuclear data library generated in the "current working directory".EXAMPLE: use the sandy wrapper to generate 500 perturbed openmc-compatible cross section hdf5 files for Be9 from endf\b-8.0 library, using 1 process.
Functions in
modify_xs_xml.py
take care of the modification of thecross_section.xml
file that openmc reads in order to implement perturbed cross sections data.get_env_variable()
gets the path of a given environment variable (arguably, "OPENMC_CROSS_SECTIONS
").rewrite_xs_xml()
creates a copy of the cross_sections.xml file (useful for avoiding perturbing the original one associated with the env variable).perturb_xs_xml()
substitutes in a givencross_sections.xml
file (arguably, the copied one) the original path to a nuclide xs hdf5 file another one (most likely a perturbed one).EXAMPLE: create a local copy of the
cross_section.xml
file pointed by the 'OPENMC_CROSS_SECTIONS' (ofb.data.get_env_variable(var_name='OPENMC_CROSS_SECTIONS')
already embedded inofb.data.rewrite_xs_xml()
) env variable and substitute the original Be9 cross section with themy_Be9.h5
In
tmc_engine.py
there is the core of TMC-UQ algorithm. Thetmc_engine()
function takes in aopenmc.Model
object to run the UQ on. It also takes in all the necessary info to run the sandy functions. There is a preprocessing phase that generates the perturbed hdf5 files requested (it is possible to skip this part with perturb_xs=False, in the case perturbed xs hdf5 files have already been generated previously). Then it enters the TMC loop. Each step in the loop is an openmc simulation of the model with a different hdf5 file for the nuclide of choice. here what happens at every step:cross_section.xml
file to modify at each step (rewrite_xs_xml()
)statepoint.*.h5
file, extract ALL the tallies and stores them in atmc_results_{nuclide_name}.h5
in a pandas dataframe format, it saves the tallies with the same name they've been given in the openmc model adding an underscore and the tmc loop step number (e.g. "tallyname_n
", where n is the n-th tmc loop step)summary.h5
andstatepoint.*.h5
filesThere is also the
jade_sphere
model, inspired by JADE's original sphere benchmark model (more info in jade default models). The model is simple enough to run fast in a TMC algorithm and test nuclear data uncertainties (as well as the TMC-UQ workflow) with no additional complexities. It takes in a given material and gives the leakage fraction, and the flux on the material. It is possible to specify additional reactions to tally in the material (both from neutrons and photons).EXAMPLE: test the whole
tmc_engine()
worflow for Be9 with thejade_sphere
model. Includes the generation of a localcross_sections_mod.xml
copied from the original pointed by the xs env variable, generation of 500 perturbed xs hsd5 files (perturb_xs=True
) and the generation of atmc_results_Be9.h5
file. Thenreactions
argument in thejade_sphere()
model specifies for additional reactions to tally in the material other than leakage and flux, specifically for neutrons.The
ResultsFromTMC
class in read_results.py helps reading thetmc_results_{nuclidename}.h5
file. It lists all the tallies (like ALL, "tallyname_0, tallyname_1, etc.
") or only the tally names, tells the number of iterations of the TMC loop, extracts all the tally means and standard deviations in numpy array format.EXAMPLE: read the TMC results for Be9.
To do before merging:
jade_sphere
,sandy_wrapper
,tmc_engine
stats_analysis.py
data_conventions.py