Project

Simulating the Ideal Rankine Cycle

  • I am going to write a MATLAB program to simulate the Ideal Rankine Cycle. I will be using standard Xsteam library to get the steam table data for water.

Problem setup:
1. The Pressure at the Turbine Inlet is set to `44` bars.
2. The Temperature at the Turbine inlet is set to `538` °C.
3. The Pressure at the Condenser is set to `5.83` bars.


Programs:
The driver script 'ideal_rankine_cycle_simulator.m' is as follows

% Ideal Rankine Cycle Simulator

%% Clearing workspace, closing figures, clearing command window
clear all
close all
clc

%% Displaying title and the process in the command window
fprintf('     IDEAL RANKINE CYCLE SIMULATOR \n\n')                    
fprintf('1-2 is Isentropic Expansion in the Turbine\n')
fprintf('2-3 is Constant Pressure Heat Rejection by the Condenser\n')
fprintf('3-2 is Isentropic Compression in the Pump\n')
fprintf('4-1 is Constant Pressure Heat Addition by the Boiler\n\n')


%% Manual inputs
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): ');
disp('')

disp('   RESULTS')

%% State point 1
disp('At state point 1:')

fprintf('P1 is : %g Bar\n', P1)

fprintf('T1 is : %g Deg Celcius\n', T1)

H1 = XSteam('h_pt', P1, T1);
fprintf('H1 is : %g kJ/kg\n', H1)

S1 = XSteam('s_pt', P1, T1);
fprintf('S1 is : %g kJ/kgK\n\n', S1)

%% State point 2
disp('At state point 2:')

P2 = P2;
fprintf('P2 is : %g Bar\n', P2)

S2 = S1;
fprintf('S2 is : %g kJ/kgK\n', S2)

Sg = XSteam('sV_p', P2);
Sf = XSteam('SL_p', P2);
Sfg = Sg - Sf;
X2 = (S2 - Sf) / (Sfg);   % Dryness Fraction at state point 2
fprintf('X2 is : %g\n', X2)

Hf = XSteam('hL_p', P2);
Hg = XSteam('hV_p', P2);
Hfg = Hg - Hf;
H2 = Hf + X2 * Hfg;
fprintf('H2 is : %g kJ/kg\n', H2)

T2 = XSteam('Tsat_p', P2);
fprintf('T2 is : %g Deg Celcius\n\n', T2)

%% State point 3
disp('At state point 3:')

P3 = P2;
fprintf('P3 is : %g Bar\n', P3)

V3 = XSteam('vL_p', P3);

T3 = T2;
fprintf('T3 is : %g Deg Celcius\n', T3)

H3 = XSteam('hL_p', P3);
fprintf('H3 is : %g kJ/kg\n', H3)

S3 = XSteam('sL_p', P3);
fprintf('S3 is : %g kJ/kgK\n\n', S3)

%% State point 4
disp('At state point 4:')

P4 = P1;
fprintf('P4 is : %g Bar\n', P4)

S4 = S3;
fprintf('S4 is : %g kJ/kgK\n', S4)

Wp = V3 * (P4 - P3) * 100;
H4 = Wp + H3;
fprintf('H4 is : %g kJ/kg\n', H4)

T4 = XSteam('T_ps', P4, S4);
fprintf('T4 is : %g Deg Celcius\n\n', T4)

%% Work done, heat, SSC and efficiency calculations
Wt = H1 - H2;
fprintf('Wt is : %g kJ/kg\n', Wt)
fprintf('Wp is : %g kJ/kg\n', Wp)
Wnet = Wt - Wp;
fprintf('Wnet is : %g kJ/kg\n', Wnet)
Qin = H1 - H4;
Ntherm = Wnet / Qin * 1e2;    % Effieciency
fprintf('Ntherm is : %g', Ntherm); disp('%')
SSC = 3600 / Wt;    % Specific steam consuption
fprintf('S.S.C is : %g kg/kWh\n\n', SSC)

%% Calculation for plotting Liquid and Vapour lines 
temp = linspace(1, 373, 500);
for i = 1 : length(temp)
     H_L(i) = XSteam('hL_T', temp(i));
     H_V(i) = XSteam('hV_T', temp(i));
     S_L(i) = XSteam('sL_T', temp(i));
     S_V(i) = XSteam('sV_T', temp(i));
end

