Challenge

Project 2 - Rankine cycle Simulator

Rankine Cycle Simulation using Matlab

clear all
close all
clc
% displaying the process of Rankine cycle
disp( 'Rankine Cycle Process' )
disp('Process 1-2 is Isentropic Compression in Turbine' )
disp('process 2-3 is Constant pressure Heat reduction in the Condensor' )
disp( 'process 3-4 is Isentropic Expansion in Pump')
disp( 'Process 4-1 is Constant Pressure heat addition in Boiler' )

% Inputs
% Inputs pressure is taken in 'bar', Temperature is taken in 'degree Celcius'
% values of pressure and temperature.

p3 = input( 'Enter the pressure at the Turbine inlet (in bar): ')
T3 = input('Enter the Temperature at the Turbine inlet(in degree celcious):')
p4 = input('Enter the pressure at the condenser(in bar): ')

% State_Points

% by using XSteam library we are taking the required data like pressure, temperature, entropy, enthalpy

% State 1 Inputs

T1 = XSteam( 'Tsat_p' , p4);
p1 = p4;
h1 = XSteam( 'hL_p' , p4);
s1 = XSteam( 'sL_p' , p4);


% State_2 Inputs


T2 = XSteam( 'Tsat_p' , p3, s1);
p2 = p3;
h2 = XSteam( 'h_ps' , p3, s1);
s2 = s1;


% State 3 Inputs

h3 = XSteam( 'h_pT' , p3, T3);
s3 = XSteam( 's_pT' , p3, T3);


% State_4 Inputs
sg4 = XSteam('sV_p', p4)-XSteam('sL_p', p4);
hg4 = XSteam('hV_p', p4)-XSteam('hL_p', p4);
s4 = s3;
X = (s4-s1)/sg4;
h4 = h1+(X*hg4);
v4 = XSteam( 'VL_p', p4);
T4 = XSteam( 'T_ph' , p4, h4);


%Intermediate State points

T5 = XSteam( 'Tsat_p', p3);
h5 = XSteam( 'hL_p' , p3);
s5 = XSteam( 'sL_p' , p3);
T6 = XSteam( 'Tsat_p' , p3);
h6 = XSteam( 'hv_p', p3);
s6 = XSteam( 'sV_p' , p3);
P5 = p3;
p6 = p3;

% calculating work done

% workdone by Turbine
W_t = h3-h4;

% workdone by Pump
W_p = v4*(p3 -p4)*100;
hf2 = W_p + h1;

% Calculating Net workdone
W_net = W_t-W_p;

% Calculating Heat in to the system
Q_in = h3-h2;

% Calculating Thermal Efficiency 
n_eff = (W_net/Q_in)*100;

% Calculating specific steam consumption (S.S.C) = mass flow rate/net workdone
SSC = (3600/W_net);

%Calculating Back Work Ratio
B_w = (W_p/W_t);

% Plot for the Saturation Curve

S = linspace(0.1,10, 1000);
for i = 1: length(S)
Tsat (i) = XSteam('Tsat_s' ,S(i));
end

% Plotting T-S diagram

figure(1)
plot (S, Tsat, ' -- ', 'Linewidth', 1, 'color', 'b')
hold on
plot ( [ s1, s5, s5, s6, s3, s4, s1], [T1, T2, T5, T6, T3, T4, T1], 'linewidth' , 2, 'color' , 'r')
xlim([0 10])
ylim([0 500])
title('T-S Diagram of Rankine Cycle')
xlabel( 'Entropy, s(Kj/kgk) ' )
ylabel ( ' Temperature (degree c)')
legend( 'saturation curve' )
hold off

% marking State points
text (s1, T1, "1");
text (s5, T2, "2");
text (s3, T3, "3");
text (s4, T4, "4") ;


% Plotting H_S diagram
T = (1:2000);
for j = 1: length(T)
h_L(1,j) = XSteam('hL_T' , j);
h_V(1, j) = XSteam('hV_T' , j);
s_L(1, j) = XSteam('sL_T', j);
s_V(1,j) = XSteam('sV_T', j);
end

figure(2)
plot (s_L, h_L, '--', 'Linewidth',1, 'color' , 'r')
hold on
plot (s_V, h_V, '.', 'Linewidth', 1, 'color', 'r')
plot ([s1, s2, s5,s6, s3, s4, s1],[h1, h2, h5, h6, h3, h4, h1], 'linewidth', 2, 'color', 'b')
title('H-S Diagram of Rankine Cycle' )
xlabel('Entropy (KJ/Kg K)' )
ylabel('Enthalpy (KJ/Kg) ' )
legend( 'Saturation Curve' )

%marking state points
text (s1, h1, "1");
text (s2, h2, "2")
text (s3, h3, "3" ) ;
text (s4, h4, "4" )

saveas (1, 'T-S Diagram of Rankine Cycle', 'png' )
saveas (2, 'H-S Diagram of Rankine Cycle' , 'png')

% Results
disp('Results' );
p3 = p3;
p4 = p4;
T3 = T3;

% State point 1
disp('At stage point 1');
S_p1 = sprintf('P1 is %.3f bar', p1);
disp(S_p1);
S_T1 = sprintf('T1 is %.3f Deg celcius', T1);

disp(S_T1);
S_h1 = sprintf('H1 is %.3f kj/kg', h1);
disp (S_h1) ;
S_s1 = sprintf('S1 is %.3f kj/kgK', s1);
disp(S_s1) ;

