Challenge

MATLAB Project based on Rankine Cycle Simulator

AIM : To create a MATLAB Program that calculate the state points of the Rankine Cycle.

OBJECTIVES :

  • To create a Rankine Cycle Simulator using MATLAB.
  • To determine its state points including (i) Net work output & (ii) Back work ratio.
  • Plot its T-S and h-S diagram from the given data.
  • Explain its working.

THEORY :

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.

Layout of the Rankine cycle

  • Turbine
  • Condenser
  • Pump
  • Boiler

In the Rankine cycle, the following processes take place :

Process 1–2 :

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 1-2 is isentropic expansion in the turbine.

Process 2–3 :

The wet vapour then enters a condenser, where it is condensed at a constant pressure to become a saturated liquid. Process 2-3 is constant pressure heat rejection or isobaric heat rejection by the condenser.

Process 3–4 :

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 3-4 is isentropic compression in the pump.

Process 4–1 :

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 4-1 is constant pressure heat addition or isobaric heat transfer by the boiler.

Given Inputs :

Turbine Inlet Pressure = 30 bars

Turbine Inlet temperature = 400° C

Turbine Outlet Pressure or Condenser Inlet Pressure = 0.05 bars

PROGRAM :

% MATLAB Program to calculate the state points of the Rankine cycle simulator

clear all
close all
clc

% Step I : Process
fprintf('Rankine Cycle Simulator n n')
fprintf('Process 1-2 is Isentropic Expansion in the Turbine n')
fprintf('Process 2-3 is Isobaric Heat Rejection by the Condenser n')
fprintf('Process 3-4 is Isentropic Compression in the Pump n')
fprintf('Process 4-1 is Isobaric Heat Transfer by the Boiler n n')

% Step II : Input Variables
P1 = input('Enter the pressure at the Turbine inlet (in bar) : ');
T1 = input('Enter the temperature at the Turbine inlet (in Degree Celcius) : ');
P2 = input('Enter the pressure at the Condenser (in bar) : ');

t = linspace(0,400,500);
disp(' ')

% Step III : Calculate the State Points of the Rankine cycle

% At State Point 1
H1 = XSteam('h_pT',P1,T1);      % Enthalphy
S1 = XSteam('s_pT',P1,T1);      % Entrophy
hl1 = XSteam('hL_p',P1);        % Saturated liquid enthalpy
hg1 = XSteam('hV_p',P1);        % Saturated vapour enthalpy
sl1 = XSteam('sL_p',P1);        % Saturated liquid entrophy
sg1 = XSteam('sV_p',P1);        % Saturated vapour entrophy
Tsat1 = XSteam('Tsat_p',P1);    % Saturarted Temperature

% At State Point 2
S2 = S1;
sl2 = XSteam('sL_p',P2);
sg2 = XSteam('sV_p',P2);
d = (S2 - sl2)./(sg2 - sl2);    % dryness fraction
hl2 = XSteam('hL_p',P2);
hg2 = XSteam('hV_p',P2);
H2 = hl2 + (d.*(hg2 - hl2));
T2 = XSteam('T_ph', P2, H2);
Tsat2 = XSteam('Tsat_p',P2);


% At State Point 3
P3 = P2;
S3 = sl2;
H3 = hl2;
T3 = T2;

% At State Point 4
P4 = P1;
S4 = S3;
H4 = XSteam('h_ps', P4, S4);
T4 = XSteam('T_ps', P4, S4);

% Step IV : Calculate Work Done & Thermal Efficiency

% Work done by the turbine
Wt = H1 - H2;

% Work done by the pump
Wp = H4 - H3;

% Net Work done
Wnet = Wt - Wp;

% Thermal Efficiency
thermal_efficiency = (1 - ((H2 - H3)./(H1 - H4))).*100;

% Back Work Ratio
back_work_ratio = Wp./Wt;

% Specific Steam Conductivity
SSC = 3600./Wt;

% Step V : Plotting T-S Diagram for Rankine Cycle

figure(1), clf
hold on

% Saturation Curve
for i = 1 : length(t)
    plot(XSteam('sL_T',t(i)),t(i),'r.')     % 'r' indicates Marker's red color & '.' indicates its shape
    plot(XSteam('sV_T',t(i)),t(i),'r.')
end

% Cycle
plot([S1 S2], [T1 T2], 'LineWidth',3)
text(S1,T1+10, '1', 'FontSize',11)

if d > 1
    T3 = Tsat2;
    plot([S2 sg2 S3 S4], [T2 Tsat2 T3 T4], 'LineWidth', 3)
    T2 = Tsat2;
    text(S2,T2-10, '2', 'FontSize',11)
    text(S3,T3-10, '3', 'FontSize',11)
