Project 2 - Rankine cycle Simulator
Aim:
To create rankine cycle simulator using MATLAB. To demonstrate the T-s and h-s plots for the given set of inputs.
Objectives:
- To create rankine cycle simulator using MATLAB.
- The code should calculate the state points of the Rankine Cycle (any type of your choice) based on user inputs.
- The h-s plot and the T-s plot should be demonstrated based on the given input.
Rankine cycle:
Rankine cycle is a model created for analysing the efficiency of the steam turbine systems. The rankine cycle is designed with many assumptions. The rankine cycle is also used to analyse the performance of reciprocating steam engine. Rankine cycle is also used to measure the characteristics of various parameters in thermal power plant. The rankine cycle has four major components. They are, a) Turbine, b) Boiler, c) Pump and d) Condenser. The heat input is converted into work output in the rankine cycle. The heat input is given to the boiler and the work output is obtained from the turbine.
- Initially, the working fluid is pumped from low pressure to high pressure.
- The high pressure fluid enters into the boiler where the fluid is heated to made it as a saturated vapour. The heat input is provided to the boiler from some heat source.
- The dry saturated vapuor is used to run the turbine to get the power output. The dry saturated vapour expands on the turbine to rotate it.
- The wet vapour from the turbine then enters into the condenser where it is condensed to the constant pressure and changed into saturated form.

Various process in rankine cycle:
Process 1-2 : Isentropic compression.
Process 2-3 : Constant pressure heat addition in boiler.
Process 3-4 : Isentropic expansion.
Process 4-1 : Constant pressure heat rejection in condenser.
Formulae:
1) For boiler:
Q1 = h1 - hf4
2) For turbine:
WT = h1 -h2
3) For condeser
Q2 = h2 - hf3
4) For the feed pump
Wp = hf4 - hf3
5) Efficiency of the rankine cycle
η=(h1−h2)−(hf4−hf3)h1−hf4η=(h1-h2)-(hf4-hf3)h1-hf4
When hf4 - hf3 value is very small then,
η=h1−h2h1−hf4η=h1-h2h1-hf4
Steam conditions:
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 'x' value can be calculated by using the formula given below,
hi = hfi + x(hfgi) where i is the position in which all datas are known.
RANKINE CYLCE PROGRAMME CODES:
clear
close
clc
fprintf('RANKINE CYCLE PROCESS FLOW \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 addition in boiler\n')
%Inputs
Pressure1 = input('turbine inlet pressure (bar)');
Temperature1 = input('turbine inlet temperature (degree c)');
Pressure2 = input('turbine outlet pressure (bar)');
%Turbine inlet condition
Temperature1_sat = XSteam('Tsat_p',Pressure1);
if Temperature1>Temperature1_sat
h1 = XSteam('h_pt',Pressure1,Temperature1);
s1 = XSteam('s_pt',Pressure1,Temperature1);
elseif Temperature1 == Temperature1_sat
h1 = XSteam('hV_p',Pressure1);
s1 = XSteam('sV_p',Pressure1);
else
fprintf('Enter higher temperature value')
end
%Turbine outlet condition
s2 = s1;
s2_sat = XSteam('sV_p',Pressure2);
if s2<s2_sat
s2_f = XSteam('sL_p',Pressure2);
s2_g = XSteam('sV_p',Pressure2);
x2 = (s2 - s2_f)/(s2_g - s2_f);
h2_f = XSteam('hL_p',Pressure2);
h2_g = XSteam('hV_p',Pressure2);
h2 = h2_f + x2*(h2_g - h2_f);
Temperature2 = XSteam('Tsat_p',Pressure2);
else
x2 = 1;
h2 = XSteam('hV_p',Pressure2);
Temperature2 = XSteam('Tsat_p',Pressure2);
end
%Condensor outlet condition
Pressure3 = Pressure2;
Temperature3 = XSteam('Tsat_p',Pressure3);
h3 = XSteam('hL_p',Pressure3);
s3 = XSteam('sL_p',Pressure3);
v3 = XSteam('vL_p',Pressure3);
%Pump outlet condition
s4 = s3;
Pressure4 = Pressure1;
v4 = XSteam('v_ps',Pressure4,s4);
Cp = XSteam('Cp_ps',Pressure4,s4);
Cv = XSteam('Cv_ps',Pressure4,s4);
g = Cp/Cv;
Temperature4 = Temperature3*((Pressure3/Pressure4)^((1-g)/g));
W_p = v3*(Pressure4-Pressure3)*100;
h4 = h3 + W_p;
Temperature5 = XSteam('Tsat_p',Pressure4);
s5 = XSteam('sL_p',Pressure4);
Temperature6 = Temperature5;
s6 = XSteam('sV_T',Temperature6);
%Calculation of work done, heat and 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],[Temperature1 Temperature2],'color','k','linewidth',2)
text(s1,Temperature1,' 1')
text(s2,Temperature2,' 2')
plot([s2 s6],[Temperature1 Temperature6],'color','k','linewidth',2)
plot([s6 s5],[Temperature6 Temperature6],'color','k','linewidth',2)
plot([s5 s4],[Temperature6 Temperature4],'color','k','linewidth',2)
text(s4,Temperature4,' 4')
plot([s4 s3],[Temperature4 Temperature3],'color','k','linewidth',2)
text(s3,Temperature3,' 3')
plot([s3 s1],[Temperature3 Temperature3],'color','k','linewidth',2)
title('T-S diagram')
xlabel('Entropy (KJ/KgK)')
ylabel('Temperature (Deg celcius)')
%H-S diagram
figure (2)
hold on
plot([s1 s2],[h1 h2],'color','k','linewidth',2)
text(s1,h1,' 1')
text(s2,h2,' 2')
plot([s2 s3],[h2 h3],'color','k','linewidth',2)
plot([s3 s4],[h3 h4],'color','k','linewidth',2)
text(s3,h3,' 3')
text(s4,h4,' 4')
plot([s4 s1],[h4 h1],'color','k','linewidth',2)
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/kg)')
%Output
fprintf(' RESULTS\n')
fprintf('At state point 1: At state point 3:\n')
fprintf('%s %.2f','Pressure1 is : ',Pressure1,' Bar')
fprintf('%s %.2f',' Pressure3 is : ',Pressure3,' Bar')
fprintf('\n')
fprintf('%s %.2f','Temperature1 is : ',Temperature1,' Deg celcius')
fprintf('%s %.2f',' Temperature3 is : ',Temperature3,' Deg 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/KgK')
fprintf('%s %.2f',' S3 is : ',s3,' KJ/KgK')
fprintf('\n\n')
fprintf('At state point 2: At state point 4:\n')
fprintf('%s %.2f','Pressure2 is : ',Pressure2,' Bar')
fprintf('%s %.2f',' Pressure4 is : ',Pressure4,' Bar')
fprintf('\n')
fprintf('%s %.2f','Temperature2 is : ',Temperature2,' Deg celcius')
fprintf('%s %.2f',' Temperature4 is : ',Temperature4,' Deg 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/KgK')
fprintf('%s %.2f',' S4 is : ',s4,' KJ/KgK')
fprintf('\n\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,' Percent')
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 user.
- The different parameters at the turbine inlet condition is derived. The various constant values are obtained from the steam table.
- Here XSteam library is used for obtaining the steam table values.
- Then, the different parameters at turbine outlet condition is derived.
- In condenser outlet condition, different parameters are derived with the help of XSteam library.
- The various values at the pump outlet condition are also calculated.
- Once the different values at different conditions are obtained, we can proceed further for calculating the main resultant values.
- The work done, input and output heat and the efficiency of the rankine cycle is calculated.
- The back work ratio is also calculated.
- From all the values obtained, the h-s plot and the t-s plot were drawn
- All the values calculated are shown under result.
Input values:
- Turbine Inlet temperature = 400° C
- Turbine Inlet Pressure = 30 bars
- Turbine Outlet Pressure = 0.05 bars = Condenser Inlet Pressure.
Output:
The various result values calculated for the given input is shown below

GRAPH FOR T-S DIAGRAM HAS BEEN SHOWN BELOW:

GRAPH FOR H-S DIAGRAM HAS BEEN SHOWN BELOW:

Conclusion:
- Thus the rankine cycle was made using MATLAB. The result values for the input parameters and the plots are shown.
- This is also bit like nasa project and using some text book for learning rankine cycle process and formula used in above programme codes.