%% Code for Rankine cycle simulator
% Clearng workspace,command window and closing all plots
clear all
close all
clc
% Printing of all the processes names
disp( 'Rankine cycle simulator' )
disp('1-2 is isentropic expansion in turbine')
disp('2-3 is constant pressure heat rejection process')
disp('3-4 is isentropic compression in pump')
disp('4-1 is constant pressure heat addition process')
% Giving the required inputs and stroing them into variables p1 p2 and T1
p1 = input('Enter pressure at the inlet of turbine(Bar): ')
T1 = input('Enter Temperature at the inlet of turbine(Celcius): ')
p2 = input('Enter pressure of condenser(Bar): ')
% Required calculations
% at state point 1
s1 = XSteam('s_pT', p1, T1); % entropy at inlet of turbine given p1 and T1
h1 = XSteam('h_pT', p1, T1); % enthalpy at inlet of turbine given p1 and T1
sf1 = XSteam('sL_p',p1) ; % Saturated liquid entropy for pressure at the inlet of turbine
sg1 = XSteam('sV_p',p1); % Saturated Vapour entropy for pressure at the inlet of turbine
sf2 = XSteam('sL_p',p2); % Saturated liquid entropy for pressure at the outlet of turbine
sg2 = XSteam('sV_p',p2); % Saturated Vapour entropy for pressure at the outlet of turbine
% Temperature corrosponding to saturation pressure p1
Temp_3 = XSteam('Tsat_p',p1);
% State point 2
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);
s2 = s1 ;
x2 = (s2-sf2)/(sg2-sf2);
h2 = hf2 + (x2*(hg2-hf2));
T2 = XSteam('Tsat_p', p2);
% State point 3
p3 = p2 ;
s3 = XSteam('sL_p',p3) ; % Entropy at the inlet of the pump
h3 = XSteam('hL_p',p3) ; % Enthalpy at pump inlet
v3 = XSteam('vL_p',p3) ; % Volume at pump inlet
T3 = XSteam('Tsat_p',p3) ; % Temperature at inlet of pump which is saturation temperature corrosponding to pressure at pump(p3)
% State point 4
p4 = p1;
s4 = s3;
T4 = XSteam('T_ps',p4,s4);
% calculate h4 == h4 = XSteam('h_pT',p4,T4)
Wp = v3*(p4-p3)*100 ; %Pressure is in bar so to convert it into KPascal
h4= h3 + Wp ;
% Calculating heat input to boiler, heat rejected in condenser
Q_in = h1 - h4 ; % Heat input to boiler from coal or natural gas or nuclear reactions
Q_out = h2 -h3 ; % Heat rejected in condenser
% net work output
Wt= h1- h2; % of turbine
Wnet = Wt-Wp; % of cycle
% Thermal efficiency
eff_thermal = Wnet/Q_in;
% Plotting of T-s curve
pressure = linspace(0,2000,4000);
for i= 1:length(pressure)
temp(i) = XSteam('Tsat_p',pressure(i));
entropyL(i) = XSteam('sL_p', pressure(i));
entropyV(i) = XSteam('sV_p', pressure(i));
end
% Connecting all points
% From state point 4 to point1, it is not straight line ,hence code is
% written for that
ent_1 = linspace(sf2, sf1, 100);
ent_2 = linspace(sg1, s1, 100);
for i = 1: length(ent_1)
for j= 1: length(ent_2)
T_1(i) = XSteam('T_ps', p1, ent_1(i));
T_2(j) = XSteam('T_ps', p1, ent_2(j));
end
end
% Plotting all four state points and connecting them
figure(1)
plot([s1 s2],[T1 T2],'linewidth',2, 'color', 'g')
hold on
title('T-s curve for Rankine cycle')
xlabel('Entropy(KJ/C)')
ylabel('Temperature(Celcius)')
plot([s2 s3],[T2 T3],'linewidth',2, 'color', 'g')
plot([s3 s3],[T3 T4],'linewidth',2, 'color', 'g')
plot(entropyL, temp, 'color', 'r', 'linewidth', 2.5)
plot(entropyV, temp, 'color', 'r', 'linewidth', 2.5)
plot(ent_1,T_1,'linewidth',2, 'color', 'g')
plot(ent_2,T_2,'linewidth',2, 'color', 'g')
plot([sf1 sg1],[Temp_3 Temp_3],'linewidth',2, 'color', 'g')
hold on
text(s1,T1,'1')
text(s2,T2,'2')
text(s3,T3,'3')
text(s3,T4,'4')
hold on
% Plotting entropy-enthalpy graph
for i = 1:length(pressure)
enthalpyL(i) = XSteam('hL_p',pressure(i));
enthalpyV(i) = XSteam('hV_p',pressure(i));
end
figure (2)
plot(entropyL, enthalpyL, 'linewidth', 2, 'color', 'g') %Plotting liquid line h-s
hold on
plot(entropyV, enthalpyV, 'linewidth', 2, 'color', 'g') %Plotting vapour line h-s
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1], 'linewidth', 2, 'color', 'b')
title('Enthalpy vs entropy')
xlabel('entropy[KJ/K]')
ylabel('Enthalpy[KJ/Kg-K]')
BWR = Wp/Wt ;
% Giving all the outputs
fprintf('Work done by turbine is: %.3f KJ/Kg \n', Wt)
fprintf('Net Work of cycle is: %.3f KJ/Kg \n', Wnet)
fprintf('Back work ratio is: %.3f KJ/Kg \n', BWR)
fprintf('Heat input to boiler is: %.3f KJ/Kg \n', Q_in)
fprintf('Heat rejected in condenser is: %.3f KJ/Kg \n', Q_out)
fprintf('Thermal efficiency is: %.3f \n \n', eff_thermal)
fprintf('At turbine inlet (1) \n')
fprintf('Pressure is: %.2f Bar \n',p1)
fprintf('Temerature is: %.2f Celcius \n',T1)
fprintf('Enthalpy is: %.2f KJ/Kg \n',h1)
fprintf('Entropy is: %.2f KJ/K/n \n \n',s1)
fprintf('At turbine outlet (2) \n')
fprintf('Pressure is: %.2f Bar \n',p2)
fprintf('Temerature is: %.2f Celcius \n',T2)
fprintf('Enthalpy is: %.2f KJ/Kg \n',h2)
fprintf('Entropy is: %.2f KJ/K/n \n \n',s2)
fprintf('At inlet of pump (3) \n')
fprintf('Pressure is: %.2f Bar \n',p3)
fprintf('Temerature is: %.2f Celcius \n',T3)
fprintf('Enthalpy is: %.2f KJ/Kg \n',h3)
fprintf('Entropy is: %.2f KJ/K/n \n \n',s3)
fprintf('At inlet of boiler (4) \n')
fprintf('Pressure is: %.2f Bar \n',p4)
fprintf('Temerature is: %.2f Celcius \n',T4)
fprintf('Enthalpy is: %.2f KJ/Kg \n',h4)
fprintf('Entropy is: %.2f KJ/K/n \n \n',s4)
% Theory: Rankine cycle is the ideaal cycle for Steam power plants. It works on four components namely Pump which increases pressure of water(Its exaggeration as water is incompressible fluid), boiler which converts water into steam by coal energy or nuclear energy, Turbine where actual work is developed and condenser for rejecting heat to atmosphere.
% In this program, we have first given all the inputs like T1, p1 and p2 for Rankine cycle. Then enthalpy, entropy, temperature values at each point are calculated. For finding out x2(Dryness fraction), entropies at 1 and 2 are equated. Then enthalpy at 2 is found out. saturated enthalpy and entropy are calculated or extracted from steam table given in question. Then for plotting of T-s plot, for loop is used to consider all the values of pressures between 1 and 800 with 4000 intervals. Then for each value of pressure, saturation temperature is extracted from steam table. Then, output is displyaed by fprintf command.