openmc.mgxs.CaptureXS

class openmc.mgxs.CaptureXS(domain=None, domain_type=None, groups=None, by_nuclide=False, name='')[source]

A capture multi-group cross section.

The neutron capture reaction rate is defined as the difference between OpenMC’s ‘absorption’ and ‘fission’ reaction rate score types. This includes not only radiative capture, but all forms of neutron disappearance aside from fission (i.e., MT > 100).

This class can be used for both OpenMC input generation and tally data post-processing to compute spatially-homogenized and energy-integrated multi-group capture cross sections for multi-group neutronics calculations. At a minimum, one needs to set the CaptureXS.energy_groups and CaptureXS.domain properties. Tallies for the flux and appropriate reaction rates over the specified domain are generated automatically via the CaptureXS.tallies property, which can then be appended to a openmc.Tallies instance.

For post-processing, the MGXS.load_from_statepoint() will pull in the necessary data to compute multi-group cross sections from a openmc.StatePoint instance. The derived multi-group cross section can then be obtained from the CaptureXS.xs_tally property.

For a spatial domain \(V\) and energy group \([E_g,E_{g-1}]\), the capture cross section is calculated as:

\[\frac{\int_{r \in V} dr \int_{4\pi} d\Omega \int_{E_g}^{E_{g-1}} dE \; \left [ \sigma_a (r, E) \psi (r, E, \Omega) - \sigma_f (r, E) \psi (r, E, \Omega) \right ]}{\int_{r \in V} dr \int_{4\pi} d\Omega \int_{E_g}^{E_{g-1}} dE \; \psi (r, E, \Omega)}.\]
Parameters:
  • domain (openmc.Material or openmc.Cell or openmc.Universe) – The domain for spatial homogenization
  • domain_type ({'material', 'cell', 'distribcell', 'universe'}) – The domain type for spatial homogenization
  • 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 multi-group cross section. Used as a label to identify tallies in OpenMC ‘tallies.xml’ file.
Variables:
  • name (str, optional) – Name of the multi-group cross section
  • rxn_type (str) – Reaction type (e.g., ‘total’, ‘nu-fission’, etc.)
  • by_nuclide (bool) – If true, computes cross sections for each nuclide in domain
  • domain (Material or Cell or Universe) – Domain for spatial homogenization
  • domain_type ({'material', 'cell', 'distribcell', 'universe'}) – Domain type for spatial homogenization
  • energy_groups (openmc.mgxs.EnergyGroups) – Energy group structure for energy condensation
  • 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 multi-group cross section
  • filters (list of openmc.Filter) – The filters in each tally used to compute the multi-group cross section
  • tally_keys (list of str) – The keys into the tallies dictionary for each tally used to compute the multi-group cross section
  • estimator ({'tracklength', 'analog'}) – The tally estimator used to compute the multi-group cross section
  • tallies (collections.OrderedDict) – OpenMC tallies needed to compute the multi-group cross section. The keys are strings listed in the CaptureXS.tally_keys property and values are instances of openmc.Tally.
  • rxn_rate_tally (openmc.Tally) – Derived tally for the reaction rate tally used in the numerator to compute the multi-group cross section. This attribute is None unless the multi-group cross section has been computed.
  • xs_tally (openmc.Tally) – Derived tally for the multi-group cross section. This attribute is None unless the multi-group cross section has been computed.
  • num_subdomains (int) – The number of subdomains is unity for ‘material’, ‘cell’ and ‘universe’ domain types. When the 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).
  • num_nuclides (int) – The number of nuclides for which the multi-group cross section is being tracked. This is unity if the by_nuclide attribute is False.
  • nuclides (Iterable of str or 'sum') – The optional user-specified nuclides for which to compute cross sections (e.g., ‘U-238’, ‘O-16’). 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 multi-group 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)

Export the multi-group cross section data to an HDF5 binary file.

This method constructs an HDF5 file which stores the multi-group 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 cross-sections to include in the report. This may be a list of nuclide name strings (e.g., [‘U-235’, ‘U-238’]). 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.
Raises:
  • ValueError – When this method is called before the multi-group cross section is computed from tally data.
  • ImportError – When h5py is not installed.
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')

Export the multi-group cross section data to a file.

