Project 2 - Rankine cycle Simulator
Rankine cycle Simulator
AIM: To create a Rankine cycle simulator and code the program which can solve the state points of the Rankine cycle.
Objective:
- Create a Rankine cycle simulator.
- Plot T vs S and H vs S for a given set of points.
Theory:
The Rankine cycle is an idealized thermodynamic cycle describing the process by which certain heat engines, such as steam turbines or reciprocating steam engines, allow mechanical work to be extracted from a fluid as it moves between a heat source and heat sink. Heat energy is supplied to the system via a boiler where the working fluid (typically water) is converted to a high-pressure gaseous state (steam) in order to turn a turbine. After passing over the turbine the fluid is allowed to condense back into a liquid state as waste heat energy is rejected before being returned to the boiler, completing the cycle. Friction losses throughout the system are often neglected for the purpose of simplifying calculations as such losses are usually much less significant than thermodynamic losses, especially in larger systems.
There are four processes in the Rankine cycle. The states are identified by numbers in the T-s diagram.
- Process 1–2: The working fluid is pumped from low to high pressure. As the fluid is a liquid at this stage, the pump requires little input energy.
In other words, Process 1-2 is [Isentropic compression]
- Process 2–3: The high-pressure liquid enters a boiler, where it is heated at constant pressure by an external heat source to become a dry saturated vapour. The input energy required can be easily calculated graphically, using steam tables.
In other words, Process 2-3 is [Constant pressure heat addition in boiler]
- Process 3–4: The dry saturated vapour expands through a turbine, generating power. This decreases the temperature and pressure of the vapour, and some condensation may occur. The output in this process can be easily calculated using the chart or tables noted above.
In other words, Process 3-4 is [Isentropic expansion]
- Process 4–1: The wet vapour then enters a condenser, where it is condensed at a constant pressure to become a saturated liquid.
In other words, Process 4-1 is [Constant pressure heat rejection in condenser]

Entropy: Entropy, the measure of a system's thermal energy per unit temperature that is unavailable for doing useful work. Because work is obtained from ordered molecular motion, the amount of entropy is also a measure of the molecular disorder, or randomness, of a system.
Enthalpy: Enthalpy is a property of a thermodynamic system, defined as the sum of the system's internal energy and the product of its pressure and volume, H = U + pV. It is a convenient state function standardly used in many measurements in chemical, biological, and physical systems at a constant pressure.
Equations:
GOVERNING EQUATION:
1)Turbine Work(WT):
WT = H1 - H2
2)Pump Work(WP):
WP = H4 - H3
3)Net Work(WNET):
WNET = WT - WP
4)Thermal Efficiency(ηη):
ηη = WNET/(H1 - H4)
5)Back Work Ratio(BWR):
BWR = WP /WT
6)Specific Steam Conductivity(S.S.C):
S.S.C = 3600/WT
Where,
H1,H2,H3,H4 are the enthalpy at the respective state points.
Variables:
- h is enthalpy(kj/kg)
- v is specific volume
- s is entropy(kj/kg)
MATLAB CODE :
%PROGRAM FOR RANKINE CYCLE SIMULATOR
clear all
close all
clc
disp(' RANKINE CYCLE SIMULATOR ');
disp('1-2 is Isentropic Expansion in the Turbine');
disp('2-3 is Constant Pressure Heat Rejection by the Condenser');
disp('3-4 is Isentropic Compression in the Pump');
disp('4-1 is Constant Pressure Heat Addition by the Boiler');
fprintf('n');
%inputs to be specified
P1 = input('Enter the Pressure at the Turbine Inlet(in bar): ');
T1 = input('Enter the Temperature at the Turbine Inlet(in Degree Celcius): ');
P2 = input('Enter the Pressure at the Condenser (in bar): ');
%calculating the value of P,T,H,S at each state points
%At state point 1
H1 = XSteam('h_pT',P1,T1);
S1 = XSteam('s_pT',P1,T1);
H_L1 = XSteam('hL_p',P1);
H_G1 = XSteam('hV_p',P1);
S_L1 = XSteam('sL_p',P1);
S_G1 = XSteam('sV_p',P1);
T_sat1 = XSteam('Tsat_p',P1);
%At state point 2
S2 = S1;
S_L2 = XSteam('sL_p',P2);
S_G2 = XSteam('sV_p',P2);
D = (S2-S_L2)/(S_G2-S_L2); %Calculating the dryness fraction
H_L2 = XSteam('hL_p',P2);
H_G2 = XSteam('hV_p',P2);
H2 = H_L2 + D*(H_G2 - H_L2); %Calculating the enthalpy at point 2
T2 = XSteam('T_ph',P2,H2);
T_sat2 = XSteam('Tsat_p',P2);
%At state point 3
P3 = P2;
T3 = T2;
H3 = H_L2;
S3 = S_L2;
%At state point 4
P4 = P1;
S4 = S3;
T4 = XSteam('T_ps',P4,S4);
H4 = XSteam('H_ps',P4,S4);
%Calculating Work and Efficiency of the Rankine Cycle
%Turbine Work
W_T = H1 - H2;
%Pump Work
W_P = H4 - H3;
%Net Work
W_NET = W_T - W_P;
%Thermal Efficiency of the Rankine Cycle
EFF = (W_NET/(H1 - H4))*100 ;
%Back Work Ratio
BWR = W_P/W_T;
%Specific Steam Conductivity
SSC = 3600/W_T;
%Displaying the results
%Values of state point 1
disp(' RESULTS ');
disp('At State point 1');
fprintf('P1 is : %.2f Bar n',P1);
fprintf('T1 is : %.2f Deg Celcius n',T1);
fprintf('H1 is : %.2f KJ/kg n',H1);
fprintf('S1 is : %.2f KJ/kgK n',S1);
fprintf('n');
%Values of state point 2
disp('At State point 2');
fprintf('P2 is : %.2f Bar n',P2);
fprintf('T2 is : %.2f Deg Celcius n',T2);
fprintf('H2 is : %.2f KJ/kg n',H2);
fprintf('S2 is : %.2f KJ/kgK n',S2);
fprintf('n');
%Values of state point 3
disp('At State point 3');
fprintf('P3 is : %.2f Bar n',P3);
fprintf('T3 is : %.2f Deg Celcius n',T3);
fprintf('H3 is : %.2f KJ/kg n',H3);
fprintf('S3 is : %.2f KJ/kgK n',S3);
fprintf('n');
%Values of state point 4
disp('At State point 4');
fprintf('P4 is : %.2f Bar n',P4);
fprintf('T4 is : %.2f Deg Celcius n',T4);
fprintf('H4 is : %.2f KJ/kg n',H4);
fprintf('S4 is : %.2f KJ/kgK n',S4);
fprintf('n');
%Turbine Work
fprintf('Wt is : %.2f KJ/kg n',W_T);
%Pump Work
fprintf('Wp is : %.2f KJ/kg n',W_P);
%Net Work
fprintf('Wnet is : %.2f KJ/kg n',W_NET);
%Thermal Efficiency
fprintf('Ntherm is : %.2f Percent n',EFF);
%Specific Steam Conductivity
fprintf('S.S.C is : %.2f kg/KWh n',SSC);
%Back Work ratio
fprintf('Back Work Ratio is : %f n',BWR);
%plotting of T-S curve
t = linspace(0,373.5,200);
figure(1)
hold on
for i = 1:length(t)
plot(XSteam('sL_T',t(i)),t(i),'r.')
plot(XSteam('sV_T',t(i)),t(i),'r.')
end
plot([S1 S2],[T1 T2],'linewidth',2,'color','black')
text(S1,T1,'1','FontSize',10)
if D>1
T3 = T_sat2;
plot([S2 S_G2 S3 S4],[T2 T_sat2 T3 T4],'linewidth',2,'color','black')
T2 = T_sat2;
text(S2,T2,'2','FontSize',10)
text(S3,T3,'3','FontSize',10)
else
plot([S2 S3 S4],[T2 T3 T4],'linewidth',2,'color','black')
text(S2,T2,'2','FontSize',10)
text(S3,T3,'3','FontSize',10)
end
n = linspace(T1,T2,500);
for i = 1:length(n)
plot(XSteam('s_pT',P1,n(i)),n(i),'.','linewidth',2,'color','black')
end
plot([S_L1 S_G1],[T_sat1 T_sat1],'linewidth',2,'color','black')
text(S_L1,T_sat1,'4','FontSize',10)
xlabel('Entropy(kJ/kg-K)')
ylabel('Temperature(k)')
title('T-S Graph')
%Plotting of H-S Curve
figure(2)
hold on
for i = 1:length(t)
plot(XSteam('sL_T',t(i)),XSteam('hL_T',t(i)),'r.')
plot(XSteam('sV_T',t(i)),XSteam('hV_T',t(i)),'r.')
end
plot([S1 S2 S3 S4 S1],[H1 H2 H3 H4 H1],'linewidth',2,'color','black')
text(S1,H1,'1','FontSize',10)
text(S2,H2,'2','FontSize',10)
text(S3,H3,'3','FontSize',10)
text(S4,H4,'4','FontSize',10)
xlabel('Entropy(kJ/kg-K)')
ylabel('Enthalpy(kJ/kg)')
title('H-S Graph')
EXPLNATION :
- Initially, we display the different processes from 1-4 by using the disp command.
- After that, we assign the values to input parameters like P1,T1 and P2.
- Then we calculate the value of pressure,ṭemperature, enthalpy, and entropy at different state points by using the XSteam library.
- Then we find the values of Turbine work, Pump work,Net work ,Thermal Efficiency,Back Work Ratio and Specific Steam Conductivity by using their suitable formulas.
- We print the values of all the quantities that we have found in the earlier steps by using the fprintf command.
- At last, we plot the curve of T-S and H-S for the Rankine Cycle
OUTPUT:
The below figure shows the output in the command window.



The below curve shows the T-S Graph of the Rankine Cycle.

The below curve shows the H-S Graph of the Rankine Cycle.

CONCLUSION:
Thus we have obtained the values of P,T,H and S for different state points and also the work, Efficiency,Back work ratio and Specific steam conductivity was calculated.Also the plot of T-S and H-S of Rankine Cycle was drawn.
ERRORS :
1. typing errors like use of capital, small letters,units were obtained that were corrected after observation.
2. Initially the desired plot for T-S curve was not obtained as shown in the figure below :

To overcome this error i used if else condition in the program for dryness fraction (D) as shown below:
