Project 2 - Rankine cycle Simulator
Aim:
- Create a Rankine Cycle Simulator using OCTAVE/MATLAB
- Code should calculate the state points of the Rankine Cycle (any type of your choice) based on user inputs.
- Plot the corresponding T-s and h-s plots for the given set of inputs. Title and axes labels are a must, while legends could be used if necessary.
- Attach a report explaining the working of a Rankine cycle simulator and also the research done by you.
Rankine Cycle:
- It is an ideal thermodynamic vapor cycle used in thermal power plants.
- In this cycle all the process observed to be reversible.
- Water is used as the working fluid.
- It is modified form of the Carnot cycle, wherein most of the Carnot cycle limitation are eliminated.
Components of Rankine Cycle:
- Boiler: Heat is transferred to the feed water from an external source to generate the steam. This high pressure and high temperature steam is supplied to the turbine for expansion process.
- Turbine: High Pressure and High Temperature Steam expands to produce Mechanical Work or Shaft Work. Expanded steam is passed to the condenser to reuse the working fluid.
- Condenser: Low Pressure expanded steam is condensed into liquid water by rejecting heat to the cooling water which is continuously circulated in the heat exchanger.
- Feed Pump: To avoid losses in the boiler the liquid feedwater supplied to the boiler needs to be raised up to the boiler pressure using feed pump
https://drive.google.com/file/d/1EMOsmzwPJnrYEhrYWjkWY-XY4pTOXZAz/view?usp=sharing
This cycle is completed by the following four process.
- Reversible Adiabatic Expansion (Process 1-2): In this process, the steam is expanded isentropically (Entropy Constant) in turbine from pressure P1 to P2. This process is also called as "Isentropic Expansion Process".
- Constant Pressure Heat Rejection (Process 2-3): The steam is isothermally condensed to saturated water in condenser by rejecting heat to the circulating cooling water. This process is also called as "Isobaric Process".
- Reversible Adiabatic Compression (Process 3-4): The water at the condenser pressure is pumped to the boiler pressure by feed pump.
- Constant Pressure Heat Addition (Process 4-1): Water in the boiler is heated at constant pressure to produce steam
Performance Parameters of Rankine Cycle:
Work done by Turbine (Kj/Kg) : h1 – h2
Work done by Feed Pump (Kj/Kg) : h4-h3
Net Work done (Kj/Kg) : (Turbine Work) – (Feed Pump Work)
: (h1 – h2) – (h4 - h3)
Heat Added (Kj/Kq) : h1 – h4
Heat Rejected (Kj/Kg) : h2 – h3
Thermal Efficiency of Cycle (%) : (1 – (Heat Rejected / Heated Added)) X 100
: (1 – (h2 – h3) / (h1 – h4)) X 100
: (h1 – h4) – (h2 – h3) / (h1 – h4) X 100
: (h1 – h2) – (h4 – h3) / (h1 – h4) X 100
: (Net Work done) / (Heat Added) X 100
Specific Steam Consumption (Kg/Kj): It is the amount of steam consumed by the Turbine per unit work done.
: 3600 / (Net Work done)
Back Work Ratio: It indicates the amount of work output consumed to drive the pump. Higher the back work ratio, lower the overall efficiency of the cycle. Converse is also true.
: (Work done by Feed Pump) / (Work done by Turbine)
: (h4 – h3) / (h1 – h2)
Matlab Code:
close all %close all open file
clear all %clear the workspace
clc %clear the command window
%Header File
fprintf('Rankine Cycle Simulator')
fprintf('\n\n Process 1-2: Isentropic Expansion Process in Turbine')
fprintf('\n Process 2-3: Isobaric Heat Rejection in Condenser')
fprintf('\n Process 3-4: Isentropic Compression in Feed Pump')
fprintf('\n Process 4-1: Isobaric Heat Addition in Boiler \n')
%input parameters
p1=input("\n\nEnter Turbine inlet Pressure in bar: ");
p2=input("Enter Condenser inlet Pressure in bar: ");
t1=input("Enter Turbine inlet Temperature in celsius: ");
%State point 1
h1=XSteam('h_pt',p1,t1);
s1=XSteam('s_pt',p1,t1);
%State point 2
s2=s1;
s2_vap=XSteam('sV_p',p2);
s2_liq=XSteam('sL_p',p2);
t2_sat=XSteam('Tsat_p',p2);
x=(s2 - s2_liq) / (s2_vap - s2_liq);
if x<=1
h2=XSteam('h_px',p2,x);
t2=t2_sat;
else
t2=XSteam('T_ps',p2,s2);
h2_vap=XSteam('hV_p',p2);
h2=XSteam('h_ps',p2,s2);
end
%State point 3
t3=t2_sat;
h3=XSteam('hL_p',p2);
s3=s2_liq;
%State Point 4
s4=s3;
h4=XSteam('h_ps',p1,s4);
t4=XSteam('T_ps',p1,s4);
%Result
Turbine_Work=h1-h2;
Pump_Work=h4-h3;
Net_Work=Turbine_Work-Pump_Work;
Q_in=h1-h4;
Q_out=h2-h3;
Thermal_efficiency=(1-(Q_out/Q_in))*100;
SSC = 3600/Net_Work;
Back_Work_Ratio=Pump_Work/Turbine_Work;
%process 1-2 superheated region
h1_vap=XSteam('hV_P',p1);
h1_sup=linspace(h1_vap,h1,1000);
for i=1:length(h1_sup)
s1_sup(i)=XSteam('s_ph',p1,h1_sup(i));
t1_sup(i)=XSteam('T_ph',p1,h1_sup(i));
end
if x>1
s2_sup=linspace(s2_vap,s2,1000);
for i=1:length(s2_sup)
h2_sup(i)=XSteam('h_ps',p2,s2_sup(i));
t2_sup(i)=XSteam('T_ps',p2,s2_sup(i));
end
end
%process 4-1 Subcooled Region
h1_liq=XSteam('hL_p',p1);
s1_liq=XSteam('sL_p',p1);
s4_sub=linspace(s4,s1_liq,1000);
for i=1:length(s4_sub)
h4_sub(i)=XSteam('h_ps',p1,s4_sub(i));
t4_sub(i)=XSteam('t_ps',p1,s4_sub(i));
end
%process4-1 saturated region
s1_vap=XSteam('sV_p',p1);
s1_liq=XSteam('sL_p',p1);
t1_sat=XSteam('Tsat_p',p1);
%critical point
p_cr=220.635;
t_cr=373.946;
s_cr=XSteam('s_pt',p_cr,t_cr);
%Plot T-S curve
p_min=0.01;
p_max=p_cr;
p=linspace(p_min,p_max,1000);
for i=1:length(p)
T_sat(i)=XSteam('Tsat_p',p(i));
s_sat_liq(i)=XSteam('sL_p',p(i));
s_sat_vap(i)=XSteam('sV_p',p(i));
end
figure(1)
plot(s_sat_liq,T_sat,'--','linewidth',2,'color',[0.301 0.745 0.933]);
hold on
plot(s_sat_vap,T_sat,'--','linewidth',2,'color','r');
hold on
plot(s1_sup,t1_sup,'linewidth',2,'color','b')
hold on
line([s1 s2],[t1 t2],'linewidth',2,'color','y')
hold on
if x>1
plot(s2_sup,t2_sup,'linewidth',2,'color','g')
hold on
line([s2_vap s3],[t2_sat t2_sat],'linewidth',2,'color','r')
else
line([s2 s3],[t2_sat t2_sat],'linewidth',2,'color','r')
end
hold on
line([s3 s4],[t3 t4],'linewidth',2,'color','k')
hold on
plot(s4_sub,t4_sub,'linewidth',2,'color','m')
hold on
line([s1_liq s1_vap],[t1_sat t1_sat],'linewidth',2,'color','c')
%Setting markers to state points
plot(s1,t1,'O','MarkerSize',4,'MarkerFaceColor','r')
plot(s2,t2,'O','MarkerSize',4,'MarkerFaceColor','r')
plot(s3,t3,'O','MarkerSize',4,'MarkerFaceColor','r')
plot(s4,t4,'O','MarkerSize',4,'MarkerFaceColor','r')
%labelling the markers in plot
text(s1,t1,' 1','HorizontalAlignment','left')
text(s2,t2,' 2','HorizontalAlignment','left')
text(s3,t3,'3 ','HorizontalAlignment','right')
text(s4,t4,' 4','VerticalAlignment','top')
xlabel('Entropy [Kj/Kg-K]')
ylabel('Temperature [*C]')
legend('Saturated Liquid Line','Saturated Vapour Line','Superheated Process at P1 Pressure','Isentropic Process 1-2', ...
'Superheated Process at P2 Pressure', 'Isobaric Process at P2 Pressure', 'Isentropic Process 3-4', ...
'Subcooling Process at P1 Pressure','Isobaric Process at P1 Pressure','Location','northwest')
title('T-S Diagram of Rankine Cycle')
%plot h-s graph
for i=1:length(p)
h_sat_liq(i)=XSteam('hL_p',p(i));
h_sat_vap(i)=XSteam('hV_p',p(i));
end
figure(2)
plot(s_sat_liq,h_sat_liq,'--','linewidth',2,'color',[0.301 0.745 0.933]);
hold on
plot(s_sat_vap,h_sat_vap,'--','linewidth',2,'color','r');
hold on
plot(s1_sup,h1_sup,'linewidth',2,'color','b')
hold on
line([s1 s2],[h1 h2],'linewidth',2,'color','y')
hold on
if x>1
plot(s2_sup,h2_sup,'linewidth',2,'color','g')
hold on
line([s2_vap s3],[h2_vap h3],'linewidth',2,'color','r')
else
line([s2 s3],[h2 h3],'linewidth',2,'color','r')
end
hold on
line([s3 s4],[h3 h4],'linewidth',2,'color','k')
hold on
plot(s4_sub,h4_sub,'linewidth',2,'color','m')
hold on
line([s1_liq s1_vap],[h1_liq h1_vap],'linewidth',2,'color','c')
%Setting markers to state points
plot(s1,h1,'O','MarkerSize',4,'MarkerFaceColor','r')
plot(s2,h2,'O','MarkerSize',4,'MarkerFaceColor','r')
plot(s3,h3,'O','MarkerSize',4,'MarkerFaceColor','r')
plot(s4,h4,'O','MarkerSize',4,'MarkerFaceColor','r')
%labelling the markers in plot
text(s1,h1,' 1','HorizontalAlignment','left')
text(s2,h2,' 2','HorizontalAlignment','left')
text(s3,h3,'3 ','HorizontalAlignment','right')
text(s4,h4,' 4','VerticalAlignment','top')
xlabel('Entropy [Kj/Kg-K]')
ylabel('Enthalpy [Kj/Kg]')
legend('Saturated Liquid Line','Saturated Vapour Line','Superheated Process at P1 Pressure','Isentropic Process 1-2', ...
'Superheated Process at P2 Pressure', 'Isobaric Process at P2 Pressure', 'Isentropic Process 3-4', ...
'Subcooling Process at P1 Pressure','Isobaric Process at P1 Pressure','Location','northwest')
title('H-S Diagram of Rankine Cycle')
%Displaying State Points
fprintf(strjust('\n\n---------- Result ----------','center'))
fprintf('\n\n State Point - 1')
fprintf('\n P1 : %2.2f bar',p1)
fprintf('\n T1 : %3.2f *C',t1)
fprintf('\n S1 : %4.4f Kj/Kg-K',s1)
fprintf('\n H1 : %4.4f Kj/Kg',h1)
fprintf('\n\n State Point - 2')
fprintf('\n P2 : %2.2f bar',p2)
fprintf('\n T2 : %3.2f *C',t2)
fprintf('\n S2 : %4.4f Kj/Kg-K',s2)
fprintf('\n H2 : %4.4f Kj/Kg',h2)
if x>1
fprintf('\n State Point 2 is in Superheated Region')
else
fprintf('\n State Point 2 is within the Saturated Region')
fprintf('\n X : %2.4f',x)
end
fprintf('\n\n State Point - 3')
fprintf('\n P3 : %2.2f bar',p2)
fprintf('\n T3 : %3.2f *C',t3)
fprintf('\n S3 : %4.4f Kj/Kg-K',s3)
fprintf('\n H3 : %4.4f Kj/Kg',h3)
fprintf('\n\n State Point - 4')
fprintf('\n P4 : %2.2f bar',p1)
fprintf('\n T4 : %3.2f *C',t4)
fprintf('\n S4 : %4.4f Kj/Kg-K',s4)
fprintf('\n H4 : %4.4f Kj/Kg',h4)
%Display of Cycle Parameters
fprintf('\n\n Output Results')
fprintf('\n Workdone by Turbine : %4.2f Kj/Kg',Turbine_Work)
fprintf('\n Workdone by Pump : %4.2f Kj/Kg',Pump_Work)
fprintf('\n Network Work Output : %4.2f Kj/Kg',Net_Work)
fprintf('\n Heat Added : %4.2f Kj/Kg',Q_in)
fprintf('\n Heat Rejeected : %4.2f Kj/Kg',Q_out)
fprintf('\n Thermal Efficiency of the Cycle : %4.2f%',Thermal_efficiency)
fprintf('\n Specific Steam Consumption : %4.4f Kg/Kw-h',SSC)
fprintf('\n Back Work Ratio : %4.4f \n',Back_Work_Ratio)
Code Explanation:
- Code begins with displaying Header, to identify which code is being run.
- The code requests the user to provide the inputs like Turbine Inlet Pressure (P1), Condenser Inlet Pressure (P2) & Turbine Inlet Temperature (T1).
- It is to be remembered that within the saturated dome state points are located using one input variable. Otherwise, you require two input variables to locate the state points.
- XSteam, is a predefined function code which is available in Matlab. One needs to download the code and save it in the same folder where the user code is saved.
- Using the XSteam function Enthalpy, Entropy & Temperature for state point 1, 2, 3 & 4 are located.
- For state point 2 there is a possibility that it might fall in the superheated region or inside saturated region. So, if-else statement is created on the basis of vapor fraction (x). If value of x>1 then state point 2 is on the superheated region or else it is in the saturated region.
- Rankine cycle output parameters are calculated through their respective formula using the obtained State point values.
- In order to plot the T-S & H-S curve, one needs to know that within the saturated dome curve the state points are linearly connected as pressure & temperature are directly proportional. Outside the dome we need an array of points to plot between the state points at constant pressure.
- Hence we create three blocks of code for superheated region, subcooled region & state point 2 region.
- For superheated region, we consider the enthalpy of vapor at the pressure P1 up to the enthalpy at state point 1, we divide the points into 1000 parts and create array. Using which identify the entropy and temperature array between at this points.
- Similarly, for state point 2 region firstly we need to identify where it is inside the dome or outside using the vapor fraction. If its outside then we consider entropy of vapor at pressure P2 and state point 2 entropy divide them into 1000 parts and create a array. Through which the enthalpy and temperature at this points and identified and stored in a array.
- Similar to superheated region, in subcooled region we consider state point 4 entropy and entropy of liquid at pressure P1. To identify enthalpy and temperature at those points.
- In order to plot the T-S curve we need to plot the saturated dome, then the state points. Using pressure as the reference we identify the entropy and temperature at those points and plot the saturated curve dome.
- Then using the plot command we plot the state points and the curves associated with them. Then marker are located at the state points, marker labels are made using text command. Then X and y axis labels are done, legends are given to identify each curve in the plot, finally the plot title is provided.
- Similar to T-S Curve, H-S curve is also plotted.
- Lastly all the State Point Properties & Results are displayed at the command window using ‘fprintf’ command.
Case-1:
https://drive.google.com/file/d/1C2NXIaicZvxV5uYx4Zvl4sZOs8t0xh5L/view?usp=sharing
https://drive.google.com/file/d/1W8Ywc4RmOJrwsxXLRPH3Qd4xyf_SG-fw/view?usp=sharing
Case-2:
https://drive.google.com/file/d/1IussYTMBMZCx0s70rPNtY_BlfbuemyVI/view?usp=sharing
https://drive.google.com/file/d/1G20gjTknJbMxeV3c3FDR8GyzO7R8yi8u/view?usp=sharing
Errors Faced while coding:
1.
Errors Faced:
- While compiling the code the following output appeared, in which the saturated curve lines where missing.
- On going through the code the code for the saturated curves where present.
https://drive.google.com/file/d/1BfpSX72yFmE4LuzXqFxJOqBtJdVGW32b/view?usp=sharing
Mistake:
https://drive.google.com/file/d/1AvF0gzLOM0lmU_s7TdKcF7wXUCh-oGKT/view?usp=sharing
Overcome:
- If a number of plots have to displayed in the same graph then “hold on” command is specified after every plot command to hold the plot values. Which was missing in the code so rectified the same.
2.
Error Faced:
- While compiling the code the following error appeared, which that invalid expression at line no. 154
https://drive.google.com/file/d/1Ne7WKmcDi4_WvJzsw7u0lHyV96kil-5P/view?usp=sharing
Mistake:
https://drive.google.com/file/d/1wvBG2sc5mZiklmEtWG17ygVytCilo8-e/view?usp=sharing
Overcome:
- Checking through the MATLAB helpdesk for the line command, it appeared that the x and y coordinates to be specified within the square bracket instead of parentheses. So, the necessary changes were made.
3.
Error Faced:
- While compiling the code the following output appeared in the command window. Wherein multiple lines were joined together in a single line.
https://drive.google.com/file/d/1cAftrE9umK6VI4-WXxDDcS7dQz4BtSWc/view?usp=sharing
Mistake:
https://drive.google.com/file/d/1nH97usUgSQGB7NPAZ_4TvkUqnrAN_S-O/view?usp=sharing
Overcome:
- While writing the code missed to mention the newline command in the code hence the output joined the output with previous line output. So rectified it by specifying ‘\n’ command in the code.
Conclusion:
- For the desired input values Rankine cycle has been simulated.
- Further, T-S & H-S plots for the desired input has been plotted and the results were also evaluated.