Project 2 - Rankine cycle Simulator
Aim Rankine cycle Simulator using MATLAB
Objective:
- Understand the concept of Rankin cycle
- Create a code for Rankin Cycle Simulator using OCTAVE/MATLAB
- Extracting Steam and water properties from XSteam data
- Calculating all state point of the cycle based on User inputs
- Plot the corresponding T-s and h-s plots for the given set of inputs
Introduction
Rankins cycle
The Rankins cycle is the fundamental operating cycle of all power plants where an operating fluid is continuously evaporated and condensed. The selection of operating fluid depends mainly on the available temperature range. Figure 1 shows the idealized Rankins cycle.
The pressure-enthalpy (p-h) and temperature-entropy (T-s) diagrams of this cycle are given in Figure 2. The Rankins cycle operates in the following steps:
- 1-2-3 Isobaric Heat Transfer. High pressure liquid enters the boiler from the feed pump (1) and is heated to the saturation temperature (2). Further addition of energy causes evaporation of the liquid until it is fully converted to saturated steam (3).
- 3-4 Isentropic Expansion. The vapour is expanded in the turbine, thus producing work which may be converted to electricity. In practice, the expansion is limited by the temperature of the cooling medium and by the erosion of the turbine blades by liquid entrainment in the vapor stream as the process moves further into the two-phase region. Exit vapour qualities should be greater than 90%.
- 4-5 Isobaric Heat Rejection. The vapours-liquid mixture leaving the turbine (4) is condensed at low pressure, usually in a surface condenser using cooling water. In well designed and maintained condensers, the pressure of the vapour is well below atmospheric pressure, approaching the saturation pressure of the operating fluid at the cooling water temperature.
- 5-1 Isentropic Compression. The pressure of the condensate is raised in the feed pump. Because of the low specific volume of liquids, the pump work is relatively small and often neglected in thermodynamic calculations.


Mathematical Equations
- In general, the efficiency of a simple ranking cycle can be written as


The Thermodynamic efficiency of this cycle can be calculated by the following formula

