openmc.ParticleProductionFilter

class openmc.ParticleProductionFilter(particles, energies=None, filter_id=None)[source]

Bins tally events based on secondary particle type and energy.

This filter bins secondary particles (e.g., photons, electrons, or recoils) produced in a reaction by particle type and, optionally, by energy. This is useful for constructing production matrices or analyzing secondary particle spectra. Note that unlike other energy filters, the weight that is applied is equal to the weight of the secondary particle. Thus, to obtain secondary particle production, it should be used in conjunction with the “events” score.

The incident particle type can be filtered using ParticleFilter.

Added in version 0.15.4.

Parameters:
  • particles (str, int, openmc.ParticleType, or iterable thereof) – Type(s) of secondary particle(s) to tally (‘photon’, ‘neutron’, etc.)

  • energies (Iterable of Real or str, optional) – A list of energy boundaries in [eV]; each successive pair defines a bin. Alternatively, the name of the group structure can be given as a string (must be a key in openmc.mgxs.GROUP_STRUCTURES). If not provided, the filter tallies total secondary particle production without energy binning.

  • filter_id (int, optional) – Unique identifier for the filter

Variables:
  • particles (list of openmc.ParticleType) – The secondary particle types this filter applies to

  • energies (numpy.ndarray or None) – Energy boundaries in [eV], or None if no energy binning

  • bins (list) – A list of bins; each element fully describes one bin. When energies are specified, each element is a tuple (particle, energy_low, energy_high). When no energies are specified, each element is a particle name string.

  • num_bins (int) – Total number of filter bins

  • num_energy_bins (int) – Number of energy bins (1 if no energies specified)

  • shape (tuple of int) – Shape of the filter as (n_particles, n_energy_bins)

check_bins(bins)[source]

Make sure given bins are valid for this filter.

Raises:
classmethod from_hdf5(group, **kwargs)[source]

Construct a new Filter instance from HDF5 data.

Parameters:

group (h5py.Group) – HDF5 group to read from

Keyword Arguments:

meshes (dict) – Dictionary mapping integer IDs to openmc.MeshBase objects. Only used for openmc.MeshFilter objects.

classmethod from_xml_element(elem, **kwargs)[source]

Generate a filter from an XML element

Parameters:
  • elem (lxml.etree._Element) – XML element

  • **kwargs – Keyword arguments (e.g., mesh information)

Returns:

Filter object

Return type:

openmc.Filter

get_pandas_dataframe(data_size, stride, **kwargs)[source]

Builds a Pandas DataFrame for the Filter’s bins.

This method constructs a Pandas DataFrame object for the filter with columns annotated by filter bin information. This is a helper method for Tally.get_pandas_dataframe().

Parameters:
  • data_size (int) – The total number of bins in the tally corresponding to this filter

  • stride (int) – Stride in memory for the filter

Returns:

A Pandas DataFrame with columns for particle type and, if energy bins are specified, energy bin boundaries.

Return type:

pandas.DataFrame

See also

Tally.get_pandas_dataframe, CrossFilter.get_pandas_dataframe

to_xml_element()[source]

Return XML Element representing the Filter.

Returns:

element – XML element containing filter data

Return type:

lxml.etree._Element