.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/crystal/crystal_systems/plot_03_hauy_rational_indices.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_crystal_crystal_systems_plot_03_hauy_rational_indices.py: Hauy's law of rational indices: Miller indices from face intercepts ==================================================================== Hauy (1784-1801) argued that every natural crystal face cuts the three axes at intercepts in small whole-number ratios. :func:`~chemistrykit.crystal.systems.crystal_systems.miller_indices_from_intercepts` turns those rational intercepts into the integer Miller indices :math:`(hkl)` by taking reciprocals and clearing fractions; the :math:`(hkl)` triple then fixes each face's interplanar spacing. .. GENERATED FROM PYTHON SOURCE LINES 14-35 .. code-block:: Python import math import matplotlib.pyplot as plt import numpy as np from chemistrykit.crystal.systems.crystal_systems import miller_indices_from_intercepts from chemistrykit.crystal.systems.xrd import d_spacing_cubic faces = { "cube face": (1, math.inf, math.inf), "dodecahedron face": (1, 1, math.inf), "octahedron face": (1, 1, 1), "intercepts 1, 2, 3": (1, 2, 3), "intercepts 1/2, 1, inf": (0.5, 1, math.inf), "intercepts 2, 3, 6": (2, 3, 6), } a = 5.64 # NaCl, Angstrom for name, intercepts in faces.items(): hkl = miller_indices_from_intercepts(*intercepts) print(f"{name:24s} intercepts={str(intercepts):22s} -> (hkl)={hkl} d={d_spacing_cubic(a, *hkl):.3f} A") .. rst-class:: sphx-glr-script-out .. code-block:: none cube face intercepts=(1, inf, inf) -> (hkl)=(1, 0, 0) d=5.640 A dodecahedron face intercepts=(1, 1, inf) -> (hkl)=(1, 1, 0) d=3.988 A octahedron face intercepts=(1, 1, 1) -> (hkl)=(1, 1, 1) d=3.256 A intercepts 1, 2, 3 intercepts=(1, 2, 3) -> (hkl)=(6, 3, 2) d=0.806 A intercepts 1/2, 1, inf intercepts=(0.5, 1, inf) -> (hkl)=(2, 1, 0) d=2.522 A intercepts 2, 3, 6 intercepts=(2, 3, 6) -> (hkl)=(3, 2, 1) d=1.507 A .. GENERATED FROM PYTHON SOURCE LINES 36-38 The intercept ratios are rational, so the reciprocals clear to small integers: intercepts (2, 3, 6) give reciprocals (1/2, 1/3, 1/6) = (3, 2, 1)/6. .. GENERATED FROM PYTHON SOURCE LINES 38-40 .. code-block:: Python assert miller_indices_from_intercepts(2, 3, 6) == (3, 2, 1) .. GENERATED FROM PYTHON SOURCE LINES 41-42 Draw a few faces as planes cutting the unit cube at their intercepts. .. GENERATED FROM PYTHON SOURCE LINES 42-67 .. code-block:: Python fig = plt.figure(figsize=(9, 3.5)) for i, (hkl, color) in enumerate((((1, 0, 0), "C0"), ((1, 1, 0), "C1"), ((1, 1, 1), "C2"))): ax = fig.add_subplot(1, 3, i + 1, projection="3d") for s, e in [((0, 0, 0), (1, 0, 0)), ((0, 0, 0), (0, 1, 0)), ((0, 0, 0), (0, 0, 1))]: ax.plot(*zip(s, e, strict=True), "k-", lw=0.8) h, k, l = hkl g = np.linspace(0, 1, 2) if l != 0: # the (111) face is the triangle through the three unit intercepts ax.plot_trisurf(np.array([1, 0, 0]), np.array([0, 1, 0]), np.array([0, 0, 1]), color=color, alpha=0.5) elif k != 0: X, Z = np.meshgrid(g, g) ax.plot_surface(X, (1 - h * X) / k, Z, color=color, alpha=0.5) else: Y, Z = np.meshgrid(g, g) ax.plot_surface(np.ones_like(Y) / h, Y, Z, color=color, alpha=0.5) ax.set_title(f"({h}{k}{l})") ax.set_xlim(0, 1) ax.set_ylim(0, 1) ax.set_zlim(0, 1) ax.set_xlabel("a") ax.set_ylabel("b") ax.set_zlabel("c") plt.tight_layout() plt.show() .. image-sg:: /api/gallery/crystal/crystal_systems/images/sphx_glr_plot_03_hauy_rational_indices_001.png :alt: (100), (110), (111) :srcset: /api/gallery/crystal/crystal_systems/images/sphx_glr_plot_03_hauy_rational_indices_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.087 seconds) .. _sphx_glr_download_api_gallery_crystal_crystal_systems_plot_03_hauy_rational_indices.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_hauy_rational_indices.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_hauy_rational_indices.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_hauy_rational_indices.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_