-
Notifications
You must be signed in to change notification settings - Fork 66
FXC-1636 support S-parameter de-embedding with reference plane shift. #2856
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
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.
3 files reviewed, 3 comments
c18c1f0
to
a3d1fbe
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
|
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.
Thanks @George-Guryev-flxcmp for a long awaited feature! Can you clarify in the method docstring what a positive port shift and negative port shift mean? Positive moves closer to the device (inwards)?
Also you will need to handle the case of TCM with a mix of lumped and wave ports. I am guessing the lumped ports will have a 1.0 at their row/column position and cannot be de-embedded.
Hmm, and now that I think about it we might need something more specific than a numpy array for the shifts, because of the presence of both types of ports.
would it make sense to add a convenience function |
@George-Guryev-flxcmp I think @dbochkov-flexcompute is correct here unfortunately. It might not be so simple as multiplying by a diagonal matrix for power waves. |
64dffc1
to
14de002
Compare
14de002
to
e58a37a
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.
Thanks for handling the lumped port case (and confirming power waves undergo the same transformation)! I have a couple of nitpicks, and I think there is a problem when there are multiple modes.
class PortShiftsDataArray(DataArray): | ||
"""Port shifts Data Array""" | ||
|
||
__slots__ = () | ||
_dims = "port" |
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.
Shame PortDataArray
is already taken. It might make sense to make this a bit more general in case in the future we need an array wrt port names for some other task. I suggest PortNameDataArray
. I think port_name
makes sense so that we can identify any lumped or wave port without choosing a mode index. The nomenclature is getting a bit confusing, but I am trying to split apart the notion of a Simulation Port and a microwave network port (row/col in the smatrix).
class PortShiftsDataArray(DataArray):
"""Port shifts Data Array"""
__slots__ = ()
_dims = "port_name"
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.
also please add a docstring example:
Example
-------
>>> import numpy as np
>>> port_names = ["port1", "port2"]
>>> coords = dict(port_name=port_names)
>>> data = (1+1j) * np.random.random((2,))
>>> port_data = PortNameDataArray(data, coords=coords)
kvecs = np.zeros((N_ports, N_freq), dtype=complex) | ||
shifts_vec = np.zeros((N_ports, 1)) | ||
directions_vec = np.ones((N_ports, 1)) |
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.
If you put freq dimension first, it might be easy to make use of broadcasting instead of the loops at the bottom
# if de-embedding is requested for lumped port | ||
if isinstance(ports[index], LumpedPortType): | ||
raise ValueError( | ||
"De-embedding currently supports only `WavePort` instances. " |
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.
In a console message like this we use 'WavePort', single quotes. I find it hard to keep track of what type of punctuation mark I need to use, here is a summary, which is sort of up to date.
When I am in doubt I search the code base to see what other code looks like.
mode_map = {mode_data.monitor.name: mode_data for mode_data in data} | ||
|
||
# Collect relevant mode data | ||
modes_data = tuple( | ||
mode_map[port._mode_monitor_name] for port in ports if isinstance(port, WavePort) | ||
) | ||
|
||
# infer propagation constants from modal data | ||
for i, mode_data in enumerate(modes_data): | ||
n_complex = mode_data.n_complex | ||
kvecs[i, :] = (2 * np.pi * n_complex.f * n_complex / C_0).squeeze() |
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.
Seems like this won't work when a WavePort
is setup with a ModeSpec
that calculates more than 1 mode. mode_data.n_complex will have dimensions of mode_index and frequency. For now you can use, waveport.mode_index
to select the correct mode.
I'll need to change this when multimodal waveports are in.
The main changes include:
change_port_reference_impedance
method for artificially translating port reference planes by updating S-parameters.This enables more flexible S-parameter analysis and supports use cases where ports need to be virtually shifted without rerunning full simulation.
Greptile Overview
Updated On: 2025-09-30 23:17:37 UTC
Summary
This PR introduces S-parameter de-embedding functionality to the Tidy3D framework, specifically adding the `change_port_reference_planes` method to the `TerminalComponentModelerData` class. S-parameter de-embedding is a critical technique in RF/microwave engineering that allows users to artificially shift port reference planes without re-running expensive full-wave simulations.The implementation extracts mode data from simulation results to compute propagation constants, then applies phase corrections using diagonal transformation matrices - a standard approach in microwave theory. The method takes an array of port shifts as input and returns updated S-parameters that reflect the virtually moved reference planes.
This feature integrates well with the existing S-matrix plugin architecture in Tidy3D, leveraging the established
ModeData
infrastructure and terminal component modeling capabilities. It supports common workflows in component characterization where reference plane positioning needs adjustment during post-processing analysis.PR Description Notes:
Important Files Changed
Changed Files
Confidence score: 4/5
Sequence Diagram