.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/thermodynamics/laws/plot_01_joule_first_law.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_laws_plot_01_joule_first_law.py: Joule and the first law (1843-1850) =================================== James Prescott Joule spent the 1840s showing that a given amount of work, however it is done, always produces the same amount of heat. In his best known experiment (published 1850) falling weights turned a paddle wheel in an insulated can of water, and he measured the temperature rise to a hundredth of a degree. His result, 772 foot-pounds per British thermal unit, made heat and work two forms of one conserved quantity, energy: :math:`Q = \Delta U + W` (:func:`~engineeringkit.thermodynamics.first_law_heat`). The example redoes the paddle-wheel balance, converts Joule's number to SI, and checks the ideal-gas energy functions. .. GENERATED FROM PYTHON SOURCE LINES 18-23 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.thermodynamics import first_law_heat, specific_enthalpy_ideal_gas, specific_internal_energy_ideal_gas .. GENERATED FROM PYTHON SOURCE LINES 24-31 The paddle wheel ---------------- The can is insulated, so :math:`Q = 0`, and the weights do work *on* the water, :math:`W = -mgh` per drop. The first law gives :math:`\Delta U = -W`, and with :math:`c = 4186` J/(kg K) the rise in temperature. The weights and drop height here are illustrative. .. GENERATED FROM PYTHON SOURCE LINES 31-46 .. code-block:: Python g, c_water = 9.80665, 4186.0 m_weights, drop, n_drops, m_water = 2 * 13.0, 1.6, 20, 6.0 work_on_water = m_weights * g * drop * n_drops delta_u = work_on_water delta_T = delta_u / (m_water * c_water) print(f"work on the water {work_on_water:.0f} J, temperature rise {delta_T:.3f} K") assert first_law_heat(delta_u, -work_on_water) == 0 drops = np.arange(n_drops + 1) fig, ax = plt.subplots(figsize=(6, 3.2)) ax.plot(drops, 15.0 + drops * m_weights * g * drop / (m_water * c_water), "o-") ax.set(xlabel="number of drops", ylabel="water temperature [°C]", title="An adiabatic paddle wheel") fig.tight_layout() .. image-sg:: /api/gallery/thermodynamics/laws/images/sphx_glr_plot_01_joule_first_law_001.png :alt: An adiabatic paddle wheel :srcset: /api/gallery/thermodynamics/laws/images/sphx_glr_plot_01_joule_first_law_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none work on the water 8159 J, temperature rise 0.325 K .. GENERATED FROM PYTHON SOURCE LINES 47-52 Joule's mechanical equivalent of heat ------------------------------------- 772.692 foot-pounds raised one pound of water by one degree Fahrenheit. In SI that is joules per calorie (one gram, one kelvin): .. GENERATED FROM PYTHON SOURCE LINES 52-58 .. code-block:: Python ft_lbf, lb, degF = 1.3558179483, 0.45359237, 5 / 9 J_per_cal = 772.692 * ft_lbf / (lb * 1e3 * degF) print(f"Joule 1850: {J_per_cal:.3f} J/cal; the thermochemical calorie is defined as 4.184 J") assert abs(J_per_cal - 4.184) / 4.184 < 0.01 .. rst-class:: sphx-glr-script-out .. code-block:: none Joule 1850: 4.157 J/cal; the thermochemical calorie is defined as 4.184 J .. GENERATED FROM PYTHON SOURCE LINES 59-66 Energy functions of an ideal gas -------------------------------- Joule's free-expansion experiment (1845) found no temperature change when a gas expanded into a vacuum, so the internal energy of an ideal gas depends on temperature alone. Enthalpy :math:`h = u + pv = u + RT` follows, and :math:`c_p - c_v = R`. .. GENERATED FROM PYTHON SOURCE LINES 66-74 .. code-block:: Python R, cv, cp, T = 287.0, 718.0, 1005.0, np.linspace(250, 1500, 6) u = specific_internal_energy_ideal_gas(T, cv) h = specific_enthalpy_ideal_gas(T, cp) np.testing.assert_allclose(h - u, R * T) print(f"h - u at 300 K: {specific_enthalpy_ideal_gas(300, cp) - specific_internal_energy_ideal_gas(300, cv):.0f} J/kg = R T") plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none h - u at 300 K: 86100 J/kg = R T .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.047 seconds) .. _sphx_glr_download_api_gallery_thermodynamics_laws_plot_01_joule_first_law.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/laws/plot_01_joule_first_law.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_joule_first_law.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_joule_first_law.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_joule_first_law.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_