Remove option to specify multipole library outside of cross_sections.xml

This commit is contained in:
Paul Romano 2018-11-09 16:39:19 -06:00
parent ffdd37c163
commit 3246a9320e
20 changed files with 57 additions and 170 deletions

View file

@ -30,7 +30,6 @@ env:
- OMP_NUM_THREADS=2
- OPENMC_CROSS_SECTIONS=$HOME/nndc_hdf5/cross_sections.xml
- OPENMC_ENDF_DATA=$HOME/endf-b-vii.1
- OPENMC_MULTIPOLE_LIBRARY=$HOME/WMP_Library
- LD_LIBRARY_PATH=$HOME/MOAB/lib:$HOME/DAGMC/lib
- PATH=$PATH:$HOME/NJOY2016/build
- DISPLAY=:99.0

View file

@ -30,11 +30,11 @@ or using pip (recommended)::
pip install -e .[test]
It is also assumed that you have cross section data available that is pointed to
by the :envvar:`OPENMC_CROSS_SECTIONS` and :envvar:`OPENMC_MULTIPOLE_LIBRARY`
environment variables. Furthermore, to run unit tests for the :mod:`openmc.data`
module, it is necessary to have ENDF/B-VII.1 data available and pointed to by
the :envvar:`OPENMC_ENDF_DATA` environment variable. All data sources can be
obtained using the ``tools/ci/travis-before-script.sh`` script.
by the :envvar:`OPENMC_CROSS_SECTIONS` environment variables. Furthermore, to
run unit tests for the :mod:`openmc.data` module, it is necessary to have
ENDF/B-VII.1 data available and pointed to by the :envvar:`OPENMC_ENDF_DATA`
environment variable. All data sources can be obtained using the
``tools/ci/travis-before-script.sh`` script.
To execute the test suite, go to the ``tests/`` directory and run::

View file

@ -18,21 +18,6 @@ path to the XML cross section listing when in continuous-energy mode, and the
:envvar:`OPENMC_MG_CROSS_SECTIONS` environment variable will be used in
multi-group mode.
.. _multipole_library:
-------------------------------
``<multipole_library>`` Element
-------------------------------
The ``<multipole_library>`` element indicates the directory containing a
windowed multipole library. If a windowed multipole library is available,
OpenMC can use it for on-the-fly Doppler-broadening of resolved resonance range
cross sections. If this element is absent from the settings.xml file, the
:envvar:`OPENMC_MULTIPOLE_LIBRARY` environment variable will be used.
.. note:: The <temperature_multipole> element must also be set to "true" for
windowed multipole functionality.
.. _material:
----------------------

View file

@ -41,11 +41,6 @@ following environment variables are used:
user has not specified :attr:`Materials.cross_sections` (equivalently, the
:ref:`cross_sections` in :ref:`materials.xml <io_materials>`).
:envvar:`OPENMC_MULTIPOLE_LIBRARY`
Indicates the path to a directory containing windowed multipole data if the
user has not specified :attr:`Materials.multipole_library` (equivalently, the
:ref:`multipole_library` in :ref:`materials.xml <io_materials>`)
:envvar:`OPENMC_MG_CROSS_SECTIONS`
Indicates the path to the an :ref:`HDF5 file <io_mgxs_library>` that contains
multi-group cross sections if the user has not specified
@ -306,12 +301,12 @@ Windowed Multipole Data
-----------------------
OpenMC is capable of using windowed multipole data for on-the-fly Doppler
broadening. While such data is not yet available for all nuclides, an
experimental multipole library is available that contains data for 70
nuclides. To obtain this library, you can run :ref:`scripts_multipole` which
will download and extract it into a ``wmp`` directory. Once the library has been
downloaded, set the :envvar:`OPENMC_MULTIPOLE_LIBRARY` environment variable (or
the :attr:`Materials.multipole_library` attribute) to the ``wmp`` directory.
broadening. A comprehensive multipole data library containing all nuclides in
ENDF/B-VII.1 is available on `GitHub
<https://github.com/mit-crpg/WMP_Library>`_. To obtain this library, download
and unpack an archive (.zip or .tag.gz) from GitHub. Once unpacked, you can use
the :class:`openmc.data.DataLibrary` class to register the .h5 files as
described in :ref:`create_xs_library`.
--------------------------
Multi-Group Cross Sections

View file

