You are on page 1of 12

4/14/11 11:50 AM C:\Users\csboand\Documents\My Dr...\HW7.

m 1 of 3

function [ act1 act1_test ] = HW7( )


%UNTITLED Summary of this function goes here
% Detailed explanation goes here

m=1000;

chi = 0.6;

R= 8.314;

T= 298;

for i=0:1:100

x1 = i/100;

x2=1-x1;

psi_1=x1/(x1+m*x2);

psi_2=m*x2/(x1+m*x2);

act1(i+1) = exp( log(psi_1/x1) + (1-1/m)*psi_2 + chi*psi_2^2);

act2(i+1) = exp( log(psi_2/x2) - (m-1)*(psi_1) + m*chi*psi_1^2);


end

figure(1)
x = linspace(0,1,101);
plot(x,act1,'--',x,act2)
xlabel('mole fraction component 1 (toluene)')
ylabel('activity')
title('part c, m=1000, chi=0.6')
legend('toluene, component 1','polystyrene, component 2')

%part d

for m = [100,1000,10000];

for i=0:1:100

x1 = i/100;

x2=1-x1;

psi_1=x1/(x1+m*x2);
4/14/11 11:50 AM C:\Users\csboand\Documents\My Dr...\HW7.m 2 of 3

psi_2=m*x2/(x1+m*x2);

act1(i+1) = exp( log(psi_1/x1) + (1-1/m)*psi_2 + chi*psi_2^2);

act2(i+1) = exp( log(psi_2/x2) - (m-1)*(psi_1) + m*chi*psi_1^2);

if m ==100
g_e_1(i+1) = chi*R*T*(x1+m*x2)*psi_1*psi_2 + R*T*(x1*(log(psi_1/x1))+x2*log
(psi_2/x2));
end

if m ==1000
g_e_2(i+1) = chi*R*T*(x1+m*x2)*psi_1*psi_2 + R*T*(x1*(log(psi_1/x1))+x2*log
(psi_2/x2));
end

if m ==10000
g_e_3(i+1) = chi*R*T*(x1+m*x2)*psi_1*psi_2 + R*T*(x1*(log(psi_1/x1))+x2*log
(psi_2/x2));
end

end

hold all;
if m == 100;
figure(2)
plot(x,act1,'--',x,act2)
xlabel('mole fraction component 1 (toluene)')
ylabel('activity')
title('part d, m=100,1000,10000, chi=0.6')

end

if m == 1000;
plot(x,act1,'--',x,act2)
end

if m == 10000;
plot(x,act1,':',x,act2)

legend('toluene, component 1 m =100','polystyrene, component 2 m = 100','toluene,


component 1 m =1000','polystyrene, component 2 m = 1000','toluene, component 1 m
=10000','polystyrene, component 2 m = 10000','location','SouthOutside')
end

end
hold off;
4/14/11 11:50 AM C:\Users\csboand\Documents\My Dr...\HW7.m 3 of 3

figure(3)
plot(x,g_e_1,'+',x,g_e_2,':',x,g_e_3,'o')
xlabel('mole fraction component 1 (toluene)')
ylabel('gibbs free energy (intensive) (joule/mol)')
title('part d,c, m=100,1000,10000, chi=0.6')
legend('m =100','m =1000','m =10000','location','SouthOutside')

end
part c, m=1000, chi=0.6
1
toluene, component 1
polystyrene, component 2
0.9

0.8

0.7

0.6
activity

0.5

0.4

0.3

0.2

0.1

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
mole fraction component 1 (toluene)
part d, m=100,1000,10000, chi=0.6
1

0.9

0.8

0.7

0.6
activity

0.5

0.4

0.3

0.2

0.1

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
mole fraction component 1 (toluene)
toluene, component 1 m =100
polystyrene, component 2 m = 100
toluene, component 1 m =1000
polystyrene, component 2 m = 1000
toluene, component 1 m =10000
polystyrene, component 2 m = 10000
part d,c, m=100,1000,10000, chi=0.6
0

-2000
gibbs free energy (intensive) (joule/mol)

-4000

-6000

-8000

-10000

-12000

-14000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
mole fraction component 1 (toluene)
m =100
m =1000
m =10000

You might also like