This method leverages the functionality in the Pandas library to export the multi-group cross section data in a variety of output file formats for storage and/or post-processing.

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’.
get_all_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., [‘U-235’, ‘U-238’, ‘O-16’])
Return type:list of str
Raises:ValueError – When this method is called before the spatial domain has been set.
get_condensed_xs(coarse_groups)

Construct an energy-condensed 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_mgxs(mgxs_type, domain=None, domain_type=None, energy_groups=None, by_nuclide=False, name='')

Return a MGXS 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 MGXS subclass objects for various reaction types.

Parameters:
  • mgxs_type ({'total', 'transport', 'nu-transport', 'absorption', 'capture', 'fission', 'nu-fission', 'kappa-fission', 'scatter', 'nu-scatter', 'scatter matrix', 'nu-scatter matrix', 'multiplicity matrix', 'nu-fission matrix', chi'}) – The type of multi-group cross section object to return
  • domain (openmc.Material or openmc.Cell or openmc.Universe) – The domain for spatial homogenization
  • domain_type ({'material', 'cell', 'distribcell', 'universe'}) – 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 multi-group cross section. Used as a label to identify tallies in OpenMC ‘tallies.xml’ file. Defaults to the empty string.
Returns:

A subclass of the abstract MGXS class for the multi-group cross section type requested by the user

Return type:

openmc.mgxs.MGXS

get_nuclide_densities(nuclides='all')

Get an array of atomic number densities in units of atom/b-cm 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., [‘U-235’, ‘U-238’]). 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/b-cm) 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/b-cm for a nuclide in the cross section’s spatial domain.

Parameters:nuclide (str) – A nuclide name string (e.g., ‘U-235’)
Returns:The atomic number density (atom/b-cm) for the nuclide of interest
Return type:float
Raises:ValueError – When the density is requested for a nuclide which is not found in the spatial domain.
get_pandas_dataframe(groups='all', nuclides='all', xs_type='macro', distribcell_paths=True)

Build a Pandas DataFrame for the MGXS 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 cross-sections to include in the dataframe. This may be a list of nuclide name strings (e.g., [‘U-235’, ‘U-238’]). 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’.
  • distribcell_paths (bool, optional) – Construct columns for distribcell tally filters (default is True). The geometric information in the Summary object is embedded into a Multi-index column with a geometric “path” to each distribcell instance.
Returns:

A Pandas DataFrame for the cross section data.

Return type:

pandas.DataFrame

Raises:

ValueError – When this method is called before the multi-group cross section is computed from tally data.

get_slice(nuclides=[], groups=[])

Build a sliced MGXS for the specified nuclides and energy groups.

This method constructs a new MGXS to encapsulate a subset of the data represented by this MGXS. The subset of data to include in the tally slice is determined by the nuclides and energy groups specified in the input parameters.

Parameters:
  • nuclides (list of str) – A list of nuclide name strings (e.g., [‘U-235’, ‘U-238’]; 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 [])
Returns:

A new MGXS object which encapsulates the subset of data requested for the nuclide(s) and/or energy group(s) requested in the parameters.

Return type:

openmc.mgxs.MGXS

get_subdomain_avg_xs(subdomains='all')

Construct a subdomain-averaged 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 flux-weighted 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 multi-group cross section is computed from tally data.
get_xs(groups='all', subdomains='all', nuclides='all', xs_type='macro', order_groups='increasing', value='mean', **kwargs)

Returns an array of multi-group cross sections.

This method constructs a 2D NumPy array for the requested multi-group cross section data data for one or more energy groups and subdomains.

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., [‘U-235’, ‘U-238’]). 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’.
Returns:

A NumPy array of the multi-group cross section indexed in the order each group, subdomain and nuclide is listed in the parameters.

Return type:

numpy.ndarray

Raises:

ValueError – When this method is called before the multi-group cross section is computed from tally data.

load_from_statepoint(statepoint)

Extracts tallies in an OpenMC StatePoint with the data needed to compute multi-group cross sections.

This method is needed to compute cross section data from tallies in an OpenMC StatePoint object.

NOTE: The statepoint must first 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)

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.MGXS) – MGXS to merge with this one
Returns:merged_mgxs – Merged MGXS
Return type:openmc.mgxs.MGXS
print_xs(subdomains='all', nuclides='all', xs_type='macro')

Print a string representation for the multi-group 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 cross-sections to include in the report. This may be a list of nuclide name strings (e.g., [‘U-235’, ‘U-238’]). 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’.