Path: blob/main/latex-templates/templates/materials-science/phase_diagram.tex
51 views
unlisted
\documentclass[11pt,a4paper]{article}12% Document Setup3\usepackage[utf8]{inputenc}4\usepackage[T1]{fontenc}5\usepackage{lmodern}6\usepackage[margin=1in]{geometry}7\usepackage{amsmath,amssymb}8\usepackage{siunitx}9\usepackage{booktabs}10\usepackage{float}11\usepackage{caption}12\usepackage{hyperref}1314% PythonTeX Setup15\usepackage[makestderr]{pythontex}1617\title{Binary Phase Diagrams: Computational Analysis}18\author{Materials Engineering Laboratory}19\date{\today}2021\begin{document}22\maketitle2324\begin{abstract}25This report presents computational analysis of binary phase diagrams in materials science. We examine isomorphous and eutectic systems, the lever rule for phase fraction calculations, cooling curve analysis, and Gibbs phase rule applications. Python-based computations provide quantitative analysis with dynamic visualization.26\end{abstract}2728\tableofcontents29\newpage3031\section{Introduction to Phase Diagrams}3233Phase diagrams are graphical representations of the equilibrium phases present in a material system as a function of temperature, pressure, and composition. They are essential for:34\begin{itemize}35\item Predicting microstructure evolution during solidification36\item Designing heat treatment processes37\item Understanding alloy behavior and properties38\item Optimizing casting and welding procedures39\end{itemize}4041% Initialize Python environment42\begin{pycode}43import numpy as np44import matplotlib.pyplot as plt45from scipy.optimize import fsolve46from scipy.interpolate import interp1d4748plt.rcParams['figure.figsize'] = (8, 5)49plt.rcParams['font.size'] = 1050plt.rcParams['text.usetex'] = True5152def save_fig(filename):53plt.savefig(filename, dpi=150, bbox_inches='tight')54plt.close()55\end{pycode}5657\section{Gibbs Phase Rule}5859The Gibbs phase rule determines the degrees of freedom in a system:60\begin{equation}61F = C - P + 262\end{equation}63where $F$ is degrees of freedom, $C$ is number of components, and $P$ is number of phases.6465For a binary system ($C=2$) at constant pressure:66\begin{equation}67F = 3 - P68\end{equation}6970\begin{pycode}71# Gibbs phase rule visualization72phases = [1, 2, 3]73freedom = [3 - p for p in phases]7475fig, ax = plt.subplots(figsize=(8, 5))7677bars = ax.bar(phases, freedom, color=['green', 'blue', 'red'], alpha=0.7)78ax.set_xlabel('Number of Phases (P)')79ax.set_ylabel('Degrees of Freedom (F)')80ax.set_title('Gibbs Phase Rule for Binary System at Constant Pressure')81ax.set_xticks(phases)8283for bar, f in zip(bars, freedom):84ax.text(bar.get_x() + bar.get_width()/2, bar.get_height() + 0.1,85f'F = {f}', ha='center', fontsize=12)8687ax.grid(True, alpha=0.3, axis='y')88save_fig('gibbs_phase_rule.pdf')89\end{pycode}9091\begin{figure}[H]92\centering93\includegraphics[width=0.7\textwidth]{gibbs_phase_rule.pdf}94\caption{Gibbs phase rule showing degrees of freedom for different numbers of phases.}95\end{figure}9697\section{Isomorphous System}9899An isomorphous system exhibits complete solid solubility. The Cu-Ni system is a classic example.100101\begin{pycode}102# Cu-Ni isomorphous phase diagram103# Liquidus and solidus curves (simplified model)104x_Ni = np.linspace(0, 100, 200) # wt% Ni105106# Melting points: Cu = 1085 C, Ni = 1455 C107T_Cu = 1085108T_Ni = 1455109110# Liquidus curve (quadratic model)111T_liquidus = T_Cu + (T_Ni - T_Cu) * (x_Ni/100) + 20 * (x_Ni/100) * (1 - x_Ni/100)112113# Solidus curve (offset from liquidus)114T_solidus = T_Cu + (T_Ni - T_Cu) * (x_Ni/100) - 30 * (x_Ni/100) * (1 - x_Ni/100)115116fig, ax = plt.subplots(figsize=(10, 7))117118ax.plot(x_Ni, T_liquidus, 'b-', linewidth=2, label='Liquidus')119ax.plot(x_Ni, T_solidus, 'r-', linewidth=2, label='Solidus')120121# Fill regions122ax.fill_between(x_Ni, T_liquidus, 1500, alpha=0.3, color='yellow', label='Liquid (L)')123ax.fill_between(x_Ni, T_solidus, 900, alpha=0.3, color='lightblue', label='Solid ($\\alpha$)')124ax.fill_between(x_Ni, T_solidus, T_liquidus, alpha=0.3, color='lightgreen', label='L + $\\alpha$')125126# Tie line example127x_0 = 40 # Overall composition128T_tie = 1250129idx_liq = np.argmin(np.abs(T_liquidus - T_tie))130idx_sol = np.argmin(np.abs(T_solidus - T_tie))131x_L = x_Ni[idx_liq]132x_alpha = x_Ni[idx_sol]133134ax.plot([x_L, x_alpha], [T_tie, T_tie], 'k-', linewidth=2)135ax.plot(x_0, T_tie, 'ko', markersize=10)136ax.plot(x_L, T_tie, 'bo', markersize=8)137ax.plot(x_alpha, T_tie, 'ro', markersize=8)138139ax.annotate(f'$C_0$ = {x_0}\\%', (x_0, T_tie), xytext=(x_0+5, T_tie+30),140fontsize=10, arrowprops=dict(arrowstyle='->', color='black'))141142ax.set_xlabel('Composition (wt\\% Ni)')143ax.set_ylabel('Temperature ($^\\circ$C)')144ax.set_title('Cu-Ni Isomorphous Phase Diagram')145ax.legend(loc='upper left')146ax.set_xlim(0, 100)147ax.set_ylim(900, 1500)148ax.grid(True, alpha=0.3)149150save_fig('isomorphous_diagram.pdf')151\end{pycode}152153\begin{figure}[H]154\centering155\includegraphics[width=\textwidth]{isomorphous_diagram.pdf}156\caption{Cu-Ni isomorphous phase diagram with tie line construction at $T = 1250^{\circ}$C.}157\end{figure}158159\section{The Lever Rule}160161The lever rule calculates phase fractions in a two-phase region:162\begin{equation}163W_{\alpha} = \frac{C_L - C_0}{C_L - C_{\alpha}} \quad \text{and} \quad W_L = \frac{C_0 - C_{\alpha}}{C_L - C_{\alpha}}164\end{equation}165166\begin{pycode}167# Lever rule calculation168C_0 = 40 # Overall composition169T_analysis = np.linspace(T_solidus[int(C_0*2)], T_liquidus[int(C_0*2)], 50)170171# Interpolate liquidus and solidus172f_liquidus = interp1d(T_liquidus, x_Ni)173f_solidus = interp1d(T_solidus, x_Ni)174175W_liquid = []176W_solid = []177temps = []178179for T in T_analysis:180# Find compositions at this temperature181try:182C_L = f_liquidus(T)183C_alpha = f_solidus(T)184if C_L > C_alpha:185w_L = (C_0 - C_alpha) / (C_L - C_alpha)186w_alpha = (C_L - C_0) / (C_L - C_alpha)187W_liquid.append(w_L * 100)188W_solid.append(w_alpha * 100)189temps.append(T)190except:191pass192193fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))194195# Phase fractions vs temperature196ax1.plot(temps, W_liquid, 'b-', linewidth=2, label='Liquid')197ax1.plot(temps, W_solid, 'r-', linewidth=2, label='Solid ($\\alpha$)')198ax1.set_xlabel('Temperature ($^\\circ$C)')199ax1.set_ylabel('Phase Fraction (\\%)')200ax1.set_title(f'Phase Fractions during Cooling ($C_0$ = {C_0}\\% Ni)')201ax1.legend()202ax1.grid(True, alpha=0.3)203204# Lever rule visualization205T_demo = 1250206C_L_demo = 35207C_alpha_demo = 48208C_0_demo = 40209210ax2.plot([0, 100], [0, 0], 'k-', linewidth=3)211ax2.plot(C_L_demo, 0, 'b^', markersize=15, label=f'Liquid ({C_L_demo}\\%)')212ax2.plot(C_alpha_demo, 0, 'rs', markersize=15, label=f'Solid ({C_alpha_demo}\\%)')213ax2.plot(C_0_demo, 0, 'go', markersize=12, label=f'Overall ({C_0_demo}\\%)')214215# Lever arms216ax2.annotate('', xy=(C_L_demo, 0.2), xytext=(C_0_demo, 0.2),217arrowprops=dict(arrowstyle='<->', color='blue', lw=2))218ax2.text((C_L_demo+C_0_demo)/2, 0.3, f'{C_0_demo-C_L_demo}', ha='center', fontsize=12, color='blue')219220ax2.annotate('', xy=(C_0_demo, -0.2), xytext=(C_alpha_demo, -0.2),221arrowprops=dict(arrowstyle='<->', color='red', lw=2))222ax2.text((C_0_demo+C_alpha_demo)/2, -0.3, f'{C_alpha_demo-C_0_demo}', ha='center', fontsize=12, color='red')223224W_L_calc = (C_0_demo - C_L_demo)/(C_alpha_demo - C_L_demo) * 100225W_alpha_calc = (C_alpha_demo - C_0_demo)/(C_alpha_demo - C_L_demo) * 100226227ax2.set_xlim(20, 60)228ax2.set_ylim(-0.6, 0.6)229ax2.set_xlabel('Composition (wt\\% Ni)')230ax2.set_title(f'Lever Rule: $W_L$ = {W_L_calc:.1f}\\%, $W_\\alpha$ = {W_alpha_calc:.1f}\\%')231ax2.legend(loc='upper right')232ax2.set_yticks([])233234save_fig('lever_rule.pdf')235\end{pycode}236237\begin{figure}[H]238\centering239\includegraphics[width=\textwidth]{lever_rule.pdf}240\caption{Lever rule analysis: phase fractions during cooling and graphical representation.}241\end{figure}242243\section{Eutectic System}244245A eutectic system has limited solid solubility. The Pb-Sn system is a classic example.246247\begin{pycode}248# Pb-Sn eutectic phase diagram249x_Sn = np.linspace(0, 100, 500)250251# Key points252T_Pb = 327 # Melting point of Pb253T_Sn = 232 # Melting point of Sn254T_E = 183 # Eutectic temperature255x_E = 61.9 # Eutectic composition256x_alpha_max = 19 # Max solubility in alpha257x_beta_max = 97.5 # Max solubility in beta258259# Liquidus curves260T_liq_left = T_Pb - (T_Pb - T_E) * (x_Sn / x_E)**1.2261T_liq_right = T_Sn - (T_Sn - T_E) * ((100 - x_Sn) / (100 - x_E))**1.2262T_liquidus = np.where(x_Sn <= x_E, T_liq_left, T_liq_right)263264# Solidus curves (solvus)265T_sol_alpha = T_E + (T_Pb - T_E) * ((x_alpha_max - x_Sn) / x_alpha_max)**2266T_sol_beta = T_E + (T_Sn - T_E) * ((x_Sn - x_beta_max) / (100 - x_beta_max))**2267268fig, ax = plt.subplots(figsize=(10, 8))269270# Liquidus271ax.plot(x_Sn, T_liquidus, 'b-', linewidth=2.5, label='Liquidus')272273# Solidus (solvus) lines274x_alpha = x_Sn[x_Sn <= x_alpha_max]275ax.plot(x_alpha, T_sol_alpha[x_Sn <= x_alpha_max], 'r-', linewidth=2)276x_beta = x_Sn[x_Sn >= x_beta_max]277ax.plot(x_beta, T_sol_beta[x_Sn >= x_beta_max], 'r-', linewidth=2)278279# Eutectic isotherm280ax.plot([x_alpha_max, x_beta_max], [T_E, T_E], 'k-', linewidth=2)281282# Labels for regions283ax.text(10, 280, 'L', fontsize=14, fontweight='bold')284ax.text(8, 100, '$\\alpha$', fontsize=14, fontweight='bold')285ax.text(88, 100, '$\\beta$', fontsize=14, fontweight='bold')286ax.text(50, 100, '$\\alpha + \\beta$', fontsize=14, fontweight='bold')287ax.text(30, 220, 'L + $\\alpha$', fontsize=12)288ax.text(75, 210, 'L + $\\beta$', fontsize=12)289290# Eutectic point291ax.plot(x_E, T_E, 'ko', markersize=10)292ax.annotate(f'Eutectic\\n({x_E}\\%, {T_E}$^\\circ$C)',293(x_E, T_E), xytext=(x_E-20, T_E-40), fontsize=10)294295ax.set_xlabel('Composition (wt\\% Sn)')296ax.set_ylabel('Temperature ($^\\circ$C)')297ax.set_title('Pb-Sn Eutectic Phase Diagram')298ax.set_xlim(0, 100)299ax.set_ylim(0, 350)300ax.grid(True, alpha=0.3)301302save_fig('eutectic_diagram.pdf')303\end{pycode}304305\begin{figure}[H]306\centering307\includegraphics[width=\textwidth]{eutectic_diagram.pdf}308\caption{Pb-Sn eutectic phase diagram showing liquid, solid, and two-phase regions.}309\end{figure}310311\section{Cooling Curves}312313Cooling curves reveal phase transformations through thermal arrests.314315\begin{pycode}316# Cooling curves for different compositions317compositions = [10, 40, 61.9, 80] # wt% Sn318colors = ['blue', 'green', 'red', 'purple']319320fig, axes = plt.subplots(2, 2, figsize=(12, 10))321322for comp, color, ax in zip(compositions, colors, axes.flat):323# Generate cooling curve324time = np.linspace(0, 600, 1000)325326if comp < x_E: # Hypoeutectic327T_start = 350328T_liq = T_Pb - (T_Pb - T_E) * (comp / x_E)**1.2329330# Cooling stages331t1 = 100 # Start of solidification332t2 = 300 # End of primary solidification333t3 = 400 # End of eutectic solidification334335T = np.piecewise(time,336[time < t1, (time >= t1) & (time < t2), (time >= t2) & (time < t3), time >= t3],337[lambda t: T_start - (T_start - T_liq) * t/t1,338lambda t: T_liq - (T_liq - T_E) * (t - t1)/(t2 - t1) * 0.8,339T_E,340lambda t: T_E - (t - t3) * 0.3])341342elif comp > x_E: # Hypereutectic343T_start = 280344T_liq = T_Sn - (T_Sn - T_E) * ((100 - comp) / (100 - x_E))**1.2345346t1 = 80347t2 = 250348t3 = 350349350T = np.piecewise(time,351[time < t1, (time >= t1) & (time < t2), (time >= t2) & (time < t3), time >= t3],352[lambda t: T_start - (T_start - T_liq) * t/t1,353lambda t: T_liq - (T_liq - T_E) * (t - t1)/(t2 - t1) * 0.8,354T_E,355lambda t: T_E - (t - t3) * 0.3])356357else: # Eutectic358T_start = 220359t1 = 50360t2 = 300361362T = np.piecewise(time,363[time < t1, (time >= t1) & (time < t2), time >= t2],364[lambda t: T_start - (T_start - T_E) * t/t1,365T_E,366lambda t: T_E - (t - t2) * 0.3])367368ax.plot(time, T, color=color, linewidth=2)369ax.axhline(T_E, color='k', linestyle='--', alpha=0.5)370ax.set_xlabel('Time (s)')371ax.set_ylabel('Temperature ($^\\circ$C)')372ax.set_title(f'{comp}\\% Sn')373ax.grid(True, alpha=0.3)374375# Annotate thermal arrests376if comp == 61.9:377ax.annotate('Eutectic arrest', (175, T_E), xytext=(300, T_E+30),378arrowprops=dict(arrowstyle='->', color='black'))379380plt.suptitle('Cooling Curves for Pb-Sn Alloys', fontsize=14, y=1.02)381plt.tight_layout()382save_fig('cooling_curves.pdf')383\end{pycode}384385\begin{figure}[H]386\centering387\includegraphics[width=\textwidth]{cooling_curves.pdf}388\caption{Cooling curves for hypoeutectic (10\%, 40\%), eutectic (61.9\%), and hypereutectic (80\%) Pb-Sn alloys.}389\end{figure}390391\section{Microstructure Evolution}392393\begin{pycode}394# Microstructure composition analysis395# For 40 wt% Sn alloy at different stages396397C_0 = 40 # Overall composition398stages = ['Just below liquidus', 'Above eutectic', 'Below eutectic']399T_stages = [260, 190, 100]400401fig, axes = plt.subplots(1, 3, figsize=(14, 4))402403for ax, stage, T in zip(axes, stages, T_stages):404if T > T_E:405# Two-phase: L + alpha406W_alpha = 60 # Approximate407W_L = 40408sizes = [W_alpha, W_L]409labels = ['$\\alpha$', 'L']410colors_pie = ['lightblue', 'yellow']411else:412# Three phases present (but at equilibrium: alpha + beta)413# Primary alpha + eutectic mixture414W_primary = 55415W_eutectic = 45416sizes = [W_primary, W_eutectic]417labels = ['Primary $\\alpha$', 'Eutectic ($\\alpha + \\beta$)']418colors_pie = ['lightblue', 'lightgreen']419420ax.pie(sizes, labels=labels, colors=colors_pie, autopct='%1.1f%%',421startangle=90)422ax.set_title(f'{stage}\\n(T = {T}$^\\circ$C)')423424plt.suptitle(f'Microstructure Evolution for {C_0}\\% Sn Alloy', fontsize=12)425plt.tight_layout()426save_fig('microstructure_evolution.pdf')427\end{pycode}428429\begin{figure}[H]430\centering431\includegraphics[width=\textwidth]{microstructure_evolution.pdf}432\caption{Microstructure evolution during cooling of 40\% Sn alloy.}433\end{figure}434435\section{Phase Fraction Calculations}436437\begin{pycode}438# Complete phase fraction analysis at room temperature439compositions = np.linspace(0, 100, 100)440T_room = 25441442# At room temperature: alpha + beta region443# Alpha: ~2% Sn, Beta: ~99% Sn444C_alpha = 2445C_beta = 99446447W_alpha_arr = (C_beta - compositions) / (C_beta - C_alpha) * 100448W_beta_arr = (compositions - C_alpha) / (C_beta - C_alpha) * 100449450fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))451452ax1.plot(compositions, W_alpha_arr, 'b-', linewidth=2, label='$\\alpha$ phase')453ax1.plot(compositions, W_beta_arr, 'r-', linewidth=2, label='$\\beta$ phase')454ax1.axvline(x_E, color='k', linestyle='--', alpha=0.5, label='Eutectic')455ax1.set_xlabel('Composition (wt\\% Sn)')456ax1.set_ylabel('Phase Fraction (\\%)')457ax1.set_title('Equilibrium Phase Fractions at Room Temperature')458ax1.legend()459ax1.grid(True, alpha=0.3)460461# Primary vs eutectic fractions462W_primary_alpha = np.maximum(0, (x_E - compositions) / (x_E - x_alpha_max) * 100)463W_primary_beta = np.maximum(0, (compositions - x_E) / (x_beta_max - x_E) * 100)464W_eutectic = 100 - W_primary_alpha - W_primary_beta465466ax2.fill_between(compositions, 0, W_primary_alpha, alpha=0.5, label='Primary $\\alpha$')467ax2.fill_between(compositions, W_primary_alpha, W_primary_alpha + W_eutectic,468alpha=0.5, label='Eutectic')469ax2.fill_between(compositions, W_primary_alpha + W_eutectic, 100,470alpha=0.5, label='Primary $\\beta$')471ax2.set_xlabel('Composition (wt\\% Sn)')472ax2.set_ylabel('Microconstituent Fraction (\\%)')473ax2.set_title('Microconstituent Fractions')474ax2.legend()475ax2.grid(True, alpha=0.3)476477plt.tight_layout()478save_fig('phase_fractions.pdf')479\end{pycode}480481\begin{figure}[H]482\centering483\includegraphics[width=\textwidth]{phase_fractions.pdf}484\caption{Phase fractions and microconstituent analysis for Pb-Sn system.}485\end{figure}486487\section{Summary Table}488489\begin{table}[H]490\centering491\caption{Key Phase Diagram Parameters for Pb-Sn System}492\begin{tabular}{lcc}493\toprule494Parameter & Value & Units \\495\midrule496Eutectic temperature & \py{f"{T_E}"} & $^{\circ}$C \\497Eutectic composition & \py{f"{x_E}"} & wt\% Sn \\498Max solubility in $\alpha$ & \py{f"{x_alpha_max}"} & wt\% Sn \\499Max solubility in $\beta$ & \py{f"{x_beta_max}"} & wt\% Sn \\500Melting point of Pb & \py{f"{T_Pb}"} & $^{\circ}$C \\501Melting point of Sn & \py{f"{T_Sn}"} & $^{\circ}$C \\502\bottomrule503\end{tabular}504\end{table}505506\section{Conclusions}507508This analysis demonstrates key aspects of binary phase diagrams:509\begin{enumerate}510\item The Gibbs phase rule determines degrees of freedom in multi-phase systems511\item Isomorphous systems show complete solid solubility with smooth liquidus/solidus curves512\item The lever rule enables quantitative calculation of phase fractions513\item Eutectic systems exhibit invariant reactions at fixed temperature and composition514\item Cooling curves reveal thermal arrests during phase transformations515\item Microstructure depends on both equilibrium phases and solidification path516\end{enumerate}517518\end{document}519520521