
: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/kinetics/diamond_cvd.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_kinetics_diamond_cvd.py>`
        to download the full example code.

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

.. _sphx_glr_examples_python_kinetics_diamond_cvd.py:


Growth of diamond film using CVD
================================

This example computes the growth rate of a diamond film according to a simplified
version of a particular published growth mechanism (see
:doc:`diamond.yaml <../../input/diamond>` for details). Only the surface coverage
equations are solved here; the gas composition is fixed. (For an example of coupled
gas-phase and surface, see
:doc:`catalytic_combustion.py <../onedim/catalytic_combustion>`.) Atomic hydrogen plays
an important role in diamond CVD, and this example computes the growth rate and surface
coverages as a function of [H] at the surface for fixed temperature and [CH3].

Requires: cantera >= 2.6.0, pandas >= 0.25.0, matplotlib >= 2.0

.. tags:: Python, surface chemistry, kinetics

.. GENERATED FROM PYTHON SOURCE LINES 18-24

.. code-block:: Python


    import csv
    import matplotlib.pyplot as plt
    import pandas as pd
    import cantera as ct








.. GENERATED FROM PYTHON SOURCE LINES 25-26

Import the model for the diamond (100) surface and the adjacent bulk phases

.. GENERATED FROM PYTHON SOURCE LINES 26-41

.. code-block:: Python

    d = ct.Interface("diamond.yaml", "diamond_100")
    g = d.adjacent["gas"]
    dbulk = d.adjacent["diamond"]

    mw = dbulk.molecular_weights[0]

    t = 1200.0
    x = g.X
    p = 20.0 * ct.one_atm / 760.0  # 20 Torr
    g.TP = t, p

    ih = g.species_index('H')

    xh0 = x[ih]








.. GENERATED FROM PYTHON SOURCE LINES 42-43

Calculate growth rate as a function of H mole fraction in the gas

.. GENERATED FROM PYTHON SOURCE LINES 43-62

.. code-block:: Python

    with open('diamond.csv', 'w', newline='') as f:
        writer = csv.writer(f)
        writer.writerow(['H mole Fraction', 'Growth Rate (microns/hour)'] +
                        d.species_names)

        iC = d.kinetics_species_index('C(d)')

        for n in range(20):
            x[ih] /= 1.4
            g.TPX = t, p, x
            d.advance_coverages(10.0)  # integrate the coverages to steady state
            carbon_dot = d.net_production_rates[iC]
            mdot = mw * carbon_dot
            rate = mdot / dbulk.density
            writer.writerow([x[ih], rate * 1.0e6 * 3600.0] + list(d.coverages))

        print('H concentration, growth rate, and surface coverages '
              'written to file diamond.csv')





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

 .. code-block:: none

    H concentration, growth rate, and surface coverages written to file diamond.csv




.. GENERATED FROM PYTHON SOURCE LINES 63-64

Plot the results

.. GENERATED FROM PYTHON SOURCE LINES 64-71

.. code-block:: Python

    data = pd.read_csv('diamond.csv')

    data.plot(x="H mole Fraction", y="Growth Rate (microns/hour)", legend=False)
    plt.xlabel('H Mole Fraction')
    plt.ylabel('Growth Rate (microns/hr)')
    plt.show()




.. image-sg:: /examples/python/kinetics/images/sphx_glr_diamond_cvd_001.png
   :alt: diamond cvd
   :srcset: /examples/python/kinetics/images/sphx_glr_diamond_cvd_001.png, /examples/python/kinetics/images/sphx_glr_diamond_cvd_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 72-77

.. code-block:: Python

    names = [name for name in data.columns if not name.startswith(('H mole', 'Growth'))]
    data.plot(x='H mole Fraction', y=names, legend=True)
    plt.xlabel('H Mole Fraction')
    plt.ylabel('Coverage')
    plt.show()



.. image-sg:: /examples/python/kinetics/images/sphx_glr_diamond_cvd_002.png
   :alt: diamond cvd
   :srcset: /examples/python/kinetics/images/sphx_glr_diamond_cvd_002.png, /examples/python/kinetics/images/sphx_glr_diamond_cvd_002_2_00x.png 2.00x
   :class: sphx-glr-single-img






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

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


.. _sphx_glr_download_examples_python_kinetics_diamond_cvd.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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