diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 2d8051126..c407019f2 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -708,6 +708,12 @@ Each ```` element can have the following attributes or sub-elements: *Default*: None + :name: + An optional string name to identify the surface in summary output + files. This string is limited to 52 characters for formatting purposes. + + *Default*: "" + :type: The type of the surfaces. This can be "x-plane", "y-plane", "z-plane", "plane", "x-cylinder", "y-cylinder", "z-cylinder", or "sphere". @@ -788,6 +794,12 @@ Each ```` element can have the following attributes or sub-elements: *Default*: None + :name: + An optional string name to identify the cell in summary output files. + This string is limmited to 52 characters for formatting purposes. + + *Default*: "" + :universe: The ``id`` of the universe that this cell is contained in. @@ -853,6 +865,12 @@ the following attributes or sub-elements: :id: A unique integer that can be used to identify the lattice. + :name: + An optional string name to identify the lattice in summary output + files. This string is limited to 52 characters for formatting purposes. + + *Default*: "" + :dimension: Two or three integers representing the number of lattice cells in the x- and y- (and z-) directions, respectively. @@ -912,6 +930,12 @@ the following attributes or sub-elements: :id: A unique integer that can be used to identify the lattice. + :name: + An optional string name to identify the hex_lattice in summary output + files. This string is limited to 52 characters for formatting purposes. + + *Default*: "" + :n_rings: An integer representing the number of radial ring positions in the xy-plane. Note that this number includes the degenerate center ring which only has one @@ -989,6 +1013,12 @@ Each ``material`` element can have the following attributes or sub-elements: :id: A unique integer that can be used to identify the material. + :name: + An optional string name to identify the material in summary output + files. This string is limited to 52 characters for formatting purposes. + + *Default*: "" + :density: An element with attributes/sub-elements called ``value`` and ``units``. The ``value`` attribute is the numeric value of the density while the ``units`` @@ -1091,10 +1121,11 @@ and ````. The ```` element accepts the following sub-elements: - :label: - This is an optional sub-element specifying the name of this tally to be used - for output purposes. This string is limited to 52 characters for formatting - purposes. + :name: + An optional string name to identify the tally in summary output + files. This string is limited to 52 characters for formatting purposes. + + *Default*: "" :filter: Specify a filter that restricts contributions to the tally to particles diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index c79fec7fe..9338aff0e 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -200,7 +200,7 @@ mesh_filter = openmc.Filter() mesh_filter.mesh = mesh # Instantiate the Tally -tally = openmc.Tally(tally_id=1) +tally = openmc.Tally(tally_id=1, name='tally 1') tally.add_filter(energy_filter) tally.add_filter(mesh_filter) tally.add_score('flux') diff --git a/src/cmfd_input.F90 b/src/cmfd_input.F90 index 578ecb967..11059c48f 100644 --- a/src/cmfd_input.F90 +++ b/src/cmfd_input.F90 @@ -460,8 +460,8 @@ contains if (i == 1) then - ! Set label - t % label = "CMFD flux, total, scatter-1" + ! Set name + t % name = "CMFD flux, total, scatter-1" ! Set tally estimator to analog t % estimator = ESTIMATOR_ANALOG @@ -491,8 +491,8 @@ contains else if (i == 2) then - ! Set label - t % label = "CMFD neutron production" + ! Set name + t % name = "CMFD neutron production" ! Set tally estimator to analog t % estimator = ESTIMATOR_ANALOG @@ -536,8 +536,8 @@ contains else if (i == 3) then - ! Set label - t % label = "CMFD surface currents" + ! Set name + t % name = "CMFD surface currents" ! Set tally estimator to analog t % estimator = ESTIMATOR_ANALOG diff --git a/src/geometry_header.F90 b/src/geometry_header.F90 index 438469765..12e05336c 100644 --- a/src/geometry_header.F90 +++ b/src/geometry_header.F90 @@ -24,6 +24,7 @@ module geometry_header type, abstract :: Lattice integer :: id ! Universe number for lattice + character(len=52) :: name = "" ! User-defined name real(8), allocatable :: pitch(:) ! Pitch along each axis integer, allocatable :: universes(:,:,:) ! Specified universes integer :: outside ! Material to fill area outside @@ -120,6 +121,7 @@ module geometry_header type Surface integer :: id ! Unique ID + character(len=52) :: name = "" ! User-defined name integer :: type ! Type of surface real(8), allocatable :: coeffs(:) ! Definition of surface integer, allocatable :: & @@ -134,6 +136,7 @@ module geometry_header type Cell integer :: id ! Unique ID + character(len=52) :: name = "" ! User-defined name integer :: type ! Type of cell (normal, universe, lattice) integer :: universe ! universe # this cell is in integer :: fill ! universe # filling this cell diff --git a/src/hdf5_summary.F90 b/src/hdf5_summary.F90 index db8405e76..161246f1c 100644 --- a/src/hdf5_summary.F90 +++ b/src/hdf5_summary.F90 @@ -127,6 +127,10 @@ contains call su % write_data(i, "index", & group="geometry/cells/cell " // trim(to_str(c % id))) + ! Write name for this cell + call su % write_data(c % name, "name", & + group="geometry/cells/cell " // trim(to_str(c % id))) + ! Write universe for this cell call su % write_data(universes(c % universe) % id, "universe", & group="geometry/cells/cell " // trim(to_str(c % id))) @@ -208,6 +212,10 @@ contains call su % write_data(i, "index", & group="geometry/surfaces/surface " // trim(to_str(s % id))) + ! Write name for this surface + call su % write_data(s % name, "name", & + group="geometry/surfaces/surface " // trim(to_str(s % id))) + ! Write surface type select case (s % type) case (SURF_PX) @@ -319,6 +327,10 @@ contains call su % write_data(i, "index", & group="geometry/lattices/lattice " // trim(to_str(lat % id))) + ! Write name for this lattice + call su % write_data(lat % name, "name", & + group="geometry/lattices/lattice " // trim(to_str(lat % id))) + ! Write lattice type select type (lat) type is (RectLattice) @@ -465,6 +477,10 @@ contains call su % write_data(i, "index", & group="materials/material " // trim(to_str(m % id))) + ! Write name for this material + call su % write_data(m % name, "name", & + group="materials/material " // trim(to_str(m % id))) + ! Write atom density with units call su % write_data(m % density, "atom_density", & group="materials/material " // trim(to_str(m % id))) @@ -560,6 +576,14 @@ contains ! Get pointer to tally t => tallies(i) + ! Write the name for this tally + call su % write_data(len(t % name), "name_size", & + group="tallies/tally " // trim(to_str(t % id))) + if (len(t % name) > 0) then + call su % write_data(t % name, "name", & + group="tallies/tally " // trim(to_str(t % id))) + endif + ! Write size of each tally call su % write_data(t % total_score_bins, "total_score_bins", & group="tallies/tally " // trim(to_str(t % id))) diff --git a/src/input_xml.F90 b/src/input_xml.F90 index df7dda9b0..8f5676647 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -978,6 +978,11 @@ contains call fatal_error("Must specify id of cell in geometry XML file.") end if + ! Copy cell name + if (check_for_node(node_cell, "name")) then + call get_node_value(node_cell, "name", c % name) + end if + if (check_for_node(node_cell, "universe")) then call get_node_value(node_cell, "universe", c % universe) else @@ -1157,6 +1162,11 @@ contains &// to_str(s % id)) end if + ! Copy surface name + if (check_for_node(node_surf, "name")) then + call get_node_value(node_surf, "name", s % name) + end if + ! Copy and interpret surface type word = '' if (check_for_node(node_surf, "type")) & @@ -1279,6 +1289,11 @@ contains &// to_str(lat % id)) end if + ! Copy lattice name + if (check_for_node(node_lat, "name")) then + call get_node_value(node_lat, "name", lat % name) + end if + ! Read number of lattice cells in each dimension n = get_arraysize_integer(node_lat, "dimension") if (n == 2) then @@ -1402,6 +1417,11 @@ contains &// to_str(lat % id)) end if + ! Copy lattice name + if (check_for_node(node_lat, "name")) then + call get_node_value(node_lat, "name", lat % name) + end if + ! Read number of lattice cells in each dimension call get_node_value(node_lat, "n_rings", lat % n_rings) if (check_for_node(node_lat, "n_axial")) then @@ -1647,6 +1667,11 @@ contains &// to_str(mat % id)) end if + ! Copy material name + if (check_for_node(node_mat, "name")) then + call get_node_value(node_mat, "name", mat % name) + end if + if (run_mode == MODE_PLOTTING) then ! add to the dictionary and skip xs processing call material_dict % add_key(mat % id, i) @@ -2209,10 +2234,9 @@ contains &// to_str(t % id)) end if - ! Copy tally label - t % label = '' - if (check_for_node(node_tal, "label")) & - call get_node_value(node_tal, "label", t % label) + ! Copy tally name + if (check_for_node(node_tal, "name")) & + call get_node_value(node_tal, "name", t % name) ! ======================================================================= ! READ DATA FOR FILTERS diff --git a/src/material_header.F90 b/src/material_header.F90 index 6434fa595..a10382abd 100644 --- a/src/material_header.F90 +++ b/src/material_header.F90 @@ -8,6 +8,7 @@ module material_header type Material integer :: id ! unique identifier + character(len=52) :: name = "" ! User-defined name integer :: n_nuclides ! number of nuclides integer, allocatable :: nuclide(:) ! index in nuclides array real(8) :: density ! total atom density in atom/b-cm diff --git a/src/mpiio_interface.F90 b/src/mpiio_interface.F90 index 97ca73fb3..30093adec 100644 --- a/src/mpiio_interface.F90 +++ b/src/mpiio_interface.F90 @@ -21,7 +21,6 @@ module mpiio_interface module procedure mpi_write_integer_4Darray module procedure mpi_write_long module procedure mpi_write_string - !module procedure mpi_write_string_1Darray end interface mpi_write_data ! Generic HDF5 read procedure interface @@ -38,7 +37,6 @@ module mpiio_interface module procedure mpi_read_integer_4Darray module procedure mpi_read_long module procedure mpi_read_string - !module procedure mpi_read_string_1Darray end interface mpi_read_data contains diff --git a/src/output.F90 b/src/output.F90 index 533f99183..8419971eb 100644 --- a/src/output.F90 +++ b/src/output.F90 @@ -369,6 +369,9 @@ contains ! Write user-specified id for cell write(unit_,*) 'Cell ' // to_str(c % id) + ! Write user-specified name for cell + write(unit_,*) ' Name = ' // c % name + ! Find index in cells array and write index_cell = cell_dict % get_key(c % id) write(unit_,*) ' Array Index = ' // to_str(index_cell) @@ -487,6 +490,9 @@ contains ! Write information about lattice write(unit_,*) 'Lattice ' // to_str(lat % id) + ! Write user-specified name for lattice + write(unit_,*) ' Name = ' // lat % name + select type(lat) type is (RectLattice) ! Write dimension of lattice. @@ -572,6 +578,9 @@ contains ! Write user-specified id of surface write(unit_,*) 'Surface ' // to_str(surf % id) + ! Write user-specified name for surface + write(unit_,*) ' Name = ' // surf % name + ! Write type of surface select case (surf % type) case (SURF_PX) @@ -668,6 +677,9 @@ contains ! Write identifier for material write(unit_,*) 'Material ' // to_str(mat % id) + ! Write user-specified name for material + write(unit_,*) ' Name = ' // mat % name + ! Write total atom density in atom/b-cm write(unit_,*) ' Atom Density = ' // trim(to_str(mat % density)) & // ' atom/b-cm' @@ -1780,12 +1792,12 @@ contains end if ! Write header block - if (t % label == "") then + if (t % name == "") then call header("TALLY " // trim(to_str(t % id)), unit=UNIT_TALLY, & level=3) else call header("TALLY " // trim(to_str(t % id)) // ": " & - // trim(t % label), unit=UNIT_TALLY, level=3) + // trim(t % name), unit=UNIT_TALLY, level=3) endif ! Handle surface current tallies separately diff --git a/src/relaxng/geometry.rnc b/src/relaxng/geometry.rnc index 801c902c9..cebbc5b6a 100644 --- a/src/relaxng/geometry.rnc +++ b/src/relaxng/geometry.rnc @@ -1,6 +1,8 @@ element geometry { element cell { (element id { xsd:int } | attribute id { xsd:int }) & + (element name { xsd:string { maxLength="52" } } | + attribute name { xsd:string { maxLength="52" } })? & (element universe { xsd:int } | attribute universe { xsd:int })? & ( (element fill { xsd:int } | attribute fill { xsd:int }) | @@ -14,6 +16,8 @@ element geometry { & element surface { (element id { xsd:int } | attribute id { xsd:int }) & + (element name { xsd:string { maxLength="52" } } | + attribute name { xsd:string { maxLength="52" } })? & (element type { xsd:string { maxLength = "15" } } | attribute type { xsd:string { maxLength = "15" } }) & (element coeffs { list { xsd:double+ } } | attribute coeffs { list { xsd:double+ } }) & @@ -23,6 +27,8 @@ element geometry { & element lattice { (element id { xsd:int } | attribute id { xsd:int }) & + (element name { xsd:string { maxLength="52" } } | + attribute name { xsd:string { maxLength="52" } })? & (element dimension { list { xsd:positiveInteger+ } } | attribute dimension { list { xsd:positiveInteger+ } }) & (element lower_left { list { xsd:double+ } } | attribute lower_left { list { xsd:double+ } }) & @@ -33,6 +39,8 @@ element geometry { & element hex_lattice { (element id { xsd:int } | attribute id { xsd:int }) & + (element name { xsd:string { maxLength="52" } } | + attribute name { xsd:string { maxLength="52" } })? & (element n_rings { xsd:int } | attribute n_rings { xsd:int }) & (element n_axial { xsd:int } | attribute n_axial { xsd:int })? & (element center { list { xsd:double+ } } | attribute center { list { xsd:double+ } }) & diff --git a/src/relaxng/geometry.rng b/src/relaxng/geometry.rng index 9ac3c9c59..fdbf74cbd 100644 --- a/src/relaxng/geometry.rng +++ b/src/relaxng/geometry.rng @@ -12,6 +12,20 @@ + + + + + 52 + + + + + 52 + + + + @@ -114,6 +128,20 @@ + + + + + 52 + + + + + 52 + + + + @@ -174,6 +202,20 @@ + + + + + 52 + + + + + 52 + + + + @@ -262,6 +304,20 @@ + + + + + 52 + + + + + 52 + + + + diff --git a/src/relaxng/materials.rnc b/src/relaxng/materials.rnc index d497fa745..ae8565497 100644 --- a/src/relaxng/materials.rnc +++ b/src/relaxng/materials.rnc @@ -1,6 +1,8 @@ element materials { element material { (element id { xsd:int } | attribute id { xsd:int }) & + (element name { xsd:string { maxLength="52" } } | + attribute name { xsd:string { maxLength="52" } })? & element density { (element value { xsd:double } | attribute value { xsd:double })? & diff --git a/src/relaxng/tallies.rnc b/src/relaxng/tallies.rnc index 09a5a6eb8..6911dab2f 100644 --- a/src/relaxng/tallies.rnc +++ b/src/relaxng/tallies.rnc @@ -17,8 +17,8 @@ element tallies { element tally { (element id { xsd:int } | attribute id { xsd:int }) & - (element label { xsd:string { maxLength="52" } } | - attribute label { xsd:string { maxLength="52" } })? & + (element name { xsd:string { maxLength="52" } } | + attribute name { xsd:string { maxLength="52" } })? & (element estimator { ( "analog" | "tracklength" ) } | attribute estimator { ( "analog" | "tracklength" ) })? & element filter { diff --git a/src/relaxng/tallies.rng b/src/relaxng/tallies.rng index 60263676b..a3668925a 100644 --- a/src/relaxng/tallies.rng +++ b/src/relaxng/tallies.rng @@ -108,12 +108,12 @@ - + 52 - + 52 diff --git a/src/state_point.F90 b/src/state_point.F90 index 5cbd93677..52492fc6c 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -236,13 +236,6 @@ contains ! Get pointer to tally tally => tallies(i) - call sp % write_data(len(tally % label), "label_size", & - group="tallies/tally " // trim(to_str(tally % id))) - if (len(tally % label) > 0) then - call sp % write_data(tally % label, "label", & - group="tallies/tally " // trim(to_str(tally % id))) - endif - call sp % write_data(tally % estimator, "estimator", & group="tallies/tally " // trim(to_str(tally % id))) call sp % write_data(tally % n_realizations, "n_realizations", & @@ -656,7 +649,6 @@ contains character(MAX_FILE_LEN) :: path_temp character(19) :: current_time - character(52) :: label integer :: i, j, k integer :: length(4) integer :: int_array(3) @@ -833,13 +825,6 @@ contains tally => tallies(i) curr_key = key_array(id_array(i)) - call sp % read_data(j, "label_size", group="tallies/tally " // & - trim(to_str(curr_key))) - if (j > 0) then - call sp % read_data(label, "label", group="tallies/tally " // & - trim(to_str(curr_key))) - end if - call sp % read_data(tally % estimator, "estimator", & group="tallies/tally " // trim(to_str(curr_key))) call sp % read_data(tally % n_realizations, "n_realizations", & diff --git a/src/tally_header.F90 b/src/tally_header.F90 index ad479f9ed..5c7efe84e 100644 --- a/src/tally_header.F90 +++ b/src/tally_header.F90 @@ -72,7 +72,7 @@ module tally_header ! Basic data integer :: id ! user-defined identifier - character(len=52) :: label = "" ! user-defined label + character(len=52) :: name = "" ! user-defined name integer :: type ! volume, surface current integer :: estimator ! collision, track-length real(8) :: volume ! volume of region @@ -160,7 +160,7 @@ module tally_header ! This routine will go through each item in TallyObject and set the value ! to its default, as-initialized values, including deallocations. - this % label = "" + this % name = "" if (allocated(this % filters)) then do i = 1, size(this % filters) diff --git a/src/utils/openmc/material.py b/src/utils/openmc/material.py index 06f1bdc9f..da205dc5b 100644 --- a/src/utils/openmc/material.py +++ b/src/utils/openmc/material.py @@ -375,7 +375,7 @@ class Material(object): element.set("id", str(self._id)) if len(self._name) > 0: - element.set("label", str(self._name)) + element.set("name", str(self._name)) # Create density XML subelement subelement = ET.SubElement(element, "density") diff --git a/src/utils/openmc/statepoint.py b/src/utils/openmc/statepoint.py index 8896fd6d5..636fd9da2 100644 --- a/src/utils/openmc/statepoint.py +++ b/src/utils/openmc/statepoint.py @@ -313,18 +313,6 @@ class StatePoint(object): # Iterate over all Tallies for tally_key in self._tally_keys: - # Read user-specified Tally label (if specified) - label_size = self._get_int( - path='{0}{1}/label_size'.format(base, tally_key))[0] - - if label_size > 0: - label = self._get_string( - label_size, path='{0}{1}/label'.format(base, tally_key)) - - # Remove leading and trailing characters from string label - label = label.lstrip('[\'') - label = label.rstrip('\']') - # Read integer Tally estimator type code (analog or tracklength) estimator_type = self._get_int( path='{0}{1}/estimator'.format(base, tally_key))[0] @@ -334,7 +322,7 @@ class StatePoint(object): path='{0}{1}/n_realizations'.format(base, tally_key))[0] # Create Tally object and assign basic properties - tally = openmc.Tally(tally_key, label) + tally = openmc.Tally(tally_key) tally.estimator = ESTIMATOR_TYPES[estimator_type] tally.num_realizations = n_realizations @@ -591,7 +579,7 @@ class StatePoint(object): def get_tally(self, score, filters, nuclides, - label='', estimator='tracklength'): + name='', estimator='tracklength'): """Finds and returns a Tally object with certain properties. Parameters @@ -605,8 +593,8 @@ class StatePoint(object): nuclides : list A list of Nuclide objects - label : str - The label specified for the Tally (default is '') + name : str + The name specified for the Tally (default is '') estimator: str The type of estimator ('tracklength' (default) or 'analog') @@ -618,8 +606,8 @@ class StatePoint(object): # Iterate over all tallies to find the appropriate one for tally_id, test_tally in self._tallies.items(): - # Determine if the queried Tally label is the same as this Tally - if not label == test_tally._label: + # Determine if the queried Tally name is the same as this Tally + if not name == test_tally._name: continue # Determine if the queried Tally estimator is the same as this Tally @@ -630,7 +618,7 @@ class StatePoint(object): if not score in test_tally._scores: continue - # Determine if queried Tally filters is the same length as this Tally + # Determine if queried Tally filters is same length as this Tally if len(filters) != len(test_tally._filters): continue @@ -664,7 +652,7 @@ class StatePoint(object): return tally - def get_tally_id(self, score, filters, label='', estimator='tracklength'): + def get_tally_id(self, score, filters, name='', estimator='tracklength'): """Retrieve the Tally ID for a given list of filters and score(s). Parameters @@ -675,14 +663,14 @@ class StatePoint(object): filters : list A list of Filter objects - label : str - The label specified for the Tally (default is '') + name : str + The name specified for the Tally (default is '') estimator: str The type of estimator ('tracklength' (default) or 'analog') """ - tally = self.get_tally(score, filters, label, estimator) + tally = self.get_tally(score, filters, name, estimator) return tally._id @@ -695,6 +683,9 @@ class StatePoint(object): for tally_id, tally in self._tallies.items(): + # Get the Tally name from the summary file + tally.name = summary.tallies[tally_id].name + nuclide_zaids = copy.deepcopy(tally._nuclides) for nuclide_zaid in nuclide_zaids: diff --git a/src/utils/openmc/summary.py b/src/utils/openmc/summary.py index 8eb524cae..be9ca7a7a 100644 --- a/src/utils/openmc/summary.py +++ b/src/utils/openmc/summary.py @@ -26,6 +26,7 @@ class Summary(object): self._read_metadata() self._read_geometry() + self._read_tallies() def _read_metadata(self): @@ -105,6 +106,7 @@ class Summary(object): material_id = int(key.lstrip('material ')) index = self._f['materials'][key]['index'][0] + name = self._f['materials'][key]['name'][0] density = self._f['materials'][key]['atom_density'][0] nuc_densities = self._f['materials'][key]['nuclide_densities'][...] nuclides = self._f['materials'][key]['nuclides'][...] @@ -123,7 +125,7 @@ class Summary(object): sab_xs.append(sab_table.split('.')[1]) # Create the Material - material = openmc.Material(material_id=material_id) + material = openmc.Material(material_id=material_id, name=name) # Set the Material's density to g/cm3 - this is what is used in OpenMC material.set_density(density=density, units='g/cm3') @@ -164,6 +166,7 @@ class Summary(object): surface_id = int(key.lstrip('surface ')) index = self._f['geometry/surfaces'][key]['index'][0] + name = self._f['geometry/surfaces'][key]['name'][0] surf_type = self._f['geometry/surfaces'][key]['type'][...][0] bc = self._f['geometry/surfaces'][key]['boundary_condition'][...][0] coeffs = self._f['geometry/surfaces'][key]['coefficients'][...] @@ -172,47 +175,47 @@ class Summary(object): if surf_type == 'X Plane': x0 = coeffs[0] - surface = openmc.XPlane(surface_id, bc, x0) + surface = openmc.XPlane(surface_id, bc, x0, name) elif surf_type == 'Y Plane': y0 = coeffs[0] - surface = openmc.YPlane(surface_id, bc, y0) + surface = openmc.YPlane(surface_id, bc, y0, name) elif surf_type == 'Z Plane': z0 = coeffs[0] - surface = openmc.ZPlane(surface_id, bc, z0) + surface = openmc.ZPlane(surface_id, bc, z0, name) elif surf_type == 'Plane': A = coeffs[0] B = coeffs[1] C = coeffs[2] D = coeffs[3] - surface = openmc.Plane(surface_id, bc, A, B, C, D) + surface = openmc.Plane(surface_id, bc, A, B, C, D, name) elif surf_type == 'X Cylinder': y0 = coeffs[0] z0 = coeffs[1] R = coeffs[2] - surface = openmc.XCylinder(surface_id, bc, y0, z0, R) + surface = openmc.XCylinder(surface_id, bc, y0, z0, R, name) elif surf_type == 'Y Cylinder': x0 = coeffs[0] z0 = coeffs[1] R = coeffs[2] - surface = openmc.YCylinder(surface_id, bc, x0, z0, R) + surface = openmc.YCylinder(surface_id, bc, x0, z0, R, name) elif surf_type == 'Z Cylinder': x0 = coeffs[0] y0 = coeffs[1] R = coeffs[2] - surface = openmc.ZCylinder(surface_id, bc, x0, y0, R) + surface = openmc.ZCylinder(surface_id, bc, x0, y0, R, name) elif surf_type == 'Sphere': x0 = coeffs[0] y0 = coeffs[1] z0 = coeffs[2] R = coeffs[3] - surface = openmc.Sphere(surface_id, bc, x0, y0, z0, R) + surface = openmc.Sphere(surface_id, bc, x0, y0, z0, R, name) elif surf_type in ['X Cone', 'Y Cone', 'Z Cone']: x0 = coeffs[0] @@ -221,11 +224,11 @@ class Summary(object): R2 = coeffs[3] if surf_type == 'X Cone': - surface = openmc.XCone(surface_id, bc, x0, y0, z0, R2) + surface = openmc.XCone(surface_id, bc, x0, y0, z0, R2, name) if surf_type == 'Y Cone': - surface = openmc.YCone(surface_id, bc, x0, y0, z0, R2) + surface = openmc.YCone(surface_id, bc, x0, y0, z0, R2, name) if surf_type == 'Z Cone': - surface = openmc.ZCone(surface_id, bc, x0, y0, z0, R2) + surface = openmc.ZCone(surface_id, bc, x0, y0, z0, R2, name) # Add Surface to global dictionary of all Surfaces self.surfaces[index] = surface @@ -255,6 +258,7 @@ class Summary(object): cell_id = int(key.lstrip('cell ')) index = self._f['geometry/cells'][key]['index'][0] + name = self._f['geometry/cells'][key]['name'][0] fill_type = self._f['geometry/cells'][key]['fill_type'][...][0] if fill_type == 'normal': @@ -270,7 +274,7 @@ class Summary(object): surfaces = [] # Create this Cell - cell = openmc.Cell(cell_id=cell_id) + cell = openmc.Cell(cell_id=cell_id, name=name) if fill_type == 'universe': maps = self._f['geometry/cells'][key]['maps'][0] @@ -354,6 +358,7 @@ class Summary(object): lattice_id = int(key.lstrip('lattice ')) index = self._f['geometry/lattices'][key]['index'][0] + name = self._f['geometry/lattices'][key]['name'][0] lattice_type = self._f['geometry/lattices'][key]['type'][...][0] maps = self._f['geometry/lattices'][key]['maps'][0] offset_size = self._f['geometry/lattices'][key]['offset_size'][0] @@ -374,11 +379,12 @@ class Summary(object): universe_ids = np.swapaxes(universe_ids, 1, 2) # Create the Lattice - lattice = openmc.RectLattice(lattice_id=lattice_id) + lattice = openmc.RectLattice(lattice_id=lattice_id, name=name) lattice.dimension = tuple(dimension) lattice.lower_left = lower_left lattice.pitch = pitch + # If the Universe specified outer the Lattice is not void (-22) if outer != -22: lattice.outer = self.universes[outer] @@ -419,7 +425,7 @@ class Summary(object): self._f['geometry/lattices'][key]['universes'][...] # Create the Lattice - lattice = openmc.HexLattice(lattice_id=lattice_id) + lattice = openmc.HexLattice(lattice_id=lattice_id, name=name) lattice.num_rings = n_rings lattice.num_axial = n_axial lattice.center = center @@ -478,6 +484,73 @@ class Summary(object): self.openmc_geometry.root_universe = root_universe + def _read_tallies(self): + + # Initialize dictionaries for the Tallies + # Keys - Tally IDs + # Values - Tally objects + self.tallies = {} + + # Read the number of tallies + self.n_tallies = self._f['tallies/n_tallies'][0] + + # OpenMC Tally keys + all_keys = self._f['tallies/'].keys() + tally_keys = [key for key in all_keys if 'tally' in key] + + base = 'tallies/tally ' + + # Iterate over all Tallies + for tally_key in tally_keys: + + tally_id = int(tally_key.strip('tally ')) + subbase = '{0}{1}'.format(base, tally_id) + + # Read Tally name metadata + name_size = self._f['{0}/name_size'.format(subbase)][0] + if (name_size > 0): + tally_name = self._f['{0}/name'.format(subbase)][0] + tally_name = tally_name.lstrip('[\'') + tally_name = tally_name.rstrip('\']') + else: + tally_name = '' + + # Create Tally object and assign basic properties + tally = openmc.Tally(tally_id, tally_name) + + # Read score metadata + score_bins = self._f['{0}/score_bins'.format(subbase)][...] + for score_bin in score_bins: + tally.add_score(openmc.SCORE_TYPES[score_bin]) + num_score_bins = self._f['{0}/n_score_bins'.format(subbase)][...] + tally.num_score_bins = num_score_bins + + # Read filter metadata + num_filters = self._f['{0}/n_filters'.format(subbase)][0] + + # Initialize all Filters + for j in range(1, num_filters+1): + + subsubbase = '{0}/filter {1}'.format(subbase, j) + + # Read filter type (e.g., "cell", "energy", etc.) + filter_type = self._f['{0}/type_name'.format(subsubbase)][0] + + # Read the filter bins + num_bins = self._f['{0}/n_bins'.format(subsubbase)][0] + bins = self._f['{0}/bins'.format(subsubbase)][...] + + # Create Filter object + filter = openmc.Filter(filter_type, bins) + filter.num_bins = num_bins + + # Add Filter to the Tally + tally.add_filter(filter) + + # Add Tally to the global dictionary of all Tallies + self.tallies[tally_id] = tally + + def make_opencg_geometry(self): if self.opencg_geometry is None: self.opencg_geometry = get_opencg_geometry(self.openmc_geometry) diff --git a/src/utils/openmc/surface.py b/src/utils/openmc/surface.py index ab7ad5a7d..0e958b456 100644 --- a/src/utils/openmc/surface.py +++ b/src/utils/openmc/surface.py @@ -133,6 +133,10 @@ class Surface(object): element = ET.Element("surface") element.set("id", str(self._id)) + + if len(self._name) > 0: + element.set("name", str(self._name)) + element.set("type", self._type) element.set("boundary", self._boundary_type) diff --git a/src/utils/openmc/tallies.py b/src/utils/openmc/tallies.py index b5817a60c..1dc8e536e 100644 --- a/src/utils/openmc/tallies.py +++ b/src/utils/openmc/tallies.py @@ -584,11 +584,11 @@ class Mesh(object): class Tally(object): - def __init__(self, tally_id=None, label=''): + def __init__(self, tally_id=None, name=''): # Initialize Tally class attributes self.id = tally_id - self.label = label + self.name = name self._filters = [] self._nuclides = [] self._scores = [] @@ -612,7 +612,7 @@ class Tally(object): clone = type(self).__new__(type(self)) clone._id = self._id - clone._label = self._label + clone._name = self._name clone._estimator = self._estimator clone._num_score_bins = self._num_score_bins clone._num_realizations = self._num_realizations @@ -678,7 +678,7 @@ class Tally(object): hashable.append(score) hashable.append(self._estimator) - hashable.append(self._label) + hashable.append(self._name) return hash(tuple(hashable)) @@ -699,8 +699,8 @@ class Tally(object): @property - def label(self): - return self._label + def name(self): + return self._name @property @@ -819,16 +819,16 @@ class Tally(object): self._id = tally_id - @label.setter - def label(self, label): + @name.setter + def name(self, name): - if not is_string(label): + if not is_string(name): msg = 'Unable to set name for Tally ID={0} with a non-string ' \ - 'value {1}'.format(self._id, label) + 'value {1}'.format(self._id, name) raise ValueError(msg) else: - self._label = label + self._name = name def add_filter(self, filter): @@ -945,7 +945,7 @@ class Tally(object): string = 'Tally\n' string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id) - string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._label) + string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name) string += '{0: <16}\n'.format('\tFilters') @@ -976,9 +976,9 @@ class Tally(object): # Tally ID element.set("id", str(self._id)) - # Optional Tally label - if self._label != '': - element.set("label", self._label) + # Optional Tally name + if self._name != '': + element.set("name", self._name) # Optional Tally filters for filter in self._filters: @@ -1220,7 +1220,7 @@ class Tally(object): # Add basic Tally data to the HDF5 group tally_group.create_dataset('id', data=self._id) - tally_group.create_dataset('label', data=self._label) + tally_group.create_dataset('name', data=self._name) tally_group.create_dataset('estimator', data=self._estimator) tally_group.create_dataset('scores', data=np.array(self._scores)) @@ -1268,7 +1268,7 @@ class Tally(object): # Add basic Tally data to the nested dictionary tally_group['id'] = self._id - tally_group['label'] = self._label + tally_group['name'] = self._name tally_group['estimator'] = self._estimator tally_group['scores'] = np.array(self._scores) diff --git a/src/utils/openmc/universe.py b/src/utils/openmc/universe.py index 711fe8cc0..d6e26ff38 100644 --- a/src/utils/openmc/universe.py +++ b/src/utils/openmc/universe.py @@ -339,6 +339,9 @@ class Cell(object): element = ET.Element("cell") element.set("id", str(self._id)) + if len(self._name) > 0: + element.set("name", str(self._name)) + if isinstance(self._fill, openmc.Material): element.set("material", str(self._fill._id)) @@ -981,6 +984,9 @@ class RectLattice(Lattice): lattice_subelement = ET.Element("lattice") lattice_subelement.set("id", str(self._id)) + if len(self._name) > 0: + lattice_subelement.set("name", str(self._name)) + # Export the Lattice cell pitch if len(self._pitch) == 3: pitch = ET.SubElement(lattice_subelement, "pitch") @@ -1307,6 +1313,9 @@ class HexLattice(Lattice): lattice_subelement = ET.Element("hex_lattice") lattice_subelement.set("id", str(self._id)) + if len(self._name) > 0: + lattice_subelement.set("name", str(self._name)) + # Export the Lattice cell pitch if len(self._pitch) == 2: pitch = ET.SubElement(lattice_subelement, "pitch") diff --git a/tests/test_cmfd_feed/results.py b/tests/test_cmfd_feed/results.py index b55ef8131..125d13a8e 100644 --- a/tests/test_cmfd_feed/results.py +++ b/tests/test_cmfd_feed/results.py @@ -6,6 +6,7 @@ import numpy as np sys.path.insert(0, '../../src/utils') # import statepoint +import openmc from openmc.statepoint import StatePoint # read in statepoint file @@ -17,37 +18,38 @@ else: sp.read_results() # extract tally results and convert to vector -tally1 = sp._tallies[1] -results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) -results1[0::2] = tally1._sum.ravel() -results1[1::2] = tally1._sum_sq.ravel() +tally1 = sp.get_tally('flux', [openmc.Filter('mesh', [1])], \ + [-1], estimator='tracklength') +tally2 = sp.get_tally('flux', [openmc.Filter('mesh', [2])], \ + [-1], estimator='analog') +tally3 = sp.get_tally('nu-fission', [openmc.Filter('mesh', [2])], \ + [-1], estimator='analog') +tally4 = sp.get_tally('current', [openmc.Filter('mesh', [2]), \ + openmc.Filter('surface', [1,2,3,4,5,6])], \ + [-1], estimator='analog') -for tally_id in sp._tallies: - if 'CMFD flux, total, scatter-1' in sp._tallies[tally_id]._label: - tally2 = sp._tallies[tally_id] - elif 'CMFD neutron production' in sp._tallies[tally_id]._label: - tally3 = sp._tallies[tally_id] - elif 'CMFD surface currents' in sp._tallies[tally_id]._label: - tally4 = sp._tallies[tally_id] +results1 = np.zeros((tally1.sum.size + tally1.sum.size, )) +results1[0::2] = tally1.sum.ravel() +results1[1::2] = tally1.sum_sq.ravel() -results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) -results2[0::2] = tally2._sum.ravel() -results2[1::2] = tally2._sum_sq.ravel() +results2 = np.zeros((tally2.sum.size + tally2.sum.size, )) +results2[0::2] = tally2.sum.ravel() +results2[1::2] = tally2.sum_sq.ravel() -results3 = np.zeros((tally3._sum.size + tally3._sum.size, )) -results3[0::2] = tally3._sum.ravel() -results3[1::2] = tally3._sum_sq.ravel() +results3 = np.zeros((tally3.sum.size + tally3.sum.size, )) +results3[0::2] = tally3.sum.ravel() +results3[1::2] = tally3.sum_sq.ravel() -results4 = np.zeros((tally4._sum.size + tally4._sum.size, )) -results4[0::2] = tally4._sum.ravel() -results4[1::2] = tally4._sum_sq.ravel() +results4 = np.zeros((tally4.sum.size + tally4.sum.size, )) +results4[0::2] = tally4.sum.ravel() +results4[1::2] = tally4.sum_sq.ravel() # set up output string outstr = '' # write out k-combined outstr += 'k-combined:\n' -outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1]) +outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) # write out tally results outstr += 'tally 1:\n' diff --git a/tests/test_cmfd_jfnk/results.py b/tests/test_cmfd_jfnk/results.py index b55ef8131..e104fbd9a 100644 --- a/tests/test_cmfd_jfnk/results.py +++ b/tests/test_cmfd_jfnk/results.py @@ -6,6 +6,7 @@ import numpy as np sys.path.insert(0, '../../src/utils') # import statepoint +import openmc from openmc.statepoint import StatePoint # read in statepoint file @@ -17,30 +18,31 @@ else: sp.read_results() # extract tally results and convert to vector -tally1 = sp._tallies[1] -results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) -results1[0::2] = tally1._sum.ravel() -results1[1::2] = tally1._sum_sq.ravel() +tally1 = sp.get_tally('flux', [openmc.Filter('mesh', [1])], \ + [-1], estimator='tracklength') +tally2 = sp.get_tally('flux', [openmc.Filter('mesh', [2])], \ + [-1], estimator='analog') +tally3 = sp.get_tally('nu-fission', [openmc.Filter('mesh', [2])], \ + [-1], estimator='analog') +tally4 = sp.get_tally('current', [openmc.Filter('mesh', [2]), \ + openmc.Filter('surface', [1,2,3,4,5,6])], \ + [-1], estimator='analog') -for tally_id in sp._tallies: - if 'CMFD flux, total, scatter-1' in sp._tallies[tally_id]._label: - tally2 = sp._tallies[tally_id] - elif 'CMFD neutron production' in sp._tallies[tally_id]._label: - tally3 = sp._tallies[tally_id] - elif 'CMFD surface currents' in sp._tallies[tally_id]._label: - tally4 = sp._tallies[tally_id] +results1 = np.zeros((tally1.sum.size + tally1.sum.size, )) +results1[0::2] = tally1.sum.ravel() +results1[1::2] = tally1.sum_sq.ravel() -results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) -results2[0::2] = tally2._sum.ravel() -results2[1::2] = tally2._sum_sq.ravel() +results2 = np.zeros((tally2.sum.size + tally2.sum.size, )) +results2[0::2] = tally2.sum.ravel() +results2[1::2] = tally2.sum_sq.ravel() -results3 = np.zeros((tally3._sum.size + tally3._sum.size, )) -results3[0::2] = tally3._sum.ravel() -results3[1::2] = tally3._sum_sq.ravel() +results3 = np.zeros((tally3.sum.size + tally3.sum.size, )) +results3[0::2] = tally3.sum.ravel() +results3[1::2] = tally3.sum_sq.ravel() -results4 = np.zeros((tally4._sum.size + tally4._sum.size, )) -results4[0::2] = tally4._sum.ravel() -results4[1::2] = tally4._sum_sq.ravel() +results4 = np.zeros((tally4.sum.size + tally4.sum.size, )) +results4[0::2] = tally4.sum.ravel() +results4[1::2] = tally4.sum_sq.ravel() # set up output string outstr = '' diff --git a/tests/test_cmfd_nofeed/results.py b/tests/test_cmfd_nofeed/results.py index b55ef8131..e104fbd9a 100644 --- a/tests/test_cmfd_nofeed/results.py +++ b/tests/test_cmfd_nofeed/results.py @@ -6,6 +6,7 @@ import numpy as np sys.path.insert(0, '../../src/utils') # import statepoint +import openmc from openmc.statepoint import StatePoint # read in statepoint file @@ -17,30 +18,31 @@ else: sp.read_results() # extract tally results and convert to vector -tally1 = sp._tallies[1] -results1 = np.zeros((tally1._sum.size + tally1._sum.size, )) -results1[0::2] = tally1._sum.ravel() -results1[1::2] = tally1._sum_sq.ravel() +tally1 = sp.get_tally('flux', [openmc.Filter('mesh', [1])], \ + [-1], estimator='tracklength') +tally2 = sp.get_tally('flux', [openmc.Filter('mesh', [2])], \ + [-1], estimator='analog') +tally3 = sp.get_tally('nu-fission', [openmc.Filter('mesh', [2])], \ + [-1], estimator='analog') +tally4 = sp.get_tally('current', [openmc.Filter('mesh', [2]), \ + openmc.Filter('surface', [1,2,3,4,5,6])], \ + [-1], estimator='analog') -for tally_id in sp._tallies: - if 'CMFD flux, total, scatter-1' in sp._tallies[tally_id]._label: - tally2 = sp._tallies[tally_id] - elif 'CMFD neutron production' in sp._tallies[tally_id]._label: - tally3 = sp._tallies[tally_id] - elif 'CMFD surface currents' in sp._tallies[tally_id]._label: - tally4 = sp._tallies[tally_id] +results1 = np.zeros((tally1.sum.size + tally1.sum.size, )) +results1[0::2] = tally1.sum.ravel() +results1[1::2] = tally1.sum_sq.ravel() -results2 = np.zeros((tally2._sum.size + tally2._sum.size, )) -results2[0::2] = tally2._sum.ravel() -results2[1::2] = tally2._sum_sq.ravel() +results2 = np.zeros((tally2.sum.size + tally2.sum.size, )) +results2[0::2] = tally2.sum.ravel() +results2[1::2] = tally2.sum_sq.ravel() -results3 = np.zeros((tally3._sum.size + tally3._sum.size, )) -results3[0::2] = tally3._sum.ravel() -results3[1::2] = tally3._sum_sq.ravel() +results3 = np.zeros((tally3.sum.size + tally3.sum.size, )) +results3[0::2] = tally3.sum.ravel() +results3[1::2] = tally3.sum_sq.ravel() -results4 = np.zeros((tally4._sum.size + tally4._sum.size, )) -results4[0::2] = tally4._sum.ravel() -results4[1::2] = tally4._sum_sq.ravel() +results4 = np.zeros((tally4.sum.size + tally4.sum.size, )) +results4[0::2] = tally4.sum.ravel() +results4[1::2] = tally4.sum_sq.ravel() # set up output string outstr = ''