mckit_meshes.mesh package¶
Submodules¶
mckit_meshes.mesh.geometry_spec module¶
Common for weight and tally meshes geometry specification classes and functions.
## Relative or absolute coordinates
There are variations when coordinates are presented as relative to origin or absolute. This depends on: 1) is the output is for MCNP specification or input/output to Weight of Meshtal files 2) is it cartesian or cylinder mesh.
Cartesian:
| wwinp | meshtal |===== | ======= | ======== |spec | relative | absolute (but origin is extracted to separate item) |—– | ——- | ——– |file | relative | absolute |Cylinder:
| wwinp | meshtal |===== | ======= | ======== |spec | relative | relative |—– | ——- | ——– |file | relative | relative |The new callers are to use local_coordinates converter to avoid difficulties. For the old callers we will use ZERO_ORIGIN for Geometry Specification being used in FMesh.
- class mckit_meshes.mesh.geometry_spec.AbstractGeometrySpec[source]¶
Bases:
AbstractGeometrySpecData,ABCCommon base for rectilinear and cylinder mesh specifications.
- property bins_shape: tuple[int, int, int]¶
Shape of data corresponding to spatial bins.
- Returns:
Tuple with the data shape.
- property bins_size: int¶
Size of data corresponding to spatial bins.
- Returns:
number of voxels
- Return type:
- abstractmethod get_mean_square_distance_weights(point)[source]¶
Estimate weights as a voxel mean square distance from the point.
- select_indexes(*, i_values=None, j_values=None, k_values=None)[source]¶
Select indices for data corresponding to given spatial values.
- Parameters:
i_values – indices along i (X or R) dimension
j_values – … along j (Y or Z)
k_values – … along k (Z or Theta)
- Return type:
tuple[int|slice|ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]],int|slice|ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]],int|slice|ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]]- Returns:
see
select_indexes()
- class mckit_meshes.mesh.geometry_spec.AbstractGeometrySpecData[source]¶
Bases:
objectData mixin for
AbstractGeometrySpec.Provides reusable data fields.
Notes
The meaning of origin is different for cartesian and cylindrical meshes
In cartesian mesh origin means most negative coordinates, all the coordinates (ibins, jbins, kbins) are absolute (or in coordinate system given with transformation).
In cylindrical mesh origin is a center of a cylinder bottom, the coordinates are relative to the coordinate system given with origin, axs and vec. Plus, if specified, in coordinate system given with transformation.
- __init__(ibins, jbins, kbins)¶
- class mckit_meshes.mesh.geometry_spec.CartesianGeometrySpec[source]¶
Bases:
AbstractGeometrySpec- get_mean_square_distance_weights(point)[source]¶
Estimate weights as a voxel mean square distance from the point.
- Parameters:
point – … from where to compute distance
- class mckit_meshes.mesh.geometry_spec.CylinderGeometrySpec[source]¶
Bases:
AbstractGeometrySpecCylinder spec.
- axs¶
cylinder axis
- vec¶
vector to measure angle (theta) from
- __init__(ibins, jbins, kbins, origin, axs=<factory>, vec=<factory>)¶
- adjust_axs_vec_for_mcnp()[source]¶
Set axs and vec attributes to the values, which MCNP considers orthogonal.
- Return type:
Assumptions¶
- Cylinder mesh is not tilted:
self.vec is in PY=0 plane
self.axs is vertical
Returns:¶
: gs:
new CylinderGeometrySpec with adjusted axs and vec attributes.
- property bins: tuple[ndarray[tuple[Any, ...], dtype[floating]], ...]¶
Pack the fields to tuple.
- Returns:
tuple of bins.
- get_mean_square_distance_weights(point)[source]¶
Estimate weights as a voxel mean square distance from the point.
- mckit_meshes.mesh.geometry_spec.as_float_array(array)[source]¶
Convert any sequence of numbers to numpy array of floats.
Note
We rely on unified representation all the ‘floats’ with Python float.
- mckit_meshes.mesh.geometry_spec.compute_intervals_and_coarse_bins(arr, tolerance=0.0001)[source]¶
Compute fine intervals and coarse binning.
Examples: Find equidistant bins and report as intervals >>> arry = np.array([1, 2, 3, 4], dtype=float) >>> arry array([1., 2., 3., 4.]) >>> intervals, coarse = compute_intervals_and_coarse_bins(arry) >>> intervals [3] >>> coarse [np.float64(1.0), np.float64(4.0)]
A bins with two interval values. >>> arry = np.array([1, 2, 3, 6, 8, 10], dtype=float) >>> intervals, coarse = compute_intervals_and_coarse_bins(arry) >>> intervals [2, 1, 2] >>> coarse [np.float64(1.0), np.float64(3.0), np.float64(6.0), np.float64(10.0)]
On zero (or negative tolerance) just use intervals filled with ones and return original array. >>> intervals, coarse = compute_intervals_and_coarse_bins(arry, tolerance=0.0) >>> intervals [1, 1, 1, 1, 1] >>> coarse is arry True
- mckit_meshes.mesh.geometry_spec.select_indexes(a, x)[source]¶
Find indexes for a mesh bin, corresponding given coordinates.
Assumes that a is sorted.
Examples
>>> r = np.arange(5) >>> r array([0, 1, 2, 3, 4])
For x is None return slice over all a indexes.
>>> select_indexes(r, None) slice(0, 5, None)
For none specified x, if input array represents just one bin, then return index 0 to squeeze results. >>> select_indexes(np.array([10, 20]), None) 0
For x = 1.5, we have 1 < 1.5 < 2, so the bin index is to be 1 >>> select_indexes(r, 1.5) 1
For x = 0, it’s the first bin, and index is to be 0 >>> select_indexes(r, 0) 0
For coordinates below r[0] return -1. >>> select_indexes(r, -1) -1
For coordinates above r[-1] return a.size-1. >>> select_indexes(r, 5) 4
And for array of coordinates >>> select_indexes(r, np.array([1.5, 0, -1, 5])) array([ 1, 0, -1, 4])