openmc.EnergyFilter

class openmc.EnergyFilter(values, filter_id=None)[source]

Bins tally events based on incident particle energy.

Parameters
  • values (Iterable of Real) – A list of values for which each successive pair constitutes a range of energies in [eV] for a single bin

  • filter_id (int) – Unique identifier for the filter

Variables
  • values (numpy.ndarray) – An array of values for which each successive pair constitutes a range of energies in [eV] for a single bin

  • id (int) – Unique identifier for the filter

  • bins (numpy.ndarray) – An array of shape (N, 2) where each row is a pair of energies in [eV] for a single filter bin

  • num_bins (int) – The number of filter bins

check_bins(bins)[source]

Make sure given bins are valid for this filter.

Raises
classmethod from_group_structure(group_structure)[source]

Construct an EnergyFilter instance from a standard group structure.

New in version 0.13.1.

Parameters

group_structure (str) – Name of the group structure. Must be a valid key of openmc.mgxs.GROUP_STRUCTURES dictionary.

get_bin_index(filter_bin)[source]

Returns the index in the Filter for some bin.

Parameters

filter_bin (int or tuple) – The bin is the integer ID for ‘material’, ‘surface’, ‘cell’, ‘cellborn’, and ‘universe’ Filters. The bin is an integer for the cell instance ID for ‘distribcell’ Filters. The bin is a 2-tuple of floats for ‘energy’ and ‘energyout’ filters corresponding to the energy boundaries of the bin of interest. The bin is an (x,y,z) 3-tuple for ‘mesh’ filters corresponding to the mesh cell of interest.

Returns

filter_index – The index in the Tally data array for this filter bin.

Return type

int

get_tabular(values, **kwargs)[source]

Create a tabulated distribution based on tally results with an energy filter

This method provides an easy way to create a distribution in energy (e.g., a source spectrum) based on tally results that were obtained from using an EnergyFilter.

New in version 0.13.3.

Parameters
  • values (iterable of float) – Array of numeric values, typically from a tally result

  • **kwargs – Keyword arguments passed to openmc.stats.Tabular

Returns

Tabular distribution with histogram interpolation

Return type

openmc.stats.Tabular

property lethargy_bin_width

Calculates the base 10 log width of energy bins which is useful when plotting the normalized flux.

Returns

Array of bin widths

Return type

numpy.array