.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/materials/diffusion/plot_01_fick_carburizing.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 or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_materials_diffusion_plot_01_fick_carburizing.py: Fick's laws of diffusion (1855) =============================== Adolf Fick, a 26-year-old prosector in anatomy at Zürich, took Fourier's law of heat conduction and applied it to salt dissolving in water: the flux is proportional to the concentration gradient, :math:`J = -D\,\partial C/\partial x` (:func:`~engineeringkit.materials.fick_flux`), and conservation gives the second law :math:`\partial C/\partial t = D\,\partial^2 C/\partial x^2`. Into a thick steel part whose surface is held at a carbon content :math:`C_s`, the second law gives the error-function profile (:func:`~engineeringkit.materials.semi_infinite_concentration`) that times every carburizing furnace. The example computes the case depth of a gear and the furnace time it needs. .. GENERATED FROM PYTHON SOURCE LINES 19-24 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.materials import diffusion_coefficient, diffusion_time, fick_flux, semi_infinite_concentration .. GENERATED FROM PYTHON SOURCE LINES 25-30 Steady flux through a plate --------------------------- Fick's first law: carbon at 1.2 and 0.8 kg/m^3 at depths 5 and 10 mm in an iron plate with :math:`D = 3\times10^{-11}` m^2/s. .. GENERATED FROM PYTHON SOURCE LINES 30-35 .. code-block:: Python J = fick_flux(3e-11, (0.8 - 1.2) / (10e-3 - 5e-3)) print(f"flux {J:.2e} kg/(m^2 s)") assert np.isclose(J, 2.4e-9) .. rst-class:: sphx-glr-script-out .. code-block:: none flux 2.40e-09 kg/(m^2 s) .. GENERATED FROM PYTHON SOURCE LINES 36-43 Carburizing a gear ------------------ Carbon diffuses in austenite with :math:`D_0 = 2.3\times10^{-5}` m^2/s and :math:`Q_d = 148` kJ/mol. A 0.25 wt% C steel in a 1.2 wt% atmosphere must reach 0.80 wt% at 0.5 mm. Doubling the depth takes four times as long, because time enters only through :math:`x/\sqrt{Dt}`. .. GENERATED FROM PYTHON SOURCE LINES 43-64 .. code-block:: Python C0, Cs, target, depth = 0.25, 1.20, 0.80, 0.5e-3 for T in (900.0, 950.0, 1000.0): D = diffusion_coefficient(2.3e-5, 148e3, T + 273.15) t = diffusion_time(depth, target, D, C0, Cs) print(f"{T:.0f} C: D = {D:.2e} m^2/s, {t / 3600:.1f} h") D = diffusion_coefficient(2.3e-5, 148e3, 950 + 273.15) t = diffusion_time(depth, target, D, C0, Cs) assert np.isclose(diffusion_time(2 * depth, target, D, C0, Cs), 4 * t) x = np.linspace(0, 2e-3, 200) fig, ax = plt.subplots(figsize=(6, 3.8)) for hours in (1, 4, 16): ax.plot(1e3 * x, semi_infinite_concentration(x, hours * 3600, D, C0, Cs), label=f"{hours} h") ax.plot(1e3 * depth, target, "ko", label=f"0.80% at 0.5 mm, {t / 3600:.1f} h") ax.set(xlabel="depth [mm]", ylabel="carbon [wt%]", title="Carburizing at 950 C") ax.legend() fig.tight_layout() assert np.isclose(semi_infinite_concentration(depth, t, D, C0, Cs), target) plt.show() .. image-sg:: /api/gallery/materials/diffusion/images/sphx_glr_plot_01_fick_carburizing_001.png :alt: Carburizing at 950 C :srcset: /api/gallery/materials/diffusion/images/sphx_glr_plot_01_fick_carburizing_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 900 C: D = 5.92e-12 m^2/s, 19.1 h 950 C: D = 1.10e-11 m^2/s, 10.2 h 1000 C: D = 1.95e-11 m^2/s, 5.8 h .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.068 seconds) .. _sphx_glr_download_api_gallery_materials_diffusion_plot_01_fick_carburizing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/materials/diffusion/plot_01_fick_carburizing.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_fick_carburizing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_fick_carburizing.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_fick_carburizing.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_