ABSTRACT (original article): The present paper describes a numerical technique to compute phase equilibria of ternary liquid systems. First, particle swarm optimization is used to estimate the binary interaction parameters of the NRTL (Non-Random Two Liquid) and UNIQUAC (Universal Quasi-Chemical) models. We show how the arc-length continuation method allows the calculation of the liquid–liquid equilibrium diagram for any ternary system. A total of seven case studies of industrially important mixtures are described. Both Type I systems (oleic acid–water–ethanol, water–1-propanol–toluene, DEC–ethanol–water, water–propionic acid–n-hexane, and water–TMA–benzene) and Type II mixtures (water–1-butanol–n-hexane) are discussed. In addition, a system with temperature-dependent behavior (n-hexane–methyl cyclopentane–aniline) is studied. The numerical techniques and the thermodynamic problem involved in this paper are suitable for a first-year graduate-level course in chemical engineering. All computer coding is based either on Mathematica© or Matlab®. This is an ideal opportunity to introduce graduate students to advanced commands and programming syntax of state-of-the-art mathematical software. CITATION (original article): Binous, H., Mejbri, K., & Bellagi, A. (2021). Application of graduate-level numerical tools to teach phase equilibria of liquid ternary systems. Computer Applications in Engineering Education, 29(6), 1589–1601. https://doi.org/10.1002/cae.22411
We compute the LLE diagram and tie-lines for Aniline - Methyl-cyclopentane - Hexane at 25 °C and 1 atm . Calculations use NRTL activity coefficients and are based on a new approach, which is thoroughly described in Ref . 1-2.
aniline (component 1)
n-hexane (component 2)
methyl-cyclopentane (component 3)
aniline (component 1)
n-hexane (component 2)
methyl-cyclopentane (component 3)
NRTL model
NRTL model
In[]:=
TK=273.15+25;GAMMA1=Exp[(t21G21x2+t31G31x3)/(x1+G21x2+G31x3)+x1/(x1+G21x2+G31x3)(-(x2t21G21+x3t31G31)/(x1+G21x2+G31x3))+x2G12/(G12x1+x2+G32x3)(t12-(x1t12G12+x3t32G32)/(G12x1+x2+G32x3))+x3G13/(G13x1+G23x2+x3)(t13-(x1t13G13+x2t23G23)/(G13x1+G23x2+x3))]/.x31-x1-x2;GAMMA1p=Exp[(t21G21xp2+t31G31xp3)/(xp1+G21xp2+G31xp3)+xp1/(xp1+G21xp2+G31xp3)(-(xp2t21G21+xp3t31G31)/(xp1+G21xp2+G31xp3))+xp2G12/(G12xp1+xp2+G32xp3)(t12-(xp1t12G12+xp3t32G32)/(G12xp1+xp2+G32xp3))+xp3G13/(G13xp1+G23xp2+xp3)(t13-(xp1t13G13+xp2t23G23)/(G13xp1+G23xp2+xp3))]/.xp31-xp1-xp2;GAMMA2=Exp[(t12G12x1+t32G32x3)/(G12x1+x2+G32x3)+x1G21/(x1+G21x2+G31x3)(t21-(x2t21G21+x3t31G31)/(x1+G21x2+G31x3))+x2/(G12x1+x2+G32x3)(-(x1t12G12+x3t32G32)/(G12x1+x2+G32x3))+x3G23/(G13x1+G23x2+x3)(t23-(x1t13G13+x2t23G23)/(G13x1+G23x2+x3))]/.x31-x1-x2;GAMMA2p=Exp[(t12G12xp1+t32G32xp3)/(G12xp1+xp2+G32xp3)+xp1G21/(xp1+G21xp2+G31xp3)(t21-(xp2t21G21+xp3t31G31)/(xp1+G21xp2+G31xp3))+xp2/(G12xp1+xp2+G32xp3)(-(xp1t12G12+xp3t32G32)/(G12xp1+xp2+G32xp3))+xp3G23/(G13xp1+G23xp2+xp3)(t23-(xp1t13G13+xp2t23G23)/(G13xp1+G23xp2+xp3))]/.xp31-xp1-xp2;GAMMA3=Exp[(t13G13x1+t23G23x2)/(G13x1+G23x2+x3)+x1G31/(x1+G21x2+G31x3)(t31-(x2t21G21+x3t31G31)/(x1+G21x2+G31x3))+x2G32/(G12x1+x2+G32x3)(t32-(x1t12G12+x3t32G32)/(G12x1+x2+G32x3))+x3/(G13x1+G23x2+x3)(-(x1t13G13+x2t23G23)/(G13x1+G23x2+x3))]/.x31-x1-x2;GAMMA3p=Exp[(t13G13xp1+t23G23xp2)/(G13xp1+G23xp2+xp3)+xp1G31/(xp1+G21xp2+G31xp3)(t31-(xp2t21G21+xp3t31G31)/(xp1+G21xp2+G31xp3))+xp2G32/(G12xp1+xp2+G32xp3)(t32-(xp1t12G12+xp3t32G32)/(G12xp1+xp2+G32xp3))+xp3/(G13xp1+G23xp2+xp3)(-(xp1t13G13+xp2t23G23)/(G13xp1+G23xp2+xp3))]/.xp31-xp1-xp2;G12=Exp[-a12t12];G21=Exp[-a12t21];G13=Exp[-a13t13];G31=Exp[-a13t31];G32=Exp[-a32t32];G23=Exp[-a32t23];t13=A13+B13/TK;t23=A23+B23/TK;t12=A12+B12/TK;t32=A32+B32/TK;t31=A31+B31/TK;t21=A21+B21/TK;
Parameters for the NRTL model obtained from Aspen-Properties
Parameters for the NRTL model obtained from Aspen-Properties
In[]:=
param={a120.30,a130.20,a320.30,B212291.8179,B121410.9323,A12-2.8027,A21-5.2486,B23-153.9573,B32190.1605,A320.0,A230.0,B13857.3718,B312650.6843,A13-1.9693,A31-7.1321};
In[]:=
K={GAMMA1/GAMMA1p,GAMMA2/GAMMA2p,GAMMA3/GAMMA3p}/.param;
In[]:=
z={0.2,0.3,0.5};
In[]:=
sol=FindRoot(K[[i]]-1)z[[i]](1+(K[[i]]-1)ϕ)0,x1z[[1]](1+(K[[1]]-1)ϕ),x2z[[2]](1+(K[[2]]-1)ϕ),xp1K[[1]]z[[1]](1+(K[[1]]-1)ϕ),xp2K[[2]]z[[2]](1+(K[[2]]-1)ϕ),{ϕ,0.1,0.8},{x1,0.08,0.2},{x2,0.8,0.9},{xp1,0.9,0.8},{xp2,0.3,0.9}
3
∑
i=1
Out[]=
{ϕ0.139434,x10.097215,x20.342029,xp10.834375,xp20.0406023}
In[]:=
z={0.2,a,1-0.2-a}/.aa[s];
In[]:=
eq1=(K[[i]]-1)z[[i]]/(1+(K[[i]]-1)ϕ)0/.x1x1[s]/.x2x2[s]/.xp1xp1[s]/.xp2xp2[s]/.ϕϕ[s];
3
∑
i=1
In[]:=
eq2=x1z[[1]]/(1+(K[[1]]-1)ϕ)/.x1x1[s]/.x2x2[s]/.xp1xp1[s]/.xp2xp2[s]/.ϕϕ[s];eq3=x2z[[2]]/(1+(K[[2]]-1)ϕ)/.x1x1[s]/.x2x2[s]/.xp1xp1[s]/.xp2xp2[s]/.ϕϕ[s];eq4=xp1K[[1]]z[[1]]/(1+(K[[1]]-1)ϕ)/.x1x1[s]/.x2x2[s]/.xp1xp1[s]/.xp2xp2[s]/.ϕϕ[s];eq5=xp2K[[2]]z[[2]]/(1+(K[[2]]-1)ϕ)/.x1x1[s]/.x2x2[s]/.xp1xp1[s]/.xp2xp2[s]/.ϕϕ[s];
In[]:=
eq6=x1'[s]^2+x2'[s]^2+xp1'[s]^2+xp2'[s]^2+ϕ'[s]^2+a'[s]^21;
In[]:=
derivinit={x1'[0]0,x2'[0]0,xp1'[0]0,xp2'[0]0,ϕ'[0]1,a'[0]-0.4};
In[]:=
init={x1[0](x1/.sol),x2[0](x2/.sol),xp1[0](xp1/.sol),xp2[0](xp2/.sol),ϕ[0](ϕ/.sol),a[0]0.3};
In[]:=
system=Flatten[Join[{{eq1,eq2,eq3,eq4,eq5,eq6},derivinit,init}]];
In[]:=
SOL=Quiet@NDSolve[system,{x1,x2,xp1,xp2,ϕ,a},{s,-100,1000},AccuracyGoal->5]
Out[]=
x1InterpolatingFunction,x2InterpolatingFunction,xp1InterpolatingFunction,xp2InterpolatingFunction,ϕInterpolatingFunction,aInterpolatingFunction
In[]:=
tbl1=Flatten[Table[{x1[s],1-x1[s]-x2[s],x2[s]}/.SOL,{s,-3.6,400,0.02}],1];
In[]:=
tbl2=Flatten[Table[{xp1[s],1-xp1[s]-xp2[s],xp2[s]}/.SOL,{s,-3.6,400,0.02}],1];
In[]:=
p1=TernaryListPlot[{tbl1,tbl2},PlotRangeAll,GridLines->Automatic,PlotStyleThickness[0.0075],Joined->True,FrameLabel->{Style["Aniline",16],Style["C5H9CH3",16],Style["n-hexane",16]},PlotRange->All,Method->{"Backdrop"->Lighter[Yellow,.85]}];
25 Tie lines computed with Aspen-Properties
25 Tie lines computed with Aspen-Properties
In[]:=
tbltieaspen25={{"tie line",Style["aniline",Darker@Red],Style["C5H9CH3",Darker@Red],Style["n-hexane",Darker@Red],Style["aniline",Darker@Blue],Style["C5H9CH3",Darker@Blue],Style["n-hexane",Darker@Blue]},{1,0.0445971,0,0.9554029,0.9256509,0,0.0743491},{2,0.0470557,0.0388607,0.9140835,0.9208615,0.0064733,0.0726651},{3,0.0496065,0.0775272,0.8728662,0.9159358,0.0131367,0.0709274},{4,0.0522571,0.1159939,0.831749,0.910867,0.0200005,0.0691324},{5,0.0550162,0.154254,0.7907298,0.9056481,0.027076,0.0672759},{6,0.0578935,0.1922995,0.7498069,0.9002709,0.0343757,0.0653533},{7,0.0609005,0.2301204,0.708979,0.8947269,0.0419136,0.0633595},{8,0.06405,0.2677048,0.6682452,0.8890061,0.0497052,0.0612886},{9,0.0673566,0.3050379,0.6276055,0.8830976,0.0577682,0.0591341},{10,0.0708371,0.3421022,0.5870607,0.8769889,0.0661225,0.0568885},{11,0.0745109,0.3788762,0.5466128,0.8706658,0.0747908,0.0545433},{12,0.0783999,0.4153344,0.5062656,0.8641123,0.083799,0.0520886},{13,0.0825298,0.4514457,0.4660244,0.8573096,0.0931772,0.0495132},{14,0.0869303,0.4871723,0.4258973,0.8502359,0.1029604,0.0468036},{15,0.0916349,0.5224693,0.3858957,0.8428655,0.11319,0.0439445},{16,0.0966858,0.5572807,0.3460335,0.835169,0.1239138,0.0409171},{17,0.1021303,0.5915392,0.3063306,0.8271103,0.1351901,0.0376996},{18,0.1080256,0.6251619,0.2668125,0.8186462,0.1470886,0.0342651},{19,0.1144396,0.6580471,0.2275133,0.8097237,0.159695,0.0305812},{20,0.1214575,0.6900667,0.1884759,0.8002787,0.1731138,0.0266075},{21,0.1291816,0.7210608,0.1497576,0.7902298,0.1874769,0.0222933},{22,0.1377408,0.750826,0.1114333,0.779474,0.2029519,0.0175741},{23,0.1472986,0.7790993,0.0736021,0.7678778,0.2197558,0.0123663},{24,0.1580673,0.8055355,0.0363971,0.7552651,0.2381762,0.00655869},{25,0.1703292,0.8296708,0,0.7413963,0.2586037,0}};
In[]:=
TableForm[tbltieaspen25]
Out[]//TableForm=
tie line | aniline | C5H9CH3 | n-hexane | aniline | C5H9CH3 | n-hexane |
1 | 0.0445971 | 0 | 0.955403 | 0.925651 | 0 | 0.0743491 |
2 | 0.0470557 | 0.0388607 | 0.914084 | 0.920862 | 0.0064733 | 0.0726651 |
3 | 0.0496065 | 0.0775272 | 0.872866 | 0.915936 | 0.0131367 | 0.0709274 |
4 | 0.0522571 | 0.115994 | 0.831749 | 0.910867 | 0.0200005 | 0.0691324 |
5 | 0.0550162 | 0.154254 | 0.79073 | 0.905648 | 0.027076 | 0.0672759 |
6 | 0.0578935 | 0.1923 | 0.749807 | 0.900271 | 0.0343757 | 0.0653533 |
7 | 0.0609005 | 0.23012 | 0.708979 | 0.894727 | 0.0419136 | 0.0633595 |
8 | 0.06405 | 0.267705 | 0.668245 | 0.889006 | 0.0497052 | 0.0612886 |
9 | 0.0673566 | 0.305038 | 0.627606 | 0.883098 | 0.0577682 | 0.0591341 |
10 | 0.0708371 | 0.342102 | 0.587061 | 0.876989 | 0.0661225 | 0.0568885 |
11 | 0.0745109 | 0.378876 | 0.546613 | 0.870666 | 0.0747908 | 0.0545433 |
12 | 0.0783999 | 0.415334 | 0.506266 | 0.864112 | 0.083799 | 0.0520886 |
13 | 0.0825298 | 0.451446 | 0.466024 | 0.85731 | 0.0931772 | 0.0495132 |
14 | 0.0869303 | 0.487172 | 0.425897 | 0.850236 | 0.10296 | 0.0468036 |
15 | 0.0916349 | 0.522469 | 0.385896 | 0.842866 | 0.11319 | 0.0439445 |
16 | 0.0966858 | 0.557281 | 0.346034 | 0.835169 | 0.123914 | 0.0409171 |
17 | 0.10213 | 0.591539 | 0.306331 | 0.82711 | 0.13519 | 0.0376996 |
18 | 0.108026 | 0.625162 | 0.266813 | 0.818646 | 0.147089 | 0.0342651 |
19 | 0.11444 | 0.658047 | 0.227513 | 0.809724 | 0.159695 | 0.0305812 |
20 | 0.121458 | 0.690067 | 0.188476 | 0.800279 | 0.173114 | 0.0266075 |
21 | 0.129182 | 0.721061 | 0.149758 | 0.79023 | 0.187477 | 0.0222933 |
22 | 0.137741 | 0.750826 | 0.111433 | 0.779474 | 0.202952 | 0.0175741 |
23 | 0.147299 | 0.779099 | 0.0736021 | 0.767878 | 0.219756 | 0.0123663 |
24 | 0.158067 | 0.805536 | 0.0363971 | 0.755265 | 0.238176 | 0.00655869 |
25 | 0.170329 | 0.829671 | 0 | 0.741396 | 0.258604 | 0 |
Our Tie lines computed with Mathematica
Our Tie lines computed with Mathematica
In[]:=
i=1;While[i<=24,{solt[i]=FindRoot[(x2[s]/.SOL)==tbltieaspen25[[i+1]][[4]],{s,-0.4},MaxIterations->1000];Print[i," ",solt[i]];i++}]
1 {s-0.800272}
2 {s-0.746955}
3 {s-0.693717}
4 {s-0.640553}
5 {s-0.587458}
6 {s-0.534421}
7 {s-0.481435}
Ternary diagram for ANILINE/METHY-CYCLOPENTANE/HEXANE mixture
Ternary diagram for ANILINE/METHY-CYCLOPENTANE/HEXANE mixture
Tie lines with Aspen-Properties in blue; our tie lines using Mathematica are in red.
Ternary diagram for ANILINE/METHY-CYCLOPENTANE/HEXANE mixture (obtained with Aspen-Properties)
Ternary diagram for ANILINE/METHY-CYCLOPENTANE/HEXANE mixture (obtained with Aspen-Properties)
Partition of the solute (METHYL-CYCLOPENTANE) between ANILINE-rich and n-HEXANE-rich phases
Partition of the solute (METHYL-CYCLOPENTANE) between ANILINE-rich and n-HEXANE-rich phases
Blue Dots : Aspen-Properties; Red Curve : our calculated distribution line using method described in Ref . 1 - 2.
References
References
◼
[1] H. Binous and A. Bellagi, Calculation of ternary liquid-liquid equilibrium data using arc-length continuation. Engineering Reports. 2021; 3:e12296. https://doi.org/10.1002/eng2.12296
◼
[2] H. Binous , K. Mejbri , and A. Bellagi , Application of graduate-level numerical tools to teach phase equilibria of liquid ternary systems. Comput Appl Eng Educ. 2021; 29: 1589–1601. https://doi.org/10.1002/cae.22411
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Liquid-liquid equilibrium Diagram for Aniline - Methyl- cyclopentane - hexane at 25 °C and 1 atm
by Housam Binous and Ahmed Bellagi
Wolfram Community, STAFF PICKS, September 15, 2025
https://community.wolfram.com/groups/-/m/t/3545325
by Housam Binous and Ahmed Bellagi
Wolfram Community, STAFF PICKS, September 15, 2025
https://community.wolfram.com/groups/-/m/t/3545325