.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/electrical_engineering/transmission_lines/plot_02_smith_chart.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_electrical_engineering_transmission_lines_plot_02_smith_chart.py: Smith's chart (1939) ==================== Phillip Hagar Smith, an engineer at Bell Labs, tired of evaluating the transmission-line equations with a slide rule. His 1939 chart plots the reflection coefficient :math:`\Gamma = (Z_L - Z_0)/(Z_L + Z_0)` (:func:`~engineeringkit.electrical_engineering.reflection_coefficient`) in the unit disc, overlaid with circles of constant normalised resistance and arcs of constant reactance. Moving along a lossless line just rotates :math:`\Gamma` around the centre, at constant standing-wave ratio (:func:`~engineeringkit.electrical_engineering.standing_wave_ratio`), so the input impedance (:func:`~engineeringkit.electrical_engineering.input_impedance`) can be read off the grid. This example uses the chart to design a single-stub match, drawn with :func:`~engineeringkit.electrical_engineering.visualizers.plot_smith_chart`. .. GENERATED FROM PYTHON SOURCE LINES 20-27 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from scipy.optimize import brentq from engineeringkit.electrical_engineering import input_impedance, reflection_coefficient, standing_wave_ratio from engineeringkit.electrical_engineering.visualizers import plot_smith_chart .. GENERATED FROM PYTHON SOURCE LINES 28-30 Moving along the line --------------------- .. GENERATED FROM PYTHON SOURCE LINES 30-39 .. code-block:: Python z0, zl = 50.0, 25.0 - 30.0j gamma_l = reflection_coefficient(zl, z0) print(f"load: Gamma = {abs(gamma_l):.3f} at {np.degrees(np.angle(gamma_l)):.1f} deg, VSWR = {standing_wave_ratio(gamma_l):.2f}") bl = np.linspace(0, np.pi, 361) # half a wavelength locus = reflection_coefficient(input_impedance(zl, z0, bl), z0) assert np.allclose(np.abs(locus), abs(gamma_l)) # a circle about the centre assert np.isclose(input_impedance(zl, z0, np.pi), zl) # half a wavelength repeats the load .. rst-class:: sphx-glr-script-out .. code-block:: none load: Gamma = 0.483 at -108.0 deg, VSWR = 2.87 .. GENERATED FROM PYTHON SOURCE LINES 40-46 A shorted shunt stub -------------------- Move toward the generator until the input conductance is :math:`1/Z_0` (the unit conductance circle), then cancel the remaining susceptance with a short-circuited stub in parallel. .. GENERATED FROM PYTHON SOURCE LINES 46-71 .. code-block:: Python def conductance_error(x): return (1 / input_impedance(zl, z0, x)).real - 1 / z0 error = conductance_error(bl) k = np.flatnonzero(np.sign(error[:-1]) != np.sign(error[1:]))[0] # first crossing of the circle d = brentq(conductance_error, bl[k], bl[k + 1]) b = (1 / input_impedance(zl, z0, d)).imag stub = brentq(lambda x: (1 / input_impedance(0, z0, x)).imag + b, 0.01, np.pi / 2 - 1e-9) y_total = 1 / input_impedance(zl, z0, d) + 1 / input_impedance(0, z0, stub) print(f"stub at {d / (2 * np.pi):.4f} wavelengths from the load, stub length {stub / (2 * np.pi):.4f} wavelengths") print(f"matched input impedance {1 / y_total:.4f} ohm") assert abs(reflection_coefficient(1 / y_total, z0)) < 1e-9 ax = plot_smith_chart(locus, label="along the line") ax.plot(gamma_l.real, gamma_l.imag, "ks", label="load") g_d = reflection_coefficient(input_impedance(zl, z0, d), z0) ax.plot(g_d.real, g_d.imag, "C3o", label="stub position") ax.plot(0, 0, "C2*", ms=12, label="matched") ax.legend(loc="upper left", fontsize="small") ax.set_title("Single-stub match on the Smith chart") plt.show() .. image-sg:: /api/gallery/electrical_engineering/transmission_lines/images/sphx_glr_plot_02_smith_chart_001.png :alt: Single-stub match on the Smith chart :srcset: /api/gallery/electrical_engineering/transmission_lines/images/sphx_glr_plot_02_smith_chart_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none stub at 0.0151 wavelengths from the load, stub length 0.1171 wavelengths matched input impedance 50.0000-0.0000j ohm .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.019 seconds) .. _sphx_glr_download_api_gallery_electrical_engineering_transmission_lines_plot_02_smith_chart.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/electrical_engineering/transmission_lines/plot_02_smith_chart.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_smith_chart.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_smith_chart.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_smith_chart.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_