0% found this document useful (0 votes)
58 views8 pages

Problem 1: Task 1

The document provides code to calculate properties of carbon dioxide (CO2) at different temperatures and pressures. It includes an algorithm to calculate the molar volume of CO2 at a given temperature and pressure. The code is executed for temperatures from 217K to 1000K and pressures from 0.517MPa to 10MPa. Plots of molar volume versus temperature and pressure, and compressibility factor Z versus pressure are generated. The results closely match those on a reference webpage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views8 pages

Problem 1: Task 1

The document provides code to calculate properties of carbon dioxide (CO2) at different temperatures and pressures. It includes an algorithm to calculate the molar volume of CO2 at a given temperature and pressure. The code is executed for temperatures from 217K to 1000K and pressures from 0.517MPa to 10MPa. Plots of molar volume versus temperature and pressure, and compressibility factor Z versus pressure are generated. The results closely match those on a reference webpage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

PROBLEM 1

FLUID SELECTED
CARBON DIOXIDE
Ttri = 217 K
Ptrip = 0.517 MPa
Tc = 304.1282 K
Pc = 7.3773 MPa
W = 0.22394 MPa

TASK 1
1) Algorithm to calculate a molar volume at a set temperature and pressure
syms Z;
format long g;
R=8.314; %[L.KPa/(k*mol)]
T=217;
p=0.517*10^3;
Tc=304.1282;
Pc=7.3773*10^3;
omega=0.22394;
Tr=T/Tc;
alpha=exp((2.0+0.836*Tr)*(1-Tr^(0.134+0.508*omega-0.0467*omega^2)));
a=0.457535*alpha*R^2*Tc^2/Pc;
b=0.077796*R*Tc/Pc;
A=a*p/(R*T)^2;
B=b*p/R/T;
f=Z^3-(1-B)*Z^2+(A-2*B-3*B^2)*Z-(A*B-B^2-B^3);
df=diff(f,Z);
lambda=((1-B)^2)/9-(A-3*B^2-2*B)/3;
if lambda<=0
Z1=1;
Z2=(4/3)*B;
else
Z1=(1-B)/3-sqrt(lambda);
Z2=(1-B)/3+sqrt(lambda);
end

% Solve for vapor root of Z

if double(subs(f,{Z},{Z2}))>0
Zvap=(Z1+B)/2;
else
Zvap=(Z2+1)/2;
end

for j=1:200
fZ=double(subs(f,Z,Zvap));
dfZ=double(subs(df,Z,Zvap));
if dfZ<0
Zvapnew=Zvap+1;
else
Zvapnew=Zvap-fZ/dfZ;
end
if abs(Zvapnew-Zvap)<1e-6
fprintf('The vapor root of Z is %6.4d\n', Zvapnew);
fprintf('Iteration number is %4.d\n', j);
vvap=Zvap*R*T/p;
fprintf('The molar volume of vapor root is %6.4d\n', vvap);
break;
end
Zvap=Zvapnew;
end

if double(subs(f,{Z},{Z1}))>0
Zliq=(Z1+B)/2;
else
Zliq=(Z2+1)/2;
end
for i=1:200
fZ=double(subs(f,Z,Zliq));
dfZ=double(subs(df,Z,Zliq));
if dfZ<0
Zliqnew=Zliq+1;
else
Zliqnew=Zliq-fZ/dfZ;
end
if abs(Zliqnew-Zliq)<1e-6
fprintf('The liquid root of Z is %6.4d\n', Zliqnew);
fprintf('Iteration number is %4.d\n', i);
vliq=Zliq*R*T/p;
fprintf('The molar volume of vapor root is %6.4d\n', vliq);
break;
end
Zliq=Zliqnew;
end

Results:
The vapor root of Z is 9.2607e-01
Iteration number is 5
The molar volume of vapor root is 3.2316e+00
The liquid root of Z is 1.0269e-02
Iteration number is 5
The molar volume of vapor root is 3.5834e-02

This results are very close with those found in the webpage given as a reference
TASK 2
2) Code for the Temperature range

syms Z;
format long g;
R=8.314; %[L.KPa/(k*mol)]
p=0.517*10^3;
Tc=304.1282;
Pc=7.3773*10^3;
omega=0.22394;
Tt=217;
Pt=0.517*10^3;
Trt=Tt/Tc;
Prt=Pt/Pc;
vdata=zeros(length([Trt:(10-Trt)/100:10]),3);
vdata(:,1)=[Trt:(10-Trt)/100:10]*Tc;
count=1;

for Tr=Trt:(10-Trt)/100:10
T=Tr*Tc;
alpha=exp((2.0+0.836*Tr)*(1-Tr^(0.134+0.508*omega-0.0467*omega^2)));
a=0.457535*alpha*R^2*Tc^2/Pc;
b=0.077796*R*Tc/Pc;
A=a*p/(R*T)^2;
B=b*p/R/T;
f=Z^3-(1-B)*Z^2+(A-2*B-3*B^2)*Z-(A*B-B^2-B^3);
df=diff(f,Z);
lambda=((1-B)/3)^2-(A-2*B-3*B^2)/3;
Z1=(1-B)/3-sqrt(lambda);
Z2=(1-B)/3+sqrt(lambda);
if lambda<=0
Z1=B;
Z2=1.01*B;
else
Z1=(1-B)/3-sqrt(lambda);
Z2=(1-B)/3+sqrt(lambda);
end
% Solve for vapor root of Z

