Project 2 - Rankine cycle Simulator
AIM
To Understand the concept of Rankine cycle by referring to standard thermal engineering text book.
- To Create a Rankine Cycle Simulator using MATLAB.
- code should calculate the state points of the Rankine Cycle based on user inputs.
- plot the corresponding T-s and h-s plots for the given set of inputs. Title and axes labels are a must, while legends could be used if necessary.
The link for the standard Xsteam library to get the steam table data for water, is given. Which is used as function call used to calculate the points in between the state variables.
Inputs Data:
Required Inputs:
Turbine Inlet temperature = 400° C
Turbine Inlet Pressure = 30 bars
Turbine Outlet Pressure = 0.05 bars = Condenser Inlet Pressure
To Find
- Net work output
- Back work ratio
Solution:
Main Code
clc
close all
clear all
%rankine cycle simulation
%state point 1-[ 1:2 Isentropic Expansion]work output at turbine
%state point 2-[ 2:3 isobaric heat release]head released by condenser
%stage point 3-[ 3:4 Isentropic compression ]work input in condensation
%state point 4-[ 4:1 Isobaric heat addition ]heat added by boiler
%% Input Parameters
p1=input('Inlet Turbine Pressure(bar)\n');
t1=input('Inlet Turbine Temperature(Celcius)\n');
p2=input('Outlet Turbine Temperature(bar)\n');
%% Saturation Curve
t= [0:t1];
sL=[];
sV=[];
hL=[];
hV=[];
for i=1:length(t)
sL=[sL, XSteam('sL_T',t(i))];%saturation liquid entropy at temparatue
sV=[sV, XSteam('sV_T',t(i))];%saturation vapur entropy at temparature
hL=[hL, XSteam('hL_T',t(i))];%saturation liquid enthanlpy at temperature
hV=[hV, XSteam('hV_T',t(i))];%saturation vaopur enthanlpy at temperature
end
%%
%State POint 1
h1= XSteam('h_pT',p1,t1);
s1= XSteam('s_pT',p1,t1);
%% Turbine [1:2 Insentropic Expansion at Turbine]
%state Point 2
s2= s1;
g= 1.4; %gamma
t2=((p2/p1)^(1-(1/g)))*t1;
h2= XSteam('h_pT',p2,t2);
%Wt Turbine Work ,1:2 Insentropic Expansion at Turbine
Wt = h1-h2
%% Condenser [ 2:3 isobaric heat release condensation]
%state Point 3
t3=t2;
p3=p2;
h3= XSteam('hL_T',t3);
s3= XSteam('sL_T',t3);
%% Pump [ 3:4 Isentropic compression at pump]
%state point 4
s4=s3;
p4=p1;
t4=XSteam('T_ps',p4,s4);
h4=XSteam('h_pT',p4,t4);
%% Boiler [ 4:1 Isobaric heat addition at boiler]
% inter mediate state points on saturation line
hL41=XSteam('hL_p',p4);
sL41=XSteam('sL_p',p4);
t41=XSteam('T_hs',hL41,sL41);
hV42=XSteam('hV_p',p4);
sV42=XSteam('sV_p',p4);
t42=XSteam('T_hs',hV42,sV42);
%% Caluctions
%Wt Turbine Work ,1:2 Insentropic Expansion at Turbine
Wt = h1-h2
%Wp pump Work ,3:4 Insentropic Expansion at Turbine
Wp=h4-h3
%Net Work
Wn=Wt-Wp
%efficinency
qin=h1-h4 %total added heat
eff=(Wn/qin)*100
%Back Work ratio
bW=Wp/Wt
l1=sprintf('%s = %f\n','Work By Turbine in KJ/Kg',Wt);
l2=sprintf('%s = %f\n','Work By pump in KJ/Kg',Wp);
l3=sprintf('%s = %f\n','Net Work in KJ/Kg',Wn);
l4=sprintf('%s = %f\n','Thermal Efficiency ',eff);
l5=sprintf('%s = %f\n','Back Work ratio',bW);
disp(l1)
disp(l2)
disp(l3)
disp(l4)
disp(l5)
%% Making new directory
Dir=cd();
mkdir('Rankine Cycle')%creating new directory for every 'gas' input
cd('Rankine Cycle')%changing the directory to created folder using mkdir
%% Results output in a saved file
S= [s1 s2 s3 s4 sL41 sV42 s1];
T= [t1 t2 t3 t4 t41 t42 t1];
H= [h1 h2 h3 h4 hL41 hV42 h1];
P=[p1 p2 p3 p4];
f1= fopen('output.txt','w');
fprintf(f1,'%s\n','Rankine Cycle Simulation Results');
fprintf(f1,'[ 1:2 Isentropic Expansion]-work output at turbine\n');
fprintf(f1,'[ 2:3 isobaric heat release]-head released by condenser\n');
fprintf(f1,'[ 3:4 Isentropic compression ]-work input in condensation\n');
fprintf(f1,'[ 4:1 Isobaric heat addition ]-heat added by boiler\n');
fprintf(f1,'%10s %10s %12s %12s %12s\n','State Point','Pressure bar','Temperature C',' Entropy KJ/KgK ','Enthalpy KJ/Kg');
for i=1:4
fprintf(f1,'%10.0f %10.3f %15.3f %15.3f %15.3f',i,P(i),T(i),S(i),H(i));
fprintf(f1,'\n');
end
fprintf(f1,'\n');
fprintf(f1,'%10s = %1f\n','Work By Turbine in KJ/Kg',Wt);
fprintf(f1,'%10s = %1f\n','Work By pump in KJ/Kg',Wp);
fprintf(f1,'%10s = %1f\n','Net Work in KJ/Kg',Wn);
fprintf(f1,'%10s = %1f\n','Thermal Efficiency ',eff);
fprintf(f1,'%10s = %1f\n','Back Work ratio',bW);
fclose(f1);
%% plot T-S curve
figure (1)
hold on
title('Rankine Cyle Simulation','T-S Curve')
xlabel('S - Entropy in KJ/KgK')
ylabel('T - Temperature in Celcius')
axis([0 10 -5 425])
plot(sL,t,'color','blue','linestyle','--')
plot(sV,t,'color','red','linestyle','--')
plot(g,'XData',S,'YData',T,'color','k','linewidth',1)
%plot node points with values
statePoints=[1 2 4 5];
a=1;
for i=statePoints
%marking the points in red with o
plot(S(i),T(i),'or')
%caption text data to be shown on graph
caption=sprintf('State=%.0f (S=%.2f, T=%.2f)',a,S(i),T(i));
%text position size and shape
text(S(i)+0.3,T(i)-25,caption,'fontsize',7,'backgroundcolor','y');
a=a+1;
end
saveas(figure(1),'T-S Curve.jpg')
%% plot H-S Cruve
figure (2)
hold on
title('Rankine Cyle Simulation','H-S Curve')
xlabel('S - Entropy in KJ/KgK')
ylabel('H - Enthalpy in KJ/K')
plot(sL,hL,'color','blue','linestyle','--')
plot(sV,hV,'color','red','linestyle','--')
plot(g,'XData',S,'YData',H,'color','k','linewidth',1,'marker','*')
saveas(figure(2),'H-S Curve.jpg')
cd(Dir);