clear all
close all
clc
% the required informations
fprintf('n RANKINE CYCLE SIMULATOR');
fprintf('nn1-2 Isentropic Expansion in Turbine');
fprintf('n2-3 Constant Pressure Heat Rejection in the Condenser');
fprintf('n3-4 Isentropic Compression in the Pump');
fprintf('n4-1 Constant Pressure Heat Addition by the Boilern');
%inputs pressure and temperature
p1=input(' Pressure at the Turbine inlet (bar): ');
t1=input(' Temperature at the Turbine inlet (celsius) :');
p2=input(' Pressure at the Condenser: ');
%@ stage 1 Turbine Inlet
% p1 & t1 are given
h1=XSteam ('h_pT', p1,t1);
s1= XSteam('s_pT',p1,t1);
%@ stage 2 Condenser Inlet
% p2 is given
s2=s1;
sf2=XSteam ('sL_p', p2);
sg2=XSteam('sV_p', p2);
hf2=XSteam('hL_p',p2);
x2=(s2-sf2)/(sg2-sf2);
hg2=XSteam ('hV_p', p2);
h2=hf2+(x2+(hg2-hf2));
%@ stage 3 Pump Inlet
p3=p2;
h3=XSteam('hL_p',p3);
s3=XSteam ('SL_p',p3);
t3=XSteam( 'Tsat_p',p3);
t2=t3;
%@ stage 4 Boiler Inlet
p4=p1;
s4=s3;
h4=XSteam ('h_ps', p4,s4);
cp4=XSteam ('Cp_ps', p4, s4);
cv4=XSteam('Cv_ps', p4, s4);
lambda=cp4/cv4;
t4=t3/((p3/p4)^((lambda-1)/lambda));
t5=XSteam ('Tsat_p',p1);
t6=t5;
s5=XSteam ('SL_p',p1);
s6=XSteam ('sV_p',p1);
h5=XSteam ('hL_p',p1);
h6=XSteam('hV_p',p1);
% Turbine Work
Wt=h1-h2;
% Pump Work
Wp=h4-h3;
% Net Work (kJ/Kg)
W=Wt-Wp;
% Heat in & out of the System
Q_in=h1-h4;
Q_out=h2-h3;
%Thermal Efficiency
ntherm= (W/Q_in)*100;
% Steam rate (kg/kWh)
SSC=3600/W;
% Back Work Ratio
BWR= (h1-h4)/(h2-h3);
% to plot Saturation Curve
T=linspace (1,400, 500);
for i=1:length(T)
h_l(i)=XSteam('hL_T',T(i));
h_v(i)=XSteam ( 'hV_T',T(i));
s_l(i)=XSteam ('SL_T',T(i));
s_v(i)=XSteam('sV_T',T(i));
end
% plotting TS diagram
figure(1)
hold on
title('T-S Diagram'),
plot([s1 s2], [t1 t2], 'linewidth', 3, 'color', 'b')
plot([s2 s3], [t2 t3], 'linewidth', 3, 'color', 'b')
plot([s3 s4], [t3 t4], 'linewidth', 3, 'color', 'b')
plot([s4 s5], [t4 t5], 'linewidth', 3, 'color','b')
plot([s5 s6], [t5 t6], 'linewidth', 3, 'color', 'b')
xlabel('Entropy (kJ/KgK');
ylabel('Temperature (deg C)');
S_1=linspace (s6, s1,500);
for j=1:length(s_1)'
t_1(j)=XSteam ('T_ps',p1,s_1(j));
end
plot(s_1,t_1, 'linewidth', 3, 'color', 'b')
plot(s_1, T, 'linewidth',1.5, 'color', 'r')
plot(s_v, T, 'linewidth',1.5, 'color', 'r')
% Annotations
text(s1,t1,'1', 'fontsize',15);
text (s2, t2, '2', 'fontsize',15);
text(s3, t3, '3', 'fontsize', 15, 'verticalalignment', 'top');
text (s4, t4, '4', 'fontsize', 15, 'verticalalignment', 'bottom');
text (s5, t5, '5', 'fontsize', 15, 'verticalalignment', 'bottom');
text(s6, t6, '6', 'fontsize', 15, 'verticalalignment', 'bottom');
figure(2)
hold on
title('H-S Diagram');
plot([s1 s2], [h1 h2], 'linewidth',2, 'color', 'b')
plot([s2 s3], [h2 h3], 'linewidth',2, 'color', 'b')
plot([s3 s4], [h3 h4], 'linewidth',2, 'color', 'b')
h_4=linspace(h4,h5,500);
for k=1:length(h_4);
s_4(k)=XSteam('s_ph',p1,h_4(k));
end
h_6=linspace(h6,h1,500);
for m=1:length(h_6);
s_6 (m) =XSteam('s_ph',p1,h_6(m));
end
plot(s_4,h_4, 'linewidth', 2, 'color', 'b')
plot([s5 s6], [h5 h6], 'linewidth',2, 'color', 'b')
xlabel('Specific Entropy (kJ/KgK)');
plot(s_6,h_6, 'linewidth', 2, 'color', 'b')
ylabel('Specific Enthalpy (kJ/Kg)');
plot(s_l,h_l, 'linewidth', 1.5, 'color', 'r')
plot(s_v,h_v, 'linewidth',1.5, 'color', 'r')
% Annotations
text(s1,h1,'1','fontsize',15);
text(s2,h2,'2','fontsize',15);
text(s3, h3, '3', 'fontsize', 15, 'verticalalignment', 'top');
text(s4, h4, '4', 'fontsize', 15, 'verticalalignment', 'bottom');
text(s5, h5, '5', 'fontsize', 15, 'verticalalignment', 'bottom');
text(s6, h6, '6', 'fontsize', 15, 'vertica lalignment', 'bottom');
Results Window fprintf('nRESULTSnn');
fprintf('At State Point 1 :n');
fprintf('P1 sf Barn',p1);
fprintf('T1-f Deg Celsiusn',t1);
fprintf('H1 f kJ/Kgn',h1);
fprintf('S1-f kJ/KgKnn',s1);
fprintf('At State Point 2 :n');
fprintf('P2-f Barn', p2);
fprintf('T2=%f Deg Celsiusn', t2);
fprintf('H2=f kJ/Kgn', h2);
fprintf('S2=f kJ/KgKnn',s2);
fprintf('At State Point 3 :n');
fprintf('P3-f Barn', p3);
fprintf('T3-f Deg Celsiusn', t3);
fprintf('H3-f k3/Kgn', h3);
fprintf('S3=%f kJ/KgKnn', s3);
fprintf('At State Point 4 :n');
fprintf('P4-f Barn', p4);
fprintf('T4-%f Deg Celsiusn', t4);
fprintf('H4 %f kJ/Kgn', h4);
fprintf('S4-%f kJ/KgKnn', s4);
fprintf('Work done by Turbine is: %f kJ/Kgn', Wt);
fprintf('Work done by Pump is: %f kJ/Kgn',Wp);
fprintf('Net Work done on the System: %f kJ/Kgn',W);
fprintf('Specific Steam Consumption is: %f kg/kWhn', SSC);
fprintf('The Net Thermal Efficiency of the System is %fn', ntherm);
fprintf('The BWR of the Rankine Cycle is found to be %fn', BWR);
AIM:
TO CREATE A RANKINE CYCLE STIMULATOR
PLOTTING THE GRAPD T-S AND H-S
OBJECTIVE:
A rankine cycle is obtained:
RANKINE CYLCE IS A CYCLE IN WICH THE STEAM ENGINE WORKS
Process 1-2:
Reversible adiabatic expansion
2-3:
Constant pressure transfer in the condenser
3-4:
Reversible adiabatic pumping process i
4-1:
Constant pressure transfer in the boiler.
The main equation used is Steady flow energy equations;
MAIN PROGRAM WITH DEFINITION:
We are using XSteam.m program which is basically the steam table.
Clearing workspace command window and closing all plots.
clear all
close all
Clc
% the required informations
Thisc command is used to print all the information in the command window.
fprintf('n RANKINE CYCLE SIMULATOR');
fprintf('nn1-2 Isentropic Expansion in Turbine');
fprintf('n2-3 Constant Pressure Heat Rejection in the Condenser');
fprintf('n3-4 Isentropic Compression in the Pump');
fprintf('n4-1 Constant Pressure Heat Addition by the Boilern');
The inputs are given to the program p1 t1 p2:
%inputs pressure and temperature
p1=input(' Pressure at the Turbine inlet (bar): ');
t1=input(' Temperature at the Turbine inlet (celsius) :');
p2=input(' Pressure at the Condenser: ');
%@ stage 1 Turbine Inlet
% p1 & t1 are given
H1 ans s1 are find from the steam table;
h1=XSteam ('h_pT', p1,t1);
s1= XSteam('s_pT',p1,t1);
%@ stage 2 Condenser Inlet
% p2 is given
s2=s1;
When s2 is found:
sf2=XSteam ('sL_p', p2);
sg2=XSteam('sV_p', p2);
hf2=XSteam('hL_p',p2);
x2=(s2-sf2)/(sg2-sf2);
hg2=XSteam ('hV_p', p2);
h2=hf2+(x2+(hg2-hf2));
The required values are found from the steam table :
%@ stage 3 Pump Inlet
p3=p2;
h3=XSteam('hL_p',p3);
s3=XSteam ('SL_p',p3);
t3=XSteam( 'Tsat_p',p3);
t2=t3;
%@ stage 4 Boiler Inlet
The saturations properties are found using the steam table;
Also at stage 1,2 3,4 are calculated
p4=p1;
s4=s3;
h4=XSteam ('h_ps', p4,s4);
cp4=XSteam ('Cp_ps', p4, s4);
cv4=XSteam('Cv_ps', p4, s4);
lambda=cp4/cv4;
t4=t3/((p3/p4)^((lambda-1)/lambda));
t5=XSteam ('Tsat_p',p1);
t6=t5;
s5=XSteam ('SL_p',p1);
s6=XSteam ('sV_p',p1);
h5=XSteam ('hL_p',p1);
h6=XSteam('hV_p',p1);
The equations are given to find the work at each stage of the rankine cycle:
% Turbine Work
Wt=h1-h2;
% Pump Work
Wp=h4-h3;
% Net Work (kJ/Kg)
W=Wt-Wp;
% Heat in & out of the System
Q_in=h1-h4;
Q_out=h2-h3;
%Thermal Efficiency
ntherm= (W/Q_in)*100;
% Steam rate (kg/kWh)
SSC=3600/W;
% Back Work Ratio
BWR= (h1-h4)/(h2-h3);
The garph plot saturation curve is given:
% to plot Saturation Curve
T=linspace (1,400, 500);
for i=1:length(T)
h_l(i)=XSteam('hL_T',T(i));
h_v(i)=XSteam ( 'hV_T',T(i));
s_l(i)=XSteam ('SL_T',T(i));
s_v(i)=XSteam('sV_T',T(i));
End
The ts diagram is plotted using the below comand;
% plotting TS diagram
figure(1)
hold on
title('T-S Diagram'),
plot([s1 s2], [t1 t2], 'linewidth', 3, 'color', 'b')
plot([s2 s3], [t2 t3], 'linewidth', 3, 'color', 'b')
plot([s3 s4], [t3 t4], 'linewidth', 3, 'color', 'b')
plot([s4 s5], [t4 t5], 'linewidth', 3, 'color','b')
plot([s5 s6], [t5 t6], 'linewidth', 3, 'color', 'b')
xlabel('Entropy (kJ/KgK');
ylabel('Temperature (deg C)');
S_1=linspace (s6, s1,500);
for j=1:length(s_1)'
t_1(j)=XSteam ('T_ps',p1,s_1(j));
end
plot(s_1,t_1, 'linewidth', 3, 'color', 'b')
plot(s_1, T, 'linewidth',1.5, 'color', 'r')
plot(s_v, T, 'linewidth',1.5, 'color', 'r')
% Annotations
text(s1,t1,'1', 'fontsize',15);
text (s2, t2, '2', 'fontsize',15);
text(s3, t3, '3', 'fontsize', 15, 'verticalalignment', 'top');
text (s4, t4, '4', 'fontsize', 15, 'verticalalignment', 'bottom');
text (s5, t5, '5', 'fontsize', 15, 'verticalalignment', 'bottom');
text(s6, t6, '6', 'fontsize', 15, 'verticalalignment', 'bottom');
figure(2)
hold on
title('H-S Diagram');
plot([s1 s2], [h1 h2], 'linewidth',2, 'color', 'b')
plot([s2 s3], [h2 h3], 'linewidth',2, 'color', 'b')
plot([s3 s4], [h3 h4], 'linewidth',2, 'color', 'b')
h_4=linspace(h4,h5,500);
for k=1:length(h_4);
s_4(k)=XSteam('s_ph',p1,h_4(k));
end
h_6=linspace(h6,h1,500);
for m=1:length(h_6);
s_6 (m) =XSteam('s_ph',p1,h_6(m));
end
plot(s_4,h_4, 'linewidth', 2, 'color', 'b')
plot([s5 s6], [h5 h6], 'linewidth',2, 'color', 'b')
xlabel('Specific Entropy (kJ/KgK)');
plot(s_6,h_6, 'linewidth', 2, 'color', 'b')
ylabel('Specific Enthalpy (kJ/Kg)');
plot(s_l,h_l, 'linewidth', 1.5, 'color', 'r')
plot(s_v,h_v, 'linewidth',1.5, 'color', 'r')
% Annotations
text(s1,h1,'1','fontsize',15);
text(s2,h2,'2','fontsize',15);
text(s3, h3, '3', 'fontsize', 15, 'verticalalignment', 'top');
text(s4, h4, '4', 'fontsize', 15, 'verticalalignment', 'bottom');
text(s5, h5, '5', 'fontsize', 15, 'verticalalignment', 'bottom');
text(s6, h6, '6', 'fontsize', 15, 'vertica lalignment', 'bottom');
The resulats are given to the command window usimg the below comands;
Results Window fprintf('nRESULTSnn');
fprintf('At State Point 1 :n');
fprintf('P1 sf Barn',p1);
fprintf('T1-f Deg Celsiusn',t1);
fprintf('H1 f kJ/Kgn',h1);
fprintf('S1-f kJ/KgKnn',s1);
fprintf('At State Point 2 :n');
fprintf('P2-f Barn', p2);
fprintf('T2=%f Deg Celsiusn', t2);
fprintf('H2=f kJ/Kgn', h2);
fprintf('S2=f kJ/KgKnn',s2);
fprintf('At State Point 3 :n');
fprintf('P3-f Barn', p3);
fprintf('T3-f Deg Celsiusn', t3);
fprintf('H3-f k3/Kgn', h3);
fprintf('S3=%f kJ/KgKnn', s3);
fprintf('At State Point 4 :n');
fprintf('P4-f Barn', p4);
fprintf('T4-%f Deg Celsiusn', t4);
fprintf('H4 %f kJ/Kgn', h4);
fprintf('S4-%f kJ/KgKnn', s4);
fprintf('Work done by Turbine is: %f kJ/Kgn', Wt);
fprintf('Work done by Pump is: %f kJ/Kgn',Wp);
fprintf('Net Work done on the System: %f kJ/Kgn',W);
fprintf('Specific Steam Consumption is: %f kg/kWhn', SSC);
fprintf('The Net Thermal Efficiency of the System is %fn', ntherm);
fprintf('The BWR of the Rankine Cycle is found to be %fn', BWR);
Errors faced:
Matlab is showing errors in the steam table while running the program:
CONCLUTIONS:
The garph is obtained, and the efficiency are obtained