zapFDTD — 3D Euler bend example¶
A standalone notebook for simulating a generic silicon Euler bend with zapFDTD through gsim. Run the cells in order in an environment with gsim installed; it uses the generic PDK bundled with gdsfactory. This notebook uses the gsim API that includes Simulation.add_monitors(). This notebook requires gsim>=0.8.0; to update an older project environment, run uv add "gsim>=0.8.0" "pdk-schema[sympy]~=0.3.0" from your project folder, then restart the notebook kernel.
Edit the component in Config and numerical parameters in Simulation Settings. The Run cell sends your job to GDSFactory+ servers for computation and requires your usual gsim account access.
Rerun Config after changing your filesystem, PDK, imports, or making any changes to the simulation target.
# Config
import gdsfactory as gf
from gsim import fdtd as zap
pdk = gf.gpdk.PDK
pdk.activate()
component = gf.components.bend_euler(radius=10.0, angle=90.0, cross_section="strip")
Simulation Settings¶
Wavelengths are in micrometers; grid spacing is in nanometers. The background is silica, using the PDK material name SiO2. Paths are relative to the kernel working directory; absolute paths also work.
These numerical settings are starting values. Compare finer grids before relying on numerical accuracy.
source_port = "o1"
wavelength_um = 1.55
wavelength_span_um = 0.10
num_wavelengths = 11
cell_size_nm = 60.0
background_material = "SiO2"
# Lossless refractive indices at 1.55 um for the generic PDK materials.
material_overrides = {"si": 3.47, "SiO2": 1.44}
prepare_path = "zapfdtd_bend_inputs"
results_path = "zapfdtd_bend_results"
Prepare and preview¶
Configure zapFDTD with your settings, write the local mesh and configuration, then preview the geometry. Rerun this cell after changing simulation parameters. This cell does not submit a solver job.
sim = zap.Simulation(pdk=pdk)
sim.materials(background=background_material, overrides=material_overrides)
sim.source(
port=source_port,
wavelength_um=wavelength_um,
wavelength_span_um=wavelength_span_um,
num_wavelengths=num_wavelengths,
)
sim.geometry(component)
# Pad the sides without ports (um) so the port monitor windows fit inside the
# non-PML domain; sides containing a guided port must stay unpadded.
sim.domain(padding_x=(0.0, 1.0), padding_y=(1.0, 0.0))
sim.solver(cell_size_nm=cell_size_nm)
# Native gsim heatmaps at every optical port and an optional XY overview.
# xy=True includes the XY overview;
# xy=False keeps only port heatmaps. z_um=None chooses the geometry midpoint;
# pass z_um in micrometers to set the overview height explicitly.
# margin_um=0.75 adds cladding on each side of the port cross section.
sim.add_monitors()
# Preview
artifacts = sim.write(prepare_path)
print("Prepared:", artifacts.config_path)
sim.plot_3d()
Run¶
Run this cell when ready to submit a cloud job. Rerun preparation after changing the settings. One source produces one response column, not a full multi-source S-matrix.
Results¶
Inspect the response and convergence information before relying on the result. A finer-grid comparison is still needed to establish numerical accuracy. Field heatmaps show driven intensity at the center wavelength.