Challenge

Project 2 - Rankine cycle Simulator

Aim:

Creation of a Rankine cycle simulator from a given input and reading the data from a standard thermodynamic library of steam table.

Objective:

  1. To create a Rankine Cycle simulator in MATLAB.
  2. To calculate the state point using function 'XSteam'.
  3. To plot the T-S and H-S curve for a given input in Rankine Cycle.
  4. To get output in the command window for each state point in the cycle.

Rankine Cycle:

The Rankine cycle is a process, used in power plants to produce mechanical energy from heat. It usually uses water as a working fluid. In this cycle, fuel is used externally to convert water into steam which expands through the turbine and produces work. The heat energy of the fuel is converted into mechanical work or power in steam turbine power plants.

The main four components of the cycle are:

(1) Boiler

(2) Turbine

(3) Condensor

(4) Feed Pump

Basic Rankine Cycle: 

                                                                     

Processes:

As the Rankine Cycle is a cyclic process, we generally can start it from any of the components we like. But As we are asked to start from the isentropic expansion in the turbine, we are going to start accordingly. 

1 - 2: Isentropic Expansion in the turbine:

High pressure and high temperature superheated, dry saturated, or wet steam generated in the boiler at P1 and T1 is supplied to the steam turbine.

The steam expands isentropically into the steam turbine up to the condenser pressure. Steam turbine develops mechanical work, Wt due to the expansion of steam. 

Turbine Work, `W_t = h_1 - h_2`

2 - 3: Constant Pressure heat rejection by the condenser

The exhaust steam from the turbine enters the condenser, where it is condensed at constant pressure by circulating cooling water in the tubes. The heat rejected by exhaust steam is Qr. 

Heat Rejected, `Q_r = h_2 - h_3`

3 - 4: Isentropic Compression in the pump (Pumping Process)

The condensed water coming from the condenser is pumped to the boiler at boiler pressure with the help of the feed pump. 

To do so, work, Wr is supplied to the feed pump.

4 - 1: Constant Pressure Heat Addition in the boiler

The water is heated at constant pressure P1 in the boiler until the saturation temperature is reached. Saturated water is converted into saturated steam at constant pressure. During the process 2'-2, steam is superheated in the superheater.

Heat Supplied, `Q_s = h_4 - h_1` 

Difference between ideal and actual Rankine Cycle:

In an ideal Rankine cycle, the pump and turbine would be isentropic, they would maximize the net work output by generating no entropy, and also, we are assuming that water-to-steam and steam-to-water conversion is taking place at constant pressure.

The actual Rankine cycle differs from the ideal Rankine cycle because fluid friction causes irreversibility and heat loss to surround causes loss of work output. pressure drops in the boiler and condenser it causes, steam to leave the boiler at a lower pressure.

The Rankine cycle can be modified with reheat and regenerative processes. The reheating cycle removes moisture carried by steam at the final stage of the expansion process. It increases the thermal efficiency of the cycle. In the Regenerative cycle, heat is exchanged between the working fluid and compressed fluid before heat addition. The regenerative cycle reduces heat supplied to the boiler and increases thermal efficiency.

Formulas related to the Rankine cycle –

Heat addition, `Q_a = h_1 - h_4`

Heat rejection, `Q_r =h_2 - h_3`

Work done by the turbine, `W_t = h_1 - h_2`

Work took by pump, `W_p = h_4 - h_3`

Thermal Efficiency = `(W_t - W_p)/Q_a` 

Net work output, `W_n = W_t -W_p`

back work ratio(BWR)  = `W_p/W_t`

specific steam consumption(SSC) = `3600/W_n`

`h_1` = enthalpy at turbine inlet

`h_2` = enthalpy at turbine outlet

`h_3` = enthalpy at pump inlet

`h_4` = enthalpy at pump outlet

`W_t` = work done by the turbine

`W_p`= work taken by pump

 `(p_i, t_i, h_i, s_i)`  = Pressure, temperature, enthalpy, entropy at `i-th` state respectively.

Code:

Now let us start with the explanation and formation of the code for our required Rankine Cycle. 

%We start by clearing and resetting everything
close all
clc

% Rankine Cycle Simulator
% We initiate our project by displaying the essentials

fprintf('ttt RANKINE CYCLE SIMULATOR nn');
fprintf('1-2 is Isentropic Expansion in the Turbinen');
fprintf('2-3 is Const Pressure Heat Rejection by the Condensern');
fprintf('3-4 is Isentropic Compression in the Pumpn');
fprintf('4-1 is Const Pressure Heat Addition by the Boilernn');

% Entering the input data for the calculation of the state points
p1 = input('Enter the Pressure at the Turbine Inlet (in bar): ');                 % Taking input for the Pressure at Turbine Inlet
T1 = input('nEnter the Temperature at the Turbine Inlet (in Degree Celsios): '); %Temperature a Turbine Inlet
p2 = input('nEnter the Pressure at the Condensor (in bar): ');                   %Pressure at the condensor

%From the XSteam file we input the data for the state point 1
h1 = XSteam('h_pT', p1, T1);        %Enthalpy at pressure and Temp 1
s1 = XSteam('s_pT', p1, T1);        %Entropy at pressure and Temp 1

%From the XSteam file we input the data for the state point 2
s2 = s1;                            �cause of Isentropic Expansion
sf2 = XSteam('sL_p', p2);           % Saturated liquid entropy at pressure 2
sg2 = XSteam('sV_p', p2);           % Saturated vapour entropy at pressure 2
x2 = (s2-sf2)/(sg2-sf2);            % Vapour Fraction at state point 2
hf2 = XSteam('hL_p', p2);           % Saturated liquid Enthalpy at pressure 2
hg2 = XSteam('hV_p', p2);           % Saturated vapour Enthalpy at pressure 2
h2 = hf2 + (x2*(hg2-hf2));          % Enthalpy at state point 2

%From the XSteam file we input the data for the state point 3
p3 = p2;                            % Constant Pressure(Isobaric) heat removal process
s3 = XSteam('sL_p', p3);            % Saturated liquid entropy at Pressure 3
h3 = XSteam('hL_p', p3);            % Saturated liquid Enthalpy at Pressure 3

%From the XSteam file we input the data for the state point 4
s4 = s3;                            % Isentropic Compression process
p4 = p1;                            % Constant Pressure heat rejection

% Work done in Turbine for the rankine cycle
W_T = h1-h2;

% Work done required for pump
v3 = XSteam('vL_p',p3);             % Saturated Liquid Vapour at pressure 3
W_P = v3*(p4-p3)*100;               % Work done for pump
h4 = h3 - W_P;                      % Enthalpy at State point 4

% Net work done for Rankine Cycle
W_net = W_T - W_P;

% Heat Supplied to the System
Q_in = h1-h4;

% Heat Rejected from the System
Q_out = h2-h3;

% Thermal Efficiency of Rankine Cycle
T_eff = (W_net/Q_in)*100;

%specific steam consumption  = (Mass flow rate / Net work done)
Sp_S = (3600/W_net);

�lculation of Temperature at All state Point 2, 3 and 4
T3 = XSteam('Tsat_p',p3);           % Saturation Temperature at Pressure 3
T2 = T3;                            �cuase of Constant Pressure Heat addition
Cp4 = XSteam('Cp_ps',p4,s4);        % Specific isobaric heat capacity
Cv4 = XSteam('Cv_ps',p4,s4);        % Specific isochoric heat capacity
k = Cp4/Cv4;
T4 = T3/((p3/p4)^((k-1)/k));        % Temperature at State point 4

�lculation of Other constant for saturated liquid and Vapour
T6 = XSteam('Tsat_p', p1);          % Saturated Temperature at Pressure 1
s5 = XSteam('sL_p', p1);            % Saturated Liquid entropy at pressure 1
s6 = XSteam('sV_p', p1);            % Saturated Vapour entropy at Pressure 1
h5 = XSteam('hL_p', p1);            % Saturated Liquid Enthalpy at Pressure 1
h6 = XSteam('hV_p', p1);            % Saturated Vapour Enthalpy at pressure 1
T5 = T6;

%Plotting for Saturation Line
T = linspace(1,560,1000);
for i = 1:length(T)
    sf(i) = XSteam('sL_T' ,T(i));   % Saturated Liquid Entropy
    sg(i) = XSteam('sV_T' ,T(i));   % Saturated Vapour Entropy
    hf(i) = XSteam('hL_T' ,T(i));   % Saturated Liquid Enthalpy
    hg(i) = XSteam('hV_T' ,T(i));   % Saturated Vapour Enthalpy
    
end

% Plotting T-S Diagram for Rankine Cycle
figure(1)
hold on
plot(sf,T,'color','b','linewidth',2)
plot(sg,T,'color','b','linewidth',2)
plot([s1 s2],[T1 T2], 'color', 'r', 'linewidth',3)
plot([s2 s3],[T2 T3], 'color', 'r', 'linewidth',3)
plot([s3 s4],[T3 T4], 'color', 'r', 'linewidth',3)
plot([s4 s5],[T4 T5], 'color', 'r', 'linewidth',3)
plot([s5 s6],[T5 T6], 'color', 'r', 'linewidth',3)
s_1 = linspace(s6,s1,1000);
for j = 1:length(s_1)
    Tc(j) = XSteam('T_ps',p1,s_1(j));
end
plot(s_1,Tc,'color','r','linewidth',3)
text(s1+0.1, T1, '1')
text(s2+0.1, T2, '2')
text(s3, T3-20, '3')
text(s4, T4+20, '4')
title('Temperature Vs Entropy (t-s Diagram)')
xlabel('Entropy (Kj/kg-k)')
ylabel('Temeperature (Deg. Celcius)')
legend('Saturation Curve')

% Plotting H-S Diagram for Rankine Cycle
figure(2)
hold on
plot(sf,hf,'color','b','linewidth',2)
plot(sg,hg,'color','b','linewidth',2)
plot([s1 s2],[h1 h2],'color','r','linewidth',3)
plot([s2 s3],[h2 h3],'color','r','linewidth',3)
plot([s3 s4],[h3 h4],'color','r','linewidth',3)
hc = linspace(h4,h5,100);
for k = 1:length(hc)
    s_c(k) = XSteam('s_ph',p1,hc(k));
end
plot(s_c,hc,'color','r','linewidth',3)
plot([s5 s6],[h5 h6],'color','r','linewidth',3)
for l = 1:length(s_1)
    h_c(l) = XSteam('h_ps',p1,s_1(l));
end
plot(s_1,h_c,'color','r','linewidth',3)
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 (h-s diagram)')
xlabel('Entropy (Kj/kg-k)')
ylabel('Enthalpy (KJ/Kg)')
legend('Saturation Curve')

% Displaying Results in Command window
disp('Results of Rankine Cycle')
fprintf('At state point 1ttttt')
fprintf('At state Point 2n')
fprintf('P1 = f in Bartttt',p1);
fprintf('P2 = f in Barn',p2);
fprintf('T1 = f in Deg.Celciustt',T1);
fprintf('T2 = f in Deg.Celciusn',T2);
fprintf('H1 = f in KJ/Kgttt',h1);
fprintf('H2 = f in KJ/Kgn',h2);
fprintf('S1 = � in KJ/Kg-kttt',s1);
fprintf('S2 = � in KJ/Kg-kn',s2);
fprintf('n')
fprintf('At state point 3ttttt')
fprintf('At state Point 4n')
fprintf('P3 = f in Bartttt',p3);
fprintf('P4 = f in Barn',p4);
fprintf('T3 = f in Deg.Celciustt',T3);
fprintf('T4 = f in Deg.Celciusn',T4);
fprintf('H3 = f in KJ/Kgttt',h3);
fprintf('H4 = f in KJ/Kgn',h4);
fprintf('S3 = � in KJ/Kg-kttt',s3);
fprintf('S4 = � in KJ/Kg-kn',s4);
fprintf('n')
fprintf('Turbine Work Done = f in KJ/Kgn',W_T)
fprintf('Pump Work Done = f in KJ/Kgn',W_P)
fprintf('Net Work Done  = f in KJ/Kgn',W_net)
fprintf('Thermal Efficiency = f in percentn',T_eff)
fprintf('Sp. Steam Consumption = %f in KJ/Kwn',Sp_S)



