RANKINE CYCLE SIMULATOR IDEAL
clear all
close all
clc
fprintf(\' RANKINE CYCLE SIMULATOR \\n\\n\')
fprintf(\'1-2 is Isentropic Expansion in the Turbine\\n\')
fprintf(\'2-3 is Constant Pressure Heat Rejection by the Condenser\\n\')
fprintf(\'3-2 is Isentropic Compression in the Pump\\n\')
fprintf(\'4-1 is Constant Pressure Heat Addition by the Boiler\\n\\n\')
%% inputs
P1 = input(\'Enter the Pressure at the Turbine Inlet (in bar): \');
T1 = input(\'Enter the Temperature at the Turbine inlet (in Degree Celcius): \');
P2 = input(\'Enter the Pressure at the Condenser (in bar): \');
disp(\'\')
disp(\' RESULTS\')
%% State point 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);
fprintf(\'H1 is : %g kJ/kg\\n\', H1)
S1 = XSteam(\'s_pt\', P1, T1);
fprintf(\'S1 is : %g kJ/kgK\\n\\n\', S1)
%% State point 2
disp(\'At state point 2:\')
P2 = P2;
fprintf(\'P2 is : %g Bar\\n\', P2)
S2 = S1;
fprintf(\'S2 is : %g kJ/kgK\\n\', S2)
Sg = XSteam(\'sV_p\', P2);
Sf = XSteam(\'SL_p\', P2);
Sfg = Sg - Sf;
X2 = (S2 - Sf) / (Sfg); % Dryness Fraction at state point 2
fprintf(\'X2 is : %g\\n\', X2)
Hf = XSteam(\'hL_p\', P2);
Hg = XSteam(\'hV_p\', P2);
Hfg = Hg - Hf;
H2 = Hf + X2 * Hfg;
fprintf(\'H2 is : %g kJ/kg\\n\', H2)
T2 = XSteam(\'Tsat_p\', P2);
fprintf(\'T2 is : %g Deg Celcius\\n\\n\', T2)
%% State point 3
disp(\'At state point 3:\')
P3 = P2;
fprintf(\'P3 is : %g Bar\\n\', P3)
V3 = XSteam(\'vL_p\', P3);
T3 = T2;
fprintf(\'T3 is : %g Deg Celcius\\n\', T3)
H3 = XSteam(\'hL_p\', P3);
fprintf(\'H3 is : %g kJ/kg\\n\', H3)
S3 = XSteam(\'sL_p\', P3);
fprintf(\'S3 is : %g kJ/kgK\\n\\n\', S3)
%% State point 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;
H4 = Wp + H3;
fprintf(\'H4 is : %g kJ/kg\\n\', H4)
T4 = XSteam(\'T_ps\', P4, S4);
fprintf(\'T4 is : %g Deg Celcius\\n\\n\', T4)
%% Work done, heat, SSC and efficiency calculations
Wt = H1 - H2;
fprintf(\'Wt is : %g kJ/kg\\n\', Wt)
fprintf(\'Wp is : %g kJ/kg\\n\', Wp)
Wnet = Wt - Wp;
fprintf(\'Wnet is : %g kJ/kg\\n\', Wnet)
Qin = H1 - H4;
Ntherm = Wnet / Qin * 1e2; % Effieciency
fprintf(\'Ntherm is : %g\', Ntherm); disp(\'%\')
SSC = 3600 / Wt; % Specific steam consuption
fprintf(\'S.S.C is : %g kg/kWh\\n\\n\', SSC)
%% Calculation for plotting Liquid and Vapour lines
temp = linspace(1, 373, 500);
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
%% Points between state point 4 to state point 1
S5 = XSteam(\'sL_p\', P1);
S6 = XSteam(\'sV_p\', P1);
T5 = XSteam(\'Tsat_p\', P1);
T6 = XSteam(\'Tsat_p\', P1);
%% Ploting T - S and H - S Diagrams
figure(1) % T-S
hold on
plot([S1 S2], [T1 T2], \'b\', \'linewidth\', 2)
plot([S2 S3], [T2 T3], \'r\', \'linewidth\', 2)
plot([S3 S4], [T3 T4], \'y\', \'linewidth\', 2)
plot([S4 S5 S6 S1], [T4 T5 T6 T1], \'g\', \'linewidth\', 2)
plot(S_L, temp, \'c\', \'linewidth\', 1.5)
plot(S_V, temp, \'k\', \'linewidth\', 1.5)
title(\'T-S Diagram\')
ylabel(\'Temprature (\\degC)\')
xlabel(\'Specific Entropy (kJ/kgK)\')
figure(2) % H-S
hold on
plot([S1 S2], [H1 H2], \'b\', \'linewidth\', 2);
plot([S2 S3], [H2 H3], \'r\', \'linewidth\', 2);
plot([S3 S4], [H3 H4], \'y\', \'linewidth\', 2);
plot([S4 S1], [H4 H1], \'g\', \'linewidth\', 2);
plot(S_L, H_L, \'c\', \'linewidth\', 1.5)
plot(S_V, H_V, \'k\', \'linewidth\', 1.5)
title(\'H-S Diagram\', \'FontSize\', 15)
ylabel(\'Specific Enthalpy (kJ/kg)\')
xlabel(\'Specific Entropy (kJ/kgK)\')
FOLLOWING IS THE OUTPUT IN COMMAND WINDOW
FOLLOWING ARE THE PLOTS OF RANKINE CYCLE HS AND TS DIAGRAMS
HS DIAGRAM
TS DIAGRAM