openmc.MeshMaterialVolumes

class openmc.MeshMaterialVolumes(materials: ndarray, volumes: ndarray, bboxes: ndarray | None = None)[source]

Results from a material volume in mesh calculation.

This class provides multiple ways of accessing information about material volumes in individual mesh elements. First, the class behaves like a dictionary that maps material IDs to an array of volumes equal in size to the number of mesh elements. Second, the class provides a by_element() method that gives all the material volumes for a specific mesh element.

Added in version 0.15.1.

Parameters:
  • materials (numpy.ndarray) – Array of shape (elements, max_materials) storing material IDs

  • volumes (numpy.ndarray) – Array of shape (elements, max_materials) storing material volumes

  • bboxes (numpy.ndarray, optional) – Array of shape (elements, max_materials, 6) storing axis-aligned bounding boxes for each (element, material) combination with ordering (xmin, ymin, zmin, xmax, ymax, zmax). Bounding boxes enclose the ray-estimator prisms used to compute volumes.

See also

openmc.MeshBase.material_volumes

Examples

If you want to get the volume of a specific material in every mesh element, index the object with the material ID:

>>> volumes = mesh.material_volumes(...)
>>> volumes
{1: <32121 nonzero volumes>
 2: <338186 nonzero volumes>
 3: <49120 nonzero volumes>}

If you want the volume of all materials in a specific mesh element, use the by_element() method:

>>> volumes = mesh.material_volumes(...)
>>> volumes.by_element(42)
[(2, 31.87963824195591), (1, 6.129949130817542)]
by_element(index_elem: int, include_bboxes: bool = False) list[tuple[int | None, float] | tuple[int | None, float, BoundingBox | None]][source]

Get a list of volumes for each material within a specific element.

Parameters:

index_elem (int) – Mesh element index

Returns:

If include_bboxes is False (default), returns tuples of (material ID, volume). If include_bboxes is True, returns tuples of (material ID, volume, bounding box).

Return type:

list of tuple

classmethod from_npz(filename: str | PathLike) MeshMaterialVolumes[source]

Generate material volumes from a .npz file

Parameters:

filename (path-like) – File where data will be read from

save(filename: str | PathLike)[source]

Save material volumes to a .npz file.

Parameters:

filename (path-like) – Filename where data will be saved