Project 2 - Rankine cycle Simulator
Aim:
To create Rankine Cycle Simulator using 'MATLAB'
Rankine Cycle:
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
There are four processes in the Rankine cycle. The states are identified by numbers (in brown) 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 enthalpy–entropy chart (h–s chart, or Mollier diagram), 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 condenser, where it is condensed at a constant pressure to become a saturated liquid. Process 4-1 is constant pressure heat rejection in condenser.
In an ideal Rankine cycle the pump and turbine would be isentropic, i.e., the pump and turbine would generate no entropy and hence maximize the net work output. Processes 1–2 and 3–4 would be represented by vertical lines on the T–s diagram and more closely resemble that of the Carnot cycle. The Rankine cycle shown here prevents the state of the working fluid from ending up in the superheated vapor region after the expansion in the turbine, which reduces the energy removed by the condensers.
The actual vapor power cycle differs from the ideal Rankine cycle because of irreversibilities in the inherent components caused by fluid friction and heat loss to the surroundings; fluid friction causes pressure drops in the boiler, the condenser, and the piping between the components, and as a result the steam leaves the boiler at a lower pressure; heat loss reduces the net work output, thus heat addition to the steam in the boiler is required to maintain the same level of net work output.
MATLAB CODE:
clear all
close all
clc
%displaying
disp('RANKINE CYCLE');
disp('1-2 is Isentropic Expantion in the turbine');
disp('2-3 is Constant preassure heat removal in the condenser');
disp('3-4 is Isentropic compression in the pump');
disp('4-1 is constant pressure heat addition in the boiler');
%Input data
p1= input('n value of pressure at turbine inlet, p1(in bar) = ');
T1= input('n value of temperature at turbine inlet, T1(in degree.C) = ');
p2= input('n value of temperature at condenser inlet, p2(in bar) = ');
%Extracting data_defining variables
%State 1
h1 = XSteam('h_pT', p1, T1);
s1 = XSteam('s_pT', p1, T1);
%State 2
s2 = s1;
sf2 = XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
x2 = (s2 - sf2)/(sg2 - sf2);
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);
h2 = hf2 + (x2*(hg2 - hf2));
%State 3
p3 = p2;
s3 = XSteam('sl_p',p3);
h3 = XSteam('hL_p',p3);
%State 4
s4 = s3;
p4 = p1;
%Workdone by turbine
Wt = h1 - h2;
%Workdone to run pump
v3 = XSteam('vL_p', p3);
Wp = v3*(p4 - p3)*100;
h4 = h3 + Wp;
%Net work
wnet = Wt - Wp;
%Heat into the system
Qin = h1 - h4;
%Heat out of the system
Qout = h2 - h3;
%Thermal Efficiency
eff = (wnet/Qin)*100;
%Specific steam consumption
% SSC = mass flow rate/power
SSC = (3600/wnet);
%Calculating temperatures at the 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));
% Calculating temperature, Entropy and Enthalpy at the vapour and liquid
% Line for plotting
T6 = XSteam('Tsat_p', p1);
s5 = XSteam('sL_P', p1);
s6 = XSteam('sV_p', p1);
h5 = XSteam('hL_p', p1);
h6 = XSteam('hV_p', p1);
T5 = T6;
% Plotting the saturation curve
T = linspace(1,375,1000);
for i = 1:length(T)
sf(i) = XSteam('sL_T', T(i));
sg(i) = XSteam('sV_T', T(i));
hf(i) = XSteam('hL_T', T(i));
hg(i) = XSteam('hV_T', T(i));
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], 'k', 'LineWidth',2)
plot([s2 s3], [T2 T3], 'k', 'LineWidth',2)
plot([s3 s4], [T3 T4], 'k', 'LineWidth',2)
plot([s4 s5], [T4 T5], 'k', 'LineWidth',2)
plot([s5 s6], [T5 T6], 'k', 'LineWidth',2)
sc1 = linspace(s6, s1, 1000);
for l = 1:length(sc1)
Tc1(1) = XSteam('T_ps', p1, sc1(1));
end
plot(sc1, Tc1,'k', 'LineWidth',2)
text(s1+0.1, T1, '1')
text(s2+0.1, T2, '2')
text(s3, T3-20, '3')
text(s4, T4+20, '4')
title('Temp vs Entropy plot')
xlabel('Entropy, S(kj/kgk)')
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], 'k', 'LineWidth', 2)
plot([s2 s3], [h2 h3], 'k', 'LineWidth', 2)
plot([s3 s4], [h3 h4], 'k', 'LineWidth', 2)
hc = linspace(h4, h5, 100);
for k = 1:length(hc)
sch(k) = XSteam('s_ph', p1, hc(k));
end
plot(sch, hc, 'k', 'LineWidth', 2)
plot([s5 s6], [h5 h6], 'k', 'LineWidth', 2)
for m = 1:length(sc1)
hc1(m) = XSteam('h_ps', p1, sc1(m));
end
plot(sc1, hc1, 'k', 'LineWidth', 2)
text(s1+0.1, h1,'1')
text(s2+0.1, h2,'2')
text(s3, h3-100,'3')
text(s4, h4+200,'4')
title('Enthalpy vs Entropy plot')
xlabel('Entropy, S(kj/kgk)')
ylabel('Enthalpy, H(kj/kgk)')
legend('Saturation curve','location','northwest')
%Displaying Results
disp('RESULTS');
disp('State point 1')
fprintf('At state point 1:n');
fprintf('p1 : %8.3f barn', p1);
fprintf('T1 : %8.3f Cn', T1);
fprintf('h1 : %8.3f kj/kn', h1);
fprintf('s1 : %8.3f kj/kn', s1);
disp('State point 2')
fprintf('At state point 2:n');
fprintf('p2 : %8.3f barn', p2);
fprintf('T2 : %8.3f Cn', T2);
fprintf('h2 : %8.3f kj/kn', h2);
fprintf('s2 : %8.3f kj/kn', s2);
fprintf('x2 : %8.3fnn', x2)
disp('State point 3')
fprintf('At state point 3:n');
fprintf('p3 : %8.3f barn', p3);
fprintf('T3 : %8.3f Cn', T3);
fprintf('h3 : %8.3f kj/kn', h3);
fprintf('s3 : %8.3f kj/kn', s3);
disp('State point 4')
fprintf('At state point 4:n');
fprintf('p4 : %8.3f barn', p4);
fprintf('T4 : %8.3f Cn', T4);
fprintf('h4 : %8.3f kj/kn', h4);
fprintf('s4 : %8.3f kj/kn', s4);
disp('Wt, Wp, Wnet, eff, ssc')
fprintf('Turbine work : %8.3f kj/kgn', Wt);
fprintf('pump work : %8.3f kj/kgn', Wp);
fprintf('wnet : %8.3f kj/kgn', wnet);
fprintf('Efficiency : %8.3f percent n', eff);
fprintf('S.S.C : %8.3f kj/kWh', SSC);
Explaination of code:
clear all,close all,clc - To close command window and remove previous variables.
fprintf - To print required lines in the command window
input - To get values of input conditions from user
XSteam - custom function to get values from steam tables
if-else - to calculate dryness fraction
for - to create plots
plot - to plot graph based outputs
RESULTS:

PLOTS:


CONCLUSION:
- Net work output = 1117.852 kj/kg
- Back work ratio = 36.167%
- Thermal Efficienct = 1.56
REFERENCES:
https://en.wikipedia.org/wiki/Rankine_cycle
https://en.wikipedia.org/wiki/Rankine_cycle#The_four_processes_in_the_Rankine_cycle
https://drive.google.com/open?id=1RK_fvrOj38CIaQvmLT1S3daqHnxKCGU-