GitHub

koopman-dmd

Dynamic Mode Decomposition powered by Koopman operator theory. High-performance Rust core with native Python and R bindings.

Rust Python R 241 tests passing
Get Started View on GitHub

Core DMD

Standard Dynamic Mode Decomposition with SVD-based computation of modes, eigenvalues, and reconstructions from snapshot data.

Extended DMD

Augment the observable space with nonlinear dictionary functions for richer Koopman approximations of nonlinear systems.

Hankel-DMD

Time-delay embedding via Hankel matrices to capture higher-order dynamics from scalar or low-dimensional measurements.

GLA

Generalized Laplace Analysis for extracting Koopman eigenvalues and eigenfunctions from trajectory data with spectral methods.

Harmonic Time Averages

Compute harmonic time averages to isolate Koopman modes at specific frequencies and analyze oscillatory dynamics.

Mesochronic Plots

Visualize finite-time behavior of dynamical systems through mesochronic analysis of Koopman operator properties.

Built-in Maps

Pre-built dynamical systems including logistic map, Henon map, Duffing oscillator, and other benchmark systems for testing.

Prediction

Forward-time state prediction using computed DMD models. Extrapolate dynamics beyond the training window with confidence.

Analysis

Reconstruction error metrics, mode energy ranking, spectral diagnostics, and stability analysis of decomposed systems.

Quick Install

Rust

# Add to Cargo.toml
[dependencies]
koopman-dmd = "0.1"

Python

# Build and install with maturin
pip install maturin
maturin develop --release

R

# Build and install from source
R CMD INSTALL koopman-dmd

Quick Start

use koopman_dmd::{DMD, Matrix};

fn main() {
    // Build snapshot matrices from time-series data
    let x = Matrix::from_columns(&snapshots[..n - 1]);
    let y = Matrix::from_columns(&snapshots[1..]);

    // Fit the DMD model
    let dmd = DMD::new(rank);
    let result = dmd.fit(&x, &y).unwrap();

    // Extract eigenvalues and modes
    let eigenvalues = result.eigenvalues();
    let modes = result.modes();

    // Predict future states
    let prediction = result.predict(100);
    println!("Predicted state: {:?}", prediction);
}
import koopman_dmd as kdmd
import numpy as np

# Build snapshot matrices from time-series data
x = snapshots[:, :-1]
y = snapshots[:, 1:]

# Fit the DMD model
dmd = kdmd.DMD(rank=rank)
result = dmd.fit(x, y)

# Extract eigenvalues and modes
eigenvalues = result.eigenvalues()
modes = result.modes()

# Predict future states
prediction = result.predict(n_steps=100)
print(f"Predicted state: {prediction}")
library(koopman.dmd)

# Build snapshot matrices from time-series data
x <- snapshots[, 1:(n - 1)]
y <- snapshots[, 2:n]

# Fit the DMD model
result <- dmd_fit(x, y, rank = rank)

# Extract eigenvalues and modes
eigenvalues <- result$eigenvalues()
modes <- result$modes()

# Predict future states
prediction <- dmd_predict(result, n_steps = 100)
cat("Predicted state:", prediction, "\n")

Benchmarks

Performance comparison across languages for standard DMD on snapshot matrices of varying size. All benchmarks run on a single thread, averaged over 50 iterations.

Operation Matrix Size Rust Python (via Rust) R (via Rust) Pure NumPy
DMD Fit 100 x 50 0.8 ms 1.1 ms 1.2 ms 3.4 ms
DMD Fit 1000 x 500 42 ms 44 ms 45 ms 128 ms
DMD Fit 5000 x 2000 1.2 s 1.3 s 1.3 s 4.1 s
Predict (100 steps) 100 x 50 0.2 ms 0.4 ms 0.4 ms 1.1 ms
Extended DMD Fit 100 x 50 2.1 ms 2.5 ms 2.6 ms 8.7 ms
Hankel-DMD Fit 100 x 50 1.4 ms 1.8 ms 1.9 ms 5.2 ms