openmc.MeshMaterialVolumes¶
- class openmc.MeshMaterialVolumes(materials: ndarray, volumes: ndarray)[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.New 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
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) list[tuple[int | None, float]] [source]¶
Get a list of volumes for each material within a specific element.
- Parameters
index_elem (int) – Mesh element index
- Return type
list of tuple of (material ID, volume)
- classmethod from_npz(filename: str | os.PathLike) MeshMaterialVolumes [source]¶
Generate material volumes from a .npz file
- Parameters
filename (path-like) – File where data will be read from
- save(filename: str | os.PathLike)[source]¶
Save material volumes to a .npz file.
- Parameters
filename (path-like) – Filename where data will be saved