openmc.mgxs.MDGXS¶

class
openmc.mgxs.
MDGXS
(domain=None, domain_type=None, energy_groups=None, delayed_groups=None, by_nuclide=False, name='', num_polar=1, num_azimuthal=1)[source]¶ An abstract multidelayedgroup cross section for some energy and delayed group structures within some spatial domain.
This class can be used for both OpenMC input generation and tally data postprocessing to compute spatiallyhomogenized and energyintegrated multigroup and multidelayedgroup cross sections for downstream neutronics calculations.
NOTE: Users should instantiate the subclasses of this abstract class.
Parameters:  domain (openmc.Material or openmc.Cell or openmc.Universe or openmc.RegularMesh) – The domain for spatial homogenization
 domain_type ({'material', 'cell', 'distribcell', 'universe', 'mesh'}) – The domain type for spatial homogenization
 energy_groups (openmc.mgxs.EnergyGroups) – The energy group structure for energy condensation
 by_nuclide (bool) – If true, computes cross sections for each nuclide in domain
 name (str, optional) – Name of the multigroup cross section. Used as a label to identify tallies in OpenMC ‘tallies.xml’ file.
 delayed_groups (list of int) – Delayed groups to filter out the xs
 num_polar (Integral, optional) – Number of equiwidth polar angle bins for angle discretization; defaults to one bin
 num_azimuthal (Integral, optional) – Number of equiwidth azimuthal angle bins for angle discretization; defaults to one bin
Variables:  name (str, optional) – Name of the multigroup cross section
 rxn_type (str) – Reaction type (e.g., ‘chidelayed’, ‘beta’, etc.)
 by_nuclide (bool) – If true, computes cross sections for each nuclide in domain
 domain (openmc.Material or openmc.Cell or openmc.Universe or openmc.RegularMesh) – Domain for spatial homogenization
 domain_type ({'material', 'cell', 'distribcell', 'universe', 'mesh'}) – Domain type for spatial homogenization
 energy_groups (openmc.mgxs.EnergyGroups) – Energy group structure for energy condensation
 delayed_groups (list of int) – Delayed groups to filter out the xs
 num_polar (Integral) – Number of equiwidth polar angle bins for angle discretization
 num_azimuthal (Integral) – Number of equiwidth azimuthal angle bins for angle discretization
 tally_trigger (openmc.Trigger) – An (optional) tally precision trigger given to each tally used to compute the cross section
 scores (list of str) – The scores in each tally used to compute the multigroup cross section
 filters (list of openmc.Filter) – The filters in each tally used to compute the multigroup cross section
 tally_keys (list of str) – The keys into the tallies dictionary for each tally used to compute the multigroup cross section
 estimator ({'tracklength', 'analog'}) – The tally estimator used to compute the multigroup cross section
 tallies (collections.OrderedDict) – OpenMC tallies needed to compute the multigroup cross section
 rxn_rate_tally (openmc.Tally) – Derived tally for the reaction rate tally used in the numerator to compute the multigroup cross section. This attribute is None unless the multigroup cross section has been computed.
 xs_tally (openmc.Tally) – Derived tally for the multigroup cross section. This attribute is None unless the multigroup cross section has been computed.
 num_subdomains (int) – The number of subdomains is unity for ‘material’, ‘cell’, and ‘universe’ domain types. This is equal to the number of cell instances for ‘distribcell’ domain types (it is equal to unity prior to loading tally data from a statepoint file) and the number of mesh cells for ‘mesh’ domain types.
 num_nuclides (int) – The number of nuclides for which the multigroup cross section is being tracked. This is unity if the by_nuclide attribute is False.
 nuclides (Iterable of str or 'sum') – The optional userspecified nuclides for which to compute cross sections (e.g., ‘U238’, ‘O16’). If by_nuclide is True but nuclides are not specified by the user, all nuclides in the spatial domain are included. This attribute is ‘sum’ if by_nuclide is false.
 sparse (bool) – Whether or not the MGXS’ tallies use SciPy’s LIL sparse matrix format for compressed data storage
 loaded_sp (bool) – Whether or not a statepoint file has been loaded with tally data
 derived (bool) – Whether or not the MGXS is merged from one or more other MGXS
 hdf5_key (str) – The key used to index multigroup cross sections in an HDF5 data store

