Depletion Chain File with ENDF-B-7.0

Decay, Neutron fission yield & Neutron reaction sublibrary files are taken from NNDC-ENDF-b7.0.

AssertionError                            Traceback (most recent call last)
<ipython-input-9-e1cb954a0bff> in <module>
----> 1 chain = openmc.deplete.Chain.from_endf(decay_files, nfy_files, neutron_files)
      2 chain.export_to_xml('chain_endfb70.xml')

~/anaconda3/envs/openmc12/lib/python3.8/site-packages/openmc/deplete/chain.py in from_endf(cls, decay_files, fpy_files, neutron_files, progress)
    298         decay_data = {}
    299         for f in decay_files:
--> 300             data = openmc.data.Decay(f)
    301             # Skip decay data for neutron itself
    302             if data.nuclide['atomic_number'] == 0:

~/anaconda3/envs/openmc12/lib/python3.8/site-packages/openmc/data/decay.py in __init__(self, ev_or_filename)
    315             ev = ev_or_filename
    316         else:
--> 317             ev = Evaluation(ev_or_filename)
    318 
    319         file_obj = StringIO(ev.section[8, 457])

~/anaconda3/envs/openmc12/lib/python3.8/site-packages/openmc/data/endf.py in __init__(self, filename_or_obj)
    446             fh.close()
    447 
--> 448         self._read_header()
    449 
    450     def __repr__(self):

~/anaconda3/envs/openmc12/lib/python3.8/site-packages/openmc/data/endf.py in _read_header(self)
    477         self.target['isomeric_state'] = m = items[3]
    478         self.info['format'] = items[5]
--> 479         assert self.info['format'] == 6
    480 
    481         # Set correct excited state for Am242_m1, which is wrong in ENDF/B-VII.1

What’s the solution in case of ENDF/B-VII.0?

The ENDF/B-VII.0 decay file is missing a record at the beginning. You can fix it with the following:

with open('dec-ENDF-VII0.endf', 'r') as a, open('dec-ENDF-VII0_fixed.endf', 'w' as b:
    b.write(' '*70 + ' 1  0    0\n')
    b.write(a.read())

Then, to actually get all the individual evaluations inside the file, run

decay_evals = openmc.data.endf.get_evaluations('dec-ENDF-VII0_fixed.endf')
...

openmc.deplete.Chain.from_endf(decay_evals, ...)
1 Like

@paulromano Still got the same error.

In [10]: decay_evals = openmc.data.endf.get_evaluations('dec-ENDF-VII0_fixed.endf')
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-10-0edcfa40da84> in <module>
----> 1 decay_evals = openmc.data.endf.get_evaluations('dec-ENDF-VII0_fixed.endf')

~/anaconda3/envs/openmc12/lib/python3.8/site-packages/openmc/data/endf.py in get_evaluations(filename)
    361                 break
    362             fh.seek(pos)
--> 363             evaluations.append(Evaluation(fh))
    364     return evaluations
    365 

~/anaconda3/envs/openmc12/lib/python3.8/site-packages/openmc/data/endf.py in __init__(self, filename_or_obj)
    446             fh.close()
    447 
--> 448         self._read_header()
    449 
    450     def __repr__(self):

~/anaconda3/envs/openmc12/lib/python3.8/site-packages/openmc/data/endf.py in _read_header(self)
    477         self.target['isomeric_state'] = m = items[3]
    478         self.info['format'] = items[5]
--> 479         assert self.info['format'] == 6
    480 
    481         # Set correct excited state for Am242_m1, which is wrong in ENDF/B-VII.1

AssertionError: 

Sorry, there was a mistake in my code above for writing a “fixed” file (I was missing a newline character before). I’ve editing the post above so it should be correct now.

1 Like

This time It creates an empty file.

In [5]: chain = openmc.deplete.Chain.from_endf(decay_files, nfy_files, neutron_files)
   ...: chain.export_to_xml('chain_endfb70.xml')
Processing neutron sub-library files...
Processing decay sub-library files...
Processing fission product yield sub-library files...
Creating depletion_chain...

In [6]: 

I’m not sure what’s happening in your case. When I try to generate a chain using all ENDF/B-VII.0, I run into an error due to a negative uncertainty in one of the decay files. I got around this by making a temporary change in OpenMC:

diff --git a/openmc/data/decay.py b/openmc/data/decay.py
index 3e7d9599c..f669a3ed5 100644
--- a/openmc/data/decay.py
+++ b/openmc/data/decay.py
@@ -429,7 +429,10 @@ class Decay(EqualityMixin):
                             if len(values) >= 8:
                                 di['total_internal_conversion'] = ufloat(*values[6:8])
                             if len(values) == 12:
-                                di['k_shell_conversion'] = ufloat(*values[8:10])
+                                try:
+                                    di['k_shell_conversion'] = ufloat(*values[8:10])
+                                except Exception:
+                                    di['k_shell_conversion'] = None
                                 di['l_shell_conversion'] = ufloat(*values[10:12])
                         spectrum['discrete'].append(di)

After that, I’m able to successfully generate a chain. Here’s the script I used (modify as needed based on where your files are):

from pathlib import Path
import openmc.deplete
import openmc.data


endf_dir = Path('/opt/data/endf/endf-b-vii.0/')

# Fix missing TPID line in decay file
with open(endf_dir / 'decay' / 'dec-ENDF-VII0.endf', 'r') as original, open('dec_fixed.endf', 'w') as fixed:
    fixed.write(' '*70 + ' 1  0    0\n')
    fixed.write(original.read())
decay_evals = openmc.data.endf.get_evaluations('dec_fixed.endf')

# Get neutron and fission product yield evaluations
neutron_files = tuple((endf_dir / "neutrons").glob("*endf"))
nfy_files = tuple((endf_dir / "nfy").glob("*endf"))

# Generate chain
chain = openmc.deplete.Chain.from_endf(decay_evals, nfy_files, neutron_files)
chain.export_to_xml('chain_endfb70.xml')

Here’s the resulting chain file:
chain_endfb70.xml (1.7 MB)

In my case, It didn’t happen.

Thanks @paulromano

@paulromano, Could you update generate_endf71_chain_casl.py script because openmc/deplete/chain.py has undergone a number of updates over time e.g _REACTIONS :arrow_right: REACTIONS global dictionary?

Thanks for pointing that out @Pranto. I’ve just updated a pull request with changes necessary to get this script working: https://github.com/openmc-dev/data/pull/45