

AIM : Create a Rankine Cycle Simulator using MATLAB.
OBJECTIVE :
• Calculate each state points of the Rankine Cycle (any type your choice)based on user inputs.
• Plot the Corresponding T-s and h-s plots for the given set of inputs.
• Calculate Efficiency.
THEROY :
The ideal Rankine Cycle consist of the following four processes, as showen in the result and the figure.
• 1-2: Isentropic Expansion in the turbine
• 2-3: constant pressure heat rejection in a condenser
• 3-4: Isentropic compression in a compressor
• 4-1: Constant pressure heat addition in a Boiler
Turbine (process 1-2): Steam from the boiler, which has an elevated temperture and pressure, expands through the turbine produce work and then is discharged to the condencer with relatyively low pressure.
Neglacting heat transfer with the surrounding, the energy balance in the turbine is
Wturbine, out = h2 -h1
Condenser (process 2-3): steam from the turbine is condensed to liquid water in the condenser. The energy balance in condenser is
Qout=h2-h3
Pump (process 3-4): pump pressurized the liquid water from the condenser prior to going back to the boiler. Assuming no heat transfer with the surrounding, the energy balance in the pump is
Wpump,in=h4-h3
Boiler (process 3-4): Liquid water enters the bioler and is heated to superheated state in the boiler. The energy balance in the boiler is
Qin=h1-h4
% Main code
clear all
close all
clc
%user inputs
fprintf('%75s','Rankine Cycle Simulator');
fprintf('\n\n\n')
fprintf('1-2 is Isentropic Expansion in the turbine\n');
fprintf('2-3 is constant pressure Heat Rejection by the condensor\n');
fprintf('3-4 is Isentropic compression in the pump\');
fprintf('4-1 is constant Pressure Heat Addition by the Boiler\n\n');
% inputs
p1 = input(' Enter the pressure(in bar) at the inlet of the turbine(at point 1):');
t1 = input(' Enter the Temperature(in degree) at the inlet of the turbine(at point 1):');
p2 = input(' Enter the pressure(in degree) at the inlet of the condensor(at point 2):');
%input to the turbine
s1 = XSteam('s_pT',p1,t1);
h1 = XSteam('h_pt',p1,t1);
% condensor inlet
s2 = s1; %1-2 is an isentropic expansion process
sf2 = XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);
% calculating dryness fraction
if(s2<=sg2)
x2 = ((s2 - sf2) / (sg2 - sf2)); % Dryness Fraction at state point 2
else
x2 = 1;
end
h2 = hf2+(x2*(hg2-hf2));
% condensor exit
p3 = p2;
t3 = XSteam('Tsat_p',p3);
s3 = XSteam('sL_p',p3);
h3 = XSteam('hL_p',p3);
v3 = XSteam('vL_p',p3);
t2 = t3;
% boiler inlet
p4 = p1; % constant pressure heat addition
s4 = s3; %isentropic compression in the pump
h4 = XSteam('h_ps',p4,s4);
cp4 = XSteam('Cp_ps',p4,s4);
cv4 = XSteam('Cv_ps',p4,s4);
g4 = (cp4/cv4);
% calculation for t4
%p4^(1-gamma)*t4^gamma=p3^(1-gamma)*t3^gamma;
t4 = (t3*((p3/p4)^((1-g4)/g4)));
% calculation
% work done by turbine
wt=h1-h2;
% work done by the turbine
wp=h4-h3;
% net work done
w_net=wt-wp;
% heat added in the boiler
q_in=h1-h4;
% heat rejection in the condensor
q_out = h2-h3
% Thermal efficiency
n = (w_net/q_in)*100;
% plotting the results
figure(1)
%plotting liquid and vapour curves
t = linspace(1,t1,1000);
for i = 1:length(t)
s_l(i) = XSteam('sL_T',t(i));
end
for i = 1:length(t)
s_v(i) = XSteam('sV_T',t(i));
end
hold on
plot(s_l,t,'linewidth',2,'linestyle','- -','color','r');
plot(s_v,t,'linewidth',2,'LineStyle','- -','color','r');
grid on
% plotting for the work done by the turbine(process 1-2)
plot([s1,s2],[t1,t2],'linewidth',2,'color','k')
hold on
title(' T-s Digram of Ideal Rankine Cycle')
xlabel('Entropy(KJ/KgK)')
ylabel('Temperature(k)')
% plotting for het rejection in condensor (process 2-3)
plot([s2,s3],[t2,t3],'linewidth',2,'color','k')
hold on
%plotting for work done by the pump (process 3-4)/
plot([s3,s4],[t3,t4],'linewidth',2,'color','k')
hold on
% plotting for heat addedd by the boiler(process 4-1)
tp = XSteam('Tsat_p',p4);
sp = XSteam('sL_T',tp);
plot([s4,sp],[t4,tp],'linewidth',2,'color','k')
hold on
tq = tp;
sq = XSteam('sV_T',tq);
plot([sp,sq],[tp,tq],'linewidth',2,'color','k')
hold on
plot([sq,s1],[tq,t1],'linewidth',2,'color','k')
hold on
%Indicate states with numbers
text(s1,t1,' 1');
text(s2,t2,' 2');
text(s3,t3,' 3');
text(s4,t4,' 4');
%plot for enthalpy vs entropy
figure(2)
plot([s1,s2],[h1,h2],'linewidth',2,'Color','k')
grid on
title('h-s DIAGRAM')
xlabel('Entropy(KJ/kgK')
ylabel('Enthalpy(KJ/kg')
hold on
plot([s2,s3],[h2,h3],'linewidth',2,'color','k')
hold on
plot([s3,s4],[h3,h4],'linewidth',2,'Color','k')
hold on
plot([s4,s1],[h4,h1],'linewidth',2,'Color','k')
%plot for liquid and vapour saturation curve
t = linspace(1,t1,1000);
for j = 1:length(t)
h_l(j) = XSteam('hL_T',t(j)');
end
for j = 1:length(t)
h_v(j) = XSteam('hV_T',t(j));
end
plot(s_l,h_l,'linewidth',2,'Color','r')
hold on
plot(s_v,h_v,'linewidth',2,'Color','r')
% Indicate state with number
text(s1,h1,'1');
text(s2,h2,'2');
text(s3,h3,'3');
text(s4,h4,'4');
%Result output
fprintf('%40s \n \n \n','RESULT');
fprintf('%10s %54s \n','At State Point 1','At State point 2');
fprintf('%s %.2f%s %44s %.2f%s \n','P1:',p1,' bar','P2:',p2,' bar');
fprintf('%s %.2f%s %35s %.2f%s \n','T1:',t1,' Deg Celcius','T2:',t2,' Deg Celcius');
fprintf('%s %.2f%s %40s %.2f%s \n','H1:',h1,' KJ/kg','H2:',h2,' KJ/kg');
fprintf('%s %.2f%s %42s %.2f%s \n','S1:',s1,' KJ/kgk','S2:',s2,' KJ/kgk');
fprintf('%58s %.2f \n \n','X2:',x2);
fprintf('%10s %54s \n','At State point 3','At State point 4');
fprintf('%s %.2f%s %45s %.2f%s \n','P3:',p3,' bar','P4:',p4,' bar');
fprintf('%s %.2f%s %35s %.2f%s \n','T3:',t3,' Deg Celcicus','T4:',t4,' Deg Celcius');
fprintf('%s %.2f%s %41s %.2f%s \n','H3:',h3,' KJ/kg','H4:',h4,' KJ/kg');
fprintf('%s %.2f%s %42s %.2f%s \n \n','S3:',s3,' KJ/kgk','S4:',s4,' KJ/kgk');
fprintf('%40s %.2f %s \n','Work output by Turbine(Wt): ',wt,' KJ/kg');
fprintf('%40s %.2f %s \n','Work input by pump(Wp): ',wp,' KJ/kg');
fprintf('%40s %.2f %s \n','Net Work(Went): ',w_net,' KJ/kg');
fprintf('%40s %.2f %s \n','Thermodynamic Efficiency(Ntherm): ',n,'Percent');
fprintf('%40s %.2f %s \n','Heat input in Boiler: ',q_in,' KJ/kg');
fprintf('%40s %.2f %s \n','Heat rejection in condenser: ',q_out,' KJ/kg');
fprintf('%40s %.2f %s \n','S.S.C.: ',p3,' Kg/kwh');