.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/thermo/mixtures/plot_02_henry_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_mixtures_plot_02_henry_law.py: Henry's law: the dilute-solute limit of a real solution ======================================================= Henry's law, :math:`P_B = x_B K_H` (:func:`~chemistrykit.thermo.systems.mixtures.henry_law_pressure`), says the vapor pressure of a dilute solute (equivalently, the amount of a gas that dissolves at a given pressure) is proportional to its mole fraction, with an empirical constant :math:`K_H` that differs from the pure solute's vapor pressure. Below, an illustrative real solute's partial pressure follows the Henry's-law line at high dilution and leaves it as the solute becomes concentrated, where Raoult's law (:func:`~chemistrykit.thermo.systems.mixtures.raoult_vapor_pressure`) takes over. .. GENERATED FROM PYTHON SOURCE LINES 18-48 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.thermo.systems.mixtures import henry_law_pressure, raoult_vapor_pressure P_B_star = 40.0 # kPa, pure-B vapor pressure K_H = 120.0 # kPa, Henry's law constant (slope at infinite dilution) x_B = np.linspace(0.0, 1.0, 200) # The quadratic that starts with slope K_H at x_B = 0 and reaches P_B* at x_B = 1. P_B_real = x_B * (K_H + (P_B_star - K_H) * x_B) fig, axes = plt.subplots(1, 2, figsize=(12, 4.8)) axes[0].plot(x_B, P_B_real, color="black", linewidth=2, label="real (illustrative) partial pressure") axes[0].plot(x_B, henry_law_pressure(x_B, K_H), "--", color="darkorange", label=r"Henry's law ($x_B K_H$)") axes[0].plot(x_B, raoult_vapor_pressure(x_B, P_B_star), ":", color="steelblue", label=r"Raoult's law ($x_B P_B^*$)") axes[0].set_ylim(0, 60) axes[0].set_xlabel("mole fraction of solute B") axes[0].set_ylabel("partial pressure of B (kPa)") axes[0].set_title("Henry's law holds for the dilute solute") axes[0].legend() x_dilute = np.linspace(1e-4, 0.1, 100) error = (henry_law_pressure(x_dilute, K_H) - x_dilute * (K_H + (P_B_star - K_H) * x_dilute)) / (x_dilute * (K_H + (P_B_star - K_H) * x_dilute)) axes[1].plot(x_dilute, 100 * error, color="darkorange") axes[1].set_xlabel("mole fraction of solute B") axes[1].set_ylabel("Henry's-law error (%)") axes[1].set_title("The error vanishes as the solution becomes dilute") fig.tight_layout() .. image-sg:: /api/gallery/thermo/mixtures/images/sphx_glr_plot_02_henry_law_001.png :alt: Henry's law holds for the dilute solute, The error vanishes as the solution becomes dilute :srcset: /api/gallery/thermo/mixtures/images/sphx_glr_plot_02_henry_law_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 49-52 Read the other way, Henry's law gives the solubility of a gas: the dissolved mole fraction is :math:`x_B = P_B/K_H`, doubling when the gas pressure above the liquid doubles. .. GENERATED FROM PYTHON SOURCE LINES 52-57 .. code-block:: Python for P in (1.0, 2.0, 4.0): print(f"P_B = {P:4.1f} kPa -> dissolved x_B = {P / K_H:.4f}") plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none P_B = 1.0 kPa -> dissolved x_B = 0.0083 P_B = 2.0 kPa -> dissolved x_B = 0.0167 P_B = 4.0 kPa -> dissolved x_B = 0.0333 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.073 seconds) .. _sphx_glr_download_api_gallery_thermo_mixtures_plot_02_henry_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_02_henry_law.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_henry_law.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_henry_law.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_