Skip to content

jwt625/BPM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BPM (Beam Propagation Method)

Update 202505: I've "deployed" a Gradio based GUI on Hugging Face, future development will likely continue there:

BPM is a Python library for simulating beam propagation in integrated photonics using the Beam Propagation Method (BPM). The package provides functions to generate refractive index distributions for various structures (e.g., lenses, waveguides, and MMI splitters), a mode solver for slab waveguides, and BPM propagation routines with support for Perfectly Matched Layers (PML) for absorbing boundary conditions.

Currently it is 2D only, and use analytic solutions to launch slab modes. Propagation direction is upward and is called z. Transverse direction is x.

Features

  • Generate refractive index distributions:
    • Spherical lens
    • S-bend waveguide
    • MMI-based splitter
  • Solve for guided slab waveguide modes (even/odd modes)
  • BPM propagation using a Runge-Kutta integrator
  • PML boundary absorption
  • [] Import from GDSII

Installation

Using uv (Recommended)

uv is a fast Python package manager. Install it first if you haven't:

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# or on macOS with Homebrew
brew install uv

Then clone and set up the project:

git clone https://github.com/jwt625/bpm.git
cd bpm

# Basic installation
uv pip install -e .

# With optional dependencies
uv pip install -e ".[test]"      # For running tests
uv pip install -e ".[examples]"  # For running examples
uv pip install -e ".[gui]"       # For GUI functionality
uv pip install -e ".[dev]"       # For development
uv pip install -e ".[all]"       # Install everything

Using pip (Traditional)

git clone https://github.com/jwt625/bpm.git
cd bpm

# Basic installation
pip install -e .

# With optional dependencies
pip install -e ".[test]"      # For running tests
pip install -e ".[examples]"  # For running examples
pip install -e ".[gui]"       # For GUI functionality
pip install -e ".[dev]"       # For development
pip install -e ".[all]"       # Install everything

Running the GUI

After installation, you can launch the interactive GUI:

# With uv
uv run bpm-gui

# With pip
bpm-gui

Examples

Slab mode solver and launcher:

image

Refractive index distribution of an MMI:

image

Simulated example MMI:

image

Simulated example S bend. The waveguide is multimode:

image

Development

Setting up the development environment

# Clone the repository
git clone https://github.com/jwt625/bpm.git
cd bpm

# Create virtual environment and install dependencies
uv sync --extra dev --extra gui

# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov=bpm --cov-report=html

# Format code
uv run black bpm/ tests/
uv run isort bpm/ tests/

# Type checking
uv run mypy bpm/

# Linting
uv run flake8 bpm/ tests/

Project Structure

bpm/
├── bpm/                    # Main package
│   ├── __init__.py        # Package initialization
│   ├── core.py            # BPM propagation engine
│   ├── mode_solver.py     # Slab waveguide mode solver
│   ├── refractive_index.py # Structure generation
│   ├── pml.py             # Perfectly Matched Layer
│   └── app.py             # Gradio GUI application
├── tests/                 # Test suite
├── examples/              # Usage examples
├── pyproject.toml         # Project configuration
└── README.md              # This file

References

Optical tomographic reconstruction based on multi-slice wave propagation method

Light propagation through microlenses: a new simulation method

Light propagation in graded-index optical fibers

Numerical Simulation of Optical Wave Propagation with Examples in MATLAB

Photonic Devices for Telecommunications

Papers cited in chapter 2.2.1 of the book:

About

2D Beam Propagation Method for E&M wave simulations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages