Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Solutions · 9. Regular and Redlich–Kister solutions and the spinodal

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 9. 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.

Exercise 1

Problem. Evaluate RTln⁡γA=ΔμA−RTln⁡(1−x)R T \ln\gamma_A = \Delta\mu_A - R T \ln(1 - x) and RTln⁡γB=ΔμB−RTln⁡xR T \ln\gamma_B = \Delta\mu_B - R T \ln x from redlich_kister_free_energy with (L0,L1,L2)=(21 000,−5 500,2 400) J/mol(L_0, L_1, L_2) = (21\,000, -5\,500, 2\,400)\ \mathrm{J/mol} at T=1000 KT = 1000\ \mathrm{K}, verifying Raoult’s law (γA→1\gamma_A \to 1 as x→0+x \to 0^+) and Henry’s infinite-dilution enthalpies RTln⁡γB∞=L0+L1+L2R T \ln\gamma_B^\infty = L_0 + L_1 + L_2 (x→0+x \to 0^+) and RTln⁡γA∞=L0−L1+L2R T \ln\gamma_A^\infty = L_0 - L_1 + L_2 (x→1−x \to 1^-).


Exercise 1: Raoult's Law & Henry's Infinite-Dilution Limits of Redlich-Kister Activity Coefficients
===================================================================================================
x -> 0+ : RT ln(gamma_A) = 1.650e-12 J/mol (Raoult = 0) | RT ln(gamma_B^inf) = 17900.00 vs L0+L1+L2 = 17900.00
x -> 1- : RT ln(gamma_B) = 4.950e-12 J/mol (Raoult = 0) | RT ln(gamma_A^inf) = 28900.00 vs L0-L1+L2 = 28900.00

Explanation. Near x→0+x \to 0^+, u=1−2x→+1u = 1 - 2x \to +1, so Gex(x)≈x(L0+L1+L2)G^{\mathrm{ex}}(x) \approx x(L_0 + L_1 + L_2) while near x→1−x \to 1^-, u→−1u \to -1, so Gex(x)≈(1−x)(L0−L1+L2)G^{\mathrm{ex}}(x) \approx (1-x)(L_0 - L_1 + L_2). The direct physical meaning of L1L_1: when L1≠0L_1 \neq 0, the partial molar enthalpy of dissolving trace B into pure A (L0+L1+L2L_0 + L_1 + L_2) differs from dissolving trace A into pure B (L0−L1+L2L_0 - L_1 + L_2) by 2L12 L_1.


Exercise 2

Problem. Verify that pure-component endpoints x∈{0.0,1.0}x \in \{0.0, 1.0\} return exact zero mixing energy (dG_mix == 0.0) without 0 * (-inf) = NaN corruption in both regular_solution_free_energy and redlich_kister_free_energy, and confirm that invalid compositions (x=−0.01,1.02x = -0.01, 1.02) or T≤0T \leq 0 raise ValueError.


Exercise 2: Pure-Component Endpoint Limit Check (0 * log(0) == 0) & Input Validation Guards
===========================================================================================
Regular dG_mix([0, 1])        : [0. 0.] | dS_mix([0, 1]): [0. 0.]
Redlich-Kister dG_mix([0, 1]) : [0. 0.] | G_ex([0, 1])  : [0. 0.]
All endpoint limits and out-of-domain ValueError guards verified

Explanation. Evaluating x * np.log(x) directly at x = 0.0 in IEEE-754 floating point produces 0.0 * (-inf) = nan (plus RuntimeWarning), even though lim⁡x→0+xln⁡x=0\lim_{x \to 0^+} x\ln x = 0. Guarding pure endpoints with np.where((x > 0) & (x < 1), ..) preserves exact ΔGmix(0)=ΔGmix(1)=0\Delta G_{\mathrm{mix}}(0) = \Delta G_{\mathrm{mix}}(1) = 0 when building full [0,1][0, 1] convex-hull phase diagrams.


Exercise 3

Problem. Implement subregular_spinodal_roots(T_K, L0, L1, L2=0.0) to find the spinodal compositions where redlich_kister_free_energy(..., L0, L1, L2)['d2G_dx2'] == 0 via sign-change bracketing and 60-step bisection. Verify exact match with regular_solution_spinodal when L1=L2=0L_1 = L_2 = 0, and compute the skewed spinodal roots for (L0,L1)=(18 500,−6 000) J/mol(L_0, L_1) = (18\,500, -6\,000)\ \mathrm{J/mol} at T=850 KT = 850\ \mathrm{K}.


Exercise 3: Implement It Yourself — Asymmetric Subregular Spinodal Solver via Bisection
=======================================================================================
Symmetric (L1=0) roots      : (0.257117, 0.742883) -> midpoint = 0.5000
Skewed (L1=-6000) roots     : (0.396364, 0.873315) -> midpoint = 0.6348
Curvature |d2G/dx2| at roots: 7.276e-12 J/mol

Summary. A negative L1=−6 000 J/molL_1 = -6\,000\ \mathrm{J/mol} (an assumed value) shifts the midpoint of the spinodal from x=0.500x = 0.500 to x=0.635x = 0.635, so that spinodal decomposition is centred on the B-rich side.