GPU-parallel, fully differentiable implicit DAE solvers in PyTorch.
Project description
TorchDAE
Numerical Differential-Algebraic Equation solvers in PyTorch. Autodifferentiable and GPU-capable.
TorchDAE is a PyTorch-based library providing numerical Differential-Algebraic Equation (DAE) solvers.
Features include:
- Implicit Solvers: Multiple stiff solvers (including BDF1, BDF2, SDIRK TR-BDF2, and 5th-order Radau IIA) [2];
- Automatic Index Reduction: lowering high-index DAEs to Index-1 using Pantelides' algorithm and Mattsson-Söderlind Dummy Derivatives;
- Manifold Stabilization: Coordinate Projection Method (CPM) and Baumgarte feedback to eliminate numerical constraint drift;
- Events & Resets: Vectorized, differentiable event handling with continuous-time Hermite state interpolation and resets;
- Adjoint Methods: Continuous adjoint sensitivity backward-in-time for constant-memory backpropagation;
- Vmappable everything: Full support for PyTorch
vmapandtorch.compileon GPU and CPU pipelines.
Installation
pip install torchdae
Requires Python 3.8+ and PyTorch 2.0+.
Documentation
Available at https://example.com.
Quick Example
A simple example of how to solve an Index-1 DAE with BDF2.
import torch
from torchdae import solve_bdf2
# Define a simple Index-1 DAE: F(t, y, yp) = 0
def physics(t, y, yp):
# supporting batching
y1, y2 = y[..., 0], y[..., 1]
y1p, _ = yp[..., 0], yp[..., 1]
# f1 (differential): y1' + y1 - y2 = 0
f1 = y1p + y1 - y2
# f2 (algebraic): y1 + y2 - sin(t) = 0
t_tensor = torch.as_tensor(t, dtype=y.dtype, device=y.device)
f2 = y1 + y2 - torch.sin(t_tensor)
return torch.stack([f1, f2], dim=-1)
y0 = torch.tensor([[0.5, -0.5]])
sol = solve_bdf2(physics, t_span=(0.0, 1.0), y0=y0, h=0.01)
print("Solved states at t=1.0:", sol.ys[-1, 0].numpy())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torchdae-0.1.0.tar.gz.
File metadata
- Download URL: torchdae-0.1.0.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e112e27e3f63c919bab37c70588e4a0fea0665017ec2450af24bca79ee02736b
|
|
| MD5 |
1323d99cf0935ea67d2a3e7a37a61615
|
|
| BLAKE2b-256 |
e56d2f3402899d520a845d1cb8445fbd73ad3be420843bd75a287657a5e69abc
|
File details
Details for the file torchdae-0.1.0-py3-none-any.whl.
File metadata
- Download URL: torchdae-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
365021e8707013e7d9dd6a5f0aa135e9a6ce14e1ba3e75e2710d338d604bcda4
|
|
| MD5 |
42c4d6de396339cde0a03c121fd6f45a
|
|
| BLAKE2b-256 |
f91d12de92a10afccc77ad998767bbe1b57e821e9ebb65ec86da6e0093a15bc9
|