diff --git a/docs/source/io_formats/mgxs_library.rst b/docs/source/io_formats/mgxs_library.rst index 942c50305..4129ed4ba 100644 --- a/docs/source/io_formats/mgxs_library.rst +++ b/docs/source/io_formats/mgxs_library.rst @@ -19,6 +19,8 @@ energy groups, delayed groups, and the energy group structure, etc.) as well as the actual cross section data itself for each of the necessary nuclides or materials. +The current version of the multi-group library file format is 1.0. + .. _HDF5: http://www.hdfgroup.org/HDF5/ .. _mgxs_lib_spec: @@ -29,7 +31,11 @@ MGXS Library Specification **/** -:Attributes: - **energy_groups** (*int*) -- Number of energy groups +:Attributes: - **filetype** (*char[]*) -- String indicating the type of file; + for this library it will be 'mgxs'. + - **version** (*int[2]*) -- Major and minor version of the + multi-group library file format. + - **energy_groups** (*int*) -- Number of energy groups - **delayed_groups** (*int*) -- Number of delayed groups (optional) - **group structure** (*double[]*) -- Monotonically increasing list of group boundaries, in units of eV. The length of this diff --git a/examples/xml/pincell_multigroup/geometry.xml b/examples/xml/pincell_multigroup/geometry.xml index 7f2fb36e8..a1df07a9e 100644 --- a/examples/xml/pincell_multigroup/geometry.xml +++ b/examples/xml/pincell_multigroup/geometry.xml @@ -1,7 +1,7 @@ - + diff --git a/examples/xml/pincell_multigroup/mgxs.h5 b/examples/xml/pincell_multigroup/mgxs.h5 index ae3b17e90..dbcda859d 100644 Binary files a/examples/xml/pincell_multigroup/mgxs.h5 and b/examples/xml/pincell_multigroup/mgxs.h5 differ diff --git a/examples/xml/pincell_multigroup/settings.xml b/examples/xml/pincell_multigroup/settings.xml index cc2b9ea14..6966d02b7 100644 --- a/examples/xml/pincell_multigroup/settings.xml +++ b/examples/xml/pincell_multigroup/settings.xml @@ -1,10 +1,13 @@ - eigenvalue - - - -0.63 -0.63 -1 0.63 0.63 1 - - - multi-group + eigenvalue + 1000 + 100 + 10 + + + -0.63 -0.63 -1 0.63 0.63 1 + + + multi-group diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index 7f0e3f31f..6950d646c 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -25,6 +25,12 @@ _XS_SHAPES = ["[G][G'][Order]", "[G]", "[G']", "[G][G']", "[DG]", "[DG][G]", # Number of mu points for conversion between scattering formats _NMU = 257 +# Filetype name of the MGXS Library +_FILETYPE_MGXS_LIBRARY = 'mgxs' + +# Current version of the MGXS Library Format +_VERSION_MGXS_LIBRARY = 1 + class XSdata(object): """A multi-group cross section data set providing all the @@ -2513,6 +2519,8 @@ class MGXSLibrary(object): # Create and write to the HDF5 file file = h5py.File(filename, "w") + file.attrs['filetype'] = np.string_(_FILETYPE_MGXS_LIBRARY) + file.attrs['version'] = [_VERSION_MGXS_LIBRARY, 0] file.attrs['energy_groups'] = self.energy_groups.num_groups file.attrs['delayed_groups'] = self.num_delayed_groups file.attrs['group structure'] = self.energy_groups.group_edges @@ -2552,6 +2560,10 @@ class MGXSLibrary(object): check_type('filename', filename, str) file = h5py.File(filename, 'r') + # Check filetype and version + cv.check_filetype_version(file, _FILETYPE_MGXS_LIBRARY, + _VERSION_MGXS_LIBRARY) + group_structure = file.attrs['group structure'] num_delayed_groups = file.attrs['delayed_groups'] energy_groups = openmc.mgxs.EnergyGroups(group_structure) diff --git a/src/constants.F90 b/src/constants.F90 index 682ae79e8..5952aeaba 100644 --- a/src/constants.F90 +++ b/src/constants.F90 @@ -22,6 +22,7 @@ module constants integer, parameter :: VERSION_SUMMARY(2) = [5, 0] integer, parameter :: VERSION_VOLUME(2) = [1, 0] integer, parameter :: VERSION_VOXEL(2) = [1, 0] + integer, parameter :: VERSION_MGXS_LIBRARY(2) = [1, 0] character(10), parameter :: VERSION_MULTIPOLE = "v0.2" ! ============================================================================ diff --git a/src/mgxs_data.F90 b/src/mgxs_data.F90 index f687b6e5b..a43d45c0e 100644 --- a/src/mgxs_data.F90 +++ b/src/mgxs_data.F90 @@ -36,6 +36,8 @@ contains logical :: file_exists type(DictCharInt) :: xsdata_dict type(VectorReal), allocatable :: temps(:) + character(MAX_WORD_LEN) :: word + integer, allocatable :: array(:) ! Check if MGXS Library exists inquire(FILE=path_cross_sections, EXIST=file_exists) @@ -55,6 +57,20 @@ contains ! Open file for reading file_id = file_open(path_cross_sections, 'r', parallel=.true.) + ! Read filetype + call read_attribute(word, file_id, "filetype") + if (word /= 'mgxs') then + call fatal_error("Provided MGXS Library is not a MGXS Library file.") + end if + + ! Read revision number for the MGXS Library file and make sure it matches + ! with the current version + call read_attribute(array, file_id, "version") + if (any(array /= VERSION_MGXS_LIBRARY)) then + call fatal_error("MGXS Library file version does not match current & + &version supported by OpenMC.") + end if + ! allocate arrays for MGXS storage and cross section cache allocate(nuclides_MG(n_nuclides_total)) !$omp parallel diff --git a/tests/1d_mgxs.h5 b/tests/1d_mgxs.h5 index 8f28e02cb..0f747345a 100644 Binary files a/tests/1d_mgxs.h5 and b/tests/1d_mgxs.h5 differ