Skip to content
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

fix switch term termination function #938

Merged
merged 1 commit into from
Jul 28, 2023
Merged

Conversation

ZiadHatab
Copy link
Contributor

I have noticed that when terminating switch terms with zero values to a network and they have different port impedances, I get a wrong answer. Ideally, when switch terms are zero, I should get the same values of the network back. However, S11 and S22 are impacted depending on the port impedances of the network and the switch terms.

The problem comes from the fact that the function is written in such way that it performs network cascading when computing S11 and S22, which obviously results in implicit impedance transformation when the network and switch terms have different impedances.

The fix is basically to explicitly write the equations for S11 and S22 without using network cascading.

Here is a test code:

import skrf as rf
import matplotlib.pyplot as plt
from skrf.media import Coaxial

freq = rf.F(1, 10, 299, 'GHz')

coax1mm = Coaxial(freq, z0_port=50, Dint=0.434e-3, Dout=1.0e-3, sigma=1e8)

# Network
X = coax1mm.line(0.1, 'm', name='X')
X.name = 'Network unterminated'
X.z0 = [60, 60]   # overwrite port impedance

# switch terms
gamma_f = coax1mm.delay_load(0.2, 21e-3, 'm')
gamma_f.z0 = 50  # overwrite port impedance

gamma_r = coax1mm.delay_load(0.25, 16e-3, 'm')
gamma_r.z0 = 50  # overwrite port impedance

gamma_f.s = gamma_f.s*0  # zero switch terms
gamma_r.s = gamma_r.s*0  # zero switch terms

X_terminated = rf.terminate(X, gamma_f, gamma_r)
X_terminated.name = 'Network terminated'

fig, axs = plt.subplots(2,1)
fig.tight_layout(pad=2)
ax= axs[0]
X.s11.plot_s_db(ax=ax)
X_terminated.s11.plot_s_db(ax=ax, linestyle='--')
ax= axs[1]
X.s11.plot_s_deg(ax=ax)
X_terminated.s11.plot_s_deg(ax=ax, linestyle='--')

fig, axs = plt.subplots(2,1)
fig.tight_layout(pad=2)
ax= axs[0]
X.s22.plot_s_db(ax=ax)
X_terminated.s22.plot_s_db(ax=ax, linestyle='--')
ax= axs[1]
X.s22.plot_s_deg(ax=ax)
X_terminated.s22.plot_s_deg(ax=ax, linestyle='--')

plt.show()

Which results in below plots:
image
image

After the fix:
image
image

@jhillairet jhillairet added the fix Bug Fix label Jul 23, 2023
@jhillairet jhillairet merged commit 2787385 into scikit-rf:master Jul 28, 2023
11 checks passed
@jhillairet
Copy link
Member

Thank you @ZiadHatab

@jhillairet jhillairet mentioned this pull request Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants