Skip to content

feat: add FiberSource for grating coupler simulation#23

Draft
vvahidd wants to merge 9 commits intomainfrom
feat/fiber-source
Draft

feat: add FiberSource for grating coupler simulation#23
vvahidd wants to merge 9 commits intomainfrom
feat/fiber-source

Conversation

@vvahidd
Copy link
Copy Markdown
Contributor

@vvahidd vvahidd commented Feb 19, 2026

Summary

  • Add FiberSource API for Gaussian beam excitation (grating coupler fiber-to-chip coupling)
  • New CouplingResult model with from_csv(), plot(db=True), and peak_ce property
  • Runner generates mp.GaussianBeamSource with incident flux normalization: CE = |alpha|² / |flux|
  • Example notebook using UBC PDK ebeam_gc_te1550
  • 179 meep tests passing (136 new for FiberSource)

Key design decisions

  • FiberSource.z_offset references the core layer top (highest refractive index), not the topmost metal layer, so the source is always near the waveguide
  • Cell z-range includes dielectrics (cladding/air above patterned layers), with a safety extension if the source would fall outside
  • Incident flux uses abs() since a downward beam produces negative flux through a +z-normal plane (MEEP convention)
  • SimConfig.source is a discriminated union (source_type: "mode" | "fiber") for backward compatibility

Test plan

  • All 179 meep tests pass (uv run pytest tests/meep/)
  • New tests: FiberSource model, FiberSourceConfig, CouplingResult, simulation integration, script generation
  • z_position regression test: verifies core layer reference, not topmost layer
  • Validation warns when z_offset >= margin_z_above
  • Cloud run with UBC PDK grating coupler produces non-zero coupling efficiency

@vvahidd vvahidd marked this pull request as draft February 19, 2026 19:50
vvahidd added 2 commits April 7, 2026 20:56
Add Gaussian beam source support to gsim.meep for simulating
fiber-to-chip coupling through grating couplers.

New API:
- FiberSource model (beam_waist, angle_theta, z_offset, polarization)
- FiberSourceConfig with discriminated union on SimConfig.source
- CouplingResult with from_csv(), plot(), peak_ce
- Notebook example using UBC PDK ebeam_gc_te1550

Runner changes:
- build_fiber_source() creates mp.GaussianBeamSource
- build_incident_flux_monitor() for normalization
- extract_coupling_efficiency() with CE = |alpha|^2 / |incident_flux|
- Cell z-range includes dielectrics (not just layer_stack)
- Source z references core layer (highest n), not topmost metal
- Use abs() on incident flux (downward beam gives negative flux)

179 meep tests passing.
@vvahidd vvahidd force-pushed the feat/fiber-source branch from 2683607 to 0de2238 Compare April 7, 2026 18:57
@github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 7, 2026
vvahidd added 7 commits April 7, 2026 21:00
- Format long pydantic import line
- Add docstring to TestFiberSource class (interrogate)
- Add isinstance narrowing for ty type checker
- Wrap long lines in ROADMAP.md
…nimation helper

Support xz cross-section animations for grating coupler sims, render
fiber source metadata in 2D plot overlays, and add CouplingResult.show_animation()
for inline Jupyter playback.
Draw the Gaussian beam on plot_2d slices: cone with arrow on XZ/YZ
side views, dashed circle footprint on XY top-down view.
Replace GaussianBeamSource with the proven gplugins approach:
launch EigenModeSource from waveguide port, measure coupling
into fiber mode via get_eigenmode_coefficients with oblique
kpoint and NO_DIRECTION. Fixes grating coupler CE from -37 dB
to physically meaningful values.

Also fix animation frame saving to use MEEP's native HDF5 output
(mp.output_efield_y) instead of get_array, avoiding MPI vol
mismatch crashes and OOM kills on multi-rank cloud runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant