Project

Rankine cycle simulator

AIM:

To write a program in MATLAB/Octave to simulate Rankine cycle.

OBJECTIVES:

  1. To write a program in MATLAB/Octave to plot T-S and H-S curve for rankine cycle.
  2. To calculate Turbine work, pump work, net work, back work ratio and thermal efficiency of rankine cycle

THEORY: The Rankine cycle is a model used to predict the performance of steam turbine systems. It was also used to study the performance of reciprocating steam engines. The Rankine cycle is an idealized thermodynamic cycle of a heat engine that converts heat into mechanical work while undergoing phase change.

PRINCIPAL COMPONENTS OF VAPOUR POWER CYCLE:

The four basic component of vapour power plant are shown in Fig

Turbine: The vapour leaving the boiler enters the turbine, where it expands isentropically to the condenser pressure at state 2.The work produced by the turbine is rotator (shaft) work and is used to drive an electric generator or machine.

Condenser: The condenser is attached at the exit of the turbine. The vapour leaving the turbine is wet vapour and it is condensed completely in the condenser to the state 3, by giving its latent heat to some other cooling fluid like water.

Pump: The liquid condensate leaving the condenser at the state 3 is pumped to the operating pressure of the boiler. The pump operation is considered isentropic.

Boiler: The heat is supplied to the working fluid (feed water) in the boiler and thus vapour is generated. The vapour leaving the boiler is either saturated or superheated depending upon the amount of heat supplied in the boiler.

PROCESS: The ideal rankine cycle consist of four processes:

Process 1-2: Isentropic expansion of the working fluid in the turbine from boiler pressure to condenser pressure.

Process 2-3: Heat rejection from the working fluid at constant pressure in the condenser till the fluid reaches the saturated liquid state 3.

Process 3-4: Isentropic compression of the working fluid in the pump to the boiler pressure at state 4 in the compressed liquid region.

Process 4-1: Heat addition to the working fluid at constant pressure in the boiler from state 4 to 1.

PROGRAM: To plot the T-S and H-S diagram for Rankine cycle and to calculate pump work, turbine work, back work ratio and thermal efficiency for the same.

PROGRAMMING LANGUAGE: Octave

clc
clear all
close all

disp('RANKINE CYCLE SIMULATOR');
disp('1-2 is isentropic expansion in turbine');
disp('2-3 is constant pressure heat rejection in condenser');
disp('3-4 is isentropic compression in pump');
disp('4-1 is constant pressure heat addition in boiler');

%Rankine cycle simulator

%Providing the known parameters
p1= input(' enter the pressure at the turbine inlet (in bar)=   ');
t1= input('enter the temperature at the turbine inlet (in deg-C):     ');
p2= input('enter the pressure at the Condensor inlet (in bar):     ');


%Calculating state variables at point 1 i,e at the inlet of turbine

%Entropy at point 1
s1= XSteam('s_pT',p1,t1);

%Enthalpy at point 1
h1= XSteam('h_pT',p1,t1);

%Calculating variables at the saturation points for pressure p1 i,e 30 bar
tsat_at_p1=XSteam('Tsat_p',p1);
hf_at_p1=XSteam('hL_p',p1);
hg_at_p1=XSteam('hV_p',p1);
sf_at_p1=XSteam('sL_p',p1);
sg_at_p1=XSteam('sV_p',p1);

%Calculating state variables at point 2 i,e at the inlet of condensor

s2=s1;
sg2=XSteam('sV_p',p2);
sf2=XSteam('sL_p',p2);

%dryness fraction
% s1=s2= sf2+ x(sg2-sf2)
% x= (s2-sf2)/(sg2-sf2)
x= (s2-sf2)/(sg2-sf2);

t2= XSteam('T_ps',p2,s2);

hg2=XSteam('hV_T',t2);
hf2=XSteam('hL_T',t2);
h2= hf2+x*(hg2-hf2);

%Calculating state variables at point 3 i,e at the inlet of pump
s3= sf2;
t3=t2;
p3=p2;
h3=hf2;
%v3=vf3
vf3=XSteam('vL_T',t3);

%Calculating state variables at point 4 i,e at the inlet of boiler
p4=p1;
s4=s3;

%specific heat calculation
cp=XSteam('Cp_ps',p4,s4);
cv=XSteam('Cv_ps',p4,s4);
gamma=cp/cv;
t4= t3*(p4/p3)^((gamma-1)/gamma);

%Calculating Pump work
%w_p= h4-h3
%w_p= vf*(pi-p2)
w_p= vf3*(p4-p3)*100;

