Diffraction beams, electron Bloch waves, and phonon dispersion curves are described not in direct space but in reciprocal space (), where an entire infinite family of parallel atomic planes collapses to a single vector normal to the planes with length . Instead of memorizing separate interplanar-spacing formulas for cubic, tetragonal, hexagonal, and triclinic crystals, a single three-line linear-algebra relation handles every crystal system universally.
Learning objectives¶
Construct the dual reciprocal basis (
lattices.reciprocal_lattice) and verify biorthogonality .Verify the universal Brillouin-zone volume invariant across cubic and hexagonal crystals.
Evaluate Miller interplanar spacings (
lattices.interplanar_spacing) for orthogonal cubic (Cu) and non-orthogonal hexagonal (Ti,Mg) lattices.Rank close-packed slip planes and visualize direct vs. reciprocal hexagonal lattices and the 2-D Wigner–Seitz first Brillouin zone.
Time: about 60 min
try: # use the installed package, or the copy in this repository
import engmaterials
except ImportError:
import pathlib, subprocess, sys
for _root in [pathlib.Path.cwd(), *pathlib.Path.cwd().parents]:
if (_root / "engmaterials" / "__init__.py").exists():
sys.path.insert(0, str(_root))
break
else: # on Google Colab: install from GitHub
subprocess.run([sys.executable, "-m", "pip", "install", "-q",
"git+https://github.com/ktwyw/engmaterials.git"], check=True)
import engmaterials
import inspect
import numpy as np
import matplotlib.pyplot as plt
from engmaterials import (atomistics, constants, diffraction, elasticity, kinetics_selection,
lattices, phase_field, phase_thermodynamics)
from engmaterials.plotting import label_panels, panel_label, use_style
use_style()
def show_source(obj):
"""Return the source code of a library function or class."""
return inspect.getsource(obj)
def heading(text):
print(f"\n{text}\n" + "=" * len(text))1. Principles and governing equations¶
1.1 Dual Reciprocal Basis & Biorthogonality¶
For any direct lattice matrix (rows ), the reciprocal lattice (rows in ) is defined by the plane-wave periodicity condition :
Taking determinants on both sides of yields the universal first Brillouin-zone volume invariant:
and the reciprocal metric tensor satisfies .
heading("Demonstration 1: Biorthogonality A @ B.T = 2*pi*I and Brillouin-Zone Volume Invariant")
two_pi_cubed = (2.0 * np.pi) ** 3
print(f"{'Crystal':10s} | {'V_cell [A^3]':>13s} | {'V_BZ [A^-3]':>13s} | {'V * V_BZ':>12s} | {'||AB^T - 2pi I||':>16s}")
print("-" * 74)
for sym in ["Cu", "Fe", "Si", "Ti", "Mg"]:
meta = constants.ELEMENTS_DB[sym]
cell = lattices.build_unit_cell(meta["structure"], meta["a_A"], meta["c_A"])
mt = lattices.metric_tensor(cell["lattice_vectors"])
rec = lattices.reciprocal_lattice(cell["lattice_vectors"])
biorth_err = float(np.max(np.abs(cell["lattice_vectors"] @ rec["reciprocal_vectors"].T - 2.0 * np.pi * np.eye(3))))
prod_vol = mt["volume_A3"] * rec["brillouin_zone_volume"]
print(f"{sym + ' (' + meta['structure'] + ')':10s} | {mt['volume_A3']:13.5f} | {rec['brillouin_zone_volume']:13.5f} | {prod_vol:12.6f} | {biorth_err:16.2e}")
assert biorth_err < 1e-13
assert np.isclose(prod_vol, two_pi_cubed, rtol=1e-13)
assert np.allclose(rec["reciprocal_metric"], (2.0 * np.pi) ** 2 * mt["G_inv"], rtol=1e-13)
Demonstration 1: Biorthogonality A @ B.T = 2*pi*I and Brillouin-Zone Volume Invariant
=====================================================================================
Crystal | V_cell [A^3] | V_BZ [A^-3] | V * V_BZ | ||AB^T - 2pi I||
--------------------------------------------------------------------------
Cu (fcc) | 47.23771 | 5.25111 | 248.050213 | 0.00e+00
Fe (bcc) | 23.55352 | 10.53134 | 248.050213 | 8.88e-16
Si (diamond) | 160.18263 | 1.54855 | 248.050213 | 8.88e-16
Ti (hcp) | 35.33183 | 7.02059 | 248.050213 | 8.88e-16
Mg (hcp) | 46.48178 | 5.33650 | 248.050213 | 1.54e-16
What Demonstration 1 shows. Large real-space unit cells (Si, ) compress into tiny Brillouin zones (), whereas compact BCC Fe () expands in reciprocal space (), always preserving to 14 digits.
2. Miller Planes & Universal Interplanar Spacing ¶
Every reciprocal lattice vector is strictly perpendicular to the Miller plane family, and its norm determines the perpendicular plane spacing:
heading("Demonstration 2: Universal Reciprocal Interplanar Spacing vs Analytical Cubic & Hexagonal Formulas")
cu_a = constants.ELEMENTS_DB["Cu"]["a_A"]
cu_lat = lattices.cubic_unit_cell("fcc", cu_a)["lattice_vectors"]
for hkl in [(1, 0, 0), (1, 1, 0), (1, 1, 1), (2, 2, 0), (3, 1, 1)]:
d_rec = lattices.interplanar_spacing(hkl, cu_lat)
d_cub = cu_a / np.sqrt(hkl[0] ** 2 + hkl[1] ** 2 + hkl[2] ** 2)
print(f"Cu {str(hkl):10s} | d_reciprocal = {d_rec:.6f} A | d_cubic_formula = {d_cub:.6f} A")
assert np.isclose(d_rec, d_cub, rtol=1e-14)
ti_a, ti_c = constants.ELEMENTS_DB["Ti"]["a_A"], constants.ELEMENTS_DB["Ti"]["c_A"]
ti_lat = lattices.hcp_unit_cell(ti_a, ti_c)["lattice_vectors"]
print("")
for hkl in [(1, 0, 0), (0, 0, 2), (1, 0, 1), (1, 1, 0), (1, 0, 2)]:
h, k, m_l = hkl
d_rec = lattices.interplanar_spacing(hkl, ti_lat)
inv_d2_hex = (4.0 / 3.0) * (h ** 2 + h * k + k ** 2) / (ti_a ** 2) + (m_l ** 2) / (ti_c ** 2)
d_hex = 1.0 / np.sqrt(inv_d2_hex)
print(f"Ti {str(hkl):10s} | d_reciprocal = {d_rec:.6f} A | d_hex_formula = {d_hex:.6f} A")
assert np.isclose(d_rec, d_hex, rtol=1e-14)
Demonstration 2: Universal Reciprocal Interplanar Spacing vs Analytical Cubic & Hexagonal Formulas
==================================================================================================
Cu (1, 0, 0) | d_reciprocal = 3.614900 A | d_cubic_formula = 3.614900 A
Cu (1, 1, 0) | d_reciprocal = 2.556120 A | d_cubic_formula = 2.556120 A
Cu (1, 1, 1) | d_reciprocal = 2.087063 A | d_cubic_formula = 2.087063 A
Cu (2, 2, 0) | d_reciprocal = 1.278060 A | d_cubic_formula = 1.278060 A
Cu (3, 1, 1) | d_reciprocal = 1.089933 A | d_cubic_formula = 1.089933 A
Ti (1, 0, 0) | d_reciprocal = 2.555468 A | d_hex_formula = 2.555468 A
Ti (0, 0, 2) | d_reciprocal = 2.342750 A | d_hex_formula = 2.342750 A
Ti (1, 0, 1) | d_reciprocal = 2.243486 A | d_hex_formula = 2.243486 A
Ti (1, 1, 0) | d_reciprocal = 1.475400 A | d_hex_formula = 1.475400 A
Ti (1, 0, 2) | d_reciprocal = 1.726888 A | d_hex_formula = 1.726888 A
What Demonstration 2 shows. lattices.interplanar_spacing needs zero crystal-system if/else branches, computing automatically reproduces both the cubic formula and the hexagonal formula to rounding error.
3. Slip-Plane Spacing Comparison (Cu vs. Ti) & 2-D Hexagonal Brillouin Zone¶
In dislocation mechanics (Peierls–Nabarro theory, Lecture 8), slip preferentially occurs on planes with the widest interplanar spacing . We compare plane spacings in Cu vs. Ti and visualize how the direct hexagonal lattice dualizes into a reciprocal lattice whose Wigner–Seitz cell is the regular hexagonal first Brillouin zone (with , , and symmetry points, as in graphene and -Ti).
heading("Demonstration 3: Slip-Plane Ranking (Cu vs Ti) & 2-D Hexagonal Reciprocal / Brillouin Zone Plot")
ti_rec = lattices.reciprocal_lattice(ti_lat)["reciprocal_vectors"]
b1_2d, b2_2d = ti_rec[0, :2], ti_rec[1, :2]
cos_gamma_star = np.dot(b1_2d, b2_2d) / (np.linalg.norm(b1_2d) * np.linalg.norm(b2_2d))
gamma_star_deg = float(np.degrees(np.arccos(cos_gamma_star)))
print(f"Direct basal angle gamma = 120.0 deg -> Reciprocal basal angle gamma* = {gamma_star_deg:.4f} deg")
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11.0, 4.4))
# Panel 1: Slip-plane d-spacings in Cu vs Ti
labels = ["Cu (111)", "Cu (200)", "Cu (220)", "Ti (100)\nPrism", "Ti (002)\nBasal", "Ti (101)\nPyram."]
d_bars = [
lattices.interplanar_spacing((1, 1, 1), cu_lat),
lattices.interplanar_spacing((2, 0, 0), cu_lat),
lattices.interplanar_spacing((2, 2, 0), cu_lat),
lattices.interplanar_spacing((1, 0, 0), ti_lat),
lattices.interplanar_spacing((0, 0, 2), ti_lat),
lattices.interplanar_spacing((1, 0, 1), ti_lat),
]
bar_cols = ["#1f77b4"] * 3 + ["#9467bd"] * 3
ax1.bar(labels, d_bars, color=bar_cols, width=0.55)
ax1.set_ylabel("Interplanar Spacing $d_{hkl}$ [Å]")
ax1.set_title("Primary Plane Spacings: FCC Cu vs. HCP Ti")
# Panel 2: 2-D reciprocal hexagonal lattice & 1st Brillouin Zone
pts_g = []
for h in range(-2, 3):
for k in range(-2, 3):
pts_g.append(h * b1_2d + k * b2_2d)
pts_g = np.array(pts_g)
ax2.scatter(pts_g[:, 0], pts_g[:, 1], c="#1f77b4", s=35, zorder=3, label="Reciprocal Nodes $\\mathbf{g}_{hk0}$")
ax2.arrow(0, 0, b1_2d[0] * 0.9, b1_2d[1] * 0.9, head_width=0.12, color="#d62728", lw=1.8)
ax2.arrow(0, 0, b2_2d[0] * 0.9, b2_2d[1] * 0.9, head_width=0.12, color="#2ca02c", lw=1.8)
# 1st Brillouin Zone vertices (circumradius R_BZ = ||b1|| / sqrt(3)):
r_bz = np.linalg.norm(b1_2d) / np.sqrt(3.0)
angles_bz = np.radians(np.arange(0, 361, 60))
bz_x = r_bz * np.cos(angles_bz)
bz_y = r_bz * np.sin(angles_bz)
ax2.plot(bz_x, bz_y, "k-", lw=2.0, label="1st Brillouin Zone")
ax2.fill(bz_x, bz_y, color="#ffbb78", alpha=0.25)
ax2.annotate("$\\Gamma$", (0.08, 0.08), fontsize=10, fontweight="bold")
ax2.set_xlim(-4.8, 4.8)
ax2.set_ylim(-4.8, 4.8)
ax2.set_aspect("equal")
ax2.set_xlabel("$g_x$ [Å$^{-1}$]")
ax2.set_ylabel("$g_y$ [Å$^{-1}$]")
ax2.set_title("HCP Ti Basal Reciprocal Space ($\\gamma^* = 60^\\circ$)")
ax2.legend(loc="upper right", frameon=False, fontsize=8)
label_panels(fig)
plt.show()
assert np.isclose(gamma_star_deg, 60.0, atol=1e-12)
assert d_bars[3] > d_bars[4] > d_bars[5]
Demonstration 3: Slip-Plane Ranking (Cu vs Ti) & 2-D Hexagonal Reciprocal / Brillouin Zone Plot
===============================================================================================
Direct basal angle gamma = 120.0 deg -> Reciprocal basal angle gamma* = 60.0000 deg

Figure 2.1. (a) Spacing of low-index planes in FCC Cu and HCP Ti. (b) Reciprocal lattice points of Ti in the basal plane, the two reciprocal basis vectors and the first Brillouin zone.
What Demonstration 3 shows. In panel (a), because Ti has a sub-ideal , its prism plane spacing exceeds its half-cell basal spacing . This is consistent with prismatic slip being the primary slip mode of -Ti at room temperature.
4. Sensitivity: Anisotropic -Axis Strain in HCP Titanium¶
In in-situ synchrotron X-ray diffraction under load, elastic strain shifts selectively according to plane orientation. Suppose we apply uniaxial -axis tension to HCP Ti at fixed basal : which spacings stretch, and which remain strictly invariant?
heading("Demonstration 4: Selective Plane-Spacing Shift Under Uniaxial c-Axis Strain in Ti")
eps_c_grid = np.linspace(-0.02, 0.02, 9)
print(f"{'eps_c [%]':>10s} | {'d_(100) [A]':>12s} | {'d_(101) [A]':>12s} | {'d_(002) [A]':>12s} | {'dd_(002)/d0 [%]':>16s}")
print("-" * 74)
d002_ref = lattices.interplanar_spacing((0, 0, 2), ti_lat)
d100_ref = lattices.interplanar_spacing((1, 0, 0), ti_lat)
for eps_c in eps_c_grid:
lat_strained = lattices.hcp_unit_cell(ti_a, ti_c * (1.0 + eps_c))["lattice_vectors"]
d100 = lattices.interplanar_spacing((1, 0, 0), lat_strained)
d101 = lattices.interplanar_spacing((1, 0, 1), lat_strained)
d002 = lattices.interplanar_spacing((0, 0, 2), lat_strained)
rel_002 = 100.0 * (d002 - d002_ref) / d002_ref
print(f"{100.0*eps_c:10.2f} | {d100:12.6f} | {d101:12.6f} | {d002:12.6f} | {rel_002:16.4f}")
assert np.isclose(d100, d100_ref, rtol=1e-15)
assert np.isclose(rel_002, 100.0 * eps_c, rtol=1e-13)
caught_zero_hkl = False
try:
lattices.interplanar_spacing((0, 0, 0), ti_lat)
except ValueError:
caught_zero_hkl = True
assert caught_zero_hkl
Demonstration 4: Selective Plane-Spacing Shift Under Uniaxial c-Axis Strain in Ti
=================================================================================
eps_c [%] | d_(100) [A] | d_(101) [A] | d_(002) [A] | dd_(002)/d0 [%]
--------------------------------------------------------------------------
-2.00 | 2.555468 | 2.232957 | 2.295895 | -2.0000
-1.50 | 2.555468 | 2.235635 | 2.307609 | -1.5000
-1.00 | 2.555468 | 2.238283 | 2.319323 | -1.0000
-0.50 | 2.555468 | 2.240899 | 2.331036 | -0.5000
0.00 | 2.555468 | 2.243486 | 2.342750 | 0.0000
0.50 | 2.555468 | 2.246043 | 2.354464 | 0.5000
1.00 | 2.555468 | 2.248571 | 2.366178 | 1.0000
1.50 | 2.555468 | 2.251069 | 2.377891 | 1.5000
2.00 | 2.555468 | 2.253540 | 2.389605 | 2.0000
eps_line = np.linspace(-0.02, 0.02, 41)
fig, ax = plt.subplots(figsize=(6.4, 4.0))
for hkl_plot, style in [((1, 0, 0), "-"), ((1, 0, 1), "--"), ((0, 0, 2), "-.")]:
d_ref = lattices.interplanar_spacing(hkl_plot, ti_lat)
d_line = [lattices.interplanar_spacing(hkl_plot, lattices.hcp_unit_cell(ti_a, ti_c * (1.0 + e))["lattice_vectors"]) for e in eps_line]
ax.plot(100.0 * eps_line, 100.0 * (np.array(d_line) / d_ref - 1.0), style, label="(%d%d%d)" % hkl_plot)
ax.set_xlabel(r"strain along $c$ [%]"); ax.set_ylabel(r"change of $d_{hkl}$ [%]"); ax.legend()
plt.show()
Figure 2.2. Relative change of three plane spacings of Ti when the cell is strained along only: (002) follows the strain, (100) does not change and (101) changes by about a quarter of the strain.
Inside the algorithm¶
Under pure -axis strain, prism planes () exhibit zero change in , basal planes track one-for-one, and pyramidal planes respond at an intermediate projection weight. Below we inspect lattices.reciprocal_lattice and show equivalence between matrix inversion and the textbook vector triple-product formulas .
Check against the library¶
heading("Inside the Algorithm: Vector Cross-Product Triple Product vs 2*pi*inv(A).T")
print(show_source(lattices.reciprocal_lattice))
a1, a2, a3 = ti_lat[0], ti_lat[1], ti_lat[2]
vol_signed = float(np.dot(a1, np.cross(a2, a3)))
b_cross = (2.0 * np.pi / vol_signed) * np.vstack([
np.cross(a2, a3),
np.cross(a3, a1),
np.cross(a1, a2),
])
b_lib = lattices.reciprocal_lattice(ti_lat)["reciprocal_vectors"]
max_diff = float(np.max(np.abs(b_cross - b_lib)))
print(f"Max discrepancy ||B_cross - B_library||_inf = {max_diff:.2e} A^-1")
assert np.allclose(b_cross, b_lib, atol=1e-14)
Inside the Algorithm: Vector Cross-Product Triple Product vs 2*pi*inv(A).T
==========================================================================
def reciprocal_lattice(lattice_vectors: np.ndarray) -> dict:
"""Compute reciprocal basis vectors B (rows b_1, b_2, b_3) satisfying a_i . b_j = 2*pi*delta_ij."""
lat = np.asarray(lattice_vectors, dtype=float)
if lat.shape != (3, 3):
raise ValueError("lattice_vectors must have shape (3, 3).")
b_mat = 2.0 * np.pi * np.linalg.inv(lat).T
bz_vol = float(abs(np.linalg.det(b_mat)))
return {
"reciprocal_vectors": b_mat,
"reciprocal_metric": b_mat @ b_mat.T,
"brillouin_zone_volume": bz_vol,
}
Max discrepancy ||B_cross - B_library||_inf = 4.44e-16 A^-1
Exercises¶
Worked solutions are in 02_solutions.ipynb. The cell below the list is a short self-check to start from.
Verify a result. Construct the 1-atom primitive FCC and BCC lattice matrices for and show via
lattices.reciprocal_latticethat the reciprocal of primitive FCC is primitive BCC (and vice versa), satisfying .Find how it fails. Quantify the exact percentage error when the cubic formula is mistakenly applied to HCP
Ti(1,0,0),(1,1,0), and(1,0,1)planes.Implement it yourself. Implement
interplanar_angle_deg(hkl1, hkl2, lattice_vectors)via reciprocal dot products and verify between(1,1,1)and(1,1,-1)inCuand between(0,0,1)and(1,0,1)in HCPTi.
heading("Self-check for the exercises")
a_val = 3.6149
a_fcc_prim = 0.5 * a_val * np.array([[0.0, 1.0, 1.0], [1.0, 0.0, 1.0], [1.0, 1.0, 0.0]])
b_of_fcc = lattices.reciprocal_lattice(a_fcc_prim)["reciprocal_vectors"]
b_expected_bcc = (2.0 * np.pi / a_val) * np.array([[-1.0, 1.0, 1.0], [1.0, -1.0, 1.0], [1.0, 1.0, -1.0]])
assert np.allclose(b_of_fcc, b_expected_bcc, atol=1e-14)
print("Reciprocal of primitive FCC verified as primitive BCC to machine precision")
print("All checks passed.")
Self-check for the exercises
============================
Reciprocal of primitive FCC verified as primitive BCC to machine precision
All checks passed.