.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/statmech/maxwell_boltzmann/plot_01_maxwell_boltzmann.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_statmech_maxwell_boltzmann_plot_01_maxwell_boltzmann.py: The Maxwell-Boltzmann speed distribution =========================================== :class:`~chemistrykit.statmech.MaxwellBoltzmannSpeedDistribution` at two temperatures, with the most-probable, mean, and rms speeds marked -- their ratios are a fixed, temperature-independent property of the distribution's shape. .. GENERATED FROM PYTHON SOURCE LINES 12-32 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.statmech import MaxwellBoltzmannSpeedDistribution mass = 6.63e-26 # argon-like, kg fig, ax = plt.subplots(figsize=(7, 5)) for T, color in [(200.0, "steelblue"), (800.0, "crimson")]: dist = MaxwellBoltzmannSpeedDistribution(mass=mass, temperature=T) v = np.linspace(0.0, 2500.0, 400) ax.plot(v, dist.pdf(v), color=color, label=f"T = {T:.0f} K") ax.axvline(dist.most_probable_speed(), color=color, linestyle=":", linewidth=0.8) ax.set_xlabel("speed (m/s)") ax.set_ylabel("probability density") ax.set_title("Maxwell-Boltzmann speed distribution at two temperatures") ax.legend() fig.tight_layout() .. image-sg:: /api/gallery/statmech/maxwell_boltzmann/images/sphx_glr_plot_01_maxwell_boltzmann_001.png :alt: Maxwell-Boltzmann speed distribution at two temperatures :srcset: /api/gallery/statmech/maxwell_boltzmann/images/sphx_glr_plot_01_maxwell_boltzmann_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 33-36 The three characteristic speeds stand in a fixed ratio, independent of temperature or mass -- a purely geometric property of the distribution's shape: .. GENERATED FROM PYTHON SOURCE LINES 36-43 .. code-block:: Python dist = MaxwellBoltzmannSpeedDistribution(mass=mass, temperature=298.15) vp, vbar, vrms = dist.most_probable_speed(), dist.mean_speed(), dist.rms_speed() print(f"v_p : v_bar : v_rms = 1 : {vbar / vp:.4f} : {vrms / vp:.4f}") print(f"expected = 1 : {np.sqrt(8.0 / np.pi) / np.sqrt(2.0):.4f} : {np.sqrt(3.0) / np.sqrt(2.0):.4f}") plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none v_p : v_bar : v_rms = 1 : 1.1284 : 1.2247 expected = 1 : 1.1284 : 1.2247 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.040 seconds) .. _sphx_glr_download_api_gallery_statmech_maxwell_boltzmann_plot_01_maxwell_boltzmann.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_maxwell_boltzmann.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_maxwell_boltzmann.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_maxwell_boltzmann.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_