Project

Rankine cycle simulator

Rankine cycle simulator

close all
clc

%user input
fprintf(\'\\n      RANKINE CYCLE SIMULATOR         \');
fprintf(\'\\n Process 1-2 Isentropic Expansion in Turbine\');
fprintf(\'\\n Process 2-3 Isobaric Heat Rejection in Condensor\');
fprintf(\'\\n Process 3-4 Isentropic Compression in Pump\');
fprintf(\'\\n Process 4-1 Isobaric Heat Transfer in Boiler\');

%user inputs
P1 = input(\'\\n Enter Pressure at Turbine inlet (in bar): \');
T1 = input(\' Enter Temperature at Turbine Inlet (in degree C): \');
P2 = input(\' Enter Pressure at condenser (in bar): \');

%state points calculations
disp(\'Results\')

%state 1
disp(\'At state point 1: \')
fprintf(\'P1 is : %g Bar\\n\', P1);
fprintf(\'T1 is : %g Deg Celcius\\n\', T1);

H1 = XSteam(\'h_pT\', P1, T1); %enthalpy as a function of pressure and temperature
fprintf(\'H1 is : %g KJ/Kg\\n\', H1);

S1 = XSteam(\'s_pT\', P1, T1); %Specific entropy as a function of pressure and temperature
fprintf(\'S1 is : %g KJ/KgK\\n\\n\', S1);

%state 2
disp(\'At state point 2: \')
fprintf(\'P2 is: %g Bar\\n\', P2)

S2 = S1;
fprintf(\'S2 is: %g KJ/KgK\\n\', S2);

Sg = XSteam(\'sV_p\', P2); %saturated vapour entropy
Sf = XSteam(\'sL_p\', P2); %saturated liquid entropy
Sfg = Sg - Sf;
%dryness fraction X2 at state point 2
X2 = (S2 - Sf)/Sfg;
fprintf(\'X2 is: %g\\n\', X2)

Hg = XSteam(\'hV_p\', P2); %saturated vapour enthalpy
Hf = XSteam(\'hL_p\', P2); %saturated liquid enthalpy
Hfg = Hg - Hf;
H2 = Hf + X2 * Hfg;
fprintf(\'H2 is: %g KJ/Kg\\n\', H2);

T2 = XSteam(\'Tsat_p\', P2); %saturation temperature
fprintf(\'T2 is: %g Deg Celcius\\n\\n\', T2)

%state 3
disp(\'At state point 3: \')

P3 = P2;
fprintf(\'P3 is: %g Bar\\n\', P3)

V3 = XSteam(\'vL_p\', P3); %saturated liquid volume

T3 = T2;
fprintf(\'T3 is: %g Deg Celcius\\n\', T3)

H3 = XSteam(\'hL_p\', P3); %saturated liquid enthalpy
fprintf(\'H3 is: %g KJ/Kg\\n\', H3)

S3 = XSteam(\'sL_p\', P3); %saturated liquid entropy
fprintf(\'S3 is: %g KJ/KgK\\n\\n\', S3)

%state 4
disp(\'At state point 4: \')

P4 = P1;
fprintf(\'P4 is: %g Bar\\n\', P4)

S4 = S3;
fprintf(\'S4 is: %g KJ/KgK\\n\', S4)

Wp = V3 * (P4 - P3) * 100; %wp = work done ON the pump
H4 = Wp + H3; 
fprintf(\'H4 is: %g KJ/Kg\\n\', H4)

T4 = XSteam(\'T_ps\', P4, S4); %Temperature as a function of pressure and entropy
fprintf(\'T4 is: %g Deg Celcius\\n\\n\', T4)

% net work done Wnet = (Wt - Wp)
Wt = H1 - H2; %Turbine work (work done by the system)
fprintf(\'Wt is: %g KJ\\n\', Wt)
fprintf(\'Wp is: %g KH\\n\', Wp)
Wnet = Wt-Wp; 
fprintf(\'Wnet is: %g KJ\\n\', Wnet)

%net heat transfer Qnet = (Qin - Qout) 
Qin = H1 - H4;
Qout = H2 - H3;
fprintf(\'Qin is: %g KJ\\n\', Qin)
fprintf(\'Qout is: %g KJ\\n\', Qout)
Qnet = Qin - Qout;
fprintf(\'Qnet is: %g KJ\\n\', Qnet)

%Thermal efficiency n_th = (Wnet / Qin) in %age
n_th = Wnet/Qin*100;  
fprintf(\'n_th is: %g\', n_th) 
disp(\'%\')

%specific steam consumption SSC
SSC = 3600/Wt;
fprintf(\'S.S.C is: %g KJ/KWh\\n\\n\', SSC)

%calculation for plotting Saturated liquid and Saturated vapor lines
temp = linspace(1,373,500); %temp in kelvin
for i = 1:length(temp)
    H_L(i) = XSteam(\'hL_T\', temp(i));
    H_V(i) = XSteam(\'hV_T\', temp(i));
    S_L(i) = XSteam(\'sL_T\', temp(i));
    S_V(i) = XSteam(\'sV_T\', temp(i));
end
S = [S_L,S_V];
%points between state point 4 and state point 1
S5 = XSteam(\'sL_p\', P1);
S6 = XSteam(\'sV_p\', P1);
T5 = XSteam(\'Tsat_p\', P1);
T6 = XSteam(\'Tsat_p\', P1);

%plot T-S and H-S diagrams for the rankine cycle
rakine_plot(S1,S2,S3,S4,S5,S6,T1,T2,T3,T4,T5,T6,H1,H2,H3,H4,temp,S_L,S_V,H_L,H_V)

Function for plotting T-S and H-S Diagram

%function for plotting H-S and T-S diagram

function rakine_plot(S1,S2,S3,S4,S5,S6,T1,T2,T3,T4,T5,T6,H1,H2,H3,H4,temp,S_L,S_V,H_L,H_V)
figure(1) %T-S plot
hold on
plot([S1 S2], [T1 T2],\'linewidth\',1.5,\'color\',\'r\')
plot([S2 S3], [T2 T3],\'linewidth\',1.5,\'color\',\'b\')
plot([S3 S4], [T3 T4],\'linewidth\',1.5,\'color\',\'k\')
plot([S4 S5 S6 S1], [T4 T5 T6 T1],\'linewidth\',1.5,\'color\',\'g\')
plot(S_L,temp,\'linewidth\',1,\'color\',\'c\')
plot(S_V,temp,\'linewidth\',1,\'color\',\'y\')
l1 = legend(\'Isentropic Expansion\',\'Isobaric Heat Rejection\',\'Isentropic compression\',\'Isobaric Heat Addition\');
set(l1, \'location\',\'NorthWest\')
title(\'T-S Diagram\',\'FontSize\',15)
xlabel(\'Entropy (KJ/KgK)\',\'FontSize\',12)
ylabel(\'Temperature (Deg Cel)\',\'FontSize\',12)

figure(2) %H-S plot
hold on
plot([S1 S2], [H1 H2],\'linewidth\',1.5,\'color\',\'r\')
plot([S2 S3], [H2 H3],\'linewidth\',1.5,\'color\',\'b\')
plot([S3 S4], [H3 H4],\'linewidth\',1.5,\'color\',\'g\')
plot([S4 S1], [H4 H1],\'linewidth\',1.5,\'color\',\'c\')
plot(S_L,H_L,\'linewidth\',1,\'color\',\'y\')
plot(S_V,H_V,\'linewidth\',1,\'color\',\'k\')
l2 = legend(\'Isentropic Expansion\',\'Isobaric Heat Rejection\',\'Isentropic compression\',\'Isobaric Heat Addition\');
set(l2, \'location\',\'NorthWest\')
title(\'H-S Diagram\',\'FontSize\',15)
xlabel(\'Entropy (KJ/KgK)\',\'FontSize\',12)
ylabel(\'Enthalpy (KJ/Kg)\',\'FontSize\',12)
end

Output-

T-S plot

H-S plot:

state point values:-

      RANKINE CYCLE SIMULATOR         
 Process 1-2 Isentropic Expansion in Turbine
 Process 2-3 Isobaric Heat Rejection in Condensor
 Process 3-4 Isentropic Compression in Pump
 Process 4-1 Isobaric Heat Transfer in Boiler
 Enter Pressure at Turbine inlet (in bar): 44
 Enter Temperature at Turbine Inlet (in degree C): 538
 Enter Pressure at condenser (in bar): 5.83
Results
At state point 1: 
P1 is : 44 Bar
T1 is : 538 Deg Celcius
H1 is : 3528.83 KJ/Kg
S1 is : 7.15399 KJ/KgK

At state point 2: 
P2 is: 5.83 Bar
S2 is: 7.15399 KJ/KgK
X2 is: 1.07942
H2 is: 2920.82 KJ/Kg
T2 is: 157.712 Deg Celcius

At state point 3: 
P3 is: 5.83 Bar
T3 is: 157.712 Deg Celcius
H3 is: 665.638 KJ/Kg
S3 is: 1.91987 KJ/KgK

At state point 4: 
P4 is: 44 Bar
S4 is: 1.91987 KJ/KgK
H4 is: 669.834 KJ/Kg
T4 is: 158.16 Deg Celcius

Wt is: 608.008 KJ
Wp is: 4.196 KH
Wnet is: 603.812 KJ
Qin is: 2858.99 KJ
Qout is: 2255.18 KJ
Qnet is: 603.812 KJ
n_th is: 21.1197%
S.S.C is: 5.92098 KJ/KWh
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.