Project 2 - Rankine cycle Simulator
AIM:
Creation of rankine cycle simulator from given input and reading the data from standard thermodynamic library of steam table
clear all
close all
clc
%Rankine cycle simulatore
fprintf('Rankine cyclen')
fprintf('1-2 is isentopic ecpansion in turbinen')
fprintf('2-3 is constant pressure heat removaln')
fprintf('3-4 is isentropic compression in pump n')
fprintf('4-1 constant pressure heat addition in boilern')
%Taking data from xsteam file for state point 1
h1 = Xsteam('h_pT', p1, T1); %enthalpy at pressure and temp 1
s1 = Xsteam('s_pT', p1, T1); %entropy at pressure and temp 1
%Taking data from xsteam file for state point 2
s2 = s1; %because of isentropic expansion
sf2 = xsteam('sL_p',p2); %saturated liquide entropy at pressure 2
sg2 = xsteam('sV_p',p2); %saturated vapour entropy at pressure 2
x2 = (s2-sf2)/(sg2-sf2); %vapour fraction at state popint 2
hf2 = xsteam('hL_p',p2); %saturated liquid enthalpy at pressure 2
hg2 = xsteam('hV_p',p2); %saturated vapour enthalpy at pressure 2
h2 = hf2 + (x2*(hg2-hf2)); %enthalpyat state point 2
%Taking data from xsteam file for state point 3
p3 = p2; %constant pressure heat removal process
s3 = xsteam('sL_p',p3); %saturated liquid entropy at pressure 3
h3 = xsteam('hL_p',p3); %saturated liquid enthalpy at pressure 3
%work done in turbine for the rankine cycle
W_T = h1-h2;
%work done required for pump
v3 = xsteam('vL_p',p3); %saturated liquid vapour at pressure 3
W_P = v3*(p4-p3)*100; %work done for pump
h4 = h3 - W_P; %Enthalpy at state pint 4
%Net work done for rankin cycle
W_net = W_T - W_p;
%Heat addition to system
Q_in = h1-h4;
%Heat rejection from system
Q_out = h2-h3;
%Thermal efficiency of rankin cycle
T_eff = (W_net/Q_in)*100;
%specific steam consumption = (mass flow rate / net work done)
sp_s = (3600/W_net);
%calculation of temperature at all state poin 2,3and 4
T3 = xsteam('Tsat_p',p3); %saturation temperature at pressure 3
T3 = T3; %becuase of constant pressure heat addition
cp4 = xsteam('cp_ps',p4,s4); %specific isobaric heat capacity
cv4 = xsteam('cv_ps',p4,s4); %specific isochoric heat capacity
k = cp4/cv4;
T4 = T3/((p3/p4)^((k-1)/k)); %temperature at state point 4
%claculation of other constant for saturated liquid and vapour
T6 = xsteam('Tsat_p',p1); %saturated temperature at pressure 1
s5 = xsteam('sL_p',p1); %saturated liquid entropy at pressure 1
s6 = xsteam('sV_p',p1); %saturated vapour entropy at pressure 1
h5 = xsteam('hL_p',p1); %saturated liquid enthalpy at pressure 1
h6 = xsteam('hV_p',p1); %saturated vapour enthalpy at pressure 1
T5 = T6;
%plotting for saturation line
T = linspace(1,560,1000);
for i = 1:length(T)
sf(i) = xsteam('sL_T',T(i)); %saturated liquid entropy
sg(i) = xsteam('sV_T',T(i)); %saturated vapour entropy
hf(i) = xsteam('hL_T',T(i)); %saturated liquid enthalpy
hg(i) = xsteam('hV_T',T(i)); %saturated vapour enthalpy
end
%plotting T-S diagram for rankine cycle
figure(1)
hold on
plot(sf,T,'color','b','linewidth',2)
plot(sg,T,'color','b','linewidth',2)
plot([s1 s2],[T1 T2], 'color','r','linewidth',3)
plot([s2 s3],[T2 T3], 'color','r','linewidth',3)
plot([s3 s4],[T3 T4], 'color','r','linewidth',3)
plot([s4 s5],[T4 T5], 'color','r','linewidth',3)
plot([s5 s6],[T5 T6], 'color','r','linewidth',3)
s_1 = linspace(s6,s1,1000);
for j = 1:length(s_1)
Tc(j) = xsteam('T_ps',p1,s_1(j));
end
plot(s_1,Tc,'color','r','linewidth',3)
text(s1+0.1,T1,'1')
text(s2+0.1,T2,'2')
text(s3, T3-20, '3')
text(s4, T4+20, '4')
title('Temperature vs Entropy')
xlable('Entropy (kj/kg-k)')
ylable('temperature (deg.celcius)')
legend('saturated curve')
%plotting H-S diagram for rankine cycle
figure(2)
hold on
plot(sf,hf,'color','b','linewidth',2)
plot(sg,hg,'color','b','linewidth',2)
plot([s1 s2],[h1 h2],'color','r','linewidth',3)
plot([s2 s3],[h2 h3],'color','r','linewidth',3)
plot([s3 s4],[h3 h4],'color','r','linewidth',3)
hc = linspace(h4,h5,100);
for k = 1:length(hc)
s_c(k) = xsteam('s_ph',p1,hc(k));
end
plot(s_c,hc,'color','r','linewidth',3)
plot([s5 s6],[h5 h6],'color','r','linewidth',3)
for l = 1:length(s_1)
h_c(l) = xsteam('h_ps',p1,s_1(l))
end
plot(s_1,h_c,'color','r','linewidth',3)
text(s1+0.1,h1,'1')
text(s2+0.1,h2,'2')
text(s3,h3-100,'3')
text(s4,h4+200,'4')
title('enthalpy vs entropy')
xlable('entropy (kj/kg-k)')
ylable('enthalpy (kj/kg)')
legend('saturation curve')
%Displaying result in command window
disp('result of rankine cycle')
fprintf('At state point 1ttttt')
fprintf('At state point 2n')
fprintf('p1 = %10f in bartttt',p1);
fprintf('p2 = %10f in barn',p2);
fprintf('T1 = %11f in deg.celciustt',T1);
fprintf('T2 = %11f in deg.celciustt',T2);
fprintf('H1 = %12f in kj/kgttt',h1);
fprintf('H2 = %12f in kj/kgn',h2);
fprintf('s1 = %9f in kj/kg-kttt',s1);
fprintf('s2 = %9f in kj/kg-kn',s2);
fprintf('n')
fprintf('At state point 3ttttt')
fprintf('At state point 4n')
fprintf('p3 = %10f in bartttt',p3);
fprintf('p4 = %10f in barn',p4);
fprintf('T3 = %11f in deg.celciustt',T3);
fprintf('T4 = %11f in deg.celciusn',T4);
fprintf('H3 = %12f in kj/kgttt',h3);
fprintf('H4 = %12f in kj/kgn',h4);
fprintf('s3 = %9f in kj/kg-kttt',s3);
fprintf('s4 = %9f in kj/kg-kn',s4);
fprintf('n')
fprintf('Turbine work done = %14f in kj/kg',W_T)
fprintf('pump work done = %15f in kj/kg',W_p)
fprintf('net work done = %17f kj/kg',W_net)
fprintf('Thermal efficiency = %13f in percentn',T_eff)
fprintf('sp.steam consuption = %f in kj/kwn',Sp_S)
CODE EXPLANATION;
*The creation of rankine cycle simulator starts with some input value which are required to calculate the other state point in cycle eventually
*The rankine cycle process is displayed in the command window and then inputs are entered which are inlet pressure for turbine temperature at turbine inlet and pressure at condenser
*Then we are using Xsteam function file for reading state point. first we get the value of enthalpy and entropy at state point 1 from the Xsteam function file
*As process 'sg' and 'sf' are referred to saturated liquid and saturated vapour entropy respectively. this value is used to calculate other function according to mathamatical relations
*Similarly other points are taken from Xsteam function file which are necessary to calculate other parameters .after that work done in turbine and pump are calculated for further getting the net work done rankine cycle
*After calculating the net work done the efficiency of the rankine cycle is claculated along with specific steam consumption which is steam consumed by a locomotive cylinders per unit of output of work done
*Then temperature at each point of cycle is calculated using input taken from start of the program and data taken Xsteam file for given temperature range from lower to higher entropy points are calculated to creat the T-S plot.similarly another for loop is used to create the saturation curve in each plot
*Then plotting is done respectivily for T-s and H-s graph in rankine cycle and each state point value has been put in command window


Result in the command window for entire calculation


ERRORS;

REFERENCES;
1.https://en.wikipedia.org/wiki/rankine_cycle
2.https://www.sciencedirect.com/topics/earth-and-planetary-science/rankine-cycle
3.https://www.youtube.com/watch?v=QFZN71MY71O