% compute gas pressure using
% the Peng-Robinson equation
% of state for methane
clear % clear workspace
clc % clear Command window
global R % make R available to functions
R = 8.314; % kJ/kmol/K
% methane molecular weight
MW = 16.04; % kg/kmol
% critical properties for methane
Tc = 191.15; % K
Pc = 4.641e6; % Pa
% acentric factor for methane
w = 0.0155;
% conditions
T = 700; % K
Vm = 0.1; % m3/kmol
Tr = T/Tc;
% Peng-Robinson parameters
a = 0.45724*R^2*Tc^2/Pc;
b = 0.07780*R*Tc/Pc;
alpha = (1+(0.37464+1.54226*w-0.26992*w^2)*(1-sqrt(Tr)))^2;
% compute pressure in Pa
P = R*T/(Vm-b)-a*alpha/(Vm^2+2*b*Vm-b^2);
% convert to kPa
PM = P/1000;
% display result
fprintf('Pressure = %4.1f kPa\n',PM)

