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

Resonace Covariance Module #1024

Merged
merged 59 commits into from
Aug 3, 2018
Merged
Show file tree
Hide file tree
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 Dec 15, 2017
468f48c
Merge remote-tracking branch 'upstream/develop' into develop
icmeyer Jan 18, 2018
8bd02e7
Limited functionality for MLBW/SLBW covariances
icmeyer Jan 30, 2018
03c7f8b
Merge remote-tracking branch 'upstream/develop' into develop
icmeyer Jan 30, 2018
b6082ac
Added some capability for LCOMP=2 format
icmeyer Feb 1, 2018
27b6abe
Added capability for LCOMP=0
icmeyer Feb 6, 2018
8687875
Merge remote-tracking branch 'upstream/develop' into develop
icmeyer Feb 6, 2018
c27aeb3
fixed an issue causing LCOMP=2 to fail
icmeyer Feb 7, 2018
c298f2e
Merge remote-tracking branch 'remotes/upstream/develop' into develop
icmeyer Feb 23, 2018
756690c
Sampling covariance working for one nuclide
icmeyer Mar 20, 2018
00b12a1
Sampling for almost all possible File 32
icmeyer Mar 20, 2018
9156410
added function to handle dicts of values
icmeyer Apr 6, 2018
1d8ac57
removed print statements
icmeyer Apr 6, 2018
77b5149
Added more resonance sampling capability
icmeyer Apr 10, 2018
0a1408d
Sampling and reconstructing working for large files
icmeyer Apr 17, 2018
9e321f7
Fixed l-values, added subset capability
icmeyer May 29, 2018
a85829e
more l-value changes
icmeyer Jun 21, 2018
3647306
Restructuring of classes, better handling of file 2 contribution
icmeyer Jul 3, 2018
a0182e1
Sampling and subset functions working
icmeyer Jul 3, 2018
1845edb
Fixed a lot of doc strings, jupyter example
icmeyer Jul 5, 2018
0bcb6f8
Pull from upstream before testing
icmeyer Jul 5, 2018
84ef96c
added reconstruction ability for resonance samples
icmeyer Jul 6, 2018
e88f8cd
Small change to endf parser
icmeyer Jul 6, 2018
6b836a1
Fixed MLBW sample reconstruction
icmeyer Jul 6, 2018
27c9d3c
MLBW test added
icmeyer Jul 16, 2018
ebd66a4
Added tests for RM covariance
icmeyer Jul 17, 2018
447d85a
some spelling
icmeyer Jul 17, 2018
b197b2b
Some cleanup of dependencies
icmeyer Jul 17, 2018
219ea89
style
icmeyer Jul 17, 2018
f69ab27
Added to sphinx autodocs
icmeyer Jul 17, 2018
1963fbe
More docs work
icmeyer Jul 17, 2018
416a89c
added example notebook for covariance module
icmeyer Jul 17, 2018
be5b111
removed changes to reconstruction functions for pull request
icmeyer Jul 17, 2018
8956f2a
Some cleanup for pr
icmeyer Jul 17, 2018
07e481b
Fixed docs by adding module to imports within [data]
icmeyer Jul 18, 2018
35baf51
changed to sphinx_numfig
icmeyer Jul 18, 2018
7647573
removed parsing of blanks in endf
icmeyer Jul 18, 2018
15ffa56
Style
icmeyer Jul 18, 2018
1beab30
even more style
icmeyer Jul 19, 2018
c22b36e
Style and changed sampling to produce ResonanceRange objects
icmeyer Jul 19, 2018
e485211
More reconstruction fixes
icmeyer Jul 19, 2018
9ad8dab
Fixes to tests
icmeyer Jul 19, 2018
d148c24
Take advantage of np.random.multivariate size option for multiple sam…
icmeyer Jul 19, 2018
fde13a9
Style and change of __init__ methods
icmeyer Jul 19, 2018
81a15a9
Stopped loop from erroneously adding range for unresolved paramaters …
icmeyer Jul 20, 2018
010acb8
added warning for sampling/reconstruction
icmeyer Jul 20, 2018
5381ad4
Style, changed sampling/subset methods to return new objects
icmeyer Jul 23, 2018
e2a27f2
Restructured ResonanceCovarianceRange class to contain corresponding …
icmeyer Jul 23, 2018
8c320cf
Changed tests to reflect changes in module
icmeyer Jul 23, 2018
6b82852
Removed print statements from test
icmeyer Jul 24, 2018
78a411e
Fix of sampling routine, change dataframe .as_matrix to .values
icmeyer Jul 25, 2018
1bf5e7b
more changes to sampling
icmeyer Jul 25, 2018
3626d8e
Condensed sampling method
icmeyer Jul 27, 2018
28414ef
Changed __copy__ method of ResonanceRange to mark parameters unprepared
icmeyer Jul 27, 2018
5918f5b
remove unused variable
icmeyer Jul 27, 2018
c6c47e1
Some name changes, removed redundandancies
icmeyer Jul 31, 2018
c4b28e4
Fixed naming change in tests
icmeyer Jul 31, 2018
7190792
Merge branch 'develop' of https://github.com/mit-crpg/openmc into dev…
icmeyer Aug 1, 2018
46e58ef
Added more tests for covariance module
icmeyer Aug 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Basic Usage
triso
candu
nuclear-data
nuclear-data-resonance-covariance

------------------------------------
Multi-Group Cross Section Generation
Expand Down
13 changes: 13 additions & 0 deletions docs/source/examples/nuclear-data-resonance-covariance.rst
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.
5 changes: 5 additions & 0 deletions docs/source/pythonapi/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ Resonance Data
openmc.data.MultiLevelBreitWigner
openmc.data.ReichMoore
openmc.data.RMatrixLimited
openmc.data.ResonanceCovariances
openmc.data.ResonanceCovarianceRange
openmc.data.SingleLevelBreitWignerCovariance
openmc.data.MultiLevelBreitWignerCovariance
openmc.data.ReichMooreCovariance
openmc.data.ParticlePair
openmc.data.SpinGroup
openmc.data.Unresolved
Expand Down
964 changes: 964 additions & 0 deletions examples/jupyter/nuclear-data-resonance-covariance.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions openmc/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
from .library import *
from .fission_energy import *
from .resonance import *
from .resonance_covariance import *
from .multipole import *
from .grid import *
64 changes: 63 additions & 1 deletion openmc/data/endf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -250,6 +268,50 @@ def get_tab2_record(file_obj):
return params, Tabulated2D(breakpoints, interpolation)


def get_intg_record(file_obj):
Copy link
Contributor

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)

"""
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


Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Expand Down Expand Up @@ -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.
Expand Down
24 changes: 23 additions & 1 deletion openmc/data/neutron.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .product import Product
from .reaction import Reaction, _get_photon_products_ace
from . import resonance as res
from . import resonance_covariance as res_cov
from .urr import ProbabilityTables
import openmc.checkvalue as cv
from openmc.mixin import EqualityMixin
Expand Down Expand Up @@ -148,6 +149,8 @@ class IncidentNeutron(EqualityMixin):
and the values are Reaction objects.
resonances : openmc.data.Resonances or None
Resonance parameters
resonance_covariance : openmc.data.ResonanceCovariance or None
Covariance for resonance parameters
summed_reactions : collections.OrderedDict
Contains summed cross sections, e.g., the total cross section. The keys
are the MT values and the values are Reaction objects.
Expand Down Expand Up @@ -228,6 +231,10 @@ def reactions(self):
def resonances(self):
return self._resonances

@property
def resonance_covariance(self):
return self._resonance_covariance

@property
def summed_reactions(self):
return self._summed_reactions
Expand Down Expand Up @@ -289,6 +296,12 @@ def resonances(self, resonances):
cv.check_type('resonances', resonances, res.Resonances)
self._resonances = resonances

@resonance_covariance.setter
def resonance_covariance(self, resonance_covariance):
cv.check_type('resonance covariance', resonance_covariance,
res_cov.ResonanceCovariances)
self._resonance_covariance = resonance_covariance

@summed_reactions.setter
def summed_reactions(self, summed_reactions):
cv.check_type('summed reactions', summed_reactions, Mapping)
Expand Down Expand Up @@ -744,7 +757,7 @@ def from_ace(cls, ace_or_filename, metastable_scheme='nndc'):
return data

@classmethod
def from_endf(cls, ev_or_filename):
def from_endf(cls, ev_or_filename, covariance=False):
"""Generate incident neutron continuous-energy data from an ENDF evaluation

Parameters
Expand All @@ -753,6 +766,10 @@ def from_endf(cls, ev_or_filename):
ENDF evaluation to read from. If given as a string, it is assumed to
be the filename for the ENDF file.

covariance : bool
Flag to indicate whether or not covariance data from File 32 should be
retrieved

Returns
-------
openmc.data.IncidentNeutron
Expand Down Expand Up @@ -784,6 +801,11 @@ def from_endf(cls, ev_or_filename):
if (2, 151) in ev.section:
data.resonances = res.Resonances.from_endf(ev)

if (32, 151) in ev.section and covariance:
data.resonance_covariance = (
res_cov.ResonanceCovariances.from_endf(ev, data.resonances)
)

# Read each reaction
for mf, mt, nc, mod in ev.reaction_list:
if mf == 3:
Expand Down
1 change: 1 addition & 0 deletions openmc/data/resonance.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
_reconstruct = False
import openmc.checkvalue as cv


class Resonances(object):
"""Resolved and unresolved resonance data

Expand Down
Loading