if double(subs(f,{Z},{Z2}))>0
Zvap=(Z1+B)/2;
else Zvap=(Z2+1)/2;
end
for j=1:100
fZ=double(subs(f,{Z},{Zvap}));
dfZ=double(subs(df,{Z},{Zvap}));
if dfZ<0
Zvapnew=Zvap+1;
else
Zvapnew=Zvap-fZ/dfZ;
end
if abs(Zvapnew-Zvap)<1e-6
break;
end
Zvap=Zvapnew;
end
vdata(count,3)=Zvap*R*T/p;

% Solve for liquid root of Z

if double(subs(f,{Z},{Z1}))>=0
Zliq=(Z1+B)/2;
else Zliq=(Z2+1)/2;
end
for i=1:100
fZ=double(subs(f,{Z},{Zliq}));
dfZ=double(subs(df,{Z},{Zliq}));
if dfZ<0
Zliqnew=Zliq-1;
else
Zliqnew=Zliq-fZ/dfZ;
end
if abs(Zliqnew-Zliq)<1e-12
if Zliqnew<0
Zliqnew=Zvapnew;
vliq=Zliqnew*R*T/p;
end
break;
end
Zliq=Zliqnew;
end
vdata(count,2)=Zliqnew*R*T/p;
count=count+1;
end
plot(vdata(:,1),vdata(:,2),'or');
hold on
plot(vdata(:,1),vdata(:,3),'ob');
grid on
axis([200 1100 2.5 20]);
xlabel('Temperature K');
ylabel('Molar volume L/mol');
RESULTS

REFERENCE WEBPAGE RESULT

Both result were obtained at the same pressure (0.517 MPa).

3) Code for the Pressure range and for “Z vs Pr”

clear all;
syms Z;
format long g;
R=8.314;
T=217;
Tc=304.1282;
Pc=7.3773*10^3;
omega=0.22394;
Tt=217;
Pt=0.517*10^3;
Trt=Tt/Tc;
Prt=Pt/Pc;
Tr=T/Tc;
vdata=zeros(length([Prt:(10-Prt)/100:10]),3);
vdata(:,1)=[Prt:(10-Prt)/100:10]*Pc;
Zdata=zeros(length([Prt:(10-Prt)/100:10]),3);
Zdata(:,1)=[Prt:(10-Prt)/100:10]*Pc;
count=1;
for Pr=Prt:(10-Prt)/100:10
p=Pc*Pr;
alpha=exp((2.0+0.836*Tr)*(1-Tr^(0.134+0.508*omega-0.0467*omega^2)));
a=0.457535*alpha*R^2*Tc^2/Pc;
b=0.077796*R*Tc/Pc;
A=a*p/(R*T)^2;
B=b*p/R/T;
f=Z^3-(1-B)*Z^2+(A-2*B-3*B^2)*Z-(A*B-B^2-B^3);
df=diff(f,Z);
lambda=((1-B)/3)^2-(A-2*B-3*B^2)/3;
Z1=(1-B)/3-sqrt(lambda);
Z2=(1-B)/3+sqrt(lambda);
if lambda<=0
Z1=B;
Z2=1.01*B;
else
Z1=(1-B)/3-sqrt(lambda);
Z2=(1-B)/3+sqrt(lambda);
end

% Solve for vapor root of Z

if double(subs(f,{Z},{Z2}))>0
Zvap=(Z1+B)/2;
else Zvap=(Z2+1)/2;
end
for j=1:100
fZ=double(subs(f,{Z},{Zvap}));
dfZ=double(subs(df,{Z},{Zvap}));
if dfZ<0
Zvapnew=Zvap+1;
else
Zvapnew=Zvap-fZ/dfZ;
end
if abs(Zvapnew-Zvap)<1e-6
break;
end
Zvap=Zvapnew;
end
Zdata(count,3)=Zvap;
vdata(count,3)=Zvap*R*T/p*1000;

% Solve for liquid root of Z

if double(subs(f,{Z},{Z1}))>=0
Zliq=(Z1+B)/2;
else Zliq=(Z2+1)/2;
end
for i=1:100
fZ=double(subs(f,{Z},{Zliq}));
dfZ=double(subs(df,{Z},{Zliq}));
if dfZ<0
Zliqnew=Zliq-1;
else
Zliqnew=Zliq-fZ/dfZ;
end
if abs(Zliqnew-Zliq)<1e-12
if Zliqnew<0
Zliqnew=Zvapnew;
vliq=Zliqnew*R*T/p;
end
break;
end
Zliq=Zliqnew;
end
Zdata(count,2)=Zliqnew;
vdata(count,2)=Zliqnew*R*T/p*1000;

count=count+1;
end
plot(vdata(:,1)/1e3,vdata(:,2),'or',vdata(:,1)/1e3,vdata(:,3),'or');
title('Molar volume Vs Pr')
xlabel('P');
ylabel('Molar volume L/mol');

figure

semilogy(Zdata(:,1)/1e3,Zdata(:,2),'or',Zdata(:,1)/1e3,Zdata(:,3),'ob');
title('Z vs Pr');
xlabel('Pr');
ylabel('Z');

RESULTS

Molar volume Vs Pressure

RESOURCE
As we can see, or results are very close to those on the resource webpage.

4) Z Vs Pr

Main Resource
http://webbook.nist.gov/chemistry/fluid/
Fluid selected “CO2”

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy