Challenge

Project 2 - Rankine cycle Simulator

AIM:

To write a code in Matlab to create a basic 'RANKINE CYCLE SIMULATOR' by taking in User inputs and displaying the Out state parameters along with the H-S and T-S graph.

THEORY:

The Rankine cycle is a model used to predict the performance of a steam turbine cycle. It is the fundamental operating cycle of all power plants where an operating fluid is continuously evaporated and condensed. There are many fluids that can be used but water is the most preferred fluid due to its favorable properties, such as non-toxic, unreactive chemistry, abundance, and low cost, as well as its thermodynamic properties .

The above figure shows us the basic Rankine cycle.

Here:

PROCESS 1-2: Isentropic expansion in turbine.

PROCESS 2-3: Isobaric heat rejection by the condenser.

PROCESS 3-4: Isentropic compression in pump.

PROCESS 4-1: Isobaric heat addition in the boiler.

GOVERNING EQUATION:

1)Turbine Work(WT): WT = H1 - H2

2)Pump Work(WP): WP = H4 - H3

3)Net Work(WNET): WNET = WT - WP

4)Thermal Efficiency(`η`): eff = WNET/(H1 - H4)

5)Specific Steam Conductivity(S.S.C): S.S.C = 3600/WT

Where,

H1,H2,H3,H4 are the enthalpy at the respective state points.

WORKFLOW OF THE PROJECT:

  1. The Initial Values of P1, T1 and P2 are input using the User input.
  2. Using the Input values, on the basis of the working of the Rankine cycle and the Xsteam library the values for Pressure, Temperature, Enthalpy and Entropy at all the 4 states are calculated.
  3. Once all the state parameters are calculated, the Value for different work done and efficiency is calculated based on the above formulae and they are printed on the screen
  4. By using the Xsteam function we plot the Saturation curve for the H-S and T-S diagram.
  5. Finally the values of the state parameters are plotted using the plot function.

Xsteam Function:

https://drive.google.com/file/d/1RK_fvrOj38CIaQvmLT1S3daqHnxKCGU-/view

Code:

clear all
close all
clc
%--------------------------------------------------------------------------------------------
disp('------------------------RANKINE CYCLE SIMULATOR---------------------------')
disp('Process 1-2 : Isentropic Expansion in turbine')
disp('Process 2-3 : Constant pressure heat rejection in Condensor')
disp('Process 3-4 : Isentropic compression in pump')
disp('Process 4-1 : Constant pressure heat addition in Boiler')
fprintf('\n');

%------------Input Values to the Code---------------------------------------
p1 = input('Enter the Turbine inlet pressure (in Bar)');
t1 = input('Enter the Turbine inlet temperature (in Degree Celcius)');
p2 = input('Enter the Condenser pressure (in Bar)');

%--------------------------State 1---------------------------------------
t1_sat = XSteam('Tsat_p',p1);
if t1 > t1_sat
   h1 = XSteam('h_pt',p1,t1);
   s1 = XSteam('s_pt',p1,t1);
elseif t1 == t1_sat
        h1 = XSteam('hV_p',p1);
        s1 = XSteam('sV_p',p1);
else
    disp('Invalid Temperature Input. Input a Higer Value')
end
    
%----------------------------State 2--------------------------------
s2 = s1;
s2_sat = XSteam('sV_p',p2);

if s2 < s2_sat
s2_f = XSteam('sL_p',p2);
s2_g = XSteam('sV_p',p2);
x2 = (s2 - s2_f)/(s2_g - s2_f); %calculation vapour fraction
h2_f = XSteam('hL_p',p2);
h2_g = XSteam('hV_p',p2);
h2 = h2_f + x2*(h2_g - h2_f);
t2 = XSteam('Tsat_p',p2);
else
    x2 = 1;
    h2 = XSteam('hV_p',p2);
    t2 = XSteam('Tsat_p',p2);
end

%-----------------------State 3--------------------------
p3 = p2;
t3 = XSteam('Tsat_p',p3);
h3 = XSteam('hL_p',p3);
s3 = XSteam('sL_p',p3);
v3 = XSteam('vL_p',p3);

%------------------------State 4---------------------------------------
s4 = s3;
p4 = p1;
v4 = XSteam('v_ps',p4,s4);
Cp = XSteam('Cp_ps',p4,s4);
Cv = XSteam('Cv_ps',p4,s4);
g = Cp/Cv;                            
t4 = t3*((p3/p4)^((1-g)/g));
W_pump = v3*(p4 - p3)*100;               %Total Work done by the Pump
h4 = h3 + W_pump;

%considering point 5 and 6 to complete the curve since 4-1 is not a single
%curve
t5 = XSteam('Tsat_p',p4);
s5 = XSteam('sL_p',p4);
t6 = t5;
s6 = XSteam('sV_T',t6);

% ---------------Calculation for Work done, heat and efficiency-------------
%assuming mass flow rate = 1

W_turbine = h1 - h2;                 % Work done by turbine
W_net = W_turbine - W_pump;          % Net work done by the System
Q_input = h1 - h4;                   % Heat added to the Boiler
Q_output = h2 - h3;                  % Heat rejected by the Condensor
Eff = W_net/Q_input;                 % Efficiency of the Cycle
SSC = 3600/W_net;                    %specific steam consumption (SSC)

%----------------Printing Output Results------------------------------------
disp('----------------------------RESULTS----------------------------------')

%Values of state point 1
disp('At State point 1');
fprintf('Pressure at state 1 is    : %.2f Bar \n',p1);
fprintf('Temperature at state 1 is : %.2f Deg Celcius \n',t1);
fprintf('Ethalpy at state 1 is     : %.2f KJ/kg \n',h1);
fprintf('Entropy at State 1 is     : %.2f KJ/kgK \n',s1);
fprintf('\n');

%Values of state point 2
disp('At State point 2');
fprintf('Pressure at state 2 is    : %.2f Bar \n',p2);
fprintf('Temperature at state 2 is : %.2f Deg Celcius \n',t2);
fprintf('Ethalpy at state 2 is     : %.2f KJ/kg \n',h2);
fprintf('Entropy at State 2 is     : %.2f KJ/kgK \n',s2);
fprintf('\n');

%Values of state point 3
disp('At State point 3');
fprintf('Pressure at state 3 is    : %.2f Bar \n',p3);
fprintf('Temperature at state 3 is : %.2f Deg Celcius \n',t3);
fprintf('Ethalpy at state 3 is     : %.2f KJ/kg \n',h3);
fprintf('Entropy at State 3 is     : %.2f KJ/kgK \n',s3);
fprintf('\n');

%Values of state point 4
disp('At State point 4');
fprintf('Pressure at state 4 is    : %.2f Bar \n',p4);
fprintf('Temperature at state 4 is : %.2f Deg Celcius \n',t4);
fprintf('Ethalpy at state 4 is     : %.2f KJ/kg \n',h4);
fprintf('Entropy at State 4 is     : %.2f KJ/kgK \n',s4);
fprintf('\n');

%Turbine Work
fprintf('Work done by Turbine : %.2f KJ/kg \n',W_turbine);

%Pump Work
fprintf('Work done by Pump    : %.2f KJ/kg \n',W_pump);

%Net Work
fprintf('Net Work done by the System : %.2f KJ/kg \n',W_net);

%Thermal Efficiency
fprintf('Thermal Efficiency of the System : %.2f Percent \n',Eff);

%Specific Steam Conductivity
fprintf('S.S.C of the System : %.2f kg/KWh \n',SSC);


%----------------------Plotting the T-S Curve------------------------------

t = linspace(0,500,1000);               %Time steps
figure(1)
hold on

for i = 1:length(t)
plot(XSteam('sL_T',t(i)),t(i),'r.')
plot(XSteam('sV_T',t(i)),t(i),'r.')
end

plot([s1,s2],[t1,t2],'linewidth',2,'color','b')
plot([s2,s3],[t2,t3],'linewidth',2,'color','r')
plot([s3,s4],[t3,t4],'linewidth',2,'color','y')
plot([s4,s5],[t4,t5],'linewidth',2,'color','k')
plot([s5,s6],[t5,t6],'linewidth',2,'color','k')
plot([s6,s1],[t6,t1],'linewidth',2,'color','k')

text(s1,t1,'State 1')
text(s2,t2,'State 2')
text(s3,t3,'State 3')
text(s4,t4,'State 4')

xlabel('Entropy [KJ/Kg-K]')
ylabel('Temperature [C]')
title('T-s Curve for Rankine Cycle')

hold off

%------------------------Plotting H-S curve-------------------------------

figure(2)
hold on
for i = 1:length(t)
 plot(XSteam('sL_T',t(i)),XSteam('hL_T',t(i)),'r.')
 plot(XSteam('sV_T',t(i)),XSteam('hV_T',t(i)),'r.')
end

plot([s1,s2],[h1,h2],'linewidth',2,'color','b')
plot([s2,s3],[h2,h3],'linewidth',2,'color','r')
plot([s3,s4],[h3,h4],'linewidth',2,'color','y')
plot([s4,s1],[h4,h1],'linewidth',2,'color','k')

text(s1,h1,'State 1')
text(s2,h2,'State 2')
text(s3,h3,'State 3')
text(s4,h4,'State 4')

xlabel('Entropy [KJ/Kg-K]')
ylabel('Enthalpy [KJ/Kg]')
title('H-S Curve of Rankine Cycle')

hold off



Input at Command:

Output( Matlab Online ):

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.