Project 2 - Rankine cycle Simulator
Aim:
To Create a Rankine Cycle Simulator using MATLAB & plotting the corresponding T-s and h-s plots for the given set of inputs.
Objective:
- To create a Rankine cycle simulator using MATLAB.
- The code should calculate the state points of the Rankine Cycle based on user inputs.
- Then plot H-S and the T-S plot should be demonstrated based on the given input.
Rankine Cycle:
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. The figure shows the idealized Rankine cycle.

1-2-3 Isobaric Heat Transfer.
High-pressure liquid enters the boiler from the feed pump (1) and is heated to the saturation temperature (2). Further addition of energy causes evaporation of the liquid until it is fully converted to saturated steam (3).
3-4 Isentropic Expansion.
The vapour is expanded in the turbine, thus producing work which may be converted to electricity. In practice, the expansion is limited by the temperature of the cooling medium and by the erosion of the turbine blades by liquid entrainment in the vapour stream as the process moves further into the two-phase region. Exit vapour qualities should be greater than 90%.
4-5 Isobaric Heat Rejection.
The vapour-liquid mixture leaving the turbine (4) is condensed at low pressure, usually in a surface condenser using cooling water. In well-designed and maintained condensers, the pressure of the vapour is well below atmospheric pressure, approaching the saturation pressure of the operating fluid at the cooling water temperature.
5-1 Isentropic Compression.
The pressure of the condensate is raised in the feed pump. Because of the low specific volume of liquids, the pump work is relatively small and often neglected in thermodynamic calculations.
The pressure-enthalpy (p-h) and temperature-entropy (T-s) diagrams of this cycle are given in Figure 2.

Enthalpy.
The enthalpy is the amount of heat content present in a system. It was denoted by h
Entropy:
Entropy is defined as a measure of randomness or disorder of a system. It was denoted by's
Formulae:
Formulae:
1) For boiler
Q1 = h1 - hf4
2) For turbine:
WT = h1-h2
3) For condenser
Q2 = h2-hf3
4) For the feed pump
Wp = hf4 - hf3
5) Efficiency of the Rankine cycle

When hf4 - hf3 value is very small then,

The steam phase diagram
The data provided in the steam tables can also be expressed in a graphical form. The image bellow illustrates the relationship between the enthalpy and temperature of the various states of water and steam; this is known as a phase diagram.

