.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/thermodynamics/cycles/plot_10_diesel_dual_cycle.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_cycles_plot_10_diesel_dual_cycle.py: Diesel's cycle and the dual cycle (1893) ======================================== Diesel's ideal engine burns its fuel at constant pressure. Real high-speed diesels burn part of the charge almost at once, at nearly constant volume, and the rest as the piston moves. The dual (limited-pressure) cycle models this with both heat additions (:func:`~engineeringkit.thermodynamics.dual_efficiency`). It contains Otto's cycle (no constant-pressure part) and Diesel's (no constant-volume part) as its limits. .. GENERATED FROM PYTHON SOURCE LINES 15-21 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.thermodynamics import diesel_efficiency, dual_efficiency, isentropic_pressure_volume, otto_efficiency from engineeringkit.thermodynamics.visualizers import plot_pv_diagram .. GENERATED FROM PYTHON SOURCE LINES 22-27 Four states of a dual cycle --------------------------- Compression ratio 16, pressure ratio 1.5 at constant volume, then cutoff ratio 1.4 at constant pressure, air with :math:`\gamma = 1.4`. .. GENERATED FROM PYTHON SOURCE LINES 27-50 .. code-block:: Python r, alpha, rc, g, T1, p1 = 16.0, 1.5, 1.4, 1.4, 300.0, 100e3 T2 = T1 * r ** (g - 1) Tx, T3 = alpha * T2, alpha * T2 * rc T4 = T3 * (rc / r) ** (g - 1) eta_states = 1 - (T4 - T1) / ((Tx - T2) + g * (T3 - Tx)) print(f"T2 = {T2:.0f} K, Tx = {Tx:.0f} K, T3 = {T3:.0f} K, T4 = {T4:.0f} K") print(f"efficiency from the states {eta_states:.4f}, from the formula {dual_efficiency(r, alpha, rc):.4f}") assert np.isclose(eta_states, dual_efficiency(r, alpha, rc)) assert np.isclose(dual_efficiency(r, 1.0, rc), diesel_efficiency(r, rc)) and np.isclose(dual_efficiency(r, alpha, 1.0), otto_efficiency(r)) v1 = 1.0 v2 = v1 / r v3 = rc * v2 compression = np.linspace(v1, v2, 40) expansion = np.linspace(v3, v1, 40) p2 = p1 * r**g p3 = alpha * p2 v = np.r_[compression, v2, v3, expansion] p = np.r_[isentropic_pressure_volume(p1, v1, compression, g), p3, p3, isentropic_pressure_volume(p3, v3, expansion, g)] ax = plot_pv_diagram(np.r_[v, v1], np.r_[p, p1], label="dual cycle") ax.set(xlabel="volume / initial volume", title="Dual cycle, r = 16") .. image-sg:: /api/gallery/thermodynamics/cycles/images/sphx_glr_plot_10_diesel_dual_cycle_001.png :alt: Dual cycle, r = 16 :srcset: /api/gallery/thermodynamics/cycles/images/sphx_glr_plot_10_diesel_dual_cycle_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none T2 = 909 K, Tx = 1364 K, T3 = 1910 K, T4 = 721 K efficiency from the states 0.6547, from the formula 0.6547 [Text(0.5, 23.633333333333333, 'volume / initial volume'), Text(0.5, 1.0, 'Dual cycle, r = 16')] .. GENERATED FROM PYTHON SOURCE LINES 51-57 The same heat in different ways ------------------------------- For a fixed compression ratio and heat input, adding more of the heat at constant volume raises the efficiency: Otto beats dual beats Diesel. Diesel engines win in practice because they can run at twice the compression ratio. .. GENERATED FROM PYTHON SOURCE LINES 57-71 .. code-block:: Python alphas = np.linspace(1.0, 2.5, 31) fig, ax = plt.subplots(figsize=(6, 3.5)) heat = (alpha - 1) + g * alpha * (rc - 1) # the example's heat input, in units of cv T2 cutoffs = 1 + (heat - (alphas - 1)) / (g * alphas) valid = cutoffs >= 1 ax.plot(alphas[valid], dual_efficiency(r, alphas[valid], cutoffs[valid]), label="dual, same heat input") ax.axhline(otto_efficiency(r), color="gray", ls=":", label="Otto") ax.set(xlabel="constant-volume pressure ratio α", ylabel="efficiency", title="Splitting the heat addition, r = 16") ax.legend() fig.tight_layout() assert np.all(np.diff(dual_efficiency(r, alphas[valid], cutoffs[valid])) > 0) plt.show() .. image-sg:: /api/gallery/thermodynamics/cycles/images/sphx_glr_plot_10_diesel_dual_cycle_002.png :alt: Splitting the heat addition, r = 16 :srcset: /api/gallery/thermodynamics/cycles/images/sphx_glr_plot_10_diesel_dual_cycle_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.107 seconds) .. _sphx_glr_download_api_gallery_thermodynamics_cycles_plot_10_diesel_dual_cycle.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/cycles/plot_10_diesel_dual_cycle.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_10_diesel_dual_cycle.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_10_diesel_dual_cycle.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_10_diesel_dual_cycle.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_