Project 2 - Rankine cycle Simulator
Aim : To develope Rankine cycle Simulator using matlab programme .
Objective :
1) Understand basics of rankine cycle and each process involve in it
2) Calculate state points using XSteam.m library
3) develope logic for each process involve in it.
4) Make plot for T-S and H-S diagram
Theory:
The Rankine cycle is an idealized thermodynamic cycle describing the process by which certain heat engines , such as steam turbine or reciprocating steam engines, allow mechanical work to be extracted from a fluid as it moves between a heat source and heat sink The Rankine cycle is named after william john macquorn rankine a Scottish polymath professor at glassglow university .
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 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. 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 an H-S, or numerically, using steam tables or software. 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. Process 3-4 is isentropic expansion.
- Process 4–1: The wet vapour then enters a condensor , where it is condensed at a constant pressure to become a saturated liquid Process 4-1 is constant pressure heat rejection in condenser.
Main Programme :
%% Rankine Cycle Simulator
close all
clear all
clc
%% Rankine Cycle Simulator
disp('RANKINE CYCLE SIMULATOR')
fprintf(' \n')
disp('1-2 is Isentropic Expansion in the Turbine')
disp('2-3 is Constant pressure heat rejection in condensor')
disp('3-4 is Isentropic Compression in Pump')
disp('4-1 is Constant pressure Heat Addition by Boiler')
fprintf(' \n')
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 condensor(in bar):');
fprintf(' \n')
disp('RESULTS')
%% inputs
P4 = P1; P4_dash =P1; P1_dash = P1;
P3 = P2;
%% Temperature points
T2_dash = XSteam('Tsat_p',P2); T2 = T2_dash;
T3 = T2_dash; T4_dash = XSteam('Tsat_p',P1); T1_dash = T4_dash;
%% Entropy (Kj/Kg K)
s1 = XSteam('s_pT',P1,T1); s2 = s1;
s3 = XSteam('sL_p',P2,T2); s4 = s3;
s2_dash = XSteam('sV_p',P2,T2);
s4_dash = XSteam('sL_p',P1,T1);
s1_dash = XSteam('sV_p',P1,T1);
%% dryness fraction
x = (s2-s3)/(s2_dash-s3);
%% getting T4
Cp4 = XSteam('Cp_ps',P4,s4);
Cv4 = XSteam('Cv_ps',P4,s4);
k = Cp4/Cv4;
T4 = T3/((P3/P4)^((k-1)/k));
%% Enthalpy (Kj/Kg K)
h1 = XSteam('h_pT',P1,T1);
h3 = XSteam('hL_p',P2,T2);
h2_dash = XSteam('hV_p',P2,T2);
h2 = h3 + x*(h2_dash-h3);
%% Performance Parameters
W_T = h1-h2; % turbine work
v3 = XSteam('vL_p',P3);
W_P = v3*(P4-P3)*100;% pump work
h4 = h3 + W_P;
W_Net = W_T-W_P; % net work
Q_in = h1-h4;
Efficiency = W_Net/Q_in;
BWR = W_P/W_T;
%% Entropy variation at T1_dash - T1
%specific heat capacity
[T] = linspace(T1_dash,T1,100);
for i = 1:length(T);
T(i) = round(T(i),2);
[Cp(i)] = XSteam('Cp_pT',P1,T(i));
end
[s_1dash1] = entropy1(T,T1_dash,s1_dash,Cp);
%% Entropy variation at T4-T4_dash
%specific heat capacity
[t] = linspace(T4_dash,T1,1000);
for i =1:length(t)
t(i) = round(t(i),2);
s_41(i) = XSteam('s_pT',P1,t(i));
end
%% Entropy variation at T3 -T4
[p]= linspace(P3,P4,100);
T34 = linspace(T3,T4,100);
s34 = linspace(s3,s4,100);
%% saturation line
% for T-S diagram
T_range = linspace(0,400,500);
for i = 1:length(T_range);
sf(i) = XSteam('sL_T',T_range(i));
sg(i) = XSteam('sV_T',T_range(i));
end
% for H-S diagram
for j = 1:length(T_range);
hf(j) = XSteam('hL_T',T_range(j));
hg(j) = XSteam('hV_T',T_range(j));
end
%% Plotting
% T-S diagram
figure(1)
line([s1 s2],[T1 T2],'linewidth',2,'color','r');
line([s2 s3],[T2 T3],'linewidth',2,'color','r');
hold on
plot(s34,T34,'linewidth',2,'color','r');
hold on
line([s4 s4_dash],[T4 T4_dash],'linewidth',2,'color','r')
line([s4_dash s1_dash],[ T4_dash T1_dash],'linewidth',2,'color','r')
plot(s_41,t,'linewidth',2,'color','r')
hold on
plot(sf,T_range,'color','g');
plot(sg,T_range,'color','g');
text(s1+0.1,T1,'1');
text(s2+0.2,T2_dash,'2')
text(s2_dash-0.1,T2_dash-10,'2*')
text(s3-0.4,T2_dash,'3')
text(s4,T4+20,'4');
text(s4_dash+0.1,T4_dash+10,'4*');
legend('T-S diagram')
xlabel('Entropy[Kj/kg k]');
ylabel('Temperature[C]');
title('T-S diagram');
% H-S diagram
figure(2)
line([s1 s2],[h1 h2],'linewidth',2,'color','r');
line([s2 s3],[h2 h3],'linewidth',2,'color','r');
line([s3 s4],[h3 h4],'linewidth',2,'color','r');
line([s4 s1],[h4 h1],'linewidth',2,'color','r');
hold on
plot(sf,hf,'color','g');
plot(sg,hg,'color','g');
text(s1+0.1,h1,'1');
text(s2+0.1,h2,'2');
text(s3,h3-100,'3');
text(s4,h4+200,'4');
legend('H-S diagram');
xlabel('Entropy[Kj/kgk]');
ylabel('Enthalphy[Kj/kg]');
title('H-S diagram');
%% printing Results
% state point 1
disp('At state Point 1:')
fprintf('P1 is:%0.2f Bar\n',P1)
fprintf('T1 is:%0.2f Deg Celcius\n',T1)
fprintf('H1 is:%0.2f Kj/kg\n',h1)
fprintf('S1 is:%0.2f Kj/kgk\n\n',s1)
% state point 2
disp('At state Point 2:')
fprintf('P2 is:%0.2f Bar\n',P2)
fprintf('T2 is:%0.2f Deg Celcius\n',T2)
fprintf('H2 is:%0.2f Kj/kg\n',h2)
fprintf('S2 is:%0.2f Kj/kgk\n',s2)
fprintf('Dryness fraction (x) is: %f \n\n',x)
% state point 3
disp('At state Point 3:')
fprintf('P3 is:%0.2f Bar\n',P3)
fprintf('T3 is:%0.2f Deg Celcius\n',T3)
fprintf('H3 is:%0.2f Kj/kg\n',h3)
fprintf('S3 is:%0.2f Kj/kgk\n\n',s3)
% state point 4
disp('At state Point 4:')
fprintf('P4 is:%0.2f Bar\n',P4)
fprintf('T4 is:%0.2f Deg Celcius\n',T4)
fprintf('H4 is:%0.2f Kj/kg\n',h4)
fprintf('S4 is:%0.2f Kj/kgk\n\n',s4)
% Performance parameters
fprintf('Turbine work is:%0.2f Kj/Kg\n',W_T)
fprintf('Pump work is:%0.2f Kj/Kg\n',W_P)
fprintf('Net work output is:%0.2f Kj/Kg\n',W_Net)
fprintf('Back Work Ratio is:%f \n',BWR)
fprintf('Thermel Efficiency is:%0.2f Percent\n',Efficiency*100)
Function :
%% function for entropy change with temperature
function [s_1dash1] = entropy1(T,T1_dash,s1_dash,Cp);
s_1dash1 = s1_dash + Cp.*log(T./T1_dash);
end
Explanation :
a) first i have calculated temperature points
b) entropy points are extracted using XSteam.m library by using known variable points
c) dryness fraction is calculated using formula
d) T4 is calculated using formula - T4 = T3/((P3/P4)^((k-1)/k)) k = Cp4/Cv4;
e) Enthalphy points are extracted from XSteam.m Library
f)Performance parameters like efficiency,turbine work,pump work,net work,Back work ratio are calculated
g) Entropy variation at T1_dash -T1 is find by function
h)other entropy points are calculated
i) Points for plotting saturation is then extracted from XSteam library
j)Plotting of T-S and H-S digram is done using plot and line commands
k)Printing points in command window is done by Fprintf command
Results:
T-S PLOT

H-S PLOT

Workspace :

ERRORS:
Error No. 1
here ' is used in LHS so after i corrected

Error No. 2
this error occurs due to more decimal after decimal places so i reduced decimal places to 2 using round command.


Error No. 3
here bracket is not given

Error No. 4
here in round command decimal places are not specified

Error No. 5
s_range is not specified

Error No. 6
here only one side of saturation curve is showing

Conclusion :
in this i have studied and developed Rankine cycle simulator using matlab programming