%% Points between state point 4 to state point 1 
S5 = XSteam('sL_p', P1);
S6 = XSteam('sV_p', P1);
T5 = XSteam('Tsat_p', P1);
T6 = XSteam('Tsat_p', P1);

%% Ploting T - S and H - S Diagrams 
rankine_plots(S1, S2, S3, S4, S5, S6, T1, T2, T3, T4, T5, T6, H1, H2, H3, H4, temp, S_L, S_V, H_L, H_V)


Below is the function file 'rankine_plots.m' used in driver script which plots the T - S and H - S diagrams

% rankine_plots - It generates and saves T-S and H-S Diagrams 

function rankine_plots(S1, S2, S3, S4, S5, S6, T1, T2, T3, T4, T5, T6, H1, H2, H3, H4, temp, S_L, S_V, H_L, H_V)

figure(1) % T-S
hold on
plot([S1 S2], [T1 T2], 'r', 'linewidth', 2)
plot([S2 S3], [T2 T3], 'y', 'linewidth', 2)
plot([S3 S4], [T3 T4], 'b', 'linewidth', 2)
plot([S4 S5 S6 S1], [T4 T5 T6 T1], 'g', 'linewidth', 2)
plot(S_L, temp, 'c', 'linewidth', 1.5)
plot(S_V, temp, 'k', 'linewidth', 1.5)
l = legend('Isentropic Expansion',...
              'Constant Pressure Heat Rejection',...
              'Isentropic Compression',...
              'Constant Pressure Heat Addition',...
              'Liquid Line', 'Vapour Line');
set(l,'location','northwest');              
title('T-S Diagram', 'FontSize', 15)
ylabel('Temprature (\degC)', 'FontSize', 12)
xlabel('Specific Entropy (kJ/kgK)', 'FontSize', 12)

figure(2) % H-S
hold on
plot([S1 S2], [H1 H2], 'r', 'linewidth', 2);
plot([S2 S3], [H2 H3], 'y', 'linewidth', 2);
plot([S3 S4], [H3 H4], 'b', 'linewidth', 2);
plot([S4 S1], [H4 H1], 'g', 'linewidth', 2);
plot(S_L, H_L, 'c', 'linewidth', 1.5)
plot(S_V, H_V, 'k', 'linewidth', 1.5)
l = legend('Isentropic Expansion',...
              'Constant Pressure Heat Rejection',...
              'Isentropic Compression',...
              'Constant Pressure Heat Addition',...
              'Liquid Line', 'Vapour Line');
set(l,'location','northwest');      
title('H-S Diagram', 'FontSize', 15)
ylabel('Specific Enthalpy (kJ/kg)', 'FontSize', 12)
xlabel('Specific Entropy (kJ/kgK)', 'FontSize', 12)

% Saving the plots obtained
saveas(1, 'TS.png')
saveas(2, 'HS.png')
end

Results:

  1. Output Screen -
         IDEAL RANKINE CYCLE SIMULATOR
    
    1-2 is Isentropic Expansion in the Turbine
    2-3 is Constant Pressure Heat Rejection by the Condenser
    3-2 is Isentropic Compression in the Pump
    4-1 is Constant Pressure Heat Addition by the Boiler
    
    Enter the Pressure at the Turbine Inlet (in bar): 44
    Enter the Temperature at the Turbine inlet (in Degree Celcius): 538
    Enter the Pressure at the Condenser (in bar): 5.83
    
       RESULTS
    At state point 1:
    P1 is : 44 Bar
    T1 is : 538 Deg Celcius
    H1 is : 3528.83 kJ/kg
    S1 is : 7.15399 kJ/kgK
    
    At state point 2:
    P2 is : 5.83 Bar
    S2 is : 7.15399 kJ/kgK
    X2 is : 1.07942
    H2 is : 2920.82 kJ/kg
    T2 is : 157.712 Deg Celcius
    
    At state point 3:
    P3 is : 5.83 Bar
    T3 is : 157.712 Deg Celcius
    H3 is : 665.638 kJ/kg
    S3 is : 1.91987 kJ/kgK
    
    At state point 4:
    P4 is : 44 Bar
    S4 is : 1.91987 kJ/kgK
    H4 is : 669.834 kJ/kg
    T4 is : 158.16 Deg Celcius
    
    Wt is : 608.008 kJ/kg
    Wp is : 4.196 kJ/kg
    Wnet is : 603.812 kJ/kg
    Ntherm is : 21.1197%
    S.S.C is : 5.92098 kg/kWh
  2. Plots -
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.