From 04c1304dc42629c9edf8d75433b8b3bd02b16c18 Mon Sep 17 00:00:00 2001 From: Adam Nelson Date: Sat, 18 Mar 2017 10:13:16 -0400 Subject: [PATCH 1/2] Added Version number to MGXS Library format --- docs/source/io_formats/mgxs_library.rst | 8 +++++++- examples/xml/pincell_multigroup/geometry.xml | 2 +- examples/xml/pincell_multigroup/mgxs.h5 | Bin 16696 -> 16832 bytes examples/xml/pincell_multigroup/settings.xml | 17 ++++++++++------- openmc/mgxs_library.py | 12 ++++++++++++ src/constants.F90 | 1 + src/mgxs_data.F90 | 16 ++++++++++++++++ 7 files changed, 47 insertions(+), 9 deletions(-) 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 ae3b17e90f2dafb1a350d9bd1392d61254f2a37c..dbcda859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=dq7Z28Kkkoo2dzcbMQWWB-7{ti@9tVC7p~^MjYLA)*O@eTGmj9CteQtuW+~5R5KvxZNm~~EY MbA0#&TW9b70|v47LI3~& 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 From 726202af53e4ea57c67661276ae0906c6bac61ab Mon Sep 17 00:00:00 2001 From: Adam Nelson Date: Sat, 18 Mar 2017 10:20:19 -0400 Subject: [PATCH 2/2] updated test library version info --- tests/1d_mgxs.h5 | Bin 134280 -> 134432 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/1d_mgxs.h5 b/tests/1d_mgxs.h5 index 8f28e02cbcfb2d51e94d81bafdd97ba1220313d3..0f747345a8da7c1cee71928d337a5c590dcc0e78 100644 GIT binary patch delta 181 zcmeB}$+2J-#{>-~1>T8T7SlJ$Fp6!guwb4p@tjdYn1Mlp0R%k0FoJ0Z28QO_%-e4> zGrB(J?BHPn3(lDQP^NJEtmlmHR8)BwfJ%UXk%5ze1E@JIGbgpAvLF>K2qb_eGO$km zDp9~)6##9#6`BA5