fix(mode-solver): avoid GaussianBeam validation failure in rotated mode copy#3321
Open
momchil-flex wants to merge 1 commit intodevelopfrom
Open
fix(mode-solver): avoid GaussianBeam validation failure in rotated mode copy#3321momchil-flex wants to merge 1 commit intodevelopfrom
momchil-flex wants to merge 1 commit intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a validation failure that occurred when using angled mode solving with ModeMonitor and GaussianBeam sources. The issue arose because the rotated reference simulation retained sources that could become invalid after structure rotation, causing validation errors even though sources aren't needed for mode solving.
Changes:
- Modified
rotated_structures_copyto drop sources and monitors from the rotated simulation since they're not used for mode solving - Preserved the auto-grid wavelength before dropping sources to maintain deterministic grid generation
- Added a regression test to verify sources are properly dropped in rotated mode solver scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tidy3d/components/mode/mode_solver.py | Updated rotated_structures_copy method to extract and preserve wavelength from sources before dropping them, along with monitors, from the rotated simulation |
| tests/test_components/test_mode.py | Added regression test verifying that rotated mode solver simulations correctly drop sources and monitors while preserving wavelength |
| changelog.d/99999.fixed.md | Documented the fix for angled mode-solving with GaussianBeam sources |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lucas-flexcompute
approved these changes
Feb 20, 2026
Contributor
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
2680cbc to
9d4a025
Compare
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
ModeSolver.rotated_structures_copysince they are not needed for mode solving and can become invalid after structure rotationModeMonitor+GaussianBeamto verify rotated copy no longer retains sourcesValidation
source /home/momchil/flexcompute/codex/compute/src/Tidy3DCore/_build_local/bin/activate && cd /tmp/tidy3d_frontend_modefix && PYTHONPATH=/tmp/tidy3d_frontend_modefix pytest -q tests/test_components/test_mode.py -k "rotated_structures_copy_drops_sources_for_angled_mode_solver or test_validation_from_simulation" --maxfail=1source /home/momchil/flexcompute/codex/compute/src/Tidy3DCore/_build_local/bin/activate && cd /tmp/tidy3d_frontend_modefix && pre-commit run --files tidy3d/components/mode/mode_solver.py tests/test_components/test_mode.py changelog.d/99999.fixed.mdNote
Medium Risk
Touches
ModeSolver’s rotated-reference simulation construction and validation behavior, which could affect angled mode-solving and autogrid wavelength selection in edge cases.Overview
Fixes angled mode solving when a
Simulationcontains sources likeGaussianBeamby changingModeSolver.rotated_structures_copyto build the rotated-reference simulation without carrying over sources/monitors (and skipping validation).To keep auto-grid behavior deterministic after dropping sources, it snapshots an explicit
grid_spec.wavelengthwhen using autogrid without a wavelength. Adds a regression test covering an angledModeMonitorwith aGaussianBeam, and includes a changelog entry.Written by Cursor Bugbot for commit 9d4a025. This will update automatically on new commits. Configure here.