Cells
|
Main class for seeds/source data points. |
|
Main class for particles with a volume. |
- class iceshot.cells.DataPoints(seeds, source, bc=None, box_size=[1.0, 1.0])
Bases:
object
Main class for seeds/source data points.
- Variables:
device – default device for all the tensors (same as
seeds
device)dtype – data type
d – dimenstion
x – seeds positions
y – source positions
bc – boundary conditions
L – box size as tensor
- __init__(seeds, source, bc=None, box_size=[1.0, 1.0])
Initialize
- Parameters:
seeds ((N,d) Tensor) – seed points
source ((M,d) Tensor) – source points
bc (optional) – boundary condition. Defaults to None.
box_size (list, optional) – Defaults to [1.0,1.0].
- lazy_XY()
Return the XY matrix as a LazyTensor.
The XY matrix is the matrix \((y_j - x_i)_{ij}\) where \(y\) and \(x\) are respectively the source and seed points.
- Returns:
(N,M) LazyTensor
- class iceshot.cells.Cells(seeds, source, vol_x, extra_space=None, fluid_size=None, orientation=None, axis=None, ar=None, bc=None, box_size=[1.0, 1.0], jct_method='Kmin')
Bases:
DataPoints
Main class for particles with a volume.
- Variables:
N_cells – initial number of cells
N_crystals – current number of cells
M_grid – number of source points
vol_grid – volume of a source point (equal to 1/
M_grid
)axis – (N,d) Tensor of axes
ar – (N,) Tensor of aspect ratios
orientation – (N,d,d) Tensor of orientations
f_x – (N,) Tensor of Kantorovich potentials
g_y – (M,) Tensor of Kantorovich potentials
labels – (M,) Tensor of labels
- __init__(seeds, source, vol_x, extra_space=None, fluid_size=None, orientation=None, axis=None, ar=None, bc=None, box_size=[1.0, 1.0], jct_method='Kmin')
Initialize
- Parameters:
seeds ((N,d) Tensor) – seed points
source ((M,d) Tensor) – source points
vol_x (N Tensor) – volumes of the particles
extra_space (str, optional) – TBI. Defaults to None.
fluid_size (float) – TBI. Defaults to None.
orientation ((N,d,d) Tensor, optional) – Orientation matrices. Defaults to None (automatically computed from axis and aspect ratio).
axis ((N,d) Tensor, optional) – Orientation axis. Defaults to None (random axis).
ar (N tensor, optional) – Aspect ratios. Defaults to 1.
bc (optional) – boundary condition. Defaults to None.
box_size (list, optional) – Defaults to [1.0,1.0].
jct_method (string, optional) – The method used to compute junction points. Can be ‘linear’ (faster on CPU) or ‘Kmin’ (faster on GPU). Defaults to ‘linear’.
- orientation_from_axis()
Compute the orientation matrices from the axes and aspect ratios.
- Raises:
NotImplementedError – Only in 2D and 3D
- Returns:
Orientation matrices
- Return type:
Tensor
- covariance_matrix(vols=None, bsr=False, **kwargs)
Compute the covariance matrices of a particle configuration.
- Parameters:
vols (_type_, optional) – Input volumes. Defaults to None (automatically computed).
bsr (bool, optional) – Use Block-Sparse-Reduction (faster). Defaults to False.
- Raises:
NotImplementedError – Only in 2D and 3D
- Returns:
Covariance matrix
- Return type:
(N,d,d) Tensor
- allocation_matrix(type='lazy')
Compute the allocation matrix
- Parameters:
type (str, optional) – Output type. Can be “lazy” for LazyTensor or “dense” for Tensor. Defaults to “lazy”.
- Returns:
The \((i,j)\) component of the allocation matrix is 1 if the source point \(j\) belongs to the particle \(i\) and 0 otherwise.
- Return type:
(N,M) Tensor or LazyTensor
- barycenters(weight=None, bsr=False)
Compute the (weighted) barycenter of each particle.
- Parameters:
weight (float or Tensor, optional) – Defaults to 1.
bsr (bool, optional) – Use Block-Sparse-Reduction (faster). Defaults to False.
- Returns:
barycenters
- Return type:
(N,d) Tensor
- junctions(r=None, K=None)
Return a matrix of size MxK containing the cell labels of K neighbours of each pixel, padded with -1
- Parameters:
r (float, optional) – The ‘vision radius’ around each pixel point. By defaults, only the +/-1 neighbouring pixels are considered.
K (int, optional) – Must be larger than the number of pixels inside the ‘vision radius’. By default, it is equal to 3**d + 1.
- Returns:
A matrix of size MxK containing the cell labels of K neighbours of each pixel, padded with -1
- Return type:
(Tensor)
- extract_boundary(r=None, K=None)
Return the indices of the grid-cells corresponding to a boundary pixel.
- lazy_XY()
Return the XY matrix as a LazyTensor.
The XY matrix is the matrix \((y_j - x_i)_{ij}\) where \(y\) and \(x\) are respectively the source and seed points.
- Returns:
(N,M) LazyTensor
- sort_y()
Sort the source points according to their labels.
- Returns:
Positions before sorting and
ranges_ij
argument to be passed to the Block-Sparse-Reduction method.- Return type:
(Tensor, tuple)