Project 2 - Rankine cycle Simulator
Rankine Cycle simulator (MATLAB)
Aim :
Create the rankine cycle simulator and calculate the state poins and plot the T-S and S-H using MATLAB.
Objective :
- Study about Rankine cycle concepts.
- Calculate the state points of Rankine cycle using matlab.
- plot T-S and S-H graphs using given input in the matlab.
- display the final results such as Net Work Output, Back Work Ratio etc..,
Theory :
Rankine Cycle :
The Rankine cycle was named and describes the performance of steam turbine system, though the theoritical priciple also applies to reciprocating engines such as steam locomotives. The Rankine cycle is an idealized thermodynamic cycle of a constant pressure heat engine that converts part of heat into mechanical work. In this cycle , the heat is supplied externally to a closed loop, which usally uses water in a liquid and vapor phase as the working fluid. In contrast to the Brayton cycle, the working fluid in th e Rankine cycle undergo the phase change from liquid to vapor phase and vice versa.

Water is usually the fluid of choice due to its favorable properties, such as its non-toxic and unreactive chemistry, abundance, and low cast, as well as its thermodynamic properties. For example, water has the highest specific heat of any common substance. moreover it has a very high heat of vaporization, making it an effective coolant and mediem in thermal power plants and other energy industries. In the case of the Rankine cycle, the Ideal Gas Law almost cannot be used(steam does not follow pV=nRT). Therefore all important parameters of water and steam are tabulated in so called "Steam Tables".
One of the major advantages of the Rankine cycle is that the compression process in the pump takes place on a liquid. By condensing the working steam to a liquid (inside a condenser), the pressure at the turbine outlet is lowered, and the energy required by the feed pump consumed only 1% to 3% of the turbine output power. These factors contribute to higher efficiency for the cycle.

In an ideal Rankine cycle, the system executing the cycle undergoes a series of four processes two Isentropic (reversible adiabatic) processes alternated with two isobaric processes.
Four process :
- Isentropic expansion
- Constant pressure heat rejection
- Isentropic comperssion
- Constant pressure heat addition
Isentropic expansion : (in steam turbine)
Steam from the boiler expands adiabatically from state 1 to state 2 in a steam turbine to produce work and then is discharged to the condenser (partially condensed). The steam works on the surroundings (blades of the turbine) and loses an amount of enthalpy equal to the work that leaves the system. The work done by the turbine is given by W(turine). Again the entropy remains unchanged.

Constant pressure heat rejection : (in a heat exchanger)
In this phase the cycle completes by a constant-pressure process in which heat is rejected from the partially condensed steam. There is heat transfer from the vapor to cooling circuit. The vapor condenses, and the temperature of the cooling water increases. The net heat rejected is given by Q(out).

Isentropic compression : (compression in pumps)
The liquid condensate is compressed adiabatically from state 3to state 4 by centrifugal pumps usually by condensate is pumped from the condenser into the higher pressure boiler. In this process, the surroundings work on the fluid, increasing its enthalpy and compressing it. On the other hand, the entropy remains unchanged. the work required for the compressor is given by W(pump).

Constant pressure heat addition : (in heat exchanger-boiler)
In this phase there is a constant-pressure heat transfer to the liquid condenstate from an external source since the chamber is open to flow in and out. The feedwater (secondary circuit) is heated to the boiling point (4 to 5) of that fluid and then evaporated in the boiler (5 to 1). The net heat added is given by Q(in).

Net work done :
During a Rankine cycle, work is done by the fluid in the turbine between stages 1 and 2 (isentropic expansion). The pump's work is done on the fluid between states 3 and 4 (isentropic compression). The difference between the work done by the fluid and the work done on the fluid is the network produced by the cycle, and it corresponds to the area enclosed by the cycle curve. The working fluid in a Rankine cycle follows a closed loop and is reused constantly.

Thermal Efficiency :
The thermal efficience of this rankine cycle is the ratio of the work done by the pump and heat addition in tha constant heat addition process.

Specific Heat Consumption :
Specific heat consumption is calculated by the ratio of mass flow rate to the power in the cycle.

Back Work Ratio :
The Rankine cycle back work ratio is calculated by work done by the pump with work done by turbine.

Program for simulation :
clear all
close all
clc
%information
fprintf('\n RANKINE CVCLE SIMULATOR ');
fprintf('\n\n1-2 is Isentropic Expansion in Turbine');
fprintf('\n2-3 is Constant Pressure Heat Rejection by the Condenser');
fprintf('\n3-4 is Isentropic Compression in the Pump');
fprintf('\n4-1 is Constant Pressure Heat Addition by the Boiler\n\n');
%inputs
p1=input('Enter the Pressure at the Turbine inlet (in bar) : ');
t1=input('Enter the Temperature at the Turbine inlet (in degree celcius) : ');
p2=input('Enter the Pressure at the Condenser (in bar) : ');
% @ 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);
hg2=XSteam('hV_p',p2);
x2=(s2-sf2)/(sg2-sf2);
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 Saturatlon 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 T-S diagram
figure(1)
hold on
plot(s_l,T,'linewidth',1.5,'color','r')
plot(s_v,T,'linewidth',1.5,'color','r')
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')
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')
title('T-S Diagram');
xlabel('Entropy (kJ/KgK)');
ylabel('Temperature (deg C)');
legend('Saturation Curve','location','northwest')
% 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','top');
text(s6,t6,'6','fontsize',15);
% plotting H-S diagram
figure(2)
hold on
plot(s_l,h_l,'linewidth',1.5,'color','r')
plot(s_v,h_v,'linewidth',1.5,'color','r')
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')
plot(s_6,h_6,'linewidth',2,'color','b')
title('H-S Diagram');
xlabel('Specific Entropy (kJ/KgK)');
ylabel('Specific Enthalpy (kJ/Kg)');
legend('Saturation Curve','location','northwest')
% 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,'horizontalalignment','right');
text(s6,h6,'6','fontsize',15,'verticalalignment','bottom');
% Results window
% Results at state point 1:
fprintf( '\n RESULTS \n' );
fprintf('At State Point 1:\n');
fprintf(' P1=%0.2f Bar\n',p1);
fprintf(' T1=%0.2f Deg Celsius\n',t1);
fprintf(' H1=%0.2f kJ/kg\n',h1);
fprintf(' S1=%0.2f kJ/kgK\n\n',s1);
% Results at state point 2:
fprintf('At State Point 2 :\n');
fprintf(' P2=%0.2f Bar\n',p2);
fprintf(' T2=%0.2f Deg Celsius\n',t2);
fprintf(' H2=%0.2f kJ/kg\n',h2);
fprintf(' S2=%0.2f kJ/kgK\n\n',s2);
% Results at state point 3:
fprintf('At State Point 3 :\n');
fprintf(' P3=%0.2f Bar\n',p3);
fprintf(' T3=%0.2f Deg Celsius\n',t3);
fprintf(' H3=%0.2f kJ/kg\n',h3);
fprintf(' S3=%0.2f kJ/kgK\n\n',s3);
% Results at state point 4:
fprintf('At State Point 4 :\n');
fprintf(' P4=%0.2f Bar\n',p4);
fprintf(' T4-%0.2f Deg Celsius\n',t4);
fprintf(' H4=%0.2f kJ/kg\n',h4);
fprintf(' S4=%0.2f kJ/kgK\n\n',s4);
fprintf('Work done by Turbine is (Wt) : %0.2f kJ/kg\n',Wt);
fprintf('Work done by Pump is (Wp) : %0.2f kJ/kg\n',Wp);
fprintf('Net Work done on the System (Wnet) : %0.2f kJ/kg\n',W);
fprintf('Specific Steam Consumption is (S.S.C) : %0.2f kg/kWh\n',SSC);
fprintf('The Net Thermal Efficiency of the System is (Ntherm) : %0.2f percent \n',ntherm);
fprintf('The BWR of the Ranklne Cycle is found to be : %0.2f\n' ,BWR);
Code Explanation :
1) clear all, close all, clc commands are given to clear all old data, plots and variables in the command window and workspace.
2) A series of information on Rankine cycle is given to display in the command window and also take input value for calculation process. For that fprintf() this command is used to display the information about rankine cycle. And the next to take the input by using the p1=input() this command we take the p1,p2,t1 as the input value.
3) The data for the Rankine cycle is extracted by the XSteam.m file which contains the water and steam properties which are need to calculate the enthalpy, entropy, at the all state points.
4) from the state1 from the XSteam.m file we extract the enthalpy(h1) and entropy(s1) values as the function of pressure and temperature. In the XSteam.m file the h_pT,s_pT,hL_p,sV_p etc are the default variable are stored in that file.
5) Pressure, Temperature, Enthalpy, Entropy for all state variables are extracted as a function of dependent variable from the XSteam.m file.
6) At state2 is an codenser inlet where the high pressure steam is converted into low pressure water and hence Dryness fraction, Enthalpy and Entropy for saturated vapor and saturated water are considered to calculate the specific Enthalpy. And at state4 this is constant pressure heat addition hence pressure is equal to p1 but, temperature increases on heating at constant pressure and constant volume as entropy remains same and hence lambda is equal to Cp/Cv is considered to find temperature T4.
7) Finally work done by the pump(Wp) is calculated by the formula above the isentropic compression process. and the work done by turbine(Wt) is also calculated. and in the constant pressure heat addition process the amount of heat given (Qin) calculated. similarly the heat rejected in the constant pressure process also calculated.
8) next step is to calculate thermal efficiency of the cycle is ratio of Net Work done to total heat additon in the cycle. and Back Work Ratio(BWR) is defined as the fraction of work produced by the turbine that is consumed by the pump.
9) To plot the saturation curve a temperature range is given by linspace command and for the overall length of this temperature values of enthalpy and entropy are calculated at every temperature point. The break in the saturation curve seperates the liquid phase and vapor phase. Now the all necessary data is find out, plotting is done for both T-S diagram and H-S diagram curves using plot command.
10) using title, xlabel, ylable, commands give name to the axis and title to the plots. Annotations are assigned using text command and alignment of some letter are properly located using verticalalinment and bottom commands.
11) Results of the rakine cycle simulation is displayed over command window using fprintf() command.
Ouput :

Plot 1 : T-S Diagram

Plot 1 : H-S Diagram

Results in command window :

Conclusion :
The performance of the heat engine was calculated and the corresponding T-S diagram and H-S diagram are plotted with proper name and title. And the results of the Rankine cycle are displayed in the command window.
1.Net work = 1117.87 kj/kg
2.Thermal Efficiency = 36.17 %
3.Back Work Ratio (BWR)= 1.57
Reference :
https://en.wikipedia.org/wiki/Rankine_cycle#Equations