Output:

Explanation of the code:

Collecting Data for the State Points:

%We start by clearing and resetting everything
close all
clc

We start our code by clearing and resetting everything. 

% Rankine Cycle Simulator
% We initiate our project by displaying the essentials

fprintf('ttt RANKINE CYCLE SIMULATOR nn');
fprintf('1-2 is Isentropic Expansion in the Turbinen');
fprintf('2-3 is Const Pressure Heat Rejection by the Condensern');
fprintf('3-4 is Isentropic Compression in the Pumpn');
fprintf('4-1 is Const Pressure Heat Addition by the Boilernn');

We then print and display the necessary information about the Rankine Cycle in the console which is required for better understanding. As we have said that the Rankine Cycle is a cyclic process and we can start it from any of the state points, it is necessary for us to declare from where we are starting. We used the 'strong' command to bold the necessary texts which require more attention.

% Entering the input data for the calculation of the state points
p1 = input('Enter the Pressure at the Turbine Inlet (in bar): ');                 % Taking input for the Pressure at Turbine Inlet
T1 = input('nEnter the Temperature at the Turbine Inlet (in Degree Celsius): '); %Temperature a Turbine Inlet
p2 = input('nEnter the Pressure at the Condensor (in bar): ');                   %Pressure at the condenser

We then take our necessary inputs from the user as given in the question. As we are starting from the turbine. So, we will need the turbine inlet pressure and temperature. From the turbine, we go to the Condensor. So, we also take the condenser pressure data.

%From the XSteam file we input the data for the state point 1
h1 = XSteam('h_pT', p1, T1);        %Enthalpy at pressure and Temp 1
s1 = XSteam('s_pT', p1, T1);        %Entropy at pressure and Temp 1

Next, we used our 'XSteam' Matlab file in the project description to find the enthalpy and entropy at the turbine inlet. We use 'h_pT' and 's_pT' which require the pressure and the temperature to find the enthalpy and the entropy. Process 1- 2 is isentropic Expansion in the turbine. So the changes we observe will only be in pressure and temperature. No changes will be there in the entropy.

%From the XSteam file we input the data for the state point 2
s2 = s1;                            �cause of Isentropic Expansion
sf2 = XSteam('sL_p', p2);           % Saturated liquid entropy at pressure 2
sg2 = XSteam('sV_p', p2);           % Saturated vapour entropy at pressure 2
x2 = (s2-sf2)/(sg2-sf2);            % Vapour Fraction at state point 2
hf2 = XSteam('hL_p', p2);           % Saturated liquid Enthalpy at pressure 2
hg2 = XSteam('hV_p', p2);           % Saturated vapour Enthalpy at pressure 2
h2 = hf2 + (x2*(hg2-hf2));          % Enthalpy at state point 2

Now for state point 2, the entropy would be similar to that of state 1. Because the first process was isentropic. Now, we need the saturated liquid and vapor entropy, from which we can find the vapor fraction by using the formula,

 `x_2 = (s_2 - s.f_2)/(sg_2 - s.f_2)`

The saturated liquid and vapor enthalpy can be figured out from the XSteam file provided to us.

%From the XSteam file we input the data for the state point 3
p3 = p2;                            % Constant Pressure(Isobaric) heat removal process
s3 = XSteam('sL_p', p3);            % Saturated liquid entropy at Pressure 3
h3 = XSteam('hL_p', p3);            % Saturated liquid Enthalpy at Pressure 3

%From the XSteam file we input the data for the state point 4
s4 = s3;                            % Isentropic Compression process
p4 = p1;                            % Constant Pressure heat rejection

