Project 2 - Rankine cycle Simulator in MATLAB
Objective
Create a Rankine Cycle Simulator using OCTAVE/MATLAB.
RANKINE CYCLE
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 of a heat engine that converts heat into mechanical work while undergoing phase change. It is an idealized cycle in which friction losses in each of the four components are neglected.

PROCESSES
1-2 is ISENTROPIC EXPANSION IN TURBINE
2-3 is CONSTANT PRESSURE HEAT REJECTION BY THE CONDENSOR
3-4 is ISENTROPIC COMPRESSION IN THE PUMP
4-1 is CONSTANT PRESSURE HEAT ADDITION BY THE BOILER
The efficiency of power cycles is defined as
- STANDARD RANKINE CYCLE
- SUPERHEATED RANKINE CYCLE
- REHEATED RANKINE CYCLE
- REGENERATIVE RANKINE CYCLE
NET WORK OUT PUT
WNET=WTURBINE-WPUMP
CODE
close all
clear all
clc
%RANKINE CYCLE
%user input
fprintf(" n RANKINE CYCLE SIMULATOR ");
fprintf("nn1-2 is ISENTROPIC EXPANSION IN TURBINE");
fprintf("n2-3 is CONSTANT PRESSURE HEAT REJECTION BY THE CONDENSOR");
fprintf("n3-4 is ISENTROPIC COMPRESSION IN THE PUMP");
fprintf("n4-1 is CONSTANT PRESSURE HEAT ADDITION BY THE BOILERn");
p1=input("n Enter the Pressure at turbine inlet (in bar): " );
t1=input("n Enter the Temperature at turbine inlet (in Degree Celcius): " );
p2=input("n Enter the Pressure at Condensor inlet (in bar): " );
disp( 'RESULTS')
%steam properties are directly inserted from XSteam library
%state 1(steam at turbine input)
t1sat=XSteam('Tsat_P',p1);%saturation temperature is inserted as per given input pressure p1
sf1=XSteam('sL_P',p1);%saturation liquid entropy is inserted as per given input pressure p1
sg1=XSteam('sV_P',p1);%saturation vapour entropy is inserted as per given input pressure p1
%checking where t1 lies i.e in superheated region , saturation or inside
%in same manner the properties are inserted from the Xsteam
if t1>t1sat
tsup=t1;
h1=XSteam('h_pT',p1,tsup);
s1=XSteam('s_pT',p1,tsup);
else if t1 == t1sat;
h1=XSteam('hV_p',p1);
s1=XSteam('sV_p',p1);
else
disp('Enter Temperature greater than saturation Temperature.')
end
end
%state 2(Turbine Exit and Condensor Inlet)
s2=s1;%it is a constant entropy process .
sg2=XSteam('sV_p',p2);
sf2=XSteam('sL_p',p2);
%cheching where the entropy lies to know the dryness fraction
if s2>sg2
display('Enter a lower value of condenser inlet pressure as exit condition of steam in turbine should not be superheated.');
else if s2 == sg2
t2=XSteam('Tsat_p',p2);
h2=XSteam('hV_p',p2);
x=100;
else
t2=XSteam('T_ps',p2,s2);
h2=XSteam('h_ps',p2,s2);
hf2=XSteam('hL_p',p2);
hg2=XSteam('hV_p',p2);
x=(((s2-sf2)/(sg2-sf2)))*100;
end
end
%state 3(Condesor Exit OR pump entry)
p3=p2;%CONSTANT PRESSURE HEAT REJECTION process
t3=t2;%temperature is constant inside the dome
%inserting properties in the point
h3=XSteam('hL_p',p3);
s3=XSteam('sL_p',p3);
v3=XSteam('vL_p',p3);
t3=XSteam('Tsat_p',p3);
%state 4(PUMP exit or BOiler entry)
p4=p1;%CONSTANT PRESSURE HEAT ADDITION BY THE BOILER
t4sat=XSteam('Tsat_p',p4);
sf4=XSteam('sL_p',p4);
sg4=XSteam('sV_p',p4);
s4=s3;%ISENTROPIC COMPRESSION IN THE PUMP
%Assume Cp and Cv are constant
cp4=XSteam('Cp_ps',p4,s4);
cv4=XSteam('Cv_ps',p4,s4);
g4=cp4/cv4;
o=(g4-1)/g4;
t4=t3*((p4/p3)^o);
%work done by pump
Wp=v3*(p4-p3)*100;
h4=h3+Wp;
%calculation
Wt=h1-h2;%work done by turbine
Qin=h1-h4;%Total heat addition
Qout=h2-h3;%Total heat rejection
Wnet=Wt-Wp;%Net work done
Ntherm=(Wnet/Qin)*100;%Thermal efficiency
SSC=3600/Wnet;%specific steam consumption
BWR=(h3-h4)/(h2-h1);%back work ratio
%display pionts
%satete 1
fprintf("state-1n");
fprintf("p1 is %f barn",p1);
fprintf("T1 is %f degree Cn",t1);
fprintf("h1 is %f kj/kgn",h1);
fprintf("S1 is %f kj/kg-deg C n",s1);
%satete 2
fprintf("state-2n");
fprintf("p2 is %f barn",p2);
fprintf("T2 is %f degree Cn",t2);
fprintf("h2 is %f kj/kgn",h2);
fprintf("S2 is %f kj/kg-deg Cn",s2);
fprintf("Dryness fraction of the steam is %f n", x);
%satete 3
fprintf("state-3n");
fprintf("p3 is %f barn",p3);
fprintf("T3 is %f degree Cn",t3);
fprintf("h3 is %f kj/kgn",h3);
fprintf("S3 is %f kj/kg-deg Cn",s3);
%satete 4
fprintf("state-4");
fprintf("p4 is %f barn",p4);
fprintf("T4 is %f degreen",t4);
fprintf("h4 is %f kj/kgn",h4);
fprintf("S4 is %f kj/kg-deg Cn",s4);
fprintf("HEAT INPUT IS %f (in jolue)n",Qin);
fprintf("HEAT OUTPUT IS %f (in jolue) n",Qout);
fprintf("WORK DONE BY TURBINE IS %f (in jolue)n",Wt);
fprintf("WORK DONE BY PUMP IS %f (in jolue) n",Wp);
fprintf("NET WORK OUTPUT IS %f (in jolue) n",Wnet);
fprintf("CYCLE EFFICIENCY IS %f (in percentage)n",Ntherm);
fprintf("specific steam consumption is %f n",SSC);
fprintf("Back Work Ratio is %fn",BWR);
%plotting the curve of RANKINE CYCLE
%saturation dome of T-S diagram
figure(1)
hold on
%Approx 374 deg-cel critical temperature of water
%creating 1000 equal spaces between 0 to 374
globalT=linspace(0,374,1000);
%running a loop to store entopy point to cereate dome
for i=1:length(globalT)
global_sf(i)=XSteam('sL_T',globalT(i));
global_sg(i)=XSteam('sV_T',globalT(i));
end
%plotiing the dome
plot(global_sf,globalT,'-k')
plot(global_sg,globalT,'-k')
axis([0 10 0 1000]);
xlabel('Entropy (kj/kg-k)');
ylabel('Temperature(Degree Celcius)');
%ploting the isobaric process
hold on
%pump exit to saturation temperature at constant pressure , creating 1000
%equal spaces
Tiso1=linspace(t4,t4sat,1000);
for i=1:length(Tiso1)
siso1(i)=XSteam('s_pT',p2,Tiso1(i));
end
plot(siso1,Tiso1,'-g')
hold on
%Turbine Entry to saturation temperature at constant pressure , creating 1000
%equal spaces
Tiso2=linspace(t1sat,t1,1000);
for i=1:length(Tiso2)
siso2(i)=XSteam('s_pT',p2,Tiso2(i));
end
plot(siso2,Tiso2,'-g')
%plotiing of points
title('T-S DIAGRAM')
plot([s1 s2],[t1 t2],'color','g','linewidth',2,'marker','o','markersize',2)
text(s1,t1,'1')
plot([s2 s3],[t2 t3],'color','g','linewidth',2,'marker','o','markersize',2)
text(s2,t2,'2')
plot([s3 s4],[t3 t4],'color','g','linewidth',2,'marker','o','markersize',2)
text(s3,t3,'3')
plot([s4 sf4],[t4 t4sat],'color','g','linewidth',2,'marker','o','markersize',2)
text(s4,t4,'4')
plot([sf4 sg4],[t4sat t1sat],'color','g','linewidth',2,'marker','o','markersize',2)
plot([sg4 s1],[t4sat t1],'color','g','linewidth',2,'marker','o','markersize',2)
hold off
%plotting of graph
%saturation curve H-S diagram
figure(2)
hold on
%running loop to get indivisual h, s values
for i=1:length(globalT)
global_hf(i)=XSteam('hL_T',globalT(i));
global_hg(i)=XSteam('hV_T',globalT(i));
global_sf(i)=XSteam('sL_T',globalT(i));
global_sg(i)=XSteam('sV_T',globalT(i));
end
%plotting the above h,s values
plot(global_sf,global_hf,'-k')
plot(global_sg,global_hg,'-k')
axis([0 10 0 5000]);
xlabel('Entropy (kj/kg-k)');
ylabel('Enthalpy(kj/kg)');
%plotting points
title('H-S DIAGRAM')
plot([s1 s2],[h1 h2],'color','r','linewidth',2,'marker','o','markersize',2)
text(s1,h1,'1')
plot([s2 s3],[h2 h3],'color','r','linewidth',2,'marker','o','markersize',2')
text(s2,h2,'2')
plot([s3 s4],[h3 h4],'color','r','linewidth',2,'marker','o','markersize',2)
text(s3,h3,'3')
plot([s4 s1],[h4 h1],'color','r','linewidth',2,'marker','o','markersize',2)
text(s4,h4,'4')
hold off
EXPLANATION
- XSteam is an inbuit function in MATLAB.By calling it we can get differrent properties of steam.
- Turbine pressure,temperature entry and exit pressure of steam are taken from user.
- net work done and back work ratio are calculated.
- plot of T-S and H-S diagram are done.
RESULTS
RANKINE CYCLE SIMULATOR
1-2 is ISENTROPIC EXPANSION IN TURBINE
2-3 is CONSTANT PRESSURE HEAT REJECTION BY THE CONDENSOR
3-4 is ISENTROPIC COMPRESSION IN THE PUMP
4-1 is CONSTANT PRESSURE HEAT ADDITION BY THE BOILER
Enter the Pressure at turbine inlet (in bar): 30
Enter the Temperature at turbine inlet (in Degree Celcius): 400
Enter the Pressure at Condensor inlet (in bar): 0.05
RESULTS
state-1
p1 is 30.000000 bar
T1 is 400.000000 degree C
h1 is 3231.571027 kj/kg
S1 is 6.923259 kj/kg-deg C
state-2
p2 is 0.050000 bar
T2 is 32.875490 degree C
h2 is 2110.708212 kj/kg
S2 is 6.923259 kj/kg-deg C
Dryness fraction of the steam is 81.425634
state-3
p3 is 0.050000 bar
T3 is 32.875490 degree C
h3 is 137.765119 kj/kg
S3 is 0.476254 kj/kg-deg C
state-4p4 is 30.000000 bar
T4 is 36.935287 degree
h4 is 140.776056 kj/kg
S4 is 0.476254 kj/kg-deg C
HEAT INPUT IS 3090.794971 (in jolue)
HEAT OUTPUT IS 1972.943093 (in jolue)
WORK DONE BY TURBINE IS 1120.862815 (in jolue)
WORK DONE BY PUMP IS 3.010937 (in jolue)
NET WORK OUTPUT IS 1117.851878 (in jolue)
CYCLE EFFICIENCY IS 36.167131 (in percentage)
specific steam consumption is 3.220462
Back Work Ratio is 0.002686

