Project

Project 2 - Rankine cycle Simulator Using Matlab

Aim:

To Create a Rankine Cycle Simulator using MATLAB and to plot the corresponding T-s and h-s plots for the given set of inputs

Objective:

  1. The main objective to develop a basic program that calculates the state points .
  2. Then To add the thermodynamic relation to get the points in-between the state variables.
  3. Finally To plot rankine cycle on T-s and H-s curve.

Introduction:

A rankine cycle is an idealized Thermodynamic cycle which governs the working of a Heat Engine. In Rankine cycle, the friction losses of a heat engine are neglected. Heat is supplied externally in a loop where the working fluid is water.

There are four components in this cycle which work on four different processes. The four components are turbine, Condenser, Pump and Boiler. The rankine cycle is as shown in the figure.

1-2 : Isentropic Expansion in the Turbine

2-3 : Constant Pressure Heat Rejection in the Condenser

3-4 : Isentropic Expansion in the Pump

4-1 : Constant Pressure Heat Addition in the Boiler

In process 1-2 Isentropic Expansion happens in the turbine where the steam from the boiler is converted into mechanical energy, in process 2-3 Constant pressure heat rejection takes place where the vapor is converted to liquid inside a condenser.

In process 3-4 Isentropic Compression happens in the Pump where the pressure increases and the liquid is fed to the boiler. In process 4-1 Constant pressure heat addition takes place inside the boiler from where the superheated steam is fed to the Turbine.

H-S and T-S diagrams,

Thermodynamic Equations and formulae:

1.Thermal efficiency,

2.Q-input,Q-Output,Pump Work and Turbine Work.

Where,

Here the Input Values are given as,

Turbine Inlet temperature,T1 = 400° C

Turbine Inlet Pressure p1= 30 bars

Turbine Outlet Pressure p2= 0.05 bars = Condenser Inlet Pressure

Software used:

MATLAB R2020(online)

Program CODE:

%simulation of a basic Rankine cycle.

%Basic commands
clear all 
close all
clc

%isplaying the Basic datas
disp('RANKINE CYCLE SIMULATOR');
disp('1-2 - Isentropic Expansion in the turbine');
disp('2-3 - const Pressure heat Rejection by the Condenser');
disp('3-4 - Isentropic Compression in the pump');
disp('4-1 - const Pressure heat Addition by the Boiler');

disp('Enter the following input values to proceed to the results ');

%Getting inputs from the user
p1=input('Enter the Turbine Inlet pressure(in bar):');
t1=input('Enter the Turbine Inlet temperature(in degree Celsius):');
p2=input('Enter the Condenser inlet pressure(in bar):');

%State 1
% conditions at the inlet of the Turbine
tsat=XSteam('Tsat_p',p1);  %saturation temperature

%Extracting the Entropy values from XStream file
sf1=XSteam('sL_p',p1);
sg1=XSteam('sV_p',p1);
if t1>tsat      %using if-elseif to check the correctness of the temperature
    tsup=t1;
    h1=XSteam('h_pT',p1,tsup);
    s1=XSteam('s_pT',p1,tsup);
elseif t1==tsat
    h1=XSteam('hL_p',p1);
    s1=XSteam('sL_p',p1);
else
    disp('Temperature entered must be greater than or equal to saturation temperature')
end


%State 2
%conditions at the condenser inlet or the Turbine exhaust

t2=XSteam('Tsat_p',p2);
%Extracting the Enthalpy values from XStream file
hf2=XSteam('hL_p',p2);
hg2=XSteam('hV_p',p2);
s2=s1;
%Extracting the Entropy values from XStream file
sg2=XSteam('sV_p',p2);
sf2=XSteam('sL_p',p2);
x2=(s2-sf2)/(sg2-sf2);
h2=hf2+(x2*(hg2-hf2));   %calculating the enthalpy at state 2


%State 3
%conditions at the condenser exit
p3=p2;
t3=t2;
h3=hf2;  %since it is at saturated liquid line
s3=sf2;  %since it is an isentropic prcoess


%State 3
%conditions at the boiler inlet
p4=p1;
s4=s3;   %since it is an isentropic prcoess
cp4=XSteam('Cp_ps',p4,s4);
cv4=XSteam('Cv_ps',p4,s4);
gamma=cp4/cv4;
t4=t3*(p4/p3)^((gamma-1)/gamma);
vf=XSteam('vL_p',p3);

%input power to pump
pump_work=vf*(p1-p2)*100;  
h4=pump_work+h3;

% work output from turbine
Turbine_work=h1-h2;

%heat input
Q_in=h1-h4;

%heat output
Q_out=h2-h3;

%net work
work_net=Turbine_work-pump_work; 

% thermalefficiency
Thermal_eff=(work_net/Q_in)*100;

%Back work ratio
Back_work_ratio=(pump_work/Turbine_work);

%plotting of T-S and H-S diagram

%T-S diagram

figure(1)
hold on
%plotting saturation lines
temp = linspace(1, 373, 500);
for i = 1 : length(temp)
     hl(i) = XSteam('hL_T', temp(i));
     hv(i) = XSteam('hV_T', temp(i));
     sl(i) = XSteam('sL_T', temp(i));
     sv(i) = XSteam('sV_T', temp(i));
end
plot(sl, temp, 'k', 'linestyle','-','linewidth', 2,"Color",'y')
plot(sv, temp, 'k', 'linestyle','-','linewidth', 2,"Color",'y')
xlabel('Specific Entropy (kJ/kgK)')
ylabel('Temprature (degree C)')
grid on
title('T-S diagram','fontweight','bold','fontsize',14);
plot([s1 s2 s3 s4 sf1 sg1],[t1 t2 t3 t4 tsat tsat],'color','b','linewidth', 1.5)
text(s1,t1,'1')
text(s2,t2,'2')
text(s3,t3-10,'3')
text(s4,t4+10,'4')

t=linspace(tsat,tsup,1000); 
    for j =1:length(t)
        sinst(j) = XSteam('s_pT',p1,t(j));
    end
 plot(sinst,t,'color','b','linewidth', 1.5);


%H-S diagram
figure(2)
hold on
grid on
title('H-S diagram','fontweight','bold','fontsize',14,'color','b');
plot(sl, hl, 'k','linestyle','-', 'linewidth', 2,"Color",'g')
plot(sv, hv, 'k','linestyle','-', 'linewidth', 2,"Color",'g')      
plot([s1 s2 s3 s4 s1], [h1 h2 h3 h4 h1], 'color', 'r','linewidth', 1.5);
text(s1,h1,'1')
text(s2,h2,'2')
text(s3,h3-100,'3')
text(s4,h4+100,'4')
%labelling the axis
ylabel('Specific Enthalpy (kJ/kg)')
xlabel('Specific Entropy (kJ/kgK)')


%OUTPUTS
%at state 1
fprintf('\n')

disp('RESULTS :-');
fprintf('\n')

fprintf('At State 1:\n')
fprintf('P1 is : %.2f Bar\n',p1);
fprintf('T1 is : %.2f Deg Celsius\n',t1);
fprintf('H1 is : %.2f kJ/kg\n',h1);
fprintf('S1 is : %.2f kJ/kgKr\n',s1);
fprintf('\n')

%at state 2
fprintf('At State 2:\n')
fprintf('P2 is : %.2f Bar\n',p2);
fprintf('T2 is : %.2f Deg Celsius\n',t2);
fprintf('H2 is : %.2f kJ/kg\n',h2);
fprintf('S2 is : %.2f kJ/kgKr\n',s2);
fprintf('\n')

%at state 3
fprintf('At State 3:\n')
fprintf('P3 is : %.2f Bar\n',p3);
fprintf('T3 is : %.2f Deg Celsius\n',t3);
fprintf('H3 is : %.2f kJ/kg\n',h3);
fprintf('S3 is : %.2f kJ/kgKr\n',s3);
fprintf('\n')

%at state 4
fprintf('At State 4:\n')
fprintf('P4 is : %.2f Bar\n',p4);
fprintf('T4 is : %.2f Deg Celsius\n',t4);
fprintf('H4 is : %.2f kJ/kg\n',h4);
fprintf('S4 is : %.2f kJ/kgKrn\n',s4);
fprintf('\n')

%%Printing the results
fprintf('Turbine_work is : %.2f kJ/kg\n',Turbine_work);
fprintf('pump_work is : %.2f kJ/kg\n',pump_work);
fprintf('work_net is : %.2f kJ/kg\n',work_net);
fprintf('Thermal_efficiency is : %.2f Percent\n',Thermal_eff);
fprintf('The Back_work_ratio is :%f\n',Back_work_ratio);

Code Explanation:

  1. Initially first enter the basic commands clear all, close all and clc.
  2. Then the Xsteam file was uploaded to the MATLAB drive as i was working with Matlab online.
  3. Then the Heading and some of the basic process in the Rankine cycle is made to display using the disp() command.
  4. Next using the values of"P1", "T1" and "P2" were given as input and the inputs are got from the user. And the temperature value array "t" was created using the "linspace"
  5. Here using the provided "XSteam" library the values of various physical parameters such as Enthalpy ,Entropy , Saturated liquid/vapor - enthalpy/entropy ,saturation temperature at state 1 is extracted from the file.
  6. Similarly at the states 2,3 and 4 same were calculated.
  7. Then using basic relations between work and physical parameters the "Work_net", "back_work_ratio" etc. were calculated.
  8. Now plot the T-s curve. Here again we used the provided "XSteam" library function to plot the T-s Curve at different temperature array values.
  9. Then along with the state points the curve was plotted and labelled the axis for better understanding.
  10. Similarly like the T-s curve was plotted. Again the provided "XSteam" library function is used to plot the h-s Curve at different temperature array values.
  11. Then along with the state points the curve was plotted and the axis are labelled.
  12. Then the values of physical parameters at each state is displayed in the command window. This was done for all the "4" state points in similar way.
  13. Then the final results i.e. "Work_net" "Turbine_work" "pump_work" "back_work_ratio" ,"thermal_efficiency" were printed in the command window using the disp() command.
  14. Finally the program was executed.

Output:

T-S Diagram:

H-S Diagram:

COMMAND WINDOW:

Errors faced:

1)

Forgot to enclose 'r' within '...'

2)Other syntax errors that appeared during the execution of the program has been corrected and executed to get the correct results.

References:

  1. http://www.thermopedia.com/content/1072/
  2. https://energyeducation.ca/encyclopedia/Rankine_cycle

Conclusions:

Finally the program for the Rankine Cycle Simulator was created using MATLAB, the plots for the corresponding T-s and h-s diagram for the given set of inputs were created.And the objective of this project is successfully completed to get the desired output.

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.