.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/thermo/equations_of_state/plot_01_ideal_gas_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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_thermo_equations_of_state_plot_01_ideal_gas_law.py: Clapeyron's ideal gas law, PV = RT ================================== Clapeyron's 1834 combined gas law unites Boyle's law (:math:`PV` constant at fixed :math:`T`), Charles's and Gay-Lussac's law (:math:`V \propto T` at fixed :math:`P`), and Avogadro's hypothesis into :math:`PV_m = RT`. This example draws both classic views with :class:`~chemistrykit.thermo.systems.equations_of_state.IdealGas`: hyperbolic Boyle isotherms, and straight Charles isobars that all extrapolate to zero volume at absolute zero. .. GENERATED FROM PYTHON SOURCE LINES 15-42 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.thermo.systems.equations_of_state import IdealGas gas = IdealGas() fig, axes = plt.subplots(1, 2, figsize=(11, 4.5)) Vm = np.linspace(0.005, 0.05, 300) # m^3/mol for T in [200.0, 300.0, 400.0, 500.0]: axes[0].plot(Vm * 1000.0, gas.pressure(Vm, T) / 1000.0, label=f"T = {T:.0f} K") axes[0].set_xlabel(r"$V_m$ (L/mol)") axes[0].set_ylabel("P (kPa)") axes[0].set_title("Boyle isotherms: P proportional to 1/V") axes[0].legend() T = np.linspace(0.0, 500.0, 200) for P in [50e3, 101325.0, 200e3]: axes[1].plot(T - 273.15, gas.molar_volume(P, np.maximum(T, 1e-9)) * 1000.0, label=f"P = {P / 1000:.0f} kPa") axes[1].axvline(-273.15, color="gray", linestyle=":") axes[1].set_xlabel("t (degC)") axes[1].set_ylabel(r"$V_m$ (L/mol)") axes[1].set_title("Charles isobars: V extrapolates to 0 at -273.15 degC") axes[1].legend() fig.tight_layout() .. image-sg:: /api/gallery/thermo/equations_of_state/images/sphx_glr_plot_01_ideal_gas_law_001.png :alt: Boyle isotherms: P proportional to 1/V, Charles isobars: V extrapolates to 0 at -273.15 degC :srcset: /api/gallery/thermo/equations_of_state/images/sphx_glr_plot_01_ideal_gas_law_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 43-46 The same law gives the textbook molar volume at 0 degC and 1 atm, and the product :math:`PV_m` along any isotherm is the constant :math:`RT`: .. GENERATED FROM PYTHON SOURCE LINES 46-52 .. code-block:: Python print(f"Vm(273.15 K, 101325 Pa) = {gas.molar_volume(101325.0, 273.15) * 1000.0:.3f} L/mol") PV = gas.pressure(Vm, 300.0) * Vm print(f"PV_m along the 300 K isotherm: min {PV.min():.3f}, max {PV.max():.3f} J/mol (= RT = {gas.R * 300.0:.3f})") plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none Vm(273.15 K, 101325 Pa) = 22.414 L/mol PV_m along the 300 K isotherm: min 2494.339, max 2494.339 J/mol (= RT = 2494.339) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.071 seconds) .. _sphx_glr_download_api_gallery_thermo_equations_of_state_plot_01_ideal_gas_law.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_ideal_gas_law.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_ideal_gas_law.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_ideal_gas_law.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_