.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/thermodynamics/plot_thermodynamics_benchmark.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_thermodynamics_plot_thermodynamics_benchmark.py: Carnot engine and heat-pump limits ================================== A reversible heat pump delivers absorbed heat plus supplied work. Consequently its COP exceeds refrigerator COP by one. The temperature difference must remain positive and absolute temperatures are used. .. GENERATED FROM PYTHON SOURCE LINES 9-32 .. image-sg:: /api/gallery/thermodynamics/images/sphx_glr_plot_thermodynamics_benchmark_001.png :alt: plot thermodynamics benchmark :srcset: /api/gallery/thermodynamics/images/sphx_glr_plot_thermodynamics_benchmark_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.thermodynamics import carnot_cop_heat_pump, carnot_cop_refrigerator, carnot_efficiency Tc = 280 Th = np.linspace(281, 450, 201) engine = np.array([carnot_efficiency(t, Tc) for t in Th]) pump = np.array([carnot_cop_heat_pump(t, Tc) for t in Th]) fridge = np.array([carnot_cop_refrigerator(t, Tc) for t in Th]) np.testing.assert_allclose(pump - fridge, 1) assert np.isclose(carnot_efficiency(560, Tc), 0.5) fig, axes = plt.subplots(1, 2, figsize=(9, 3)) axes[0].plot(Th, engine) axes[0].set(xlabel="hot reservoir [K]", ylabel="engine efficiency") axes[1].plot(Th, pump, label="heat pump") axes[1].plot(Th, fridge, label="refrigerator") axes[1].set(xlabel="hot reservoir [K]", ylabel="reversible COP", ylim=(0, 30)) axes[1].legend() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.175 seconds) .. _sphx_glr_download_api_gallery_thermodynamics_plot_thermodynamics_benchmark.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/thermodynamics/plot_thermodynamics_benchmark.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_thermodynamics_benchmark.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_thermodynamics_benchmark.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_thermodynamics_benchmark.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_