% State point 2
disp('At stage point 2') ;
S_p2 = sprintf('P2 is %. 3f bar' , p2);
disp(S_p2);
S_T2 = sprintf('T2 is X.3f Deg celcius', T2);
disp(S_T2);
S_h2 = sprintf('H2 is %.3f kj/Kg', h2);
disp(S_h2) ;
S_s2 = sprintf('S2 is X.3f kj/KgK', s2);
disp(S_s2);

% State point3

disp('At stage point 3');
S_p3 = sprintf('P3 is %.3f bar', p3);
disp(S_p3) ;
S_T3 = sprintf('T3 is %.3f Deg celcius', T3);
disp(S_T3) ;
S_h3 = sprintf('H3 is %.3f kj/kg', h3);
disp(S_h3);
S_s3 = sprintf('S3 is %.3f KJ/kg K', s3);
disp(S_s3);

% State point 4
disp('At stage point 4');
S_p4 = sprintf('P4 is %.3f bar', p4);
disp(S_p4);
S_T4 = sprintf('T4 is %.3f Deg celcius', 14);
disp(S_T4);
S_h4 = sprintf('H4 is %.3f kj/kg', h4);
disp(S_h4);
S_s4 = sprintf('S4 is %.3f kj/kg K', 54);
disp(S_s4);

%  Efficiency and Back work ratio

wt = sprintf('wt is %.3f KJ/Kg', W_t);
disp(wt) ;
Wp = sprintf('wp is %.3f KJ/Kg', W_p);
disp(Wp) ;
W_net = sprintf('W_net is %.3f KJ/Kg', W_net);
disp (W_net);
neff = sprintf('Thermal Efficiency is %.3f percent', n_eff);
disp(neff);
Ssc = sprintf('SSC is %.2f kg/KWh', SSC);
disp(Ssc);
BW = sprintf('Back Work Ratio is %.3f', B_w);
disp(BW) ;

Output from command window

Rankine Cycle Process
Process 1-2 is Isentropic Compression in Turbine
process 2-3 is Constant pressure Heat reduction in the Condensor
process 3-4 is Isentropic Expansion in Pump
Process 4-1 is Constant Pressure heat addition in Boiler
Enter the pressure at the Turbine inlet (in bar): 30

p3 =

30

Enter the Temperature at the Turbine inlet(in degree celcious):400

T3 =

400

Enter the pressure at the condenser(in bar): .05

p4 =

0.0500

Results
At stage point 1
P1 is 0.050 bar
T1 is 32.875 Deg celcius
H1 is 137.765 kj/kg
S1 is 0.476 kj/kgK
At stage point 2
P2 is
T2 is X.3f Deg celcius
H2 is 140.762 kj/Kg
S2 is X.3f kj/KgK
At stage point 3
P3 is 30.000 bar
T3 is 400.000 Deg celcius
H3 is 3231.571 kj/kg
S3 is 6.923 KJ/kg K
At stage point 4
P4 is 0.050 bar
T4 is 14.000 Deg celcius
H4 is 2110.708 kj/kg
S4 is 54.000 kj/kg K
wt is 1120.863 KJ/Kg
wp is 3.011 KJ/Kg
W_net is 1117.852 KJ/Kg
Thermal Efficiency is 36.167 percent
SSC is 3.22 kg/KWh
Back Work Ratio is 0.003
>>

Explanation

  1. To displaying the process of Rankine cycle
    disp( 'Rankine Cycle Process' )
    disp('Process 1-2 is Isentropic Compression in Turbine' )
    disp('process 2-3 is Constant pressure Heat reduction in the Condensor' )
    disp( 'process 3-4 is Isentropic Expansion in Pump')
    disp( 'Process 4-1 is Constant Pressure heat addition in Boiler' )

  2. Initially,a platform for filling required inputs is established.
    p3 = input( 'Enter the pressure at the Turbine inlet (in bar): ')
    T3 = input('Enter the Temperature at the Turbine inlet(in degree celcious):')
    p4 = input('Enter the pressure at the condenser(in bar): ')

  3. By using XSteam library we are taking the required data like pressure, temperature, entropy, enthalpy for state1,2,3,4
    T1 = XSteam( 'Tsat_p' , p4);
    p1 = p4;
    h1 = XSteam( 'hL_p' , p4);
    s1 = XSteam( 'sL_p' , p4);

  4. calculating work done
    workdone by Turbine
    W_t = h3-h4;
    workdone by Pump
    W_p = v4*(p3 -p4)*100;

  5. Calculating Net workdone
    W_net = W_t-W_p;

  6. Calculating Heat in to the system
    Q_in = h3-h2;

  7. Calculating Thermal Efficiency
    n_eff = (W_net/Q_in)*100;

  8. Calculating specific steam consumption (S.S.C) = mass flow rate/net workdone
    SSC = (3600/W_net);

  9. Calculating Back Work Ratio
    B_w = (W_p/W_t);

  10. Plotting T-S and H-S diagram

  11. Saving the plotted T-S and H-S diagram
  12. Displaying state point and the values of temperature,entropy,enthalpy and pressure

  13. And also displaying
    work done by turbine
    work done by pump
    net work done
    Thermal Efficiency
    Specific steam consumption
    Back Work Ratio

Errors

errors are mainly occured by spelling mistakes and errors while using paranthesis

Reference

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

https://energyeducation.ca/encyclopedia/Rankine_cycle

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.