openmc.MeshSource

class openmc.MeshSource(mesh: MeshBase, sources: Sequence[SourceBase])[source]

A source with a spatial distribution over mesh elements

This class represents a mesh-based source in which random positions are uniformly sampled within mesh elements and each element can have independent angle, energy, and time distributions. The element sampled is chosen based on the relative strengths of the sources applied to the elements. The strength of the mesh source as a whole is the sum of all source strengths applied to the elements.

New in version 0.14.1.

Parameters
  • mesh (openmc.MeshBase) – The mesh over which source sites will be generated.

  • sources (iterable of openmc.SourceBase) – Sources for each element in the mesh. If spatial distributions are set on any of the source objects, they will be ignored during source site sampling.

Variables
  • mesh (openmc.MeshBase) – The mesh over which source sites will be generated.

  • sources (numpy.ndarray or iterable of openmc.SourceBase) – The set of sources to apply to each element. The shape of this array must match the shape of the mesh with and exception in the case of unstructured mesh, which allows for application of 1-D array or iterable.

  • strength (float) – Strength of the source

  • type (str) – Indicator of source type: ‘mesh’

classmethod from_xml_element(elem: Element, meshes) MeshSource[source]

Generate MeshSource from an XML element

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

  • meshes (dict) – A dictionary with mesh IDs as keys and openmc.MeshBase instances as values

Returns

MeshSource generated from the XML element

Return type

openmc.MeshSource

normalize_source_strengths()[source]

Update all element source strengths such that they sum to 1.0.

populate_xml_element(elem: Element)[source]

Add necessary source information to an XML element

Returns

element – XML element containing source data

Return type

lxml.etree._Element

set_total_strength(strength: float)[source]

Scales the element source strengths based on a desired total strength.

Parameters

strength (float) – Total source strength