Project 2 - Rankine cycle Simulator
AIM - Write a Matlab code to calculate the state points of the Rankine Cycle and Create a Rankine cycle and plot the corresponding T-s and h-s plots .
INTRODUCTION -
Vapor power plants generate electrical power by using fuels like coal, oil or natural gas. The schematic of a vapor power plant is shown on the left. The entire power plant can be broken down into four major subsystems.
- Subsystem A: Energy conversion from heat to work
- Subsystem B: Energy source and waste removal required to vaporize the water
- Subsystem C: Electric generator
- Subsystem D: Cooling water system
The thermodynamic cycle in subsystem A is called the Rankine cycle. Subsystem A consists of a boiler, turbine, condenser and a pump. Fuel, burned in the boiler, heats the water to generate superheated steam (subsystem B). This steam is used to run the turbine which powers the generator. Electrical energy is generated when the generator windings rotate in a strong magnetic field (subsystem C). After the steam leaves the turbine, it is cooled to its liquid state in the condenser by transferring heat to the cooling water system (subsystem D). The liquid is pressurized by the pump prior to going back to the boiler.
All four components associated with the ideal Rankine cycle are steady-flow devices, and thus all four processes that make up the Rankine cycle can be analyzed as steady-flow process. The kinetic and potential energy changes of water are small relative to the heat and work terms, are thus neglected. Energy analysis of the four components are given below.
Pump (process 1-2): Pump pressurized the liquid water from the condenser prior to going back to the boiler. Assuming no heat transfer with the surroundings, the energy balance in the pump is
wpump, in = h2 - h1
Boiler (process 2-3): Liquid water enters the boiler and is heated to superheated state in the boiler. The energy balance in the boiler is
qin = h3 - h2
Turbine (process 3-4): Steam from the boiler, which has an elevated temperature and pressure, expands through the turbine to produce work and then is discharged to the condenser with relatively low pressure. Neglecting heat transfer with the surroundings, the energy balance in the turbine is
wturbine, out = h3 - h4
Condenser (process 4-1): Steam from the turbine is condensed to liquid water in the condenser. The energy balance in the condenser is
qout = h4 - h1
For the whole cycle, the energy balance can be obtained by summarizing the four energy equations above. It yields,
(qin- qout) - (wturbine, out - wpump, in) = 0
The thermal efficiency of the Rankine cycle is determined from
ηth = wnet ,out/qin = 1 - qout/qin
where the net work output from the cycle is
wnet ,out = wturbine, out - wpump, in
The Rankine cycle is an ideal cycle if water passes through the four components without irreversibilities and pressure drops. The ideal Rankine cycle consists of the following four processes, as shown on the T-s diagram on the left:
- 1-2: Isentropic compression in a pump
- 2-3: Constant pressure heat addition in a boiler
- 3-4: Isentropic expansion in a turbine
- 4-1: Constant pressure heat rejection in a condenser


MATLAB CODE -
clear all
close all
clc
% At state Point 1
p1 = 30;
t1 = 400;
p2 = 0.05;
h1 = XSteam ('h_pt',p1,t1)
s1 = XSteam ('s_pt',p1,t1)
% At state point 2
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))
wt = h1-h2
% At state point 3
p3 = p2;
h3 = XSteam ('hL_p',p3)
s3 = XSteam ('sL_p',p3)
% At state point 4
p4 = p1;
s4 = s3;
vf3 = XSteam('vL_p',p3)
wp = vf3*(p4-p3)*100
h4 = h3+wp
wnet = wt-wp
ssc = 3600/wnet
% Back work ratio and net work ratio
bwr = wp/wt
nwr = (wt-wp)/wt
% calculation for temperature
t3 = XSteam('Tsat_p',p3)
t2 = t3
cp4 = XSteam('cp_ps', p4,s4);
cv4 = XSteam('cv_ps', p4,s4);
g4 = cp4/cv4;
o = (g4-1)/g4;
t4 = t3*((p4/p3)^o)
% calculation for N Therm
qin = h1-h4
qout = h2-h3
ntherm = (wnet/qin)*100
% calculation for remaining temperature
h5 = XSteam('hL_p',p4)
h6 = XSteam('hv_p',p4)
s5 = XSteam('sL_p',p4)
s6 = XSteam('sv_p',p4)
t5 = XSteam('Tsat_p',p4)
t6 = t5
% displaying the results in command window
fprintf('\n At state point 1 :\n')
fprintf('p1 : %f Bar \n',p1)
fprintf('t1 : %f Deg celcius \n',t1)
fprintf ('h1 : %f kj/kg \n', h1)
fprintf ('s1 : %f kj/kg \n', s1)
fprintf('\n At state point 2 :\n')
fprintf('p2 : %f Bar \n',p2)
fprintf('t2 : %f Deg celcius \n',t2)
fprintf ('h2 : %f kj/kg \n', h2)
fprintf ('s2 : %f kj/kg \n', s2)
fprintf('\n At state point 3 :\n')
fprintf('p3 : %f Bar \n',p3)
fprintf('t3 : %f Deg celcius \n',t3)
fprintf ('h3 : %f kj/kg \n', h3)
fprintf ('s3 : %f kj/kg \n', s3)
fprintf('\n At state point 4 :\n')
fprintf('p4 : %f Bar \n',p4)
fprintf('t4 : %f Deg celcius \n',t4)
fprintf ('h4 : %f kj/kg \n', h4)
fprintf ('s4 : %f kj/kg \n', s4)
fprintf('\n At state point 5 :\n')
fprintf('t5 : %f Deg celcius \n',t5)
fprintf ('h5 : %f kj/kg \n', h5)
fprintf ('s5 : %f kj/kg \n', s5)
fprintf('\n At state point 6 :\n')
fprintf('t6 : %f Deg celcius \n',t6)
fprintf ('h6 : %f kj/kg \n', h6)
fprintf ('s6 : %f kj/kg \n', s6)
fprintf('\n main values :\n')
fprintf('wt : %f kj/kg \n',wt)
fprintf('wp : %f kj/kg \n',wp)
fprintf('wnet : %f kj/kg \n',wnet)
fprintf('ntherm : %f percent \n',ntherm)
% plotting result
T = linspace (0,400,400);
for i = 1:length(T)
S1(i) = XSteam('sV_T',T(i));
S2(i) = XSteam('sL_T',T(i));
H1(i) = XSteam('hV_T',T(i));
H2(i) = XSteam('hL_T',T(i));
end
figure(1)
hold on
plot ([s1,s2,s3,s4,s5,s6],[h1,h2,h3,h4,h5,h6], '*', 'color', 'r')
line ([s1,s2,s3,s4,s5,s6,s1],[h1,h2,h3,h4,h5,h6,h1],'color', 'g','linewidth',3)
plot([S1, S2],[H1, H2],'linewidth',2,'color','m')
xlabel('Entropy (kj/kg)')
ylabel('Enthalpy (kj/kg)')
title('H-S Diagram')
text(s1, h1,'1','fontsize',12);
text(s2, h2,'2','fontsize',12);
text(s3, h3,'3','fontsize',12);
text(s4, h4,'4','fontsize',12);
text(s5, h5,'5','fontsize',12);
text(s6, h6,'6','fontsize',12);
figure(2)
hold on
plot ([s1,s2,s3,s4,s5,s6],[t1,t2,t3,t4,t5,t6], '*', 'color', 'r')
line ([s1,s2,s3,s4,s5,s6,s1],[t1,t2,t3,t4,t5,t6,t1],'color', 'b','linewidth',3)
plot([S1, S2],[T, T],'linewidth',2,'color','m')
xlabel('Entropy (kj/kg)')
ylabel('Temperature (deg celcius)')
title('T-S Diagram')
text(s1, t1,'1','fontsize',12);
text(s2, t2,'2','fontsize',12);
text(s3, t3,'3','fontsize',12);
text(s4, t4,'4','fontsize',12);
text(s5, t5,'5','fontsize',12);
text(s6, t6,'6','fontsize',12);
MATLAB CODE EXPLAIN -
- Xsteam data is used to extract steam and water properties of enthaly , entropy at specific pressure and temperatures for sat liquid, sat vapour conditions etc .
- The program requires the input of Pressure ( in bar) at state point 1 on ( turbine inlet) , Temperature at same point (deg celcius) and Temp at condenser inlet (point 2).
- With the help of these inlets & from Xsteam data, the program calculates all the state points of the Rankine cycle .
- The xsteam data works as , h1 = XSteam('h_pT' , p1 , T1) ; ( Returns the enthalpy of water at given pressure and temperature in bar and degC resp .)
- As we extract the data , we use thermodynamic relation to further find state points and extract their data from XSteam .
- Sf and sg , hf and hg , where f and g stands for saturated liquid and saturated vapour respectively.
- The net work , work done by turbine , work done to run the pump , Heat in and heat out are calculated using standard thermodynamic relation
- Efficiency and Specific steam consumption (s.s.c) of the Rankine cycle is calculated .
- T , s and h are extracted at vapour and liquid line for plotting purpose , after 4th point for the variation you observe in the plot .
- Now, we need to display all these results in the command window which is done by using command 'fprintf()'.
- The next objective is to plot the graph for H-S and T-S. The first step in plotting this graph is to plot the saturation curve which is calculated using 'for' loop. Under 'for' loop, values for entropy and enthalpy are calculated over a temperature range. Plotting these calculated values, the plot of a saturation curve can is obtained. Other processes are plotted by plotting respective values of H, S, T.
- Saturation curve is plotted in red for saturated liquid and saturated gas .
- Plot of T vs s and h vs s is created from all the points obtained from the program .
- The plot changes as the user input changes for the above mentioned inputs .
- Results are displayed in the command window .
OUTPOT -
output display in command window

PLOT -

Temperature vs entropy diagram

Enthalpy vs entropy diagram
RESULT -
The performance of the Heat Engine was calculated and the following Observations were made:
- Net Work = 1117.85kJ/kg
- Thermal Efficiency = 36.17%
- Back Work Ratio = 0.0027