
:html_theme.sidebar_secondary.remove:

.. py:currentmodule:: cantera


.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/python/thermo/critical_properties.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_python_thermo_critical_properties.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_python_thermo_critical_properties.py:


Critical state properties
=========================

Print the critical state properties for the fluids for which Cantera has
built-in liquid/vapor equations of state.

.. tags:: Python, thermodynamics, multiphase, non-ideal fluid

.. GENERATED FROM PYTHON SOURCE LINES 10-14

.. code-block:: Python


    import cantera as ct
    import matplotlib.pyplot as plt








.. GENERATED FROM PYTHON SOURCE LINES 15-16

Create `PureFluid` objects:

.. GENERATED FROM PYTHON SOURCE LINES 16-26

.. code-block:: Python

    fluids = {'water': ct.Water(),
              'nitrogen': ct.Nitrogen(),
              'methane': ct.Methane(),
              'hydrogen': ct.Hydrogen(),
              'oxygen': ct.Oxygen(),
              'carbon dioxide': ct.CarbonDioxide(),
              'heptane': ct.Heptane(),
              'HFC-134a': ct.Hfc134a()
              }








.. GENERATED FROM PYTHON SOURCE LINES 27-28

Plot critical properties and print tabulated values:

.. GENERATED FROM PYTHON SOURCE LINES 28-48

.. code-block:: Python

    fig, ax = plt.subplots()

    print('Critical State Properties')
    print(f"{'Fluid':^16s}   {'Tc [K]':^7s}   {'Pc [Pa]':^10s}   {'Zc':^7s}")
    print(f"{'-'*16}   {'-'*7}   {'-'*10}   {'-'*7}")
    for name in fluids:
        f = fluids[name]
        tc = f.critical_temperature
        pc = f.critical_pressure
        rc = f.critical_density
        mw = f.mean_molecular_weight
        zc = pc * mw / (rc * ct.gas_constant * tc)
        ax.plot(tc, pc, 'o')
        ax.annotate(name, (tc, pc), (4, 2), textcoords='offset points', size=9)
        print(f'{name:16s}   {tc:7.2f}   {pc:10.4g}   {zc:7.4f}')

    ax.set(xlabel='Critical Temperature [K]', ylabel='Critical Pressure [Pa]')
    ax.set(xlim=(0, 750))
    ax.grid(True)
    plt.show()



.. image-sg:: /examples/python/thermo/images/sphx_glr_critical_properties_001.png
   :alt: critical properties
   :srcset: /examples/python/thermo/images/sphx_glr_critical_properties_001.png, /examples/python/thermo/images/sphx_glr_critical_properties_001_2_00x.png 2.00x
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Critical State Properties
         Fluid         Tc [K]     Pc [Pa]       Zc   
    ----------------   -------   ----------   -------
    water               647.29    2.209e+07    0.2333
    nitrogen            126.20      3.4e+06    0.2891
    methane             190.56    4.599e+06    0.2904
    hydrogen             32.94    1.284e+06    0.3013
    oxygen              154.58    5.043e+06    0.2879
    carbon dioxide      304.21    7.384e+06    0.2769
    heptane             537.68     2.62e+06    0.2972
    HFC-134a            374.21    4.059e+06    0.2600





.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.537 seconds)


.. _sphx_glr_download_examples_python_thermo_critical_properties.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: critical_properties.ipynb <critical_properties.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: critical_properties.py <critical_properties.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: critical_properties.zip <critical_properties.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