Main Code for Rankine cycle
%%RANKING CYCLE
close all
clear all
clc
disp('RANKING CYCLE SIMULATOR')
disp(' ')
fprintf('process 1-2 : Isentropic expansion in the turbine \n')
fprintf('process 2-3 : Transfer of heat in the at condencerat constant pressure \n')
fprintf('process 3-4 : isentropic pumping processin the feed pump \n')
fprintf('process 4-1 : Transfer of heat in the at boiler constant pressure \n')
%%Enter the inputs
disp(' ')
T1=input('Enter the Turbine inlet temperature (in °C)\n');
p1=input('Enter the Turbine inlet pressure (in bar)\n');
p2=input('Enter the Condenser inlet pressure (in bar)\n');
%%Define the properties at every State by taking data from XSteam file
%state 1
s1=XSteam('s_pT',p1,T1);% Entropy at state 1
h1=XSteam('h_pT',p1,T1);% Entalpy at state 1
%state 2
s2=s1; %isentropic expansion
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)
s2=sg2;
h2=hg2; %hf2+(x2*(hg2-hf2));
T2=XSteam('T_hs',h2,s2);
%state point 3
T3=T2;
p3=p2;
s3=XSteam('sL_T',T3);
h3=XSteam('hL_T',T3);
v3=XSteam('vL_p',p2);
%state point 4
p4=p1;
s4=s3;
Cp4=XSteam('Cp_ps',p4,s4);
Cv4=XSteam('Cv_ps',p4,s4);
gamma=Cp4/Cv4;
r=(gamma-1)/gamma;
T4=T3*(p4/p3)^r;
%Calculate the W_net,Qs,N_per,steam_rate
Wt=h1-h2; %Turbine Work
Wp=v3*(p1-p2)*100%pump work
h4=Wp+h3 % Net Work Unit in kj/kg
W_net=Wt-Wp
Qs=h1-h4%heat Suppied
N_per=(W_net/Qs)*100 %Efficiency
Steam_rate=3600/(Wt-Wp)%Steam rate per sec
%state point 5
T5=XSteam('Tsat_p',p1);
T6=T5;
s5=XSteam('sL_p',p1);
h5=XSteam('hL_p',T3);
%state point 6
s6=XSteam('sV_p',p1);
h6=XSteam('hV_p',T3);
%Display The Result into coomand Window
fprintf('\n.......................RESULT..............\n')
fprintf('At State point 1:\n')
fprintf ('P1 is : %4.2f Bar \n',p1)
fprintf ('T1 is :%4.2f Degree Clelcius \n',T1)
fprintf ('H1 is : %4.2f KJ/kg \n',h1)
fprintf ('s1 is : %4.2f KJ/Kgk \n',s1)
fprintf('\n')
fprintf('At State point 2:\n')
fprintf ('P2 is : %4.2f Bar \n',p2)
fprintf ('T2 is :%4.2f Degree Clelcius \n',T2)
fprintf ('H2 is : %4.2f KJ/kg \n',h2)
fprintf ('s2 is : %4.2f KJ/Kgk\n',s2)
fprintf('\n')
fprintf('At 00State point 3:\n')
fprintf ('P3 is : %4.2f Bar\n',p3)
fprintf ('T3 is :%4.2f Degree Clelcius\n',T3)
fprintf ('H3 is : %4.2f KJ/kg \n',h3)
fprintf ('s3 is : %4.2f KJ/Kgk \n',s3)
fprintf('\n')
fprintf('At State point 4:\n')
fprintf ('P4 is : %4.2f Bar\n',p4)
fprintf ('T4 is :%4.2f Degree Clelcius\n',T4)
fprintf ('H4 is : %4.2f KJ/kg \n',h4)
fprintf ('s4 is : %4.2f KJ/Kgk \n',s4)
fprintf('\n')
fprintf('wt is : %4.2f KJ/kg\n',Wt)
fprintf('Wnet is : %4.2f KJ/kg\n',W_net)
fprintf('Ntherm is : %4.2f percent\n',N_per)
fprintf('Steam_rate is: %4.2f Kg/kwh\n',Steam_rate)
% plot T-S Diagram
subplot(1,2,1)
T_rankine=linspace(T5,T1,5000);
for i=1:length(T_rankine)
s_rankine(i)=XSteam('s_pt',p1,T_rankine(i));
end
plot([s1 s2 s3 s4 s5 s6 s_rankine],[T1 T2 T3 T4 T5 T6 T_rankine],'linewidth',2,'color','r');
hold on
T_curve = linspace(1,400,500);
for i=1:length(T_curve)
s_l(i)= XSteam('sL_T',T_curve(i));
s_v(i)= XSteam('sv_T',T_curve(i));
h_1(i)= XSteam('hL_T',T_curve(i));
h_v(i)= XSteam('hV_T',T_curve(i));
end
plot(s_l,T_curve,'k','linewidth',1.5);
plot(s_v,T_curve,'k','linewidth',1.5);
text(s1,T1,'1','FontSize',15)
text(s2,T2,'2','FontSize',15)
text(s3,T3,'3','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','Top')
text(s4,T4,'4','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','bottom')
text(s5,T5,'5','FontSize',15)
text(s6,T6,'6','FontSize',15)
xlabel('Entropy in KJ/KgK');
ylabel('Temperature in Degree Celcius');
%plot H-S Digram
subplot(1,2,2)
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1],'linewidth',2,'color','r')
hold on
plot(s_v,h_v,'color','k','linewidth',1.5)
plot(s_l,h_1,'color','k','linewidth',1.5)
text(s1,h1,'1','FontSize',15)
text(s2,h2,'2','FontSize',15)
text(s3,h3,'3','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','Top')
text(s4,h4,'4','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','bottom')
xlabel('Entropy in KJ/KgK');
ylabel('Enthalpy in KJ/kg');
Step wise explanation of Main Code
- The Creation of the ranking cycle simulator start with the clear all close all clc basic command of the mat lab
- Using the input command to enter the given Value at different state in our case we use inlet pressure for turbine Temperature at inlet and pressure at condenser
- Using the XSteam function file we get the value of enthalpy and entropy at very point
- After getting all input we can calculate the turbine work work done by the pump total work done efficiency of the cycle using the above thermodynamic Formula
- Using the fprintf command display the all input and result on the command window
- After that using the plot and subplot command showing the graphical output of the command
- To obtain the smooth graph we use the linspace command between two points
- And use for loop to calculate the each point value of the function
- Using the text command to show the state point in plot
- And Xlabel and Ylabel to assign the name to the x and y axis
Result and output
Out of the Rankine cycle At Inputs:
Turbine Inlet temperature = 400° C
Turbine Inlet Pressure = 30 bars
Turbine Outlet Pressure = 0.05 bars


Graphical Represantaion of the cycle

Error:
error due to forget to close the for loop using end keywords

Refrances :
https://in.mathworks.com/matlabcentral/answers/12855-newlines-and-spaces-in-strings