Torch-based Inversion & Development Engine for electromagnetic wave propagation
Project description
TIDE
Torch-based Inversion & Development Engine
TIDE is a PyTorch-based library for high-frequency electromagnetic wave propagation and inversion, built on Maxwell's equations. It provides CPU and CUDA implementations for forward modeling, gradient computation, and full-waveform inversion workflows.
Features
- Maxwell Equation Solvers:
- 2D TM mode propagation
- 3D Maxwell propagation
- Automatic Differentiation: Gradient support through PyTorch's autograd hooks
- High Performance: Optimized C/CUDA kernels for critical operations
- Flexible Storage: Device/CPU/disk snapshot modes for gradient computation
- Staggered Grid: Standard FDTD staggered grid implementation
- PML Boundaries: Perfectly Matched Layer absorbing boundaries
- Snapshot Compression: Optional BF16 snapshot compression on the default path
Feature Matrix
| Capability | Entry Point | Status | Notes |
|---|---|---|---|
| 2D TM forward modeling | tide.maxwelltm |
Stable | Primary onboarding path |
| 2D TM inversion / autograd | tide.maxwelltm, MaxwellTM |
Stable | Uses PyTorch autograd |
| 3D forward modeling | tide.maxwell3d |
Stable | Supports component selection |
| 3D inversion / gradients | tide.maxwell3d, Maxwell3D |
Stable with constraints | Check the limitations guide before scaling up |
| Snapshot storage modes | storage_mode=* |
Stable | Device, CPU, disk, none, and auto |
| Callbacks | forward_callback, backward_callback |
Stable | Keep callback work lightweight |
| Debye dispersion | DebyeDispersion |
Advanced | Requires explicit time-step validation |
Installation
From PyPI
Ensure you have proper PyTorch installation with CUDA binding for your system.
For CUDA environments, you may need to install a CUDA-enabled PyTorch build first:
uv pip install torch --index-url https://download.pytorch.org/whl/cu128
The cu128 tag is for CUDA 12.8. Replace it based on your CUDA version.
Then install TIDE via uv or pip:
uv pip install tide-GPR
or
pip install tide-GPR
From Source
We recommend using uv for building:
git clone https://github.com/vcholerae1/tide.git
cd tide
uv build
To rebuild only the native backend during development:
bash scripts/build_csrc.sh
Requirements:
- Python >= 3.12
- PyTorch >= 2.9.1
- CUDA Toolkit (optional, for GPU support)
- CMake >= 3.28 (optional, for building from source)
Quick Start
import torch
import tide
# Create a simple model
nx, ny = 200, 100
epsilon = torch.ones(ny, nx) * 4.0 # Relative permittivity
sigma = torch.zeros_like(epsilon) # Conductivity (S/m)
mu = torch.ones_like(epsilon) # Relative permeability
epsilon[50:, :] = 9.0 # Add a layer
# Set up source
source_amplitude = tide.ricker(
freq=4e8, # 400 MHz
length=1000,
dt=1e-11,
peak_time=5e-10
).reshape(1, 1, -1)
source_location = torch.tensor([[[10, 100]]], dtype=torch.long)
receiver_location = torch.tensor([[[10, 150]]], dtype=torch.long)
# Run forward simulation
*_, receiver_data = tide.maxwelltm(
epsilon=epsilon,
sigma=sigma,
mu=mu,
grid_spacing=0.01,
dt=1e-11,
source_amplitude=source_amplitude,
source_location=source_location,
receiver_location=receiver_location,
pml_width=10
)
print(f"Recorded data shape: {receiver_data.shape}")
Core Modules
tide.maxwelltm: 2D TM solvertide.maxwell3d: 3D solvertide.wavelets: Source wavelet generationtide.callbacks: Callback state and factoriestide.storage: Snapshot storage and compression controlstide.workflow: Shot batching, receiver loss, and optimizer workflow helperstide.resampling: CFL resampling helperstide.cfl: CFL condition helpertide.padding: Padding and interior masking helperstide.validation: Input validation helpers
Precision and Storage
Storage and precision controls:
out = tide.maxwelltm(
epsilon,
sigma,
mu,
grid_spacing=0.02,
dt=4e-11,
source_amplitude=src,
source_location=src_loc,
receiver_location=rec_loc,
storage_mode="auto",
storage_compression="bf16",
)
Notes:
storage_modeaccepts device, cpu, disk, none, and auto.storage_compressionaccepts none or bf16 for float32 snapshot storage on Maxwell and Born native paths that save backward intermediates.
Documentation
Recommended reading path:
docs/getting-started.mdfor installation and the first 2D forward rundocs/guides/api-orientation.mdfor choosing betweentide.maxwelltm,tide.maxwell3d,MaxwellTM, andMaxwell3Ddocs/guides/modeling.mdanddocs/guides/inversion.mdfor forward modeling and inversion workflowsdocs/guides/configuration.mdfor storage, callbacks, backend, and CFL-related controlsdocs/guides/limitations.mdanddocs/guides/verification.mdbefore enabling advanced features broadly
Testing
Run the test suite:
pytest tests/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
This project includes code derived from Deepwave by Alan Richardson. We gratefully acknowledge the foundational work that made TIDE possible.
Citation
If you use TIDE in your research, please cite:
@software{tide2025,
author = {Vcholerae1},
title = {TIDE: Torch-based Inversion \& Development Engine},
year = {2025},
url = {https://github.com/vcholerae1/tide}
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 Distributions
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 tide_gpr-0.0.29.tar.gz.
File metadata
- Download URL: tide_gpr-0.0.29.tar.gz
- Upload date:
- Size: 332.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71c7d0f70df225ba02bceb2a0723681ebcdd73f44f920dcf9c7ece1c4286e27b
|
|
| MD5 |
f5a104fba3c65c5bc8c4c1edfaa11616
|
|
| BLAKE2b-256 |
af9af7463936f7ace27e9952c3e92aa96e093b44a9f2963b4d083e3173cb3daf
|
File details
Details for the file tide_gpr-0.0.29-py3-none-win_amd64.whl.
File metadata
- Download URL: tide_gpr-0.0.29-py3-none-win_amd64.whl
- Upload date:
- Size: 612.2 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73dbaaa1cc905783b78570a2ff0071c68b9dd9b98d924bd9ac72bb58581e27c4
|
|
| MD5 |
cdeb3e82d4e4ddbc6473e496d1c11b38
|
|
| BLAKE2b-256 |
bd820beec241856647f26f1e8cf4f1040bc062c07b9ee64320debbb09671be50
|
File details
Details for the file tide_gpr-0.0.29-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tide_gpr-0.0.29-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cad1a2e425a1b3e94bb570099766c243b0920a98715fae108aedfdb2d19aee32
|
|
| MD5 |
9fc51ab9e3d3a60a68ae9bca80b0c2ad
|
|
| BLAKE2b-256 |
db20812f015f17f4606b6b747565e1bfe79790b260a5bfb9a8b901a103ad1f46
|
File details
Details for the file tide_gpr-0.0.29-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: tide_gpr-0.0.29-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 806.2 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29f115a9bba7ebffd1cdf5225f669014e6664e3c14e52a44179f49fd16e73362
|
|
| MD5 |
08a67fe422e65f6e92942605b4e1ff37
|
|
| BLAKE2b-256 |
e029c64cbfe82a04f4ec36e2012ff3ff273526118702f3097a85f25599b8f256
|