{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "8.31446261815324" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "using Statistics\n", "using CSV, DataFrames\n", "using Plots\n", "using Markdown\n", "using Printf\n", "\n", "gr()\n", "\n", "const R::Float64 = 8.31446261815324" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "regress (generic function with 1 method)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function regress(y::Vector, x::Vector)\n", " @assert (n = length(x)) == length(y) \"x and y must have the same length\"\n", " a1 = (n * sum(x .* y) - sum(x) * sum(y)) / (n * sum(x .^ 2) - sum(x)^2)\n", " a0 = mean(y) - a1 * mean(x)\n", " st = sum((y .- mean(y)) .^ 2)\n", " sr = sum((y .- a1 * x .- a0) .^ 2)\n", " r2 = (st - sr) / st\n", " return a0, a1, r2\n", "end" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "plot_all (generic function with 1 method)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pstyle = (\n", " color=\"#ff7f0e\", \n", " linewidth=3\n", ")\n", "scstyle = (\n", " marker=\"#636efa\",\n", ")\n", "\n", "xrange(x) = range(minimum(x), maximum(x), 501) |> collect\n", "\n", "function plot_all(_x, _y, x, y, f1, f2, a0, a1, r2; posx=0.35, posy=0.8)\n", " x1 = xrange(_x)\n", " y1 = f1.(x1)\n", " x2 = xrange(x)\n", " y2 = f2.(x2)\n", "\n", " txt = \"\\$Y =$(round(a0, sigdigits=8)) $(sign(a1) > 0 ? \"+\" : \"\")$(round(a1, sigdigits=8)) \\\\times X\\$\"\n", " txt2 = \"\\$ r^2 = $(r2) \\$\"\n", " mix, mxx = minimum(_x), maximum(_x)\n", " ranx = mxx - mix\n", " miy, mxy = minimum(_y), maximum(_y)\n", " rany = mxy - miy\n", "\n", " p = plot(size=(1200, 400), layout=(1, 2), legend=false)\n", " plot!(p, x1, y1, ; pstyle...)\n", " scatter!(p, _x, _y; scstyle...)\n", "\n", " plot!([mix + posx * ranx], [miy + posy * rany], text=txt)\n", " plot!([mix + posx * ranx], [miy + (posy - 0.1) * rany], text=txt2)\n", "\n", " plot!(p, x2, y2, subplot=2; pstyle...)\n", " scatter!(p, x, y, subplot=2; scstyle...)\n", " display(p)\n", "end" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
39×9 DataFrame
14 rows omitted
RowL_xL_delHmL_aTkFCC_xFCC_delHfFCC_aTkBCC_xBCC_delHfBCC_aPs
Float64Float64Float64Float64?Float64?Float64?Float64?Float64?Float64?
10.025360.00.0306190.025490.20.65390.63280.01.243
20.05696.00.0595690.05956.41.12090.6253140.01.1986
30.0751008.00.0870990.0751399.01.454180.652993.01.152
40.11297.00.113420.11819.01.69170.6752835.01.103
50.1251564.00.138750.1252217.01.860840.72670.01.0509
60.151807.00.163230.152593.01.98140.7252496.00.9955
70.1752029.00.187040.1752949.02.060.752313.00.9363
80.22230.00.210310.23285.02.12990.7752121.00.87283
90.2252409.00.233160.2253602.02.175950.81920.00.8045
100.252568.00.25570.253900.02.21140.8251710.00.7308
110.2752707.00.278020.2754179.02.24040.851493.00.6511
120.32826.00.300230.34442.02.2660.8751266.00.5646
130.3252926.00.322390.3254688.02.29060.91030.00.47053
280.72423.00.68096missingmissingmissingmissingmissingmissing
290.7252276.00.70736missingmissingmissingmissingmissingmissing
300.752118.00.73401missingmissingmissingmissingmissingmissing
310.7751949.00.76084missingmissingmissingmissingmissingmissing
320.81769.00.78782missingmissingmissingmissingmissingmissing
330.8251579.00.81489missingmissingmissingmissingmissingmissing
340.851379.00.84197missingmissingmissingmissingmissingmissing
350.8751170.00.86899missingmissingmissingmissingmissingmissing
360.9952.20.89586missingmissingmissingmissingmissingmissing
370.925725.60.9225missingmissingmissingmissingmissingmissing
380.95491.10.94881missingmissingmissingmissingmissingmissing
390.975249.10.97468missingmissingmissingmissingmissingmissing
" ], "text/latex": [ "\\begin{tabular}{r|ccccccccc}\n", "\t& L\\_x & L\\_delHm & L\\_aTk & FCC\\_x & FCC\\_delHf & FCC\\_aTk & BCC\\_x & BCC\\_delHf & \\\\\n", "\t\\hline\n", "\t& Float64 & Float64 & Float64 & Float64? & Float64? & Float64? & Float64? & Float64? & \\\\\n", "\t\\hline\n", "\t1 & 0.025 & 360.0 & 0.030619 & 0.025 & 490.2 & 0.6539 & 0.6 & 3280.0 & $\\dots$ \\\\\n", "\t2 & 0.05 & 696.0 & 0.059569 & 0.05 & 956.4 & 1.1209 & 0.625 & 3140.0 & $\\dots$ \\\\\n", "\t3 & 0.075 & 1008.0 & 0.087099 & 0.075 & 1399.0 & 1.45418 & 0.65 & 2993.0 & $\\dots$ \\\\\n", "\t4 & 0.1 & 1297.0 & 0.11342 & 0.1 & 1819.0 & 1.6917 & 0.675 & 2835.0 & $\\dots$ \\\\\n", "\t5 & 0.125 & 1564.0 & 0.13875 & 0.125 & 2217.0 & 1.86084 & 0.7 & 2670.0 & $\\dots$ \\\\\n", "\t6 & 0.15 & 1807.0 & 0.16323 & 0.15 & 2593.0 & 1.9814 & 0.725 & 2496.0 & $\\dots$ \\\\\n", "\t7 & 0.175 & 2029.0 & 0.18704 & 0.175 & 2949.0 & 2.06 & 0.75 & 2313.0 & $\\dots$ \\\\\n", "\t8 & 0.2 & 2230.0 & 0.21031 & 0.2 & 3285.0 & 2.1299 & 0.775 & 2121.0 & $\\dots$ \\\\\n", "\t9 & 0.225 & 2409.0 & 0.23316 & 0.225 & 3602.0 & 2.17595 & 0.8 & 1920.0 & $\\dots$ \\\\\n", "\t10 & 0.25 & 2568.0 & 0.2557 & 0.25 & 3900.0 & 2.2114 & 0.825 & 1710.0 & $\\dots$ \\\\\n", "\t11 & 0.275 & 2707.0 & 0.27802 & 0.275 & 4179.0 & 2.2404 & 0.85 & 1493.0 & $\\dots$ \\\\\n", "\t12 & 0.3 & 2826.0 & 0.30023 & 0.3 & 4442.0 & 2.266 & 0.875 & 1266.0 & $\\dots$ \\\\\n", "\t13 & 0.325 & 2926.0 & 0.32239 & 0.325 & 4688.0 & 2.2906 & 0.9 & 1030.0 & $\\dots$ \\\\\n", "\t14 & 0.35 & 3007.0 & 0.34458 & 0.35 & 4918.0 & 2.3158 & 0.925 & 785.6 & $\\dots$ \\\\\n", "\t15 & 0.375 & 3070.0 & 0.36686 & 0.375 & 5132.0 & 2.343 & 0.95 & 532.5 & $\\dots$ \\\\\n", "\t16 & 0.4 & 3115.0 & 0.38929 & 0.4 & 5332.0 & 2.3731 & 0.975 & 270.6 & $\\dots$ \\\\\n", "\t17 & 0.425 & 3142.0 & 0.41191 & 0.425 & 5518.0 & 2.40696 & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t18 & 0.45 & 3153.0 & 0.43476 & 0.45 & 5691.0 & 2.44507 & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t19 & 0.475 & 3147.0 & 0.45788 & 0.475 & 5851.0 & 2.4879 & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t20 & 0.5 & 3125.0 & 0.48131 & 0.5 & 6000.0 & 2.53582 & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t21 & 0.525 & 3087.0 & 0.50506 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t22 & 0.55 & 3034.0 & 0.52915 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t23 & 0.575 & 2966.0 & 0.55359 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t24 & 0.6 & 2884.0 & 0.57838 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t25 & 0.625 & 2789.0 & 0.60353 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t26 & 0.65 & 2679.0 & 0.62902 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t27 & 0.675 & 2557.0 & 0.65484 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t28 & 0.7 & 2423.0 & 0.68096 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t29 & 0.725 & 2276.0 & 0.70736 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t30 & 0.75 & 2118.0 & 0.73401 & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & \\emph{missing} & $\\dots$ \\\\\n", "\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & \\\\\n", "\\end{tabular}\n" ], "text/plain": [ "\u001b[1m39×9 DataFrame\u001b[0m\n", "\u001b[1m Row \u001b[0m│\u001b[1m L_x \u001b[0m\u001b[1m L_delHm \u001b[0m\u001b[1m L_aTk \u001b[0m\u001b[1m FCC_x \u001b[0m\u001b[1m FCC_delHf \u001b[0m\u001b[1m FCC_aTk \u001b[0m\u001b[1m BCC_\u001b[0m ⋯\n", " │\u001b[90m Float64 \u001b[0m\u001b[90m Float64 \u001b[0m\u001b[90m Float64 \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m Floa\u001b[0m ⋯\n", "─────┼──────────────────────────────────────────────────────────────────────────\n", " 1 │ 0.025 360.0 0.030619 0.025 490.2 0.6539 ⋯\n", " 2 │ 0.05 696.0 0.059569 0.05 956.4 1.1209\n", " 3 │ 0.075 1008.0 0.087099 0.075 1399.0 1.45418\n", " 4 │ 0.1 1297.0 0.11342 0.1 1819.0 1.6917\n", " 5 │ 0.125 1564.0 0.13875 0.125 2217.0 1.86084 ⋯\n", " 6 │ 0.15 1807.0 0.16323 0.15 2593.0 1.9814\n", " 7 │ 0.175 2029.0 0.18704 0.175 2949.0 2.06\n", " 8 │ 0.2 2230.0 0.21031 0.2 3285.0 2.1299\n", " 9 │ 0.225 2409.0 0.23316 0.225 3602.0 2.17595 ⋯\n", " 10 │ 0.25 2568.0 0.2557 0.25 3900.0 2.2114\n", " 11 │ 0.275 2707.0 0.27802 0.275 4179.0 2.2404\n", " ⋮ │ ⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋱\n", " 30 │ 0.75 2118.0 0.73401 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m\n", " 31 │ 0.775 1949.0 0.76084 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m ⋯\n", " 32 │ 0.8 1769.0 0.78782 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m\n", " 33 │ 0.825 1579.0 0.81489 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m\n", " 34 │ 0.85 1379.0 0.84197 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m\n", " 35 │ 0.875 1170.0 0.86899 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m ⋯\n", " 36 │ 0.9 952.2 0.89586 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m\n", " 37 │ 0.925 725.6 0.9225 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m\n", " 38 │ 0.95 491.1 0.94881 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m\n", " 39 │ 0.975 249.1 0.97468 \u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m missing \u001b[0m\u001b[90m miss\u001b[0m ⋯\n", "\u001b[36m 3 columns and 18 rows omitted\u001b[0m" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = CSV.File(\"data.csv\") |> DataFrame" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\subsubsection{Theory}\n", "$$L = L^0 + L^1(1-2x)$$\n", "$$L^0 = L^{00} + L^{01}T$$\n", "$$L^1 = L^{10} + L^{11}T$$\n", "$$\\Delta H_m = x(1-x)(L^{00}+L^{10}(1-2x))$$\n", "$$\\Delta H_f = x\\Delta °H_A^{\\text{ref} \\rightarrow \\beta} + (1-x)\\Delta H_B^{\\text{ref} \\rightarrow \\beta} + x(1-x)(L^{0}+L^{1}(1-2x))$$\n", "$$RT\\ln a = °G_A^{\\text{ref} \\rightarrow \\beta} + RT\\ln x + (1-x)^2(L^0 + L^1(1-4x)$$\n" ], "text/markdown": [ "### Theory\n", "\n", "$$\n", "L = L^0 + L^1(1-2x)\n", "$$\n", "\n", "$$\n", "L^0 = L^{00} + L^{01}T\n", "$$\n", "\n", "$$\n", "L^1 = L^{10} + L^{11}T\n", "$$\n", "\n", "$$\n", "\\Delta H_m = x(1-x)(L^{00}+L^{10}(1-2x))\n", "$$\n", "\n", "$$\n", "\\Delta H_f = x\\Delta °H_A^{\\text{ref} \\rightarrow \\beta} + (1-x)\\Delta H_B^{\\text{ref} \\rightarrow \\beta} + x(1-x)(L^{0}+L^{1}(1-2x))\n", "$$\n", "\n", "$$\n", "RT\\ln a = °G_A^{\\text{ref} \\rightarrow \\beta} + RT\\ln x + (1-x)^2(L^0 + L^1(1-4x)\n", "$$\n" ], "text/plain": [ "\u001b[1m Theory\u001b[22m\n", "\u001b[1m ––––––––\u001b[22m\n", "\n", "\u001b[35m L = L^0 + L^1(1-2x)\u001b[39m\n", "\n", "\u001b[35m L^0 = L^{00} + L^{01}T\u001b[39m\n", "\n", "\u001b[35m L^1 = L^{10} + L^{11}T\u001b[39m\n", "\n", "\u001b[35m \\Delta H_m = x(1-x)(L^{00}+L^{10}(1-2x))\u001b[39m\n", "\n", "\u001b[35m \\Delta H_f = x\\Delta °H_A^{\\text{ref} \\rightarrow \\beta} + (1-x)\\Delta H_B^{\\text{ref} \\rightarrow \\beta} + x(1-x)(L^{0}+L^{1}(1-2x))\u001b[39m\n", "\n", "\u001b[35m RT\\ln a = °G_A^{\\text{ref} \\rightarrow \\beta} + RT\\ln x + (1-x)^2(L^0 + L^1(1-4x)\u001b[39m" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "raw\"\"\"\n", "### Theory\n", "$$L = L^0 + L^1(1-2x)$$\n", "$$L^0 = L^{00} + L^{01}T$$\n", "$$L^1 = L^{10} + L^{11}T$$\n", "$$\\Delta H_m = x(1-x)(L^{00}+L^{10}(1-2x))$$\n", "$$\\Delta H_f = x\\Delta °H_A^{\\text{ref} \\rightarrow \\beta} + (1-x)\\Delta H_B^{\\text{ref} \\rightarrow \\beta} + x(1-x)(L^{0}+L^{1}(1-2x))$$\n", "$$RT\\ln a = °G_A^{\\text{ref} \\rightarrow \\beta} + RT\\ln x + (1-x)^2(L^0 + L^1(1-4x)$$\n", "\"\"\" |> Markdown.parse" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\subsubsection{Liquid}\n", "$$\\frac{\\Delta H_m}{x(1-x)} = L^{00} + L^{10}(1-2x)$$\n", "$$\\frac{RT\\ln a_{Tk} - RT\\ln x}{(1-x)^2} = L^0 + L^1(1-4x)$$\n" ], "text/markdown": [ "### Liquid\n", "\n", "$$\n", "\\frac{\\Delta H_m}{x(1-x)} = L^{00} + L^{10}(1-2x)\n", "$$\n", "\n", "$$\n", "\\frac{RT\\ln a_{Tk} - RT\\ln x}{(1-x)^2} = L^0 + L^1(1-4x)\n", "$$\n" ], "text/plain": [ "\u001b[1m Liquid\u001b[22m\n", "\u001b[1m ––––––––\u001b[22m\n", "\n", "\u001b[35m \\frac{\\Delta H_m}{x(1-x)} = L^{00} + L^{10}(1-2x)\u001b[39m\n", "\n", "\u001b[35m \\frac{RT\\ln a_{Tk} - RT\\ln x}{(1-x)^2} = L^0 + L^1(1-4x)\u001b[39m" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "raw\"\"\"\n", "### Liquid\n", "$$\\frac{\\Delta H_m}{x(1-x)} = L^{00} + L^{10}(1-2x)$$\n", "$$\\frac{RT\\ln a_{Tk} - RT\\ln x}{(1-x)^2} = L^0 + L^1(1-4x)$$\n", "\n", "\"\"\" |> Markdown.parse" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "ΔH mixing\n", "\n" ], "text/markdown": [ "ΔH mixing\n" ], "text/plain": [ " ΔH mixing" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "L00 = 12496.767885862411\n", "L10 = 2397.4627335963833\n", "r2 = 0.999997132004234\n" ] }, { "data": { "image/svg+xml": "\n\n" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/latex": [ "activity of Tk at 1500K\n", "\n" ], "text/markdown": [ "activity of Tk at 1500K\n" ], "text/plain": [ " activity of Tk at 1500K" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "L0 = 501.2778464221253\n", "L1 = 2405.8888107102252\n", "r2 = 0.9999746051487942\n" ] }, { "data": { "image/svg+xml": "\n\n" }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "L01 = -7.996993359626858\n", "L11 = 0.005617384742561323\n", "L = 12496.767886 + -7.996993T + (2397.462734 + 0.005617T)(1-2x)" ] } ], "source": [ "T = 1500\n", "x = df.L_x\n", "ΔHm = df.L_delHm\n", "a_Tk = df.L_aTk\n", "\n", "_y = @. ΔHm / (x * (1 - x))\n", "_x = @. 1 - 2 * x\n", "L00, L10, r2 = regress(_y, _x)\n", "md\"ΔH mixing\" |> display\n", "@show L00 L10 r2\n", "\n", "f1(_x) = L00 + L10*_x\n", "f2(x) = x*(1-x)*(L00 + L10*(1-2*x))\n", "plot_all(_x, _y, x, ΔHm, f1, f2, L00, L10, r2)\n", "\n", "_y = @. (R*T*log(a_Tk) - R*T*log(x))/(1-x)^2\n", "_x = @. 1 - 4*x\n", "L0, L1, r2 = regress(_y, _x)\n", "md\"activity of Tk at 1500K\" |> display\n", "@show L0 L1 r2\n", "\n", "f1(_x) = L0 + L1*_x\n", "f2(x) = exp((R*T*log(x) + (L0 + L1*(1-4*x))*(1-x)^2)/(R*T))\n", "plot_all(_x, _y, x, a_Tk, f1, f2, L0, L1, r2)\n", "\n", "L01 = (L0 - L00)/T\n", "L11 = (L1 - L10)/T\n", "@show L01 L11\n", "@printf \"L = %.6f + %.6fT + (%.6f + %.6fT)(1-2x)\" L00 L01 L10 L11" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\subsubsection{FCC}\n", "$$\\frac{\\Delta H_f^{FCC} - x\\Delta °G_{Tk}^{BCC \\rightarrow FCC} }{x(1-x)} = L^{00} + L^{10}(1-2x)$$\n", "$$\\frac{RT\\ln a_{Tk} - RT\\ln x - \\Delta °G_{Tk}^{BCC\\rightarrow FCC}}{(1-x)^2} = L^0 + L^1(1-4x)$$\n" ], "text/markdown": [ "### FCC\n", "\n", "$$\n", "\\frac{\\Delta H_f^{FCC} - x\\Delta °G_{Tk}^{BCC \\rightarrow FCC} }{x(1-x)} = L^{00} + L^{10}(1-2x)\n", "$$\n", "\n", "$$\n", "\\frac{RT\\ln a_{Tk} - RT\\ln x - \\Delta °G_{Tk}^{BCC\\rightarrow FCC}}{(1-x)^2} = L^0 + L^1(1-4x)\n", "$$\n" ], "text/plain": [ "\u001b[1m FCC\u001b[22m\n", "\u001b[1m –––––\u001b[22m\n", "\n", "\u001b[35m \\frac{\\Delta H_f^{FCC} - x\\Delta °G_{Tk}^{BCC \\rightarrow FCC} }{x(1-x)} = L^{00} + L^{10}(1-2x)\u001b[39m\n", "\n", "\u001b[35m \\frac{RT\\ln a_{Tk} - RT\\ln x - \\Delta °G_{Tk}^{BCC\\rightarrow FCC}}{(1-x)^2} = L^0 + L^1(1-4x)\u001b[39m" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "raw\"\"\"\n", "### FCC\n", "$$\\frac{\\Delta H_f^{FCC} - x\\Delta °G_{Tk}^{BCC \\rightarrow FCC} }{x(1-x)} = L^{00} + L^{10}(1-2x)$$\n", "$$\\frac{RT\\ln a_{Tk} - RT\\ln x - \\Delta °G_{Tk}^{BCC\\rightarrow FCC}}{(1-x)^2} = L^0 + L^1(1-4x)$$\n", "\"\"\" |> Markdown.parse" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "ΔH mixing\n", "\n" ], "text/markdown": [ "ΔH mixing\n" ], "text/plain": [ " ΔH mixing" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "L00 = 8997.620500253193\n", "L10 = 3599.98896194755\n", "r2 = 0.9999974319054352\n" ] }, { "data": { "image/svg+xml": "\n\n" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/latex": [ "activity of Tk at 600K\n", "\n" ], "text/markdown": [ "activity of Tk at 600K\n" ], "text/plain": [ " activity of Tk at 600K" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "L0 = 5998.430144016807\n", "L1 = 3598.6777708523755\n", "r2 = 0.9999921967821312\n" ] }, { "data": { "image/svg+xml": "\n\n" }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "L01 = -4.99865059372731\n", "L11 = -0.0021853184919571806\n", "L = 8997.620500 + -4.998651T + (3599.988962 + -0.002185T)(1-2x)" ] } ], "source": [ "T = 600\n", "G = 7500\n", "x = df.FCC_x |> skipmissing |> collect\n", "ΔHf = df.FCC_delHf |> skipmissing |> collect\n", "a_Tk = df.FCC_aTk |> skipmissing |> collect\n", "\n", "_y = @. (ΔHf - x*G)/(x*(1-x))\n", "_x = @. 1 - 2*x\n", "L00, L10, r2 = regress(_y, _x)\n", "md\"ΔH mixing\" |> display\n", "@show L00 L10 r2\n", "\n", "f1(_x) = L00 + L10*_x\n", "f2(x) = x*(1-x)*(L00 + L10*(1 - 2*x)) + x*G\n", "plot_all(_x, _y, x, ΔHf, f1, f2, L00, L10, r2)\n", "\n", "_y = @. (R*T*log(a_Tk) - R*T*log(x) - G)/(1-x)^2\n", "_x = @. 1 - 4*x\n", "L0, L1, r2 = regress(_y, _x)\n", "md\"activity of Tk at 600K\" |> display\n", "@show L0 L1 r2\n", "\n", "f1(_x) = L0 + L1*_x\n", "f2(x) = exp(((L0 + L1*(1-4*x))*(1-x)^2 + R*T*log(x) + G)/(R*T))\n", "plot_all(_x, _y, x, a_Tk, f1, f2, L0, L1, r2)\n", "\n", "L01 = (L0 - L00)/T\n", "L11 = (L1 - L10)/T\n", "@show L01 L11\n", "@printf \"L = %.6f + %.6fT + (%.6f + %.6fT)(1-2x)\" L00 L01 L10 L11" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\subsubsection{BCC}\n", "$$\\frac{\\Delta H_f^{BCC} - (1-x)\\Delta °G_{Ps}^{FCC \\rightarrow BCC} }{x(1-x)} = L^{00} + L^{10}(1-2x)$$\n", "$$\\frac{RT\\ln a_{Ps} - RT\\ln{(1-x)} - \\Delta °G_{Ps}^{FCC\\rightarrow BCC}}{x^2} = L^0 + L^1(4x - 3)$$\n" ], "text/markdown": [ "### BCC\n", "\n", "$$\n", "\\frac{\\Delta H_f^{BCC} - (1-x)\\Delta °G_{Ps}^{FCC \\rightarrow BCC} }{x(1-x)} = L^{00} + L^{10}(1-2x)\n", "$$\n", "\n", "$$\n", "\\frac{RT\\ln a_{Ps} - RT\\ln{(1-x)} - \\Delta °G_{Ps}^{FCC\\rightarrow BCC}}{x^2} = L^0 + L^1(4x - 3)\n", "$$\n" ], "text/plain": [ "\u001b[1m BCC\u001b[22m\n", "\u001b[1m –––––\u001b[22m\n", "\n", "\u001b[35m \\frac{\\Delta H_f^{BCC} - (1-x)\\Delta °G_{Ps}^{FCC \\rightarrow BCC} }{x(1-x)} = L^{00} + L^{10}(1-2x)\u001b[39m\n", "\n", "\u001b[35m \\frac{RT\\ln a_{Ps} - RT\\ln{(1-x)} - \\Delta °G_{Ps}^{FCC\\rightarrow BCC}}{x^2} = L^0 + L^1(4x - 3)\u001b[39m" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "raw\"\"\"\n", "### BCC\n", "$$\\frac{\\Delta H_f^{BCC} - (1-x)\\Delta °G_{Ps}^{FCC \\rightarrow BCC} }{x(1-x)} = L^{00} + L^{10}(1-2x)$$\n", "$$\\frac{RT\\ln a_{Ps} - RT\\ln{(1-x)} - \\Delta °G_{Ps}^{FCC\\rightarrow BCC}}{x^2} = L^0 + L^1(4x - 3)$$\n", "\"\"\" |> Markdown.parse" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "ΔH formation\n", "\n" ], "text/markdown": [ "ΔH formation\n" ], "text/plain": [ " ΔH formation" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "L00 = 6999.842480324455\n", "L10 = -0.8190938995497105\n", "r2 = 0.007056523427811438\n", "L00_real = 7000.313459316696\n", "L10_real = 0\n" ] }, { "data": { "image/svg+xml": "\n\n" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/latex": [ "activity of Ps at 600K\n", "\n" ], "text/markdown": [ "activity of Ps at 600K\n" ], "text/plain": [ " activity of Ps at 600K" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "L0 = 4599.889912227212\n", "L1 = -0.03289471962596187\n", "r2 = 0.0021664323858918426\n", "\n", "L0_real = 4599.884978019269\n", "L1_real = 0\n" ] }, { "data": { "image/svg+xml": "\n\n" }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "L01 = -3.999920946828738\n", "L11 = 0\n", "L = 6999.842480 + -3.999921T " ] } ], "source": [ "T = 600\n", "G = 4000\n", "x = df.BCC_x |> skipmissing |> collect\n", "ΔHf = df.BCC_delHf |> skipmissing |> collect\n", "a_Ps = df.BCC_aPs |> skipmissing |> collect\n", "\n", "_y = @. (ΔHf - (1 - x)*G)/(x*(1-x))\n", "_x = @. 1 - 2x\n", "L00, L10, r2 = regress(_y, _x)\n", "md\"ΔH formation\" |> display\n", "@show L00 L10 r2\n", "\n", "L00_real = mean(_y)\n", "L10_real = 0\n", "@show L00_real L10_real\n", "f1(_x) = L00 + L10 * _x\n", "f2(x) = (L00_real + L10_real*(1 - 2*x))*x*(1-x) + (1-x)*G\n", "plot_all(_x, _y, x, ΔHf, f1, f2, L00, L10, r2, posy=0.3)\n", "\n", "_y = @. (R*T*log(a_Ps) - R*T*log(1-x) - G)/x^2\n", "_x = @. 4x - 3\n", "L0, L1, r2 = regress(_y, _x)\n", "md\"activity of Ps at 600K\" |> display\n", "println()\n", "@show L0 L1 r2\n", "\n", "L0_real = mean(_y)\n", "L1_real = 0\n", "println()\n", "@show L0_real L1_real\n", "f1(_x) = L0 + L1*_x\n", "f2(x) = exp(((L0_real + L1_real*(4x - 3))*x^2 + G + R*T*log(1-x))/(R*T))\n", "plot_all(_x, _y, x, a_Ps, f1, f2, L0, L1, r2, posy=0.9)\n", "\n", "L01 = (L0 - L00)/T\n", "L11 = 0\n", "@show L01 L11\n", "@printf \"L = %.6f + %.6fT \" L00 L01" ] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.8.2", "language": "julia", "name": "julia-1.8" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.8.2" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" } } }, "nbformat": 4, "nbformat_minor": 2 }