A high-performance Python-based FDTD solver for waveguide photonics
Project description
Prismo
A high-performance Python-based FDTD solver for waveguide photonics.
Prismo implements the Finite-Difference Time-Domain method for solving Maxwell's equations, with features designed for photonic integrated circuits, waveguides, and optical devices.
Features
- 3D vectorial FDTD on Yee grids with automatic time-stepping
- GPU acceleration via CuPy with transparent CPU fallback
- Dispersive materials including Lorentz, Drude, Debye, and Sellmeier models
- Material library with Si, SiO2, Si3N4, Au, Ag, Al, and ITO
- Anisotropic materials supporting full permittivity and permeability tensors
- PML absorbing boundaries using the CPML formulation
- Eigenmode solver for 2D waveguide structures
- Advanced monitors for frequency-domain (DFT), power flux, and mode expansion
- S-parameter extraction with Touchstone export
- Data export to CSV and Parquet formats
- Lumerical compatibility for importing FSP files and material databases
- Parameter sweeps with parallel execution
Installation
pip install pyprismo
For GPU acceleration:
pip install pyprismo[acceleration]
For development:
git clone https://github.com/rithulkamesh/prismo.git
cd prismo
pip install -e ".[all]"
Note: The package name on PyPI is pyprismo, but you still import it as prismo:
import prismo # Import name stays as 'prismo'
Quick Start
import numpy as np
import prismo
# Select backend
prismo.set_backend('cupy') # Use GPU, or 'numpy' for CPU
# Create simulation
sim = prismo.Simulation(
size=(10e-6, 5e-6, 0), # 10×5 μm, 2D
resolution=50e6, # 20 nm grid spacing
boundary_conditions="pml",
)
# Add source
source = prismo.GaussianBeamSource(
center=(-4e-6, 0, 0),
size=(0, 2e-6, 0),
frequency=193e12, # 1550 nm
pulse_width=10e-15
)
sim.add_source(source)
# Add DFT monitor
wavelengths = np.linspace(1.5e-6, 1.6e-6, 11)
dft = prismo.DFTMonitor(
center=(4e-6, 0, 0),
size=(0, 2e-6, 0),
frequencies=(299792458.0 / wavelengths).tolist()
)
sim.add_monitor(dft)
# Run
sim.run(time=50e-15)
# Analyze
spectrum = dft.get_power_spectrum('Ex')
Documentation
- User Guide - Tutorials and how-to guides
- API Reference - Complete API documentation
- Examples - Working example scripts
Materials
# Use pre-defined materials
si = prismo.get_material('Si')
sio2 = prismo.get_material('SiO2')
au = prismo.get_material('Au')
# List all materials
print(prismo.list_materials())
# Create custom dispersive material
material = prismo.LorentzMaterial(
epsilon_inf=2.0,
poles=[prismo.LorentzPole(omega_0=2e15, delta_epsilon=1.0, gamma=1e13)]
)
Mode Solver
# Solve for waveguide modes
mode_solver = prismo.ModeSolver(
wavelength=1.55e-6,
x=x_coords,
y=y_coords,
epsilon=epsilon_profile
)
modes = mode_solver.solve(num_modes=3, mode_type='TE')
fundamental = modes[0]
print(f"Effective index: {fundamental.neff.real:.4f}")
# Use mode as source
mode_source = prismo.ModeSource(mode=fundamental, direction='+x', ...)
S-Parameters
# Extract S-parameters
s_analyzer = prismo.SParameterAnalyzer(
num_ports=2,
frequencies=frequencies
)
# Calculate metrics
s21 = s_analyzer.get_s_parameter(1, 0)
insertion_loss = s_analyzer.get_insertion_loss_db(1, 0)
# Export to Touchstone
prismo.export_touchstone("device.s2p", frequencies, s_analyzer.s_matrix)
Data Export
# Parquet (efficient, compressed)
exporter = prismo.ParquetExporter(output_dir="./results")
exporter.export_sparameters(
filename="device",
frequencies=frequencies,
sparameters={'S21': s21}
)
# CSV (universal)
csv_exporter = prismo.CSVExporter(output_dir="./results")
csv_exporter.export_spectrum(...)
Performance
Typical performance on NVIDIA A100:
| Dimension | Grid Size | Throughput |
|---|---|---|
| 2D | 1000×1000 | 80M cells/s |
| 3D | 100×100×100 | 8M cells/s |
CPU performance (NumPy): ~1-2% of GPU performance.
Requirements
- Python ≥3.9
- NumPy ≥1.21
- SciPy ≥1.7
- Polars ≥0.20 (for Parquet export)
Optional:
- CuPy ≥12.0 (for GPU acceleration)
- Matplotlib (for visualization)
Testing
pytest tests/
Run specific test categories:
pytest tests/test_backends.py
pytest tests/validation/
License
MIT License. See LICENSE for details.
Documentation
📚 Full Documentation on ReadTheDocs
Quick Links
- Installation Guide - Get set up quickly
- Quick Start Tutorial - Your first simulation in 5 minutes
- Tutorials - Step-by-step guides
- User Guide - Comprehensive documentation
- API Reference - Complete API documentation
- Examples - Sample code and demos
For Developers
- Architecture - Code structure and design
- Contributing - How to contribute
- Testing Guide - Testing practices
- Benchmarks - Performance metrics
Citation
If you use Prismo in academic work, please cite:
@software{prismo2025,
author = {Kamesh, Rithul},
title = {Prismo: Python FDTD Solver for Photonics},
year = {2025},
url = {https://github.com/rithulkamesh/prismo}
}
References
- Taflove, A., & Hagness, S. C. (2005). Computational Electrodynamics: The Finite-Difference Time-Domain Method. Artech House.
- Yee, K. S. (1966). "Numerical solution of initial boundary value problems involving Maxwell's equations in isotropic media." IEEE Trans. Antennas Propagation, 14(3), 302-307.
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 pyprismo-0.0.1.tar.gz.
File metadata
- Download URL: pyprismo-0.0.1.tar.gz
- Upload date:
- Size: 177.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd95769ea59e7aa9d477d3289b4871d2949b29f53f619efe24673e74ff028874
|
|
| MD5 |
06b228fbf8ebb99958ec962847177477
|
|
| BLAKE2b-256 |
508e9475f07278a0d9785513198808012b0081265f7a2de151d772961b6c0df4
|
Provenance
The following attestation bundles were made for pyprismo-0.0.1.tar.gz:
Publisher:
publish-pypi.yml on rithulkamesh/prismo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyprismo-0.0.1.tar.gz -
Subject digest:
cd95769ea59e7aa9d477d3289b4871d2949b29f53f619efe24673e74ff028874 - Sigstore transparency entry: 621417132
- Sigstore integration time:
-
Permalink:
rithulkamesh/prismo@49fae2a27e36d82f33c055be9e2af62d73dda359 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/rithulkamesh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@49fae2a27e36d82f33c055be9e2af62d73dda359 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyprismo-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pyprismo-0.0.1-py3-none-any.whl
- Upload date:
- Size: 115.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24091cc6f4529f8c25da9062008e23f1898a39a7907fa22a6db766d8dbb07c97
|
|
| MD5 |
a5dd2a4329cbf10d353c09d996a1efa5
|
|
| BLAKE2b-256 |
226fd566d8b851df790ba443d22b12c57dda16eb3d28fdf282cb01221be6d436
|
Provenance
The following attestation bundles were made for pyprismo-0.0.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on rithulkamesh/prismo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyprismo-0.0.1-py3-none-any.whl -
Subject digest:
24091cc6f4529f8c25da9062008e23f1898a39a7907fa22a6db766d8dbb07c97 - Sigstore transparency entry: 621417133
- Sigstore integration time:
-
Permalink:
rithulkamesh/prismo@49fae2a27e36d82f33c055be9e2af62d73dda359 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/rithulkamesh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@49fae2a27e36d82f33c055be9e2af62d73dda359 -
Trigger Event:
release
-
Statement type: