Challenge

Project 2 - Rankine cycle Simulator

REPORT

AIM
Create a Rankine Cycle Simulator using MATLAB.
calculate the state points of the Rankine Cycle based on user inputs. 
plot the corresponding T-s and h-s plots for the given set of inputs.
Required Inputs:
           Turbine Inlet temperature = 400° C
           Turbine Inlet Pressure = 30 bars
           Turbine Outlet Pressure = 0.05 bars = Condenser Inlet Pressure
         Calculate the followings,
Net work output
Back work ratio

Rankine Cycle
The Rankine cycle is an idealized thermodynamic cycle describing the process by which certain heat engines, such as steam turbines or reciprocating steam engines, allow mechanical work to be extracted from a fluid as it moves between a heat source and heat sink. The Rankine cycle is named after William John Macquorn Rankine, a Scottish polymath professor at Glasgow University.
Heat energy is supplied to the system via a boiler where the working fluid (typically water) is converted to a high pressure gaseous state (steam) in order to turn a turbine. After passing over the turbine the fluid is allowed to condense back into a liquid state as waste heat energy is rejected before being returned to boiler, completing the cycle

Process 1–2: The working fluid is pumped from low to high pressure. As the fluid is a liquid at this stage, the pump requires little input energy. Process 1-2 is isentropic compression.

Process 2–3: The high-pressure liquid enters a boiler, where it is heated at constant pressure by an external heat source to become a dry saturated vapour. Process 2-3 is constant pressure heat addition in boiler.

Process 3–4: The dry saturated vapour expands through a turbine, generating power. This decreases the temperature and pressure of the vapour, and some condensation may occur. Process 3-4 is isentropic expansion.

Process 4–1: The wet vapour then enters a condenser, where it is condensed at a constant pressure to become a saturated liquid. Process 4-1 is constant pressure heat rejection in condenser.

rankine.png

The properties such as pressure, temperature, entropy and enthalpy of each point is calculated to find the net work output the efficiency the back work ratio 

H is the enthalpy of respective points
 work done by turbine
             wt=h1-h2
2.    work done by pump
              wp=h4-h3
3.     heat addition
               qin=h1-h4
4.     heat rejection
                qout=h2-h3
5.     net work done
                wnet=wt-wp
6.    efficiency
                eff=(wnet/qin)*100
7.back work ratio
bw=wp/wt
8.specific steam consumption
   ssc=3600/wnet
XSteam
   Steam and water properties for Matlab based on the "International Association for Properties of Water and Steam Industrial Formulation 1997 . XSteam provides very accurate steam and water properties in ranges from 0-1000 bar and 0-2000°C. 
Provided thermodynamic properties are:
Temperature,Pressure,Enthalpy,Specific volume,Density,Specific entropy,
Specific internal energy, Specific isobaric heat capacity,
Specific isochoric heat capacity,Speed of sound,Viscosity, Vapour fraction.

All properties can be calculated with the inputs, p and T known, p and h known, h and s known and some with pressure and density known.

Program

For displaying the heading ‘Rankine Cycle and the process involved in it in the output window printf command is used
input( ) command is used to receive the input datas and stored in corresponding variables
    
       p1= Enter the pressure at turbine inlet(in bar)
       t1 = Enter the temperature at turbine inlet(in deg)
       p2 =enter the pressure at turbine outlet/condenser inlet(bar)
By using input parameters and the XSteam table the properties such as pressure, temperature, entropy and enthalpy of each point is calculated .
At point-1 

h1=XSteam(‘h_pt',p1,t1)       enthalpy using Xsteam
s1=XSteam(’s_pt’,p1,t1)        entropy using Xsteam
The enthalpy h, entropy s, temperature t, and pressure p for first point is calculated.

The enthalpy and entropy of saturated liquid and vapour values is calculated using XSteam function for further use
sf1 =XSteam(‘sL_p',p1)         entropy of saturated liquid using Xsteam
sg1 =XSteam(‘sV_p',p1)        entropy of saturated vapour using Xsteam
hf1 =XSteam(‘hL_p',p1)         enthalpy of saturated liquid using Xsteam
hg1 =XSteam(‘hV_p’,p1).       enthalpy of saturated vapour using Xsteam
 
Point-2
 
s2=s1  since the entropy is constant from process 1-2
sg2 =XSteam(‘sV_p’,p2).      entropy of saturated vapour using Xsteam
hg2 =XSteam(‘hV_p',p2)       enthalpy of saturated vapour using Xsteam
sf2 =XSteam(‘sL_p',p2)         entropy of saturated liquid using Xsteam
hf2 =XSteam(‘hL_p',p2)         enthalpy of saturated liquid using Xsteam
cp2v =XSteam(‘Cpv_p',p2)    specific heat using Xsteam
ts2=XSteam(‘Tsat_p’,p2).       temperature saturation using Xsteam

dryness fraction 
x=(s2-sf2)/(sg2-sf2)   

if dryness fraction is 1 the 2nd point is outside the saturated curve
temperature corresponding to point 2 using the equation
t2v=(ts2)*exp((s2-sg2)/cp2v)
Corresponding enthalpy
hv2 =XSteam('h_pT',p2,t2v) 
If dryness fraction is less than 1
The pemperature at point 2 is saturation temperature at point 2
t2=ts2
Enthalpy is calculated using the dryness fraction equation
h2 =hf2+x*(hg2-hf2)

Point-3

t3=t2;         temperature at point 3 equal to point2
s3=sf2;       entropy equal to entropy of saturated liquid
h3=hf2;      enthalpy  equal to enthalpy of saturated liquid at 2
p3=p2;       pressure equal to point 2

Point_4
   
   s4=s3;       entropy equal to entropy of point3 isentropic process
   p4=p1;      pressure equal to point 1
   h4=XSteam(‘h_ps’,p4,s4).        enthalpy at point 4 using Xsteam
   t4=XSteam(’T_ph',p4,h4)         temperature at point 4 using Xsteam

Point 5 and point 6 is calculated to complete plot of cycle 

Point-5
p5=p1;    pressure same
s5=sf1;   entropy equal to entropy of saturated liquid at point 1
h5=hf1;   enthalpy equal to enthalpy  of saturated liquid at point 1
t5=XSteam(‘Tsat_p’,p1).   temperature using Xsteam

Point-6
s6=sg1;  entropy equal to entropy of saturated vapour at point 1
h6=hg1;  enthalpy  equal to enthalpy of saturated vapour at point 1
t6=t5;    temperature
p6=p1;    pressure

saturation curve 
Linspace command is to get temperature.
t=linspace(0,400,400)
For loop is used to calculate corresponding entropy and enthalpy value for each degree of temperature 
for i=1:length(t)
    s_l(i)=XSteam('sL_T',t(i));     for entropy vs temperature at saturated liquid 
    s_v(i)=XSteam('sV_T',t(i));    for entropy vs temperature at saturated vapour
    h_l(i)=XSteam('hL_T',t(i));     for enthalpy vs temperature at saturated liquid 
    h_v(i)=XSteam('hV_T',t(i));   for enthalpy vs temperature at saturated vapour

Plotting the T-S diagram

Figure is created using figure command 
ploting the saturation curve of entropy 
Plot the first two points using the for loop because it differ according tot the value of dryness fraction
Plotting the rest ofgraph using the entropy and temperature value of each point
The diagram is labelled and title is created.

Plotting the H-S diagram

Figure (2) is created using figure command 
ploting the saturation curve of enthalpy and entropy

plot(s_l,h_l,'linewidth',1,'linestyle','--','color','r')
plot(s_v,h_v,'linewidth',1,'linestyle','--','color','r')
Plot the first two points using the for loop because it differ according tot the value of dryness fraction
Plotting the rest of graph using the entropy and enthalpy  value of each point
The diagram is labelled and title is created.

Printing the pressure enthalpy entropy and temperature value of each point 1, point 2 , point 3 , and point 4 .using fprintf( ““)  command.

The following output values are calculated using the enthalpy values of each points and displayed 
 work done by turbine
             wt=h1-h2
2.    work done by pump
              wp=h4-h3
3.     heat addition
               qin=h1-h4
4.     heat rejection
                qout=h2-h3
5.     net work done
                wnet=wt-wp
6.    efficiency
                eff=(wnet/qin)*100
7.    back work ratio
       bw=wp/wt
8.    specific steam consumption
        ssc=3600/wnet

RESULT
The pressure enthalpy entropy and temperature value of each point 1, point 2 , point 3 , and point 4 is calculated and printed
The T-S diagram and H-S diagram is plotted
The net work output and back work ratio os calculated and displayed.
command window

.....RANKINE CYCLE SIMULATOR ....
1-2 is isentropic expansion in turbine 
2-3 isconstant pressure heat rejection by condenser 
3-4 is isentropic compression in pump
4-1 is constant pressure heat addition by boiler 


Enter the pressure at turbine inlet(in bar)-30

Enter the temperature at turbine inlet(in deg)-400

enter the pressure at turbine outlet/condenser inlet(bar)-.05


...RESULTS...
point-1
 p1 is :30.000000 bar
 t1 is :400.000000 deg celcius
 s1 is :6.923259 KJ/Kgk
 h1 is :3231.571027 KJ/Kg
point-2
 p2 is :0.050000 bar
 t2 is :32.875490 deg celcius
 s2 is :6.923259 KJ/Kgk
 h2 is :2110.708212 KJ/Kg
point-3
 p3 is :0.050000 bar
 t3 is :32.875490 deg celcius
 s3 is :0.476254 KJ/Kgk
 h3 is :137.765119 KJ/Kg
point-4
 p4 is :30.000000 bar
 t4 is :32.960571 deg celcius
 s4 is :0.476254 KJ/Kgk
 h4 is :140.762226 KJ/Kg

..CALCULATION..
1....work done by turbine is 1120.862815 Kj/Kg
2....work done by pump is 2.997107 Kj/Kg
3....Net work done is 1117.865709 Kj/Kg
4....thermal efficiency is 36.167417 
5....back work ratio is 0.002674
6.... S.S.C is 3.220423 Kg/Kwh>> 
clear all
close all
clc

fprintf(".....RANKINE CYCLE SIMULATOR ....\n")
fprintf("1-2 is isentropic expansion in turbine \n")
fprintf("2-3 isconstant pressure heat rejection by condenser \n")
fprintf("3-4 is isentropic compression in pump\n")
fprintf("4-1 is constant pressure heat addition by boiler \n\n\n")


p1=input('Enter the pressure at turbine inlet(in bar)-');
t1=input('\nEnter the temperature at turbine inlet(in deg)-');
p2=input('\nenter the pressure at turbine outlet/condenser inlet(bar)-');

% point-1
h1=XSteam('h_pt',p1,t1);  %enthalpy using Xsteam
s1=XSteam('s_pt',p1,t1);  %entropy using Xsteam

sf1 =XSteam('sL_p',p1);   %entropy of saturated liquid using Xsteam
sg1 =XSteam('sV_p',p1);   %entropy of saturated vapour using Xsteam
hf1 =XSteam('hL_p',p1);   %enthalpy of saturated liquid using Xsteam
hg1 =XSteam('hV_p',p1);   %enthalpy of saturated vapour using Xsteam

% point-2
s2=s1;                     %entropy
sg2 =XSteam('sV_p',p2);    %entropy of saturated vapour using Xsteam
hg2 =XSteam('hV_p',p2);    %enthalpy of saturated vapour using Xsteam
sf2 =XSteam('sL_p',p2);    %entropy of saturated liquid using Xsteam
hf2 =XSteam('hL_p',p2);    %enthalpy of saturated liquid using Xsteam
cp2v =XSteam('Cpv_p',p2);  %specific heat using Xsteam
ts2=XSteam('Tsat_p',p2);   %temperature saturation using Xsteam


x=(s2-sf2)/(sg2-sf2);      %dryness fraction


%if dryness fraction equal to  1

t2v=(ts2)*exp((s2-sg2)/cp2v);   %temperature

hv2 =XSteam('h_pT',p2,t2v);     %enthalpy


%otherwise

t2=ts2;                 %temperature at point 2
h2 =hf2+x*(hg2-hf2);    %enthalpy at point 2

%point-3
t3=t2;         %temperature at point 3 equal to point2
s3=sf2;        %entropy equal to entropy of saturated liquid
h3=hf2;        %enthalpy  equal to enthalpy of saturated liquid at 2
p3=p2;         %pressure

%point_4
s4=s3;                    %%entropy equal to entropy of point3
p4=p1;                    %pressure
h4=XSteam('h_ps',p4,s4);  %enthalpy at point 4 using Xsteam
t4=XSteam('T_ph',p4,h4);   %temperature at point 4 using Xsteam
%point-5

p5=p1;    %pressure
s5=sf1;   %entropy equal to entropy of saturated liquid at point 1
h5=hf1;   %enthalpy
t5=XSteam('Tsat_p',p1);  %temperature using Xsteam

%point-6
s6=sg1;  %entropy equal to entropy of saturated liquid at point 1
h6=hg1;  %enthalpy  equal to enthalpy of saturated vapour at 1
t6=t5;   %temperature
p6=p1;   %pressure

%plotting T-S
figure(1)
hold on

%plotting saturation curve
t=linspace(0,400,400);
for i=1:length(t)
    s_l(i)=XSteam('sL_T',t(i));  %for entropy vs temperature at saturated liquid 
    s_v(i)=XSteam('sV_T',t(i));  %for entropy vs temperature at saturated vapour
    h_l(i)=XSteam('hL_T',t(i));  %for enthalpy vs temperature at saturated liquid 
    h_v(i)=XSteam('hV_T',t(i));  %for enthalpy vs temperature at saturated vapour
end 
%ploting the saturation curve of entropy
plot(s_l,t,'linewidth',1,'linestyle','--','color','r');
plot(s_v,t,'linewidth',1,'linestyle','--','color','r');

% drynes fraction greater the point is outside saturation curve
if x>=1
plot([s1 s2],[t1,t2v],'linewidth',2,'color','k');
%plotting the 2nd point at saturated vapour
plot([s2 sg2],[t2v t2],'linewidth',2,'color','k');
plot(s1,t1,'Marker','o','MarkerFaceColor','b');
text(s1,t1,'point-1');
text(sg2,t2v,'point-2');
else
    %point inside saturation curve
    plot([s1 s2],[t1 t2],'linewidth',2,'color','k');
    plot(s1,t1,'Marker','o','MarkerFaceColor','b');
    text(s1,t1,'-----point-1');
    plot(s2,t2,'Marker','o','MarkerFaceColor','b');
    text(s2,t2,'-----point-2');
end
%plotting the graph using the entropy and temperature values and 
% labelling the points

plot([s2 s3 s4 s5 s6 s1],[t2 t3 t4 t5 t6 t1],'linewidth',2,'color','k');
    plot(s3,t3,'Marker','o','MarkerFaceColor','b');
    text(s3,t3,'-----point-3');
    plot(s4,t4,'Marker','o','MarkerFaceColor','b');
    text(s4,t4,'-----point-4');

xlabel('entropy in KJ/KgK');
ylabel('temperature in (^0)');
title('T-S Diagram')

% opening another figure for h-s diagram
figure(2)
hold on
%ploting the saturation curve of entropy and enthalpy
plot(s_l,h_l,'linewidth',1,'linestyle','--','color','r');
plot(s_v,h_v,'linewidth',1,'linestyle','--','color','r');

% drynes fraction greater the point is outside saturation curve
if x>=1

plot([s1 s2],[h1,hv2],'linewidth',2,'color','k');
%plotting the 2nd point at saturated vapour
plot([s2 sg2],[hv2 h2],'linewidth',2,'color','k');

else
   %point 2nd point
    plot([s1 s2],[h1 h2],'linewidth',2,'color','k');
   
     plot(s1,h1,'Marker','o','MarkerFaceColor','b');
     text(s1,h1,'-----point-1');
     plot(s2,h2,'Marker','o','MarkerFaceColor','b');
     text(s2,h2,'-----point-2');
end
%plotting the graph using the entropy and enthalpy values and 
% labelling the points

plot([s2 s3 s4 s5 s6 s1],[h2 h3 h4 h5 h6 h1],'linewidth',2,'color','k');
    plot(s3,h3,'Marker','o','MarkerFaceColor','b');
    text(s3,h3,'-----point-3');
    plot(s4,h4,'Marker','o','MarkerFaceColor','b');
    text(s4,h4,'-----point-4');
 
xlabel('entropy in KJ/KgK');
ylabel('enthalpy in KJ/Kg');
title('H-S Diagram')

% displying the values calculated at each poits

fprintf("\n\n...RESULTS...")
% at point 1
fprintf("\npoint-1")
fprintf('\n p1 is :%1f bar',p1)
fprintf("\n t1 is :%1f deg celcius",t1)
fprintf("\n s1 is :%1f KJ/Kgk",s1)
fprintf("\n h1 is :%1f KJ/Kg",h1)
% at point 2
fprintf("\npoint-2")
fprintf('\n p2 is :%1f bar',p2)
fprintf("\n t2 is :%1f deg celcius",t2)
fprintf("\n s2 is :%1f KJ/Kgk",s2)
fprintf("\n h2 is :%1f KJ/Kg",h2)
% at point 3
fprintf("\npoint-3")
fprintf('\n p3 is :%1f bar',p3)
fprintf("\n t3 is :%1f deg celcius",t3)
fprintf("\n s3 is :%1f KJ/Kgk",s3)
fprintf("\n h3 is :%1f KJ/Kg",h3)
% at point 4
fprintf("\npoint-4")
fprintf('\n p4 is :%1f bar',p4)
fprintf("\n t4 is :%1f deg celcius",t4)
fprintf("\n s4 is :%1f KJ/Kgk",s4)
fprintf("\n h4 is :%1f KJ/Kg",h4)

% calculation 

fprintf("\n\n..CALCULATION..")
% work done by turbine
wt=h1-h2;
fprintf('\n1....work done by turbine is %1f Kj/Kg',wt)

%work done by pump
wp=h4-h3;
fprintf('\n2....work done by pump is %1f Kj/Kg',wp)

%heat addition
qin=h1-h4;
%heat rejection
qout=h2-h3;

%net work done
wnet=wt-wp;
fprintf('\n3....Net work done is %1f Kj/Kg',wnet)

%efficiency
eff=(wnet/qin)*100;
fprintf('\n4....thermal efficiency is %1f %',eff)

%back work ratio
bw=wp/wt;
fprintf('\n5....back work ratio is %1f',bw)

%specific steam consumption
ssc=3600/wnet;
fprintf('\n6.... S.S.C is %1f Kg/Kwh',ssc)

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.