Project 2 - Rankine cycle Simulator
Aim:
- Rankine cycle simulator.
- Plot T-S and H-S diagrams.
- Efficiency and Back work ratio calculation.
Introduction:
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.
The Rankine cycle operates in the following steps:
-
1-2 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-5 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 .

Figure-1 Rankine cycle
- Efficiency of Rankine cycle = Net work done/Heat supplied = ((h1-h2)- (h4-h3))/(h1-h4)
h = Enthalpy
- Back work ratio = 1 - Work ratio = 1- ((net work done)/work done by turbine).
Procedure and Results:
- Open matlab and go to editor window. Write clc,clear all and close all.
- After downloading the XSteam.m file, use 'fprintf' command to explain the different processes and display it in the command window.Use '\n' to go to the next line.
clc clear all close all %% Defining all processes fprintf('1-2 is Reversible adiabatic expansion in Turbine\n'); fprintf('2-3 is Constant pressure heat rejection in Condensor\n'); fprintf('3-4 is Reversible adiabatic increase in pressure in pump\n'); fprintf('4-1 is Constant pressure heat addition in Boiler\n');

- Now define input conditions. Inlet temperature, pressure and exit pressure of turbine is given in the problem statement. Now to find the inlet enthapy and entropy, Use the XSteam function file and inlet conditions. For example h1 = XSteam('h_pt',p1,t1). Remember to use the same intex as given in the function file. We calculate saturated liquid and vapor enthalpy as well. We will use these values later.
- Now at the exit of the turbine, Entropy will remain same (s2 = s1). Using this and saturated vapor and liquid values of entropy at this pressure, we fine the dryness fraction value. Once the dryness fraction is calculated, enthalpy can be found easily.
- At the exit of condensor or at the inlet of pump, enthalpy and entropy are always equal to the saturated liquid enthalpy and entropy at the given pressure. We use this concept to find h3 and s3.
- Now at boiler inlet, again entropy will remain same as the one at the pump inlet. Therefore s4 = s3. To find h4, we use p1 and s4. Finding temperature at boiler inlet is a tricky one and we can find that using entrop relation with temperature and pressure, but for that we need specific heat(cp4) of saturated liquid at pressure p1 or p4(both are equal). After finding cp4 we find entropy of saturated liquid at pressure p1.
%% Turbine inlet
tsat = XSteam('TSat_p',p1);
h1 = XSteam('h_pt',p1,t1);
hf1 = XSteam('hL_p',p1);
hg1 = XSteam('hV_p',p1);
s1 = XSteam('s_ph',p1,h1);
%% Condensor inlet
s2 = s1;
% s2 = sf2 + x(sg2-sf2)
sf2 = XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
x = (s2 - sf2)/(sg2-sf2);
% h2 = hf2 + x(hg2-hf2)
h2 = XSteam('h_px',p2,x);
%% Pump inlet
% h3 = hf2
h3 = XSteam('hl_p',p2);
s3 = XSteam('sl_p',p2);
%% Boiler inlet
s4 = s3;
sf4 = XSteam('sL_p',p1);
sg4 = XSteam('sV_p',p1);
x2 = (s4 - sf4)/(sg4-sf4);
h4 = XSteam('h_ps',p1,s4);
p4 = p1;
cp4 = XSteam('CpL_p',p4);
ts4 = XSteam('Tsat_p',p1);
sf4 = XSteam('sL_p',p1);
t4 = ts4/(exp((sf4-s4)/cp4)); % Entropy tempearture and pressure relation
%% Temperatures
tsat2 = XSteam('TSat_p',p2);
t3 = tsat2;
%t4= XSteam('T_ps',p4,s4);
- Now we can find the value of Efficiency and Back work ratio, as all the enthalpy values are known. We use the formulas defined in the introduction section to find these values.
%% Efficiency and Back work ratio
W_t = h1-h2;
W_p = h4-h3;
Q_i = h1-h4;
W_ratio = (W_t - W_p)/W_t;
Back_work_ratio = 1 - W_ratio
Efficiency = ((W_t - W_p)/Q_i)*100

- Plotting has been divided into two parts. Firstly we need to plot the saturated liquid and vapor lines. For this part we first make an array of pressure using its upper and lower value, using linspace command. Now we need temperature, entropy and enthalpy value at each point, therefore we use a for loop.
- To plot the T-S and H-S graphs, We use all the values of temperature, entropy and enthalpy at all state points. Saturated vapor and liquid lines are made using red * . x and y axis are labelled accordingly and title is marked for both the plots.
%% plotting graph
% T-S
plot([s1 s2],[t1 tsat2],'color','g')
plot([s2 s3],[tsat2 tsat2],'color','g')
plot([s3 s3],[tsat2 t4],'color','g')
plot([s3 sf4],[t4 ts4],'color','g')
plot([sf4 sg1],[ts4 ts4],'color','g')
plot([sg1 s1],[ts4 t1],'color','g')
text(s1+0.15,t1,'1');
text(s2+0.15,tsat2,'2');
text(s3-0.25,tsat2,'3');
text(s3-0.25,t4,'4');
title('T-S graph');
xlabel('Entropy(KJ/KG) C')
ylabel('Temperature(C)')
%H-S
figure(2)
hold on
plot(sf,hf,'*','color','r')
plot(sg,hg,'*','color','r')
plot([s1 s2],[h1 h2],'color','g')
plot([s2 s3],[h2 h3],'color','g')
plot([s3 s3],[h3 h4],'color','g')
plot([s3 sf4],[h4 hf1],'color','g')
plot([sf4 sg1],[hf1 hg1],'color','g')
plot([sg1 s1],[hg1 h1],'color','g')
text(s1+0.15,h1,'1');
text(s2+0.25,h2,'2');
text(s3-0.25,h3,'3,4');
xlabel('Entropy(KJ/KG) C')
ylabel('Enthalpy(KJ/KG)')
title('H-S graph');


- At last we can print the values of pressure, temperature, enthalpy and entropy using 'fprintf' command for every state.
fprintf('Results\n')
fprintf('\n')
fprintf('State-1\n')
fprintf('Pressure = %f %s\n',p1,'bar')
fprintf('Temperature = %f %s\n',t1,'C')
fprintf('Enthalpy = %f %s\n',h1,'KJ/KG')
fprintf('Entropy = %f %s\n',s1,'KJ/KG C')
fprintf('\n')
fprintf('State-2\n')
fprintf('Pressure = %f %s\n',p2,'bar')
fprintf('Temperature = %f %s\n',tsat2,'C')
fprintf('Enthalpy = %f %s\n',h2,'KJ/KG')
fprintf('Entropy = %f %s\n',s2,'KJ/KG C')
fprintf('\n')
fprintf('State-3\n')
fprintf('Pressure = %f %s\n',p2,'bar')
fprintf('Temperature = %f %s\n',t3,'C')
fprintf('Enthalpy = %f %s\n',h3,'KJ/KG')
fprintf('Entropy = %f %s\n',s3,'KJ/KG C')
fprintf('\n')
fprintf('State-4\n')
fprintf('Pressure = %f %s\n',p1,'bar')
fprintf('Temperature = %f %s\n',t4,'C')
fprintf('Enthalpy = %f %s\n',h4,'KJ/KG')
fprintf('Entropy = %f %s\n',s4,'KJ/KG C')

Final code:
clc
clear all
close all
%% Defining all processes
fprintf('1-2 is Reversible adiabatic expansion in Turbine\n');
fprintf('2-3 is Constant pressure heat rejection in Condensor\n');
fprintf('3-4 is Reversible adiabatic increase in pressure in pump\n');
fprintf('4-1 is Constant pressure heat addition in Boiler\n');
%% Input
t1 = 400; %% 400 C
p1 = 30; %% Turbine pressure at inlet
p2 = 0.05; %% Turbine pressure at outlet
%% Turbine inlet
tsat = XSteam('TSat_p',p1);
h1 = XSteam('h_pt',p1,t1);
hf1 = XSteam('hL_p',p1);
hg1 = XSteam('hV_p',p1);
s1 = XSteam('s_ph',p1,h1);
%% Condensor inlet
s2 = s1;
% s2 = sf2 + x(sg2-sf2)
sf2 = XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
x = (s2 - sf2)/(sg2-sf2);
% h2 = hf2 + x(hg2-hf2)
h2 = XSteam('h_px',p2,x);
%% Pump inlet
% h3 = hf2
h3 = XSteam('hl_p',p2);
s3 = XSteam('sl_p',p2);
%% Boiler inlet
s4 = s3;
sf4 = XSteam('sL_p',p1);
sg4 = XSteam('sV_p',p1);
x2 = (s4 - sf4)/(sg4-sf4);
h4 = XSteam('h_ps',p1,s4);
p4 = p1;
cp4 = XSteam('CpL_p',p4);
ts4 = XSteam('Tsat_p',p1);
sf4 = XSteam('sL_p',p1);
t4 = ts4/(exp((sf4-s4)/cp4)); % Entropy tempearture and pressure relation
%% Temperatures
tsat2 = XSteam('TSat_p',p2);
t3 = tsat2;
%t4= XSteam('T_ps',p4,s4);
%% Efficiency and Back work ratio
W_t = h1-h2;
W_p = h4-h3;
Q_i = h1-h4;
W_ratio = (W_t - W_p)/W_t;
Back_work_ratio = 1 - W_ratio
Efficiency = ((W_t - W_p)/Q_i)*100
sf1 = XSteam('sL_p',p1);
sg1 = XSteam('sV_p',p1);
%% Plotting saturated vapour and liquid ine
p = 0.01:10:400;
for i = 1:length(p)
T(i) = XSteam('Tsat_p',p(i));
sf(i) = XSteam('sL_T',p(i));
sg(i) = XSteam('sv_T',p(i));
hf(i) = XSteam('hL_T',p(i));
hg(i) = XSteam('hv_T',p(i));
end
hold on
plot(sf,p,'*','color','r')
plot(sg,p,'*','color','r')
%% plotting graph
% T-S
plot([s1 s2],[t1 tsat2],'color','g')
plot([s2 s3],[tsat2 tsat2],'color','g')
plot([s3 s3],[tsat2 t4],'color','g')
plot([s3 sf4],[t4 ts4],'color','g')
plot([sf4 sg1],[ts4 ts4],'color','g')
plot([sg1 s1],[ts4 t1],'color','g')
text(s1+0.15,t1,'1');
text(s2+0.15,tsat2,'2');
text(s3-0.25,tsat2,'3');
text(s3-0.25,t4,'4');
title('T-S graph');
xlabel('Entropy(KJ/KG) C')
ylabel('Temperature(C)')
%H-S
figure(2)
hold on
plot(sf,hf,'*','color','r')
plot(sg,hg,'*','color','r')
plot([s1 s2],[h1 h2],'color','g')
plot([s2 s3],[h2 h3],'color','g')
plot([s3 s3],[h3 h4],'color','g')
plot([s3 sf4],[h4 hf1],'color','g')
plot([sf4 sg1],[hf1 hg1],'color','g')
plot([sg1 s1],[hg1 h1],'color','g')
text(s1+0.15,h1,'1');
text(s2+0.25,h2,'2');
text(s3-0.25,h3,'3,4');
xlabel('Entropy(KJ/KG) C')
ylabel('Enthalpy(KJ/KG)')
title('H-S graph');
fprintf('Results\n')
fprintf('\n')
fprintf('State-1\n')
fprintf('Pressure = %f %s\n',p1,'bar')
fprintf('Temperature = %f %s\n',t1,'C')
fprintf('Enthalpy = %f %s\n',h1,'KJ/KG')
fprintf('Entropy = %f %s\n',s1,'KJ/KG C')
fprintf('\n')
fprintf('State-2\n')
fprintf('Pressure = %f %s\n',p2,'bar')
fprintf('Temperature = %f %s\n',tsat2,'C')
fprintf('Enthalpy = %f %s\n',h2,'KJ/KG')
fprintf('Entropy = %f %s\n',s2,'KJ/KG C')
fprintf('\n')
fprintf('State-3\n')
fprintf('Pressure = %f %s\n',p2,'bar')
fprintf('Temperature = %f %s\n',t3,'C')
fprintf('Enthalpy = %f %s\n',h3,'KJ/KG')
fprintf('Entropy = %f %s\n',s3,'KJ/KG C')
fprintf('\n')
fprintf('State-4\n')
fprintf('Pressure = %f %s\n',p1,'bar')
fprintf('Temperature = %f %s\n',t4,'C')
fprintf('Enthalpy = %f %s\n',h4,'KJ/KG')
fprintf('Entropy = %f %s\n',s4,'KJ/KG C')
Conclusion:
- T-S and H-S plots are made.
- Efficiency calculated for this case is 36.16% and Back work ratuio is 0.0027.