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 Water - Benzene - Ethanol 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.
water (component 1)
Benzene (component 2)
Ethanol (component 3)
water (component 1)
Benzene (component 2)
Ethanol (component 3)
NRTL model
NRTL model
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+E12Log[TK];t32=A32+B32/TK;t31=A31+B31/TK;t21=A21+B21/TK+E21Log[TK];
Parameters for the NRTL model obtained from Aspen-Properties
Parameters for the NRTL model obtained from Aspen-Properties
In[]:=
param={a120.2,a130.30,a320.3,B21591.3676,B12-5954.3071,A12140.0874,A2145.1905,E12->-20.0254,E21->-7.5629,B23882.0288,B32-54.8044,A320.5686,A23-0.9155,B13-586.0809,B31246.18,A133.4578,A31-0.8009};
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.02,0.2},{x2,0.8,0.9},{xp1,0.4,0.8},{xp2,0.03,0.4}
3
∑
i=1
Out[]=
{ϕ0.812305,x10.00790957,x20.857002,xp10.244385,xp20.171296}
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,-1.6,500,0.02}],1];
In[]:=
tbl2=Flatten[Table[{xp1[s],1-xp1[s]-xp2[s],xp2[s]}/.SOL,{s,-1.6,500,0.02}],1];
In[]:=
p1=TernaryListPlot[{tbl1,tbl2},PlotRangeAll,GridLines->Automatic,PlotStyleThickness[0.0075],Joined->True,FrameLabel->{Style["Water",16],Style["Ethanol",16],Style["Benzene",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["water",Darker@Red],Style["benzene",Darker@Red],Style["ethanol",Darker@Red],Style["water",Darker@Blue],Style["benzene",Darker@Blue],Style["ethanol",Darker@Blue]},{1,0.00292922,0.9970708,0,0.9995945,0.000405531,0},{2,0.00317198,0.9883888,0.0084392,0.9793282,0.000573565,0.0200982},{3,0.00342417,0.9798555,0.0167203,0.9583126,0.000801183,0.0408861},{4,0.00368473,0.9714883,0.024827,0.9364474,0.00110718,0.0624454},{5,0.00395232,0.9633075,0.0327401,0.9136162,0.00151615,0.0848676},{6,0.00422524,0.9553364,0.0404383,0.8896848,0.0020604,0.1082548},{7,0.00450147,0.947601,0.0478975,0.8644986,0.00278266,0.1327188},{8,0.00477863,0.9401295,0.0550918,0.8378809,0.00373974,0.1583794},{9,0.00505404,0.9329516,0.0619943,0.8096321,0.0050075,0.1853604},{10,0.00532482,0.9260955,0.0685796,0.7795307,0.00668763,0.2137817},{11,0.00558806,0.9195849,0.074827,0.7473362,0.00891665,0.2437472},{12,0.00584117,0.9134332,0.0807256,0.7127962,0.0118777,0.2753261},{13,0.00608222,0.9076369,0.0862808,0.6756566,0.0158159,0.3085274},{14,0.0063104,0.9021666,0.0915229,0.6356754,0.0210577,0.3432669},{15,0.592638,0.0280352,0.3793268,0.00652641,0.8969586,0.096515},{16,0.5463723,0.0373188,0.4163089,0.00673274,0.8919056,0.1013617},{17,0.4967635,0.0496599,0.4535766,0.00693368,0.8868485,0.1062178},{18,0.4437696,0.066052,0.4901784,0.00713516,0.8815637,0.1113011},{19,0.3874461,0.0878225,0.5247314,0.00734438,0.8757407,0.1169149},{20,0.3279898,0.1167781,0.5552322,0.00756945,0.8689315,0.123499},{21,0.2658179,0.1554621,0.57872,0.00781876,0.8604354,0.1317458},{22,0.2017062,0.2076776,0.5906162,0.00809973,0.8490088,0.1428914},{23,0.1370363,0.2798099,0.5831538,0.00841514,0.832,0.1595849},{24,0.0742891,0.385604,0.5401069,0.00876032,0.8017045,0.1895351},{25,0.0164621,0.6092259,0.3743119,0.0102226,0.6982371,0.291540}};
In[]:=
TableForm[tbltieaspen25]
Out[]//TableForm=
tie line | water | benzene | ethanol | water | benzene | ethanol |
1 | 0.00292922 | 0.997071 | 0 | 0.999595 | 0.000405531 | 0 |
2 | 0.00317198 | 0.988389 | 0.0084392 | 0.979328 | 0.000573565 | 0.0200982 |
3 | 0.00342417 | 0.979856 | 0.0167203 | 0.958313 | 0.000801183 | 0.0408861 |
4 | 0.00368473 | 0.971488 | 0.024827 | 0.936447 | 0.00110718 | 0.0624454 |
5 | 0.00395232 | 0.963308 | 0.0327401 | 0.913616 | 0.00151615 | 0.0848676 |
6 | 0.00422524 | 0.955336 | 0.0404383 | 0.889685 | 0.0020604 | 0.108255 |
7 | 0.00450147 | 0.947601 | 0.0478975 | 0.864499 | 0.00278266 | 0.132719 |
8 | 0.00477863 | 0.94013 | 0.0550918 | 0.837881 | 0.00373974 | 0.158379 |
9 | 0.00505404 | 0.932952 | 0.0619943 | 0.809632 | 0.0050075 | 0.18536 |
10 | 0.00532482 | 0.926096 | 0.0685796 | 0.779531 | 0.00668763 | 0.213782 |
11 | 0.00558806 | 0.919585 | 0.074827 | 0.747336 | 0.00891665 | 0.243747 |
12 | 0.00584117 | 0.913433 | 0.0807256 | 0.712796 | 0.0118777 | 0.275326 |
13 | 0.00608222 | 0.907637 | 0.0862808 | 0.675657 | 0.0158159 | 0.308527 |
14 | 0.0063104 | 0.902167 | 0.0915229 | 0.635675 | 0.0210577 | 0.343267 |
15 | 0.592638 | 0.0280352 | 0.379327 | 0.00652641 | 0.896959 | 0.096515 |
16 | 0.546372 | 0.0373188 | 0.416309 | 0.00673274 | 0.891906 | 0.101362 |
17 | 0.496764 | 0.0496599 | 0.453577 | 0.00693368 | 0.886849 | 0.106218 |
18 | 0.44377 | 0.066052 | 0.490178 | 0.00713516 | 0.881564 | 0.111301 |
19 | 0.387446 | 0.0878225 | 0.524731 | 0.00734438 | 0.875741 | 0.116915 |
20 | 0.32799 | 0.116778 | 0.555232 | 0.00756945 | 0.868932 | 0.123499 |
21 | 0.265818 | 0.155462 | 0.57872 | 0.00781876 | 0.860435 | 0.131746 |
22 | 0.201706 | 0.207678 | 0.590616 | 0.00809973 | 0.849009 | 0.142891 |
23 | 0.137036 | 0.27981 | 0.583154 | 0.00841514 | 0.832 | 0.159585 |
24 | 0.0742891 | 0.385604 | 0.540107 | 0.00876032 | 0.801705 | 0.189535 |
25 | 0.0164621 | 0.609226 | 0.374312 | 0.0102226 | 0.698237 | 0.29154 |
Our Tie lines computed with Mathematica
Our Tie lines computed with Mathematica
In[]:=
i=1;While[i<=25,{solt[i]=FindRoot[(x2[s]/.SOL)==If[i<15,tbltieaspen25[[i+1]][[3]],tbltieaspen25[[i+1]][[6]]],{s,-1.0},MaxIterations->1000];Print[i," ",solt[i]];i++}]
1 {s-1.18596}
2 {s-1.16109}
3 {s-1.13559}
4 {s-1.10928}
5 {s-1.08208}
6 {s-1.0538}
7 {s-1.02428}
Ternary diagram for Water/Ethanol/Benzene mixture (obtained with Mathematica)
Ternary diagram for Water/Ethanol/Benzene mixture (obtained with Mathematica)
Tie lines with Aspen-Properties in blue; our tie lines using Mathematica are in red.
Tie lines with Aspen-Properties in blue; our tie lines using Mathematica are in red
Tie lines with Aspen-Properties in blue; our tie lines using Mathematica are in red
Partition of the solute (Ethanol) between organic and aqueous phase
Partition of the solute (Ethanol) between organic and aqueous phase
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 water - benzene - ethanol 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/3545311
by Housam Binous and Ahmed Bellagi
Wolfram Community, STAFF PICKS, September 15, 2025
https://community.wolfram.com/groups/-/m/t/3545311