Code Monkey home page Code Monkey logo

openmc_data_downloader's Introduction

CI - Main Upload Python Package PyPI codecov

OpenMC data downloader

A Python package for downloading preprocessed cross section data in the h5 file format for use with OpenMC.

This package allows you to download a fully reproducible composite nuclear data library with one command.

There are several methods of obtaining complete data libraries for use with OpenMC, for example:

  • OpenMC.org has entire libraries downloadable as compressed files
  • OpenMC data repository scripts has scripts for automatically downloading ACE and ENDF files and generating h5 files from these inputs.

History

The package was originally conceived by Jonathan Shimwell as a means of downloading a minimal selection of data for use on continuous integration platforms. The package can also used to produce traceable and reproducible nuclear data distributions.

System Installation

To install the openmc_data_downloader you need to have Python3 installed, OpenMC is also advisable if you want to run simulations using the h5 data files but not actually mandatory if you just want to download the cross sections.

pip install openmc_data_downloader

Features

The OpenMC data downloader is able to download cross section files for isotopes from nuclear data libraries.The user specifies the nuclear data libraries in order of their preference. When an isotope is found in multiple libraries it will be downloaded from the highest preference library. This avoid duplication of isotopes and provides a reproducible nuclear data environment.

The nuclear data h5 file are downloaded from the OpenMC-data-storage repository. Prior to being added to the repository they have been automatically processed using scripts from OpenMC data repository, these scripts convert ACE and ENDF file to h5 files.

The resulting h5 files are then used in and automated test suite of simulations to help ensure they are suitable for their intended purpose.

Isotopes for downloading can be found in a variety of ways as demonstrated below. When downloading a cross_section.xml file is automatically created and h5 files are named with their nuclear data library and the isotope. This helps avoid downloading files that already exist locally and the overwrite argument can be used to control if these files are downloaded again.

Usage - command line usage

Getting a description of the input options

openmc_data_downloader --help

Downloading a single isotope from the FENDL 3.1d nuclear library

openmc_data_downloader -l FENDL-3.1d -i Li6

Downloading a multiple isotopes from the TENDL 2019 nuclear library

openmc_data_downloader -l TENDL-2019 -i Li6 Li7

Downloading a single element from the TENDL 2019 nuclear library

openmc_data_downloader -l TENDL-2019 -e Li

Downloading a multiple element from the TENDL 2019 nuclear library

openmc_data_downloader -l TENDL-2019 -e Li Si Na

Downloading h5 files from the ENDF/B 7.1 NNDC library to a specific folder (destination)

openmc_data_downloader -l ENDFB-7.1-NNDC -i Be9 -d my_h5_files

Downloading a combination of isotopes and element from the TENDL 2019 nuclear library

openmc_data_downloader -l TENDL-2019 -e Li Si Na -i Fe56 U235

Downloading all the isotopes from the TENDL 2019 nuclear library

openmc_data_downloader -l TENDL-2019 -i all

Downloading all the stable isotopes from the TENDL 2019 nuclear library

openmc_data_downloader -l TENDL-2019 -i stable

Downloading all the isotopes in a materials.xml file from the TENDL 2019 nuclear library

openmc_data_downloader -l TENDL-2019 -m materials.xml

Downloading 3 isotopes from ENDF/B 7.1 NNDC (first choice) and TENDL 2019 (second choice) nuclear library

openmc_data_downloader -l ENDFB-7.1-NNDC TENDL-2019 -i Li6 Li7 Be9

Downloading the photon only cross section for an element ENDF/B 7.1 NNDC

openmc_data_downloader -l ENDFB-7.1-NNDC -e Li -p photon 

Downloading the neutron and photon cross section for an element ENDF/B 7.1 NNDC

openmc_data_downloader -l ENDFB-7.1-NNDC -e Li -p neutron photon

Downloading the neutron cross section for elements and an SaB cross sections

openmc_data_downloader -l ENDFB-7.1-NNDC -e Be O -s c_Be_in_BeO

Usage - within a Python environment

When using the Python API the just_in_time_library_generator() function provides similar capabilities to the openmc_data_downloader terminal command. With one key difference being that just_in_time_library_generator() sets the OPENMC_CROSS_SECTIONS environmental variable to point to the newly created cross_sections.xml by default.

Downloading the isotopes present in an OpenMC material

import openmc
import openmc_data_downloader as odd

mat1 = openmc.Material()
mat1.add_element('Fe', 0.95)
mat1.add_element('C', 0.05)

mats = openmc.Materials([mat1])

mats.download_cross_section_data(
        libraries=["FENDL-3.1d"],
        set_OPENMC_CROSS_SECTIONS=True,
        particles=["neutron"],
    )

Downloading the isotopes present in an OpenMC material from two libraries but with a preference for ENDF/B 7.1 NNDC library over TENDL 2019

import openmc
import openmc_data_downloader as odd

mat1 = openmc.Material()
mat1.add_element('Fe', 0.95)
mat1.add_element('C', 0.05)

mats = openmc.Materials([mat1])

mats.download_cross_section_data(
        libraries=['ENDFB-7.1-NNDC', 'TENDL-2019'],
        set_OPENMC_CROSS_SECTIONS=True,
        particles=["neutron"],
    )

Downloading neutron cross sections for a material with an SaB

import openmc
import openmc_data_downloader as odd

my_mat = openmc.Material()
my_mat.add_element('Be', 0.5)
my_mat.add_element('O', 0.5)
my_mat.add_s_alpha_beta('Be_in_BeO')

mats = openmc.Materials([my_mat])

mats.download_cross_section_data(
        libraries=['ENDFB-7.1-NNDC', 'TENDL-2019'],
        set_OPENMC_CROSS_SECTIONS=True,
        particles=["neutron"],
)

Downloading photon and neutron cross sections for isotopes and elements from the TENDL 2019 library

import openmc
import openmc_data_downloader as odd

mat1 = openmc.Material()
mat1.add_element('Fe', 0.95)
mat1.add_element('C', 0.05)

mats = openmc.Materials([mat1])

mats.download_cross_section_data(
        libraries=['ENDFB-7.1-NNDC', 'TENDL-2019'],
        set_OPENMC_CROSS_SECTIONS=True,
        particles=["neutron", "photon"],
    )

openmc_data_downloader's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openmc_data_downloader's Issues

Add JEFF 3.2 cross sections

Neutrons for the JEFF 3.2 distribution have been processed in this repo https://github.com/openmc-data-storage/JEFF-3.2

However they need adding to the cross_sections_directory.py file like the other h5 file available.

This can be done with a large pull request or several smaller ones to the develop branch:

  • the introduction of a new variable called jeff_32_neutron_isotopes in the cross_sections_directory.py file . The varible should contains all the isotope names in this folder

  • then a small section that builds up the dictionary of information on the cross section like I've done for other neutron libraries for example

  • then the add the new collection to the existing collections on this line

  • then change the README.md file so that it has a few JEFF-3.2 examples

  • Add some tests to here and here

error caused by expanding an element

error caused when expanding a element without a cross section file set

import openmc
import openmc_data_downloader

openmc.config['cross_sections']=''

mat1 = openmc.Material()
mat1.add_element('Li', 1)
mat1.set_density('g/cm3',1)
materials=openmc.Materials([mat1])
materials.download_cross_section_data(
        libraries=["FENDL-3.1d"],
        set_OPENMC_CROSS_SECTIONS=True,
        particles=["neutron"],
    )

surf1 = openmc.Sphere(r=10, boundary_type='vacuum')
region1 = -surf1
cell1=openmc.Cell(region=region1,fill=mat1)
geometry=openmc.Geometry([cell1])

point = openmc.stats.Point((0, 0, 0))
energy = openmc.stats.Discrete([14.1e6], [1.0])
source = openmc.Source(space=point, energy=energy)

settings = openmc.Settings()
settings.source = source
settings.run_mode = 'fixed source'
settings.particles = 10000
settings.batches = 10

model = openmc.Model(geometry, materials, settings)
model.run()
ile ~/venv/openmc_env/lib/python3.8/site-packages/openmc/material.py:744, in Material.add_element(self, element, percent, percent_type, enrichment, enrichment_target, enrichment_type)
    742 # Add naturally-occuring isotopes
    743 element = openmc.Element(element)
--> 744 for nuclide in element.expand(percent,
    745                               percent_type,
    746                               enrichment,
    747                               enrichment_target,
    748                               enrichment_type):
    749     self.add_nuclide(*nuclide)

File ~/venv/openmc_env/lib/python3.8/site-packages/openmc/element.py:138, in Element.expand(self, percent, percent_type, enrichment, enrichment_target, enrichment_type, cross_sections)
    136 if cross_sections is not None:
    137     library_nuclides = set()
--> 138     tree = ET.parse(cross_sections)
    139     root = tree.getroot()
    140     for child in root.findall('library'):

File /usr/lib/python3.8/xml/etree/ElementTree.py:1202, in parse(source, parser)
   1193 """Parse XML document into element tree.

Adding data from openmc.org

As discussed briefly in #14 it would be great to have some of the h5 files that are currently found on openmc.org

To do this then there are a few stages, another base repository to template that would take a different approach to the existing template repository.

The new template would download from https://openmc.org/official-data-libraries/ then extract the contents and self commit to the repo using a GitHub action.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.