Based on the nature of the steam in the turbine inlet, the three types of condition is proposed. The three conditions are
1) Wet steam (x<1)
2) Saturated steam (x=1)
3) Super saturated steam (x>1)
The x value is defined as the 'dryness fraction based on the dryness fraction value the conditions can be classified. The value can be calculated by using the formula given below.
hi = hfi + x(hfgi) where is the position in which all data are known.
Rankine Cycle simulator code:
clear all
close all
clc
fprintf('Rakine Cycle Simulator\n')
fprintf('1-2 is Isentropic Expansion in Turbine\n')
fprintf('2-3 is Constant Pressure Heat Rejection in condensor\n')
fprintf('3-4 is Isentropic Compression in pump\n')
fprintf('4-1 is Constant Pressure Heat Rejection in Boiler\n')
% Input
% P1 Turbine Inlet temperature
P1 = input('turbine inlet pressure (bar)');
T1 = input('turbine inlet temperature (degree c)');
P2 = input('turbine outlet pressure (bar)');
% State 1 points (Turbine inlet)
H1 = XSteam('h_pT',P1,T1);
S1 = XSteam('s_pT',P1,T1);
% State 2 points (Turbine Outlet)
T2 = XSteam('Tsat_p',P2);
S2 = S1;
sf2 = XSteam('sL_p',P2);
sg2 = XSteam('sV_p',P2);
hf2 = XSteam('hL_p',P2);
hg2 = XSteam('hV_p',P2);
X2 = ((S2-sf2)/(sg2-sf2));
H2 = hf2 + (X2*(hg2-hf2));
% State 3 point (Condenser Outlet)
P3 = P2;
T3 = T2;
S3 = XSteam('sL_p',P3);
H3 = XSteam('hL_p',P3);
V3 = XSteam('vL_p',P3);
% State 4 point (Pump Outlet)
P4 = P1;
S4 = S3;
cp = XSteam('Cp_ps',P4,S4);
cv = XSteam('Cv_ps',P4,S4);
g = cp/cv;
T4 = T3*((P3/P4)^((1-g)/g));
W_P = V3*(P4-P3)*100;
H4 = H3 + W_P;
T5 = XSteam('Tsat_p',P4);
S5 = XSteam('sL_p',P4);
T6 = T5;
S6 = XSteam('sV_T',T6);
% Calculation of work done, heat & efficiency
W_t = H1 - H2;
W_net = W_t - W_P;
Q_in = H1 - H4;
Q_out = H2 - H3;
Efficiency = W_net/Q_in;
% Back work ratio calculation.
SSC = 3600/W_net;
% Plotting
% T-S diagram
a = linspace(0,374,500);
figure(1)
hold on
for i = 1:length(a)
plot(XSteam('sL_T',a(i)),a(i),'.','Color','r')
plot(XSteam('sV_T',a(i)),a(i),'.','Color','r')
end
plot([S1 S2 S3 S4 S5 S6 S1],[T1 T2 T3 T4 T5 T6 T1],'Color','K','LineWidth',3)
text(S1,T1,'1','Color','b')
text(S2,T2,'2','Color','b')
text(S3,T3,'3','Color','b')
text(S4,T4,'4','Color','b')
text(S5,T5,'5','Color','b')
text(S6,T6,'6','Color','b')
title('T-S Diagram')
xlabel('Entropy (KJ/KgK)')
ylabel('Temperature (Deg Celcius)')
hold off
% Plotting
% H-S Diagram
figure(2)
hold on
plot([S1 S2 S3 S4 S1],[H1 H2 H3 H4 H1],'Color','K','LineWidth',3)
text(S1,H1,'1','Color','b')
text(S2,H2,'2','Color','b')
text(S3,H3,'3','Color','b')
text(S4,H4,'4','Color','b')
for i = 1:length(a)
plot(XSteam('sL_T',a(i)),XSteam('hL_T',a(i)),'.','Color','r')
plot(XSteam('sV_T',a(i)),XSteam('hV_T',a(i)),'.','Color','r')
end
title('H-S Diagram')
xlabel('Entropy (KJ/KgK)')
ylabel('Enthalpy (KJ/KgK)')
hold off
% Output
fprintf(' RESULTS\n')
fprintf('At state point 1: At state point 3: \n')
fprintf('%s %.2f','P1 is : ',P1,' Bar')
fprintf('%s %.2f',' P3 is : ',P3,' Bar')
fprintf('\n')
fprintf('%s %.2f','T1 is : ',T1,' Degree celcius')
fprintf('%s %.2f',' T3 is : ',T3,' Degree celcius')
fprintf('\n')
fprintf('%s %.2f','H1 is : ',H1,' KJ/Kg')
fprintf('%s %.2f',' H3 is : ',H3,' KJ/Kg')
fprintf('\n')
fprintf('%s %.2f','S1 is : ',S1,' KJ/Kg')
fprintf('%s %.2f',' S3 is : ',S3,' KJ/Kg')
fprintf('\n')
fprintf('\n')
fprintf('At state point 2: At state point 4: \n')
fprintf('%s %.2f','P2 is : ',P2,' Bar')
fprintf('%s %.2f',' P4 is : ',P4,' Bar')
fprintf('\n')
fprintf('%s %.2f','T2 is : ',T2,' Degree celcius')
fprintf('%s %.2f',' T4 is : ',T4,' Degree celcius')
fprintf('\n')
fprintf('%s %.2f','H2 is : ',H2,' KJ/Kg')
fprintf('%s %.2f',' H4 is : ',H4,' KJ/Kg')
fprintf('\n')
fprintf('%s %.2f','S2 is : ',S2,' KJ/Kg')
fprintf('%s %.2f',' S4 is : ',S4,' KJ/Kg')
fprintf('\n')
fprintf('\n')
fprintf('%s %.2f','Wt is : ',W_t,'KJ/Kg')
fprintf('\n')
fprintf('%s %.2f','WP is : ',W_P,'KJ/Kg')
fprintf('\n')
fprintf('%s %.2f','Wnet is : ',W_net,'KJ/Kg')
fprintf('\n')
fprintf('%s %.2f','Ntherm is : ',Efficiency,'%')
fprintf('\n')
fprintf('%s %.2f','S.S.C is : ',SSC,'KJ/KWh')
fprintf('\n')
Code Explanation:
- Initially, the different process in a Rankine cycle is displayed. The input parameters are obtained from the given question.
- The different parameters at the turbine inlet conditions are derived. The various constant values are obtained from the steam table.
- Here XStream library is used for obtaining the steam table votes Then, the different parameters at turbine outlet conditions are derived.
- In the condenser outlet condition, different parameters are derived with the help of the steam library The various values at the pump outlet condition are also calculated Once the different values of different conditions are obtained, we can proceed further to calculating the main resultant values.
- The work done input and output heat and the efficiency of the Rankine cycle are calculated.
- The back work ratio is also calculated.
- From all the values obtained the h-s plot and the t-s plots are drawn.
- All the values calculated are shown under the result.
Output
Result Values:


Result Plots:
T-S Plots:

H-S Plots:

Conclusion:
Thus the Rankine cycle simulator was made using MATLAB. The result value for the input parameters & plots are shown as per the requirement.