build_hdf5_store
(filename='mgxs.h5', directory='mgxs', subdomains='all', nuclides='all', xs_type='macro', row_column='inout', append=True, libver='earliest')¶ Export the multigroup cross section data to an HDF5 binary file.
This method constructs an HDF5 file which stores the multigroup cross section data. The data is stored in a hierarchy of HDF5 groups from the domain type, domain id, subdomain id (for distribcell domains), nuclides and cross section type. Two datasets for the mean and standard deviation are stored for each subdomain entry in the HDF5 file.
Note
This requires the h5py Python package.
Parameters:  filename (str) – Filename for the HDF5 file. Defaults to ‘mgxs.h5’.
 directory (str) – Directory for the HDF5 file. Defaults to ‘mgxs’.
 subdomains (Iterable of Integral or 'all') – The subdomain IDs of the cross sections to include in the report. Defaults to ‘all’.
 nuclides (Iterable of str or 'all' or 'sum') – The nuclides of the crosssections to include in the report. This may be a list of nuclide name strings (e.g., [‘U235’, ‘U238’]). The special string ‘all’ will report the cross sections for all nuclides in the spatial domain. The special string ‘sum’ will report the cross sections summed over all nuclides. Defaults to ‘all’.
 xs_type ({'macro', 'micro'}) – Store the macro or micro cross section in units of cm^1 or barns. Defaults to ‘macro’.
 row_column ({'inout', 'outin'}) – Store scattering matrices indexed first by incoming group and second by outgoing group (‘inout’), or vice versa (‘outin’). Defaults to ‘inout’.
 append (bool) – If true, appends to an existing HDF5 file with the same filename directory (if one exists). Defaults to True.
 libver ({'earliest', 'latest'}) – Compatibility mode for the HDF5 file. ‘latest’ will produce files that are less backwards compatible but have performance benefits.
Raises: ValueError
– When this method is called before the multigroup cross section is computed from tally data.

can_merge
(other)¶ Determine if another MGXS can be merged with this one
If results have been loaded from a statepoint, then MGXS are only mergeable along one and only one of enegy groups or nuclides.
Parameters: other (openmc.mgxs.MGXS) – MGXS to check for merging

export_xs_data
(filename='mgxs', directory='mgxs', format='csv', groups='all', xs_type='macro', delayed_groups='all')[source]¶ Export the multidelayedgroup cross section data to a file.
This method leverages the functionality in the Pandas library to export the multigroup cross section data in a variety of output file formats for storage and/or postprocessing.
Parameters:  filename (str) – Filename for the exported file. Defaults to ‘mgxs’.
 directory (str) – Directory for the exported file. Defaults to ‘mgxs’.
 format ({'csv', 'excel', 'pickle', 'latex'}) – The format for the exported data file. Defaults to ‘csv’.
 groups (Iterable of Integral or 'all') – Energy groups of interest. Defaults to ‘all’.
 xs_type ({'macro', 'micro'}) – Store the macro or micro cross section in units of cm^1 or barns. Defaults to ‘macro’.
 delayed_groups (list of int or 'all') – Delayed groups of interest. Defaults to ‘all’.

get_condensed_xs
(coarse_groups)¶ Construct an energycondensed version of this cross section.
Parameters: coarse_groups (openmc.mgxs.EnergyGroups) – The coarse energy group structure of interest Returns: A new MGXS condensed to the group structure of interest Return type: MGXS

get_homogenized_mgxs
(other_mgxs)¶ Construct a homogenized mgxs with other MGXS objects.
Parameters: other_mgxs (openmc.mgxs.MGXS or Iterable of openmc.mgxs.MGXS) – The MGXS to homogenize with this one. Returns: A new homogenized MGXS Return type: openmc.mgxs.MGXS Raises: ValueError
– If the other_mgxs is of a different type.

