Rankine cycle Simulator
AIM: To create a Rankine cycle simulator and code the program which can solve the state points of the Rankine cycle.
Objective:
- Create a Rankine cycle simulator.
- Plot T vs S and H vs S for a given set of points.
Theory:
The Rankine cycle is an idealized thermodynamic cycle describing the process by which certain heat engines, such as steam turbines or reciprocating steam engines, allow mechanical work to be extracted from a fluid as it moves between a heat source and heat sink. Heat energy is supplied to the system via a boiler where the working fluid (typically water) is converted to a high-pressure gaseous state (steam) in order to turn a turbine. After passing over the turbine the fluid is allowed to condense back into a liquid state as waste heat energy is rejected before being returned to the boiler, completing the cycle. Friction losses throughout the system are often neglected for the purpose of simplifying calculations as such losses are usually much less significant than thermodynamic losses, especially in larger systems.
There are four processes in the Rankine cycle. The states are identified by numbers in the T-s diagram.
- Process 1–2: The working fluid is pumped from low to high pressure. As the fluid is a liquid at this stage, the pump requires little input energy.
In other words, Process 1-2 is [Isentropic compression]
- Process 2–3: The high-pressure liquid enters a boiler, where it is heated at constant pressure by an external heat source to become a dry saturated vapour. The input energy required can be easily calculated graphically, using steam tables.
In other words, Process 2-3 is [Constant pressure heat addition in boiler]
- Process 3–4: The dry saturated vapour expands through a turbine, generating power. This decreases the temperature and pressure of the vapour, and some condensation may occur. The output in this process can be easily calculated using the chart or tables noted above.
In other words, Process 3-4 is [Isentropic expansion]
- Process 4–1: The wet vapour then enters a condenser, where it is condensed at a constant pressure to become a saturated liquid.
In other words, Process 4-1 is [Constant pressure heat rejection in condenser]

Entropy: Entropy, the measure of a system's thermal energy per unit temperature that is unavailable for doing useful work. Because work is obtained from ordered molecular motion, the amount of entropy is also a measure of the molecular disorder, or randomness, of a system.
Enthalpy: Enthalpy is a property of a thermodynamic system, defined as the sum of the system's internal energy and the product of its pressure and volume, H = U + pV. It is a convenient state function standardly used in many measurements in chemical, biological, and physical systems at a constant pressure.
Equations:
Wt(turbine work) = h3-h4
Wp(pump work) = V3*(P4-P3)
Qin = h3-h2
Wnet = Wt-Wp
Ntherm = Wt-Wp/Qin
SSC = 3600/Wnet
Variables:
- h is enthalpy(kj/kg)
- v is specific volume
- s is entropy(kj/kg)
Matlab coding for Rankine cycle
clear all
close all
clc
fprintf(' RANKINE CYCLE SIMULATOR n');
fprintf('1-2 is Isentopic Expansion in the Turbinen');
fprintf('2-3 is const pressure heat rejection by condensern');
fprintf('3-4 is isentropic compression in the pumpn');
fprintf('4-1 is const pressure heat addition by the boilern');
%inputs
P1 = input('Enter the pressure at the turbine inlet (in bar): ');
T1 = input('Enter the temprature at the turbine inlet (in degree celcius): ');
P2 = input('Enter the pressure at the condenser (in bar): ');
disp('Results')
%enthalpy and entropy as a function of pressure and temprature from steam table
%state point 1
h1 = XSteam('h_pT',P1,T1);
s1 = XSteam('s_pT',P1,T1);
%State point 2 AND 3
s2 = s1;
P3 = P2;
s_l3 = XSteam('sL_p',P3); %entropy at point 3 in liquid state
s_v2 = XSteam('sV_p',P2); %entropy at point 2 in vapour state
X =(s2-s_l3)/(s_v2-s_l3); %dryness fraction
%enthalpy at point 2 and 3
h3 = XSteam('hL_p',P3);
h_v = XSteam('hV_p',P2);
h2 = h3+X*(h_v-h3);
%temprature at state point 2
T2 = XSteam('T_ps',P2,s2);
%temprature at state point 3
T3=T2;
%at state point 4
P4 = P1;
s4 = s_l3;
V3 = XSteam('vL_p',P3);
W_p = V3*(P4-P3)*10^2;
h4 = h3+W_p;
T4 = XSteam('T_ps',P4,s4);
s41 = XSteam('sL_p',P4);
s42 = XSteam('sV_p',P4);
h41 = XSteam('hL_p',P4);
h42 = XSteam('hV_p',P4);
T41 = XSteam('T_ps',P4,s41);
T42 = XSteam('T_ps',P4,s42);
%entropy curve for vapour and liquid phase
temp_values = linspace(0,500,600);
for i = 1:length(temp_values)
s_v(i)=XSteam('sV_T',temp_values(i));
s_l(i)=XSteam('sL_T',temp_values(i));
h_v(i)=XSteam('hV_T',temp_values(i));
h_l(i)=XSteam('hL_T',temp_values(i));
end
% temprature curve from t4 to t41
t = linspace(T4,T41,50);
for i = 1:length(t)
S(i) = XSteam('s_pT',P4,t(i));
end
tv = linspace(T42,T1,300);
for i = 1:length(tv)
z(i) = XSteam('s_pT',P4,tv(i));
end
%output parameters
%turbine work
W_t = h1-h2;
W_net = W_t-W_p;
Ntherm = W_net/(h1-h4)*100;
SSC = 3600/W_net;
%displaying all values in command window
disp(' Results ')
disp('At stage point 1:')
a1 = sprintf('P1 is : %.3f bar', P1);
disp(a1)
a2 = sprintf('T1 is : %.3f degree celcius', 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:')
a9 = sprintf('P2 is : %.3f bar', P2);
disp(a9)
a10 = sprintf('T2 is : %.3f degree celcius', T2);
disp(a10)
a11 = sprintf('h2 is : %.3f kJ/kg', h2);
disp(a11)
a12 = sprintf('s2 is : %.3f kJ/kgK', s2);
disp(a12)
a13 = sprintf('X is : %.3f', X);
disp(a13)
disp('At state point 3:')
a14 = sprintf('P3 is : %.3f bar', P3);
disp(a14)
a15 = sprintf('T3 is : %.3f degree celcius', T3);
disp(a15)
a16 = sprintf('h3 is : %.3f kJ/kg', h3);
disp(a16)
a17 = sprintf('s3 is : %.3f kJ/kgK', s_l3);
disp(a17)
disp('At state point 4:')
a18 = sprintf('P4 is : %.3f bar', P4);
disp(a18)
a19 = sprintf('T4 is : %.3f degree celcius', T4);
disp(a19)
a20 = sprintf('h4 is : %.3f kJ/kg', h4);
disp(a20)
a21 = sprintf('s4 is : %.3f kJ/kgK', s4);
disp(a21)
a22 = sprintf('Wt is : %.3f KJ/kg', W_t);
disp(a22)
a23 = sprintf('Wp is : %.3f KJ/kg', W_p);
disp(a23)
a24 = sprintf('Wnet is : %.3f KJ/kg', W_net);
disp(a24)
a25 = sprintf('Ntherm is : %.3f percent', Ntherm);
disp(a25)
a26 = sprintf('S.S.C is : %.3f kg/KWh', SSC);
disp(a26)
%plot for ts
figure(1)
plot([s1 s2],[T1 T2],'linewidth',2,'color','black')
hold on
plot([s2 s_l3],[T2 T3],'linewidth',2,'color','black')
hold on
plot([s_l3 s4],[T3 T4],'linewidth',2,'color','black')
hold on
plot(S,t,'linewidth',2,'color','black')
hold on
plot([s41 s42],[T41 T42],'linewidth',2,'color','black')
hold on
plot(z,tv,'linewidth',2,'color','black')
plot(s_v,temp_values,s_l,temp_values,'color','y')
title('temprature vs entropy')
xlabel('entropy')
ylabel('temprature')
%plot for hs
figure(2)
plot([s1 s2],[h1 h2],'r')
hold on
plot([s2 s_l3],[h2 h3],'r')
hold on
plot([s_l3 s4],[h3 h4],'r')
hold on
plot([s4 s1],[h4 h1],'r')
hold on
plot(s_v,h_v,s_l,h_l,'color','g')
title('enthalpy vs entropy')
xlabel('entropy')
ylabel('enthalpy')
Output:


