kill(all);

maxima:Construct  Pxy diagram Chloroform(1) & hexane(2  ) (= Mixture),version 1.0
peter.vlasschaert@gmail.com,30/08/2020

load packages , option.
===================

load(lrats)$ ratprint:false$

see: website
maxima:Construct Txy diagram Chloroform & hexane (= Mixture),version 1.0,part 1

How construct Pxy diagram
======================

xp1:[0,0.002,0.004,0.006,0.008,0.01,0.015,0.02,0.04,0.06,0.08,0.1,0.12,0.14,0.16,
    0.18,0.2,0.22,0.24,0.26,0.28,0.3,0.32,0.34,0.36,0.38,0.4,0.42,0.44,0.46,0.48,
    0.5,0.52,0.54,0.56,0.5800000000000001,0.6,0.62,0.64,0.66,0.68,0.7000000000000001,
    0.7200000000000001,0.74,0.76,0.78,0.8,0.8200000000000001,0.8400000000000001,0.86,
    0.88,0.9,0.92,0.93,0.94,0.95,0.96,0.97,0.98,0.985,0.99,0.995,1]$

xpa:length(xp1);

binary system ( = 2 components , 1e) Chloroforom 'xp1';2e)hexane,'xp2' )
----------------------------------------------------------------------------------------------------
dataset :xp1[i] + xp2[i] = 1 ,i =1,2,...,xpa

xp2:makelist(1-xp1[i],i,1,xpa);

Given : ( Pxy diagram    T (= Kelven) = fixed value)
======================================
rem : Txy diagram , P =fixed

T = given
-------------

T : 318;

parameters = Wilson Equation
------------------------------------------

G12:1.2042 $ G21:0.39799 $

Definition : 'Antoine equation : binary system = 2 equations'
----------------------------------------------------------------------------------
ts : 'K =kelvin'  (°C =degree of Celsius     K  = 273,15 + °C )

p1sat(ts):= exp(9.33984-2696.79/(ts-46.14))$/*chloroform*/
p2sat(ts):= exp(9.20324-2697.55/(ts-48.78))$/*hexane    */

use : T = fixed,see 'above'

p1vap:ev(p1sat(T));
p2vap:ev(p2sat(T));

Evaluation :activity coefficients ( = list structure  , ≠  Txy  diagram:see website)
----------------------------------------------------------------------------------------------------------------
makelist system: (dimension = xpa),ordinary language , use : "for next: i=1 to xpa"

term1:makelist(xp1[i]+xp2[i]*G12,i,1,xpa);
term2:makelist(xp2[i]+xp1[i]*G21,i,1,xpa);

q1[i]:=exp(-log(term1[i])+ xp2[i]*(G12/term1[i]-G21/term2[i]))$
q2[i]:=exp(-log(term2[i])+ xp1[i]*(G21/term2[i]-G12/term1[i]))$

γ_1:makelist(q1[i],i,1,xpa)$
γ_2:makelist(q2[i],i,1,xpa)$

partial pressure ( p1 :chloroform,;p2:hexane ),binary system
---------------------------------------------------------------------------------
{p1,p2}:list (dimension =xpa)  
total pressure = P  (use list )
P[i] =p1[i]+p2[i] 

qq1[i]:=xp1[i]*γ_1[i]*p1vap$
qq2[i]:=xp2[i]*γ_2[i]*p2vap$
p1:makelist(qq1[i],i,1,xpa);
p2:makelist(qq2[i],i,1,xpa);

yp1=vapour pressure ( chloroform (1)), ' list structure '
------------------------------------------------------------------------
yp1[i] = p1[i]/P[i] , i=1..xpa ,construction easy to use 'for next structure'

total pressure ( = list)

P:makelist(p1[i]+p2[i],i,1,xpa);

yp1:makelist(p1[i]/(p1[i]+p2[i]),i,1,xpa);

make plot2d , 'Pxy , fixed : T =318 K'
---------------------------------------------------
How to plot2d ( = wxplot2d, plot inside the document)
see :website
maxima:Construct Txy diagram Chloroform & hexane (= Mixture),version 1.0,part 3,graph
peter.vlasschaert@gmail.com,30/08/2020

p2a:['discrete,xp1,P]$ /*liquid , composition */
p2b:['discrete,yp1,P]$ /*vapour , composition */

simple :graph
--------------------

wxplot2d([p2a,p2b]);

Txy diagram : lmin 'Maxima', Pxy : lmax
------------------------------------------------------
use : P[i] : som of partial pressure.
Txy diagram : temperature minimum => Pxy diagram :pressure maximun
-----------------------------------------------------------------------------------------------------
use lmax  'Maxima : find max from a list'

lmax(P);

We want find : xp1[i], yp1[i]
--------------------------------------
find : i ,for the maximun 1 <= i <= xpa ( =63,see :above)

m1:for i:1 thru xpa do(
if lmax(P)=P[i] then s:i
)$

s;

x_az:xp1[45];
y_az:yp1[45];

We prove  xp1[45] = yp1[45] =>exit  x[i] = y[i], for i:45  'azeotrope composition'
================================================================
prove : see website
-----------------------------
new: 25/08/2020:maxima : prove :result Azeotrope  x[i]=y[i], VLE (binary),version 1.0
================================================================
see : fig below ( = az ,symbol)

p3a:[xlabel,"xp1 =blue,yp1=red, mole fraction "];
p3b:[ylabel,"P (temperatur (Kelvin))"];
p3c:[title,"Pxy diagram,chloroform(1),hexane(2)"];

p3d:[legend ,"xp1","yp1"];

p3e:[label,"az",xp1[s],P[s]-0.005];

simple graph : with option
------------------------------------

wxplot2d([p2a,p2b],p3a,p3b,p3c,p3d,p3e,grid2d);

 ------------------------------------------------------------------------------------------------------------------------------------------------------------