Project 2 - Rankine cycle Simulator
AIM: To create a Rankine Cycle simulator using MATLAB.
OBJECTIVE:
- To Simulate a Rankine cycle using Matlab.
- Extracting Steam and water properties from XSteam data (IAPWS IF - 97 standard)
- Calculating all state points of the cycle based on inputs.
- Plotting the 'T' vs 'S' and 'H' vs 'S' plot for the given input.
THEORY:
The Rankine cycle also called the "Rankine vapor cycle", is a thermodynamic cycle that converts heat into mechanical energy. The Rankine cycle is named after William Johnson Macquorn Rankine, a 19th-century Scottish engineer and physicist known for his research on the thermodynamic properties of steam.
Function:
The Rankine cycle is the fundamental operating cycle of all power plants where an operating fluid is continuously evaporated and condensed. The selection of operating fluid depends mainly on the available temperature range. shows the idealized Rankine cycle.
STEPS:
- Pump: Compression of the fluid to high-pressure using a pump
- Boiler: The compressed fluid is heated to the final temperature (which is at boiling point), therefore, it occurs—from liquid to vapor.
- Turbine: Expansion of the vapor in the turbine.
- Condenser: Condensation of the vapor in the condenser (where the waste heat goes to the final heat sink (the atmosphere or a large body of water.

Four processes of the Rankine cycle:
1-2: Isentropic Expansion
Turbine (1-2): Superheated steam enters the Turbine and expands isentropically resulting in the production of work. The shaft of the turbine is connected to the generator. This results in the production of electricity i.e Mechanical energy gets converted into electric energy. Work produced by the turbine,
`Wt=m(h1−h2)K`
2-3: Constant Pressure Heat Rejection
Condenser (2-3): The expanded vapor is then passed through a condenser, where it gets condensed and converts into liquid again. This liquid is again pumped to the boiler.
`Qc=m(h2−h3)K`
3-4: Isentropic Compression by the Pump
Pump (3-4): The water enters the pump in a saturated state. Then the liquid is compressed isentropically until it meets the boiler pressure. Work done by the pump is,
`WP=m(h3−h4)K`
4-1: Constant Pressure Heat Addition
Boiler (4-1): The water enters the boiler as compressed and leaves as superheated from the boiler. Thus the phase changes from liquid to vapor. The heat supplied by the boiler is
`Qb=m(h1−h4)K`
- The efficiency of the Steam Cycle is given by
``η=(Wnet)/Q1=(WT−WP)/Q1``
-
Applying the Steady Flow Energy Equation (SFEE) to all the processes, neglecting the Friction losses and changes in Kinetic & Potential Energy,
- Q1=h1-h4 @Boiler
- Wt=h1-h2 @Turbine
- Q2=h2-h3 @Condenser
- Wp=h4-h3 @Pump
- Steam Rate (SR) or Specific Steam Consumption (SSC) `S.S.C.=3600/(Wnet) kgkWh`

MAIN CODE:
clear all
close all
clc
disp('RANKINE CYCLE Simulator')
disp('1-2 is Isentropic expansion in the Turbine')
disp('2-3 is const. pressure heat rejection by the condenser')
disp('3-4 is Isentropic compression in the pump')
disp('4-1 is const. pressure heat addition by the Boiler')
%input data
p1=input('\nValue of pressure at the turbine inlet, p1(bar)=');
p2=input('enter the pressure at the condenser inlet,p2(bar)=');
t1=input('enter the temperature at the turbine inlet,t1(in Deg c)=');
%At state point1 (Extracting values)
h1=XSteam('h_pt',p1,t1); %h_pT Entalpy as a function of pressure and temperature.
s1=XSteam('s_pt',p1,t1); %s_pT Specific entropy as a function of pressure and temperature (Returns saturated vapour entalpy if mixture.)
%At state point2
s2=s1;
sf2=XSteam('sL_p',p2); %sL_p Saturated liquid entropy
sg2=XSteam('sV_p',p2); %sV_p Saturated vapour entropy
hf2=XSteam('hL_p',p2); %hL_p Saturated liquid enthalpy
hg2=XSteam('hV_p',p2); %hV_p Saturated vapour enthalpy
x2=((s2-sf2)/(sg2-sf2));
h2=hf2+(x2*(hg2-hf2));
%At state point3
p3=p2;
s3=XSteam('sL_p',p3);
h3=XSteam('hL_p',p3);
%At state point4
s4=s3;
p4=p1;
%workdone by Turbine
Wt=h1-h2;
%workdone for pump
v3=XSteam('vL_p',p3); %vL_p Saturated liquid volume
Wp=v3*(p4-p3)*100;
h4=h3+Wp;
%net work
Wnet=Wt-Wp;
%Heat into the system
Qin=h1-h4;
%Heat out the system
Qout=h2-h3;
%thermal efficiency
eff=((Wnet/Qin)*100);
%specific steam consumption | ssc=massflow rate/power(wnet)
ssc=3600/Wnet;
%calculating temperatures at their state points
t3=XSteam('Tsat_p',p3);
t2=t3;
Cp4=XSteam('Cp_ps',p4,s4);
Cv4=XSteam('Cv_ps',p4,s4);
k=Cp4/Cv4;
t4=t3/((p3/p4)^((k-1)/k));
t6=XSteam('Tsat_p',p1);
t5=t6;
%calculating temperatures,entropy and enthalpy
s5=XSteam('sL_p',p1);
s6=XSteam('sV_p',p1);
h5=XSteam('hL_p',p1);
h6=XSteam('hV_p',p1);
T=linspace(1,375,1000);
for i=1:length(T)
sf(i)=XSteam('sL_T',T(i)); %sL_T Saturated liquid entropy
sg(i)=XSteam('sV_T',T(i)); %sV_T Saturated vapour entropy
hf(i)=XSteam('hL_T',T(i)); %hL_T Saturated liquid enthalpy
hg(i)=XSteam('hV_T',T(i)); %hV_T Saturated vapour enthalpy
end
%plotting T-S diagram
figure(1)
hold on
plot(sf,T,'r','linewidth',1)
plot(sg,T,'r','linewidth',1)
plot([s1 s2],[t1 t2],'b','linewidth',2)
plot([s2 s3],[t2 t3],'b','linewidth',2)
plot([s3 s4],[t3 t4],'b','linewidth',2)
plot([s4 s5],[t4 t5],'b','linewidth',2)
plot([s5 s6],[t5 t6],'b','linewidth',2)
plot([s6 s1],[t6 t1],'b','linewidth',2)
text(s1+0.1,t1,'1')
text(s2+0.1,t2,'2')
text(s3+0.1,t3,'3')
text(s4+0.1,t4,'4')
title('TEMP. vs ENTROPY');
xlabel('Entropy(s) (KJ/kg-k)')
ylabel('Temperature (degree C)')
legend('Saturation curve')
%plotting h-S diagram
figure(2)
hold on
plot(sf,hf,'r','linewidth',1)
plot(sg,hg,'r','linewidth',1)
plot([s1 s2],[h1 h2],'b','linewidth',2)
plot([s2 s3],[h2 h3],'b','linewidth',2)
plot([s3 s4],[h3 h4],'b','linewidth',2)
plot([s4 s5],[h4 h5],'b','linewidth',2)
plot([s5 s6],[h5 h6],'b','linewidth',2)
plot([s6 s1],[h6 h1],'b','linewidth',2)
text(s1+0.1,h1,'1')
text(s2+0.1,h2,'2')
text(s3,h3-50,'3')
text(s4,h4+150,'4')
title('ENTHALPY vs ENTROPY');
xlabel('Entropy(s) (KJ/kg-k)')
ylabel('Enthalpy(h) (KJ/kg)')
legend('Saturation curve')
%display Results
disp(' RESULTS')
fprintf('at state point1:\n')
fprintf('p1: %5f bar\n',p1)
fprintf('t1: %5f C\n',t1)
fprintf('h1: %5f KJ/kg\n',h1)
fprintf('s1: %5f KJ/kg-k\n\n',s1)
fprintf('at state point2:\n')
fprintf('p2: %5f bar\n',p2)
fprintf('t2: %5f C\n',t2)
fprintf('h2: %5f KJ/kg\n',h2)
fprintf('s2: %5f KJ/kg-k\n\n',s2)
fprintf('x2: %5f \n\n',x2)
fprintf('at state point3:\n')
fprintf('p3: %5f bar\n',p3)
fprintf('t3: %5f C\n',t3)
fprintf('h3: %5f KJ/kg\n',h3)
fprintf('s3: %5f KJ/kg-k\n\n',s3)
fprintf('at state point4:\n')
fprintf('p4: %5f bar\n',p4)
fprintf('t4: %5f C\n',t4)
fprintf('h4: %5f KJ/kg\n',h4)
fprintf('s4: %5f KJ/kg-k\n\n',s4)
fprintf('Turbine work: %3f KJ/kg\n',Wt)
fprintf('pump work: %5f KJ/kg\n',Wp)
fprintf('Wnet: %5f KJ/kg\n', Wnet)
fprintf('Efficiency: %5f percent\n',eff)
fprintf('ssc: %5f Kg/kwh', ssc)
EXPLANATION:
- The Program begins with clear all, close all,clc.
- Input variables p1, T1, and p2 are given by the input command whose values are entered in the command window while executing the Program.
- Values for Enthalpy & Entropy are extracted as a function of Pressure & Temperature.
- h_pT, s_pT, hL_p, sV_p, etc.... are the default variables whose value is stored in XSteam file.
- Similarly, all the variables for all states are extracted using a suitable format.
At state point: 1
- Pressure, Temperature, Enthalpy, and Entropy for all the State Variables are Extracted as a function of the dependent variable from the XSteam File.
At state point: 2
Condenser inlet where the High-Pressure Steam is converted into Low-Pressure Water hence Dryness Fraction, Enthalpy & Entropy for Saturated Vapour & Saturated Water are considered to Calculate the Specific Enthalpy.
At state point: 3
The water is condensed back to its Saturation Temperature and fed to the Pump, This temperature of water at the exit of the Condenser and entry of the Pump is the same.
At state point: 4
This is Constant Pressure Heat addition, hence pressure is equal to p1, but the temperature increases on heating at Constant Pressure & Constant Volume as our Entropy remains the same and hence Cp/Cv=gamma is considered to find temperature T4.
Finally, Work done Heat Evolved & S.S.C are calculated by basic formulae.
To plot the Saturation Curve, a Temperature range is defined using linspace command and for the overall length of this Temperature values of Enthalpy and Entropy are calculated at every temperature point. The Break in the Saturation Curve separates the Liquid Phase & Vapour Phase.
Now all the necessary data is found, Plotting is done for both T-S & H-S curves using the plot commands. Annotations are assigned using the text commands.
Results of the Cycle Simulation are displayed over the Comand window using fprintf command.
COMMAND WINDOW:
RANKINE CYCLE Simulator
1-2 is Isentropic expansion in the Turbine
2-3 is const. pressure heat rejection by the condenser
3-4 is Isentropic compression in the pump
4-1 is const. pressure heat addition by the Boiler
Value of pressure at the turbine inlet, p1(bar)=30
enter the pressure at the condenser inlet,p2(bar)=0.05
enter the temperature at the turbine inlet,t1(in Deg c)=400
RESULTS
at state point1:
p1: 30.000000 bar
t1: 400.000000 C
h1: 3231.571027 KJ/kg
s1: 6.923259 KJ/kg-k
at state point2:
p2: 0.050000 bar
t2: 32.875490 C
h2: 2110.708212 KJ/kg
s2: 6.923259 KJ/kg-k
x2: 0.814256
at state point3:
p3: 0.050000 bar
t3: 32.875490 C
h3: 137.765119 KJ/kg
s3: 0.476254 KJ/kg-k
at state point4:
p4: 30.000000 bar
t4: 36.935287 C
h4: 140.776056 KJ/kg
s4: 0.476254 KJ/kg-k
Turbine work: 1120.862815 KJ/kg
pump work: 3.010937 KJ/kg
Wnet: 1117.851878 KJ/kg
Efficiency: 36.167131 percent
ssc: 3.220462 Kg/kwh>>
Screenshots:


OUTPUTS:

RESULT:
The Rankine cycle plots have generated by calculating the state points, and efficiency, and the output is printed in the command window.