Skip to content

bifrost

bifrost

The rainbow bridge between your GDSFactory pipeline and FDTD simulation.

bifrost turns a gdsfactoryx (the JAX port of gdsfactory that makes layouts differentiable) component and its layer stack into a differentiable fdtdx simulation. It also ships a 3D viewer for setting up the run and inspecting its fields. Below is an example of a straight silicon waveguide, opened in the viewer:

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

bf.StackDevice is the device the solver sees: the component's polygons, extruded using the layer stack data, with ports ready to take sources and monitors.

Where to go next

  • Installation

    How to set up the bifrost with the JAX port of GDSFactory.

  • Run your first simulation

    A 90° waveguide bend from an empty file to a transmission value and a field image.

  • Explore the live demo

    The result of that simulation in the viewer, in your browser, with no installation.

  • Read the user guide

    Layer stacks, simulation setup, results, the viewer, gradients, inverse design and diagnostics.