| 1 |
import os |
| 2 |
import unittest |
| 3 |
|
| 4 |
import numpy as np |
| 5 |
import pytest |
| 6 |
from scipy.constants import c, pi |
| 7 |
|
| 8 |
import skrf as rf |
| 9 |
from skrf.media import MLine |
| 10 |
|
| 11 |
|
| 12 |
class DeembeddingTestCase(unittest.TestCase): |
| 13 |
""" |
| 14 |
Testcase for the Deembedding class |
| 15 |
Pseudo-netlists for s-parameter files used in these tests |
| 16 |
For open-short de-embedding: |
| 17 |
- deemb_ind.s2p |
| 18 |
P1 (1 0) port |
| 19 |
Cpad1 (1 0) capacitor c=25fF |
| 20 |
Rline1 (1 2) resistor r=2ohm |
| 21 |
Dut_ind (2 3) inductor l=1nH |
| 22 |
Rline2 (3 4) resistor r=2ohm |
| 23 |
Cpad2 (4 0) capacitor c=25fF |
| 24 |
Cp2p (1 4) capacitor c=10fF |
| 25 |
P2 (4 0) port |
| 26 |
- deemb_open.s2p |
| 27 |
P1 (1 0) port |
| 28 |
Cpad1 (1 0) capacitor c=25fF |
| 29 |
Rline1 (1 2) resistor r=2ohm |
| 30 |
Rline2 (3 4) resistor r=2ohm |
| 31 |
Cpad2 (4 0) capacitor c=25fF |
| 32 |
Cp2p (1 4) capacitor c=10fF |
| 33 |
P2 (4 0) port |
| 34 |
- deemb_short.s2p |
| 35 |
P1 (1 0) port |
| 36 |
Cpad1 (1 0) capacitor c=25fF |
| 37 |
Rline1 (1 0) resistor r=2ohm |
| 38 |
Rline2 (0 4) resistor r=2ohm |
| 39 |
Cpad2 (4 0) capacitor c=25fF |
| 40 |
Cp2p (1 4) capacitor c=10fF |
| 41 |
P2 (4 0) port |
| 42 |
For open de-embedding: |
| 43 |
- deemb_ind7.s2p |
| 44 |
P1 (1 0) port |
| 45 |
Cpad1 (1 0) capacitor c=25fF |
| 46 |
Dut_ind (1 2) inductor l=1nH |
| 47 |
Cpad2 (2 0) capacitor c=25fF |
| 48 |
Cp2p (1 2) capacitor c=10fF |
| 49 |
P2 (2 0) port |
| 50 |
- deemb_open7.s2p |
| 51 |
P1 (1 0) port |
| 52 |
Cpad1 (1 0) capacitor c=25fF |
| 53 |
Cpad2 (2 0) capacitor c=25fF |
| 54 |
Cp2p (1 2) capacitor c=10fF |
| 55 |
P2 (2 0) port |
| 56 |
For short-open de-embedding: |
| 57 |
- deemb_ind2.s2p |
| 58 |
P1 (1 0) port |
| 59 |
Rline1 (1 2) resistor r=2ohm |
| 60 |
Cpad1 (2 0) capacitor c=25fF |
| 61 |
Dut_ind (2 3) inductor l=1nH |
| 62 |
Cpad2 (3 0) capacitor c=25fF |
| 63 |
Cp2p (2 3) capacitor c=10fF |
| 64 |
Rline2 (3 4) resistor r=2ohm |
| 65 |
P2 (4 0) port |
| 66 |
- deemb_open2.s2p |
| 67 |
P1 (1 0) port |
| 68 |
Rline1 (1 2) resistor r=2ohm |
| 69 |
Cpad1 (2 0) capacitor c=25fF |
| 70 |
Cpad2 (3 0) capacitor c=25fF |
| 71 |
Cp2p (2 3) capacitor c=10fF |
| 72 |
Rline2 (3 4) resistor r=2ohm |
| 73 |
P2 (4 0) port |
| 74 |
- deemb_short2.s2p |
| 75 |
P1 (1 0) port |
| 76 |
Rline1 (1 0) resistor r=2ohm |
| 77 |
Cpad1 (0 0) capacitor c=25fF |
| 78 |
Cpad2 (0 0) capacitor c=25fF |
| 79 |
Cp2p (0 0) capacitor c=10fF |
| 80 |
Rline2 (0 4) resistor r=2ohm |
| 81 |
P2 (4 0) port |
| 82 |
For short de-embedding: |
| 83 |
- deemb_ind8.s2p |
| 84 |
P1 (1 0) port |
| 85 |
Rline1 (1 2) resistor r=2ohm |
| 86 |
Dut_ind (2 3) inductor l=1nH |
| 87 |
Rline2 (3 4) resistor r=2ohm |
| 88 |
P2 (4 0) port |
| 89 |
- deemb_short8.s2p |
| 90 |
P1 (1 0) port |
| 91 |
Rline1 (1 0) resistor r=2ohm |
| 92 |
Rline2 (0 4) resistor r=2ohm |
| 93 |
P2 (4 0) port |
| 94 |
For SplitPi de-embedding: |
| 95 |
- deemb_ind3.s2p |
| 96 |
P1 (1 0) port |
| 97 |
Cpad1 (1 0) capacitor c=25fF |
| 98 |
Rline1 (1 2) resistor r=2ohm |
| 99 |
Dut_ind (2 3) inductor l=1nH |
| 100 |
Rline2 (3 4) resistor r=2ohm |
| 101 |
Cpad2 (4 0) capacitor c=25fF |
| 102 |
P2 (4 0) port |
| 103 |
- deemb_thru3.s2p |
| 104 |
P1 (1 0) port |
| 105 |
Cpad1 (1 0) capacitor c=25fF |
| 106 |
Rline1 (1 2) resistor r=2ohm |
| 107 |
Rline2 (3 4) resistor r=2ohm |
| 108 |
Cpad2 (4 0) capacitor c=25fF |
| 109 |
P2 (4 0) port |
| 110 |
For SplitTee de-embedding: |
| 111 |
- deemb_ind4.s2p |
| 112 |
P1 (1 0) port |
| 113 |
Rline1 (1 2) resistor r=2ohm |
| 114 |
Cpad1 (2 0) capacitor c=25fF |
| 115 |
Dut_ind (2 3) inductor l=1nH |
| 116 |
Cpad2 (3 0) capacitor c=25fF |
| 117 |
Rline2 (3 4) resistor r=2ohm |
| 118 |
P2 (4 0) port |
| 119 |
- deemb_thru4.s2p |
| 120 |
P1 (1 0) port |
| 121 |
Rline1 (1 2) resistor r=2ohm |
| 122 |
Cpad1 (2 0) capacitor c=25fF |
| 123 |
Cpad2 (3 0) capacitor c=25fF |
| 124 |
Rline2 (3 4) resistor r=2ohm |
| 125 |
P2 (4 0) port |
| 126 |
For AdmittanceCancel de-embedding: |
| 127 |
- deemb_ind5.s2p |
| 128 |
P1 (1 0) port |
| 129 |
Cpad1 (1 0) capacitor c=25fF |
| 130 |
Dut_ind (1 2) inductor l=1nH |
| 131 |
Cpad2 (2 0) capacitor c=25fF |
| 132 |
P2 (2 0) port |
| 133 |
- deemb_thru5.s2p |
| 134 |
P1 (1 0) port |
| 135 |
Cpad1 (1 0) capacitor c=25fF |
| 136 |
Cpad2 (1 0) capacitor c=25fF |
| 137 |
P2 (1 0) port |
| 138 |
For ImpedanceCancel de-embedding: |
| 139 |
- deemb_ind6.s2p |
| 140 |
P1 (1 0) port |
| 141 |
Rline1 (1 2) resistor r=2ohm |
| 142 |
Dut_ind (2 3) inductor l=1nH |
| 143 |
Rline2 (3 4) resistor r=2ohm |
| 144 |
P2 (4 0) port |
| 145 |
- deemb_thru6.s2p |
| 146 |
P1 (1 0) port |
| 147 |
Rline1 (1 2) resistor r=2ohm |
| 148 |
Rline2 (2 3) resistor r=2ohm |
| 149 |
P2 (3 0) port |
| 150 |
""" |
| 151 |
|
| 152 |
def setUp(self): |
| 153 |
""" |
| 154 |
Read in all the network data required for tests |
| 155 |
""" |
| 156 |
self.test_dir = os.path.dirname(os.path.abspath(__file__))+'/deembed/' |
| 157 |
|
| 158 |
|
| 159 |
self.raw = rf.Network(os.path.join(self.test_dir, 'deemb_ind.s2p')) |
| 160 |
self.open = rf.Network(os.path.join(self.test_dir, 'deemb_open.s2p')) |
| 161 |
self.short = rf.Network(os.path.join(self.test_dir, 'deemb_short.s2p')) |
| 162 |
|
| 163 |
|
| 164 |
self.raw_1f = self.raw['10GHz'] |
| 165 |
self.open_1f = self.open['10GHz'] |
| 166 |
self.short_1f = self.short['10GHz'] |
| 167 |
|
| 168 |
|
| 169 |
self.raw7 = rf.Network(os.path.join(self.test_dir, 'deemb_ind7.s2p')) |
| 170 |
self.open7 = rf.Network(os.path.join(self.test_dir, 'deemb_open7.s2p')) |
| 171 |
|
| 172 |
|
| 173 |
self.raw7_1f = self.raw7['10GHz'] |
| 174 |
self.open7_1f = self.open7['10GHz'] |
| 175 |
|
| 176 |
|
| 177 |
self.raw2 = rf.Network(os.path.join(self.test_dir, 'deemb_ind2.s2p')) |
| 178 |
self.open2 = rf.Network(os.path.join(self.test_dir, 'deemb_open2.s2p')) |
| 179 |
self.short2 = rf.Network(os.path.join(self.test_dir, 'deemb_short2.s2p')) |
| 180 |
|
| 181 |
|
| 182 |
self.raw2_1f = self.raw2['10GHz'] |
| 183 |
self.open2_1f = self.open2['10GHz'] |
| 184 |
self.short2_1f = self.short2['10GHz'] |
| 185 |
|
| 186 |
|
| 187 |
self.raw8 = rf.Network(os.path.join(self.test_dir, 'deemb_ind8.s2p')) |
| 188 |
self.short8 = rf.Network(os.path.join(self.test_dir, 'deemb_short8.s2p')) |
| 189 |
|
| 190 |
|
| 191 |
self.raw8_1f = self.raw8['10GHz'] |
| 192 |
self.short8_1f = self.short8['10GHz'] |
| 193 |
|
| 194 |
|
| 195 |
self.raw3 = rf.Network(os.path.join(self.test_dir, 'deemb_ind3.s2p')) |
| 196 |
self.thru3 = rf.Network(os.path.join(self.test_dir, 'deemb_thru3.s2p')) |
| 197 |
|
| 198 |
|
| 199 |
self.raw3_1f = self.raw3['10GHz'] |
| 200 |
self.thru3_1f = self.thru3['10GHz'] |
| 201 |
|
| 202 |
|
| 203 |
self.raw4 = rf.Network(os.path.join(self.test_dir, 'deemb_ind4.s2p')) |
| 204 |
self.thru4 = rf.Network(os.path.join(self.test_dir, 'deemb_thru4.s2p')) |
| 205 |
|
| 206 |
|
| 207 |
self.raw4_1f = self.raw4['10GHz'] |
| 208 |
self.thru4_1f = self.thru4['10GHz'] |
| 209 |
|
| 210 |
|
| 211 |
self.raw5 = rf.Network(os.path.join(self.test_dir, 'deemb_ind5.s2p')) |
| 212 |
self.thru5 = rf.Network(os.path.join(self.test_dir, 'deemb_thru5.s2p')) |
| 213 |
|
| 214 |
|
| 215 |
self.raw5_1f = self.raw5['10GHz'] |
| 216 |
self.thru5_1f = self.thru5['10GHz'] |
| 217 |
|
| 218 |
|
| 219 |
self.raw6 = rf.Network(os.path.join(self.test_dir, 'deemb_ind6.s2p')) |
| 220 |
self.thru6 = rf.Network(os.path.join(self.test_dir, 'deemb_thru6.s2p')) |
| 221 |
|
| 222 |
|
| 223 |
self.raw6_1f = self.raw6['10GHz'] |
| 224 |
self.thru6_1f = self.thru6['10GHz'] |
| 225 |
|
| 226 |
|
| 227 |
self.dm = rf.OpenShort(self.open, self.short) |
| 228 |
self.dm_os = rf.OpenShort(self.open_1f, self.short_1f) |
| 229 |
self.dm_o = rf.Open(self.open7_1f) |
| 230 |
self.dm_so = rf.ShortOpen(self.short2_1f, self.open2_1f) |
| 231 |
self.dm_s = rf.Short(self.short8_1f) |
| 232 |
self.dm_pi = rf.SplitPi(self.thru3_1f) |
| 233 |
self.dm_tee = rf.SplitTee(self.thru4_1f) |
| 234 |
self.dm_ac = rf.AdmittanceCancel(self.thru5_1f) |
| 235 |
self.dm_ic = rf.ImpedanceCancel(self.thru6_1f) |
| 236 |
|
| 237 |
|
| 238 |
self.rtol = 1e-6 |
| 239 |
|
| 240 |
def test_freqmismatch(self): |
| 241 |
""" |
| 242 |
Check that a warning is caught when networks are of different frequencies |
| 243 |
""" |
| 244 |
with self.assertWarns(RuntimeWarning): |
| 245 |
rf.OpenShort(self.open, self.short[0:len(self.short)//2]) |
| 246 |
|
| 247 |
with self.assertWarns(RuntimeWarning): |
| 248 |
self.dm.deembed(self.raw[0:len(self.raw)//2]) |
| 249 |
|
| 250 |
def test_openshort(self): |
| 251 |
""" |
| 252 |
After de-embedding, the network is a pure inductor of 1nH. |
| 253 |
Test that this is true at a spot frequency. |
| 254 |
""" |
| 255 |
dut = self.dm_os.deembed(self.raw_1f) |
| 256 |
ind_calc = 1e9*np.imag(1/dut.y[0,0,0])/2/np.pi/dut.f |
| 257 |
self.assertTrue(np.isclose(ind_calc, 1, rtol=self.rtol)) |
| 258 |
|
| 259 |
def test_open(self): |
| 260 |
""" |
| 261 |
After de-embedding, the network is a pure inductor of 1nH. |
| 262 |
Test that this is true at a spot frequency. |
| 263 |
""" |
| 264 |
dut = self.dm_o.deembed(self.raw7_1f) |
| 265 |
ind_calc = 1e9*np.imag(1/dut.y[0,0,0])/2/np.pi/dut.f |
| 266 |
self.assertTrue(np.isclose(ind_calc, 1, rtol=self.rtol)) |
| 267 |
|
| 268 |
def test_shortopen(self): |
| 269 |
""" |
| 270 |
After de-embedding, the network is a pure inductor of 1nH. |
| 271 |
Test that this is true at a spot frequency. |
| 272 |
""" |
| 273 |
dut = self.dm_so.deembed(self.raw2_1f) |
| 274 |
ind_calc = 1e9*np.imag(1/dut.y[0,0,0])/2/np.pi/dut.f |
| 275 |
self.assertTrue(np.isclose(ind_calc, 1, rtol=self.rtol)) |
| 276 |
|
| 277 |
def test_short(self): |
| 278 |
""" |
| 279 |
After de-embedding, the network is a pure inductor of 1nH. |
| 280 |
Test that this is true at a spot frequency. |
| 281 |
""" |
| 282 |
dut = self.dm_s.deembed(self.raw8_1f) |
| 283 |
ind_calc = 1e9*np.imag(1/dut.y[0,0,0])/2/np.pi/dut.f |
| 284 |
self.assertTrue(np.isclose(ind_calc, 1, rtol=self.rtol)) |
| 285 |
|
| 286 |
def test_splitpi(self): |
| 287 |
""" |
| 288 |
After de-embedding, the network is a pure inductor of 1nH. |
| 289 |
Test that this is true at a spot frequency. |
| 290 |
""" |
| 291 |
dut = self.dm_pi.deembed(self.raw3_1f) |
| 292 |
ind_calc = 1e9*np.imag(1/dut.y[0,0,0])/2/np.pi/dut.f |
| 293 |
self.assertTrue(np.isclose(ind_calc, 1, rtol=self.rtol)) |
| 294 |
|
| 295 |
def test_splittee(self): |
| 296 |
""" |
| 297 |
After de-embedding, the network is a pure inductor of 1nH. |
| 298 |
Test that this is true at a spot frequency. |
| 299 |
""" |
| 300 |
dut = self.dm_tee.deembed(self.raw4_1f) |
| 301 |
ind_calc = 1e9*np.imag(1/dut.y[0,0,0])/2/np.pi/dut.f |
| 302 |
self.assertTrue(np.isclose(ind_calc, 1, rtol=self.rtol)) |
| 303 |
|
| 304 |
def test_admittance_cancel(self): |
| 305 |
""" |
| 306 |
After de-embedding, the network is a pure inductor of 1nH. |
| 307 |
Test that this is true at a spot frequency. |
| 308 |
""" |
| 309 |
dut = self.dm_ac.deembed(self.raw5_1f) |
| 310 |
ind_calc = 1e9*np.imag(1/dut.y[0,0,0])/2/np.pi/dut.f |
| 311 |
self.assertTrue(np.isclose(ind_calc, 1, rtol=self.rtol)) |
| 312 |
|
| 313 |
def test_impedance_cancel(self): |
| 314 |
""" |
| 315 |
After de-embedding, the network is a pure inductor of 1nH. |
| 316 |
Test that this is true at a spot frequency. |
| 317 |
""" |
| 318 |
dut = self.dm_ic.deembed(self.raw6_1f) |
| 319 |
ind_calc = 1e9*np.imag(1/dut.y[0,0,0])/2/np.pi/dut.f |
| 320 |
self.assertTrue(np.isclose(ind_calc, 1, rtol=self.rtol)) |
| 321 |
|
| 322 |
def test_IEEEP370_SE_NZC_2xThru(self): |
| 323 |
""" |
| 324 |
Test test_IEEEP370_SE_NZC_2xThru. |
| 325 |
|
| 326 |
After de-embedding fixtures model from 2xtru, the network is a perfect |
| 327 |
thru. |
| 328 |
Test that this thru has S21 amplitude and phase smaller than a limit. |
| 329 |
""" |
| 330 |
s2xthru = rf.Network(os.path.join(self.test_dir, 's2xthru.s2p')) |
| 331 |
dm_nzc = rf.IEEEP370_SE_NZC_2xThru(dummy_2xthru = s2xthru, |
| 332 |
name = '2xthru') |
| 333 |
residuals = dm_nzc.deembed(s2xthru) |
| 334 |
|
| 335 |
il_mag = 20.*np.log10(np.abs(residuals.s[:, 1, 0] + 1e-12)) |
| 336 |
self.assertTrue(np.max(np.abs(il_mag)) <= 0.1, 'residual IL magnitude') |
| 337 |
|
| 338 |
il_phase = np.angle(residuals.s[:, 1, 0]) * 180/np.pi |
| 339 |
self.assertTrue(np.max(np.abs(il_phase)) <= 1.0, 'residual IL Phase') |
| 340 |
|
| 341 |
def test_IEEEP370_SE_NZC_2xThru_with_dc(self): |
| 342 |
""" |
| 343 |
Test test_IEEEP370_SE_NZC_2xThru_with_dc. |
| 344 |
|
| 345 |
After de-embedding fixtures model from 2xtru, the network is a perfect |
| 346 |
thru. |
| 347 |
Test that this thru has S21 amplitude and phase smaller than a limit. |
| 348 |
""" |
| 349 |
s2xthru = rf.Network(os.path.join(self.test_dir, 's2xthru.s2p')) |
| 350 |
|
| 351 |
s2xthru_dc = s2xthru.extrapolate_to_dc(kind='linear') |
| 352 |
with pytest.warns(RuntimeWarning, match="DC point detected"): |
| 353 |
dm_nzc = rf.IEEEP370_SE_NZC_2xThru(dummy_2xthru = s2xthru_dc, |
| 354 |
name = '2xthru') |
| 355 |
residuals = dm_nzc.deembed(s2xthru_dc) |
| 356 |
|
| 357 |
il_mag = 20.*np.log10(np.abs(residuals.s[:, 1, 0] + 1e-12)) |
| 358 |
self.assertTrue(np.max(np.abs(il_mag)) <= 0.1, 'residual IL magnitude') |
| 359 |
|
| 360 |
il_phase = np.angle(residuals.s[:, 1, 0]) * 180/np.pi |
| 361 |
self.assertTrue(np.max(np.abs(il_phase)) <= 1.0, 'residual IL Phase') |
| 362 |
|
| 363 |
def test_IEEEP370_SE_NZC_2xThru_with_interpolation(self): |
| 364 |
""" |
| 365 |
Test test_IEEEP370_SE_NZC_2xThru_with_interpolation. |
| 366 |
While interpolation should be avoided, it keep useful in some cases, |
| 367 |
e.g. when the measurement frequency axis was not well formatted but |
| 368 |
a result is still needed and some deviation acceptable. |
| 369 |
After de-embedding fixtures model from 2xtru, the network is a perfect |
| 370 |
thru. |
| 371 |
Test that this thru has S21 amplitude and phase smaller than a limit. |
| 372 |
""" |
| 373 |
s2xthru = rf.Network(os.path.join(self.test_dir, 's2xthru.s2p')) |
| 374 |
|
| 375 |
nonuniform_freq = rf.Frequency(s2xthru.f[0], s2xthru.f[-1], |
| 376 |
npoints=len(s2xthru)-10, unit='Hz') |
| 377 |
s2xthru_nu = s2xthru.interpolate(nonuniform_freq) |
| 378 |
with pytest.warns(RuntimeWarning, match="Non-uniform frequency vector detected"): |
| 379 |
dm_nzc_nu = rf.IEEEP370_SE_NZC_2xThru(dummy_2xthru = s2xthru_nu, |
| 380 |
name = '2xthru') |
| 381 |
residuals = dm_nzc_nu.deembed(s2xthru_nu) |
| 382 |
|
| 383 |
il_mag = 20.*np.log10(np.abs(residuals.s[:, 1, 0] + 1e-12)) |
| 384 |
self.assertTrue(np.max(np.abs(il_mag)) <= 0.1, 'residual IL magnitude') |
| 385 |
|
| 386 |
il_phase = np.angle(residuals.s[:, 1, 0]) * 180/np.pi |
| 387 |
self.assertTrue(np.max(np.abs(il_phase)) <= 1.0, 'residual IL Phase') |
| 388 |
|
| 389 |
def test_IEEEP370_SE_ZC_2xThru(self): |
| 390 |
""" |
| 391 |
Test test_IEEEP370_SE_ZC_2xThru. |
| 392 |
|
| 393 |
After de-embedding fixtures model from 2xtru, the network is a perfect |
| 394 |
thru. |
| 395 |
Test that this thru has S21 amplitude and phase smaller than a limit. |
| 396 |
""" |
| 397 |
s2xthru = rf.Network(os.path.join(self.test_dir, 's2xthru.s2p')) |
| 398 |
fdf = rf.Network(os.path.join(self.test_dir, 'fdf.s2p')) |
| 399 |
dm_zc = rf.IEEEP370_SE_ZC_2xThru(dummy_2xthru = s2xthru, |
| 400 |
dummy_fix_dut_fix = fdf, |
| 401 |
bandwidth_limit = 10e9, |
| 402 |
pullback1 = 0, pullback2 = 0, |
| 403 |
leadin = 0, |
| 404 |
NRP_enable = False, |
| 405 |
name = 'zc2xthru') |
| 406 |
residuals = dm_zc.deembed(s2xthru) |
| 407 |
|
| 408 |
il_mag = 20.*np.log10(np.abs(residuals.s[:, 1, 0] + 1e-12)) |
| 409 |
self.assertTrue(np.max(np.abs(il_mag)) <= 0.2, 'residual IL magnitude') |
| 410 |
|
| 411 |
|
| 412 |
il_phase = np.angle(residuals.s[:, 1, 0]) * 180/np.pi |
| 413 |
self.assertTrue(np.max(np.abs(il_phase)) <= 2.0, 'residual IL Phase') |
| 414 |
|
| 415 |
def test_IEEEP370_SE_ZC_2xThru_with_dc(self): |
| 416 |
""" |
| 417 |
Test test_IEEEP370_SE_ZC_2xThru_with_dc. |
| 418 |
|
| 419 |
After de-embedding fixtures model from 2xtru, the network is a perfect |
| 420 |
thru. |
| 421 |
Test that this thru has S21 amplitude and phase smaller than a limit. |
| 422 |
""" |
| 423 |
s2xthru = rf.Network(os.path.join(self.test_dir, 's2xthru.s2p')) |
| 424 |
fdf = rf.Network(os.path.join(self.test_dir, 'fdf.s2p')) |
| 425 |
s2xthru_dc = s2xthru.extrapolate_to_dc(kind='linear') |
| 426 |
fdf_dc = fdf.extrapolate_to_dc(kind='linear') |
| 427 |
with pytest.warns(RuntimeWarning, match="DC point detected"): |
| 428 |
dm_zc = rf.IEEEP370_SE_ZC_2xThru(dummy_2xthru = s2xthru_dc, |
| 429 |
dummy_fix_dut_fix = fdf_dc, |
| 430 |
bandwidth_limit = 10e9, |
| 431 |
pullback1 = 0, pullback2 = 0, |
| 432 |
leadin = 0, |
| 433 |
NRP_enable = False, |
| 434 |
name = 'zc2xthru') |
| 435 |
residuals = dm_zc.deembed(s2xthru_dc) |
| 436 |
|
| 437 |
il_mag = 20.*np.log10(np.abs(residuals.s[:, 1, 0] + 1e-12)) |
| 438 |
self.assertTrue(np.max(np.abs(il_mag)) <= 0.2, 'residual IL magnitude') |
| 439 |
|
| 440 |
|
| 441 |
il_phase = np.angle(residuals.s[:, 1, 0]) * 180/np.pi |
| 442 |
self.assertTrue(np.max(np.abs(il_phase)) <= 2.0, 'residual IL Phase') |
| 443 |
|
| 444 |
def test_IEEEP370_SE_ZC_2xThru_with_interpolation(self): |
| 445 |
""" |
| 446 |
Test test_IEEEP370_SE_ZC_2xThru_with_interpolation. |
| 447 |
While interpolation should be avoided, it keep useful in some cases, |
| 448 |
e.g. when the measurement frequency axis was not well formatted but |
| 449 |
a result is still needed and some deviation acceptable. |
| 450 |
After de-embedding fixtures model from 2xtru, the network is a perfect |
| 451 |
thru. |
| 452 |
Test that this thru has S21 amplitude and phase smaller than a limit. |
| 453 |
""" |
| 454 |
s2xthru = rf.Network(os.path.join(self.test_dir, 's2xthru.s2p')) |
| 455 |
fdf = rf.Network(os.path.join(self.test_dir, 'fdf.s2p')) |
| 456 |
|
| 457 |
nonuniform_freq = rf.Frequency(s2xthru.f[0], s2xthru.f[-1], |
| 458 |
npoints=len(s2xthru)-10, unit='Hz') |
| 459 |
s2xthru_nu = s2xthru.interpolate(nonuniform_freq) |
| 460 |
fdf_nu = fdf.interpolate(nonuniform_freq) |
| 461 |
with pytest.warns(RuntimeWarning, match="Non-uniform frequency vector detected"): |
| 462 |
dm_zc_nu = rf.IEEEP370_SE_ZC_2xThru(dummy_2xthru = s2xthru_nu, |
| 463 |
dummy_fix_dut_fix = fdf_nu, |
| 464 |
bandwidth_limit = 10e9, |
| 465 |
pullback1 = 0, pullback2 = 0, |
| 466 |
leadin = 0, |
| 467 |
NRP_enable = False, |
| 468 |
name = 'zc2xthru') |
| 469 |
residuals = dm_zc_nu.deembed(s2xthru_nu) |
| 470 |
|
| 471 |
il_mag = 20.*np.log10(np.abs(residuals.s[:, 1, 0] + 1e-12)) |
| 472 |
self.assertTrue(np.max(np.abs(il_mag)) <= 0.2, 'residual IL magnitude') |
| 473 |
|
| 474 |
|
| 475 |
il_phase = np.angle(residuals.s[:, 1, 0]) * 180/np.pi |
| 476 |
self.assertTrue(np.max(np.abs(il_phase)) <= 2.0, 'residual IL Phase') |
| 477 |
|
| 478 |
def test_IEEEP370_SE_NZC_2xThru_no_180deg_phase_jumps(self): |
| 479 |
""" |
| 480 |
Test test_IEEEP370_SE_NZC_2xThru_no_180deg_phase_jumps. |
| 481 |
|
| 482 |
After de-embedding fixtures model from 2xtru, the network is a perfect |
| 483 |
thru. |
| 484 |
If there is noise on the 2xthru phase, incorrect computation of e01 and |
| 485 |
e10 could lead to 180° jumps into the side models s21 phase. |
| 486 |
Check this not happens. |
| 487 |
""" |
| 488 |
s2xthru = rf.Network(os.path.join(self.test_dir, 's2xthru.s2p')) |
| 489 |
|
| 490 |
|
| 491 |
e |
| 492 |
s2xthru_pn = s2xthru.copy() |
| 493 |
s2xthru_pn.add_noise_polar(0.0002, 0.2) |
| 494 |
dm_nzc_pn = rf.IEEEP370_SE_NZC_2xThru(dummy_2xthru = s2xthru_pn, |
| 495 |
name = '2xthru') |
| 496 |
residuals = dm_nzc_pn.deembed(s2xthru_pn) |
| 497 |
|
| 498 |
il_mag = 20.*np.log10(np.abs(residuals.s[:, 1, 0] + 1e-12)) |
| 499 |
self.assertTrue(np.max(np.abs(il_mag)) <= 0.1, 'residual IL magnitude') |
| 500 |
|
| 501 |
il_phase = np.angle(residuals.s[:, 1, 0]) * 180/np.pi |
| 502 |
self.assertTrue(np.max(np.abs(il_phase)) <= 1.0, 'residual IL Phase') |
| 503 |
|
| 504 |
def test_IEEEP370_check_fd_td_se_quality(self): |
| 505 |
""" |
| 506 |
Test test_IEEEP370_check_fd_se_quality. |
| 507 |
|
| 508 |
Check for passivity, reciprocity, and causality in the frequency |
| 509 |
and in the time domains. |
| 510 |
""" |
| 511 |
freq = rf.Frequency(10e-3, 10, 1000, 'GHz') |
| 512 |
W = 3.00e-3 |
| 513 |
H = 1.55e-3 |
| 514 |
T = 50e-6 |
| 515 |
ep_r = 4.459 |
| 516 |
tanD = 0.0183 |
| 517 |
f_epr_tand = 1e9 |
| 518 |
|
| 519 |
beta = 2 * pi * freq.f / c |
| 520 |
|
| 521 |
m50 = rf.media.DefinedGammaZ0(frequency = freq, z0_port = 50, gamma = 1j * beta) |
| 522 |
|
| 523 |
|
| 524 |
with pytest.warns(RuntimeWarning, match = r"^Conductor"): |
| 525 |
m = MLine(frequency=freq, z0_port=50, w=W, h=H, t=T, |
| 526 |
ep_r=ep_r, mu_r=1, rho=1.712e-8, tand=tanD, rough=0.15e-6, |
| 527 |
f_low=1e3, f_high=1e12, f_epr_tand=f_epr_tand, |
| 528 |
diel='djordjevicsvensson', disp='kirschningjansen') |
| 529 |
|
| 530 |
thru = m.line(0.050, 'm', z0 = 52.5) |
| 531 |
thru.name = "thru" |
| 532 |
|
| 533 |
fd_qm = rf.IEEEP370_FD_QM() |
| 534 |
td_qm = rf.IEEEP370_TD_QM(1e9, |
| 535 |
32, |
| 536 |
0.4, |
| 537 |
1, |
| 538 |
2, |
| 539 |
verbose = False) |
| 540 |
qm = fd_qm.check_se_quality(thru) |
| 541 |
self.assertTrue(qm['passivity']['value'] > 99.9 and |
| 542 |
qm['reciprocity']['value'] > 99.9 and |
| 543 |
qm['causality']['value'] > 99.9, |
| 544 |
'FD quality perfect thru') |
| 545 |
|
| 546 |
thru_non_passive = thru.copy() |
| 547 |
thru_non_passive.s[:, 1, 0] = 1.137 * thru_non_passive.s[:, 1, 0] |
| 548 |
thru_non_passive.s[:, 0, 1] = 1.137 * thru_non_passive.s[:, 0, 1] |
| 549 |
qm = fd_qm.check_se_quality(thru_non_passive) |
| 550 |
self.assertTrue(np.round(qm['passivity']['value'], 4) == 49.7701, |
| 551 |
'FD quality passivity violation') |
| 552 |
qm = td_qm.check_se_quality(thru_non_passive) |
| 553 |
self.assertTrue(np.round(qm['passivity']['value'], 4) == 71.3500, |
| 554 |
'TD quality passivity violation') |
| 555 |
|
| 556 |
thru_non_reciprocal = thru.copy() |
| 557 |
thru_non_reciprocal.s[:, 1, 0] = 0.945 * thru_non_reciprocal.s[:, 0, 1] |
| 558 |
qm = fd_qm.check_se_quality(thru_non_reciprocal) |
| 559 |
self.assertTrue(np.round(qm['reciprocity']['value'], 4) == 49.6120, |
| 560 |
'FD quality reciprocity violation') |
| 561 |
qm = td_qm.check_se_quality(thru_non_reciprocal) |
| 562 |
self.assertTrue(np.round(qm['reciprocity']['value'], 4) == 28.4500, |
| 563 |
'TD quality reciprocity violation') |
| 564 |
|
| 565 |
half_fd = m50.line(0.0445, 'm', z0 = 52) |
| 566 |
thru_non_causal_fd = half_fd.inv ** thru ** half_fd.inv |
| 567 |
thru_non_causal_fd.name = 'thru' |
| 568 |
qm = fd_qm.check_se_quality(thru_non_causal_fd) |
| 569 |
self.assertTrue(np.round(qm['causality']['value'], 4) == 48.2637, |
| 570 |
'FD quality causality violation') |
| 571 |
half = m50.line(0.18, 'm', z0 = 52) |
| 572 |
thru_non_causal = half.inv ** thru ** half.inv |
| 573 |
thru_non_causal.name = 'thru' |
| 574 |
qm = td_qm.check_se_quality(thru_non_causal) |
| 575 |
self.assertTrue(np.round(qm['causality']['value'], 4) == 10.0500, |
| 576 |
'TD quality causality violation') |