.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/electrical_engineering/networks/plot_02_thevenin_equivalent.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_networks_plot_02_thevenin_equivalent.py: Thévenin's equivalent circuit (1883) ==================================== Léon Charles Thévenin, an engineer of the French telegraph service, showed in 1883 that any linear network seen from two terminals behaves like a single EMF in series with a single resistance (Hermann von Helmholtz had reached the same result in 1853). The EMF is the open-circuit voltage; the resistance is that voltage divided by the short-circuit current, or the resistance seen with every source zeroed. This example reduces a two-source network with :func:`~engineeringkit.electrical_engineering.nodal_analysis`, builds the equivalent with :func:`~engineeringkit.electrical_engineering.thevenin_from_source`, and checks that the two agree for every load. .. GENERATED FROM PYTHON SOURCE LINES 18-23 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.electrical_engineering import nodal_analysis, thevenin_from_source .. GENERATED FROM PYTHON SOURCE LINES 24-29 The network and its terminals ----------------------------- A 10 V source and a 5 mA source feed a resistive network; the load is connected between node 3 and ground. .. GENERATED FROM PYTHON SOURCE LINES 29-46 .. code-block:: Python network = [(1, 2, 2e3), (2, 0, 3e3), (2, 3, 1e3)] vsrc, isrc = [(1, 0, 10.0)], [(0, 3, 5e-3)] def solve(load=None): resistors = network + ([] if load is None else [(3, 0, load)]) return nodal_analysis(3, resistors, current_sources=isrc, voltage_sources=vsrc) v_open = solve().voltages[3] i_short = solve(1e-6).voltages[3] / 1e-6 # a 1 µohm load is a short vth, rth = thevenin_from_source(v_open, v_open / i_short) # The same resistance with both sources zeroed: 1 k + (2 k || 3 k). assert np.isclose(rth, 1e3 + 2e3 * 3e3 / 5e3, rtol=1e-6) print(f"V_th = {vth:.3f} V, R_th = {rth:.1f} ohm") .. rst-class:: sphx-glr-script-out .. code-block:: none V_th = 17.000 V, R_th = 2200.0 ohm .. GENERATED FROM PYTHON SOURCE LINES 47-49 Any load sees the same thing ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 49-62 .. code-block:: Python loads = np.logspace(1, 5, 25) v_network = np.array([solve(r).voltages[3] for r in loads]) v_thevenin = vth * loads / (rth + loads) assert np.allclose(v_network, v_thevenin, rtol=1e-6) fig, ax = plt.subplots() ax.semilogx(loads, v_network, "o", label="full network") ax.semilogx(loads, v_thevenin, label="Thévenin equivalent") ax.set(xlabel="load resistance [ohm]", ylabel="terminal voltage [V]", title="Thévenin's theorem") ax.legend() plt.show() .. image-sg:: /api/gallery/electrical_engineering/networks/images/sphx_glr_plot_02_thevenin_equivalent_001.png :alt: Thévenin's theorem :srcset: /api/gallery/electrical_engineering/networks/images/sphx_glr_plot_02_thevenin_equivalent_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.038 seconds) .. _sphx_glr_download_api_gallery_electrical_engineering_networks_plot_02_thevenin_equivalent.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/networks/plot_02_thevenin_equivalent.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_thevenin_equivalent.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_thevenin_equivalent.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_thevenin_equivalent.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_