Project 2 - Rankine cycle Simulator
Aim :- To create a Rankine Cycle Simulator that calculates state point variables at different points and plot the corresponding T-s and h-s plots for the given set of inputs.
Theory:-
Rankine cycle is the cycle on which the steam turbine works.
The Rankine cycle consists of following four processes:-
1) Turbine(Process 1-2):- Reversible adiabatic expansion of steam in the turbine.
2) Condensor (Process 2-3) :- Reversible constant pressure heat rejection in the condensor.
3)Pump(Process 3-4) :- Reversible adiabatic pumping process in the feed pump.
4) Steam boiler(Process 4-1 ):- Reversible constant pressure heating process of water in the condenser.
Analysis:-
The work done by the turbine is given by `W_(Turb i n e)= h_1 – h_2`
The heat supplied in the boiler is `Q_1 = h_1 – h_(f4)`
The heat rejected in the condensor is`Q_2 = h_2 – h_(f3)`
The work required to operate the pump is`W_(Pump) = h_(f4) – h_(f3)`
Now, Efficiency of Rankine cycle is given by
`eta_(ranki n e) = W_(n et)/Q_1`
`therefore eta_(rank i n e) = ((h_1-h_2)-(h_(f4)-h_(f3)))/(h_1-h_(f4))`
Explaination of the code:-
As mentioned above regarding the process takes place in a Rankine cycle, all the process are first displayed using the 'disp' command. The user is then asked to input the values of inlet pressure,inlet temperature,outlet pressure of turbine and this can be achieved using 'input' command.
clear all
close all
clc
disp('1-2 is Isentropic Expansion in the turbine')
disp('2-3 is Constant Pressure Heat Rejection by the condensor')
disp('3-4 is Isentropic Compression in the Pump')
disp('4-1 is Constant Pressure Heat Addition by the boiler')
P1 = input('\nEnter theInlet Pressure of Turbine in bar');
T1 = input('Enter the Inlet Temperature of Turbine in degree Celsius');
P2 = input('Enter the Outlet Pressure of Turbine in bar');
The state point variables are now calculated using the XSteam function file by passing it a correct set of input arguments. The state properties like Temperature, Enthalpy, specific entropy of liquid, vapour, superheated steam are calculated at the respective state points. The thermodynamic relation is also used in calculating the properties. As location of state point 2 depends on the dryness fraction whether it is in the superheated region(x>1) or liquid-vapour region (x<1) the dryness fraction is first calculated and depending on the value, the enthalpy 'h2' is calculated using 'if else' statement. The properties are then found out for state point 2,3,4 similarly. Finally, the work done by the turbine,pump, efficiency, specific fuel consumption, back work ratio is calculated using the appropriate thermodynamic relation.
%At state point 1
Tsat_P1 = XSteam('Tsat_p',P1);
h1 = XSteam('h_pT',P1,T1);
s1 = XSteam('s_pT',P1,T1);
sg_P1 = XSteam('sV_p',P1);
%At state point 2
Tsat_P2 = XSteam('Tsat_p',P2);
s2 = s1;
sf2 = XSteam('sL_p',P2);
sg2 = XSteam('sV_p',P2);
sfg2 = sg2-sf2;
x2 = (s2-sf2)/sfg2; %Dryness fraction at state 2
if (x2 >= 1)
T2 = XSteam('T_ps',P2,s2);
h2 = XSteam('h_ps',P2,s2);
else
T2 = XSteam('Tsat_p',P2);
hf2 = XSteam('hL_p',P2);
hg2 = XSteam('hV_p',P2);
h2 = hf2+x2*(hg2-hf2); %Enthalpy at state 2
end
%At state point 3
P3 = P2;
T3 = T2;
h3 = XSteam('hL_p',P2);
s3 = XSteam('sL_p',P3);
%At state point 4
P4 = P1;
vf_p2 = XSteam('vL_p',P2);
W_p = vf_p2*(P1-P2)*100; %Work done by pump
h4 = h3 + W_p;
s4 = s3;
T4 = XSteam('t_ps',P4,s4);
sf_p4 = XSteam('sL_p',P4);
%Work done by turbine
W_t = h1-h2; %Work done by turbine
W_net = W_t - W_p; %Net Work done
Q1 = h1 - h4; %Heat Supplied in the boiler
efficiency = W_net/Q1; %Efficiency of the cycle
SSC = 3600/W_net; %Specific Steam consumption
BWR = (h4-h3)/(h1-h2); %Back Work Ratio
After the calculation of properties at respective state points, the (Temperature-entropy)T-s diagram is plotted. First, the isentropic process in turbine is plotted which is process 1-2. For plotting the process(2-3) ie. heat rejection in the condensor, depending on the value of dryness fraction, the process(2-3) is plotted. If x>1 , then the point 2 lies in the superheated region and hence the points 2 and 3 cannot be joined using a straight line. Since it is a constant pressure heat rejection process, a curve is obtained in the supeheated region and hence, an array 'T' is created which contains values ranging from temperature 'T2' to saturation temperature corresponding to pressure P2. The entropy values are then evaluated at these temperature values and the required curve is obtained. If x<1, then the point 2 lies in the liquid vapour region and for plotting the process (2-3), a line is obtained since it is a constant pressure process. Similarly, a line is obtained for process (3-4) since it is an isentropic process. Similarly for process (4-1), the curves are plotted using an array 'T_matrix' and corresponding entropy 's6' array. The respective points are named using 'text' command.
The T-s diagram for water is then plotted using temperature and entropy values ranging from 0 degree to critical temperature (373.946 degrees) and then critical temperature to 0 .
%Plotting of processes
figure(1)
grid on
hold on
T_matrix = linspace(Tsat_P1,T1,500);
for i = 1:500
s6(1,i) = XSteam('s_pT',P1,T_matrix(1,i));
end
plot([s1 s2],[T1 T2],'linewidth',2,'color','b') %Isentropic process in turbine
if x2 >=1
T = linspace(Tsat_P2,T2,500);
for i = 1:500
s(1,i) = XSteam('s_pT',P2,T(1,i));
end
plot([s,sg2,s3],[T,Tsat_P2,Tsat_P2],'linewidth',2,'color','g') %Constant pressure curve Heat rejection in condensor
plot([s3 s4],[Tsat_P2 T4],'linewidth',2,'color','c') %Isentropic process in pump
text(s3,Tsat_P2,'3')
else
plot([s2 s3],[T2 T3],'linewidth',2,'color','g') %Constant pressure line Heat rejection in condensor
plot([s3 s4],[T3 T4],'linewidth',2,'color','c') %Isentropic process in pump
text(s3,T3,'3')
end
plot([s4,sf_p4,sg_P1,s6],[T4,Tsat_P1,Tsat_P1,T_matrix],'linewidth',2,'color','r') %Heat addition in boiler
%Plot T-S curve
n = linspace(0,373.946,500);
for i = 1:length(n)
S(1,i) = XSteam('sL_T',n(i));
end
plot(S,n,'--','color','k') %Saturated Liquid curve
n = linspace(373.946,0,500);
for i = 1:500
S(1,i) = XSteam('sV_T',n(i));
end
plot(S,n,'--','color','k') %Saturated vapour curve
text(s1,T1,'1')
text(s2,T2,'2')
text(s4,T4,'4')
xlabel('Specific Entropy(kJ/kgK)')
ylabel('Temperature(K)')
title('T-S diagram')
legend('(1-2)Isentropic process in turbine','(2-3)Constant pressure Heat rejection','(3-4)Isentropic process in pump','(4-1)Constant pressure Heat addition','Saturation curve')
The h-s diagram is also plotted similarly as done for T-s diagram. The enthalpy and entropy values were calculated for temperature values ranging from 0 degree to critical temperature (373.946 degrees) and then critical temperature to 0 .
Finally, the thermodynamic processes are plotted using the 'plot' command.
%Plot h-S curve
figure(2)
hold on
grid on
n = linspace(0,373.946,500);
for i = 1:length(n)
S(1,i) = XSteam('sL_T',n(i));
H(1,i) = XSteam('hL_T',n(i));
end
plot(S,H,'--','color','k')
% Saturated Liquid curve
n = linspace(373.946,0,500);
for i = 1:500
S(1,i) = XSteam('sV_T',n(i));
H(1,i) = XSteam('hV_T',n(i));
end
plot(S,H,'--','color','m') %Saturated vapour curve
plot([s1,s2],[h1,h2],'linewidth',2,'color','b') %Isentropic process in turbine
plot([s2,s3],[h2,h3],'linewidth',2,'color','g') %Constant pressure line Heat rejection in condensor
plot([s3,s4],[h3,h4],'linewidth',2,'color','c') %Isentropic process in pump
plot([s4,s1],[h4,h1],'linewidth',2,'color','r') %Heat addition in boiler
legend('Saturated liquid curve','Saturated vapour curve','(1-2)Isentropic process in turbine','(2-3)Constant pressure Heat rejection','(3-4)Isentropic process in pump','(4-1)Constant pressure Heat addition')
text(s1,h1,'1')
text(s2,h2,'2')
text(s3,h3,'3')
text(s4,h4,'4')
xlabel('Specific Entropy(kJ/kgK)')
ylabel('Specific Enthalpy(kJ/kg)')
title('h-s diagram')
At the end of the program, the results are dispayed to the user which displays all the state variables at different state points and this was achieved using 'fprintf' command.
fprintf('\nAt State point 1;')
fprintf('\nPressure is P1 = %f bar\n',P1)
fprintf('Temperature is T1 = %f degree celsius\n',T1)
fprintf('Enthalpy is h1 = %f kJ/kg\n',h1)
fprintf('Entropy is s1 = %f kJ/kgK\n',s1)
fprintf('\nAt State point 2;')
fprintf('\nPressure is P2 = %f bar\n',P2)
fprintf('Temperature is T2 = %f degree celsius\n',T2)
fprintf('Enthalpy is h2 = %f kJ/kg\n',h2)
fprintf('Entropy is s2 = %f kJ/kgK\n',s2)
fprintf('Dryness Fraction is x2 = %f\n',x2)
fprintf('\nAt State point 3;')
fprintf('\nPressure is P3 = %f bar\n',P3)
fprintf('Temperature is T3 = %f degree celsius\n',T3)
fprintf('Enthalpy is h3 = %f kJ/kg\n',h3)
fprintf('Entropy is s3 = %f kJ/kgK\n',s3)
fprintf('\n At State point 4;')
fprintf('\nPressure is P4 = %f bar\n',P4)
fprintf('Temperature is T4 = %f degree celsius\n',T4)
fprintf('Enthalpy is h4 = %f kJ/kg\n',h4)
fprintf('Entropy is s4 = %f kJ/kgK\n',s4)
fprintf('\nWork done by the turbine is Wt = %f kJ\n',W_t)
fprintf('Work done by the pump is Wp = %f kJ\n',W_p)
fprintf('Net Work done is Wnet = %f kJ\n',W_net)
fprintf('Efficiency of the Rankine cycle is efficiency = %f ',efficiency*100)
fprintf('\nSpecific Steam Consumption is SSC = %f kg/kWhr',SSC)
fprintf('\nBack Work Ratio is BWR = %f',BWR)
Output:-
1) Results in command window:-
2) T-s diagram
3) h-s diagram
Errors faced while programming:-
Screenshot of the error:-
Steps taken to overcome those errors:-
In the for loop, the properties S,H were calclualted using for loop, the statements were written incorrectly as:-
for i = 1:length(n)
S(i,i) = XSteam('sL_T',n(i));
H(i,i) = XSteam('hL_T',n(i));
end
The error was rectifed by writing S(1,i) and H(1,i).
Conclustion:-
Thus, a Rankine cycle was simulated using MATLAB program.