-
Notifications
You must be signed in to change notification settings - Fork 70
FXC-1617: switch tensorial mode solver to tidy3d-extras #3218
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
base: develop
Are you sure you want to change the base?
Conversation
d657e01 to
a266ac8
Compare
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.
Pull request overview
This PR transitions the fully tensorial mode solver from local implementation to requiring either tidy3d-extras or server execution. The change aims to consolidate on a more accurate tensorial mode solver implementation available in tidy3d-extras while maintaining backward compatibility for diagonal (non-tensorial) mode solving.
Changes:
- Replaces the local tensorial mode solver implementation with a NotImplementedError that provides clear instructions to users
- Adds dynamic solver selection via
_get_solver_func()that prefers tidy3d-extras when available - Includes comprehensive test coverage for both with/without tidy3d-extras scenarios
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tidy3d/components/mode/solver.py | Removed ~130 lines of tensorial solver implementation; replaced with error message directing users to tidy3d-extras or server |
| tidy3d/components/mode/mode_solver.py | Added _get_solver_func() to dynamically select between extras and base solver; updated solver calls to use this function |
| tests/test_components/test_mode.py | Added comprehensive tests for tensorial solver error handling, tidy3d-extras integration, and diagonal solver functionality |
| CHANGELOG.md | Documented the breaking change with clear user guidance |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
- Add explanatory comment to except clause in _get_solver_func - Fix import style in test (use 'from' import) - Disable local subpixel in test to prevent tidy3d-extras bypass
a266ac8 to
3cb8539
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/mode/mode_solver.pyLines 122-138 122 ImportError
123 If the local solver could not be imported (e.g., scipy not installed).
124 """
125 if not LOCAL_SOLVER_IMPORTED:
! 126 raise ImportError(IMPORT_ERROR_MSG)
127
128 # Try to get tidy3d-extras solver (handles all cases including tensorial)
129 try:
130 _check_tidy3d_extras_available(quiet=True)
! 131 if tidy3d_extras["mod"] is not None:
! 132 from tidy3d_extras.mode import EigSolver as ExtrasEigSolver
133
! 134 return ExtrasEigSolver.compute_modes
135 except (Tidy3dImportError, ImportError, AttributeError):
136 # tidy3d-extras is optional; if unavailable or incompatible, fall back to base solver.
137 pass |
The tensorial mode solver in tidy3d-extras has been made more accurate. Notably, for nominally lossless, fully tensorial media, the mode solver should return very close to lossless modes.
To avoid confusion, we are removing the legacy local tensorial mode solver. Local runs are still fully supported (and more accurate!) they just require installing tidy3d-extras.
Note
Medium Risk
Changes affect the mode-solver execution path and error behavior for tensorial/angled/aniso cases, and rely on optional
tidy3d-extrasavailability; diagonal/local and server paths should remain unchanged but need regression coverage.Overview
Local mode solving now selects the best available solver at runtime:
ModeSolver/ModeSimulation.run_local()will usetidy3d-extras’ mode solver when present, otherwise fall back to the base solver.The legacy in-core fully tensorial eigenmode implementation is removed; attempting a tensorial solve (non-zero
ModeSpec.angle_thetaor fully anisotropic media) withouttidy3d-extrasnow raises a clearNotImplementedErrorinstructing users to installtidy3d[extras]or run via the server.Tests and docs are updated accordingly: new coverage asserts the error/fallback behavior and skips tensorial-local tests when extras aren’t available, and plugin tests that directly exercised
compute_modes/angled tensorial paths are removed.Written by Cursor Bugbot for commit 3cb8539. This will update automatically on new commits. Configure here.