Project 2 - Rankine cycle Simulator
Explanation,
Rankine cycle is an idealized thermodynamic cycle or heat engine in which a fuel is used to produce heat within a boiler,converting waer into steam which is expands through a turbine producing useful work.
process,
Required Inputs:
Turbine Inlet temperature = 400° C
Turbine Inlet Pressure = 30 bars
Turbine Outlet Pressure = 0.05 bars = Condenser Inlet Pressure
using the input values to get state1,state2,state3,state4 and calculate work done by turbine and work done to run pump ,net work,thermal efficiency.
calculate the temperature,entropy,enthalpy at the vapour and liquid.
then ploting the T-S diagram and H-S diagram and finally display the result by using 'disp' commamd.
and calculate the net work output and back work ratio.
ERROR facing,
Without download the XSteam table and run the coad showing some error in XSteam data ,after downloading the XSteam table data running good.
while using the ploting command wrongly mention two time of the color command its also genetate the figure without plot,after correct it.
clear all
close all
clc
% rankine cycle simulation
fprintf('rankine cycle')
fprintf('1-2 is isentropic expansion in turbine \n')
fprintf('2-3 is constant pressure heat removal \n')
fprintf('3-4 is isentropic compression in pump \n')
fprintf('4-1 is constant pressure heat addition in boiler \n')
% input data for calculate of state points
p1 = 30;
T1 = 400;
p2 = 0.05;
% take data from Xsteam file for state point 1
h1 = XSteam('h_pT',p1,T1);
s1 = XSteam('s_pT',p1,T1);
% taking data from Xsteam file for State point 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));
% taking data from XSteam file for state point 3
p3 = p2;
s3 = XSteam('sL_p',p3);
h3 = XSteam('hL_p',p3);
% taking data from XSteam file for state point 4
s4 = s3;
p4 = p1;
% work done in turbine for the rankine cycle
w_T = h1-h2;
% work done required for pump
v3 = XSteam('vL_p',p3);
w_p = v3*(p4-p3)*100;
h4 = h3-w_p;
% Net work done for rankine cycle
W_net = w_T - w_p;
% Heat Addition to system
Q_in = h1-h4;
% Heat rejection from system
Q_in = h2-h3;
% Thermal Efficiency of rankine cycle
T_eff = (W_net/Q_in)*100;
% specific steam consumption =( Mass flow rate / Net work done)
Sp_s=(3600/W_net);
% Calculating of temperature at all state point 2,3 and 4
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 of other constant for saturated liquid and vapour
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 for saturation line
T = linspace(1,560,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 for rankine cycle
figure(1)
hold on
plot(sf,T,'Color','b','LineWidth',2)
plot(sg,T,'Color','b','LineWidth',2)
plot([s1 s2],[T1 T2],'Color','r','LineWidth',3)
plot([s2 s3],[T2 T3],'Color','r','LineWidth',3)
plot([s3 s4],[T3 T4],'Color','r','LineWidth',3)
plot([s4 s5],[T4 T5],'Color','r','LineWidth',3)
plot([s5 s6],[T5 T6],'Color','r','LineWidth',3)
s_1 = linspace(s6,s1,1000);
for j= 1:length(s_1)
Tc(j)= XSteam('T_ps',p1,s_1(j));
end
plot(s_1,Tc,'Color','r','LineWidth',3)
text(s1+0.1,T1,'1')
text(s2+0.1,T2,'2')
text(s3,T3-20,'3')
text(s4,T4+20,'4')
title('temperature vs entropy')
xlabel('entropy(kj/kg-k)')
ylabel('temperature(deg.celcius)')
legend('saturation curve')
% plotting H-s diagram for rankine cycle
figure(2)
hold on
plot(sf,hf,'Color','b','LineWidth',2)
plot(sg,hg,'Color','b','LineWidth',2)
plot([s1 s2],[h1 h2],'Color','r','LineWidth',3)
plot([s2 s3],[h2 h3],'Color','r','LineWidth',3)
plot([s3 s4],[h3 h4],'Color','r','LineWidth',3)
hc = linspace(h4,h5,100);
for k= 1:length(hc)
s_c(k)= XSteam('s_ph',p1,hc(k));
end
plot(s_c,hc,'color','r','linewidth',3)
plot([s5 s6],[h5 h6], 'color','r','linewidth',2)
for i=1:length(s_1)
hc(i) = XSteam('h_ps',p1,s_1(i));
end
plot(s_1,hc,'Color','r','LineWidth',3)
text(s1+0.1,T1,'1')
text(s2+0.1,T2,'2')
text(s3,h3-100,'3')
text(s4,h4+200,'4')
title('enthalpy vs entropy')
xlabel('entropy(kj/kg-k)')
ylabel('enthalpy(kj/kg)')
legend('saturation curve')
% displaying result
disp('results');
fprintf('at state point 1:n')
fprintf('p1: %8.3f bar n',p1)
fprintf('T1: %8.3f c n',T1)
fprintf('h1: %8.3f KJ/kg n',h1)
fprintf('s1: %8.3f KJ/kgk n',s1)
fprintf('at state point 2:n')
fprintf('p2: %8.3f bar n',p2)
fprintf('T2: %8.3f c n',T2)
fprintf('h2: %8.3f KJ/kg n',h2)
fprintf('s2: %8.3f KJ/kgk n',s2)
fprintf('x2: %8.3fn n',x2)
fprintf('at state point 3:n')
fprintf('p3: %8.3f bar n',p3)
fprintf('T3: %8.3f c n',T3)
fprintf('h3: %8.3f KJ/kg n',h3)
fprintf('s3: %8.3f KJ/kgk n',s3)
fprintf('at state point 4:n')
fprintf('p4: %8.3f bar n',p4)
fprintf('T4: %8.3f c n',T4);
fprintf('h4: %8.3f KJ/kg n',h4)
fprintf('s4: %8.3f KJ/kgk n',s4)
fprintf('nother parameters:n')
fprintf('w_T: %8.3f KJ/kg n',w_T)
fprintf('w_p:%8.3f KJ/kg n',w_p)
fprintf('W_net:%8.3f KJ/kg n',W_net)
fprintf('T_eff:%8.3f percent n',T_eff)
fprintf('Sp_s:%8.3f Kg/kWhr n',Sp_s)
% calculate Network output
W_net=w_T-w_p
% calculate back work ratio
BWR = w_p/w_T