| 1 |
{ |
| 2 |
"cells": [ |
| 3 |
{ |
| 4 |
"cell_type": "markdown", |
| 5 |
"metadata": {}, |
| 6 |
"source": [ |
| 7 |
"# How does the SWR vary along a line?\n", |
| 8 |
"Let's assume a 10 MHz source powering an antenna (of load $Z_L$) through a transmission line of length $L$. Depending on the location of the SWR-meter, what does one would read? \n", |
| 9 |
"\n", |
| 10 |
"This notebook is inspired from the reference: [\"Facts About SWR, Reflected Power, and Power Transfer on Real Transmission Lines with Loss\"](https://www.fars.k6ya.org/docs/Facts-about-SWR-and-Loss.pdf) by Steve Stearns given at ARRL Pacificon Antenna Seminar in 2010.\n", |
| 11 |
"\n", |
| 12 |
"<img src=\"Impedance_matching_4.svg\">\n" |
| 13 |
] |
| 14 |
}, |
| 15 |
{ |
| 16 |
"cell_type": "markdown", |
| 17 |
"metadata": {}, |
| 18 |
"source": [ |
| 19 |
"Let solve this question using `scikit-rf`. But first, the traditional Python imports:" |
| 20 |
] |
| 21 |
}, |
| 22 |
{ |
| 23 |
"cell_type": "code", |
| 24 |
"execution_count": null, |
| 25 |
"metadata": {}, |
| 26 |
"outputs": [], |
| 27 |
"source": [ |
| 28 |
"%matplotlib inline" |
| 29 |
] |
| 30 |
}, |
| 31 |
{ |
| 32 |
"cell_type": "code", |
| 33 |
"execution_count": null, |
| 34 |
"metadata": {}, |
| 35 |
"outputs": [], |
| 36 |
"source": [ |
| 37 |
"import matplotlib.pyplot as plt\n", |
| 38 |
"import numpy as np\n", |
| 39 |
"\n", |
| 40 |
"import skrf as rf" |
| 41 |
] |
| 42 |
}, |
| 43 |
{ |
| 44 |
"cell_type": "code", |
| 45 |
"execution_count": null, |
| 46 |
"metadata": {}, |
| 47 |
"outputs": [], |
| 48 |
"source": [ |
| 49 |
"rf.stylely()" |
| 50 |
] |
| 51 |
}, |
| 52 |
{ |
| 53 |
"cell_type": "markdown", |
| 54 |
"metadata": {}, |
| 55 |
"source": [ |
| 56 |
"## Lossless lines\n", |
| 57 |
"Let's start with a lossless line of propagation constant $\\gamma=j\\beta$ and characteristic impedance $z_0=50\\Omega$ (real). " |
| 58 |
] |
| 59 |
}, |
| 60 |
{ |
| 61 |
"cell_type": "code", |
| 62 |
"execution_count": null, |
| 63 |
"metadata": {}, |
| 64 |
"outputs": [], |
| 65 |
"source": [ |
| 66 |
"freq = rf.Frequency(10, unit='MHz', npoints=1)" |
| 67 |
] |
| 68 |
}, |
| 69 |
{ |
| 70 |
"cell_type": "code", |
| 71 |
"execution_count": null, |
| 72 |
"metadata": {}, |
| 73 |
"outputs": [], |
| 74 |
"source": [ |
| 75 |
"# load and line properties\n", |
| 76 |
"Z_L = 75 # Ohm\n", |
| 77 |
"Z_0 = 50 # Ohm\n", |
| 78 |
"L = 50 # m\n", |
| 79 |
"\n", |
| 80 |
"# propagation constant\n", |
| 81 |
"beta = freq.w/rf.c\n", |
| 82 |
"gamma = 1j*beta" |
| 83 |
] |
| 84 |
}, |
| 85 |
{ |
| 86 |
"cell_type": "markdown", |
| 87 |
"metadata": {}, |
| 88 |
"source": [ |
| 89 |
"Below we calculate the SWR of the line as a function of $z$ the line length measured from the load ($z=0$ at the load, $z=L$ at the source). " |
| 90 |
] |
| 91 |
}, |
| 92 |
{ |
| 93 |
"cell_type": "code", |
| 94 |
"execution_count": null, |
| 95 |
"metadata": {}, |
| 96 |
"outputs": [], |
| 97 |
"source": [ |
| 98 |
"z = np.linspace(start=L, stop=0, num=301)\n", |
| 99 |
"SWRs = rf.zl_2_swr(z0=Z_0, zl=rf.zl_2_zin(Z_0, Z_L, gamma*z))" |
| 100 |
] |
| 101 |
}, |
| 102 |
{ |
| 103 |
"cell_type": "code", |
| 104 |
"execution_count": null, |
| 105 |
"metadata": {}, |
| 106 |
"outputs": [], |
| 107 |
"source": [ |
| 108 |
"fig, ax = plt.subplots()\n", |
| 109 |
"ax.plot(z, SWRs, lw=2)\n", |
| 110 |
"ax.set_xlabel('z [m]')\n", |
| 111 |
"ax.set_ylabel('SWR')\n", |
| 112 |
"ax.set_title('SWR along the (lossless) line')\n", |
| 113 |
"ax.invert_xaxis()\n", |
| 114 |
"ax.axvline(0, lw=8, color='k')\n", |
| 115 |
"ax.axvline(L, lw=8, color='k')\n", |
| 116 |
"ax.annotate('Load', xy=(0, 1.55), xytext=(10, 1.575),\n", |
| 117 |
" arrowprops=dict(facecolor='black', shrink=0.05),\n", |
| 118 |
" )\n", |
| 119 |
"ax.annotate('Source', xy=(50, 1.55), xytext=(40, 1.575),\n", |
| 120 |
" arrowprops=dict(facecolor='black', shrink=0.05),\n", |
| 121 |
" )" |
| 122 |
] |
| 123 |
}, |
| 124 |
{ |
| 125 |
"cell_type": "markdown", |
| 126 |
"metadata": {}, |
| 127 |
"source": [ |
| 128 |
"As expected, the SWR is the same everywhere along the line as the forward and backward wave amplitudes are also the same along the line. " |
| 129 |
] |
| 130 |
}, |
| 131 |
{ |
| 132 |
"cell_type": "markdown", |
| 133 |
"metadata": {}, |
| 134 |
"source": [ |
| 135 |
"## Lossy Lines\n", |
| 136 |
"Let's take the previous example but this time on a lossy line. The line is defined with a propagation constant $\\gamma=\\alpha + j\\beta$ :" |
| 137 |
] |
| 138 |
}, |
| 139 |
{ |
| 140 |
"cell_type": "code", |
| 141 |
"execution_count": null, |
| 142 |
"metadata": {}, |
| 143 |
"outputs": [], |
| 144 |
"source": [ |
| 145 |
"alpha = 0.01 # Np/m. Here a dummy value, just for the sake of the example\n", |
| 146 |
"gamma = alpha + 1j*beta" |
| 147 |
] |
| 148 |
}, |
| 149 |
{ |
| 150 |
"cell_type": "code", |
| 151 |
"execution_count": null, |
| 152 |
"metadata": {}, |
| 153 |
"outputs": [], |
| 154 |
"source": [ |
| 155 |
"z = np.linspace(0, L, num=101)\n", |
| 156 |
"SWRs = rf.zl_2_swr(z0=Z_0, zl=rf.zl_2_zin(Z_0, Z_L, gamma*z))" |
| 157 |
] |
| 158 |
}, |
| 159 |
{ |
| 160 |
"cell_type": "code", |
| 161 |
"execution_count": null, |
| 162 |
"metadata": {}, |
| 163 |
"outputs": [], |
| 164 |
"source": [ |
| 165 |
"fig, ax = plt.subplots()\n", |
| 166 |
"ax.plot(z, SWRs, lw=2)\n", |
| 167 |
"ax.set_xlabel('z [m]')\n", |
| 168 |
"ax.set_ylabel('SWR')\n", |
| 169 |
"ax.set_title('SWR along the (lossy) line')\n", |
| 170 |
"ax.invert_xaxis()\n", |
| 171 |
"ax.axvline(0, lw=8, color='k')\n", |
| 172 |
"ax.axvline(L, lw=8, color='k')\n", |
| 173 |
"ax.annotate('Load', xy=(0, 1.15), xytext=(10, 1.2),\n", |
| 174 |
" arrowprops=dict(facecolor='black', shrink=0.05),\n", |
| 175 |
" )\n", |
| 176 |
"ax.annotate('Source', xy=(50, 1.4), xytext=(40, 1.5),\n", |
| 177 |
" arrowprops=dict(facecolor='black', shrink=0.05),\n", |
| 178 |
" )" |
| 179 |
] |
| 180 |
}, |
| 181 |
{ |
| 182 |
"cell_type": "markdown", |
| 183 |
"metadata": {}, |
| 184 |
"source": [ |
| 185 |
"For a lossy line, the SWR is maximum at the load and decreases to be minimum at the source side. \n", |
| 186 |
"\n", |
| 187 |
"Let's see how the impedance varies along the line:" |
| 188 |
] |
| 189 |
}, |
| 190 |
{ |
| 191 |
"cell_type": "code", |
| 192 |
"execution_count": null, |
| 193 |
"metadata": {}, |
| 194 |
"outputs": [], |
| 195 |
"source": [ |
| 196 |
"Zins = rf.zl_2_zin(Z_0, Z_L, gamma*z)\n", |
| 197 |
"\n", |
| 198 |
"fig, ax = plt.subplots()\n", |
| 199 |
"ax.plot(z, np.abs(Zins/Z_0), lw=2, label='$Z/z_0$')\n", |
| 200 |
"ax.plot(z, SWRs, lw=2, ls='--', label=r'$SWR$')\n", |
| 201 |
"ax.plot(z, 1/SWRs, lw=2, ls='--', label=r'$1/SWR$')\n", |
| 202 |
"\n", |
| 203 |
"ax.set_xlabel('z [m]')\n", |
| 204 |
"ax.set_ylabel('Z (normalized to $z_0$)')\n", |
| 205 |
"ax.set_title('Impedance along the line')\n", |
| 206 |
"ax.invert_xaxis()\n", |
| 207 |
"ax.axvline(0, lw=8, color='k')\n", |
| 208 |
"ax.axvline(L, lw=8, color='k')\n", |
| 209 |
"ax.annotate('Load', xy=(0, 1.2), xytext=(10, 1.275),\n", |
| 210 |
" arrowprops=dict(facecolor='black', shrink=0.05),\n", |
| 211 |
" )\n", |
| 212 |
"ax.annotate('Source', xy=(50, 0.6), xytext=(40, 0.7),\n", |
| 213 |
" arrowprops=dict(facecolor='black', shrink=0.05),\n", |
| 214 |
" )\n", |
| 215 |
"ax.legend()" |
| 216 |
] |
| 217 |
}, |
| 218 |
{ |
| 219 |
"cell_type": "markdown", |
| 220 |
"metadata": {}, |
| 221 |
"source": [ |
| 222 |
"The previous result is due to the fact that voltages and currents vary along the transmission line:" |
| 223 |
] |
| 224 |
}, |
| 225 |
{ |
| 226 |
"cell_type": "code", |
| 227 |
"execution_count": null, |
| 228 |
"metadata": {}, |
| 229 |
"outputs": [], |
| 230 |
"source": [ |
| 231 |
"V_s = 1\n", |
| 232 |
"Z_in = rf.zl_2_zin(Z_0, Z_L, gamma*z)\n", |
| 233 |
"# Z_s = Z_0\n", |
| 234 |
"V_in = V_s * Z_in/(Z_0 + Z_in)\n", |
| 235 |
"I_in = V_in/(Z_0 + Z_in)\n", |
| 236 |
"# note that here we are going from source to load\n", |
| 237 |
"V, I = rf.voltage_current_propagation(V_in, I_in, Z_0, gamma*z)" |
| 238 |
] |
| 239 |
}, |
| 240 |
{ |
| 241 |
"cell_type": "code", |
| 242 |
"execution_count": null, |
| 243 |
"metadata": {}, |
| 244 |
"outputs": [], |
| 245 |
"source": [ |
| 246 |
"fig, ax = plt.subplots(2,1,sharex=True)\n", |
| 247 |
"ax[0].plot(z, np.abs(V), lw=2)\n", |
| 248 |
"ax[1].plot(z, np.abs(I), lw=2, color='C1')\n", |
| 249 |
"ax[1].set_xlabel('z [m]')\n", |
| 250 |
"ax[0].set_ylabel('|V| (V)')\n", |
| 251 |
"ax[1].set_ylabel('|I| (A)')\n", |
| 252 |
"ax[0].set_title('Voltage')\n", |
| 253 |
"ax[1].set_title('Current')\n", |
| 254 |
"[a.axvline(0, lw=8, color='k') for a in ax]\n", |
| 255 |
"[a.axvline(L, lw=8, color='k') for a in ax]\n", |
| 256 |
"ax[1].annotate('Load', xy=(50, 0.0075), xytext=(40, 0.0075),\n", |
| 257 |
" arrowprops=dict(facecolor='black', shrink=0.05))\n", |
| 258 |
"ax[1].annotate('Source', xy=(0, 0.001), xytext=(10, 0.001),\n", |
| 259 |
" arrowprops=dict(facecolor='black', shrink=0.05))" |
| 260 |
] |
| 261 |
} |
| 262 |
], |
| 263 |
"metadata": { |
| 264 |
"kernelspec": { |
| 265 |
"display_name": "Python 3", |
| 266 |
"language": "python", |
| 267 |
"name": "python3" |
| 268 |
}, |
| 269 |
"language_info": { |
| 270 |
"codemirror_mode": { |
| 271 |
"name": "ipython", |
| 272 |
"version": 3 |
| 273 |
}, |
| 274 |
"file_extension": ".py", |
| 275 |
"mimetype": "text/x-python", |
| 276 |
"name": "python", |
| 277 |
"nbconvert_exporter": "python", |
| 278 |
"pygments_lexer": "ipython3", |
| 279 |
"version": "3.7.8" |
| 280 |
} |
| 281 |
}, |
| 282 |
"nbformat": 4, |
| 283 |
"nbformat_minor": 2 |
| 284 |
} |