%w_p= h4-h3
h4= h3+w_p;

% Calculating Turbine work
w_t= h1-h2;

%Net work done
w_net= w_t-w_p;

%Back work ratio
back_work_ratio= w_p/w_t;

%Heat supplied to the working fluid in the boiler
qin= h1-h4;

%Heat rejected by the working fluid in the condensor
qout= h2-h3;

%Efficiency of the rankine cycle
efficiency= ((qin-qout)/qin)*100;

%Defining temperature range for plotting t-s and h-s diagram
T= linspace(0,450,500);

%Calculating entropy values for saturated liquid line for defined tempearure range
for i= 1:length(T)
Sf(i)= XSteam('sL_T',T(i));
end 
%Calculating entropy values for saturated vapour line for defined tempearure range
for i= 1:length(T)
Sg(i)= XSteam('sV_T',T(i));
end 

%Calculating enthalpy values for saturated liquid line for defined tempearure range
for i= 1:length(T)
Hf(i)= XSteam('hL_T',T(i));
end 

%Calculating enthalpy values for saturated vapour line for defined tempearure range
for i= 1:length(T)
Hg(i)= XSteam('hV_T',T(i));
end 

%Calculating entropy values for temperature definned between saturation temperature for p1 and t1
Temp_tsat_at_p1_to_t1= linspace(tsat_at_p1,t1,100);
for i=1:length(Temp_tsat_at_p1_to_t1);
S_sf_at_p1_to_s1(i)=XSteam('s_pT',30,Temp_tsat_at_p1_to_t1(i));
end

%Plotting T-S diagram
hold on
figure(1)
plot(Sg,T,'linewidth' ,3,'color','r');
plot(Sf,T,'linewidth' ,3,'color','r');
plot([s4 sf_at_p1],[t4 tsat_at_p1],'linewidth' ,3,'color','g');
plot([sf_at_p1 sg_at_p1],[tsat_at_p1 tsat_at_p1],'linewidth',3,'color','g');
plot(S_sf_at_p1_to_s1,Temp_tsat_at_p1_to_t1,'linewidth' ,3,'color','g');
plot([s1 s1],[t1 t2],'linewidth',3,'color','g');
plot([s2 s3],[t3 t3],'linewidth',3,'color','g');
plot([s3 s3],[t3 t4],'linewidth',3,'color','g');
set(gca,'fontsize',15)
text(s1,t1,'1','fontsize',15);
text(s2,t2,'2','fontsize',15);
text(s3,t3,'3','fontsize',15);
text(s4,t4,'4','fontsize',15);

xlabel("Entropy(KJ/Kg-degC)");
ylabel("Temperature(deg C)");
title('T-S diagram ');


%Plotting H-S diagram
figure(2)
hold on
plot(Sf,Hf,'linewidth',3,'color','r');
plot(Sg,Hg,'linewidth',3,'color','r');
plot([s1 s2],[h1 h2],'linewidth',3,'color','g');
plot([s2 s3],[h2 h3],'linewidth',3,'color','g');
plot([s3 s4],[h3 h4],'linewidth',3,'color','g');
plot([s4 s1],[h4 h1],'linewidth',3,'color','g');
set(gca,'fontsize',15)
text(s1,h1,'1','fontsize',15);
text(s2,h2,'2','fontsize',15);
text(s3,h3,'3','fontsize',15);
text(s4,h4,'4','fontsize',15);
xlabel("Entropy(KJ/Kg-degC)");
ylabel("Enthalpy(KJ/Kg)");
title('H-S diagram');

fprintf('\nResults\n' );
fprintf('\nState 1:Superheated steam\n');
fprintf('p1= %f bar\n' ,p1);
fprintf('T1= %f deg C\n',t1);
fprintf('h1= %f KJ/Kg\n',h1);
fprintf('s1= %f KJ/Kg-degC\n' ,s1);

fprintf('State 2: Wet steam\n');
fprintf('p2= %f bar\n' ,p2);
fprintf('T2= %fdeg C\n',t2);
fprintf('h2= %f KJ/Kg\n',h2);
fprintf('s2= %f KJ/Kg-degC\n' ,s2);
fprintf('hf2= %f KJ/Kg\n',hf2);
fprintf('hg2= %f KJ/Kg\n',hg2);
fprintf('sf2= %f KJ/Kg-degC\n',sf2);
fprintf('sg2= %f KJ/Kg-degC\n\n',sg2);

fprintf('State 3:Saturated liquid\n');
fprintf('p3= %f bar\n' ,p3);
fprintf('T3= %fdeg C\n',t3);
fprintf('h3= %f KJ/Kg\n',h3);
fprintf('s3= %f KJ/Kg-degC\n' ,s3);
fprintf('vf3= %f m^3/Kg\n\n' ,vf3);

fprintf('State 4:Compressed liquid\n');
fprintf('p4= %f bar\n' ,p4);
fprintf('T4= %fdeg C\n',t4);
fprintf('h4= %f KJ/Kg\n',h4);
fprintf('s4= %f KJ/Kg-degC\n\n' ,s4);

fprintf('Output Results\n');
fprintf('Pump work %f KJ/Kg \n',w_p);
fprintf('Turbine work %f KJ/Kg \n',w_t);
fprintf('Back work ratio %f\n',back_work_ratio);
fprintf('Net work %f KJ/Kg \n',w_net);
fprintf('Efficiency %f \n',efficiency);

EXPLANATION:

Displaying the names of the various process of rankine cycle and taking input from user about the inlet pressure of turbine, inlet temperature of turbine, and inlet pressure of condenser.

clc
clear all
close all

disp('RANKINE CYCLE SIMULATOR');
disp('1-2 is isentropic expansion in turbine');
disp('2-3 is constant pressure heat rejection in condenser');
disp('3-4 is isentropic compression in pump');
disp('4-1 is constant pressure heat addition in boiler');

%Rankine cycle simulator

%Providing the known parameters
p1= input(' enter the pressure at the turbine inlet (in bar)=   ');
t1= input('enter the temperature at the turbine inlet (in deg-C):     ');
p2= input('enter the pressure at the Condensor inlet (in bar):     ');

Calculating the state variables and required parameters by extracting the values from the file named ‘XSteam’ or by applying suitable formula.

%Calculating state variables at point 1 i,e at the inlet of turbine

%Entropy at point 1
s1= XSteam('s_pT',p1,t1);

%Enthalpy at point 1
h1= XSteam('h_pT',p1,t1);

%Calculating variables at the saturation points for pressure p1 i,e 30 bar
tsat_at_p1=XSteam('Tsat_p',p1);
hf_at_p1=XSteam('hL_p',p1);
hg_at_p1=XSteam('hV_p',p1);
sf_at_p1=XSteam('sL_p',p1);
sg_at_p1=XSteam('sV_p',p1);

%Calculating state variables at point 2 i,e at the inlet of condensor

s2=s1;
sg2=XSteam('sV_p',p2);
sf2=XSteam('sL_p',p2);

%dryness fraction
% s1=s2= sf2+ x(sg2-sf2)
% x= (s2-sf2)/(sg2-sf2)
x= (s2-sf2)/(sg2-sf2);

t2= XSteam('T_ps',p2,s2);

hg2=XSteam('hV_T',t2);
hf2=XSteam('hL_T',t2);
h2= hf2+x*(hg2-hf2);

%Calculating state variables at point 3 i,e at the inlet of pump
s3= sf2;
t3=t2;
p3=p2;
h3=hf2;
%v3=vf3
vf3=XSteam('vL_T',t3);

%Calculating state variables at point 4 i,e at the inlet of boiler
p4=p1;
s4=s3;

%specific heat calculation
cp=XSteam('Cp_ps',p4,s4);
cv=XSteam('Cv_ps',p4,s4);
gamma=cp/cv;
t4= t3*(p4/p3)^((gamma-1)/gamma);

%Calculating Pump work
%w_p= h4-h3
%w_p= vf*(pi-p2)
w_p= vf3*(p4-p3)*100;

%w_p= h4-h3
h4= h3+w_p;

% Calculating Turbine work
w_t= h1-h2;

%Net work done
w_net= w_t-w_p;

%Back work ratio
back_work_ratio= w_p/w_t;

%Heat supplied to the working fluid in the boiler
qin= h1-h4;

%Heat rejected by the working fluid in the condensor
qout= h2-h3;

%Efficiency of the rankine cycle
efficiency= ((qin-qout)/qin)*100;

Temperature is defined to take 500 values between 0 deg C and 450 deg C and entropy values for saturated liquid line and saturated vapour line are extracted from ‘XSteam’ file against the defined temperature range so as to plot T-S diagram.

Similarly enthalpy values for saturated liquid line and saturated vapour line are extracted from ‘XSteam’ file against the extracted entropy values so as to plot H-S diagram.

%Defining temperature range for plotting t-s and h-s diagram
T= linspace(0,450,500);

%Calculating entropy values for saturated liquid line for defined tempearure range
for i= 1:length(T)
Sf(i)= XSteam('sL_T',T(i));
end 
%Calculating entropy values for saturated vapour line for defined tempearure range
for i= 1:length(T)
Sg(i)= XSteam('sV_T',T(i));
end 

%Calculating enthalpy values for saturated liquid line for defined tempearure range
for i= 1:length(T)
Hf(i)= XSteam('hL_T',T(i));
end 

%Calculating enthalpy values for saturated vapour line for defined tempearure range
for i= 1:length(T)
Hg(i)= XSteam('hV_T',T(i));
end 

Calculating entropy values against the temperature ranging from saturation temperature for`p_1` to temperature at state 1(`t_1`)

%Calculating entropy values for temperature definned between saturation temperature for p1 and t1
Temp_tsat_at_p1_to_t1= linspace(tsat_at_p1,t1,100);
for i=1:length(Temp_tsat_at_p1_to_t1);
S_sf_at_p1_to_s1(i)=XSteam('s_pT',30,Temp_tsat_at_p1_to_t1(i));
end

Plotting the T-S diagram and then increasing the font size of the various texts on graph.

%Plotting T-S diagram
hold on
figure(1)
plot(Sg,T,'linewidth' ,3,'color','r');
plot(Sf,T,'linewidth' ,3,'color','r');
plot([s4 sf_at_p1],[t4 tsat_at_p1],'linewidth' ,3,'color','g');
plot([sf_at_p1 sg_at_p1],[tsat_at_p1 tsat_at_p1],'linewidth',3,'color','g');
plot(S_sf_at_p1_to_s1,Temp_tsat_at_p1_to_t1,'linewidth' ,3,'color','g');
plot([s1 s1],[t1 t2],'linewidth',3,'color','g');
plot([s2 s3],[t3 t3],'linewidth',3,'color','g');
plot([s3 s3],[t3 t4],'linewidth',3,'color','g');
set(gca,'fontsize',15)
text(s1,t1,'1','fontsize',15);
text(s2,t2,'2','fontsize',15);
text(s3,t3,'3','fontsize',15);
text(s4,t4,'4','fontsize',15);

xlabel("Entropy(KJ/Kg-degC)");
ylabel("Temperature(deg C)");
title('T-S diagram ');

Plotting the H-S diagram and then increasing the font size of the various texts on graph.

%Plotting H-S diagram
figure(2)
hold on
plot(Sf,Hf,'linewidth',3,'color','r');
plot(Sg,Hg,'linewidth',3,'color','r');
plot([s1 s2],[h1 h2],'linewidth',3,'color','g');
plot([s2 s3],[h2 h3],'linewidth',3,'color','g');
plot([s3 s4],[h3 h4],'linewidth',3,'color','g');
plot([s4 s1],[h4 h1],'linewidth',3,'color','g');
set(gca,'fontsize',15)
text(s1,h1,'1','fontsize',15);
text(s2,h2,'2','fontsize',15);
text(s3,h3,'3','fontsize',15);
text(s4,h4,'4','fontsize',15);
xlabel("Entropy(KJ/Kg-degC)");
ylabel("Enthalpy(KJ/Kg)");
title('H-S diagram');

Printing the variables at various states and output results on command window.

fprintf('\nResults\n' );
fprintf('\nState 1:Superheated steam\n');
fprintf('p1= %f bar\n' ,p1);
fprintf('T1= %f deg C\n',t1);
fprintf('h1= %f KJ/Kg\n',h1);
fprintf('s1= %f KJ/Kg-degC\n' ,s1);

fprintf('State 2: Wet steam\n');
fprintf('p2= %f bar\n' ,p2);
fprintf('T2= %fdeg C\n',t2);
fprintf('h2= %f KJ/Kg\n',h2);
fprintf('s2= %f KJ/Kg-degC\n' ,s2);
fprintf('hf2= %f KJ/Kg\n',hf2);
fprintf('hg2= %f KJ/Kg\n',hg2);
fprintf('sf2= %f KJ/Kg-degC\n',sf2);
fprintf('sg2= %f KJ/Kg-degC\n\n',sg2);

fprintf('State 3:Saturated liquid\n');
fprintf('p3= %f bar\n' ,p3);
fprintf('T3= %fdeg C\n',t3);
fprintf('h3= %f KJ/Kg\n',h3);
fprintf('s3= %f KJ/Kg-degC\n' ,s3);
fprintf('vf3= %f m^3/Kg\n\n' ,vf3);

fprintf('State 4:Compressed liquid\n');
fprintf('p4= %f bar\n' ,p4);
fprintf('T4= %fdeg C\n',t4);
fprintf('h4= %f KJ/Kg\n',h4);
fprintf('s4= %f KJ/Kg-degC\n\n' ,s4);

fprintf('Output Results\n');
fprintf('Pump work %f KJ/Kg \n',w_p);
fprintf('Turbine work %f KJ/Kg \n',w_t);
fprintf('Back work ratio %f\n',back_work_ratio);
fprintf('Net work %f KJ/Kg \n',w_net);
fprintf('Efficiency %f \n',efficiency);

OUTPUT GRAPHS:

Graph 1: T-S Diagram

Graph 2: H-S Diagram

COMMAND WINDOW

Results
>> fprintf('\nState 1:Superheated steam\n');

State 1:Superheated steam
>> fprintf('p1= %f bar\n' ,p1);
p1= 30.000000 bar
>> fprintf('T1= %f deg C\n',t1);
T1= 400.000000 deg C
>> fprintf('h1= %f KJ/Kg\n',h1);
h1= 3231.571027 KJ/Kg
>> fprintf('s1= %f KJ/Kg-degC\n' ,s1);
s1= 6.923259 KJ/Kg-degC
>> fprintf('State 2: Wet steam\n');
State 2: Wet steam
>> fprintf('p2= %f bar\n' ,p2);
p2= 0.050000 bar
>> fprintf('T2= %fdeg C\n',t2);
T2= 32.875490deg C
>> fprintf('h2= %f KJ/Kg\n',h2);
h2= 2110.708212 KJ/Kg
>> fprintf('s2= %f KJ/Kg-degC\n' ,s2);
s2= 6.923259 KJ/Kg-degC
>> fprintf('hf2= %f KJ/Kg\n',hf2);
hf2= 137.765119 KJ/Kg
>> fprintf('hg2= %f KJ/Kg\n',hg2);
hg2= 2560.765104 KJ/Kg
>> fprintf('sf2= %f KJ/Kg-degC\n',sf2);
sf2= 0.476254 KJ/Kg-degC
>> fprintf('sg2= %f KJ/Kg-degC\n\n',sg2);
sg2= 8.393915 KJ/Kg-degC

>> fprintf('State 3:Saturated liquid\n');
State 3:Saturated liquid
>> fprintf('p3= %f bar\n' ,p3);
p3= 0.050000 bar
>> fprintf('T3= %fdeg C\n',t3);
T3= 32.875490deg C
>> fprintf('h3= %f KJ/Kg\n',h3);
h3= 137.765119 KJ/Kg
>> fprintf('s3= %f KJ/Kg-degC\n' ,s3);
s3= 0.476254 KJ/Kg-degC
>> fprintf('vf3= %f m^3/Kg\n\n' ,vf3);
vf3= 0.001005 m^3/Kg

>> fprintf('State 4:Compressed liquid\n');
State 4:Compressed liquid
>> fprintf('p4= %f bar\n' ,p4);
p4= 30.000000 bar
>> fprintf('T4= %fdeg C\n',t4);
T4= 36.935287deg C
>> fprintf('h4= %f KJ/Kg\n',h4);
h4= 140.776056 KJ/Kg
>> fprintf('s4= %f KJ/Kg-degC\n\n' ,s4);
s4= 0.476254 KJ/Kg-degC

>> fprintf('Output Results\n');
Output Results
>> fprintf('Pump work %f KJ/Kg \n',w_p);
Pump work 3.010937 KJ/Kg
>> fprintf('Turbine work %f KJ/Kg \n',w_t);
Turbine work 1120.862815 KJ/Kg
>> fprintf('Back work ratio %f\n',back_work_ratio);
Back work ratio 0.002686
>> fprintf('Net work %f KJ/Kg \n',w_net);
Net work 1117.851878 KJ/Kg
>> fprintf('Efficiency %f \n',efficiency);
Efficiency 36.167131

RESULTS:

  • Pump work for the Rankine cycle is found to be 3.010937 `"KJ/Kg"`
  • Turbine work for the Rankine cycle is found to be 1120.862815 `"KJ/Kg"`
  • Net work for the Rankine cycle is found to be 1117.8518 `"KJ/Kg"`
  • Back work ratio for the Rankine cycle is found to be 0.002686
  • Efficiency for the Rankine cycle is found to be 36.16`%`

CONCLUSION:

  • Program written in Octave to simulate Rankine cycle and T-S diagram and H-S diagram are plotted.
  • Pump work, Turbine work, Net work done, Back work ratio, and efficiency of Rankine cycle are calculated.
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.