Project 2 - Rankine cycle Simulator
AIM:- To Create a Rankine Cycle Simulator using MATLAB.
OBJECTIVE:-
- To create a program that calculates the state points.
- To use the thermodynamics relation to get the points in between the state variables.
- To plot the T-S and H-S diagram for rankine cycle.
THEORY:- A steam power plant continuously converts the energy stored in fossil fuels (coal, oil, natural gas) into shaft work and ultimately into electricity. A general layout of a steam power plant is shown below

Rankine cycle is the fundamental cycle of all vapour power cycle.
- for the steam boiler, this would be a reversible constant pressure heating process of water to form steam, for the turbine the ideal process would be a reversible adiabatic expansion of steam.
- for the condenser it would be a reversible constant pressure heat rejection as the steam condenses till it becomes saturated liquid
- and for the pump the ideal process would be the reversible adiabatic compression of this liquid ending at the initial pressure.
when all the four process are ideal, the cycle is an ideal cycle ,called as Rankine cycle. we Applying the steady flow energy equation ( SFEE ) to each of the processes on the basis of a unit mass of the fluid and neglecting changes in kinetic and potential energy, the work and heat interactions can be calculated in terms of fluid properties.

Process wise explanation:-
- Boiler (2) 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.
-
Turbine (3) 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%.
-
Condenser (4) 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.
- Pump (1) 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.
Formula used:-
- Heat addition(Qin) = (Enthalpy at turbine inlet) - (Enthalpy at pump outlet) = h1 - h4.
- Heat rejection(Qout) = (Enthalpy at turbine outlet) - (Enthalpy at pump inlet) = h2 - h3.
- Work done by turbine(Wt) = (Enthalpy at turbine inlet) - (Enthalpy at turbine outlet) = h1 - h2.
- Work taken by pump(Wp) = (Enthalpy at pump outlet) - (Enthalpy at pump inlet) = h4 - h3.
- Thermal efficiency = (Wt - Wp)/Qin.
- Net work output = Wt - Wp.
- Back work ratio(BWR) = Wp/Wt.
- Specific steam consumption(SSC) = 3600/Net work output.
MATLAB PROGRAM FOR RANKINE CYCLE (SIMULATOR):-
clear all
close all
clc
disp("RANKINE CYCLE SIMULATOR")
disp('1-2 = isentropic expansion in the turbine');
disp('2-3 = constant pressure heat rejection by the condensor');
disp('3-4 = isentropic compression in the pump');
disp('4-1 = constant pressure heat addition by the boiler');
p1 = input('Value of pressure at turbine inlet,p1(in bar) = ');
T1 = input('Value of temperature at turbine inlet, T1( in degree.C) = ');
p2 = input('Value of pressure at condenser inlet, p2(in bar) = ');
% at state 1
h1= XSteam('h_pT',p1,T1);
s1= XSteam('s_pT',p1,T1);
% at state 2
s2=s1;
sf2=XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
x2= (s2-sf2)/(sg2-sf2);
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);
h2= hf2 + (x2*(hg2-hf2));
% at state 3
p3 = p2;
s3 = XSteam('sL_p',p3);
h3 = XSteam('hL_p',p3);
% at state 4
s4=s3;
p4=p1;
% work done by the Turbine
Wt = h1 - h2;
% work required to run the pump
v3 = XSteam('vL_p',p3);
Wp = v3*(p4-p3)*100;
h4 = h3+Wp;
% Net work
Wnet = Wt-Wp;
% Heat added to the system by boiler
Qin = h1 - h4;
% Heat out of the system
Qout = h2 - h3;
% Thermal efficiency
thermal_eff = (Wnet/Qin)*100;
% Back work ratio
BW = (Wp/Wt);
% specific steam Consumption
SSC = (3600/Wnet);
% calculating Temp and gamma
T3= XSteam('Tsat_p',p3);
T2 = T3;
cp4 = XSteam('cp_ps',p4,s4);
cv4 = XSteam('cv_ps',p4,s4);
gamma= (cp4/cv4);
k=((gamma-1)/gamma);
T4 = T3/((p3/p4)^k);
% temp,Entropy,Enthalpy Calculation
T6 = XSteam('Tsat_p',p1);
s5 = XSteam('sL_p',p1);
s6 = XSteam('sV_p',p1);
h5 = XSteam('hL_p',p1);
h6 = XSteam('hV_p',p1);
T5 = T6;
% Plotting the saturation curve
T = linspace(1,400,1000);
for i = 1:length(T)
sf(i) = XSteam('sL_T',T(i));
sg(i) = XSteam('sV_T',T(i));
hf(i) = XSteam('hL_T',T(i));
hg(i) = XSteam('hV_T',T(i));
end
% plotting T-S diagram
figure(1)
hold on
plot(sf, T, 'r','LineWidth',1)
plot(sg, T, 'r','LineWidth',1)
plot([s1 s2],[T1 T2],'b','lineWidth',2)
plot([s2 s3],[T2 T3],'b','LineWidth',2)
plot([s3 s4],[T3 T4],'b','LineWidth',2)
plot([s4 s5],[T4 T5],'b','LineWidth',2)
plot([s5 s6],[T5 T6],'b','LineWidth',2)
sc1 = linspace(s6,s1,1000);
for l=1:length(sc1)
Tc1(l)= XSteam('T_ps',p1,sc1(l));
end
plot(sc1,Tc1,'b','LineWidth',2)
text(s1+0.1,T1,'1')
text(s2+0.1,T2,'2')
text(s3,T3-20,'3')
text(s4,T4+20,'4')
title('Temp vs Entropy plot')
xlabel('Entropy(S) [ kJ/kgK ] ')
ylabel('Temperature(T) [ Degree c ] ')
legend('Saturation Curve')
% Plotting H-S diagram
figure(2)
hold on
plot(sf,hf,'k','LineWidth',1)
plot(sg,hg,'k','LineWidth',1)
plot([s1 s2],[h1 h2],'r','LineWidth',2)
plot([s2 s3],[h2 h3],'r','LineWidth',2)
plot([s3 s4],[h3 h4],'r','LineWidth',2)
hc = linspace(h4,h5,100);
for r=1:length(hc)
sch(r) = XSteam('s_ph',p1,hc(r));
end
plot(sch,hc,'r','LineWidth',2)
plot([s5 s6],[h5 h6],'r','LineWidth',2)
for n=1:length(sc1)
hc1(n)=XSteam('h_ps',p1,sc1(n));
end
plot(sc1,hc1,'r','LineWidth',2)
text(s1+0.1,h1,'1')
text(s2+0.1,h2,'2')
text(s3,h3-100,'3')
text(s4,h4+200,'4')
title('Enthalpy vs Entropy plot')
xlabel('Entropy(S) [ kJ/kgK ] ')
ylabel('Enthalpy(H) [ KJ/kg ] ')
legend('saturation curve','Location','northwest')
disp('Results');
p1 = p1;
T1 = T1;
p2 = p2;
disp('At state point 1');
a1 = sprintf('P1 is %.3f bar',p1);
disp(a1);
a2 = sprintf('T1 is %.3f C',T1);
disp(a2);
a3 = sprintf('h1 is %.3f kJ/kg',h1);
disp(a3);
a4 = sprintf('s1 is %.3f kJ/kgK',s1);
disp(a4);
disp('At state point 2');
a5 = sprintf('P2 is %.3f bar',p2);
disp(a5);
a6 = sprintf('T2 is %.3f C',T2);
disp(a6);
a7 = sprintf('h2 is %.3f kJ/kg',h2);
disp(a7);
a8 = sprintf('s2 is %.3f kJ/kgK',s2);
disp(a8);
disp('At state point 3');
a9 = sprintf('P3 is %.3f bar',p3);
disp(a9);
a10 = sprintf('T3 is %.3f C',T3);
disp(a10);
a11 = sprintf('h3 is %.3f kJ/kg',h3);
disp(a11);
a12 = sprintf('s3 is %.3f kJ/kgK',s3);
disp(a12);
disp('At state point 4')
a13 = sprintf('P4 is %.3f bar',p4);
disp(a13);
a14 = sprintf('T4 is %.3f C',T4);
disp(a14);
a15 = sprintf('h4 is %.3f kJ/kg',h4);
disp(a15);
a16 = sprintf('s4 is %.3f kJ/kgK',s4);
disp(a16);
a17 = sprintf('Wt is %.3f kJ/kg',Wt);
disp(a17);
a18 = sprintf('Wp is %.3f kJ/kg',Wp);
disp(a18);
a19 = sprintf('Wnet is %.3f kJ/kg',Wnet);
disp(a19);
a20 = sprintf('Thermal_efficiency is %.2f Percent',thermal_eff);
disp(a20);
a21 = sprintf('Back work ratio is %.3f ',BW);
disp(a21);
a22 = sprintf('SSC is %.2f kg/kWh',SSC);
disp(a22);
Program Explanation:-
- XSteam data is used to extract properties ( Enthalpy, Entropy, Pressure, and Temperature ) for water and steam.
- The program Require Pressure, Temperature at Turbine inlet and Pressure at Condenser inlet.
- Now we call all state point data (given data in SXteam data file) from XSteam data file and we called it input data.we call Xsteam data as h1=XSteam('h_pt',p1,T1) and it give Enthalpy value at given pressure and temperature ( in bar and Degree celsius ).
- Now we can use thermodynamic relation and find further state point ( like h2 with the help of hf2 and hg2 ) here we need dryness fraction (x2). we have input data (sf2,sg2,s1=s2) with the help of these data we can compute x2 ( x2= (s2-sf2)/(sg2-sf2) ).
- Now we are able to compute work done by Turbine (Wt = h1 - h2 ), work require to run the pump ( Wp = v3*(p4-p3)*100 ), Net work done ( Wnet = Wt-Wp ), Heat in ( Qin = h1 - h4)and Heat out (Qout = h2 - h3 ) all the formula are derived with help of study flow energy equation(SFEE).
- Efficiency( thermal_eff = (Wnet/Qin)*100 ), Back work ratio ( BW = (Wp/Wt) ) and specific steam consumption ( SSC = (3600/Wnet) ) of Rankine cycle is also calculated with the help of thermodynamic relations.
- Temperature, Entropy and Enthalpy data are extracted from XSteam data file for liquid and vapour. some points data is not given in XSteam data file and we compute these points data previously with the help of Thermodynamic relations.
- Saturation curve is plotted in red colour in T-S and H-S diagram.
- now we plot all the points on T vs S and H vs S diagram with the help of plot command and mention all the detail ( colour, title, linewidth etc.... )
- The resultant plot is depends on user inputs. if user input can change plot (T-S and H-S) also change and finally Results are displayed in command window by using sprint command.
OUTPUT COMMAND WINDOW:-

OUTPUT PLOT:-
T - S diagram H - S diagram

Error:-
- This error comes many times, we fix this by writing XSteam in place of Xsteam

CONCLUSION:-
- The thermal efficiency based upon given input ( Turbine Inlet temperature = 400° C, Turbine Inlet Pressure = 30 bars, Turbine Outlet Pressure = 0.05 bars ) is 36.17%.
- The specific steam consumption is 3.22kg/kWh.