.. 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_01_heaviside_telegrapher.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_01_heaviside_telegrapher.py: Heaviside's telegrapher's equations and the distortionless line (1876-1887) =========================================================================== Kelvin's cable theory ignored inductance. Oliver Heaviside, a self-taught former telegraph operator, kept all four line constants: series resistance :math:`R` and inductance :math:`L`, shunt conductance :math:`G` and capacitance :math:`C` per metre. In 1876 he wrote the telegrapher's equations, whose sinusoidal waves decay and travel according to :math:`\gamma = \sqrt{(R + j\omega L)(G + j\omega C)}` (:func:`~engineeringkit.electrical_engineering.propagation_constant`). In 1887 he found that if :math:`R/L = G/C` (:func:`~engineeringkit.electrical_engineering.distortionless_condition`), every frequency is attenuated equally and travels at the same speed, so a signal arrives weaker but undistorted. Real cables have far too little inductance; Pupin's and Campbell's loading coils (1899-1900) added it and made long-distance telephony possible. This example compares a cable with and without enough inductance. .. GENERATED FROM PYTHON SOURCE LINES 22-27 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.electrical_engineering import distortionless_condition, propagation_constant, transmission_line_velocity .. GENERATED FROM PYTHON SOURCE LINES 28-30 Attenuation and velocity against frequency ------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 30-51 .. code-block:: Python R, G, C = 0.05, 1e-7, 50e-12 # ohm/m, S/m, F/m L_cable = 0.6e-6 # H/m, an unloaded cable L_loaded = R * C / G # Heaviside's condition assert not distortionless_condition(R, L_cable, G, C) assert distortionless_condition(R, L_loaded, G, C) print(f"inductance needed for a distortionless line: {L_loaded * 1e6:.0f} µH/m ({L_loaded / L_cable:.0f}x the cable's)") f = np.logspace(1, 4, 200) fig, axes = plt.subplots(1, 3, figsize=(13, 3.6)) for L, name in ((L_cable, "unloaded"), (L_loaded, "distortionless")): gamma = propagation_constant(R, L, G, C, 2 * np.pi * f) axes[0].semilogx(f, gamma.real * 1e3 * 8.686, label=name) axes[1].semilogx(f, 2 * np.pi * f / gamma.imag / 1e6, label=name) gamma = propagation_constant(R, L_loaded, G, C, 2 * np.pi * f) assert np.allclose(gamma.real, np.sqrt(R * G)) assert np.allclose(2 * np.pi * f / gamma.imag, transmission_line_velocity(L_loaded, C)) axes[0].set(xlabel="frequency [Hz]", ylabel="attenuation [dB/km]", title="Attenuation") axes[1].set(xlabel="frequency [Hz]", ylabel="phase velocity [km/ms]", title="Velocity") axes[0].legend() .. image-sg:: /api/gallery/electrical_engineering/transmission_lines/images/sphx_glr_plot_01_heaviside_telegrapher_001.png :alt: Attenuation, Velocity :srcset: /api/gallery/electrical_engineering/transmission_lines/images/sphx_glr_plot_01_heaviside_telegrapher_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none inductance needed for a distortionless line: 25 µH/m (42x the cable's) .. GENERATED FROM PYTHON SOURCE LINES 52-57 A pulse down 20 km of line -------------------------- The line is terminated in its characteristic impedance, so the received spectrum is the sent spectrum times :math:`e^{-\gamma\ell}`. .. GENERATED FROM PYTHON SOURCE LINES 57-76 .. code-block:: Python length, fs, n = 20e3, 1e6, 2**14 t = np.arange(n) / fs pulse = np.exp(-0.5 * ((t - 1e-3) / 1e-4) ** 2) w = 2 * np.pi * np.fft.rfftfreq(n, 1 / fs) for L, name in ((L_cable, "unloaded"), (L_loaded, "distortionless")): gamma = np.concatenate(([np.sqrt(R * G)], propagation_constant(R, L, G, C, w[1:]))) received = np.fft.irfft(np.fft.rfft(pulse) * np.exp(-gamma * length), n) axes[2].plot(t * 1e3, received / received.max(), label=name) delay = length / transmission_line_velocity(L_loaded, C) expected = np.exp(-np.sqrt(R * G) * length) * np.interp(t - delay, t, pulse) print(f"distortionless delay {delay * 1e3:.3f} ms, amplitude {np.exp(-np.sqrt(R * G) * length):.3f}") assert np.allclose(received, expected, atol=1e-6) axes[2].plot(t * 1e3, pulse, ":", color="gray", label="sent") axes[2].set(xlim=(0, 4), xlabel="time [ms]", ylabel="normalised voltage", title="Received pulse shape") axes[2].legend() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none distortionless delay 0.707 ms, amplitude 0.243 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.090 seconds) .. _sphx_glr_download_api_gallery_electrical_engineering_transmission_lines_plot_01_heaviside_telegrapher.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_01_heaviside_telegrapher.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_heaviside_telegrapher.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_heaviside_telegrapher.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_heaviside_telegrapher.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_