Project

Rankine Cycle Simulator

Aim : To compute values of pressure, temperature, enthalpy and entropy at each state of Rankine cycle.

Introduction :

Rankine cycle : Many problems are faced with the Carnot Cycle that canbe eliminated by superheating the steam and then condensing it in Boiler and condenser respectively. Thus, this results in Rankine cycle, which is an ideal cycle for vapour power plants. The ideal Rankine cycle does not have any irreversibilities and has following four processes:

1 2: Isentropic Expansion
2-3: Constant Pressure Heat Rejection
3-4: Isentropic Compression by the Pump
4-1: Constant Pressure Heat Addition

The components are as follows:

Pump (3-4) : The water enters into the pump in saturated state. Then the liquid is compressed isentropically until it meets the boiler pressure. Work done by the pump is,

Wp =m( h3 - h4) KW

Boiler (4-1) : The water enters into the boiler as compressed and leaves as superheated from the boiler.Thus the phase changes from liquid to vapor. The heat supplied by the boiler is

Qb = m(h1 - h4) KW

Turbine (1-2) : Superheated steam enters into the Turbine and expands isentropically resulting in production of work. The shaft of the turbine is connected to the generator. This reults in production of electricity i.e Mechanical energy gets converted into electric energy.Work produced by the turbine,

Wt = m(h1 -h2) KW

Condenser (2-3) : The expanded vapor is then passed through condenser, where it gets condensed and converts into liquid again. This liquid is again pumped to the boiler.

Qr = m(h2 - h3) KW

The code to calculate the magnitudes of the temperature, pressure, enthalpy and entropy at various of rankine cycle is as follows,

Code :

clear all
close all
clc

