Project 2 - Rankine cycle Simulator
RANKINE CYCLE SIMULATOR
OBJECTIVE-
-to simulate the rankine cycle using the MATLAB.
-extracting steam and water properties from xsteam data(IAPWS IF-97).
-calculating all the state points of the cycle based on the user points.
-plotting the T vs S and H vs S plot for the given input .
RANKINE CYCLE-
Rankine cycle idealized thermodynamic cycle or heat engine in which a fuel is used to produce heat
with in a boiler,converting water into steam which then expands through a turbine producing cycle
useful works.this process was developed by scottish engineer william J.M rankine.it is a cycle which
converts heat into mechanical energy which usually is converted into electrical energy.
-in this project an idealized cycle is simulated.hence neglecting losses.

-rankine cycle is derived out of carnot cycle.Its power depends on the temperature difference between
the heat source and a cold source.the more the difference the more mechanical power can be efficiently
extracted out of heat energy.
-since ideal cycle are only in theory,efficiency of rankine cycle is limited by high heat of vaporization
of working fluid,friction losses,etc.
-water is usually the fluid of choice due to its favourable properties such as the non-toxic and and unreactive
chemistry,abundance and low cost, as well as its thermodynamic properties.By condensing the working steam
vapour to a liquid the pressure at the turbine outlet is lowered and the energy required by the feed pump
consumes only 1% to 3% of the turbine output power and these factors contribute to a higher efficiency for the
cycle.
PROCESS OF RANKINE CYCLE
there are four process in the rankine cycle
-process(1-2):isentropic expansion in the turbine.
-process(2-3):constant pressure heat rejection in condensor.
-process(3-4):isentropic compression in the pump.
-process(4-1):constant pressure heat addition in the boiler.

WORKING OF THE RANKINE CYCLE SIMULATOR.
(1)-In process (1-2), the dry saturated vapour through a turbine,generating power.
this decreases the temperature and pressure of the vapour, and some conden-
sation may occur.
(2)-process(2-3),the vapur liquid mixture leaving the turbine (2) is condensed at low
pressure, usually in a surface condenser using cooling water.in well designed and
maintained condensors,the pressure of the vapour is well below atmosphere pres-
sure,approaching the saturation pressure of the operating fluid at cooling water
temperature.
(3)-process(3-4),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 thermodynamics calculation.
(4)-process(4-1),high pressure liquids enters the boiler from the feed pump(4) and is
heated from the saturation temperature.further addition of energy causes evaporation
of the liquid until it is fully converted steam(1) or superheated(1).

Now, writing a code in MATLAB,
%RANKINE CYCLE SIMULATOR
%objective of this program is to simulatethe rankine cycle
%plotting t-s and h-s diagram using data from XSteam data
%water and steam properties according to IAWS IF-97
clear all
close all
clc
%input
p1=30;
p2=0.05;
t1=400;
%extracting data defining variables
%state 1
h1=XSteam('h_pt',p1,t1);
s1=XSteam('s_pt',p1,t1);
%state 2
s2=s1;
sf2=XSteam('sl_p',p2);
sg2=XSteam('sv_p',p2);
x2=(s2-sf2)/(sg2-sf2);
hf2=XSteam('hl_p',p2);
hg2=XSteam('hv_p',p2);
h2=hf2+(x2*(hg2-hf2));
%state 3
p3=p2;
s3=XSteam('sl_p',p3);
h3=XSteam('hl_p',p3);
%state 4
s4=s3;
p4=p1;
%work done by turbine
wt=h1-h2;
%work done to run pump
v3=XSteam('vl_p',p3);
wp=v3*(p4-p3)*100;
h4=h3+wp;
%net work
wnet=wt-wp;
%heat into the system
Qin=h1-h4;
%heat out of the system
Qout=h2-h3;
%thermal efficiency
eff=(wnet/Qin)*100;
%specific steam consumption
%SSC=mass flow rate/power
SSC=3600/wnet;
%calculating the temperature at the state points
t3=XSteam('Tsat_p',p3);
t2=t3;
cp4=XSteam('cp_ps',p4,s4);
cv4=XSteam('cv_ps',p4,s4);
k=cp4/cv4;
t4=t3/((p3/p4)^((k-1)/k));
%calculating temperature,entropy,and enthalpy at the vapour and liquid
%line for plotting
t6=XSteam('Tsat_p',p1);
s5=XSteam('sl_p',p1);
s6=XSteam('sv_p',p1);
h5=XSteam('hl_p',p1);
h6=XSteam('hv_p',p1);
t5=t6;
%plotting the saturation curve
T=linspace(1,375,1000);
for i= 1:length(T)
sf(i)=XSteam('sl_t',T(i));
sg(i)=XSteam('sv_t',T(i));
hf(i)=XSteam('hl_t',T(i));
hg(i)=XSteam('hv_t',T(i));
end
%plotting t-s diagram
figure(1)
hold on
plot(sf,T,'r','LineWidth',1)
plot(sg,T,'r','LineWidth',1)
plot([s1 s2],[t1 t2],'k','linewidth',2)
plot([s2 s3],[t2 t3],'k','linewidth',2)
plot([s3 s4],[t3 t4],'k','linewidth',2)
plot([s4 s5],[t4 t5],'k','linewidth',2)
plot([s5 s6],[t5 t6],'k','linewidth',2)
sc1=linspace(s6,s1,1000);
for l=1:length(sc1)
tc1(l)=XSteam('T_ps',p1,sc1(l));
end
plot(sc1,tc1,'k','linewidth',2)
text(s1+0.1,t1,'1')
text(s2+0.1,t2,'2')
text(s3,t3-20,'3')
text(s4,t4+20,'4')
title('temp vs entropy plot')
xlabel('ENTROPY,S (kj/kgk')
ylabel('TEMPERATURE (degree C')
legend('SATURATION CURVE')
hence the T-S diagram is created

now writing a code to plot h-s diagram
%plotting h-s diagram
figure(2)
hold on
plot(sf,hf,'r','linewidth',1)
plot(sg,hg,'r','linewidth',1)
plot([s1 s2],[h1 h2],'k','linewidth',2)
plot([s2 s3],[h2 h3],'k','linewidth',2)
plot([s3 s4],[h3 h4],'k','linewidth',2)
hc=linspace(h4,h5,100);
for k=1:length(hc)
sch(k)=XSteam('s_ph',p1,hc(k));
end
plot(sch,hc,'k','linewidth',2)
plot([s5 s6],[h5 h6],'k','linewidth',2)
for m=1:length(sc1)
hc1(m)=XSteam('h_ps',p1,sc1(m));
end
plot(sc1,hc1,'k','linewidth',2)
text(s1+0.1,h1,'1')
text(s2+0.1,h2,'2')
text(s3,h3-100,'3')
text(s4,h4+200,'4')
title('enthalpy vs entropy plot')
xlabel('entropy,s (KJ/KGK)')
ylabel('enthalpy,H (kg/kg)')
legend('saturation curve,''location','northwest')
hence, the plot is created of h-s diagram

steps taken to create a plot,
1-XSteam data is used to extract steam and water properties of enthalpy,entropy at specific pessure and
temperature for saturated liquid and saturated vapour conditions.
2-the program requires the input of pressure(in bar)at state point(turbine inlet).temperature at same point
(deg celcius)and temperature at condenser inlet point(2).
3-with the help of these inlets & from XSteam data,the program calculates all the state points of
rankine cycle.
4-the XSteam data work as;
h1=XSteam('h_pt',p1 t1);(returns the enthalpy of water at given pressure and temp in bar and deg C respectively.
5-as we extract the data,we use thermodynamic relation to further find state points and extract their data from XSteam.
6-sf and sg ,hf and hg, wher f and g stands for saturated liquid and saturated vaopour respectively.
7-the net work,the ,work done by turbine,work done to run the pump,heat in and out are calcu;ated using the thermodynamic relation.
8-efficiency and specific steam consumption(SSC) of the rankine cycle is calculated.
9-T,S and H are the extracted at vapour and liquid line for plotting purpose,after 4th point for the variation we observe
in the plot.
10-saturation curve is plotted in red for saturated gas.
11-plot of T vs S and H vs S is created from all the points obtained from the program.
12-the plot changes as the user input changes for the mentioned inputs.
13-results are displayed in the command window.