.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/solutions/acid_base/plot_06_bjerrum_speciation_diagram.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_solutions_acid_base_plot_06_bjerrum_speciation_diagram.py: Bjerrum's speciation diagrams for polyprotic acids ==================================================== Niels Bjerrum's 1914 monograph on acid-base titrations introduced diagrams showing what fraction of a polyprotic acid is present in each protonation state as a function of pH -- today called Bjerrum plots or distribution diagrams. The fractions (:func:`~chemistrykit.solutions.systems.acid_base.polyprotic_fractions`) depend only on pH and the stepwise :math:`K_a` values, and adjacent species are equally abundant exactly where :math:`\mathrm{pH} = pK_j`. .. GENERATED FROM PYTHON SOURCE LINES 15-40 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.solutions.systems.acid_base import polyprotic_fractions pH = np.linspace(0, 14, 500) systems = { "carbonic acid": ([6.35, 10.33], ["H$_2$CO$_3$", "HCO$_3^-$", "CO$_3^{2-}$"]), "phosphoric acid": ([2.15, 7.20, 12.35], ["H$_3$PO$_4$", "H$_2$PO$_4^-$", "HPO$_4^{2-}$", "PO$_4^{3-}$"]), } fig, axes = plt.subplots(1, 2, figsize=(12, 4.5)) for ax, (name, (pKas, labels)) in zip(axes, systems.items()): alpha = polyprotic_fractions(pH, [10.0**-pK for pK in pKas]) for row, label in zip(alpha, labels): ax.plot(pH, row, label=label) for pK in pKas: ax.axvline(pK, color="gray", linestyle=":", linewidth=0.8) ax.set_xlabel("pH") ax.set_ylabel(r"fraction $\alpha_j$") ax.set_title(f"Bjerrum plot: {name}") ax.legend(fontsize=8) fig.tight_layout() .. image-sg:: /api/gallery/solutions/acid_base/images/sphx_glr_plot_06_bjerrum_speciation_diagram_001.png :alt: Bjerrum plot: carbonic acid, Bjerrum plot: phosphoric acid :srcset: /api/gallery/solutions/acid_base/images/sphx_glr_plot_06_bjerrum_speciation_diagram_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 41-43 At blood pH 7.4, dissolved inorganic carbon is overwhelmingly bicarbonate -- the basis of the bicarbonate blood buffer: .. GENERATED FROM PYTHON SOURCE LINES 43-48 .. code-block:: Python alpha_blood = polyprotic_fractions(7.4, [10**-6.35, 10**-10.33])[:, 0] print("pH 7.4 carbonate speciation: " + ", ".join(f"{a:.4f}" for a in alpha_blood)) plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none pH 7.4 carbonate speciation: 0.0817, 0.9172, 0.0011 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.078 seconds) .. _sphx_glr_download_api_gallery_solutions_acid_base_plot_06_bjerrum_speciation_diagram.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_06_bjerrum_speciation_diagram.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_06_bjerrum_speciation_diagram.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_06_bjerrum_speciation_diagram.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_