WiTwin Maxwell
Differentiable full-wave electromagnetic solver with PyTorch-native interface and Slang-compiled CUDA kernels
Overview#
WiTwin Maxwell is a differentiable full-wave electromagnetic solver. The FDTD field-update loops run as GPU kernels compiled through Slang, while the entire workflow — scene definition, simulation dispatch, result access, and automatic differentiation — stays inside standard PyTorch.
What It Provides#
- FDTD time-domain solver with monitor extraction and multi-frequency DFT sampling
- Differentiable adjoint backward support for inverse design
- PyTorch-native interface — scenes, sources, monitors, and results are all PyTorch-friendly
SceneModulepattern for wrapping differentiable scenes astorch.nn.ModuleMaterialRegionfor trainable density-based material optimization
Quick Links#
Getting Started
Install WiTwin Maxwell and run your first simulation
API Reference
Complete reference for Scene, Sources, Monitors, and Simulation
When to Use WiTwin Maxwell#
Maxwell solves the full electromagnetic wave equation using FDTD. Use it when you need:
- Accurate near-field EM simulation
- Differentiable optimization of material or geometry parameters
- Multi-frequency DFT field extraction
- Adjoint-based inverse design
If you need a high-level radio propagation simulator instead, see WiTwin Channel.
Workflow#
Every Maxwell workflow follows the same pattern:
import witwin.maxwell as mw
scene = mw.Scene(domain=..., grid=..., boundary=...)
scene.add_structure(...)
scene.add_source(...)
scene.add_monitor(...)
sim = mw.Simulation.fdtd(scene, frequencies=[1.0e9], run_time=mw.TimeConfig(time_steps=200))
result = sim.run()