flowtorch.analysis¶
flowtorch.analysis.svd¶
Classes and functions wrapping around torch.linalg.svd.
-
class
flowtorch.analysis.svd.
SVD
(data_matrix: torch.Tensor, rank: Optional[int] = None)[source]¶ Bases:
object
Compute and analyze the SVD of a data matrix.
- Parameters
U (pt.Tensor) – left singular vectors
s (pt.Tensor) – singular values
s_rel (pt.Tensor) – singular values normalized with their sum in percent
s_cum (pt.Tensor) – cumulative normalized singular values in percent
V (pt.Tensor) – right singular values
rank (int) – rank used for truncation
opt_rank (int) – optimal rank according to SVHT
required_memory (int) – memory required to store the truncation U, s, and V
Examples
>>> from flowtorch import DATASETS >>> from flowtorch.data import FOAMDataloader >>> from flowtorch.analysis import SVD >>> loader = FOAMDataloader(DATASETS["of_cavity_ascii"]) >>> data = loader.load_snapshot("p", loader.write_times[1:]) >>> svd = SVD(data, rank=100) >>> print(svd) SVD of a 400x5 data matrix Selected/optimal rank: 5/2 data type: torch.float32 (4b) truncated SVD size: 7.9297Kb >>> svd.s_rel tensor([9.9969e+01, 3.0860e-02, 3.0581e-04, 7.8097e-05, 3.2241e-05]) >>> svd.s_cum tensor([ 99.9687, 99.9996, 99.9999, 100.0000, 100.0000]) >>> svd.U.shape torch.Size([400, 5])
-
property
U
¶
-
property
V
¶
-
property
opt_rank
¶
-
property
rank
¶
-
reconstruct
(rank: Optional[int] = None) → torch.Tensor[source]¶ Reconstruct the data matrix for a given rank.
- Parameters
rank (int, optional) – rank used to compute a truncated reconstruction
- Returns
reconstruction of the input data matrix
- Return type
pt.Tensor
-
property
required_memory
¶ Compute the memory size in bytes of the truncated SVD.
- Returns
cumulative size of truncated U, s, and V tensors in bytes
- Return type
int
-
property
s
¶
-
property
s_cum
¶
-
property
s_rel
¶
flowtorch.analysis.dmd¶
Classes and functions to compute the dynamic mode decomposition (DMD) of a data matrix.
-
class
flowtorch.analysis.dmd.
DMD
(data_matrix: torch.Tensor, dt: float, rank: Optional[int] = None)[source]¶ Bases:
object
Class computing the exact DMD of a data matrix.
Currently, no advanced mode selection algorithms are implemented. The mode amplitudes are computed using the first snapshot.
Examples
>>> from flowtorch import DATASETS >>> from flowtorch.data import FOAMDataloader >>> from flowtorch.analysis import DMD >>> path = DATASETS["of_cavity_binary"] >>> loader = FOAMDataloader(path) >>> data_matrix = loader.load_snapshot("p", loader.write_times) >>> dmd = DMD(data_matrix, dt=0.1, rank=3) >>> dmd.frequency tensor([0., 5., 0.]) >>> dmd.growth_rate tensor([-2.3842e-06, -4.2345e+01, -1.8552e+01]) >>> dmd.amplitude tensor([10.5635+0.j, -0.0616+0.j, -0.0537+0.j])
-
property
amplitude
¶
-
property
dynamics
¶
-
property
eigvals
¶
-
property
eigvecs
¶
-
property
frequency
¶
-
property
growth_rate
¶
-
property
modes
¶
-
partial_reconstruction
(mode_indices: Set[int]) → torch.Tensor[source]¶ Reconstruct data matrix with limited number of modes.
- Parameters
mode_indices (Set[int]) – mode indices to keep
- Returns
reconstructed data matrix
- Return type
pt.Tensor
-
property
reconstruction
¶
-
property
required_memory
¶ Compute the memory size in bytes of the DMD.
- Returns
cumulative size of SVD, eigen values/vectors, and DMD modes in bytes
- Return type
int
-
property
svd
¶
-
property
flowtorch.analysis.psp_explorer¶
Module with classes and functions to explore and analyse iPSP data.
-
class
flowtorch.analysis.psp_explorer.
PSPExplorer
(file_path: str)[source]¶ Bases:
object
Explore iPSP data interactively.
-
interact
(zone: str, field_name: str, times: list, mask: bool = True, width: int = 1024, every: int = 5, cmin: float = - 2, cmax: float = 0.5) → plotly.graph_objs._figure.Figure[source]¶
-
property
loader
¶
-