0% found this document useful (0 votes)
21 views

Soru 1a

This MATLAB code takes input parameters for pressure, temperature, critical temperature and pressure, and acentric factor to calculate the specific volumes of an ideal gas and real gas using the Soave-Redlich-Kwong equation of state. The code calculates coefficients for the SRK equation, finds the root of the polynomial to determine real gas specific volume at different pressures, and plots the ideal and real gas specific volumes for comparison.

Uploaded by

Berkcan Arslan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Soru 1a

This MATLAB code takes input parameters for pressure, temperature, critical temperature and pressure, and acentric factor to calculate the specific volumes of an ideal gas and real gas using the Soave-Redlich-Kwong equation of state. The code calculates coefficients for the SRK equation, finds the root of the polynomial to determine real gas specific volume at different pressures, and plots the ideal and real gas specific volumes for comparison.

Uploaded by

Berkcan Arslan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

clear

clc

% Input data
P = input(' Input the vector of pressure range (Pa) = ');
T = input(' Input temperature (K) = ');
R = 8314; % Gas constant (J/kmol.K)
Tc = input(' Critical temperature (K) = ');
Pc = input(' Critical pressure (Pa) = ');
omega = input(' Acentric factor = ');

% Constants of Soave-Redlich-Kwong equation of state


a = 0.4278 * R^2 * Tc^2 / Pc;
b = 0.0867 * R * Tc / Pc;
sc = [-0.15613, 1.55171, 0.48508];
s = polyval(sc,omega);
alpha = (1 + s * (1 - sqrt(T/Tc)))^2;
A = a * alpha * P / (R^2 * T^2);
B = b * P / (R * T);

for k = 1:length(P)
% Defining the polynomial coefficients
coef = [1, -1, A(k)-B(k)-B(k)^2, -A(k)*B(k)];
v0(k) = R * T / P(k); % Ideal gas specific volume
vol(k) = NRpoly(coef , 1) * R * T / P(k); % Finding the
root
end

% Show numerical results


fprintf('\nRESULTS:\n');
fprintf('Pres. = %5.2f Ideal gas vol. =%7.4f',P(1),v0(1));
fprintf(' Real gas vol. =%7.4f\n',vol(1));
for k=10:10:length(P)
fprintf('Pres. = %5.2f Ideal gas vol. =%7.4f',P(k),v0(k));
fprintf(' Real gas vol. =%7.4f\n',vol(k));
end

% plotting the results


loglog(P/1000,v0,'.',P/1000,vol)
xlabel('Pressure, kPa')
ylabel('Specific Volume, m^3/kmol')
legend('Ideal','SRK')

You might also like