else
    plot([S2 S3 S4], [T2 T3 T4], 'LineWidth', 3)
    text(S2,T2-10, '2', 'FontSize',11)
    text(S3,T3-10, '3', 'FontSize',11)
end

n = linspace(T1, T2, 500);

for i = 1 : length(n)
    plot(XSteam('s_pT',P1,n(i)),n(i),'.','Linewidth',3,'Color','b')
end

axis([0 10 0 450])
plot([sl1 sg1], [Tsat1 Tsat1], 'LineWidth',3)
text(sl1,Tsat1-10, '4', 'FontSize',11)
xlabel('Entrophy (kJ/kg K)')
ylabel('Temperature (K)')
title('T-S Diagram for Rankine Cycle')
grid on


% Step VI : Plotting h-S Diagram for Rankine Cycle

figure(2), clf
hold on

% Saturation Curve
for i = 1 : length(t)
    plot(XSteam('sL_T',t(i)), XSteam('hL_T', t(i)),"Color",'r','Marker','.')
    plot(XSteam('sV_T',t(i)), XSteam('hV_T', t(i)),"Color",'r','Marker','.')
end

% Process Cycle
plot([S1 S2 S3 S4 S1], [H1 H2 H3 H4 H1],'LineWidth',3, 'Color','b')
text(S1,H1+80,'1','FontSize', 15)
text(S2,H2-80,'2','FontSize', 15)
text(S3,H3-60,'3','FontSize', 15)
text(S4,H4+180,'4','FontSize', 15)

xlabel('Entrophy (kJ/kg K)');
ylabel('Enthalphy (kJ/kg)');
title('h-S Diagram for Rankine Cycle');
grid on

% Step VII : Displaying Results in the command window
fprintf('Final Results n n')

% At State Point 1
disp('At State Point 1: ')
fprintf('P1 = %.2f Bar n',P1)
fprintf('T1 = %.2f Deg Celcius n',T1)
fprintf('H1 = %.2f kJ/kg n',H1)
fprintf('S1 = %.2f kJ/kg K n',S1)
disp(' ')

% At State Point 2
disp('At State Point 2: ')
fprintf('P2 = %.2f Bar n',P2)
fprintf('T2 = %.2f Deg Celcius n',T2)
fprintf('H2 = %.2f kJ/kg n',H2)
fprintf('S2 = %.2f kJ/kg K n',S2)
disp(' ')

% At State Point 3
disp('At State Point 3: ')
fprintf('P3 = %.2f Bar n',P3)
fprintf('T3 = %.2f Deg Celcius n',T3)
fprintf('H3 = %.2f kJ/kg n',H3)
fprintf('S3 = %.2f kJ/kg K n',S3)
disp(' ')

% At State Point 4
disp('At State Point 4: ')
fprintf('P4 = %.2f Bar n',P4)
fprintf('T4 = %.2f Deg Celcius n',T4)
fprintf('H4 = %.2f kJ/kg n',H4)
fprintf('S4 = %.2f kJ/kg K n',S4)
disp(' ')

fprintf('Work done by the turbine = %.2f kJ/kg n', Wt)
fprintf('Work done by the pump = %.2f kJ/kg n', Wp)
fprintf('Net work done = %.2f kJ/kg n', Wnet)
fprintf('Thermal Efficiency = %.2f % n', thermal_efficiency)
fprintf('nBack work ratio = %f', back_work_ratio)
fprintf('nSpecific Steam Conductivity = %.2f kg/kWh n', SSC)

RESULTS :

PROBLEM & SOLUTION :

As the command window shows all the outputs in a horizontal line. This issue is resolved by adding ' n ' to the format Spec.

Example :

fprintf('Work done by the turbine = %.2f kJ/kg n', Wt)
For instance, 'n' inserts a new line character.
Functions that support formatting operators are compose, num2str, sprintf, fprintf and the error handling functions are assert, error, warning and MException.

CONCLUSION :

Based on inputs, we have calculated the state points of the Rankine Cycle using MATLAB. These plots are then matched up with the corresponding T-S and h-S plots for the given set of inputs. Also, its final result is shown in the command window.

REFERENCES & COMMANDS USED :

  1. Rankine cycle
  2. Xsteam library
  3. Write data to text file (fprintf)
  4. Execute statements if condition is true (if, else)
  5. Generate linearly spaced vector (linspace)
  6. for loop to repeat specified number of times (for)
  7. Request user input (input)
  8. Display value of variable (disp)
  9. Clear figure (clf)
  10. Add text descriptions to data points (text)
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.