-
Notifications
You must be signed in to change notification settings - Fork 65
hotfix: remove unneeded warning with Medium2D and mode solver #2972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/mode/mode_solver.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense. But is the 2D medium included in the mode solve as well through the volumetric representation, or is it ignored?
It should be included in the mode solver, either via simulation.epsilon_on_grid (which explicitly uses volumetric_structures) or via the subpixel processing |
7d1306d to
b3e5469
Compare
b3e5469 to
1195830
Compare
Whenever a
Medium2Dand aModeSolverare present, we get warningsEvaluating the permittivity of a Medium2D is unphysical. We should be checking the volumetric equivalent structure instead.Greptile Overview
Updated On: 2025-11-06 16:49:01 UTC
Greptile Summary
Fixed spurious warnings when using
Medium2Dstructures withModeSolverby switching fromself.simulation.structurestoself.simulation.volumetric_structuresin the_intersecting_mediamethod.volumetric_structuresproperty automatically convertsMedium2Dstructures to their 3DAnisotropicMediumequivalentsMedium2D.eps_diagonal()directlyConfidence Score: 4/5
volumetric_structuresproperty) that was designed specifically for converting Medium2D to 3D equivalents. The fix is minimal (one line) and directly addresses the root cause of spurious warnings. However, the PR is missing a changelog entry as required by project conventions for bug fixes, which is the only reason for not scoring 5/5.Important Files Changed
File Analysis
self.simulation.structurestoself.simulation.volumetric_structuresin_intersecting_mediamethod to use converted 3D equivalents of Medium2D structures, avoiding unphysical permittivity warningsSequence Diagram
sequenceDiagram participant MS as ModeSolver participant Sim as Simulation participant Scene participant Medium2D participant VolumetricMedium as AnisotropicMedium Note over MS: _intersecting_media() called MS->>Sim: Get background_structure MS->>Sim: Get volumetric_structures Note over Sim: Returns structures with<br/>Medium2D converted to<br/>3D volumetric equivalents Sim->>Sim: _volumetric_structures_grid() loop For each structure alt Structure has Medium2D Sim->>Medium2D: volumetric_equivalent() Medium2D->>VolumetricMedium: Create AnisotropicMedium VolumetricMedium-->>Sim: Return 3D medium Note over Sim: Replace Medium2D structure<br/>with volumetric equivalent else Structure has 3D medium Note over Sim: Keep structure as is end end Sim-->>MS: Return volumetric_structures MS->>Scene: intersecting_media(plane, structures) Scene->>VolumetricMedium: Access permittivity Note over Scene: No warning since<br/>using physical 3D medium Scene-->>MS: Return intersecting media list