From e78933d0d316279e47ebade0a9a4227da269a75a Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Tue, 16 Feb 2016 14:57:01 -0500 Subject: [PATCH] Allow user to specify multipole library location --- docs/source/usersguide/input.rst | 10 ++++++++++ openmc/settings.py | 20 ++++++++++++++++++++ src/ace.F90 | 13 ++++++------- src/global.F90 | 1 + src/input_xml.F90 | 16 +++++++++++++++- src/multipole.F90 | 11 ++++++----- src/relaxng/settings.rnc | 2 ++ src/relaxng/settings.rng | 7 +++++++ 8 files changed, 67 insertions(+), 13 deletions(-) diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 0ea3d8bde5..b54b255c63 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -264,6 +264,16 @@ based on the recommended value in LA-UR-14-24530_. *Default*: 8000 +```` Element +------------------------------- + +The ```` element has no attributes and 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:`MULTIPOLE_LIBRARY` environment variable will be +used. + .. _natural_elements: ```` Element diff --git a/openmc/settings.py b/openmc/settings.py index 4ad207c7a3..71e5ebbc3e 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -72,6 +72,10 @@ class SettingsFile(object): cross_sections.xml). If it is not set, the :envvar:`CROSS_SECTIONS` environment variable will be used to find the path to the XML cross section listing. + multipole_library : str + Indicates the path to a directory containing a windowed multipole + cross section library. If it is not set, the :envvar:`MULTIPOLE_LIBRARY' + environment variable will be used. A multipole library is optional. energy_grid : str Set the method used to search energy grids. Acceptable values are 'nuclide', 'logarithm', and 'material-union'. @@ -139,6 +143,7 @@ class SettingsFile(object): self._confidence_intervals = None self._cross_sections = None + self._multipole_library = None self._energy_grid = None self._ptables = None self._run_cmfd = None @@ -233,6 +238,10 @@ class SettingsFile(object): def cross_sections(self): return self._cross_sections + @property + def multipole_library(self): + return self._multipole_library + @property def energy_grid(self): return self._energy_grid @@ -528,6 +537,11 @@ class SettingsFile(object): check_type('cross sections', cross_sections, basestring) self._cross_sections = cross_sections + @multipole_library.setter + def multipole_library(self, multipole_library): + check_type('cross sections', multipole_library, basestring) + self._multipole_library = multipole_library + @energy_grid.setter def energy_grid(self, energy_grid): check_value('energy grid', energy_grid, @@ -861,6 +875,11 @@ class SettingsFile(object): element = ET.SubElement(self._settings_file, "cross_sections") element.text = str(self._cross_sections) + def _create_multipole_library_subelement(self): + if self._multipole_library is not None: + element = ET.SubElement(self._settings_file, "multipole_library") + element.text = str(self._multipole_library) + def _create_energy_grid_subelement(self): if self._energy_grid is not None: element = ET.SubElement(self._settings_file, "energy_grid") @@ -1024,6 +1043,7 @@ class SettingsFile(object): self._create_sourcepoint_subelement() self._create_confidence_intervals() self._create_cross_sections_subelement() + self._create_multipole_library_subelement() self._create_energy_grid_subelement() self._create_ptables_subelement() self._create_run_cmfd_subelement() diff --git a/src/ace.F90 b/src/ace.F90 index 813e06ec2a..4ef77229ee 100644 --- a/src/ace.F90 +++ b/src/ace.F90 @@ -431,15 +431,14 @@ contains logical :: file_exists ! does multipole library exist? character(7) :: readable ! is multipole library readable? character(6) :: zaid_string ! String of the ZAID - character(9) :: filename ! path to multipole cross section library - type(Nuclide), pointer :: nuc => null() + character(MAX_FILE_LEN+9) :: filename ! path to multipole xs library ! For the time being, and I know this is a bit hacky, we just assume ! that the file will be zaid.h5. associate (nuc => nuclides(i_table)) - write(zaid_string,'(I6.6)') nuc % zaid - filename = zaid_string // ".h5" + write(zaid_string, '(I6.6)') nuc % zaid + filename = trim(path_multipole) // zaid_string // ".h5" ! Check if Multipole library exists and is readable inquire(FILE=filename, EXIST=file_exists, READ=readable) @@ -447,11 +446,11 @@ contains nuc % mp_present = .false. return elseif (readable(1:3) == 'NO') then - call fatal_error("Multipole library '" // trim(filename) // "' is not readable! & - &Change file permissions with chmod command.") + call fatal_error("Multipole library '" // trim(filename) // "' is not & + &readable! Change file permissions with chmod command.") end if - ! display message + ! Display message call write_message("Loading Multipole XS table: " // filename, 6) allocate(nuc % multipole) diff --git a/src/global.F90 b/src/global.F90 index 4c243ee41f..15a88d2059 100644 --- a/src/global.F90 +++ b/src/global.F90 @@ -282,6 +282,7 @@ module global 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_source = '' ! Path to binary source character(MAX_FILE_LEN) :: path_state_point ! Path to binary state point character(MAX_FILE_LEN) :: path_source_point ! Path to binary source point diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 99fbb67734..dc67d4b1fd 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -127,6 +127,21 @@ contains end if end if + ! Find the windowed multipole library + if (run_mode /= MODE_PLOTTING) then + if (.not. check_for_node(doc, "multipole_library") .and. & + run_mode /= MODE_PLOTTING) then + ! No library location specified in settings.xml, check + ! environment variable + call get_environment_variable("MULTIPOLE_LIBRARY", env_variable) + path_multipole = trim(env_variable) + else + call get_node_value(doc, "multipole_library", path_multipole) + end if + if (.not. ends_with(path_multipole, "/")) & + path_multipole = trim(path_multipole) // "/" + end if + ! Set output directory if a path has been specified on the ! element if (check_for_node(doc, "output_path")) then @@ -1901,7 +1916,6 @@ contains type(Node), pointer :: doc => null() type(Node), pointer :: node_mat => null() type(Node), pointer :: node_dens => null() - type(Node), pointer :: node_temp => null() type(Node), pointer :: node_nuc => null() type(Node), pointer :: node_ele => null() type(Node), pointer :: node_sab => null() diff --git a/src/multipole.F90 b/src/multipole.F90 index 4ed28a2dbf..da57c96a29 100644 --- a/src/multipole.F90 +++ b/src/multipole.F90 @@ -17,18 +17,19 @@ contains !=============================================================================== subroutine multipole_read(filename, multipole, i_table) - character(len=*), intent(in) :: filename ! Filename of the multipole library to load + character(len=*), intent(in) :: filename ! Filename of the + ! multipole library + ! to load type(MultipoleArray), intent(out), target :: multipole ! The object to fill - integer, intent(in) :: i_table ! index in nuclides/sab_tables - - type(Nuclide), pointer :: nuc => null() + integer, intent(in) :: i_table ! index in nuclides/ + ! sab_tables integer(HID_T) :: file_id integer(HID_T) :: group_id ! Intermediate loading components integer :: NMT - integer :: i, j, k + integer :: i, j integer, allocatable :: MT(:) logical :: accumulated_fission character(len=3) :: MT_string diff --git a/src/relaxng/settings.rnc b/src/relaxng/settings.rnc index 68f221f677..34886c6505 100644 --- a/src/relaxng/settings.rnc +++ b/src/relaxng/settings.rnc @@ -27,6 +27,8 @@ element settings { element cross_sections { xsd:string { maxLength = "255" } }? & + element multipole_library { xsd:string { maxLength = "255" } }? & + element cutoff { (element weight { xsd:double } | attribute weight { xsd:double })? & (element weight_avg { xsd:double } | attribute weight_avg { xsd:double })? diff --git a/src/relaxng/settings.rng b/src/relaxng/settings.rng index ea3efaff9f..1880153e2a 100644 --- a/src/relaxng/settings.rng +++ b/src/relaxng/settings.rng @@ -95,6 +95,13 @@ + + + + 255 + + +