Challenge

Rankine Cycle Simulator using MATLAB

Rankine Cycle Simulator

Rankine Cycle

The Rankine cycle is a model used to predict the performance of steam turbine systems. It was also used to study the performance of reciprocating steam engines. The Rankine cycle is an idealized thermodynamic cycle of a heat engine that converts heat into mechanical work while undergoing a phase change. It is an idealized cycle in which friction losses in each of the four components are neglected. The heat is supplied externally to a closed loop, which usually uses water as the working fluid.

In an ideal Rankine cycle, the system executing the cycle undergoes a series of four processes: two isentropic (reversible adiabatic) processes alternated with two isobaric processes:-

1. Isentropic compression (compression in centrifugal pumps)

The liquid condensate is compressed adiabatically from state 1 to state 2 by centrifugal pumps (usually by condensate pumps and then by feedwater pumps). The liquid condensate is pumped from the condenser into the higher pressure boiler. In this process, the surroundings do work on the fluid, increasing its enthalpy (h = u+pv) and compressing it (increasing its pressure). On the other hand, the entropy remains unchanged.

The work required for the compressor is given by WPumps = H2 – H1.

2. Isobaric heat addition (boiler)

In this phase (between state 2 and state 3) there is a constant-pressure heat transfer to the liquid condensate from an external source since the chamber is open to flow in and out. The feedwater (secondary circuit) is heated from the boiling point (2 → 3a) of that fluid and then evaporated in the boiler (3a → 3).

The net heat added is given by Qadd = H3 – H2

3. Isentropic expansion (expansion in a steam turbine)

Steam from the boiler expands adiabatically from state 3 to state 4 in a steam turbine to produce work and then is discharged to the condenser (partially condensed). The steam does work on the surroundings (blades of the turbine) and loses an amount of enthalpy equal to the work that leaves the system.

The work done by turbine is given by WT = H4 – H3. Again the entropy remains unchanged.

4. Isobaric heat rejection (in a heat exchanger)

In this phase, the cycle completes by a constant-pressure process in which heat is rejected from the partially condensed steam. There is heat transfer from the vapor to cooling water flowing in a cooling circuit. The vapor condenses and the temperature of the cooling water increases.

The net heat rejected is given by Qre = H4 – H1

During a Rankine cycle, work is done on the fluid by the pumps between states 1 and 2 (isentropic compression). Work is done by the fluid in the turbine between stages 3 and 4 (isentropic expansion). The difference between the work done by the fluid and the work done on the fluid is the net work produced by the cycle.

Isentropic Process
An isentropic process is a thermodynamic process, in which the entropy of the fluid or gas remains constant. It means the isentropic process is a special case of an adiabatic process in which there is no transfer of heat or matter. It is a reversible adiabatic process. The assumption of no heat transfer is very important, since we can use the adiabatic approximation only in very rapid processes.

From Isentropic Process and the First Law of thermodynamics

For a closed system, we can write the first law of thermodynamics in terms of enthalpy:

dH = dQ + Vdp

or

dH = TdS + Vdp

Isentropic process (dQ = 0):

dH = Vdp → W = H2 – H1

Isobaric Process
An isobaric process is a thermodynamic process, in which the pressure of the system remains constant (p = const). The heat transfer into or out of the system does work but also changes the internal energy of the system.

Since there are changes in internal energy (dU) and changes in system volume (∆V), engineers often use the enthalpy of the system, which is defined as:

H = U + pV

From Isobaric Process and the First Law

The classical form of the first law of thermodynamics is the following equation

dU = dQ – dW

In this equation dW is equal to dW = pdV and is known as the boundary work. In an isobaric process and the ideal gas, part of heat added to the system will be used to do work and part of heat added will increase the internal energy (increase the temperature). Therefore it is convenient to use the enthalpy instead of the internal energy.

Isobaric process (Vdp = 0)

dH = dQ → Q = H2– H1

At constant entropy, i.e. in isentropic process, the enthalpy change equals the flow process work done on or by the system.

Explanation for the Code

First, we note the given inputs to solve the problem, based on the inputs we find the state points variables using the Xsteam file.

Point 1 refers to the turbine inlet.

Point to is the outlet of the turbine and the process 1-2 is isentropic expansion thus the value of entropy remains the same. The steams expand into the turbine and phase changes from superheated dry saturated (if superheated) to a mixture of water and steam. Thus we find the dryness factor of the steam and using the dryness factor the enthalpy is found.

After expansion, the pressure decreases and the pressure at the turbine exit is the same throughout the heat rejection and using the Xsteam table we found the values of state variables at liquid saturation point.

Process 3-4 is isentropic compression where a pump is used to compress the liquid and the work done by the pump is calculated on the basis of the pressure difference and specific volume of the fluid.

Points 5 and 6 are the intersection points with the saturation curves at the liquid and vapor phase respectively. The points are found using the Xsteam table.

Plotting of Graph

First, the entropy diagram for the steam is plotted, and using hold on the state points with text to display their number and the curve is plotted as the respective values. The first plot is for Temperature vs Entropy.

Similarly, the enthalpy diagram for the steam is plotted, and using hold on the state points with text to display their number and the curve is plotted as the respective values. The second plot is for Temperature vs Entropy.

Plots

1. Temperature vs Entropy

2. Enthalpy vs Entropy

Complete Code for Rakine Cycle Simulator

clear all
close all
clc

%solving the equation of Rankine Cycle

%Data provided
t1=400;     %Turbine Inlet 

p1=30;      %Turbine Inlet Pressure 
p2=0.05;    %Turbine Outlet

%State points at Point 1
h1=XSteam('h_pT',p1,t1);
s1=XSteam('s_pT',p1,t1);

%state points at Point 2
%entropy at s1=s2 due to isentropic expansion
s2=s1;
%calculating the dryness factor
x=(s1-(XSteam('sL_p',p2)))/((XSteam('sV_p',p2)-(XSteam('sL_p',p2))));

%calculating the enthalpy at point 2
h2=x*(XSteam('hV_p',p2))+(1-x)*(XSteam('hL_p',p2));

t2=XSteam('Tsat_p',p2);


%calculating the the values for x cranging from 0 to x
x2_3=linspace(x,0,100);
for i=1:100
h2_h3(i)=x2_3(i)*(XSteam('hV_p',p2))+(1-x2_3(i))*(XSteam('hL_p',p2));
s2_s3(i)=x2_3(i)*(XSteam('sV_p',p2))+(1-x2_3(i))*(XSteam('sL_p',p2));
end

%state points at Point 3
%p3=p1 as constant pressure heat rejection
p3=p2;
t3=XSteam('Tsat_p',p3);
h3=XSteam('hL_p',p3);
s3=XSteam('sL_p',p3);

%state points at Point 4
p4=p1;
s4=s3;
pump_work=(p1-p2)*100*XSteam('vL_p',p2);
h4=h3+pump_work;
cp4=XSteam('Cp_ps',p4,s4);
cv4=XSteam('Cv_ps',p4,s4);
gama=cp4/cv4;
t4=t3*(p4/p3)^((gama-1)/gama);

%state points at point 5
p5=p4;
s5=XSteam('sL_p',p5);
h5=XSteam('hL_p',p5);
h_5=XSteam('h_ps',p5,s5);
t5=XSteam('T_ps',p5,s5);

%finding curve from 4 to 5
s4_s5=linspace(s4,s5,100);
t4_t5=linspace(t4,t5,100);

for i=1:100
h4_h5(i,:)=XSteam('h_ps',p5,s4_s5(i));
end

%State points at point 6
p6=p5;
t6=t5;
s6=XSteam('sV_p',p6);
h6=XSteam('hV_p',p6);

%finding curve for 6 to 1
s6_s1=linspace(s6,s1,100);
for i=1:100
t6_t1(i,:)=XSteam('T_ps',p5,s6_s1(i));
h6_h1(i,:)=XSteam('h_ps',p5,s6_s1(i));
end


%finding the performance parameters
pump_work=(p1-p2)*100*XSteam('vL_p',p2);
turbine_work=h1-h2;
work_net=turbine_work-pump_work;
efficiency=(work_net/(h1-h4))*100;

%finding the entropy diagram for steam
pressure= linspace(0.01,250,200);
for i=1:200
    entropy_liq(i,:)=XSteam('sL_p',pressure(i));
    entropy_vap(i,:)=XSteam('sV_p',pressure(i));
    temperature_sat(i,:)=XSteam('Tsat_p',pressure(i));
    enthalpy_vap(i,:)=XSteam('hV_p',pressure(i));
    enthalpy_liq(i,:)=XSteam('hL_p',pressure(i));
end



figure(1)
plot(entropy_liq,temperature_sat,'--','color','r')
axis([0 10 0 500]);
hold on
title('Temperature vs Entropy');
xlabel('Entropy');
ylabel('Temperature');
plot(fliplr(entropy_vap),temperature_sat,'--','color','r')

%Displaying the points
plot([s1 s2 s3 s4 s5 s6],[t1 t2 t3 t4 t5 t6],'*','markersize',2,'color','b');

%Plotting the curves
plot([s1 s2],[t1 t2],'color','g')
plot([s4 s3],[t4 t3],'color','g')
plot([s2 s3],[t2 t3],'color','g')
plot([s5 s6],[t5 t6],'color','g')
plot(s4_s5,t4_t5,'color','g')
plot(s6_s1,t6_t1,'color','g')

%Displaying the number for the points on the curve
text(s3,t3,'3','color', 'r','fontsize',6);
text(s2,t2,'2','color', 'r','fontsize',6);
text(s4,t4,'4','color', 'r','fontsize',6);
text(s6,t6,'6','color', 'r','fontsize',6);
text(s5,t5,'5','color', 'r','fontsize',6);
text(s1,t1,'1','color', 'r','fontsize',6);

figure(2)

%Ploting Enthalpy Diagram for Steam
plot(entropy_liq,enthalpy_liq,'--','color','r');
axis([0 10 0 3500]);
title('Enthalpy vs Entropy');
xlabel('Entropy');
ylabel('Enthalpy');
hold on
plot(fliplr(entropy_vap),(enthalpy_vap),'--','color','r');

%Displaying the points
plot([s1 s2 s3 s4 s5 56],[h1 h2 h3 h4 h5 h6],'*','markersize',1,'color','g')

%Plotting the curves
plot([s1 s2],[h1 h2],'color','g')
plot([s2_s3],[h2_h3],'color','g')
plot([s6_s1],[h6_h1],'color','g')
plot([s4_s5],[h4_h5],'color','g')
plot([s5 s6],[h5 h6],'color','g')
plot([s3 s4],[h3 h4],'color','g')

%Displaying the number for the points on the curve
text(s1,h1,'1','color', 'b','fontsize',8);
text(s2,h2,'2','color', 'b','fontsize',8);
text(s3,h3,'3','color', 'b','fontsize',8);
text(s4,h4,'4','color', 'b','fontsize',8);
text(s5,h5,'5','color', 'b','fontsize',8);
text(s6,h6,'6','color', 'b','fontsize',8);

Errors Occured

1. Length of the array should be same to plot

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.