lapy.heat¶
Functions for computing heat kernel and diffusion.
Inputs are eigenvalues and eigenvectors (for heat kernel) and the mesh geometries (tet or tria mesh) for heat diffusion.
- lapy.heat.diagonal(t, x, evecs, evals, n)[source]¶
Compute heat kernel diagonal K(t,x,x).
For a given time t (can be a vector) using only the first n smallest eigenvalues and eigenvectors.
- Parameters:
- t
floatornp.ndarray Time or array of time values, shape (n_times,).
- x
np.ndarray Vertex indices for the positions of K(t,x,x), shape (n_vertices,).
- evecs
np.ndarray Eigenvectors matrix, shape (n_vertices, n_eigenvectors).
- evals
np.ndarray Vector of eigenvalues, shape (n_eigenvalues,).
- n
int Number of eigenvectors and eigenvalues to use (smaller or equal to length).
- t
- Returns:
np.ndarrayHeat kernel diagonal values. Shape (n_vertices, n_times) if t is array, or (n_vertices, 1) if t is scalar. Rows correspond to vertices selected in x, columns to times in t.
- Raises:
ValueErrorIf n exceeds the number of available eigenpairs.
- lapy.heat.diffusion(geometry, vids, m=1.0, aniso=None, use_cholmod=False)[source]¶
Compute the heat diffusion from initial vertices in vids.
Uses the backward Euler solution with time \(t = m l^2\), where l describes the average edge length.
- Parameters:
- geometry
TriaMeshorTetMesh Geometric object on which to run diffusion.
- vids
intornp.ndarray Vertex index or indices where initial heat is applied.
- m
float, default=1.0 Factor to compute time of heat evolution.
- aniso
int, default=None Number of smoothing iterations for curvature computation on vertices.
- use_cholmod
bool, default=False Which solver to use. If True, use Cholesky decomposition from scikit-sparse cholmod. If False, use spsolve (LU decomposition).
- geometry
- Returns:
np.ndarrayHeat diffusion values at vertices, shape (n_vertices,).
- Raises:
ValueErrorIf vids contains out-of-range vertex indices.
ImportErrorIf use_cholmod is True but scikit-sparse is not installed.
- lapy.heat.kernel(t, vfix, evecs, evals, n)[source]¶
Compute heat kernel from all points to a fixed point.
For a given time t, computes K_t(p,q) using only the first n smallest eigenvalues and eigenvectors:
\[K_t (p,q) = \sum_j \exp(-\lambda_j t) \phi_j(p) \phi_j(q)\]where \(\lambda_j\) are eigenvalues and \(\phi_j\) are eigenvectors.
- Parameters:
- t
floatornp.ndarray Time (can also be array, if passing multiple times), shape (n_times,).
- vfix
int Fixed vertex index.
- evecs
np.ndarray Matrix of eigenvectors, shape (n_vertices, n_eigenvectors).
- evals
np.ndarray Column vector of eigenvalues, shape (n_eigenvalues,).
- n
int Number of eigenvalues/vectors used in heat kernel (n <= n_eigenvectors).
- t
- Returns:
np.ndarrayHeat kernel values. Shape (n_vertices, n_times) if t is array, or (n_vertices, 1) if t is scalar. Rows correspond to all vertices, columns to times in t.
- Raises:
ValueErrorIf n exceeds the number of available eigenpairs.