FXC-3574 : WavePort mode handling in antenna metrics #2881
+60
−18
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.
Greptile Overview
Updated On: 2025-10-09 15:24:29 UTC
Summary
This PR fixes a bug in the WavePort mode handling within antenna metrics calculations in the Tidy3D S-matrix plugin. The core issue was that WavePort objects have associated mode indices that need to be properly tracked and used when generating task names for simulation data lookup.The changes span multiple components of the S-matrix terminal component modeling system:
Base Component Modeler: The
get_task_name
method now automatically uses a WavePort's inherentmode_index
attribute when no explicit mode index is provided, ensuring consistent task naming.Terminal Data Interface: The
get_antenna_metrics_data
method signature was updated to useNetworkIndex
type instead of genericstr
for port amplitude keys, improving type safety and API clarity.Antenna Analysis: Enhanced the antenna metrics calculation to properly handle WavePort mode indices in both default port amplitude creation and simulation data retrieval, preventing KeyError exceptions.
Testing Infrastructure: Added parameterized testing to cover both lumped and wave port configurations, and increased simulation domain size for coaxial structures to ensure accurate mode calculations.
These changes align the antenna analysis functionality with the established NetworkIndex pattern used elsewhere in the codebase, where individual excitations (including specific modes from WavePorts) are properly identified and tracked throughout the simulation workflow.
Important Files Changed
Changed Files
CHANGELOG.md
tidy3d/plugins/smatrix/component_modelers/base.py
tidy3d/plugins/smatrix/data/terminal.py
tidy3d/plugins/smatrix/analysis/antenna.py
tests/test_plugins/smatrix/terminal_component_modeler_def.py
tests/test_plugins/smatrix/test_terminal_component_modeler.py
Confidence score: 4/5
Sequence Diagram