IDEAL RANKINE CYCLE SIMULATOR IN CASE OF WITH AND WITHOUT SUB-COOLING USING MATLAB PROGRAMMING
Aim : To simulate Ideal rankine cycle and to generate T-S diagram and H-s diagram based on user inputs using Matlab programming
Ideal Rankine Cycle :
Basic Cycle
The Rankine cycle is the fundamental operating cycle of all power plants where an operating fluid is continuously evaporated and condensed. The selection of operating fluid depends mainly on the available temperature range.

-
1- Isentropic Expansion. The vapor is expanded in the turbine, thus producing work which may be converted to electricity. In practice, the expansion is limited by the temperature of the cooling medium and by the erosion of the turbine blades by liquid entrainment in the vapor stream as the process moves further into the two-phase region. Exit vapor qualities should be greater than 90%.
-
2-3 Isobaric Heat Rejection. The vapor-liquid mixture leaving the turbine is condensed at low pressure, usually in a surface condenser using cooling water. In well designed and maintained condensers, the pressure of the vapor is well below atmospheric pressure, approaching the saturation pressure of the operating fluid at the cooling water temperature.
-
3-4 Isentropic Compression. The pressure of the condensate is raised in the feed pump. Because of the low specific volume of liquids, the pump work is relatively small and often neglected in thermodynamic calculations.
- 4-1 Isobaric Heat Transfer. High pressure liquid enters the boiler from the feed pump and is heated to the saturation temperature. Further addition of energy causes evaporation of the liquid until it is fully converted to saturated steam.
Work done by the Turbine :
Wt = h1 - h2
Work done by the pump :
Wp = h4 - h3 = Vf3(P4- P3)
Heat addition :
Qs = h1 - h4
Heat rejected :
Qr = h2 - h3
Supporting files to run this program :
https://drive.google.com/open?id=1RK_fvrOj38CIaQvmLT1S3daqHnxKCGU-
This link is to download Xsteam.m file in order to access steam data
This link is to download cprintf.m file exchange in order to display the text in colored format in the command window
These 2 .m files are to be present in the same directory where the matlab programs are saved.
Matlab Code :
clear all
close all
clc
%Giving description of all process to user
cprintf('*red','Rankine cycle simulator nn');
cprintf('*blue','1-2 Isentropic expansion in turbine n');
cprintf('*blue','2-3 constant pressure heat rejection by condensor n');
cprintf('*blue','3-4 Isentropic compression in condensor n');
cprintf('*blue','4-1 constant pressure heat addition by boiler nn');
%Giving inputs to user
p1=input('Enter the value of pressure(bar) at turbine inlet : ');
t1=input('Enter the value of temperature(celcius) at turbine inlet : ');
p2=input('Enter the value of pressure(bar) at condensor : ');
fprintf('nn')
%Preparing results
cprintf('*black','Results nn');
%calculation of Cp value at p1 and p2 for saturated liquid and vapour
Cp1ofliquid=XSteam('CpL_p',p1);
Cp1ofvapour=XSteam('CpV_p',p1);
Cp2ofliquid=XSteam('CpL_p',p2);
Cp2ofvapour=XSteam('CpV_p',p2);
%calculation of saturation temperature at p1 and p2
Tsatatp1=XSteam('Tsat_p',p1);
Tsatatp2=XSteam('Tsat_p',p2);
%calculation of entropy and enthalpy at saturation points
%saturation properties at state 1
hg1=XSteam('hV_p',p1);
sg1=XSteam('sV_p',p1);
sf1=XSteam('sL_p',p1);
%saturation properties at state 2
hg2=XSteam('hV_p',p2);
sg2=XSteam('sV_p',p2);
%saturation properties at state 3
hf3=XSteam('hL_p',p2);
sf3=XSteam('sL_p',p2);
%saturation properties at state 4
hf4=XSteam('hL_p',p1);
sf4=XSteam('sL_p',p1);
sg4=XSteam('sV_p',p1);
%calculation of process properties at state 1
cprintf('*red','At state point 1n')
fprintf('p1 is %f bar n',p1)
fprintf('t1 is %f celcius n',t1)
if (fix(t1)>fix(Tsatatp1))
cprintf('*green','steam at the entry of turbine inlet is super saturated steamn')
elseif (fix(t1)<fix(Tsatatp1))
cprintf('*green','Temperature not sufficient to convert water into steamn')
else
cprintf('*green','steam at the entry of turbine inlet is Dry saturated steamn')
end
if(fix(t1)>=fix(Tsatatp1))
h1=XSteam('h_pT',p1,t1);
fprintf('h1 is %f Kj/kg n',h1);
s1=XSteam('s_pT',p1,t1);
fprintf('s1 is %f Kj/kg-K n',s1);
%calculation of process properties at state 2
cprintf('*red','At state point 2n');
fprintf('p2 is %f bar n',p2);
s2=s1;
fprintf('s2 is %f Kj/kg-K n',s2);
%calculation of dryness fraction
if (s2<sg2)
cprintf('*green','steam at the exit of turbine outlet is wet steamn')
x2=(s2-sf3)/(sg2-sf3);
t2=Tsatatp2;
h2=hf3+x2*(hg2-hf3);
fprintf('x2 is %f n',x2);
fprintf('t2 is %f degrees n',t2);
fprintf('h2 is %f Kj/Kg n',h2);
elseif (s2>sg2)
cprintf('*green','steam at the exit of turbine outlet is still super saturated steamn')
t2=(Tsatatp2+273.15)*exp((s2-sg2)/Cp2ofvapour);
t2=t2-273.15;
h2=hg2+Cp2ofvapour*(t2-Tsatatp2);
fprintf('t2 is %f degrees n',t2);
fprintf('h2 is %f Kj/Kg n',h2);
else
cprintf('*green','steam at the exit of turbine outlet is dry saturated steamn')
t2=Tsatatp2;
h2=hg2+(Cp2ofvapour*(t2-Tsatatp2));
fprintf('t2 is %f degrees n',t2);
fprintf('h2 is %f Kj/Kg n',h2);
end
%calculation of properties at state 3
cprintf('*red','At state point 3n');
p3=p2;
fprintf('p3 is %f bar n',p3);
Type=' ';
cprintf('*green','Is there any subcooling?n')
prompt=('Enter yes or no : ');
Type=input(prompt,'s');
if strcmp(Type,'no')== 1
t3=Tsatatp2;
fprintf('t3 is %f celcius n',t3);
h3=hf3;
s3=sf3;
fprintf('h3 is %f Kj/Kg n',h3);
fprintf('s3 is %f Kj/kg-K n',s3);
%calculation of properties at state 4
cprintf('*red','At state point 4n');
p4=p1;
s4=s3;
fprintf('p4 is %f bar n',p4);
V3=XSteam('vL_p',p3);
%work done by the pump in Kj/Kg
Wp=V3*(p4-p3)*100;
h4=Wp+h3;
fprintf('h4 is %f Kj/Kg n',h4);
Cp=XSteam('Cp_ps',p3,s3);
Cv=XSteam('Cv_ps',p3,s3);
k=exp((sf1-s4)/Cp1ofliquid);
t4=Tsatatp1/k;
fprintf('t4 is %f degrees nn',t4);
%work done by turbine
Wt=h1-h2;
%Net work done
Wnet=Wt-Wp;
%Heat input by the boiler
Qin=h1-h4;
%Thermal efficiency of Rankine cycle
eff=(Wnet/Qin)*100;
%specific steam consumption
SSC=3600/Wt;
%Back work ratio
BWR=Wp/Wt;
cprintf('*blue','Work done by turbine is %f Kj/Kg nn',Wt);
cprintf('*blue','Work done by pump is %f Kj/Kg nn',Wp);
cprintf('*blue','Net Work done is %f Kj/Kg nn',Wnet);
cprintf('*blue','Heat input by boiler is %f Kj/Kg nn',Qin);
cprintf('*blue','Efficiency of Rankine cycle is %f nn',eff);
cprintf('*blue','Specific steam consumption is %f Kg/KW-Hrnn',SSC);
cprintf('*blue','Back work Ratio is %f nn',BWR);
%plotting saturation liquid and vapour line
temp=linspace(1,400,1000);
for i=1:length(temp)
hl(i)=XSteam('hL_T',temp(i));
hv(i)=XSteam('hV_T',temp(i));
sl(i)=XSteam('sL_T',temp(i));
sv(i)=XSteam('sV_T',temp(i));
end
figure(1)
plot(sl,temp,'b','linestyle','--','linewidth',1)
hold on
plot(sv,temp,'b','linestyle','--','linewidth',1)
axis([0 10 0 750])
plot([s1,s2],[t1,t2],'r','linewidth',1)
text(s1,t1,'1')
text(s2,t2,'2')
plot([s2,sg2],[t2,Tsatatp2],'r','linestyle','--','linewidth',1)
text(sg2,Tsatatp2,'2s')
plot([sg2,s3],[Tsatatp2,t3],'r','linewidth',1)
text(s3,t3,'3')
plot([s3,s4],[t3,t4],'r','linewidth',1)
text(s4,t4,'4')
plot([s4,sf4],[t4,Tsatatp1],'r','linewidth',1)
text(sf4,Tsatatp1,'4s')
text(s1,t1,'1')
plot([sf4,sg1],[Tsatatp1,Tsatatp1],'r','linewidth',1)
text(sg1,Tsatatp1,'1s')
plot([sg1,s1],[Tsatatp1,t1],'r','linewidth',1)
xlabel('Entropy (Kj/Kg-k)')
ylabel('Temperature (K)')
title('Ideal rankine cycle T-S diagram without subcooling')
legend('liquid saturation curve','vapour saturation curve','Rankine cycle process steps')
figure(2)
hold on
plot(sl,hl,'b','linestyle','--','linewidth',1)
hold on
plot(sv,hv,'b','linestyle','--','linewidth',1)
plot([s1 s2],[h1,h2],'r','linewidth',1)
text(s1,h1,'1')
text(s2,h2,'2')
plot([s2,sg2],[h2,hg2],'color','r','linestyle','--','linewidth',1)
text(s3,h3,'3')
text(sg2,hg2,'2s')
plot([sg2,s3],[hg2,h3],'r','linewidth',1)
plot([s3,s4],[h3,h4],'r','linewidth',1)
text(s4,h4,'4')
plot([s4,sf4],[h4,hf4],'r','linewidth',1)
text(sf4,hf4,'4s')
text(s1,h1,'1')
plot([sf4,sg1],[hf4,hg1],'r','linewidth',1)
text(sg1,hg1,'1s')
plot([sg1,s1],[hg1,h1],'r','linewidth',1)
xlabel('Entropy (Kj/Kg-k)')
ylabel('Enthalpy (Kj/Kg)')
title('Ideal rankine cycle H-S diagram without subcooling')
legend('liquid saturation curve','vapour saturation curve','Rankine cycle process steps','location','southeast')
elseif strcmp(Type,'yes')== 1
t3=input('Enter the value of subcooled temperature(celcius) at condensor exit : ');
fprintf('t3 is %f degrees n',t3);
h3=hf3-Cp2ofliquid*(Tsatatp2-t3);
s3=sf3+(Cp2ofliquid*log((t3+273.15)/(Tsatatp2+273.15)));
fprintf('h3 is %f Kj/Kg n',h3);
fprintf('s3 is %f Kj/kg-K n',s3);
%calculation of properties at state 4
cprintf('*red','At state point 4n');
p4=p1;
s4=s3;
fprintf('p4 is %f bar n',p4);
V3=XSteam('vL_p',p3);
%work done by the pump in Kj/Kg
Wp=V3*(p4-p3)*100;
h4=Wp+h3;
fprintf('h4 is %f Kj/Kg n',h4);
Cp=XSteam('Cp_ps',p3,s3);
Cv=XSteam('Cv_ps',p3,s3);
k=exp((sf1-s4)/Cp1ofliquid);
t4=Tsatatp1/k;
fprintf('t4 is %f degrees nn',t4);
%work done by turbine
Wt=h1-h2;
%Net work done
Wnet=Wt-Wp;
%Heat input by the boiler
Qin=h1-h4;
%Thermal efficiency of Rankine cycle
eff=(Wnet/Qin)*100;
%specific steam consumption
SSC=3600/Wt;
%Back work ratio
BWR=Wp/Wt;
cprintf('*blue','Work done by turbine is %f Kj/Kg nn',Wt);
cprintf('*blue','Work done by pump is %f Kj/Kg nn',Wp);
cprintf('*blue','Net Work done is %f Kj/Kg nn',Wnet);
cprintf('*blue','Heat input by boiler is %f Kj/Kg nn',Qin);
cprintf('*blue','Efficiency of Rankine cycle is %f nn',eff);
cprintf('*blue','Specific steam consumption is %f Kg/KW-Hrnn',SSC);
cprintf('*blue','Back work Ratio is %f nn',BWR);
%plotting saturation liquid and vapour line
temp=linspace(1,400,1000);
for i=1:length(temp)
hl(i)=XSteam('hL_T',temp(i));
hv(i)=XSteam('hV_T',temp(i));
sl(i)=XSteam('sL_T',temp(i));
sv(i)=XSteam('sV_T',temp(i));
end
figure(1)
plot(sl,temp,'b','linestyle','--','linewidth',1)
hold on
plot(sv,temp,'b','linestyle','--','linewidth',1)
axis([0 10 0 750])
plot([s1,s2],[t1,t2],'r','linewidth',1)
text(s1,t1,'1')
text(s2,t2,'2')
plot([s2,sg2],[t2,Tsatatp2],'color','r','linestyle','--','linewidth',1)
text(sg2,Tsatatp2,'2s')
plot([sg2,sf3],[Tsatatp2,Tsatatp2],'r','linewidth',1)
plot([sf3,s3],[Tsatatp2,t3],'r','linewidth',1)
text(s3,t3,'3')
text(sf3,Tsatatp2,'3s')
plot([s3,s4],[t3,t4],'r','linewidth',1)
text(s4,t4,'4')
plot([s4,sf4],[t4,Tsatatp1],'r','linewidth',1)
text(sf4,Tsatatp1,'4s')
plot([sf4,sg1],[Tsatatp1,Tsatatp1],'r','linewidth',1)
text(sg1,Tsatatp1,'1s')
plot([sg1,s1],[Tsatatp1,t1],'r','linewidth',1)
xlabel('Entropy (Kj/Kg-k)')
ylabel('Temperature (K)')
title('Ideal rankine cycle T-S diagram with subcooling')
legend('liquid saturation curve','vapour saturation curve','Rankine cycle process steps')
figure(2)
hold on
plot(sl,hl,'b','linestyle','--','linewidth',1)
hold on
plot(sv,hv,'b','linestyle','--','linewidth',1)
plot([s1 s2],[h1,h2],'r','linewidth',1)
text(s1,h1,'1')
text(s2,h2,'2')
plot([s2,sg2],[h2,hg2],'color','r','linestyle','--','linewidth',1)
text(sg2,hg2,'2s')
plot([sg2,sf3],[hg2,hf3],'r','linewidth',1)
text(sf3,hf3,'3s')
plot([sf3,s3],[hf3,h3],'r','linewidth',1)
text(s3,h3,'3')
plot([s3,s4],[h3,h4],'r','linewidth',1)
text(s4,h4,'4')
plot([s4,sf4],[h4,hf4],'r','linewidth',1)
text(sf4,hf4,'4s')
plot([sf4,sg1],[hf4,hg1],'r','linewidth',1)
text(sg1,hg1,'1s')
plot([sg1,s1],[hg1,h1],'r','linewidth',1)
xlabel('Entropy (Kj/Kg-k)')
ylabel('Enthalpy (Kj/Kg)')
title('Ideal rankine cycle H-S diagram with subcooling')
legend('liquid saturation curve','vapour saturation curve','Rankine cycle process steps','location','southeast')
else
fprintf('please enter valid input Error!clcn')
Err='Error';
end
else
fprintf('steam is not generated at this temperature Error!');
end
Code explanation :
1) By using the input command the user will input the values of temperature and pressure of turbine inlet and pressure at condensor inlet
2) The code will calculate all the state points at states 1 and 2 now the program will ask the user is there any subcooling or not? If the user types no the remaining state points will be executed. If user types yes then the user has to input the value of subcooled temperature.
3) All the Enthapy values and Entropy values are taken from Xsteam.m file
4) T-S graph and H-s graph will be plotted.
Outputs :




With subcooling :



Errors : All are Typo errors and they are rectified