Skip to content

fix: support canonical material aliases - #759

Open
vvahidd wants to merge 2 commits into
mainfrom
fix/canonical-material-aliases
Open

fix: support canonical material aliases#759
vvahidd wants to merge 2 commits into
mainfrom
fix/canonical-material-aliases

Conversation

@vvahidd

@vvahidd vvahidd commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Add canonical Si, SiO2, and SiN aliases to the default Femwell and Tidy3D material mappings used by PDK layer stacks.

Complete missing canonical or legacy aliases in Lumerical without overriding explicit mappings. Existing lowercase aliases remain supported, while film-qualified tokens still require explicit material mappings.

Summary by Sourcery

Support canonical silicon material aliases across simulators without breaking existing mappings.

New Features:

  • Add canonical Si, SiO2, and SiN aliases to Femwell, Tidy3D, and Lumerical material mappings while preserving lowercase aliases.

Bug Fixes:

  • Ensure missing canonical or legacy silicon material names in Lumerical are automatically mapped to existing materials without overriding explicit configurations.

@sourcery-ai

sourcery-ai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds canonical material name aliases (Si, SiO2, SiN) across Lumerical, Tidy3D, and Femwell mappings so PDK layer stacks can use either canonical or lowercase material tokens without breaking existing explicit mappings.

File-Level Changes

Change Details Files
Introduce a bidirectional aliasing helper so Lumerical material mappings support both canonical (capitalized) and legacy (lowercase) material names without overriding explicit entries.
  • Define a material alias map between canonical and legacy silicon-related material names.
  • Add a helper that populates missing aliases in a material_mapping dict while preserving any preexisting keys.
  • Invoke the helper after merging default and user-supplied material_name_to_lumerical mappings in write_sparameters_lumerical.
gplugins/lumerical/write_sparameters_lumerical.py
Refactor Tidy3D component material mappings to share medium instances and expose both canonical and lowercase names for silicon, silicon dioxide, and silicon nitride.
  • Create shared td.Medium instances for Si, SiO2, and SiN.
  • Update material_name_to_medium to map both canonical and lowercase material names to these shared instances.
gplugins/tidy3d/component.py
Refactor Tidy3D material library mappings to share material instances and expose both canonical and lowercase names for silicon, silicon dioxide, and silicon nitride.
  • Create shared material_library entries for Si, SiO2, and SiN.
  • Update material_name_to_tidy3d to include both canonical and lowercase keys pointing to the shared instances.
gplugins/tidy3d/materials.py
Extend Femwell mode solver material index mapping to recognize canonical silicon-related material names in addition to legacy lowercase ones.
  • Add Si, SiO2, and SiN keys with appropriate refractive index values to the _material_name_to_index map while preserving existing lowercase entries.
gplugins/femwell/mode_solver.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@vvahidd vvahidd added the bug Something isn't working label Aug 10, 2026
@vvahidd
vvahidd marked this pull request as ready for review August 10, 2026 14:08

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In _add_material_name_aliases, the docstring claims aliases are added "without overriding mappings", but the elif branch explicitly overwrites the canonical name when only a legacy name exists; consider clarifying the docstring or making the behavior symmetric (using setdefault) to avoid surprise.
  • The material aliasing and medium definitions for Si, SiO2, and SiN are now repeated across multiple modules (Lumerical, Tidy3D, Femwell); consider centralizing the alias map and shared constants to reduce the risk of them drifting out of sync.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `_add_material_name_aliases`, the docstring claims aliases are added "without overriding mappings", but the `elif` branch explicitly overwrites the canonical name when only a legacy name exists; consider clarifying the docstring or making the behavior symmetric (using `setdefault`) to avoid surprise.
- The material aliasing and medium definitions for `Si`, `SiO2`, and `SiN` are now repeated across multiple modules (Lumerical, Tidy3D, Femwell); consider centralizing the alias map and shared constants to reduce the risk of them drifting out of sync.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant