Challenge

Project 2 - Rankine cycle Simulator

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 main code

clear all
close all
clc

fprintf('Rankine cycle\n')
fprintf('1-2 is isentropic expansion in turbine\n')
fprintf('2-3 is constant pressure heat removal\n')
fprintf('3-4 is isentropic compression in pump\n')
fprintf('4-1 constant pressure heat addition in boiler\n')

% entering inputs
p1 = 50;
T1 = 500;
p2 = 5;

% taking data from XSteam file 1 - state
h1 = XSteam('h_pT',p1,T1);
s1 = XSteam('s_pT',p1,T1);

%taking data from XSteam file 2 - state
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));

% taking data from Xsteam file 3 - state
p3 = p2;
s3 = XSteam('sL_p',p3);
h3 = XSteam('hL_p',p3);

% taking data from Xsteam file 4 - state
s4 = s3;
p4 = p1;

% work done in turbine for rankine cycle
W_T = h1-h2;

% work done required for pump
v3 = XSteam('vL_p',p3);
W_p = v3*(p4-p3)*100;
h4 = h3 - W_p;

% net work done
W_net = W_T - W_p;

% Heat addiction
Q_in = h1-h4;
% heat rejection
Q_out = h2-h3;

% thermal efficiency
T_eff = (W_net/Q_in)*100;

% specific steam
Sp_S = (3600/W_net);

% calculating temp
T3 = XSteam('Tsat_p',p3);
T2 = T3;
Cp4 = XSteam('Cp_ps',p4,s4);
Cv4 = XSteam('Cv_ps',p4,s4);
k = Cp4/Cv4;
T4 = T3/((p3/p4)^((k-1)/k));

%
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
T = linspace(1,560,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,'color','b','lineWidth',2)
plot(sg,T,'color','b','LineWidth',2)
plot([s1 s2],[T1 T2],'Color','r','LineWidth',3)
plot([s2 s3],[T2 T3],'Color','r','LineWidth',3)
plot([s3 s4],[T3 T4],'Color','r','LineWidth',3)
plot([s4 s5],[T4 T5],'Color','r','LineWidth',3)
plot([s5 s6],[T5 T6],'Color','r','LineWidth',3)
s_1 = linspace(s6,s1,1000);
for j = 1:length(s_1)
Tc(j) = XSteam('T_ps',p1,s_1(j));
end
plot(s_1,Tc,'Color','r','LineWidth',3)
text(s1+0.1,T1,'1')
text(s2+0.1,T2,'2')
text(s3, T3-20,'3')
text(s4, T4+20,'4')
title('Temperature vs Entropy')
xlabel('entropy (Kj/kg-k)')
ylabel('Temperature (deg.Celcius)')
legend('saturation curve')

% plotting H-S dia
figure(2)
hold on
plot(sf,hf,'color','b','LineWidth',2)
plot(sg,hg,"Color",'b','LineWidth',2)
plot([s1 s2],[h1 h2],'Color','r','LineWidth',3)
plot([s2 s3],[h2 h3],'Color','r','LineWidth',3)
plot([s3 s4],[h3 h4],'Color','r','LineWidth',3)
hc = linspace(h4,h5,100);
for k = 1:length(hc)
s_c(k) = XSteam('s_ph',p1,hc(k));
end
plot(s_1,h_c,'color','r','LineWidth',3)
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')
xlabel('Entropy (Kj/kg-K)')
ylabel('Enthalpy (Kj/Kg)')
legend('saturation curve')

-----------------------------------------------------------------------------------------------------------------------

https://en.wikipedia.org/wiki/Rankine_cycle

https://youtu.be/QFZN71MY71o

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.