We continue doing the same thing for state 3 and state 4.

% Work done in Turbine for the rankine cycle
W_T = h1-h2;

% Work done required for pump
v3 = XSteam('vL_p',p3);             % Saturated Liquid Vapour at pressure 3
W_P = v3*(p4-p3)*100;               % Work done for pump
h4 = h3 - W_P;                      % Enthalpy at State point 4

% Net work done for Rankine Cycle
W_net = W_T - W_P;

% Heat Supplied to the System
Q_in = h1-h4;

% Heat Rejected from the System
Q_out = h2-h3;

% Thermal Efficiency of Rankine Cycle
T_eff = (W_net/Q_in)*100;

%specific steam consumption  = (Mass flow rate / Net work done)
Sp_S = (3600/W_net);

 From the understanding of the Rankine Cycle, we just use equations and figure out the

I. Work done in Turbine

II. Work required for the pump

III. Net Work Done to the system

IV. Heat supplied to the system

V. Thermal Efficiency of Rankine Cycle

VI. Specific Steam Consumption

�lculation of Temperature at All state Point 2, 3 and 4
T3 = XSteam('Tsat_p',p3);           % Saturation Temperature at Pressure 3
T2 = T3;                            �cuase of Constant Pressure Heat addition
Cp4 = XSteam('Cp_ps',p4,s4);        % Specific isobaric heat capacity
Cv4 = XSteam('Cv_ps',p4,s4);        % Specific isochoric heat capacity
k = Cp4/Cv4;
T4 = T3/((p3/p4)^((k-1)/k));        % Temperature at State point 4

We then calculate the temperature for each of the state points.

�lculation of Other constant for saturated liquid and Vapour
T6 = XSteam('Tsat_p', p1);          % Saturated Temperature at Pressure 1
s5 = XSteam('sL_p', p1);            % Saturated Liquid entropy at pressure 1
s6 = XSteam('sV_p', p1);            % Saturated Vapour entropy at Pressure 1
h5 = XSteam('hL_p', p1);            % Saturated Liquid Enthalpy at Pressure 1
h6 = XSteam('hV_p', p1);            % Saturated Vapour Enthalpy at pressure 1
T5 = T6;

For state 1, we calculate the saturated temperature, saturated liquid entropy, saturated vapor entropy, saturated liquid enthalpy, and saturated vapor enthalpy. All these are data we collect from the 'XSteam' file.

The explanation for the Plotting Section

%Collecting Data for Plotting the Saturation Line
T = linspace(1,560,1000);
for i = 1:length(T)
    sf(i) = XSteam('sL_T' ,T(i));   % Saturated Liquid Entropy
    sg(i) = XSteam('sV_T' ,T(i));   % Saturated Vapour Entropy
    hf(i) = XSteam('hL_T' ,T(i));   % Saturated Liquid Enthalpy
    hg(i) = XSteam('hV_T' ,T(i));   % Saturated Vapour Enthalpy
    
end

For the figure 1, we obtain the data for plotting the saturation line for different temperatures which we take by using 'linspace'.

% Plotting T-S Diagram for Rankine Cycle
figure(1)
hold on
plot(sf,T,'color','y','linewidth',2)
plot(sg,T,'color','y','linewidth',2)
plot([s1 s2],[T1 T2], 'color', 'r', 'linewidth',3)
plot([s2 s3],[T2 T3], 'color', 'r', 'linewidth',3)
plot([s3 s4],[T3 T4], 'color', 'r', 'linewidth',3)
plot([s4 s5],[T4 T5], 'color', 'r', 'linewidth',3)
plot([s5 s6],[T5 T6], 'color', 'r', 'linewidth',3)
s_1 = linspace(s6,s1,1000);
for j = 1:length(s_1)
    Tc(j) = XSteam('T_ps',p1,s_1(j));
end
plot(s_1,Tc,'color','r','linewidth',3)
text(s1+0.1, T1, '1')
text(s2+0.1, T2, '2')
text(s3, T3-20, '3')
text(s4, T4+20, '4')
title('Temperature Vs Entropy (t-s Diagram)')
xlabel('Entropy (Kj/kg-k)')
ylabel('Temeperature (Deg. Celcius)')
legend('Saturation Curve')

