To write a code Rankine cycle.
Rankine cycle is a vapour power cycle that is used in steam power plants. It is similar to the carnot cycle, its use is more popular because, it is much more practical than the carnot cycle with good efficiency rates. It also has a scope to improve the efficiency by a lot of methods such as regeneration and reheating. This makes the rankine cycle an ideal cycle for the steam turbines.
After going through the condenser, the water gets into liquid state. In this process, the pump transfers the water towards the boiler. Here, the pump increases the pressure, by compression and leaves it to boiler. Hence, isentropic compression occurs at this process.
The high-pressure liquid enters a boiler, where it is heated at constant pressure by an external heat source to become a dry saturated vapour. Since the inlet of the turbine needs to be fed with water at high pressure and temperature, this step is necessary. Hence, isobaric heat addition occurs at this stage, with the help of the boiler.
In this process, the hot steam coming out from the boiler is fed to the turbines. Where, the the superheated water hits the blade of the turbine at high temperature and high pressure. This results in rotation of the turbine blade and as a result, the water loses its temperature and pressure. The walls of the turbine are assumed to be adiabatic, hence no heat transfer occurs in the process. Hence isentropic expanasion occurs in this process.
The output leftover product from the turbines are fed into the condenser. To reuse the water again, it has to be brought back to the saturated liquid state. Hence the condenser absrobs heat from the water and brings it to saturated water state at constant pressure. Hence, isobaric heat rejection occurs at this process.
In this cycle, work is obtained frrom the turbine and work is consumed from the pump. Along with this, hear is supplied at the boiler and rejected at the condenser. By this information, we can find the net work, efficiency and the back power ration of the cycle.
where, Q is the net heat supplied.
clear all
close all
clc
% Display is playing the content
fprintf("\n RANKINE CYCLE SIMULATOR \n");
fprintf("\n Process 1-2 : Isentropic expansion in the Turbine \n");
fprintf("\n Process 2-3 : Isobaric heat rejection by the Condenser \n");
fprintf("\n Process 3-4 : Isentropic compression in the Pump \n");
fprintf("\n Process 4-1 : Isobaric heat addition by the Boiler \n");
% Requesting user to give the inputs
p1 = input('\n Enter the pressure at the Turbine inlet (in bar) = ');
t1 = input('\n Enter the temperature at the Turbine inlet (in Celsius) = ');
p2 = input('\n Enter the pressure at the Condenser (in bar) = ');
% Turbine inlet Parameters
tsat_1 = XSteam('Tsat_p',p1);
if t1 > tsat_1
h1 = XSteam('h_pt',p1,t1);
s1 = XSteam('s_pt',p1,t1);
elseif t1 == tsat_1
h1 = XSteam('hV_p',p1);
s1 = XSteam('sV_p',p1);
else
fprintf("\n Enter higher value of Turbine inlet temperature (in Celsius)!!! \n\n");
end
% Conditions at turbine outlet
% Based on the location of point 2 folling values\properties
% Evaluated
% Isentropic expansion in the turbine
s2 = s1;
ssat_2 = XSteam('sV_p',p2);
if s2 < ssat_2
sf_2 = XSteam('sL_p',p2);
sg_2 = XSteam('sV_p',p2);
% Let x denote the dryness fraction of the steam in the system
x = (s2 - sf_2)/(sg_2 - sf_2);
hf_2 = XSteam('hL_p',p2);
hg_2 = XSteam('hV_p',p2);
h2 = hf_2 + x*(hg_2 - hf_2);
t2 = XSteam('Tsat_p',p2);
else
x = 1;
h2 = XSteam('hV_p',p2);
t2 = XSteam('Tsat_p',p2);
end
% Conditions at pump inlet
p3 = p2;
t3 = XSteam('Tsat_p',p3);
h3 = XSteam('hL_p',p3);
s3 = XSteam('sL_p',p3);
v3 = XSteam('vL_p',p3);
% Conditions at boiler inlet
p4 = p1;
s4 = s3;
v4 = XSteam('v_ps',p4,s4);
cp4 = XSteam('Cp_ps',p4,s4);
cv4 = XSteam('Cv_ps',p4,s4);
gamma = cp4/cv4;
G = (gamma - 1)/gamma;
t4 = t3*(p2/p1)^G;
% Work required by the pump
W_p = v3*(p4 - p3)*100;
% W_p = h4 - h3
h4 = W_p + h3;
% Condition of intermediate states:State 5 and 6 in (4-1)State
t5 = XSteam('Tsat_p',p4);
s5 = XSteam('sL_p',p4);
t6 = t5;
s6 = XSteam('sV_p',p4);
% Work done by Turbine
W_t = h1 - h2;
% Heat input
Q_in = h1 - h4;
% Heat output
Q_out = h2 - h3;
% NET-WORK Obtained
W_net = W_t - W_p;
% Efficiency of the Rankine Cycle
efficiency = (W_net*100)/Q_in;
% Back work ratio
BWR = W_p/W_t;
% Specific stream
SSC = 3600/W_net;
% Displaying the obtained information
fprintf("\n RESULTS\n");
fprintf("At State Point 1: At State Point 4: \n P1 = %.2f ba P4 = %.2f bar \n T1 = %.2f C T4 = %.2f C \n H1 = %.2f kJ/kg H4 = %.2f kJ/kg \n S1 = %.2f kJ/kg-C S4 = %.2f kJ/kg-C \n",p1,p4,t1,t4,h1,h4,s1,s4);
fprintf("\nAt State Point 2: At State Point 3:\n P2 = %.2f bar P3 = %.2f bar \n T2 = %.2f C T3 = %.2f C \n H2 = %.2f kJ/kg H3 = %.2f kJ/kg \n S2 = %.2f kJ/kg-C S3 = %.2f kJ/kg-C \n",p2,p3,t2,t3,h2,h3,s2,s3);
fprintf("\n Work required by the pump in the Rankine Cycle = %.2f kJ/kg\n",W_p);
fprintf("\n Work produced by the turbine in the Rankine Cycle = %.2f kJ/kg\n",W_t);
fprintf("\n Net Work obtained in the Rankine Cycle = %.2f kJ/kg\n",W_net);
fprintf("\n Heat input to the Rankine Cycle = %.2f kJ/kg\n",Q_in);
fprintf("\n The efficiency of the Rankine Cycle = %.2f \n",efficiency);
fprintf("\n Back Work Ratio in the Rankine Cycle = %.9f \n",BWR);
fprintf("\n Specific Steam Consumption in the Rankine Cycle = %.2f kg/kWh \n",SSC);
% Plotting
% Plotting Rankine Cycle is diagram
% Plotting Saturation Curve
% Critical point of water occurs at 373.946 degree
T = linspace(0,373.946,100);
figure(1);
hold on
for i = 1 : length(T)
s_l(i) = XSteam('sL_T',T(i));
s_g(i) = XSteam('sV_T',T(i));
h_l(i) = XSteam('hL_T',T(i));
h_g(i) = XSteam('hV_T',T(i));
end
plot(s_l,T,'linewidth',3,'color','g');
plot(s_g,T,'linewidth',3,'color','g');
plot([s1 s2],[t1 t2],'linewidth',1,'color','k');
text(s1,t1,'1');
plot([s2 s3],[t2 t3],'linewidth',1,'color','r');
text(s2,t2,'2');
plot([s3 s4],[t3 t4],'linewidth',1,'color','k');
text(s3,t3,'3');
plot([s4 s5],[t4 t5],'linewidth',1,'color','r');
text(s4,t4,'4');
plot([s5 s6],[t5 t6],'linewidth',1,'color','r');
text(s5,t5,'5');
plot([s6 s1],[t6 t1],'linewidth',1,'color','r');
text(s6,t6,'6');
xlabel('Entropy (kJ/kg-C)');
ylabel('Temperature (C)');
title('Entropy versus Temperature Curve - Rankine Cycle');
legend('Entropy (s)kJ/kg-C','Temperature (t)C');
grid on
hold off
% Plotting Rankine Cycle is diagram
% Plotting Saturation Curve
figure(2);
hold on
plot(s_l,h_l,'linewidth',3,'color','c');
plot(s_g,h_g,'linewidth',3,'color','c');
plot([s1 s2],[h1 h2],'linewidth',1,'color','k');
text(s1,h1,'1');
plot([s2 s3],[h2 h3],'linewidth',1,'color','r');
text(s2,h2,'2');
plot([s3 s4],[h3 h4],'linewidth',1,'color','k');
text(s3,h3,'3');
plot([s4 s1],[h4 h1],'linewidth',1,'color','r');
text(s4,h4,'4');
xlabel('Entropy (kJ/kg-C)');
ylabel('Enthalpy (kJ/kg)');
title('Enthalpy versus Entropy Curve - Rankine Cycle');
legend('Entropy (s)kJ/kg-C','Enthalpy (h)kJ/kg');
grid on
hold off