Jonathan Shimwell
IAEA Consultancy Meeting on Model Code Output
&
Application Nuclear Data Form Structure
Library | Release | Processed by | Download from openmc.org | Download from openmc-data-downloader | Download ACE files and convert HDF5 | Download ENDF files and generate HDF5 | Convert local ACE files |
---|---|---|---|---|---|---|---|
CENDL | 3.1 3.2 |
generate_cendl.py | |||||
ENDF/B | VII.0 | LANL | ✓ | convert_mcnp70.py | |||
ENDF/B | VII.1 | LANL |
✓ | convert_mcnp71.py | |||
ENDF/B | VII.1 | NNDC | ✓ | ✓ | convert_nndc71.py | generate_endf.py | |
ENDF/B | VIII.0 | LANL | ✓ | convert_lib80x.py | |||
ENDF/B | VIII.0 | NNDC | ✓ | ||||
FENDL | 2.1, 3.0, 3.1a, 3.1d |
✓ (3.1d) | convert_fendl.py | ||||
JENDL | 4.0 | generate_jendl.py | |||||
JEFF | 3.2 | ✓ | convert_jeff32.py | ||||
JEFF | 3.3 | ✓ | convert_jeff33.py | ||||
TENDL | 2015, 2017, 2019 | ✓ (2019) | convert_tendl.py |
There are several ways of obtaining the cross section data in the h5 file format required for neutronics simulations.
git clone https://github.com/openmc-dev/data.git
cd data
python convert_fendl.py --release 3.1d
>> downloading, extracting and processing ...
ls
>> fendl-3.1d-ace/
>> fendl-3.1d-endf/
>> fendl-3.1d-download/
>> fendl-3.1d-hdf5/
ls fendl-3.1d-hdf5/
>> cross_sections.xml
>> neutron/
>> photon/
ls fendl-3.1d-hdf5/neutron
>> Ag107.h5
>> Ag109.h5
>> Al27.h5
>> Ar36.h5
>> ...
export OPENMC_CROSS_SECTIONS=fendl-3.1d-hdf5/cross_sections.xml
wget -O nndc-b7.1.tar.xz https://anl.box.com/shared/static/9igk353zpy8fn9ttvtrqgzvw1vtejoz6.xz
>> dowloading compressed file ...
mkdir nndc-b7.1-hdf5
tar -xf nndc-b7.1.tar.xz -C nndc-b7.1-hdf5
>> extracting compressed file ...
ll nndc-b7.1-hdf5
>>cross_sections.xml
>>neutron/
>>photon/
ll nndc-b7.1-hdf5/neutron
>>Ac225.h5
>>Ac226.h5
>>Ac227.h5
>>Ag107.h5
>>Ag109.h5
>>...
export OPENMC_CROSS_SECTIONS=nndc-b7.1-hdf5/cross_sections.xml
https://hub.docker.com/r/openmc/openmc
https://github.com/openmc-dev/openmc/actions
Contains repository for the openmc-data-downloader Python package.
Contains separate repositories for each library release
Repositories can be templated
Open source, permissively licensed (MIT) https://github.com/openmc-data-storage
Use of the openmc/openmc-dev image this contains NJOY as well
Addition of the openmc-data repo to the base image
FROM openmc/openmc:develop
RUN git clone https://github.com/openmc-dev/data.git
COPY tests tests/
ENV OPENMC_CROSS_SECTIONS=/share/cross_sections.xml
Copying test suite
See environmental variable
4 Lines
+ + =
Github action (CI) then commits the new h5 files from the share folder to the repository
Github actions (CI) build and run the new docker image
name: process_test_h5_files
on:
push:
branches:
- main
env:
PROCESS_CMD: 'python data/convert_*****.py -d /share/h5_files -r *****'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Create custom readme
run: |
python readme_writer.py
cat README.md
- name: Build and test with Docker
run: |
docker build --tag nuc_data_maker .
rm -rf h5_files
docker run -v /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}:/share nuc_data_maker /bin/bash -c "${{ env.PROCESS_CMD }} && pytest -rP tests/test_xs_in_simulations.py"
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add h5_files/*.h5
git add h5_files/cross_sections.xml
git add README.md
git commit -m "Added readme with repo name (bot commit)" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
The new docker image is then run externally with a shared volume mount
40 Lines
4 Lines
+ + =
Each h5 cross section file is then used in an OpenMC simulation
Testing the h5 file produced has converted successfully and does not cause errors during usage
import os
import unittest
import xml.etree.ElementTree as ET
import openmc
os.environ["OPENMC_CROSS_SECTIONS"] = '/share/h5_files/cross_sections.xml'
class TestH5FilesInSimulations(unittest.TestCase):
def test_simulation_runs_with_isotopes(self):
tree = ET.parse('/share/h5_files/cross_sections.xml')
root = tree.getroot()
for elem in root:
if elem.attrib['type'] == 'neutron':
isotope_name = elem.attrib['materials']
sett = openmc.Settings()
sett.batches = 100
sett.inactive = 0
sett.particles = 500
sett.run_mode = 'fixed source'
mat1 = openmc.Material(1, "pure_isotope_material")
mat1.add_nuclide(isotope_name, 1)
mat1.set_density('g/cm3', 1)
mats = openmc.Materials([mat1])
outer_surface = openmc.Sphere(r=10, boundary_type='vacuum')
cell1 = openmc.Cell(region=-outer_surface)
cell1.fill = mat1
universe = openmc.Universe(cells=[cell1])
geom = openmc.Geometry(universe)
model = openmc.model.Model(geom, mats, sett)
model.run()
40 Lines
4 Lines
39 Lines
+ + =
Gigabytes of h5 files each with their own URL endpoint
https://github.com/openmc-data-storage/FENDL-3.1d/blob/main/h5_files/neutron/Ag107.h5?raw=true
+ + =
40 Lines
4 Lines
39 Lines
Easy to install Python package
pip install openmc_data_downloader
https://github.com/openmc-data-storage/openmc_data_downloader
Knowledge of all the URLs of all the h5 files available.
Translation from user instructions to a list of h5 files to download
Internal data based that gets filtered by library / isotopes etc
{
'element': 'Zn',
'isotope': 'Zn66',
'library': 'FENDL-3.1d',
'local_file': 'FENDL-3.1d_Zn66.h5',
'remote_file': 'Zn66.h5',
'url': 'https://github.com/openmc-data-storage/FENDL-3.1d/raw/main/h5_files/neutron/Zn66.h5'
},
...
Command line usage
openmc_data_downloader --help
openmc_data_downloader -l FENDL-3.1d -i Li6
Downloads one isotope
openmc_data_downloader -l TENDL-2019 -i Li6 Li7
Downloads two isotopes
openmc_data_downloader -l TENDL-2019 -e Li
Downloads one element
openmc_data_downloader -l TENDL-2019 -e Li Si Na
Downloads two elements
openmc_data_downloader -l ENDFB-7.1-NNDC -i Be9 -d my_h5_files
Downloads to a directory
openmc_data_downloader -l TENDL-2019 -e Li Si Na -i Fe56 U235
Downloads a combination of elements and isotopes
openmc_data_downloader -l TENDL-2019 -m materials.xml
Downloads all isotopes in a materials.xml file
openmc_data_downloader -l FENDL-3.1d TENDL-2019 -i Li6 U235
Downloads isotopes with library preference
import openmc
import openmc_data_downloader as odd
mat1 = openmc.Material(1, "breeder_mat")
mat1.add_element('Pb', 84.2, percent_type='ao')
mat1.add_element('Li', 15.8, percent_type='ao')
mat1.set_density('g/cm3', 11.3)
mats = openmc.Materials([mat1])
odd.just_in_time_library_generator(
libraries='FENDL-3.1d',
materials=mat1
)
Extra import
Material
Download h5 cross section files for the materials, accepts lists or individual items
Resulting download of h5 files and setting of OPENMC_CROSS_SECTIONS environmental varible
Re-running the same Python script and h5 downloading can be skipped as they already exist
import openmc
import openmc_data_downloader as odd
mat1 = openmc.Material(1, "breeder_mat")
mat1.add_element('Pb', 84.2, percent_type='ao')
mat1.add_element('Li', 15.8, percent_type='ao')
mat1.set_density('g/cm3', 11.3)
mats = openmc.Materials([mat1])
outer_surface = openmc.Sphere(r=500, boundary_type='vacuum')
cell1 = openmc.Cell(region=-outer_surface)
cell1.fill = mat1
universe = openmc.Universe(cells=[cell1])
geom = openmc.Geometry(universe)
sett = openmc.Settings()
sett.batches = 100
sett.particles = 500
sett.run_mode = 'fixed source'
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14e6], [1])
sett.source = source
odd.just_in_time_library_generator(
libraries='FENDL-3.1d',
materials=mat1
)
model = openmc.model.Model(geom, mats, sett)
model.run()
Extra import
Materials
CSG
Settings
Point source
Download h5 cross section files for the materials
Run the simulation
Less time spent making a repo for new nuclear data
Architecture + customization = new nuclear data repo
Live demo
~ 1 min human time
OpenMC Python API
Openmc-dev data repository
Automated processing and testing via CI
Downloading of reproducible collections of isotopes
+URL endpoints for ACE and ENDF libraries
+ Run commands and containerized enviroment
+URL end points for h5 files and libraries
IncidentNeutron, from_endf and from_ace
convert*.py and generate*.py
docker build, docker run and pytest
There are several methods of obtaining the h5 cross section files needed to run OpenMC simulations.
Each method has a specific use case.
Future work