@ -52,7 +52,6 @@ extern "C" bool dagmc; //!< indicator of DAGMC geometry
// Paths to various files
extern std::string path_cross_sections; //!< path to cross_sections.xml
extern std::string path_input; //!< directory where main .xml files resides
extern std::string path_multipole; //!< directory containing multipole files
extern std::string path_output; //!< directory where output files are written
extern std::string path_particle_restart; //!< path to a particle restart file
extern std::string path_source;
@ -62,7 +61,7 @@ extern std::string path_statepoint; //!< path to a statepoint file
extern "C" int32_t index_entropy_mesh; //!< Index of entropy mesh in global mesh array
extern "C" int32_t index_ufs_mesh; //!< Index of UFS mesh in global mesh array
extern "C" int32_t index_cmfd_mesh; //!< Index of CMFD mesh in global mesh array
extern "C" int32_t n_batches; //!< number of (inactive+active) batches
extern "C" int32_t n_inactive; //!< number of inactive batches
extern "C" int32_t gen_per_batch; //!< number of generations per batch

View file

@ -53,11 +53,6 @@ to locate HDF5 format cross section libraries if the user has not specified the
Indicates the default path to an HDF5 file that contains multi-group cross
section libraries if the user has not specified the <cross_sections> tag in
.I materials.xml\fP.
.TP
.B OPENMC_MULTIPOLE_LIBRARY
Indicates the default path to a directory containing windowed multipole data if
the user has not specified the <multipole_library> tag in
.I materials.xml\fP.
.SH LICENSE
Copyright \(co 2011-2018 Massachusetts Institute of Technology and OpenMC
contributors.

View file

@ -989,18 +989,12 @@ class Materials(cv.CheckedList):
continuous-energy calculations and
:envvar:`OPENMC_MG_CROSS_SECTIONS` will be used for multi-group
calculations to find the path to the HDF5 cross section file.
multipole_library : str
Indicates the path to a directory containing a windowed multipole
cross section library. If it is not set, the
:envvar:`OPENMC_MULTIPOLE_LIBRARY` environment variable will be used. A
multipole library is optional.
"""
def __init__(self, materials=None):
super().__init__(Material, 'materials collection')
self._cross_sections = None
self._multipole_library = None
if materials is not None:
self += materials
@ -1009,20 +1003,11 @@ class Materials(cv.CheckedList):
def cross_sections(self):
return self._cross_sections
@property
def multipole_library(self):
return self._multipole_library
@cross_sections.setter
def cross_sections(self, cross_sections):
cv.check_type('cross sections', cross_sections, str)
self._cross_sections = cross_sections
@multipole_library.setter
def multipole_library(self, multipole_library):
cv.check_type('cross sections', multipole_library, str)
self._multipole_library = multipole_library
def append(self, material):
"""Append material to collection
@ -1060,11 +1045,6 @@ class Materials(cv.CheckedList):
element = ET.SubElement(root_element, "cross_sections")
element.text = str(self._cross_sections)
def _create_multipole_library_subelement(self, root_element):
if self._multipole_library is not None:
element = ET.SubElement(root_element, "multipole_library")
element.text = str(self._multipole_library)
def export_to_xml(self, path='materials.xml'):
"""Export material collection to an XML file.
@ -1077,7 +1057,6 @@ class Materials(cv.CheckedList):
root_element = ET.Element("materials")
self._create_cross_sections_subelement(root_element)
self._create_multipole_library_subelement(root_element)
self._create_material_subelements(root_element)
# Clean the indentation in the file to be user-readable
@ -1114,8 +1093,5 @@ class Materials(cv.CheckedList):
xs = tree.find('cross_sections')
if xs is not None:
materials.cross_sections = xs.text
mpl = tree.find('multipole_library')
if mpl is not None:
materials.multipole_library = mpl.text
return materials

View file

@ -180,7 +180,6 @@ class Settings(object):
self._confidence_intervals = None
self._cross_sections = None
self._electron_treatment = None
self._multipole_library = None
self._photon_transport = None
self._ptables = None
self._run_cmfd = None

View file

@ -1,9 +1,10 @@
#!/usr/bin/env python3
"""
Download ENDF/B-VII.1 ENDF and ACE files from NNDC and generate a full HDF5
library with incident neutron, incident photon, and thermal scattering data.
This data is used for OpenMC's regression test suite.
Download ENDF/B-VII.1 ENDF and ACE files from NNDC and WMP files from GitHub and
generate a full HDF5 library with incident neutron, incident photon, thermal
scattering data, and windowed multipole data. This data is used for OpenMC's
regression test suite.
"""
import glob
@ -19,12 +20,14 @@ from openmc._utils import download
base_ace = 'http://www.nndc.bnl.gov/endf/b7.1/aceFiles/'
base_endf = 'http://www.nndc.bnl.gov/endf/b7.1/zips/'
base_wmp = 'https://github.com/mit-crpg/WMP_Library/releases/download/v1.1/'
files = [
(base_ace, 'ENDF-B-VII.1-neutron-293.6K.tar.gz', '9729a17eb62b75f285d8a7628ace1449'),
(base_ace, 'ENDF-B-VII.1-tsl.tar.gz', 'e17d827c92940a30f22f096d910ea186'),
(base_endf, 'ENDF-B-VII.1-neutrons.zip', 'e5d7f441fc4c92893322c24d1725e29c'),
(base_endf, 'ENDF-B-VII.1-photoat.zip', '5192f94e61f0b385cf536f448ffab4a4'),
(base_endf, 'ENDF-B-VII.1-atomic_relax.zip', 'fddb6035e7f2b6931e51a58fc754bd10')
(base_endf, 'ENDF-B-VII.1-atomic_relax.zip', 'fddb6035e7f2b6931e51a58fc754bd10'),
(base_wmp, 'WMP_Library_v1.1.tar.gz', '8523895928dd6ba63fba803e3a45d4f3')
]
@ -36,12 +39,12 @@ def fix_zaid(table, old, new):
with open(filename, 'w') as fh:
fh.write(text)
pwd = Path.cwd()
output_dir = pwd / 'nndc_hdf5'
os.makedirs('nndc_hdf5/photon', exist_ok=True)
with tempfile.TemporaryDirectory() as tmpdir:
# Save current working directory and temporarily change dir
pwd = os.getcwd()
# Temporarily change dir
os.chdir(tmpdir)
# =========================================================================
@ -98,7 +101,7 @@ with tempfile.TemporaryDirectory() as tmpdir:
data.add_elastic_0K_from_endf(endf_filename)
# Determine filename
outfile = os.path.join('nndc_hdf5', data.name + '.h5')
outfile = output_dir / (data.name + '.h5')
data.export_to_hdf5(outfile, 'w', 'earliest')
# Register with library
@ -113,7 +116,7 @@ with tempfile.TemporaryDirectory() as tmpdir:
data = openmc.data.ThermalScattering.from_ace(f)
# Determine filename
outfile = os.path.join('nndc_hdf5', data.name + '.h5')
outfile = output_dir / (data.name + '.h5')
data.export_to_hdf5(outfile, 'w', 'earliest')
# Register with library
@ -127,23 +130,35 @@ with tempfile.TemporaryDirectory() as tmpdir:
print('Generating HDF5 file for Z={} ({})...'.format(z, element))
# Generate instance of IncidentPhoton
photo_file = os.path.join('photoat', 'photoat-{:03}_{}_000.endf'.format(z, element))
atom_file = os.path.join('atomic_relax', 'atom-{:03}_{}_000.endf'.format(z, element))
photo_file = Path('photoat') / 'photoat-{:03}_{}_000.endf'.format(z, element)
atom_file = Path('atomic_relax') / 'atom-{:03}_{}_000.endf'.format(z, element)
data = openmc.data.IncidentPhoton.from_endf(photo_file, atom_file)
# Write HDF5 file and register it
outfile = os.path.join('nndc_hdf5', 'photon', element + '.h5')
outfile = output_dir / 'photon' / (element + '.h5')
data.export_to_hdf5(outfile, 'w', 'earliest')
library.register_file(outfile)
library.export_to_xml(os.path.join('nndc_hdf5', 'cross_sections.xml'))
# =========================================================================
# WINDOWED MULTIPOLE DATA
# Move data into output directory
os.rename('WMP_Library', str(output_dir / 'wmp'))
# Add multipole data to library
for f in sorted(glob.glob('{}/wmp/*.h5'.format(output_dir))):
print('Registering WMP file {}...'.format(f))
library.register_file(f)
library.export_to_xml(output_dir / 'cross_sections.xml')
# =========================================================================
# CREATE TARBALL AND MOVE BACK
test_tar = os.path.join(pwd, 'nndc_hdf5_test.tar.xz')
with tarfile.open(test_tar, 'w:xz') as txz:
print('Creating compressed archive...')
test_tar = pwd / 'nndc_hdf5_test.tar.xz'
with tarfile.open(str(test_tar), 'w:xz') as txz:
txz.add('nndc_hdf5')
# Change back to original directory
os.chdir(pwd)
os.chdir(str(pwd))

View file

@ -125,21 +125,6 @@ void read_cross_sections_xml()
settings::path_cross_sections = get_node_value(root, "cross_sections");
}
// Find the windowed multipole library
if (settings::run_mode != RUN_MODE_PLOTTING) {
if (!check_for_node(root, "multipole_library")) {
// No library location specified in materials.xml, check
// environment variable
char* envvar = std::getenv("OPENMC_MULTIPOLE_LIBRARY");
if (envvar) settings::path_multipole = envvar;
} else {
settings::path_multipole = get_node_value(root, "multipole_library");
}
if (!ends_with(settings::path_multipole, "/")) {
settings::path_multipole += "/";
}
}
// Now that the cross_sections.xml or mgxs.h5 has been located, read it in
if (settings::run_CE) {
read_ce_cross_sections_xml();

View file

@ -2276,9 +2276,8 @@ contains
end if
end do
if (.not. mp_found) call warning("Windowed multipole functionality is &
&turned on, but no multipole libraries were found. Set the &
&<multipole_library> element in settings.xml or the &
&OPENMC_MULTIPOLE_LIBRARY environment variable.")
&turned on, but no multipole libraries were found. Make sure that &
&windowed multipole data is present in your cross_sections.xml file.")
end if
call already_read % clear()
@ -2302,34 +2301,14 @@ contains
integer(HID_T) :: file_id
integer(HID_T) :: group_id
interface
function path_multipole_c() result(ptr) bind(C)
import C_PTR
type(C_PTR) :: ptr
end function
end interface
associate (nuc => nuclides(i_table))
! Look for WMP data in cross_sections.xml
if (library_present(LIBRARY_WMP, to_lower(nuc % name))) then
! If WMP data is listed in cross_sections.xml, prefer that
filename = library_path(LIBRARY_WMP, to_lower(nuc % name))
else
! Otherwise, we rely on the OPENMC_MULTIPOLE_LIBRARY environment
! variable. This is a bit hacky, but we just assume that the file will be
! ZZZAAAmM.h5.
call c_f_pointer(path_multipole_c(), string, [255])
path_multipole = to_f_string(string)
if (nuc % metastable > 0) then
filename = trim(path_multipole) // trim(zero_padded(nuc % Z, 3)) // &
trim(zero_padded(nuc % A, 3)) // 'm' // &
trim(to_str(nuc % metastable)) // ".h5"
else
filename = trim(path_multipole) // trim(zero_padded(nuc % Z, 3)) // &
trim(zero_padded(nuc % A, 3)) // ".h5"
end if
nuc % mp_present = .false.
return
end if
! Check if Multipole library exists and is readable

View file

@ -37,7 +37,5 @@ element materials {
}*
}+ &
element cross_sections { xsd:string { maxLength = "255" } }? &
element multipole_library { xsd:string { maxLength = "255" } }?
element cross_sections { xsd:string { maxLength = "255" } }?
}

View file

@ -161,12 +161,5 @@
</data>
</element>
</optional>
<optional>
<element name="multipole_library">
<data type="string">
<param name="maxLength">255</param>
</data>
</element>
</optional>
</interleave>
</element>

View file

@ -101,7 +101,6 @@ module settings
character(MAX_FILE_LEN) :: path_input ! Path to input file
character(MAX_FILE_LEN) :: path_cross_sections = '' ! Path to cross_sections.xml
character(MAX_FILE_LEN) :: path_multipole ! Path to wmp library
character(MAX_FILE_LEN) :: path_state_point ! Path to binary state point
character(MAX_FILE_LEN) :: path_source_point ! Path to binary source point
character(MAX_FILE_LEN) :: path_particle_restart ! Path to particle restart

View file

@ -63,7 +63,6 @@ bool dagmc {false};
std::string path_cross_sections;
std::string path_input;
std::string path_multipole;
std::string path_output;
std::string path_particle_restart;
std::string path_source;
@ -73,7 +72,7 @@ std::string path_statepoint;
int32_t index_entropy_mesh {-1};
int32_t index_ufs_mesh {-1};
int32_t index_cmfd_mesh {-1};
int32_t n_batches;
int32_t n_inactive {0};
int32_t gen_per_batch {1};
@ -257,21 +256,6 @@ void read_settings_xml()
path_cross_sections = get_node_value(root, "cross_sections");
}
// Look for deprecated windowed_multipole file in settings.xml
if (run_mode != RUN_MODE_PLOTTING) {
if (check_for_node(root, "multipole_library")) {
warning("Setting multipole_library in settings.xml has been "
"deprecated. The multipole_library is now set in materials.xml and"
" the multipole_library input to materials.xml and the "
"OPENMC_MULTIPOLE_LIBRARY environment variable will take "
"precendent over setting multipole_library in settings.xml.");
path_multipole = get_node_value(root, "multipole_library");
}
if (!ends_with(path_multipole, "/")) {
path_multipole += "/";
}
}
if (!run_CE) {
// Scattering Treatments
if (check_for_node(root, "max_order")) {
@ -839,9 +823,6 @@ extern "C" {
const char* path_input_c() {
return settings::path_input.c_str();
}
const char* path_multipole_c() {
return settings::path_multipole.c_str();
}
const char* path_statepoint_c() {
return settings::path_statepoint.c_str();
}

View file

@ -113,9 +113,6 @@ class DiffTallyTestHarness(PyAPITestHarness):
return df.to_csv(None, columns=cols, index=False, float_format='%.7e')
@pytest.mark.skipif('OPENMC_MULTIPOLE_LIBRARY' not in os.environ,
reason='OPENMC_MULTIPOLE_LIBRARY environment variable '
'must be set')
def test_diff_tally():
harness = DiffTallyTestHarness('statepoint.3.h5')
harness.main()

View file

@ -74,9 +74,6 @@ class MultipoleTestHarness(PyAPITestHarness):
return outstr
@pytest.mark.skipif('OPENMC_MULTIPOLE_LIBRARY' not in os.environ,
reason='OPENMC_MULTIPOLE_LIBRARY environment variable '
'must be set')
def test_multipole():
model = make_model()
harness = MultipoleTestHarness('statepoint.5.h5', model)

View file

@ -1,25 +1,23 @@
import os
import pathlib
import numpy as np
import pytest
import openmc.data
pytestmark = pytest.mark.skipif(
'OPENMC_MULTIPOLE_LIBRARY' not in os.environ,
reason='OPENMC_MULTIPOLE_LIBRARY environment variable must be set')
@pytest.fixture(scope='module')
def u235():
directory = os.environ['OPENMC_MULTIPOLE_LIBRARY']
filename = os.path.join(directory, '092235.h5')
return openmc.data.WindowedMultipole.from_hdf5(filename)
directory = pathlib.Path(os.environ['OPENMC_CROSS_SECTIONS']).parent
u235 = directory / 'wmp' / '092235.h5'
return openmc.data.WindowedMultipole.from_hdf5(u235)
@pytest.fixture(scope='module')
def b10():
directory = os.environ['OPENMC_MULTIPOLE_LIBRARY']
filename = os.path.join(directory, '005010.h5')
return openmc.data.WindowedMultipole.from_hdf5(filename)
directory = pathlib.Path(os.environ['OPENMC_CROSS_SECTIONS']).parent
b10 = directory / 'wmp' / '005010.h5'
return openmc.data.WindowedMultipole.from_hdf5(b10)
def test_evaluate(u235):

View file

@ -154,7 +154,6 @@ def test_materials(run_in_tmpdir):
mats = openmc.Materials([m1, m2])
mats.cross_sections = '/some/fake/cross_sections.xml'
mats.multipole_library = '/some/awesome/mp_lib/'
mats.export_to_xml()
@ -200,7 +199,6 @@ def test_from_xml(run_in_tmpdir):
mats = openmc.Materials([m1, m2, m3])
mats.cross_sections = 'fake_path.xml'
mats.multipole_library = 'fake_multipole/'
mats.export_to_xml()
# Regenerate materials from XML

View file

@ -20,7 +20,6 @@ def test_export_to_xml(run_in_tmpdir):
s.statepoint = {'batches': [50, 150, 500, 1000]}
s.confidence_intervals = True
s.cross_sections = '/path/to/cross_sections.xml'
s.multipole_library = '/path/to/wmp/'
s.ptables = True
s.run_cmfd = False
s.seed = 17