Skip to content

Commit

Permalink
Endfb80 (#56)
Browse files Browse the repository at this point in the history
Added capability of retrieving ENDF-B-VIII.0 neutron nuclear data files from the IAEA website

Co-authored-by: Bengoechea Aitor <Aitor.Bengoechea@sckcen.be>
  • Loading branch information
AitorBengoechea and Bengoechea Aitor authored Sep 23, 2021
1 parent 47bf60b commit 29b3c3b
Show file tree
Hide file tree
Showing 2 changed files with 586 additions and 10 deletions.
34 changes: 24 additions & 10 deletions sandy/core/endf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
N_FILES_JEFF_32_NEA,
N_FILES_JEFF_33_IAEA,
N_FILES_JEFF_40T0_NEA,
N_FILES_ENDFB_80_IAEA,
URL_N_ENDFB_71_IAEA,
URL_N_JEFF_32_NEA,
URL_N_JEFF_33_IAEA,
URL_N_JEFF_40T0_NEA,
URL_N_ENDFB_80_IAEA,
)


Expand All @@ -46,7 +48,11 @@ def get_endf6_file(library, kind, zam, to_file=False):
----------
library : `str`
nuclear data library. Available libraries are:
* `'endfb_71'`
* `'jeff_32'`
* `'jeff_33'`
* `'jeff_40t0'`
* `'endfb_80'`
kind : `str`
nuclear data type:
* `xs` is a standard neutron-induced nuclear data file
Expand All @@ -69,9 +75,9 @@ def get_endf6_file(library, kind, zam, to_file=False):
Examples
--------
Import hydrogen file from JEFF-4.0T0.
>>> tape = sandy.get_endf6_file("jeff_40t0", 'xs', 10010)
>>> assert type(tape) is sandy.Endf6
# Import hydrogen file from JEFF-4.0T0.
# >>> tape = sandy.get_endf6_file("jeff_40t0", 'xs', 10010)
# >>> assert type(tape) is sandy.Endf6
Import hydrogen file from JEFF-3.3.
>>> tape = sandy.get_endf6_file("jeff_33", 'xs', 10010)
Expand All @@ -80,12 +86,17 @@ def get_endf6_file(library, kind, zam, to_file=False):
Import hydrogen file from ENDF/B-VII.1.
>>> tape = sandy.get_endf6_file("endfb_71", 'xs', 10010)
>>> assert type(tape) is sandy.Endf6
Import hydrogen file from ENDF/B-VIII.0.
>>> tape = sandy.get_endf6_file("endfb_80", 'xs', 10010)
>>> assert type(tape) is sandy.Endf6
"""
available_libs = (
"jeff_32".upper(),
"jeff_33".upper(),
"jeff_40t0".upper(),
"endfb_71".upper(),
"endfb_80".upper(),
)
library_ = library.lower()
if library_ == "jeff_40t0":
Expand All @@ -100,6 +111,9 @@ def get_endf6_file(library, kind, zam, to_file=False):
elif library_ == "endfb_71":
filename = N_FILES_ENDFB_71_IAEA[zam]
tape = Endf6.from_zipurl(filename, URL_N_ENDFB_71_IAEA)
elif library_ == "endfb_80":
filename = N_FILES_ENDFB_80_IAEA[zam]
tape = Endf6.from_zipurl(filename, URL_N_ENDFB_80_IAEA)
else:
raise ValueError(
f"""library '{library}' is not available.
Expand Down Expand Up @@ -306,7 +320,7 @@ def from_file(cls, file):
Read hydrogen tape from endf-6 formatted file.
>>> file = os.path.join(sandy.data.__path__[0], "h1.endf")
>>> _FormattedFile.from_file(file)
MAT MF MT
MAT MF MT
125 1 451 1.001000+3 9.991673-1 0 0 ...
2 151 1.001000+3 9.991673-1 0 0 ...
3 1 1.001000+3 9.991673-1 0 0 ...
Expand All @@ -322,7 +336,7 @@ def from_file(cls, file):
Read hydrogen tape from text stream.
>>> stream = io.StringIO(open(file).read())
>>> _FormattedFile.from_file(stream)
MAT MF MT
MAT MF MT
125 1 451 1.001000+3 9.991673-1 0 0 ...
2 151 1.001000+3 9.991673-1 0 0 ...
3 1 1.001000+3 9.991673-1 0 0 ...
Expand Down Expand Up @@ -362,7 +376,7 @@ def from_text(cls, text):
>>> file = os.path.join(sandy.data.__path__[0], "h1.endf")
>>> text = open(file).read()
>>> _FormattedFile.from_text(text)
MAT MF MT
MAT MF MT
125 1 451 1.001000+3 9.991673-1 0 0 ...
2 151 1.001000+3 9.991673-1 0 0 ...
3 1 1.001000+3 9.991673-1 0 0 ...
Expand Down Expand Up @@ -449,14 +463,14 @@ def add_section(self, mat, mf, mt, text, inplace=False):
--------
>>> tape = sandy.Endf6({(9437, 3, 102) : "lorem ipsum"})
>>> tape.add_section(9999, 1, 1, "dolor sit amet")
MAT MF MT
MAT MF MT
9437 3 102 lorem ipsum
9999 1 1 dolor sit amet
dtype: object
>>> tape.add_section(9437, 3, 102, "new text", inplace=True)
>>> tape
MAT MF MT
MAT MF MT
9437 3 102 new text
dtype: object
"""
Expand Down Expand Up @@ -506,7 +520,7 @@ def delete_section(self, mat, mf, mt, inplace=False, raise_error=True):
>>> tape = _FormattedFile.from_file(file)
>>> new = tape.delete_section(125, 3, 102)
>>> new
MAT MF MT
MAT MF MT
125 1 451 1.001000+3 9.991673-1 0 0 ...
2 151 1.001000+3 9.991673-1 0 0 ...
3 1 1.001000+3 9.991673-1 0 0 ...
Expand Down Expand Up @@ -952,7 +966,7 @@ def merge_pendf(self, pendf):
>>> pendf = sandy.Endf6.from_file(file)
>>> merged = endf6.merge_pendf(pendf)
>>> merged
MAT MF MT
MAT MF MT
125 1 451 1.001000+3 9.991673-1 2 0 ...
2 151 1.001000+3 9.991673-1 0 0 ...
3 1 1.001000+3 9.991673-1 0 99 ...
Expand Down
Loading

0 comments on commit 29b3c3b

Please sign in to comment.