fix(rf): fix frequency sampling in MicrowaveModeData #2950
Merged
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-31 16:22:57 UTC
Greptile Summary
Fixes frequency sampling in
MicrowaveModeDatawhen group index calculation is enabled. Group index calculation requires triplet frequencies (backward, center, forward) for numerical differentiation, but theTransmissionLineDatasetwas incorrectly retaining all triplet frequencies instead of filtering back to the original center frequencies.Key Changes:
_group_index_freq_slices()helper method inModeDatato centralize frequency slice logic_group_index_post_process()inMicrowaveModeDatato filtertransmission_line_datafrequenciestest_mode_solver_with_microwave_group_index()to verify frequency filteringIssues Found:
Nonecheck fortransmission_line_databefore accessing attributes (could causeAttributeError)Confidence Score: 3/5
_group_index_post_process()accessestransmission_line_dataattributes without checking if it'sNonefirst (it's declared asOptional[TransmissionLineDataset]), which will cause anAttributeErrorin cases where transmission line data is not populatedtidy3d/components/microwave/data/monitor_data.py- the_group_index_post_process()method needs a None check before accessingtransmission_line_dataImportant Files Changed
File Analysis
Sequence Diagram
sequenceDiagram participant MS as ModeSolver participant MSD as MicrowaveModeSolverData participant MMD as MicrowaveModeData participant MD as ModeData MS->>MS: _get_data_with_group_index() Note over MS: Expands frequencies to triplets<br/>(back, center, forward) for<br/>numerical differentiation MS->>MS: _freqs_for_group_index() Note over MS: Creates [f1*(1-δ), f1, f1*(1+δ),<br/>f2*(1-δ), f2, f2*(1+δ), ...] MS->>MSD: Solve with expanded frequencies Note over MSD: data_raw contains triplet frequencies<br/>in transmission_line_data MS->>MMD: _group_index_post_process(frequency_step) MMD->>MD: super()._group_index_post_process() MD->>MD: _group_index_freq_slices() Note over MD: Returns (back, center, fwd) slices<br/>slice(0, n, 3), slice(1, n, 3), slice(2, n, 3) MD->>MD: Calculate n_group from triplets MD->>MD: Filter frequencies to center values MD-->>MMD: Returns filtered ModeData MMD->>MMD: _group_index_freq_slices() Note over MMD: Reuse same frequency slices MMD->>MMD: Filter transmission_line_data Note over MMD: Z0.isel(f=center_inds)<br/>voltage_coeffs.isel(f=center_inds)<br/>current_coeffs.isel(f=center_inds) MMD->>MMD: updated_copy(**update_dict) MMD-->>MS: Returns MicrowaveModeData<br/>with original frequencies only