-
Notifications
You must be signed in to change notification settings - Fork 525
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
Resonace Covariance Module #1024
Merged
Merged
Changes from 50 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
f741c21
limited functionality for RM covariance only
icmeyer 468f48c
Merge remote-tracking branch 'upstream/develop' into develop
icmeyer 8bd02e7
Limited functionality for MLBW/SLBW covariances
icmeyer 03c7f8b
Merge remote-tracking branch 'upstream/develop' into develop
icmeyer b6082ac
Added some capability for LCOMP=2 format
icmeyer 27b6abe
Added capability for LCOMP=0
icmeyer 8687875
Merge remote-tracking branch 'upstream/develop' into develop
icmeyer c27aeb3
fixed an issue causing LCOMP=2 to fail
icmeyer c298f2e
Merge remote-tracking branch 'remotes/upstream/develop' into develop
icmeyer 756690c
Sampling covariance working for one nuclide
icmeyer 00b12a1
Sampling for almost all possible File 32
icmeyer 9156410
added function to handle dicts of values
icmeyer 1d8ac57
removed print statements
icmeyer 77b5149
Added more resonance sampling capability
icmeyer 0a1408d
Sampling and reconstructing working for large files
icmeyer 9e321f7
Fixed l-values, added subset capability
icmeyer a85829e
more l-value changes
icmeyer 3647306
Restructuring of classes, better handling of file 2 contribution
icmeyer a0182e1
Sampling and subset functions working
icmeyer 1845edb
Fixed a lot of doc strings, jupyter example
icmeyer 0bcb6f8
Pull from upstream before testing
icmeyer 84ef96c
added reconstruction ability for resonance samples
icmeyer e88f8cd
Small change to endf parser
icmeyer 6b836a1
Fixed MLBW sample reconstruction
icmeyer 27c9d3c
MLBW test added
icmeyer ebd66a4
Added tests for RM covariance
icmeyer 447d85a
some spelling
icmeyer b197b2b
Some cleanup of dependencies
icmeyer 219ea89
style
icmeyer f69ab27
Added to sphinx autodocs
icmeyer 1963fbe
More docs work
icmeyer 416a89c
added example notebook for covariance module
icmeyer be5b111
removed changes to reconstruction functions for pull request
icmeyer 8956f2a
Some cleanup for pr
icmeyer 07e481b
Fixed docs by adding module to imports within [data]
icmeyer 35baf51
changed to sphinx_numfig
icmeyer 7647573
removed parsing of blanks in endf
icmeyer 15ffa56
Style
icmeyer 1beab30
even more style
icmeyer c22b36e
Style and changed sampling to produce ResonanceRange objects
icmeyer e485211
More reconstruction fixes
icmeyer 9ad8dab
Fixes to tests
icmeyer d148c24
Take advantage of np.random.multivariate size option for multiple sam…
icmeyer fde13a9
Style and change of __init__ methods
icmeyer 81a15a9
Stopped loop from erroneously adding range for unresolved paramaters …
icmeyer 010acb8
added warning for sampling/reconstruction
icmeyer 5381ad4
Style, changed sampling/subset methods to return new objects
icmeyer e2a27f2
Restructured ResonanceCovarianceRange class to contain corresponding …
icmeyer 8c320cf
Changed tests to reflect changes in module
icmeyer 6b82852
Removed print statements from test
icmeyer 78a411e
Fix of sampling routine, change dataframe .as_matrix to .values
icmeyer 1bf5e7b
more changes to sampling
icmeyer 3626d8e
Condensed sampling method
icmeyer 28414ef
Changed __copy__ method of ResonanceRange to mark parameters unprepared
icmeyer 5918f5b
remove unused variable
icmeyer c6c47e1
Some name changes, removed redundandancies
icmeyer c4b28e4
Fixed naming change in tests
icmeyer 7190792
Merge branch 'develop' of https://github.com/mit-crpg/openmc into dev…
icmeyer 46e58ef
Added more tests for covariance module
icmeyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
13 changes: 13 additions & 0 deletions
13
docs/source/examples/nuclear-data-resonance-covariance.rst
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.. _notebook_nuclear_data_resonance_covariance: | ||
|
||
================================== | ||
Nuclear Data: Resonance Covariance | ||
================================== | ||
|
||
.. only:: html | ||
|
||
.. notebook:: ../../../examples/jupyter/nuclear-data-resonance-covariance.ipynb | ||
|
||
.. only:: latex | ||
|
||
IPython notebooks must be viewed in the online HTML documentation. |
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
964 changes: 964 additions & 0 deletions
964
examples/jupyter/nuclear-data-resonance-covariance.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,24 @@ def float_endf(s): | |
return float(_ENDF_FLOAT_RE.sub(r'\1e\2', s)) | ||
|
||
|
||
def _int_endf(s): | ||
"""Convert string to int. Used for INTG records where blank entries | ||
indicate a 0. | ||
|
||
Parameters | ||
---------- | ||
s : str | ||
Integer or spaces | ||
|
||
Returns | ||
------- | ||
integer | ||
The number or 0 | ||
""" | ||
s = s.strip() | ||
return int(s) if s else 0 | ||
|
||
|
||
def get_text_record(file_obj): | ||
"""Return data from a TEXT record in an ENDF-6 file. | ||
|
||
|
@@ -250,6 +268,50 @@ def get_tab2_record(file_obj): | |
return params, Tabulated2D(breakpoints, interpolation) | ||
|
||
|
||
def get_intg_record(file_obj): | ||
""" | ||
Return data from an INTG record in an ENDF-6 file. Used to store the | ||
covariance matrix in a compact format. | ||
|
||
Parameters | ||
---------- | ||
file_obj : file-like object | ||
ENDF-6 file to read from | ||
|
||
Returns | ||
------- | ||
numpy.ndarray | ||
The correlation matrix described in the INTG record | ||
""" | ||
# determine how many items are in list and NDIGIT | ||
items = get_cont_record(file_obj) | ||
ndigit = int(items[2]) | ||
npar = int(items[3]) # Number of parameters | ||
nlines = int(items[4]) # Lines to read | ||
NROW_RULES = {2: 18, 3: 12, 4: 11, 5: 9, 6: 8} | ||
nrow = NROW_RULES[ndigit] | ||
|
||
# read lines and build correlation matrix | ||
corr = np.identity(npar) | ||
for i in range(nlines): | ||
line = file_obj.readline() | ||
ii = _int_endf(line[:5]) - 1 # -1 to account for 0 indexing | ||
jj = _int_endf(line[5:10]) - 1 | ||
factor = 10**ndigit | ||
for j in range(nrow): | ||
if jj+j >= ii: | ||
break | ||
element = _int_endf(line[11+(ndigit+1)*j:11+(ndigit+1)*(j+1)]) | ||
if element > 0: | ||
corr[ii, jj] = (element+0.5)/factor | ||
elif element < 0: | ||
corr[ii, jj] = (element-0.5)/factor | ||
|
||
# Symmetrize the correlation matrix | ||
corr = corr + corr.T - np.diag(corr.diagonal()) | ||
return corr | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete one blank line here |
||
def get_evaluations(filename): | ||
"""Return a list of all evaluations within an ENDF file. | ||
|
||
|
@@ -288,7 +350,7 @@ class Evaluation(object): | |
Attributes | ||
---------- | ||
info : dict | ||
Miscallaneous information about the evaluation. | ||
Miscellaneous information about the evaluation. | ||
target : dict | ||
Information about the target material, such as its mass, isomeric state, | ||
whether it's stable, and whether it's fissionable. | ||
|
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
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
Oops, something went wrong.
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.
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.
Add another blank line before this function (PEP8: 2 lines between functions/classes at top level)