Skip to content

Comments

fix(mode-solver): avoid GaussianBeam validation failure in rotated mode copy#3321

Open
momchil-flex wants to merge 1 commit intodevelopfrom
hotfix/mode-monitor-rotated-copy-sources
Open

fix(mode-solver): avoid GaussianBeam validation failure in rotated mode copy#3321
momchil-flex wants to merge 1 commit intodevelopfrom
hotfix/mode-monitor-rotated-copy-sources

Conversation

@momchil-flex
Copy link
Collaborator

@momchil-flex momchil-flex commented Feb 20, 2026

Summary

  • drop sources and monitors from ModeSolver.rotated_structures_copy since they are not needed for mode solving and can become invalid after structure rotation
  • preserve an explicit auto-grid wavelength before dropping sources to keep grid generation deterministic
  • add regression test for angled ModeMonitor + GaussianBeam to verify rotated copy no longer retains sources
  • add changelog fragment

Validation

  • 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=1
  • source /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.md

Note

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 Simulation contains sources like GaussianBeam by changing ModeSolver.rotated_structures_copy to 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.wavelength when using autogrid without a wavelength. Adds a regression test covering an angled ModeMonitor with a GaussianBeam, and includes a changelog entry.

Written by Cursor Bugbot for commit 9d4a025. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings February 20, 2026 13:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_copy to 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.

@github-actions
Copy link
Contributor

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

  • tidy3d/components/mode/mode_solver.py (100%)

Summary

  • Total: 5 lines
  • Missing: 0 lines
  • Coverage: 100%

@momchil-flex momchil-flex force-pushed the hotfix/mode-monitor-rotated-copy-sources branch from 2680cbc to 9d4a025 Compare February 20, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants