clear all

% Plot pressure of acetone-chloroform binary mixture.
% Original data from Zawidzki Zeitschrift fur Physicalische Chemie 1900.
% https://doi.org/10.1515/zpch-1900-3514
% 
% Executes properly on MATLAB version 9.4.0.813654 (R2018a).
% Executes mostly properly on OCTAVE version 4.2.1.
% Joshua C. Vaughan 1/31/2021

Xchl = [0 5.88 6.03 12.03 12.32 18.18 18.53 26.57 27.04 28.84 29.10...
    35.68 36.06 36.64 39.66 40.50 42.32 42.48 49.30 49.39 50.83 ...
    51.28 51.43 55.16 55.31 58.12 66.10 66.35 79.97 80.47 91.75 91.79 100]/100;

Xdmm = 1-Xchl;

Pac = [0 9.2 9.5 19.9 20.4 31.7 31.9 50.7 50.2 54.9 55.4 71.2 72.3 ...
    74.3 83.7 85.0 88.9 89.9 111.5 111.8 115.3 117.1 117.8 130.5 130.6 ...
    139.9 169.6 170.2 224.4 224.2 267.1 265.6 293.1]*133.322; % Units of Pa

Pchl = [344.5 323.2 322.6 300.2 299.3 276.3 275.4 240.9 240.3 231.2 230.3...
    202.3 200.8 197.9 183.7 181.9 174.3 173.2 144.2 143.6 137.6 135.6 ...
    135.0 120.3 118.8 108.5 79.2 79.0 37.5 38.4 13.0 13.9 0]*133.322; % Units of Pa

Ptot = Pchl + Pac;

Xac = 1-Xchl;

% Raoult's law prediction
n = 2^8;
Xa = linspace(0,1,n);
Pa_pure = Pac(end);
Pb_pure = Pchl(1);

Pa = Xa*Pa_pure;
Pb = (1-Xa)*Pb_pure;
Ptot_raoult = Pa+Pb;

% create plot

ax_lw = 2;
pl_lw = 2;
ax_fs = 30;
la_fs = 28;
ti_fs = 30;
lg_fs = 24;
fontname = 'Arial';

figure(1); clf
plot(Xchl,Pchl/1e4,'bo-',Xchl,Pac/1e4,'ro-',Xchl,Ptot/1e4,'ko-','linewidth',pl_lw,'markersize',4)
hold on
plot(Xa,Pa/1e4,'r--',Xa,Pb/1e4,'b--',Xa,Ptot_raoult/1e4,'k--','linewidth',pl_lw)
hold off


xlabel('{\itX}_{CHCl_3}','fontsize',la_fs)
ylabel('Pressure [\times10^4 Pa]','fontsize',la_fs)
set(gca,'fontsize',la_fs)
set(gca,'linewidth',ax_lw)
set(gca,'tickdir','out')
set(gcf,'color',[1 1 1])
set(gca,'fontname',fontname)
xlim([0 1])
ylim([0  1.05*max([Pa_pure Pb_pure])/1e4])
set(gca,'xtick',[0, 1])
%set(gca,'ytick',[0, Pb_pure, 1])
%set(gca,'yticklabel',{'0','{\itP}_B^*','{\itP}_A^*'})
set(gca,'LooseInset',get(gca,'TightInset'));

% add legend
h = legend('{\itP}_{acetone}','{\itP}_{CHCl3}','{\itP}_{total}');
set(h,'fontsize',lg_fs);
set(h,'linewidth',1.5);
set(h,'position',[0.1755 0.4345 0.2750 0.3220])
set(h,'box','off')