Project 2 - Rankine cycle Simulator
Aim:
- Create a Rankine Cycle Simulator using MATLAB.
- To 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.
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. The Rankine cycle is named after William John Macquorn Rankine, a Scottish polymath professor at Glasgow University.
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 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.

The four processes in the Rankine cycle:
There are four processes in the Rankine cycle. The states are identified by numbers (in brown) 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. 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 an enthalpy–entropy chart (h–s chart, or Mollier diagram), or numerically, using steam tables or software. Process 2-3 is constant pressure heat addition in boiler.
Process 3–4:
The dry saturated vapor expands through a turbine, generating power. This decreases the temperature and pressure of the vapor, and some condensation may occur. The output in this process can be easily calculated using the chart or tables noted above. 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. Process 4-1 is constant pressure heat rejection in condenser.
In an ideal Rankine cycle the pump and turbine would be isentropic, i.e., the pump and turbine would generate no entropy and hence maximize the network output. Processes 1–2 and 3–4 would be represented by vertical lines on the T–s diagram and more closely resemble that of the Carnot cycle. The Rankine cycle shown here prevents the state of the working fluid from ending up in the superheated vapor region after the expansion in the turbine, [1] which reduces the energy removed by the condensers.
The actual vapor power cycle differs from the ideal Rankine cycle because of irreversibilities in the inherent components caused by fluid friction and heat loss to the surroundings; fluid friction causes pressure drops in the boiler, the condenser, and the piping between the components, and as a result the steam leaves the boiler at a lower pressure; heat loss reduces the net work output, thus heat addition to the steam in the boiler is required to maintain the same level of net work output.
Equations:

h1 - Enthalpy at turbine inlet.
h2 - Enthalpy at turbine outlet
h3 - Enthalpy at pump inlet
h4 - Enthalpy at pump outlet
wt - Work done by turbine
wp - Work taken by pump
Matlab code:
clear all
close all
clc
% displaying rankine cycle simulation and its processes
disp('Rankine cycle simulator');
fprintf('\n 1-2 is the isentropic expansion process');
fprintf('\n 2-3 is the constant pressure heat rejection process');
fprintf('\n 3-4 is the isentropic compression process');
fprintf('\n 4-1 is the constant pressur heat addition process');
% variables for stages 1
p1 = 30;
t1 = 400;
h1 = XSteam('h_pT',30,400);
s1 = XSteam('s_ph',30,h1);
fprintf('\n\n Results');
fprintf('\n\n at state point 1');
fprintf('\n P1 is : % f bar',p1);
fprintf('\n T1 is : % f deg celcius',t1);
fprintf('\n H1 is : % f KJ/Kg',h1);
fprintf('\n S1 is : % f KJ/Kg-k',s1);
% variables for stages 2
p2 = 0.05;
s2 = s1;
t2 = XSteam('T_ps',0.05,6.1858);
sf2 = XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);
x = ((s2-sf2)/(sg2-sf2));
h2 = hf2+(x*(hg2-hf2));
v2 = XSteam('v_ph',p2,h2);
fprintf('\n\n At State Point-2');
fprintf('\n P2 : %f bar',p2);
fprintf('\n T2 : %f deg celcius',t2);
fprintf('\n H2 : %f KJ/Kg',h2);
fprintf('\n P2 : %f KJ/Kg-K',s2);
% variables for stages 3
t3 = t2;
p3 = p2;
s3 = XSteam('sL_p',p3);
h3 = XSteam('hL_T',32.875);
v3 = XSteam('v_ph',p3,h3);
fprintf('\n\n At State Point-3');
fprintf('\n P3 is :%f bar', p3);
fprintf('\n T3 : %f deg celcius',t3);
fprintf('\n H3 : %f KJ/Kg',h3);
fprintf('\n P3 : %f KJ/Kg-K',s3);
% variables for stages 4
s4 = s3;
v4 = v3;
p4 = p1;
h4 = XSteam('h_ps',p4,s4);
t4 = XSteam('T_hs',h4,s4);
fprintf('\n\n At State Point-4');
fprintf('\n P4 is :%f bar', p4);
fprintf('\n T4 : %f deg celcius',t4);
fprintf('\n H4 : %f KJ/Kg',h4);
fprintf('\n P4 : %f KJ/Kg-K',s4);
% variables for stages 5
p5 = p4;
t5 = XSteam('Tsat_p',p5);
h5 = XSteam('hL_T',t5);
s5 = XSteam('sL_p',p5);
fprintf('\n\n At State Point-5');
fprintf('\n P5 is :%f bar', p5);
fprintf('\n T5 : %f deg celcius',t5);
fprintf('\n H5 : %f KJ/Kg',h5);
fprintf('\n P5 : %f KJ/Kg-K',s5);
% variables for stages 6
t6 = t5;
p6 = XSteam('psat_T',t5);
s6 = XSteam('sV_T',t6);
h6 = XSteam('hV_T',t6);
fprintf('\n\n At State Point-6');
fprintf('\n P6 is :%f bar', p6);
fprintf('\n T6 : %f deg celcius',t6);
fprintf('\n H6 : %f KJ/Kg',h6);
fprintf('\n P6 : %f KJ/Kg-K',s6);
% loop to find variable on saturation lines
t = linspace(0,400,1000);
for i = 1:length(t)
s_line1(i) = XSteam('sL_T',t(i));
end
for j = 1:length(t)
s_line2(j) = XSteam('sV_T',t(j));
end
for i = 1:length(t)
h_line1(i) = XSteam('hL_T',t(i));
end
for j = 1:length(t)
h_line2(j) = XSteam('hV_T',t(j));
end
% net work output calculation
w_turbine = h1-h2;
w_pump = h4-h3;
work = w_turbine - w_pump;
q_in = h1-h4;
q_out = h2-h3;
% thermal efficiency
n = work/q_in;
% Brak work ratio
BWR = w_pump/w_turbine;
% specific steam consumption
ssc = 3600/work;
% plotting
figure(1)
hold on
grid on
plot([s_line1 s_line2],[t t]);
plot([s1 s2 s3 s4 s5 s6 s1],[t1 t2 t3 t4 t5 t6 t1]);
text(s1,t1,'1')
text(s2,t2,'2')
text(s3,t3,'3')
text(s4,t4,'4')
text(s5,t5,'5')
text(s6,t6,'6')
title('Rankine Cycle T-S Diagram')
xlabel('Entropy(KJ/Kg-K)')
ylabel('Temperature(K)')
axis([0 8 0 450])
figure(2)
hold on
grid on
plot([s_line1 s_line2],[h_line1 h_line2])
plot([s1 s2 s3 s4 s5 s6 s1],[h1 h2 h3 h4 h5 h6 h1])
text(s1,h1,'1')
text(s2,h2,'2')
text(s3,h3,'3')
text(s4,h4,'4')
text(s5,h5,'5')
text(s6,h6,'6')
title('Rankine Cycle H-S Diagram')
xlabel('Entropy(KJ/Kg-K)')
ylabel('Enthalpy(KJ/Kg)')
axis([0 8 0 3600])
Results:
Rankine cycle simulator
1-2 is the isentropic expansion process
2-3 is the constant pressure heat rejection process
3-4 is the isentropic compression process
4-1 is the constant pressur heat addition process
Results
at state point 1
P1 is : 30.000000 bar
T1 is : 400.000000 deg celcius
H1 is : 3231.571027 KJ/Kg
S1 is : 6.923260 KJ/Kg-k
At State Point-2
P2 : 0.050000 bar
T2 : 32.875490 deg celcius
H2 : 2110.708472 KJ/Kg
P2 : 6.923260 KJ/Kg-K
At State Point-3
P3 is :0.050000 bar
T3 : 32.875490 deg celcius
H3 : 137.763073 KJ/Kg
P3 : 0.476254 KJ/Kg-K
At State Point-4
P4 is :30.000000 bar
T4 : 32.963066 deg celcius
H4 : 140.762226 KJ/Kg
P4 : 0.476254 KJ/Kg-K
At State Point-5
P5 is :30.000000 bar
T5 : 233.858445 deg celcius
H5 : 1008.371370 KJ/Kg
P5 : 2.645621 KJ/Kg-K
At State Point-6
P6 is :30.000000 bar
T6 : 233.858445 deg celcius
H6 : 2803.264739 KJ/Kg
P6 : 6.185788 KJ/Kg-K


Plots:


Conclusion:
1)Rankine cycle is a power generating cycle.
2)Superheating increase the thermal efficiency of cycle.
3)It is the most practical cycle.