Project 2 - Rankine cycle Simulator
AIM:
Create a Rankine Cycle Simulator using MATLAB.
Challenge expectations:
- 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.
- to get output in the commands window for all state points.
Concepts:
Rankine cycle is the Thermodynamic Cycle which describes processes like a Heat engine, Steam Turbine and Steam Engine, it will extract mechanical energy from some heat source and give some useful work. In Steam Turbine the Rankine cycle principle is used.

Components used in Steam Turbine
- 1. Turbine
- 2. Condensor
- 3. Pump
- 4. Boiler
The pump delivers liquid water to the boiler. The boiler heated by the solar heat converts water to superheated steam. This steam is used to run the turbine which powers the generator. Steam leaves the turbine and becomes cooled to a liquid state in the condenser. Then the liquid is pressurized by the pump and goes back to the boiler. And the cycle continues.
Working Principle:
There are Four Processes in Rankine Cycle
- Process 1-2: Isentropic Expansion in Turbine
Dry Saturated Vapour expands in the Turbine, generating power. The shafts are connected to a generator, which results in the production of electricity means the conversion of Mechanical energy to Electrical energy. - Process 2-3: Constant Pressure Heat Rejection in Condensor
The expanded vapor passed through the condenser, where it gets condensed and converted into Liquid again. This again pumped to the boiler. - Process 3-4: Isentropic Compression by Pump
In this process water comes into the pump in the saturated state then the liquid is compressed isentropically until get boiler pressure. - Process 4-1: Constant Pressure Heat Addition in Boiler
In this process water enters into boiler it converts into high-pressure steam in this process pressure will be constant in which Liquid phase change into Vapour.
Formulae used:

Required Inputs:
- Turbine Inlet Temperature = 400 C
- Turbine Inlet Pressure = 30 bars
- Turbine Outlet Pressure = 0.05 bars = Condenser Inlet Pressure
CODE:
clear all
close all
clc
% Rankine Cycle Process.
disp(' RANKINE CYCLE PROCESS')
fprintf('n')
disp('1-2 Isentropic Expansion in Turbine')
disp('2-3 Constant Pressure Heat Rejection in Condenser')
disp('3-4 Isentropic Compression in Pump')
disp('4-1 Constant Pressure Heat Addition in Boiler')
fprintf('n')
% Obtaining the input Data.
p1 = input('Turbine inlet Pressure in (bar), p1 = ');
t1 = input('Turbine inlet Temperature in (degree celcius), t1 = ');
p2 = input('Condenser inlet Pressure in (bar), p2 = ');
fprintf('n')
% State 1 Boiler Outlet or Turbine Inlet
% Enthalpy at Point 1
s1 = XSteam('s_pT',p1,t1);
h1 = XSteam('h_pT',p1,t1);
% State 2 Turbine outlet or Condenser Inlet
% Constant Pressure Heat Rejection in Condenser
s2 = s1;
t2 = XSteam('Tsat_p',p2);
% Saturated Liquid Entropy
sf2 = XSteam('sl_p',p2);
% Saturated Vapour Entropy
sg2 = XSteam('sV_p',p2);
% Saturated Liquid Enthalpy
hf2 = XSteam('hL_p',p2);
% Saturated Vapour Enthalpy
hg2 = XSteam('hV_p',p2);
% Vapour Fraction
x2 = ((s2-sf2)/(sg2-sf2));
% Enthalpy at Point 2
h2 = hf2+(x2*(hg2-hf2));
% State point 3 Condenser Outlet or Pump Inlet
p3 = p2;
t3 = t2;
s3 = XSteam('sL_p',p3);
h3 = XSteam('hL_p',p3);
v3 = XSteam('vL_p',p3);
% State point 4 Pump Outlet or Boiler Inlet
% Constant Pressure Heat Addition in Boiler
p4 = p1;
s4 = s3;
cp4 = XSteam('Cp_ps',p4,s4);
cv4 = XSteam('Cv_ps',p4,s4);
g4 = cp4/cv4;
o = (g4-1)/g4;
t4 = t3*((p4/p3)^o);
% Work done by Pump
Wp = v3*(p4-p3)*100;
h4 = h3+Wp;
% State 5
s5 = XSteam('sL_p',p1);
h5 = XSteam('hL_p',p1);
t5 = XSteam('Tsat_p',p1);
% State 6
s6 = XSteam('sV_p',p1);
h6 = XSteam('hV_p',p1);
t6 = t5;
% Work done by turbine
Wt = h1-h2;
% Net Work done
Wnet = Wt-Wp;
% Heat in
Qin = h1-h4;
% Heat out
Qout = h2-h3;
% Thermal Efficiency
eff = Wnet/Qin;
% Creating an Array for Temperature
T = linspace(1,400,1000);
% Entropy and Enthalpy values for creating saturation Curve
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 for Cycle
figure(1)
hold on
plot(sf,T,'linewidth',1.5)
plot(sg,T,'linewidth',1.5)
plot([s1 s2],[t1 t2],'linewidth',1.5,'color','k')
plot([s2 s3],[t2 t3],'linewidth',1.5,'color','k')
plot([s3 s4],[t3 t4],'linewidth',1.5,'color','k')
plot([s4 s5],[t4 t5],'linewidth',1.5,'color','k')
plot([s5 s6],[t5 t6],'linewidth',1.5,'color','k')
%plot([s6,s1],[t6,t1],'linewidth',1.5,'color','k')
s_c = linspace(s6,s1,1000);
for l = 1:length(s_c)
t_c(l) = XSteam('t_ps',p1,s_c(l));
end
plot(s_c,t_c,'k','linewidth',4)
legend('saturated Liquid','Saturated Vapour')
%axis([0 8 0 450])
grid on
xlabel('Entropy(S)')
ylabel('Temperature(T)')
title('Temperature(T)Vs Entropy(S)')
% saveas(figure(1),'T vs S.jpg')
% Plotting H-S Diagram for Cycle
figure(2)
plot(sf,hf,'linewidth',1.5,'color','r')
hold on
plot(sg,hg,'linewidth',1.5,'color','r')
plot([s1 s2],[h1 h2],'linewidth',1.5,'color','k')
plot([s2 s3],[h2 h3],'linewidth',1.5,'color','k')
plot([s3 s4],[h3 h4],'linewidth',1.5,'color','k')
plot([s4 s5],[h4 h5],'linewidth',1.5,'color','k')
plot([s5 s6],[h5 h6],'linewidth',1.5,'color','k')
plot([s6 s1],[h6 h1],'linewidth',1.5,'color','k')
legend('saturated curve')
axis([0 8 0 450])
grid on
xlabel('Entropy(S)')
ylabel('Enthalpy(H)')
title('Enthalpy(H)Vs Entropy(S)')
saveas(figure(2),'H vs S.jpg')
% Back work ratio
Back_work_ratio = (h4-h3)/(h1-h2);
% SSC
SSC = 3600/(h1-h2);
% Displaying Results
disp(' Results')
fprintf('n')
fprintf('State point 1:n')
fprintf('P1 = %f bar n',p1)
fprintf('T1 = %f *Cn',t1)
fprintf('H1 = %f KJ/Kgmn',h1)
fprintf('S1 = %f KJ/Kg-kn',s1)
fprintf('n')
fprintf('State point 2:n')
fprintf('P2 = %f bar n',p2)
fprintf('T2 = %f *Cn',t2)
fprintf('H2 = %f KJ/Kgmn',h2)
fprintf('S2 = %f KJ/Kg-kn',s2)
fprintf('X2 = %f n',x2)
fprintf('n')
fprintf('State point 3:n')
fprintf('P3 = %f bar n',p3)
fprintf('T3 = %f *Cn',t3)
fprintf('H3 = %f KJ/Kgmn',h3)
fprintf('S3 = %f KJ/Kg-kn',s3)
fprintf('n')
fprintf('State point 4:n')
fprintf('P4 = %f bar n',p4)
fprintf('T4 = %f *Cn',t4)
fprintf('H4 = %f KJ/Kgmn',h4)
fprintf('S4 = %f KJ/Kg-kn',s4)
fprintf('n')
fprintf('Work done by Turbine = %f KJ/Kgn',Wt)
fprintf('Work done by Pump = %f KJ/Kgn',Wp)
fprintf('Net Work done = %f KJ/Kgn',Wnet)
fprintf('Thermal Efficiency = %f %n',eff)
fprintf('S.S.C = %f KJ/Kg-kn',SSC)
Explanation of code:
- To print all process descriptions in Command Window we used here 'fprintf' Command.
- Then we can get the inputs like Pressure at the turbine inlet, Temperature at Turbineand Pressure at the condenser inlet.
- Then we calculated the state point values at various states like State-1, State-2, State-3, and State-4 from 'XSteam.m' file. we used XSteam data to calculate Enthalpy and Entropy at various Temperatures and Pressure. By using this we calculated Various state points in the Rankine cycle.
- The 'XSteam' data workes as h1=XSteam('h_pT',T1); (Enthalpy at pressure and Temperature 1).
- Then we calculated the work done by Turbine (Wt), Work done by pump(Wp), Network (Wnet), Heat in In system(Qin), Heat out In system(Qout), Thermal efficiency, and S.S.C by using the formulas.
- By using For LOOP and 'Plot' command we are plotting the saturation curve for the T-S diagram (Fig.1) and H-S diagram (Fig.2)
- By using 'fprintf' command and 'disp' command we are getting results in Command window
By entering our Input Parameters Turbine Inlet temperature = 400 C, Turbine Inlet Pressure = 30 Bars
Turbine Outlet Pressure = 0.05 bars = Condenser Inlet Pressure in command window
we can get our results.
Errors while programming:
Not enough input arguments.

RESULTS:



Conclusion:
We can conclude that with the MATLAB program for the Rankine cycle and from this we can improve the efficiency can be increased and specific steam consumption can be decreased.
References: