Metadata-Version: 2.5
Name: bifrost-photonics
Version: 0.2.0
Summary: The rainbow bridge between your GDSFactory(X) pipeline and FDTD(X) simulation
Author: Helaman Flores
Requires-Python: >=3.12,<3.15
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gdsfactoryx>=9.51.0.post2
Requires-Dist: fdtdx>=0.6.3
Requires-Dist: tidy3d>=2.12
Requires-Dist: jax>=0.6
Requires-Dist: numpy
Requires-Dist: scipy<2
Requires-Dist: shapely<3
Requires-Dist: anywidget>=0.9
Requires-Dist: manifold3d>=3.0
Requires-Dist: traitlets
Requires-Dist: imageio-ffmpeg
Requires-Dist: pytest ; extra == "dev"
Requires-Dist: pytest-xdist ; extra == "dev"
Requires-Dist: pytest-randomly ; extra == "dev"
Requires-Dist: ruff ; extra == "dev"
Requires-Dist: mypy ; extra == "dev"
Requires-Dist: marimo ; extra == "dev"
Requires-Dist: playwright ; extra == "dev"
Requires-Dist: zensical>=0.0.46,<0.1.0 ; extra == "docs"
Requires-Dist: mkdocstrings[python] ; extra == "docs"
Requires-Dist: meep ; extra == "meep"
Project-URL: Documentation, https://sephiram591.github.io/bifrost/
Project-URL: Homepage, https://github.com/Sephiram591/bifrost
Project-URL: Issues, https://github.com/Sephiram591/bifrost/issues
Provides-Extra: dev
Provides-Extra: docs
Provides-Extra: meep
Import-Name: bifrost

<p align="center"><img src="docs/images/bifrost-logo-rounded-rectangle.svg" alt="bifrost" width="360"></p>

# bifrost

[![docs](https://github.com/Sephiram591/bifrost/actions/workflows/pages.yml/badge.svg)](https://sephiram591.github.io/bifrost/)
[![tests](https://github.com/Sephiram591/bifrost/actions/workflows/test.yml/badge.svg)](https://github.com/Sephiram591/bifrost/actions/workflows/test.yml)

The rainbow bridge between your GDSFactory pipeline and FDTD simulation.

bifrost turns a [gdsfactory](https://gdsfactory.github.io/gdsfactory/) component and its layer stack into a
differentiable [fdtdx](https://github.com/ymahlau/fdtdx) simulation, and ships a 3D viewer for setting up the run and
inspecting its fields. It builds on [gdsfactoryx](https://github.com/Sephiram591/gdsfactoryx), the JAX port of gdsfactory.

**Documentation:** https://sephiram591.github.io/bifrost/

## Install

Use a fresh environment:
gdsfactoryx (installed from PyPI as a dependency) provides the `gdsfactory` import package, so it cannot share an
environment with upstream gdsfactory.

```bash
pip install bifrost-photonics
```

To install the latest development version from GitHub
instead: `pip install "bifrost-photonics @ git+https://github.com/Sephiram591/bifrost.git"`.

## Quick start

A straight silicon waveguide in the viewer (in a Jupyter or marimo cell, end the cell with `viewer`):

```python
import fdtdx
import gdsfactory as gf
import bifrost as bf
from gdsfactory.technology import LayerLevel, LayerStack

gf.gpdk.PDK.activate()

component = gf.components.straight(length=5)  # a 5 um long, 500 nm wide waveguide with ports o1 and o2

# one 220 nm thick level on the waveguide layer; silicon core in a silica cladding
layer_stack = LayerStack(
    layers={"core": LayerLevel(layer=gf.gpdk.LAYER.WG, zmin=0.0, thickness=0.22, material="core", mesh_order=1)}
)
materials = {
    "core": fdtdx.Material(permittivity=3.48**2),
    "clad": fdtdx.Material(permittivity=1.444**2),
}

stack = bf.StackDevice.from_layer_stack(
    component, layer_stack, materials,
    background="clad",                               # fills everything the core does not
    zrange_layers=["core"],                          # the box's z range is the core's
    extend_ports=(("o1", 1.0), ("o2", 1.0)),         # 1 um straight leads out of both ports
    boundary_offset=(0, 0, 1.5, -1.5, 1.5, -1.5),    # 1.5 um of cladding in y and z
    name="stack",
)
viewer = bf.view(stack)  # the interactive 3D viewer
viewer
```

Next: [run your first simulation](https://sephiram591.github.io/bifrost/getting-started/), a 90 degree bend from an empty
file to a transmission value and a field image.