static
get_mgxs
(mdgxs_type, domain=None, domain_type=None, energy_groups=None, delayed_groups=None, by_nuclide=False, name='', num_polar=1, num_azimuthal=1)[source]¶ Return a MDGXS subclass object for some energy group structure within some spatial domain for some reaction type.
This is a factory method which can be used to quickly create MDGXS subclass objects for various reaction types.
Parameters:  mdgxs_type ({'delayednufission', 'chidelayed', 'beta', 'decayrate', 'delayednufission matrix'}) – The type of multidelayedgroup cross section object to return
 domain (openmc.Material or openmc.Cell or openmc.Universe or) – openmc.RegularMesh The domain for spatial homogenization
 domain_type ({'material', 'cell', 'distribcell', 'universe', 'mesh'}) – The domain type for spatial homogenization
 energy_groups (openmc.mgxs.EnergyGroups) – The energy group structure for energy condensation
 by_nuclide (bool) – If true, computes cross sections for each nuclide in domain. Defaults to False
 name (str, optional) – Name of the multigroup cross section. Used as a label to identify tallies in OpenMC ‘tallies.xml’ file. Defaults to the empty string.
 delayed_groups (list of int) – Delayed groups to filter out the xs
 num_polar (Integral, optional) – Number of equiwidth polar angle bins for angle discretization; defaults to one bin
 num_azimuthal (Integral, optional) – Number of equiwidth azimuthal angle bins for angle discretization; defaults to one bin
Returns: A subclass of the abstract MDGXS class for the multidelayedgroup cross section type requested by the user
Return type:

get_nuclide_densities
(nuclides='all')¶ Get an array of atomic number densities in units of atom/bcm for all nuclides in the cross section’s spatial domain.
Parameters: nuclides (Iterable of str or 'all' or 'sum') – A list of nuclide name strings (e.g., [‘U235’, ‘U238’]). The special string ‘all’ will return the atom densities for all nuclides in the spatial domain. The special string ‘sum’ will return the atom density summed across all nuclides in the spatial domain. Defaults to ‘all’. Returns: An array of the atomic number densities (atom/bcm) for each of the nuclides in the spatial domain Return type: numpy.ndarray of float Raises: ValueError
– When this method is called before the spatial domain has been set.

get_nuclide_density
(nuclide)¶ Get the atomic number density in units of atoms/bcm for a nuclide in the cross section’s spatial domain.
Parameters: nuclide (str) – A nuclide name string (e.g., ‘U235’) Returns: The atomic number density (atom/bcm) for the nuclide of interest Return type: float

get_nuclides
()¶ Get all nuclides in the cross section’s spatial domain.
Returns: A list of the string names for each nuclide in the spatial domain (e.g., [‘U235’, ‘U238’, ‘O16’]) Return type: list of str Raises: ValueError
– When this method is called before the spatial domain has been set.

get_pandas_dataframe
(groups='all', nuclides='all', xs_type='macro', paths=True, delayed_groups='all')[source]¶ Build a Pandas DataFrame for the MDGXS data.
This method leverages
openmc.Tally.get_pandas_dataframe()
, but renames the columns with terminology appropriate for cross section data.Parameters:  groups (Iterable of Integral or 'all') – Energy groups of interest. Defaults to ‘all’.
 nuclides (Iterable of str or 'all' or 'sum') – The nuclides of the crosssections to include in the dataframe. This may be a list of nuclide name strings (e.g., [‘U235’, ‘U238’]). The special string ‘all’ will include the cross sections for all nuclides in the spatial domain. The special string ‘sum’ will include the cross sections summed over all nuclides. Defaults to ‘all’.
 xs_type ({'macro', 'micro'}) – Return macro or micro cross section in units of cm^1 or barns. Defaults to ‘macro’.
 paths (bool, optional) – Construct columns for distribcell tally filters (default is True). The geometric information in the Summary object is embedded into a Multiindex column with a geometric “path” to each distribcell instance.
 delayed_groups (list of int or 'all') – Delayed groups of interest. Defaults to ‘all’.
Returns: A Pandas DataFrame for the cross section data.
Return type: Raises: ValueError
– When this method is called before the multidelayedgroup cross section is computed from tally data.

get_slice
(nuclides=[], groups=[], delayed_groups=[])[source]¶ Build a sliced MDGXS for the specified nuclides, energy groups, and delayed groups.
This method constructs a new MDGXS to encapsulate a subset of the data represented by this MDGXS. The subset of data to include in the tally slice is determined by the nuclides, energy groups, delayed groups specified in the input parameters.
Parameters:  nuclides (list of str) – A list of nuclide name strings (e.g., [‘U235’, ‘U238’]; default is [])
 groups (list of int) – A list of energy group indices starting at 1 for the high energies (e.g., [1, 2, 3]; default is [])
 delayed_groups (list of int) – A list of delayed group indices (e.g., [1, 2, 3]; default is [])
Returns: A new MDGXS object which encapsulates the subset of data requested for the nuclide(s) and/or energy group(s) and/or delayed group(s) requested in the parameters.
Return type:

get_subdomain_avg_xs
(subdomains='all')¶ Construct a subdomainaveraged version of this cross section.
This method is useful for averaging cross sections across distribcell instances. The method performs spatial homogenization to compute the scalar fluxweighted average cross section across the subdomains.
Parameters: subdomains (Iterable of Integral or 'all') – The subdomain IDs to average across. Defaults to ‘all’. Returns: A new MGXS averaged across the subdomains of interest Return type: openmc.mgxs.MGXS Raises: ValueError
– When this method is called before the multigroup cross section is computed from tally data.

get_units
(xs_type='macro')¶ This method returns the units of a MGXS based on a desired xs_type.
Parameters: xs_type ({'macro', 'micro'}) – Return the macro or micro cross section units. Defaults to ‘macro’. Returns: A string representing the units of the MGXS. Return type: str

get_xs
(groups='all', subdomains='all', nuclides='all', xs_type='macro', order_groups='increasing', value='mean', delayed_groups='all', squeeze=True, **kwargs)[source]¶ Returns an array of multidelayedgroup cross sections.
This method constructs a 4D NumPy array for the requested multidelayedgroup cross section data for one or more subdomains (1st dimension), delayed groups (2nd demension), energy groups (3rd dimension), and nuclides (4th dimension).
Parameters:  groups (Iterable of Integral or 'all') – Energy groups of interest. Defaults to ‘all’.
 subdomains (Iterable of Integral or 'all') – Subdomain IDs of interest. Defaults to ‘all’.
 nuclides (Iterable of str or 'all' or 'sum') – A list of nuclide name strings (e.g., [‘U235’, ‘U238’]). The special string ‘all’ will return the cross sections for all nuclides in the spatial domain. The special string ‘sum’ will return the cross section summed over all nuclides. Defaults to ‘all’.
 xs_type ({'macro', 'micro'}) – Return the macro or micro cross section in units of cm^1 or barns. Defaults to ‘macro’.
 order_groups ({'increasing', 'decreasing'}) – Return the cross section indexed according to increasing or decreasing energy groups (decreasing or increasing energies). Defaults to ‘increasing’.
 value ({'mean', 'std_dev', 'rel_err'}) – A string for the type of value to return. Defaults to ‘mean’.
 delayed_groups (list of int or 'all') – Delayed groups of interest. Defaults to ‘all’.
 squeeze (bool) – A boolean representing whether to eliminate the extra dimensions of the multidimensional array to be returned. Defaults to True.
Returns: A NumPy array of the multigroup cross section indexed in the order each group, subdomain and nuclide is listed in the parameters.
Return type: Raises: ValueError
– When this method is called before the multidelayedgroup cross section is computed from tally data.

load_from_statepoint
(statepoint)¶ Extracts tallies in an OpenMC StatePoint with the data needed to compute multigroup cross sections.
This method is needed to compute cross section data from tallies in an OpenMC StatePoint object.
Note
The statepoint must be linked with an OpenMC Summary object.
Parameters: statepoint (openmc.StatePoint) – An OpenMC StatePoint object with tally data Raises: ValueError
– When this method is called with a statepoint that has not been linked with a summary object.

merge
(other)[source]¶ Merge another MGXS with this one
MGXS are only mergeable if their energy groups and nuclides are either identical or mutually exclusive. If results have been loaded from a statepoint, then MGXS are only mergeable along one and only one of energy groups or nuclides.
Parameters: other (openmc.mgxs.MDGXS) – MDGXS to merge with this one Returns: merged_mdgxs – Merged MDGXS Return type: openmc.mgxs.MDGXS

print_xs
(subdomains='all', nuclides='all', xs_type='macro')[source]¶ Print a string representation for the multigroup cross section.
Parameters:  subdomains (Iterable of Integral or 'all') – The subdomain IDs of the cross sections to include in the report. Defaults to ‘all’.
 nuclides (Iterable of str or 'all' or 'sum') – The nuclides of the crosssections to include in the report. This may be a list of nuclide name strings (e.g., [‘U235’, ‘U238’]). The special string ‘all’ will report the cross sections for all nuclides in the spatial domain. The special string ‘sum’ will report the cross sections summed over all nuclides. Defaults to ‘all’.
 xs_type ({'macro', 'micro'}) – Return the macro or micro cross section in units of cm^1 or barns. Defaults to ‘macro’.