Challenge

Project 2 - Rankine cycle Simulator

Aim: Writing a MATLAB code to simulate the rankine cycle.

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.

Processes in Rankine cycle: There are four processes in the Rankine cycle.

  • 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. 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. Process 3-4 is isentropic expansion.
  • Process 4–1: The wet vapour then enters a condensor, where it is condensed at a constant pressure to become a saturated liquid. Process 4-1 is constant pressure heat rejection in condenser.

Matlab codes:

clear all 
close all
clc

disp('RANKINE CYCLE SIMULATOR');
disp('1-2 = isentropic expansion in the turbine');
disp('2-3 = contant pressure heat rejection by condensor');
disp('3-4 = isentropic compression in the pump');
disp('4-1 = constant pressure heat addition by boiler');

% To type the inputs and getting the text as given in the problem

t1 = 400;
p1=30;
p2=0.05;

fprintf('rRESULTSrn')

%stage 1 (turbine inlet)
s1=XSteam('s_pT' ,p1,t1);
h1=XSteam('h_pT' ,p1,t1);

%stage 2 condensor inlet
sf2=XSteam('sL_p',p2);
sg2=XSteam('sV_p',p2);
hf2=XSteam('hL_p',p2);
hg2=XSteam('sV_p',p2);

s2=s1;
t2=XSteam('Tsat_p',p2);

%splitting the formulae

x2=((s2-sf2)/(sg2-sf2));
h2=hf2+(x2*(hg2-hf2));

%stage 3 (pump inlet)
p3=p2;
t3=XSteam('Tsat_p' ,p2);
s3=XSteam('sL_p', p3);
h3=XSteam('hL_p', p3);

cp4 = XSteam('cpL_p', p3);
cv4 = XSteam('cvL_p', p3);
gamma = (cp4/cv4);
g = (gamma-1)/gamma;

%stage 4 (boiler inlet)
p4=p1;
s4=s3;
h4=XSteam('h_ps',p4,s4);
t4=t3*((p4/p3)^g);

%turbine work
wt=h1-h2;

%pump work
wp=h4-h3;
 
%net work
w_net=wt-wp;

%Heat in and out of the system
q_in=h1-h4;
q_out=h2-h3;

n=w_net/q_in;
np=n*100;

SSC=3600/w_net;
tf_sat=XSteam('Tsat_p', p1);
sf_sat=XSteam('sL_p', p1);
hf_sat=XSteam('hL_p', p1);
sg_sat=XSteam('sV_p', p1);
hg_sat=XSteam('sV_p', p1);

%plot figure 1
figure(1)
hold on
temp=linspace(0,400,1000);
for i=1:length(temp)
    aa(i)=XSteam('sL_T',temp(i));
end

for j=1:length(temp)
    bb(j)=XSteam('sV_T',temp(i));
end

plot(aa,temp,'color','b')
plot(bb,temp,'color','b')

temp=(XSteam('Tsat_p' ,p1));
t0=linspace(temp,t1,300);
for i=1:length(t0)
    c11(i)=XSteam('s_pt',p1,t0(i));
end

t5=XSteam('Tsat_p',p4);
s5=XSteam('sL_T',t5);

plot([s1 s2],[t1 t2],'color','r')
plot([s2 s3],[t2 t3],'color','r')
plot([s3 s4],[t3 t4],'color','r')
plot([s4 s5],[t4 t5],'color','r')
plot([sf_sat sg_sat],[tf_sat tf_sat],'color','r')
plot(c11,t0,'color','r')

title('T-S diagram')
xlabel('entropy(KJ/kgK)')
ylabel('Temperature(K)')

text(s1,t1,'1');
text(s2,t2,'2');
text(s3,t3,'3');
text(s4,t4,'4');
text(s5,t5,'5');
text(sg_sat,tf_sat,'1s');

%plotting figure 2
figure(2)
hold on

temp1=linspace(0,400,1000);
for i=1:length(temp1)
    cc(i)=XSteam('hL_T',temp1(i));
end

for j=1:length(temp1)
    dd(i)=XSteam('hV_T',temp1(j));
end

plot(aa,cc,'color','b')
plot(bb,dd,'color','b')

plot([s1 s2],[h1 h2],'color','r')
plot([s2 s3],[h2 h3],'color','r')
plot([s3 s4],[h3 h4],'color','r')
plot([s4 s1],[h4 h1],'color','r')

title('H-S diagram')
xlabel('entropy(KJ/kgK)')
ylabel('enthalpy(KJ/kg)')

text(s1,h1,'1');
text(s2,h2,'2');
text(s3,h3,'3');
text(s4,h4,'4');

%printing the output

fprintf('at stage point 1:n');
fprintf('P1 is : %f bar',p1);
fprintf('T1 is : %f deg celsius',p1);
fprintf('T1 is : %f KJ/kgn',h1);
fprintf('S1 is : %f KJ/kgKrn',s1);

disp('at stage point 2:');
fprintf('P2 is : %f barn',p2);
fprintf('T2 is : %f deg celsiusn',t2);
fprintf('H2 is : %f KJ/kgn',h2);
fprintf('S2 is : %f KJ/kgKrn',s2);
fprintf('X is : %f rn',x2);

disp('at stage point 3:');
fprintf('P3 is : %f bar',p3);
fprintf('T3 is : %f deg celsius',t3);
fprintf('H3 is : %f KJ/kgn',h3);
fprintf('S2 is : %f KJ/kgKbn',s3);

disp('at stage point 4:');
fprintf('P4 is : %f bar',p4);
fprintf('T4 is : %f deg celsius',t4);
fprintf('H4 is : %f KJ/kgn',h4);
fprintf('S4 is : %f KJ/kgKbn',s4);

fprintf('Wt : %f KJ/Kgn',wt);
fprintf('Wp : %f KJ/Kgn',wp);
fprintf('Wnet : %f KJ/Kgn',w_net);
fprintf('Ntherm : %f %%n',n*100 );
fprintf('SSC : %f KJ/KWhbn',SSC);




Explanation:

1) Xsteam data is used to extract steam and water properties of enthalpy, entropy at specific pressure and temperatures for sat liquid, sat vapour conditions etc.

2) The program requires the input of pressure at state pt. 1 temp. at same point and temp. at condensor inlet.

3) With the help of these inputs and Xsteam data, the program calculates all the state points of rankine cycle.

4) The Xsteam data works as, h1=Xsteam('h_pT',p1,T1);

5) As we extract the data, we use thermodynamic relations to further find state points.

6) sf,sg,hf and hg where f and g stands for saturated liquid and saturated vapour respecctively.

7) The net work, work done by turbine , pump work, heat in and heat out are calculated using thermodynamic relations. Efficiency and Specific steam consumption are also calculated.

8) Saturation curve is plotted in red. and also T-S and H-S plot created from all the points obtaine dfrom the program.

9) The plot changes as the user input changes for the above mentioned inputs.

10) Results are displayed in the command window.

Command window:

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.