We plot the different saturated liquid and saturated vapor entropy for different temperatures that we got earlier. Then we plot the entropy and temperature for each of the state points.

We then take the temperature as a function of pressure and enthalpy and figure it out for different entropies.

We display the state points by using 'text' and also label in the x and y-axes the required informations.

We use a legend to distinguish the 'Saturation Curve'.

% Plotting H-S Diagram for Rankine Cycle
figure(2)
hold on
plot(sf,hf,'color','y','linewidth',2)
plot(sg,hg,'color','y','linewidth',2)
plot([s1 s2],[h1 h2],'color','r','linewidth',3)
plot([s2 s3],[h2 h3],'color','r','linewidth',3)
plot([s3 s4],[h3 h4],'color','r','linewidth',3)
hc = linspace(h4,h5,100);
for k = 1:length(hc)
    s_c(k) = XSteam('s_ph',p1,hc(k));
end
plot(s_c,hc,'color','r','linewidth',3)
plot([s5 s6],[h5 h6],'color','r','linewidth',3)
for l = 1:length(s_1)
    h_c(l) = XSteam('h_ps',p1,s_1(l));
end
plot(s_1,h_c,'color','r','linewidth',3)
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 (h-s diagram)')
xlabel('Entropy (Kj/kg-k)')
ylabel('Enthalpy (KJ/Kg)')
legend('Saturation Curve')

 We continue with the same procedure for the H-S diagram and plot it in the second figure.

Printing the Pressure, Temperature, Entropy and Enthalpy for each of the State Points to the console:

% Displaying Results in Command window
disp('Results of Rankine Cycle')
fprintf('At state point 1ttttt')
fprintf('At state Point 2n')
fprintf('P1 = f in Bartttt',p1);
fprintf('P2 = f in Barn',p2);
fprintf('T1 = f in Deg.Celciustt',T1);
fprintf('T2 = f in Deg.Celciusn',T2);
fprintf('H1 = f in KJ/Kgttt',h1);
fprintf('H2 = f in KJ/Kgn',h2);
fprintf('S1 = � in KJ/Kg-kttt',s1);
fprintf('S2 = � in KJ/Kg-kn',s2);
fprintf('n')
fprintf('At state point 3ttttt')
fprintf('At state Point 4n')
fprintf('P3 = f in Bartttt',p3);
fprintf('P4 = f in Barn',p4);
fprintf('T3 = f in Deg.Celciustt',T3);
fprintf('T4 = f in Deg.Celciusn',T4);
fprintf('H3 = f in KJ/Kgttt',h3);
fprintf('H4 = f in KJ/Kgn',h4);
fprintf('S3 = � in KJ/Kg-kttt',s3);
fprintf('S4 = � in KJ/Kg-kn',s4);
fprintf('n')

 We then simply print the datas for each of the state points as calculated before.

fprintf('Turbine Work Done = f in KJ/Kgn',W_T)
fprintf('Pump Work Done = f in KJ/Kgn',W_P)
fprintf('Net Work Done = f in KJ/Kgn',W_net)
fprintf('Thermal Efficiency = f in percentn',T_eff)
fprintf('Sp. Steam Consumption = %f in KJ/Kwn',Sp_S)

We also print the calculated value for theI. Turbine Work Done

II. Pump Work Done

III. Net Work Done

IV. Thermal Efficiency

V. Specific Steam Consumption

Output:

Console:

T-S and H-S Diagram:

Conclusion:

In this project, I learnt the process of simulating the Rankine Cycle Process from which I now can figure out any thermodynamic cycle simulation with ease.

This project was a great learning experience for me. I hope the time and effort I had to put behind this would be useful to me in future.

References:

1. https://skill-lync.com/student-projects/project-2-rankine-cycle-simulator-89

2. https://www.youtube.com/watch?v=SwCdae4Q_QE

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.