feat: add FiberSource for grating coupler simulation#23
Draft
feat: add FiberSource for grating coupler simulation#23
Conversation
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.
2683607 to
0de2238
Compare
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FiberSourceAPI for Gaussian beam excitation (grating coupler fiber-to-chip coupling)CouplingResultmodel withfrom_csv(),plot(db=True), andpeak_cepropertymp.GaussianBeamSourcewith incident flux normalization:CE = |alpha|² / |flux|ebeam_gc_te1550Key design decisions
FiberSource.z_offsetreferences the core layer top (highest refractive index), not the topmost metal layer, so the source is always near the waveguideabs()since a downward beam produces negative flux through a +z-normal plane (MEEP convention)SimConfig.sourceis a discriminated union (source_type: "mode" | "fiber") for backward compatibilityTest plan
uv run pytest tests/meep/)z_offset >= margin_z_above