Skip to main content

A high-performance Python-based FDTD solver for waveguide photonics

Project description

Prismo

PyPI version CI codecov Documentation Status License: MIT Python 3.9+

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

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

For Developers

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyprismo-0.0.1.tar.gz (177.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyprismo-0.0.1-py3-none-any.whl (115.1 kB view details)

Uploaded Python 3

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

Hashes for pyprismo-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cd95769ea59e7aa9d477d3289b4871d2949b29f53f619efe24673e74ff028874
MD5 06b228fbf8ebb99958ec962847177477
BLAKE2b-256 508e9475f07278a0d9785513198808012b0081265f7a2de151d772961b6c0df4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyprismo-0.0.1.tar.gz:

Publisher: publish-pypi.yml on rithulkamesh/prismo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pyprismo-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24091cc6f4529f8c25da9062008e23f1898a39a7907fa22a6db766d8dbb07c97
MD5 a5dd2a4329cbf10d353c09d996a1efa5
BLAKE2b-256 226fd566d8b851df790ba443d22b12c57dda16eb3d28fdf282cb01221be6d436

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyprismo-0.0.1-py3-none-any.whl:

Publisher: publish-pypi.yml on rithulkamesh/prismo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page