openmc.MeshSource¶
- class openmc.MeshSource(mesh: MeshBase, sources: Sequence[SourceBase], constraints: dict[str, Any] | None = None)[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.15.0.
- Parameters
mesh (openmc.MeshBase) – The mesh over which source sites will be generated.
sources (sequence of openmc.SourceBase) – Sources for each element in the mesh. Sources must be specified as either a 1-D array in the order of the mesh indices or a multidimensional array whose shape matches the mesh shape. If spatial distributions are set on any of the source objects, they will be ignored during source site sampling.
constraints (dict) – Constraints on sampled source particles. Valid keys include ‘domains’, ‘time_bounds’, ‘energy_bounds’, ‘fissionable’, and ‘rejection_strategy’. For ‘domains’, the corresponding value is an iterable of
openmc.Cell
,openmc.Material
, oropenmc.Universe
for which sampled sites must be within. For ‘time_bounds’ and ‘energy_bounds’, the corresponding value is a sequence of floats giving the lower and upper bounds on time in [s] or energy in [eV] that the sampled particle must be within. For ‘fissionable’, the value is a bool indicating that only sites in fissionable material should be accepted. The ‘rejection_strategy’ indicates what should happen when a source particle is rejected: either ‘resample’ (pick a new particle) or ‘kill’ (accept and terminate).
- Variables
mesh (openmc.MeshBase) – The mesh over which source sites will be generated.
sources (numpy.ndarray of openmc.SourceBase) – Sources to apply to each element
strength (float) – Strength of the source
type (str) – Indicator of source type: ‘mesh’
constraints (dict) – Constraints on sampled source particles. Valid keys include ‘domain_type’, ‘domain_ids’, ‘time_bounds’, ‘energy_bounds’, ‘fissionable’, and ‘rejection_strategy’.
- 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
- normalize_source_strengths()[source]¶
Update all element source strengths such that they sum to 1.0.