00 · Quickstart — a layout to S-parameters in ten lines

Take a component, pair it with a technology, pick an engine, and get a scattering matrix back. This runs on beamz, the free open-source JAX FDTD engine, so there’s no cloud account or license to set up.

Component  +  Technology  +  SimulationSpec   ──get_solver(engine)──▶  SMatrix

The rest of the guide (0110) covers each piece in detail.

from pathlib import Path

import gdsfactory as gf
import matplotlib.pyplot as plt

from gds_fdtd.layout.gdsfactory import from_gdsfactory
from gds_fdtd.plotting import plot_component, plot_smatrix
from gds_fdtd.solvers import get_solver
from gds_fdtd.spec import SimulationSpec
from gds_fdtd.technology import Technology


def _find(rel: str) -> Path:
    for base in (Path.cwd(), *Path.cwd().parents):
        if (base / rel).exists():
            return base / rel
    raise FileNotFoundError(rel)

The ten lines

A 3 µm straight silicon waveguide, simulated 1.5–1.6 µm on beamz.

gf.gpdk.PDK.activate()
tech = Technology.from_yaml(_find("examples/tech.yaml"))
component = from_gdsfactory(gf.components.straight(length=3), tech)
spec = SimulationSpec(
    wavelength_start=1.5, wavelength_end=1.6, wavelength_points=5, mesh=6, z_min=-1.0, z_max=1.11
)

solver = get_solver("beamz")(component, technology=tech, spec=spec)
smatrix = solver.run()  # the only line that spends compute (free & local here)

print(f"ports {smatrix.port_names}  ·  {smatrix.f.size} wavelengths")
print(f"through |S21| peak: {float(smatrix.magnitude_db(out='o2', in_='o1').max()):+.3f} dB")
18:59:57 PDT WARNING: Using canonical configuration directory at                
             '/home/mustafa/.config/tidy3d'. Found legacy directory at          
             '~/.tidy3d', which will be ignored. Remove it manually or run      
             'tidy3d config migrate --delete-legacy' to clean up.               
● Done: Raster cache hit (3d): 78b41468738b996da53e44784d675587621d3e9f5b8d0f4f7d8292ce9c127280.npz | load=0.10s
ports ['o1', 'o2']  ·  5 wavelengths
through |S21| peak: -0.004 dB

What came back

The geometry (auto-detected ports and simulation region) and the S-parameters. A straight waveguide passes most of its power through, near 0 dB.

plot_component(component, spec)
plt.show()

plot_smatrix(smatrix, kind="db")
plt.show()
../_images/7239c56d2c5175f0166709bd94a46d1fbd9055cece3364bdbb1861e5ddf3ba5c.png ../_images/37c20b5c30752f631010a95fa4fc3dc8599e47368bb8e8e13d0a7c8648b77d43.png

The run’s field profile: |E|² in the device plane, showing the guided mode carrying power from left to right.

solver.plot_fields(axis="z")
plt.show()
../_images/879e7230d2b1da97035c308487acb0c6fd6dffc2b6746df5a5bba887fbbe2a7b.png

Recap & next

The workflow is Component + Technology + SimulationSpecSMatrix. validate(), build(), and estimate() preview the job offline and free before run() spends anything.

Next: 01_layout_to_component (loading real layouts) and 03_first_simulation (the full flow, step by step).