Worked solutions to the three exercises of Lecture 6. Each solution is computed here and checked with assert statements against an exact identity or an independent calculation. The first code cell sets up the notebook and runs Demonstration 1 of the lecture without showing its output, because some of the solutions use its variables.
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))
# Demonstration 1 of the lecture, run without output: the solutions use its variables.
import contextlib, io
_show, plt.show = plt.show, lambda *args, **kwargs: None
_stdout = contextlib.redirect_stdout(io.StringIO()); _stdout.__enter__()
heading("Demonstration 1: Voigt-Reuss-Hill Bounds Across Representative Cubic Crystals")
rep_symbols = ["W", "Al", "Fe", "Cu", "Au", "C-diamond"]
print(f"{'Elem':10s} | {'B [GPa]':>8s} | {'G_R [GPa]':>9s} | {'G_H [GPa]':>9s} | {'G_V [GPa]':>9s} | {'E_H [GPa]':>9s} | {'nu_H':>7s}")
print("-" * 76)
for sym in rep_symbols:
el = constants.ELEMENTS_DB[sym]
vrh = elasticity.voigt_reuss_hill_cubic(el["C11_GPa"], el["C12_GPa"], el["C44_GPa"])
print(
f"{sym:10s} | {vrh['B']:8.2f} | {vrh['G_reuss']:9.2f} | {vrh['G_hill']:9.2f} | "
f"{vrh['G_voigt']:9.2f} | {vrh['E_hill']:9.2f} | {vrh['nu_hill']:7.4f}"
)
assert vrh["G_reuss"] <= vrh["G_hill"] <= vrh["G_voigt"] + 1e-12
assert -1.0 < vrh["nu_hill"] < 0.5
# Exact isotropic coincidence check when 2*C44 == C11 - C12 (A_Z = 1):
iso_vrh = elasticity.voigt_reuss_hill_cubic(200.0, 100.0, 50.0)
assert np.isclose(iso_vrh["G_voigt"], 50.0, atol=1e-14)
assert np.isclose(iso_vrh["G_reuss"], 50.0, atol=1e-14)
assert np.isclose(iso_vrh["universal_anisotropy_AU"], 0.0, atol=1e-14)
_stdout.__exit__(None, None, None); plt.show = _show; plt.close("all")Exercise 1¶
Problem. Verify across reciprocal Zener pairs for that voigt_reuss_hill_cubic obeys to 10-14, and confirm across all 12 cubic elements in ELEMENTS_DB that pugh_B_over_G > 1.75 is equivalent to nu_hill > 0.26.
heading("Exercise 1: Reciprocal Symmetry A^U(A_Z) == A^U(1/A_Z) & Poisson Equivalent of Pugh Criterion")
B_ref, Cp_ref = 150.0, 30.0
c11_r = B_ref + (4.0 / 3.0) * Cp_ref
c12_r = B_ref - (2.0 / 3.0) * Cp_ref
for az in [0.2, 0.4, 0.8, 1.0]:
au_1 = elasticity.voigt_reuss_hill_cubic(c11_r, c12_r, az * Cp_ref)["universal_anisotropy_AU"]
au_2 = elasticity.voigt_reuss_hill_cubic(c11_r, c12_r, (1.0 / az) * Cp_ref)["universal_anisotropy_AU"]
print(f"A_Z = {az:5.2f} vs 1/A_Z = {1.0/az:5.2f} | A^U = {au_1:9.6f} vs {au_2:9.6f} | |diff| = {abs(au_1 - au_2):.2e}")
assert np.isclose(au_1, au_2, rtol=1e-14, atol=1e-14)
nu_crit = (3.0 * 1.75 - 2.0) / (2.0 * (3.0 * 1.75 + 1.0))
assert np.isclose(nu_crit, 0.26, atol=1e-15)
for sym, d in constants.ELEMENTS_DB.items():
if d["C11_GPa"] is not None:
vrh = elasticity.voigt_reuss_hill_cubic(d["C11_GPa"], d["C12_GPa"], d["C44_GPa"])
assert vrh["ductile_by_pugh"] == (vrh["nu_hill"] > nu_crit)
print(f"Critical Poisson ratio nu_crit = {nu_crit:.4f} matches B/G_H > 1.75 across all 12 cubic elements.")
Exercise 1: Reciprocal Symmetry A^U(A_Z) == A^U(1/A_Z) & Poisson Equivalent of Pugh Criterion
=============================================================================================
A_Z = 0.20 vs 1/A_Z = 5.00 | A^U = 3.840000 vs 3.840000 | |diff| = 0.00e+00
A_Z = 0.40 vs 1/A_Z = 2.50 | A^U = 1.080000 vs 1.080000 | |diff| = 0.00e+00
A_Z = 0.80 vs 1/A_Z = 1.25 | A^U = 0.060000 vs 0.060000 | |diff| = 0.00e+00
A_Z = 1.00 vs 1/A_Z = 1.00 | A^U = 0.000000 vs 0.000000 | |diff| = 0.00e+00
Critical Poisson ratio nu_crit = 0.2600 matches B/G_H > 1.75 across all 12 cubic elements.
Explanation. Substituting into gives , showing that swapping and shear stiffnesses produces identical polycrystalline Voigt/Reuss divergence. Likewise, is strictly increasing in , mapping exactly onto .
Exercise 2¶
Problem. Verify that elasticity.voigt_reuss_hill_cubic raises ValueError for all three Born mechanical instability modes (, , and ), and show the unphysical negative shear modulus or produced when the stability guard is omitted.
heading("Exercise 2: Diagnostic Audit of Born Mechanical Instability Modes")
unstable_cases = [
("Tetragonal softening (C11 < C12)", 100.0, 130.0, 50.0),
("Spinodal bulk collapse (C11+2C12 < 0)", 80.0, -60.0, 40.0),
("Trigonal shear collapse (C44 < 0)", 180.0, 100.0, -25.0),
]
for label, c11, c12, c44 in unstable_cases:
stab = elasticity.verify_born_stability_cubic(c11, c12, c44)
assert stab["stable"] is False
raised = False
try:
elasticity.voigt_reuss_hill_cubic(c11, c12, c44)
except ValueError:
raised = True
assert raised is True
b_unguarded = (c11 + 2.0 * c12) / 3.0
gr_unguarded = 5.0 * c44 * (c11 - c12) / (4.0 * c44 + 3.0 * (c11 - c12))
print(f"{label:38s} | min eig = {np.min(stab['eigenvalues_GPa']):+7.2f} GPa | unguarded B = {b_unguarded:+7.2f}, G_R = {gr_unguarded:+7.2f}")
Exercise 2: Diagnostic Audit of Born Mechanical Instability Modes
=================================================================
Tetragonal softening (C11 < C12) | min eig = -30.00 GPa | unguarded B = +120.00, G_R = -68.18
Spinodal bulk collapse (C11+2C12 < 0) | min eig = -40.00 GPa | unguarded B = -13.33, G_R = +48.28
Trigonal shear collapse (C44 < 0) | min eig = -25.00 GPa | unguarded B = +126.67, G_R = -71.43
Explanation. A crystal’s elastic strain energy density is positive-definite if and only if its three distinct cubic eigenvalues , , and are strictly positive. Without verify_born_stability_cubic, negative or corrupts the harmonic Reuss denominator and yields negative shear stiffness or (thermodynamic instability toward spontaneous lattice transformation).
Exercise 3¶
Problem. Implement hashin_shtrikman_shear_bounds_cubic(C11, C12, C44) using , , , and evaluated at and . Verify across all 12 cubic elements in ELEMENTS_DB.
heading("Exercise 3: Implement It Yourself — Hashin-Shtrikman Polycrystalline Shear Bounds")
def hashin_shtrikman_shear_bounds_cubic(C11: float, C12: float, C44: float) -> dict:
"""Compute variational Hashin-Shtrikman lower and upper shear bounds [GPa] for a cubic polycrystal."""
vrh = elasticity.voigt_reuss_hill_cubic(C11, C12, C44)
B = vrh["B"]
mu1 = 0.5 * (float(C11) - float(C12))
mu2 = float(C44)
def g_hs(mu0: float) -> float:
zeta = mu0 * (9.0 * B + 8.0 * mu0) / (6.0 * (B + 2.0 * mu0))
return float(1.0 / (0.4 / (mu1 + zeta) + 0.6 / (mu2 + zeta)) - zeta)
mu_lo, mu_hi = min(mu1, mu2), max(mu1, mu2)
return {"G_hs_lower": g_hs(mu_lo), "G_hs_upper": g_hs(mu_hi), "G_reuss": vrh["G_reuss"], "G_voigt": vrh["G_voigt"]}
print(f"{'Elem':10s} | {'G_R':>8s} | {'G_HS^-':>8s} | {'G_HS^+':>8s} | {'G_V':>8s} | {'HS/VR Gap Ratio':>16s}")
print("-" * 70)
for sym, d in constants.ELEMENTS_DB.items():
if d["C11_GPa"] is not None:
hs = hashin_shtrikman_shear_bounds_cubic(d["C11_GPa"], d["C12_GPa"], d["C44_GPa"])
vr_gap = hs["G_voigt"] - hs["G_reuss"]
hs_gap = hs["G_hs_upper"] - hs["G_hs_lower"]
ratio = hs_gap / vr_gap if vr_gap > 1e-12 else 0.0
print(f"{sym:10s} | {hs['G_reuss']:8.2f} | {hs['G_hs_lower']:8.2f} | {hs['G_hs_upper']:8.2f} | {hs['G_voigt']:8.2f} | {ratio:16.3f}")
assert hs["G_reuss"] - 1e-12 <= hs["G_hs_lower"] <= hs["G_hs_upper"] <= hs["G_voigt"] + 1e-12
assert hs_gap < vr_gap
Exercise 3: Implement It Yourself — Hashin-Shtrikman Polycrystalline Shear Bounds
=================================================================================
Elem | G_R | G_HS^- | G_HS^+ | G_V | HS/VR Gap Ratio
----------------------------------------------------------------------
Cu | 40.03 | 45.96 | 49.45 | 54.64 | 0.238
Al | 26.04 | 26.16 | 26.17 | 26.28 | 0.040
Ni | 77.66 | 84.95 | 88.10 | 94.66 | 0.186
Au | 23.99 | 27.10 | 28.70 | 31.04 | 0.228
Ag | 25.54 | 29.00 | 30.89 | 33.78 | 0.228
Fe | 74.47 | 80.84 | 83.44 | 89.18 | 0.177
W | 159.96 | 159.96 | 159.96 | 159.96 | 0.002
Mo | 123.31 | 124.92 | 125.15 | 126.70 | 0.068
Cr | 113.80 | 115.22 | 115.43 | 116.92 | 0.067
Si | 64.95 | 66.43 | 66.71 | 68.12 | 0.089
Ge | 52.75 | 54.29 | 54.64 | 56.12 | 0.102
C-diamond | 531.61 | 533.82 | 534.01 | 536.40 | 0.039
Summary. Setting () recovers and () recovers , while choosing the tightest admissible isotropic comparison media and narrows the interval for the shear modulus by at least for all 12 cubic elements (for copper, from the Voigt–Reuss interval of to ).