| 1 |
{ |
| 2 |
"cells": [ |
| 3 |
{ |
| 4 |
"cell_type": "markdown", |
| 5 |
"id": "2fcad5e3", |
| 6 |
"metadata": {}, |
| 7 |
"source": [ |
| 8 |
"# Finding Dielectric Constant and Loss from Resonance Fitting" |
| 9 |
] |
| 10 |
}, |
| 11 |
{ |
| 12 |
"cell_type": "markdown", |
| 13 |
"id": "7f62e543", |
| 14 |
"metadata": {}, |
| 15 |
"source": [ |
| 16 |
"In this example, the Q-factors are fitted from S-parameters data measured to characterize PCB laminate materials. The data correspond to a 36, 72 and 144 mm long stripline resonator respectively. We will then deduce the Dielectric permittivity and loss constants." |
| 17 |
] |
| 18 |
}, |
| 19 |
{ |
| 20 |
"cell_type": "markdown", |
| 21 |
"id": "89cc436a", |
| 22 |
"metadata": {}, |
| 23 |
"source": [ |
| 24 |
"## Fitting Q-factors" |
| 25 |
] |
| 26 |
}, |
| 27 |
{ |
| 28 |
"cell_type": "code", |
| 29 |
"execution_count": null, |
| 30 |
"id": "cec79edf", |
| 31 |
"metadata": {}, |
| 32 |
"outputs": [], |
| 33 |
"source": [ |
| 34 |
"import matplotlib.pyplot as plt\n", |
| 35 |
"\n", |
| 36 |
"import skrf as rf\n", |
| 37 |
"\n", |
| 38 |
"rf.stylely()" |
| 39 |
] |
| 40 |
}, |
| 41 |
{ |
| 42 |
"cell_type": "code", |
| 43 |
"execution_count": null, |
| 44 |
"id": "d9862027", |
| 45 |
"metadata": {}, |
| 46 |
"outputs": [], |
| 47 |
"source": [ |
| 48 |
"# Loading the data.\n", |
| 49 |
"# Setting the frequency unit is optional, just a convenience for displaying results\n", |
| 50 |
"Reson36 = rf.Network('data/resonator_36mm.s2p', f_unit='GHz')\n", |
| 51 |
"Reson72 = rf.Network('data/resonator_72mm.s2p', f_unit='GHz')\n", |
| 52 |
"Reson144 = rf.Network('data/resonator_144mm.s2p', f_unit='GHz')" |
| 53 |
] |
| 54 |
}, |
| 55 |
{ |
| 56 |
"cell_type": "code", |
| 57 |
"execution_count": null, |
| 58 |
"id": "9860ddc0", |
| 59 |
"metadata": {}, |
| 60 |
"outputs": [], |
| 61 |
"source": [ |
| 62 |
"Reson36.plot_s_db(m=1, n=0)\n", |
| 63 |
"Reson72.plot_s_db(m=1, n=0)\n", |
| 64 |
"Reson144.plot_s_db(m=1, n=0)" |
| 65 |
] |
| 66 |
}, |
| 67 |
{ |
| 68 |
"cell_type": "markdown", |
| 69 |
"id": "f77d1fbf", |
| 70 |
"metadata": {}, |
| 71 |
"source": [ |
| 72 |
"To find the Q-factors of these resonators, we create a `Qfactor` object from the transmission S-parameters we want to fit.\n", |
| 73 |
"\n", |
| 74 |
"Note that is there are many resonances close to each other, it is recommended to pass the frequency sub-Networks for the range of frequency of interest, to help the convergence of the fitting algorithm. Here, we are interested in the resonances occurring around 2 and 4 GHz, hence:" |
| 75 |
] |
| 76 |
}, |
| 77 |
{ |
| 78 |
"cell_type": "code", |
| 79 |
"execution_count": null, |
| 80 |
"id": "3e5f0990", |
| 81 |
"metadata": {}, |
| 82 |
"outputs": [], |
| 83 |
"source": [ |
| 84 |
"# Around 2 GHz\n", |
| 85 |
"QF_36_2GHz = rf.Qfactor(Reson36['1.75-2.25GHz'].s21, res_type='transmission')\n", |
| 86 |
"QF_72_2GHz = rf.Qfactor(Reson72['1.75-2.25GHz'].s21, res_type='transmission')\n", |
| 87 |
"QF_144_2GHz = rf.Qfactor(Reson144['1.75-2.25GHz'].s21, res_type='transmission')\n", |
| 88 |
"# Around 4 GHz\n", |
| 89 |
"QF_36_4GHz = rf.Qfactor(Reson36['3.75-4.25GHz'].s21, res_type='transmission')\n", |
| 90 |
"QF_72_4GHz = rf.Qfactor(Reson72['3.75-4.25GHz'].s21, res_type='transmission')\n", |
| 91 |
"QF_144_4GHz = rf.Qfactor(Reson144['3.75-4.25GHz'].s21, res_type='transmission')\n", |
| 92 |
"\n", |
| 93 |
"all_QFs = [QF_36_2GHz, QF_72_2GHz, QF_144_2GHz, QF_36_4GHz, QF_72_4GHz, QF_144_4GHz]" |
| 94 |
] |
| 95 |
}, |
| 96 |
{ |
| 97 |
"cell_type": "code", |
| 98 |
"execution_count": null, |
| 99 |
"id": "557dc5f1", |
| 100 |
"metadata": {}, |
| 101 |
"outputs": [], |
| 102 |
"source": [ |
| 103 |
"print(*all_QFs, sep='\\n')" |
| 104 |
] |
| 105 |
}, |
| 106 |
{ |
| 107 |
"cell_type": "markdown", |
| 108 |
"id": "2cc57ef0", |
| 109 |
"metadata": {}, |
| 110 |
"source": [ |
| 111 |
"Then we fit the Q-factors:" |
| 112 |
] |
| 113 |
}, |
| 114 |
{ |
| 115 |
"cell_type": "code", |
| 116 |
"execution_count": null, |
| 117 |
"id": "aa771f3d", |
| 118 |
"metadata": {}, |
| 119 |
"outputs": [], |
| 120 |
"source": [ |
| 121 |
"[Q.fit() for Q in all_QFs]\n", |
| 122 |
"print(*all_QFs, sep='\\n')" |
| 123 |
] |
| 124 |
}, |
| 125 |
{ |
| 126 |
"cell_type": "markdown", |
| 127 |
"id": "2a27c7dd", |
| 128 |
"metadata": {}, |
| 129 |
"source": [ |
| 130 |
"We can create the Networks corresponding to the fitted results to benchmark the model against the measurements:" |
| 131 |
] |
| 132 |
}, |
| 133 |
{ |
| 134 |
"cell_type": "code", |
| 135 |
"execution_count": null, |
| 136 |
"id": "9e779273", |
| 137 |
"metadata": {}, |
| 138 |
"outputs": [], |
| 139 |
"source": [ |
| 140 |
"new_freq = rf.Frequency(1, 5, unit='GHz', npoints=1001)\n", |
| 141 |
"fitted_ntwk_36_2GHz = QF_36_2GHz.fitted_network(frequency=new_freq)\n", |
| 142 |
"fitted_ntwk_72_2GHz = QF_72_2GHz.fitted_network(frequency=new_freq)\n", |
| 143 |
"fitted_ntwk_144_2GHz = QF_144_2GHz.fitted_network(frequency=new_freq)\n", |
| 144 |
"\n", |
| 145 |
"fitted_ntwk_36_4GHz = QF_36_4GHz.fitted_network(frequency=new_freq)\n", |
| 146 |
"fitted_ntwk_72_4GHz = QF_72_4GHz.fitted_network(frequency=new_freq)\n", |
| 147 |
"fitted_ntwk_144_4GHz = QF_144_4GHz.fitted_network(frequency=new_freq)" |
| 148 |
] |
| 149 |
}, |
| 150 |
{ |
| 151 |
"cell_type": "code", |
| 152 |
"execution_count": null, |
| 153 |
"id": "c504a66b", |
| 154 |
"metadata": {}, |
| 155 |
"outputs": [], |
| 156 |
"source": [ |
| 157 |
"Reson36.plot_s_db(m=1, n=0, color='C0')\n", |
| 158 |
"fitted_ntwk_36_2GHz.plot_s_db(label='Fitted Model ~ 2GHz', lw=2, color='C0', ls='--')\n", |
| 159 |
"fitted_ntwk_36_4GHz.plot_s_db(label='Fitted Model ~ 4GHz', lw=2, color='C0', ls=':')\n", |
| 160 |
"Reson72.plot_s_db(m=1, n=0, color='C1')\n", |
| 161 |
"fitted_ntwk_72_2GHz.plot_s_db(label='Fitted Model ~ 2GHz', lw=2, color='C1', ls='--')\n", |
| 162 |
"fitted_ntwk_72_4GHz.plot_s_db(label='Fitted Model ~ 4GHz', lw=2, color='C1', ls=':')\n", |
| 163 |
"Reson144.plot_s_db(m=1, n=0, color='C2')\n", |
| 164 |
"fitted_ntwk_144_2GHz.plot_s_db(label='Fitted Model ~ 2GHz', lw=2, color='C2', ls='--')\n", |
| 165 |
"fitted_ntwk_144_4GHz.plot_s_db(label='Fitted Model ~ 4GHz', lw=2, color='C2', ls=':')\n", |
| 166 |
"plt.gca().legend(ncol=3)" |
| 167 |
] |
| 168 |
}, |
| 169 |
{ |
| 170 |
"cell_type": "markdown", |
| 171 |
"id": "fed0d05b", |
| 172 |
"metadata": {}, |
| 173 |
"source": [ |
| 174 |
"Another way to represent the results is to use polar planes:" |
| 175 |
] |
| 176 |
}, |
| 177 |
{ |
| 178 |
"cell_type": "code", |
| 179 |
"execution_count": null, |
| 180 |
"id": "e4295d4e", |
| 181 |
"metadata": {}, |
| 182 |
"outputs": [], |
| 183 |
"source": [ |
| 184 |
"fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})\n", |
| 185 |
"Reson36.plot_s_polar(m=1, n=0, ax=ax, ls='', marker='x', ms=5)\n", |
| 186 |
"fitted_ntwk_36_2GHz.plot_s_polar(ax=ax, label=\"Fitted Model ~ 2GHz\", lw=2, ls='--', color='C3')\n", |
| 187 |
"fitted_ntwk_36_4GHz.plot_s_polar(ax=ax, label=\"Fitted Model ~ 4GHz\", lw=2, ls=':', color='C3')" |
| 188 |
] |
| 189 |
}, |
| 190 |
{ |
| 191 |
"cell_type": "code", |
| 192 |
"execution_count": null, |
| 193 |
"id": "99f626cf", |
| 194 |
"metadata": {}, |
| 195 |
"outputs": [], |
| 196 |
"source": [ |
| 197 |
"fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})\n", |
| 198 |
"Reson72.plot_s_polar(m=1, n=0, ax=ax, ls='', marker='x', ms=5, color='C1')\n", |
| 199 |
"fitted_ntwk_72_2GHz.plot_s_polar(ax=ax, label=\"Fitted Model ~ 2GHz\", lw=2, ls='--', color='C3')\n", |
| 200 |
"fitted_ntwk_72_4GHz.plot_s_polar(ax=ax, label=\"Fitted Model ~ 4GHz\", lw=2, ls=':', color='C3')" |
| 201 |
] |
| 202 |
}, |
| 203 |
{ |
| 204 |
"cell_type": "code", |
| 205 |
"execution_count": null, |
| 206 |
"id": "14f65cf4", |
| 207 |
"metadata": {}, |
| 208 |
"outputs": [], |
| 209 |
"source": [ |
| 210 |
"fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})\n", |
| 211 |
"Reson144.plot_s_polar(m=1, n=0, ax=ax, ls='', marker='x', ms=5, color='C2')\n", |
| 212 |
"fitted_ntwk_144_2GHz.plot_s_polar(ax=ax, label=\"Fitted Model ~ 2GHz\", lw=2, ls='--', color='C3')\n", |
| 213 |
"fitted_ntwk_144_4GHz.plot_s_polar(ax=ax, label=\"Fitted Model ~ 4GHz\", lw=2, ls=':', color='C3')" |
| 214 |
] |
| 215 |
}, |
| 216 |
{ |
| 217 |
"cell_type": "markdown", |
| 218 |
"id": "9f653dfd", |
| 219 |
"metadata": {}, |
| 220 |
"source": [ |
| 221 |
"## Increasing Accuracy\n", |
| 222 |
"If you want to get the best accuracy in the calculation of the Q-factors, it’s recommended to repeat the fitting a second time using S-parameters data having the resonance peak at the centre frequency and the span reduced to $\\pm f_L/Q_L$ (cf. [1] page 21). This is justified in two ways:\n", |
| 223 |
"\n", |
| 224 |
"* $Q_L$ is defined at the resonant frequency $f_L$\n", |
| 225 |
"* Limiting the span reduces the effects of other modes, mismatches, and differences between the actual resonator and the lumped-component model for the resonator. It also adds more points near the peak.\n", |
| 226 |
"\n", |
| 227 |
"The advantage is greatest if the resonance has poor shape, or if there are other modes nearby. Thus, a recommended workflow for optimal accuracy would be to:\n", |
| 228 |
"\n", |
| 229 |
"1. Set sweep parameters so the resonance is on the VNA screen\n", |
| 230 |
"2. Get Measurements\n", |
| 231 |
"3. Fit Q param to deduce $f_L$\n", |
| 232 |
"4. Set the Centre Freq to $f_L$ \n", |
| 233 |
"5. Set Span to $2f_L/Q_L$\n", |
| 234 |
"6. Get Measurements\n", |
| 235 |
"7. Fit Q param\n", |
| 236 |
"8. Calculate Unloaded Q\n", |
| 237 |
"\n", |
| 238 |
"So, for example:" |
| 239 |
] |
| 240 |
}, |
| 241 |
{ |
| 242 |
"cell_type": "code", |
| 243 |
"execution_count": null, |
| 244 |
"id": "2dc68e53", |
| 245 |
"metadata": {}, |
| 246 |
"outputs": [], |
| 247 |
"source": [ |
| 248 |
"# extracting the subfrequency range of interest from the data\n", |
| 249 |
"f_L = QF_72_2GHz.f_L\n", |
| 250 |
"Q_L = QF_72_2GHz.Q_L\n", |
| 251 |
"span = f_L/Q_L\n", |
| 252 |
"ntwk = Reson72[f'{f_L - span/2}-{f_L + span/2}Hz']" |
| 253 |
] |
| 254 |
}, |
| 255 |
{ |
| 256 |
"cell_type": "code", |
| 257 |
"execution_count": null, |
| 258 |
"id": "ce753704", |
| 259 |
"metadata": {}, |
| 260 |
"outputs": [], |
| 261 |
"source": [ |
| 262 |
"QF_72_2GHz_2 = rf.Qfactor(ntwk.s21, res_type='transmission')" |
| 263 |
] |
| 264 |
}, |
| 265 |
{ |
| 266 |
"cell_type": "code", |
| 267 |
"execution_count": null, |
| 268 |
"id": "42c028f8", |
| 269 |
"metadata": {}, |
| 270 |
"outputs": [], |
| 271 |
"source": [ |
| 272 |
"# After the second fit, the weighting ratio is close to 0.2 at the minimum and maximum frequencies\n", |
| 273 |
"# provided that the loop_plan contains ‘w’. (cf. [1] Fig. 6(b) and equation (28))\n", |
| 274 |
"QF_72_2GHz_2.fit()" |
| 275 |
] |
| 276 |
}, |
| 277 |
{ |
| 278 |
"cell_type": "code", |
| 279 |
"execution_count": null, |
| 280 |
"id": "53f9cc44", |
| 281 |
"metadata": {}, |
| 282 |
"outputs": [], |
| 283 |
"source": [ |
| 284 |
"QF_72_2GHz_2.Q_L # higher accury fit" |
| 285 |
] |
| 286 |
}, |
| 287 |
{ |
| 288 |
"cell_type": "markdown", |
| 289 |
"id": "365f559c", |
| 290 |
"metadata": {}, |
| 291 |
"source": [ |
| 292 |
"\n", |
| 293 |
"\n", |
| 294 |
" " |
| 295 |
] |
| 296 |
}, |
| 297 |
{ |
| 298 |
"cell_type": "markdown", |
| 299 |
"id": "ec60fb62", |
| 300 |
"metadata": {}, |
| 301 |
"source": [ |
| 302 |
"## Deducing Permittivity and Loss\n", |
| 303 |
"Equations for calculation Dk (aka $\\epsilon_r$) and Df (aka $\\tan \\delta$) from measured data for stripline resonators are given in [2]:\n", |
| 304 |
"\n", |
| 305 |
"$$\\epsilon_r = \\left[ \\frac{c n}{2 f_r (L + \\Delta L)} \\right]^2$$\n", |
| 306 |
"\n", |
| 307 |
"where:\n", |
| 308 |
"- $L$ is the length of resonator,\n", |
| 309 |
"- $n$ is the number of half wavelengths at resonance in resonator,\n", |
| 310 |
"- $f_r$ is the resonance frequency of resonator,\n", |
| 311 |
"- $c$ is the speed of light in vacuum,\n", |
| 312 |
"- $\\Delta L$ is the total effective increase in length of the resonant strip due to the fringing field at the ends of the resonant strip (neglected below for the example)\n", |
| 313 |
"\n", |
| 314 |
"and \n", |
| 315 |
"\n", |
| 316 |
"$$ \\tan \\delta = \\frac{1}{Q} - \\frac{1}{Q_c} $$\n", |
| 317 |
"\n", |
| 318 |
"where:\n", |
| 319 |
"- $Q_c$ is the Q-value associated with the copper loss: 250 at 2 GHz and 360 at 4 GHz according to IPC." |
| 320 |
] |
| 321 |
}, |
| 322 |
{ |
| 323 |
"cell_type": "markdown", |
| 324 |
"id": "50b26549", |
| 325 |
"metadata": {}, |
| 326 |
"source": [ |
| 327 |
"Hence, for the permittivity:" |
| 328 |
] |
| 329 |
}, |
| 330 |
{ |
| 331 |
"cell_type": "code", |
| 332 |
"execution_count": null, |
| 333 |
"id": "396cab77", |
| 334 |
"metadata": {}, |
| 335 |
"outputs": [], |
| 336 |
"source": [ |
| 337 |
"def Dk(f, L, n):\n", |
| 338 |
" \"Calculates Dk from resonator data. Eq.(1) of ref [1]\"\n", |
| 339 |
" return (n*rf.c/(2*f*L))**2" |
| 340 |
] |
| 341 |
}, |
| 342 |
{ |
| 343 |
"cell_type": "code", |
| 344 |
"execution_count": null, |
| 345 |
"id": "4de8e99c", |
| 346 |
"metadata": {}, |
| 347 |
"outputs": [], |
| 348 |
"source": [ |
| 349 |
"Dk(QF_72_2GHz.f_L, 72e-3, 2)" |
| 350 |
] |
| 351 |
}, |
| 352 |
{ |
| 353 |
"cell_type": "code", |
| 354 |
"execution_count": null, |
| 355 |
"id": "a3541406", |
| 356 |
"metadata": {}, |
| 357 |
"outputs": [], |
| 358 |
"source": [ |
| 359 |
"Dk(QF_72_2GHz.f_L, 144e-3, 4)" |
| 360 |
] |
| 361 |
}, |
| 362 |
{ |
| 363 |
"cell_type": "markdown", |
| 364 |
"id": "ab205dbe", |
| 365 |
"metadata": {}, |
| 366 |
"source": [ |
| 367 |
"And the loss tangent:" |
| 368 |
] |
| 369 |
}, |
| 370 |
{ |
| 371 |
"cell_type": "code", |
| 372 |
"execution_count": null, |
| 373 |
"id": "62c94424", |
| 374 |
"metadata": {}, |
| 375 |
"outputs": [], |
| 376 |
"source": [ |
| 377 |
"Qc = 250 # from IPC ref [1]\n", |
| 378 |
"print(1/QF_36_2GHz.Q_L - 1/Qc)" |
| 379 |
] |
| 380 |
}, |
| 381 |
{ |
| 382 |
"cell_type": "code", |
| 383 |
"execution_count": null, |
| 384 |
"id": "95609723", |
| 385 |
"metadata": {}, |
| 386 |
"outputs": [], |
| 387 |
"source": [ |
| 388 |
"Qc = 250 # from IPC ref [1]\n", |
| 389 |
"print(1/QF_144_2GHz.Q_L - 1/Qc)" |
| 390 |
] |
| 391 |
}, |
| 392 |
{ |
| 393 |
"cell_type": "code", |
| 394 |
"execution_count": null, |
| 395 |
"id": "498648e8", |
| 396 |
"metadata": {}, |
| 397 |
"outputs": [], |
| 398 |
"source": [ |
| 399 |
"Qc = 360 # from IPC\n", |
| 400 |
"print(1/QF_36_4GHz.Q_L - 1/Qc)" |
| 401 |
] |
| 402 |
}, |
| 403 |
{ |
| 404 |
"cell_type": "code", |
| 405 |
"execution_count": null, |
| 406 |
"id": "e2c1e19a", |
| 407 |
"metadata": {}, |
| 408 |
"outputs": [], |
| 409 |
"source": [ |
| 410 |
"Qc = 360 # from IPC\n", |
| 411 |
"print(1/QF_144_4GHz.Q_L - 1/Qc)" |
| 412 |
] |
| 413 |
}, |
| 414 |
{ |
| 415 |
"cell_type": "markdown", |
| 416 |
"id": "9952f148", |
| 417 |
"metadata": {}, |
| 418 |
"source": [ |
| 419 |
"## References\n", |
| 420 |
"- [1] A. P. Gregory, \"Q-factor Measurement by using a Vector Network Analyser\", National Physical Laboratory Report MAT 58 (2021), https://eprintspublications.npl.co.uk/9304/\n", |
| 421 |
"- [2] IPC-TM-650 TEST METHODS MANUAL, https://www.ipc.org/sites/default/files/test_methods_docs/2-5_2-5-5-5.pdf" |
| 422 |
] |
| 423 |
}, |
| 424 |
{ |
| 425 |
"cell_type": "code", |
| 426 |
"execution_count": null, |
| 427 |
"id": "869021ad", |
| 428 |
"metadata": {}, |
| 429 |
"outputs": [], |
| 430 |
"source": [] |
| 431 |
} |
| 432 |
], |
| 433 |
"metadata": { |
| 434 |
"kernelspec": { |
| 435 |
"display_name": "Python 3 (ipykernel)", |
| 436 |
"language": "python", |
| 437 |
"name": "python3" |
| 438 |
}, |
| 439 |
"language_info": { |
| 440 |
"codemirror_mode": { |
| 441 |
"name": "ipython", |
| 442 |
"version": 3 |
| 443 |
}, |
| 444 |
"file_extension": ".py", |
| 445 |
"mimetype": "text/x-python", |
| 446 |
"name": "python", |
| 447 |
"nbconvert_exporter": "python", |
| 448 |
"pygments_lexer": "ipython3", |
| 449 |
"version": "3.8.11" |
| 450 |
} |
| 451 |
}, |
| 452 |
"nbformat": 4, |
| 453 |
"nbformat_minor": 5 |
| 454 |
} |