Gold and nickel form a single FCC solid solution at high temperature and separate into Au-rich and Ni-rich regions when cooled into a miscibility gap. Inside part of that gap the separation needs no nucleation barrier. Both facts follow from the competition between interaction enthalpy (which favors A–A and B–B clustering when ) and configurational entropy (whose vertical logarithmic walls at always enforce finite terminal solubility). In this lecture we evaluate regular and CALPHAD subregular Redlich–Kister solution models (phase_thermodynamics), verify Euler homogeneity and the Gibbs–Duhem identity for chemical potentials , and map out consolute critical temperatures and spinodal instability loci ().
Learning objectives¶
Analyze the competition between mixing enthalpy and configurational entropy in
phase_thermodynamics.regular_solution_free_energy.Evaluate asymmetric CALPHAD excess free energies via
phase_thermodynamics.redlich_kister_free_energy() and verify Euler homogeneity and the isothermal Gibbs–Duhem relation.Derive and verify the exact consolute critical temperature (
regular_solution_critical_temp) and spinodal boundary (regular_solution_spinodal).Explore parameter sensitivity across ordering (), ideal (), and skewed subregular () alloy solutions.
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. Regular Solution Thermodynamics: Enthalpy vs. Entropy¶
In Hildebrand’s regular solution model (phase_thermodynamics.regular_solution_free_energy), A and B atoms mix randomly on a crystal lattice () while pairwise A–B bond mismatch () produces a parabolic mixing enthalpy with interaction parameter :
Differentiating twice with respect to mole fraction reveals the local compositional stiffness (curvature):
When (clustering / endothermic mixing), attains its minimum at . Thus is globally convex above , whereas for its center buckles upward into an unstable spinodal dome ().
heading("Demonstration 1: Enthalpy-Entropy Competition Above and Below Tc = Omega / (2R)")
omega_demo = 18000.0 # [J/mol], representative of Au-Ni / Cu-Co positive-enthalpy FCC solid solutions
Tc_demo = phase_thermodynamics.regular_solution_critical_temp(omega_demo)
x_grid = np.linspace(0.002, 0.998, 400)
res_low = phase_thermodynamics.regular_solution_free_energy(x_grid, T_K=750.0, omega_J_mol=omega_demo)
res_high = phase_thermodynamics.regular_solution_free_energy(x_grid, T_K=1300.0, omega_J_mol=omega_demo)
mid_low = phase_thermodynamics.regular_solution_free_energy(0.5, T_K=750.0, omega_J_mol=omega_demo)
mid_high = phase_thermodynamics.regular_solution_free_energy(0.5, T_K=1300.0, omega_J_mol=omega_demo)
print(f"Omega = {omega_demo:.0f} J/mol -> Consolute Critical Temperature Tc = {Tc_demo:.2f} K")
print(f"At T = 750 K (< Tc): dG_mix(0.5) = {mid_low['dG_mix']:+8.1f} J/mol | d2G/dx2(0.5) = {mid_low['d2G_dx2']:+9.1f} J/mol (UNSTABLE < 0)")
print(f"At T = 1300 K (> Tc): dG_mix(0.5) = {mid_high['dG_mix']:+8.1f} J/mol | d2G/dx2(0.5) = {mid_high['d2G_dx2']:+9.1f} J/mol (STABLE > 0)")
assert mid_low["d2G_dx2"] < 0.0 and mid_high["d2G_dx2"] > 0.0
assert float(np.min(res_low["dG_mix"])) < 0.0 # Entropy guarantees negative dG_mix wells near x->0 and x->1
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9.4, 3.9))
ax1.plot(x_grid, res_low["dH_mix"] / 1e3, "--", lw=1.7, label=r"$\Delta H_{\mathrm{mix}}$")
ax1.plot(x_grid, -750.0 * res_low["dS_mix"] / 1e3, ":", lw=1.7, label=r"$-T \Delta S_{\mathrm{mix}}$ ($750$ K)")
ax1.plot(x_grid, res_low["dG_mix"] / 1e3, lw=2.2, color="#c0392b", label=r"$\Delta G_{\mathrm{mix}}$ ($750$ K $< T_c$, double well)")
ax1.plot(x_grid, res_high["dG_mix"] / 1e3, lw=2.0, color="#1f4e79", label=r"$\Delta G_{\mathrm{mix}}$ ($1300$ K $> T_c$, convex)")
ax1.set_xlabel(r"Solute Mole Fraction $x_B$ [-]")
ax1.set_ylabel(r"Molar Energy [$\mathrm{kJ/mol}$]")
ax1.set_title("Enthalpy vs. Configurational Entropy")
ax1.set_ylim(-5.0, 8.5)
ax1.legend(fontsize=7.8, loc="upper center", ncol=2)
ax2.plot(x_grid, res_low["d2G_dx2"] / 1e3, lw=2.0, color="#c0392b", label=r"$750$ K ($< T_c$)")
ax2.plot(x_grid, res_high["d2G_dx2"] / 1e3, lw=2.0, color="#1f4e79", label=r"$1300$ K ($> T_c$)")
ax2.axhline(0.0, color="black", ls="--", lw=1.2)
ax2.set_ylim(-20.0, 80.0)
ax2.set_xlabel(r"Solute Mole Fraction $x_B$ [-]")
ax2.set_ylabel(r"Curvature $\partial^2 \Delta G_{\mathrm{mix}} / \partial x^2$ [$\mathrm{kJ/mol}$]")
ax2.set_title("Spinodal Instability Window ($\\partial^2 G / \\partial x^2 < 0$)")
ax2.legend()
label_panels(fig)
plt.show()
Demonstration 1: Enthalpy-Entropy Competition Above and Below Tc = Omega / (2R)
===============================================================================
Omega = 18000 J/mol -> Consolute Critical Temperature Tc = 1082.45 K
At T = 750 K (< Tc): dG_mix(0.5) = +177.6 J/mol | d2G/dx2(0.5) = -11056.6 J/mol (UNSTABLE < 0)
At T = 1300 K (> Tc): dG_mix(0.5) = -2992.1 J/mol | d2G/dx2(0.5) = +7235.2 J/mol (STABLE > 0)

Figure 9.1. Regular solution with the assumed . (a) Enthalpy, entropy term and Gibbs energy of mixing below and above . (b) Second derivative of the Gibbs energy; it is negative inside the spinodal.
What Demonstration 1 shows. Even at where pushes the equiatomic solution upward into an unstable barrier (), the infinite downward slope of at and produces two symmetric free-energy minima below . This is why a pure element always dissolves a finite equilibrium concentration of a second element. The interaction parameter is an assumed value.
2. Subregular Redlich–Kister CALPHAD Expansion, Euler Homogeneity & Gibbs–Duhem¶
Real binary alloys rarely have equal atomic radii (for example, vs. , making it much costlier in elastic strain energy to squeeze a large Au atom into a stiff Ni lattice than vice versa). CALPHAD databases represent asymmetric excess Gibbs energy via the Redlich–Kister (1948) polynomial (phase_thermodynamics.redlich_kister_free_energy):
The partial molar mixing chemical potentials follow from the tangent-intercept relations:
which automatically enforce Euler’s homogeneity theorem and the Gibbs–Duhem differential constraint .
heading("Demonstration 2: Redlich-Kister Asymmetric Alloy Verification — Euler & Gibbs-Duhem Identities")
x_interior = np.linspace(0.03, 0.97, 200)
L0_rk, L1_rk, L2_rk = 19500.0, -5200.0, 1800.0
T_rk = 850.0
rk = phase_thermodynamics.redlich_kister_free_energy(x_interior, T_K=T_rk, L0=L0_rk, L1=L1_rk, L2=L2_rk)
# 1. Exact reduction to regular_solution_free_energy when L1 = L2 = 0:
rk_sym = phase_thermodynamics.redlich_kister_free_energy(x_interior, T_K=T_rk, L0=L0_rk, L1=0.0, L2=0.0)
reg_sym = phase_thermodynamics.regular_solution_free_energy(x_interior, T_K=T_rk, omega_J_mol=L0_rk)
assert np.allclose(rk_sym["dG_mix"], reg_sym["dG_mix"], rtol=1e-13, atol=1e-10)
assert np.allclose(rk_sym["dmu_A"], reg_sym["dmu_A"], rtol=1e-13, atol=1e-10)
assert np.allclose(rk_sym["dmu_B"], reg_sym["dmu_B"], rtol=1e-13, atol=1e-10)
# 2. Euler homogeneity: (1 - x)*dmu_A + x*dmu_B == dG_mix
euler_resid = np.max(np.abs((1.0 - x_interior) * rk["dmu_A"] + x_interior * rk["dmu_B"] - rk["dG_mix"]))
# 3. Isothermal Gibbs-Duhem via 4th-order finite-difference derivatives of dmu_A and dmu_B:
dx = 1e-6
rk_p = phase_thermodynamics.redlich_kister_free_energy(x_interior + dx, T_K=T_rk, L0=L0_rk, L1=L1_rk, L2=L2_rk)
rk_m = phase_thermodynamics.redlich_kister_free_energy(x_interior - dx, T_K=T_rk, L0=L0_rk, L1=L1_rk, L2=L2_rk)
dmuA_dx = (rk_p["dmu_A"] - rk_m["dmu_A"]) / (2.0 * dx)
dmuB_dx = (rk_p["dmu_B"] - rk_m["dmu_B"]) / (2.0 * dx)
gd_resid = np.max(np.abs((1.0 - x_interior) * dmuA_dx + x_interior * dmuB_dx))
print(f"Max Euler homogeneity residual |(1-x)dmu_A + x*dmu_B - dG| = {euler_resid:.3e} J/mol")
print(f"Max Gibbs-Duhem residual |(1-x)dmuA/dx + x*dmuB/dx| = {gd_resid:.3e} J/mol")
assert euler_resid < 1e-11
assert gd_resid < 1e-5
Demonstration 2: Redlich-Kister Asymmetric Alloy Verification — Euler & Gibbs-Duhem Identities
==============================================================================================
Max Euler homogeneity residual |(1-x)dmu_A + x*dmu_B - dG| = 1.137e-13 J/mol
Max Gibbs-Duhem residual |(1-x)dmuA/dx + x*dmuB/dx| = 2.700e-06 J/mol
What Demonstration 2 shows. Regardless of how strongly and skew , Euler’s theorem holds to and Gibbs–Duhem holds across the entire composition interval, meaning and can never vary independently at constant : wherever rises with , must fall with slope .
3. Critical Temperature & Exact Spinodal Locus (regular_solution_spinodal)¶
Setting yields the quadratic , whose roots define the chemical spinodal curve (phase_thermodynamics.regular_solution_spinodal):
Inside , : uphill interdiffusion () amplifies infinitesimal composition waves spontaneously (spinodal decomposition, Cahn 1961).
heading("Demonstration 3: Regular-Solution Critical Point & Spinodal Dome Verification")
omega_sp = 20000.0
Tc_sp = phase_thermodynamics.regular_solution_critical_temp(omega_sp)
assert phase_thermodynamics.regular_solution_spinodal(Tc_sp * 1.01, omega_sp) is None
T_ratios = [0.35, 0.50, 0.65, 0.80, 0.92, 0.99]
print(f"Omega = {omega_sp:.0f} J/mol -> Exact Tc = {Tc_sp:.4f} K")
print(f"{'T / Tc':>8s} | {'T [K]':>9s} | {'x_s1':>10s} | {'x_s2':>10s} | {'d2G/dx2(x_s1)':>15s} | {'d2G/dx2(0.5)':>15s}")
print("-" * 80)
for tr in T_ratios:
tk = tr * Tc_sp
xs1, xs2 = phase_thermodynamics.regular_solution_spinodal(tk, omega_sp)
chk_s1 = phase_thermodynamics.regular_solution_free_energy(xs1, tk, omega_sp)["d2G_dx2"]
chk_mid = phase_thermodynamics.regular_solution_free_energy(0.5, tk, omega_sp)["d2G_dx2"]
print(f"{tr:8.2f} | {tk:9.2f} | {xs1:10.6f} | {xs2:10.6f} | {chk_s1:15.3e} | {chk_mid:+15.2f}")
assert np.isclose(xs1 + xs2, 1.0, atol=1e-15)
assert abs(chk_s1) < 1e-10 and chk_mid < 0.0
Demonstration 3: Regular-Solution Critical Point & Spinodal Dome Verification
=============================================================================
Omega = 20000 J/mol -> Exact Tc = 1202.7236 K
T / Tc | T [K] | x_s1 | x_s2 | d2G/dx2(x_s1) | d2G/dx2(0.5)
--------------------------------------------------------------------------------
0.35 | 420.95 | 0.096887 | 0.903113 | 7.276e-12 | -26000.00
0.50 | 601.36 | 0.146447 | 0.853553 | 7.276e-12 | -20000.00
0.65 | 781.77 | 0.204196 | 0.795804 | 0.000e+00 | -14000.00
0.80 | 962.18 | 0.276393 | 0.723607 | 0.000e+00 | -8000.00
0.92 | 1106.51 | 0.358579 | 0.641421 | -7.276e-12 | -3200.00
0.99 | 1190.70 | 0.450000 | 0.550000 | 0.000e+00 | -400.00
What Demonstration 3 shows. As rises toward , the spinodal roots pinch together parabolically as and merge at the critical consolute point where both and .
4. Conceptual Exploration & Parameter Sensitivity (“What-If”: Ordering vs. Subregular Skewness)¶
How does changing the sign of ( ordering/intermetallic tendency vs. clustering) or introducing subregular asymmetry reshape and shift the spinodal instability zone?
heading("Demonstration 4: Ordering (Omega < 0) Guard & Subregular Skewness Sweep (L1 / L0)")
# Ordering alloy (Omega = -15,000 J/mol): globally convex at ALL temperatures -> Tc == 0.0, spinodal is None
assert phase_thermodynamics.regular_solution_critical_temp(-15000.0) == 0.0
assert phase_thermodynamics.regular_solution_spinodal(300.0, -15000.0) is None
ord_300 = phase_thermodynamics.regular_solution_free_energy(np.linspace(0.01, 0.99, 99), 300.0, -15000.0)
assert np.all(ord_300["d2G_dx2"] > 0.0)
x_fine = np.linspace(0.02, 0.98, 500)
L0_base, T_sub = 20000.0, 900.0
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9.4, 3.9))
print(f"{'L1 / L0':>8s} | {'Peak G_ex x*':>13s} | {'Min d2G/dx2 x*':>15s} | {'Min d2G/dx2 [J/mol]':>20s}")
print("-" * 66)
for ratio_l1 in [-0.45, 0.0, +0.45]:
L1_val = ratio_l1 * L0_base
rk_s = phase_thermodynamics.redlich_kister_free_energy(x_fine, T_K=T_sub, L0=L0_base, L1=L1_val, L2=0.0)
x_peak_gex = float(x_fine[int(np.argmax(rk_s["G_excess"]))])
idx_min_d2 = int(np.argmin(rk_s["d2G_dx2"]))
print(f"{ratio_l1:+8.2f} | {x_peak_gex:13.3f} | {x_fine[idx_min_d2]:15.3f} | {rk_s['d2G_dx2'][idx_min_d2]:+20.1f}")
ax1.plot(x_fine, rk_s["G_excess"] / 1e3, lw=2.0, label=rf"$L_1/L_0 = {ratio_l1:+.2f}$")
ax2.plot(x_fine, rk_s["d2G_dx2"] / 1e3, lw=2.0, label=rf"$L_1/L_0 = {ratio_l1:+.2f}$")
ax2.axhline(0.0, color="black", ls="--", lw=1.2)
ax2.set_ylim(-25.0, 50.0)
ax1.set_xlabel(r"Mole Fraction $x_B$ [-]")
ax1.set_ylabel(r"Excess Gibbs Energy $G^{\mathrm{ex}}$ [$\mathrm{kJ/mol}$]")
ax1.set_title("Redlich–Kister Excess Energy Skewness")
ax1.legend()
ax2.set_xlabel(r"Mole Fraction $x_B$ [-]")
ax2.set_ylabel(r"Curvature $\partial^2 \Delta G_{\mathrm{mix}} / \partial x^2$ [$\mathrm{kJ/mol}$]")
ax2.set_title("Asymmetric Shift of the Unstable Spinodal Zone")
ax2.legend()
label_panels(fig)
plt.show()
Demonstration 4: Ordering (Omega < 0) Guard & Subregular Skewness Sweep (L1 / L0)
=================================================================================
L1 / L0 | Peak G_ex x* | Min d2G/dx2 x* | Min d2G/dx2 [J/mol]
------------------------------------------------------------------
-0.45 | 0.599 | 0.751 | -27091.7
+0.00 | 0.499 | 0.499 | -10067.8
+0.45 | 0.401 | 0.249 | -27091.7

Figure 9.2. Redlich–Kister solution for three values of . (a) Excess Gibbs energy. (b) Second derivative of the Gibbs energy of mixing.
Inside the algorithm¶
In Demonstration 4, because , setting adds to , making the curvature most negative on the A-rich side (, right where peaks), whereas shifts both the excess-enthalpy peak and the spinodal core toward B-rich compositions ().
Below we inspect phase_thermodynamics.redlich_kister_free_energy and verify its exact polynomial derivatives from scratch.
Check against the library¶
heading("Inside the Algorithm: phase_thermodynamics.redlich_kister_free_energy")
print(show_source(phase_thermodynamics.redlich_kister_free_energy))
x_t = np.array([0.15, 0.40, 0.75])
T_t, L0_t, L1_t, L2_t = 920.0, 17500.0, -4300.0, 2100.0
u_t = 1.0 - 2.0 * x_t
poly_t = L0_t + L1_t * u_t + L2_t * (u_t ** 2)
dpoly_t = -2.0 * L1_t - 4.0 * L2_t * u_t
g_ex_hand = x_t * (1.0 - x_t) * poly_t
dg_hand = constants.R * T_t * (x_t * np.log(x_t) + (1.0 - x_t) * np.log(1.0 - x_t)) + g_ex_hand
dg_dx_hand = constants.R * T_t * np.log(x_t / (1.0 - x_t)) + u_t * poly_t + x_t * (1.0 - x_t) * dpoly_t
rk_lib = phase_thermodynamics.redlich_kister_free_energy(x_t, T_t, L0_t, L1_t, L2_t)
assert np.allclose(dg_hand, rk_lib["dG_mix"], rtol=1e-15, atol=1e-13)
assert np.allclose(dg_dx_hand, rk_lib["dG_dx"], rtol=1e-15, atol=1e-13)
print("Exact Redlich-Kister polynomial & derivative match verified to machine precision")
Inside the Algorithm: phase_thermodynamics.redlich_kister_free_energy
=====================================================================
def redlich_kister_free_energy(
x: float | np.ndarray,
T_K: float,
L0: float,
L1: float = 0.0,
L2: float = 0.0,
) -> dict:
"""Evaluate subregular Redlich-Kister mixing Gibbs energy G_ex = x*(1-x)*[L0 + L1*(1-2x) + L2*(1-2x)^2]."""
if T_K <= 0.0:
raise ValueError("Temperature T_K must be strictly positive.")
x_arr = np.asarray(x, dtype=float)
if np.any((x_arr < 0.0) | (x_arr > 1.0)):
raise ValueError("Mole fraction x must lie in [0, 1].")
xc = np.clip(x_arr, 1e-15, 1.0 - 1e-15)
u = 1.0 - 2.0 * x_arr
poly = L0 + L1 * u + L2 * (u**2)
dpoly_dx = -2.0 * L1 - 4.0 * L2 * u
d2poly_dx2 = 8.0 * L2
g_ex = x_arr * (1.0 - x_arr) * poly
dg_ex_dx = u * poly + x_arr * (1.0 - x_arr) * dpoly_dx
d2g_ex_dx2 = -2.0 * poly + 2.0 * u * dpoly_dx + x_arr * (1.0 - x_arr) * d2poly_dx2
g_id = np.where((x_arr > 0.0) & (x_arr < 1.0), R * T_K * (xc * np.log(xc) + (1.0 - xc) * np.log(1.0 - xc)), 0.0)
dg_id_dx = R * T_K * np.log(xc / (1.0 - xc))
d2g_id_dx2 = (R * T_K) / (xc * (1.0 - xc))
dg = g_id + g_ex
dg_dx = dg_id_dx + dg_ex_dx
d2g = d2g_id_dx2 + d2g_ex_dx2
dmu_a = dg - x_arr * dg_dx
dmu_b = dg + (1.0 - x_arr) * dg_dx
if np.ndim(x) == 0:
return {
"dG_mix": float(dg),
"G_excess": float(g_ex),
"dG_dx": float(dg_dx),
"d2G_dx2": float(d2g),
"dmu_A": float(dmu_a),
"dmu_B": float(dmu_b),
}
return {
"dG_mix": dg,
"G_excess": g_ex,
"dG_dx": dg_dx,
"d2G_dx2": d2g,
"dmu_A": dmu_a,
"dmu_B": dmu_b,
}
Exact Redlich-Kister polynomial & derivative match verified to machine precision
Exercises¶
Worked solutions are in 09_solutions.ipynb. The cell below the list is a short self-check to start from.
Verify a result. Evaluate and from
redlich_kister_free_energywith at , verifying Raoult’s law ( as ) and Henry’s infinite-dilution enthalpies () and ().Find how it fails. Verify that pure-component endpoints return exact zero mixing energy (
dG_mix == 0.0) without0 * (-inf) = NaNcorruption in bothregular_solution_free_energyandredlich_kister_free_energy, and confirm that invalid compositions () or raiseValueError.Implement it yourself. Implement
subregular_spinodal_roots(T_K, L0, L1, L2=0.0)to find the spinodal compositions whereredlich_kister_free_energy(..., L0, L1, L2)['d2G_dx2'] == 0via sign-change bracketing and 60-step bisection. Verify exact match withregular_solution_spinodalwhen , and compute the skewed spinodal roots for at .
heading("Self-check for the exercises")
tc_chk = phase_thermodynamics.regular_solution_critical_temp(16628.925236)
xs_chk = phase_thermodynamics.regular_solution_spinodal(750.0, 16628.925236)
assert np.isclose(tc_chk, 1000.0, rtol=1e-9)
assert xs_chk is not None and np.isclose(xs_chk[0], 0.25, rtol=1e-9) and np.isclose(xs_chk[1], 0.75, rtol=1e-9)
print(f"Verified exact Tc = {tc_chk:.2f} K and spinodal roots at T/Tc = 0.75: {xs_chk}.")
print("All checks passed.")
Self-check for the exercises
============================
Verified exact Tc = 1000.00 K and spinodal roots at T/Tc = 0.75: (0.25000000000000006, 0.75).
All checks passed.