Project 2 - Rankine cycle Simulator
RANKINE CYCLE SIMULATOR
MAIN CODE
close all
clear all
clc
% Print process description
fprintf('1-2 Isobaric heat Transfer\n')
fprintf('2-3 Isentropic Expansion\n')
fprintf('3-4 Isobaric heat Rejection\n')
fprintf('2-3 Isentropic Compression\n')
% Enter Inputs
p1 = input('Enter the pressure at the turbo inlet(in bar) :');
t1 = input('Enter the temperature in the turbine inlet(in degree celcius) : ');
p2 = input('Enter the pressure at the condenser(in bar) :')
% State points
h1 = XSteam('h_pt',p1,t1);
s1 = XSteam('s_pt',p1,t1);
%state point 2
s2 = s1;
sf2 = XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);
s2 = sg2;
h2 = hg2;
t2 = XSteam('T_hs',h2,s2);
% State point 3
t3 = t2;
p3 = p2;
s3 = XSteam('sL_t',t3);
h3 = XSteam('hL_t',t3);
v3 = XSteam('VL_p',p2);
% State point 4
p4 = p1;
s4 = s3;
Cp4 = XSteam('Cp_ps',p4,s4);
Cv4 = XSteam('Cv_ps',p4,s4);
gamma = Cp4/Cv4;
r = (gamma-1)/gamma;
t4 = t3*(p4/p3)*r;
% Calculate other output values
% Turbine work
Wt = h1 - h2;
% Pump work
Wp = v3*(p1 - p2)*100;
h4 = Wp + h3;
W_net = Wt - Wp;
% Heat supplied
Qs = h1 -h4;
N_per = (W_net/Qs)*100;
%Steam rate per second
steam_rate = 3600/(Wt - Wp);
% State point 5 and 6 which helps in plotting
t5 = XSteam('Tsat_p' , p1);
t6 = t5;
s5 = XSteam('sL_p',p1);
s6 = XSteam('sV_p',p1);
h5 = XSteam('hL_p',p1);
h6 = XSteam('hV_p',p1);
% Print all state points values
fprintf('\n Result \n')
fprintf('A state point 1 :\np1 is : %4.2f bar\nt1 is : %4.2f degree celcius\nh1 : %4.2fKJ/Kg\ns1 is : %4.2f KJ/kgk\n\n',p1,t1,h1,s1)
fprintf('A state point 1 :\np2 is : %4.2f bar\nt2 is : %4.2f degree celcius\nh2 : %4.2fKJ/Kg\ns2 is : %4.2f KJ/kgk\n\n',p2,t2,h2,s2)
fprintf('A state point 1 :\np3 is : %4.2f bar\nt3 is : %4.2f degree celcius\nh3 : %4.2fKJ/Kg\ns3 is : %4.2f KJ/kgk\n\n',p3,t3,h3,s3)
fprintf('A state point 1 :\np4 is : %4.2f bar\nt4 is : %4.2f degree celcius\nh4 : %4.2fKJ/Kg\ns4 is : %4.2f KJ/kgk\n\n',p4,t4,h4,s4)
fprintf('Wt is : %4.2f KJ/kgn Wp is : %4.2f KJ/kg \nWnet is : %4.2fKJ/Kg\n Ntherm is : %4.2f percent\nS.S.C is : %4.2f Kg/kWh',Wt,Wp,W_net,N_per,steam_rate)
% Plot T-S diagram
subplot(1,2,1)
T_rankine = linspace(t5 , t1 , 5000);
for i = 1 : length(T_rankine)
s_rankine(i) = XSteam('s_pt',p1,T_rankine(i));
end
plot([s1 s2 s3 s4 s5 s6 s_rankine],[t1 t2 t3 t4 t5 t6 T_rankine],'linewidth',1.5);
hold on
T_curve = linspace(1,400,500);
for i = 1:length(T_curve)
s_l(i) = XSteam('sL_T',T_curve(i));
s_v(i) = XSteam('sV_T',T_curve(i));
h_l(i) = XSteam('hL_T',T_curve(i));
h_v(i) = XSteam('hV_T',T_curve(i));
end
plot(s_l,T_curve);
plot(s_v,T_curve);
text(s1,t1,'1','FontSize',15)
text(s2,t2,'2','FontSize',15)
text(s3,t3,'3','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','top')
text(s4,t4,'4','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','bottom')
text(s5,t5,'5','FontSize',15)
text(s6,t6,'6','FontSize',15)
xlabel('Entropy in KJ/kgk');
ylabel('Temperature in Degree Celcius');
% Plot H-S diagram
subplot(1,2,2)
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1],'LineWidth',2)
hold on
plot(s_v,h_v,'color','b')
plot(s_l,h_l,'Color','g')
text(s1,h1,'1','FontSize',15)
text(s2,h2,'2','FontSize',15)
text(s3,h3,'3','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','top')
text(s4,h4,'4','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','bottom')
xlabel('Entropy in KJ/kgK')
ylabel('Enthalpy in KJ/kg')
EXPLANATION
close all - to close all output window
clear all - to clear all the workspace variable
clc - to clear the command window
fprintf('1-2 Isobaric heat Transfer\n') - to print process
fprintf('2-3 Isentropic Expansion\n') - to print process
fprintf('3-4 Isobaric heat Rejection\n') - to print process
fprintf('2-3 Isentropic Compression\n') - to print process
p1 = input('Enter the pressure at the turbo inlet(in bar) :'); - to enter value of p1
t1 = input('Enter the temperature in the turbine inlet(in degree celcius) : '); - to enter value of t1
p2 = input('Enter the pressure at the condenser(in bar) :') - to enter value of p2
h1 = XSteam('h_pt',p1,t1); - to take an variable from x steam file
s1 = XSteam('s_pt',p1,t1); - to take a variable from x steam file
s2 = s1;
sf2 = XSteam('sL_p',p2); - sequence of an pressure variable
sg2 = XSteam('sV_p',p2); - sequence of an pressure variable
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);
s2 = sg2;
h2 = hg2;
t2 = XSteam('T_hs',h2,s2);
% State point 3
t3 = t2;
p3 = p2;
s3 = XSteam('sL_t',t3);
h3 = XSteam('hL_t',t3);
v3 = XSteam('VL_p',p2);
% State point 4
p4 = p1;
s4 = s3;
Cp4 = XSteam('Cp_ps',p4,s4);
Cv4 = XSteam('Cv_ps',p4,s4);
gamma = Cp4/Cv4;
r = (gamma-1)/gamma;
t4 = t3*(p4/p3)*r;
% Calculate other output values
% Turbine work
Wt = h1 - h2;
% Pump work
Wp = v3*(p1 - p2)*100;
h4 = Wp + h3;
W_net = Wt - Wp;
% Heat supplied
Qs = h1 -h4;
N_per = (W_net/Qs)*100;
%Steam rate per second
steam_rate = 3600/(Wt - Wp);
% State point 5 and 6 which helps in plotting
t5 = XSteam('Tsat_p' , p1);
t6 = t5;
s5 = XSteam('sL_p',p1);
s6 = XSteam('sV_p',p1);
h5 = XSteam('hL_p',p1);
h6 = XSteam('hV_p',p1);
% Print all state points values
fprintf('\n Result \n')
fprintf('A state point 1 :\np1 is : %4.2f bar\nt1 is : %4.2f degree celcius\nh1 : %4.2fKJ/Kg\ns1 is : %4.2f KJ/kgk\n\n',p1,t1,h1,s1)
fprintf('A state point 1 :\np2 is : %4.2f bar\nt2 is : %4.2f degree celcius\nh2 : %4.2fKJ/Kg\ns2 is : %4.2f KJ/kgk\n\n',p2,t2,h2,s2)
fprintf('A state point 1 :\np3 is : %4.2f bar\nt3 is : %4.2f degree celcius\nh3 : %4.2fKJ/Kg\ns3 is : %4.2f KJ/kgk\n\n',p3,t3,h3,s3)
fprintf('A state point 1 :\np4 is : %4.2f bar\nt4 is : %4.2f degree celcius\nh4 : %4.2fKJ/Kg\ns4 is : %4.2f KJ/kgk\n\n',p4,t4,h4,s4)
fprintf('Wt is : %4.2f KJ/kgn Wp is : %4.2f KJ/kg \nWnet is : %4.2fKJ/Kg\n Ntherm is : %4.2f percent\nS.S.C is : %4.2f Kg/kWh',Wt,Wp,W_net,N_per,steam_rate)
% Plot T-S diagram
subplot(1,2,1)
T_rankine = linspace(t5 , t1 , 5000);
for i = 1 : length(T_rankine)
s_rankine(i) = XSteam('s_pt',p1,T_rankine(i));
end
plot([s1 s2 s3 s4 s5 s6 s_rankine],[t1 t2 t3 t4 t5 t6 T_rankine],'linewidth',1.5);
hold on
T_curve = linspace(1,400,500);
for i = 1:length(T_curve)
s_l(i) = XSteam('sL_T',T_curve(i));
s_v(i) = XSteam('sV_T',T_curve(i));
h_l(i) = XSteam('hL_T',T_curve(i));
h_v(i) = XSteam('hV_T',T_curve(i));
end
plot(s_l,T_curve);
plot(s_v,T_curve);
text(s1,t1,'1','FontSize',15)
text(s2,t2,'2','FontSize',15)
text(s3,t3,'3','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','top')
text(s4,t4,'4','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','bottom')
text(s5,t5,'5','FontSize',15)
text(s6,t6,'6','FontSize',15)
xlabel('Entropy in KJ/kgk');
ylabel('Temperature in Degree Celcius');
% Plot H-S diagram
subplot(1,2,2)
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1],'LineWidth',2)
hold on
plot(s_v,h_v,'color','b')
plot(s_l,h_l,'Color','g')
text(s1,h1,'1','FontSize',15)
text(s2,h2,'2','FontSize',15)
text(s3,h3,'3','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','top')
text(s4,h4,'4','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','bottom')
xlabel('Entropy in KJ/kgK')
ylabel('Enthalpy in KJ/kg')