disp(\'Rankine cycle\');
disp(\'1-2: Isentropic Expansion\');
disp(\'2-3: Constant Pressure Heat Rejection\');
disp(\'3-4: Isentropic Compression by the Pump\');
disp(\'4-1: Constant Pressure Heat Addition by Boiler\');

%Enter the inputs for the calculations of the rankine cycle
p1 =  input(\'Enter the pressure at the turbine inlet (Bar)-\');
t1 =  input(\'Enter the temperature at the turbine inlet (C)-\');
p3 =  input(\'Enter the pressure at the condenser (Bar)-\');

%calculations
p2 = p3;
p4 = p1;
h3 = XSteam(\'hL_p\',p3);
s3 = XSteam(\'sL_p\',p3);
t3 = XSteam(\'Tsat_p\',p3);
v3 = XSteam(\'vL_p\',p3);

t2 = t3;
s4 = s3;

cp4 = XSteam(\'Cp_ps\',p4,s4);
cv4 = XSteam(\'Cv_ps\',p4,s4);
gamma = cp4/cv4;

K = (gamma - 1)/gamma;
t4 = t3 *(p4/p3)^K;

pump_work = v3 *(p4-p3) * 100;     
h4 =  h3 + pump_work;

h1=XSteam(\'h_pT\', p1, t1);
s2=XSteam(\'s_pT\', p1, t1);

s1 = s2;
sf2 = XSteam(\'sL_p\',p2);
sg2 = XSteam(\'sV_p\',p2);
hf2 = XSteam(\'hL_p\',p2);
hg2 = XSteam(\'hV_p\',p2);

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

turbine_Work = h1-h2;     
net_work = turbine_Work-pump_work;   
q_in = h1-h4;             
q_out = h2-h3;            

n_th = (net_work/q_in )*100;    
p6 = p1;
%point 6
t6 = XSteam(\'Tsat_p\',p6);
h6 = XSteam(\'hV_p\',p6);
s6 = XSteam(\'sV_p\',p6);

%point 5

p5 = p1;
t5 = XSteam(\'Tsat_p\',p5);
h5 = XSteam(\'hL_p\',p5);
s5 = XSteam(\'sL_p\',p5);

%point from 6 to 1

t_6to1 = linspace(t6,t1, 1000);

for i = 1:length(t_6to1)
    s_6_1(i)= XSteam(\'s_pT\',p6,t_6to1(i));
    h_6_1(i)= XSteam(\'h_pT\',p6,t_6to1(i));
end

%entropy and enthalpy for obtaining the data from the file XSteam to plot the
%saturation curve
tall = linspace(0,t1,500);
for i = 1:length(tall)
    s_tot(i) = XSteam(\'sV_t\',tall(i));
    S_tot(i) = XSteam(\'sL_t\',tall(i));
    h_tot(i) = XSteam(\'hV_t\',tall(i));
    H_tot(i) = XSteam(\'hL_t\',tall(i));
    
end

%plots
figure (1)

plot(s_6_1 ,t_6to1,\'r\')
hold on
% plot the saturation curve
plot(s_tot,tall)
hold on

plot(S_tot, tall)
hold on
plot([s4 s5],[t4 t5])
hold on
plot([s5 s6],[t5 t6])
hold on
plot([s1 s2],[t1 t2])
hold on
plot([s2 s3],[t2 t3])
hold on
plot([s3 s4],[t3 t4])

xlabel(\'Entropy [KJ/kg.k]\')
ylabel(\'Temperature [C]\')
title(\'Entropy vs Temperature\')

figure(2)
% ploting the saturation curve
plot(s_tot,h_tot)
hold on

plot(S_tot,H_tot)
hold on
% plot between point 6 to point 1
plot(s_6_1 ,h_6_1)
hold on
plot([s4 s5],[h4 h5])
hold on
plot([s5 s6],[h5 h6])
hold on
plot([s1 s2],[h1 h2])
hold on
plot([s2 s3],[h2 h3])
hold on
plot([s3 s4],[h3 h4])

xlabel(\'Entropy [KJ/kg.k]\')
ylabel(\'Enthalpy [KJ/kg]\')
title(\'Entropy vs Enthalpy\')

%Results 
fprintf(\'\\nResults\\n\');
fprintf(\'\\nAt State 1\\n\');
fprintf(\'P1= %4.2f in [Bar]\\n\',p1);
fprintf(\'t1= %4.2f in [celsius]\\n\',t1);
fprintf(\'h1= %4.2f in [KJ/kg]\\n\',h1);
fprintf(\'s1= %4.2f in [KJ/kg.k]\\n\',s1);

fprintf(\'\\nAt State 2\\n\');
fprintf(\'P2= %4.2f in [Bar]\\n\',p2);
fprintf(\'t2= %4.2f in [celsius]\\n\',t2);
fprintf(\'h2= %4.2f in [KJ/kg]\\n\',h2);
fprintf(\'s2= %4.2f in [KJ/kg.k]\\n\',s2);
fprintf(\'x2= %4.2f\\n\',x2);

fprintf(\'\\nAt State 3\\n\');
fprintf(\'P3= %4.2f in [Bar]\\n\',p3);
fprintf(\'t3= %4.2f in [celsius]\\n\',t3);
fprintf(\'h3= %4.2f in [KJ/kg]\\n\',h3);
fprintf(\'s3= %4.2f in [KJ/kg.k]\\n\',s3);

fprintf(\'\\nAt State 4\\n\');
fprintf(\'P4= %4.2f in [Bar]\\n\',p4);
fprintf(\'t4= %4.2f in [celsius]\\n\',t4);
fprintf(\'h4= %4.2f in [KJ/kg]\\n\',h4);
fprintf(\'s4= %4.2f in [KJ/kg.k]\\n\',s4);

fprintf(\'\\nwork_turbine= %4.2f in [KJ/kg]\\n\',turbine_Work);
fprintf(\'work_pump= %4.2f in [KJ/kg]\\n\',pump_work);
fprintf(\'work_netp= %4.2f in [KJ/kg]\\n\',net_work);
fprintf(\'Efficiency= %4.2f Percent\\n\',n_th);


Explaination :

The code starts with the clear all, close all and clc. Then \'disp\' command is used in order to to get the terms under it to view in command window.Here the processes are displayed in order to understand how the cycle flow would be.

Next, p1,t1 and p3 are the variables assigned for pressure at inlet of turbine, Temperature of steam at temperature inlet and pressure of condenser respectively. As these values must be given, \'input\' command is used.

Next is the calculations part, the values of enthalpy, entropy, temperatures at various states are extracted from Xsteam Lbrary. Once all the values are computed, we get Work done, Heat supplied, Heat rejected and Quality of Steam(dryness fraction) as the formulas are used in the code.

In order to draw a saturation curve, obtained the values of enthalpy and entropy from Xsteam library for this for loop is used.

Further the plots are ploted in order to get the T - S diagran which is under figure 1 and H - S diagram which is under figure 2.

Then, \'fprintf\' command is used for printing out the values of pressure, temperature, enthalpy,etc.and \\n means new line.

Errors faced : Incorrect plot.

Corrected action : Used \'hold on\' command after every plot.

Output :

1) T - S diagram :

2) H - S diagram :

3) Results :

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.