Project 2 - Rankine cycle Simulator
clear all
close all
clc
fprintf(' SIMULATOR OF RANKINE CYCLE nn')
fprintf('1-2 Isentropic Expansion in the Turbinen')
fprint('2-3 Constant pressure Heat Rejection by the Condensren')
fprint('3-2 Isentropic Compression in the pumpn')
fprint('4-1 Constant Pressure Heat Addition by the Boilernn')
%inputs
P1 = input('Enter the Pressure at the Turbine Inlet (in bar)');
T1 = input('Enter the Temperature at the Turbine inlet (in Degree celsius)');
P2 = input('Enter the Pressure at the condenser (in bar):');
disp(' RESULTS')
%GETTING cp and cv valves from xstream
%cp and cv assumed to not change with temperature to make problem simple
% for vapour
high_cpv= xstream('cpv_p',P1);
low_cpv= xstream('cpv_p',P2);
high_cpv= xstream('cvv_p',P1);
low_cpv= xstream('cvv_p',P2);
% for liquid
high_cpl= xstream('cpl_p',P1);
low_cpl= xstream('cpl_p',P2);
high_cvl= xstream('cpl_p',P1);
low_cvl= xstream('cpl_p',P2);
%Getting important parameters for xstream
%for high pressure
T1s = xstream('Tsat_p',P1);
S1g = xstream('sV_p',P1);
S1f = xstream('SL_p', P1);
S1fg = S1g - S1f;
H1f = xstream('hL_p', P1);
H1g = xstream('hV_p', P1);
H1fg = H1g - H1f;
%for low pressure
S2g = xstream('sV_p', P2);
S2f = xstream('sL_p', P2);
S2fg = S2g - S2f;
t2s = xstream('Tsat_p', P2);
H2f = xstream('hL_p', P2);
H2g = xstream('hV_p', P2);
H2fg = H2g - H2f;
%% State point 1
disp('At state point 1:')
fprintf('P1 is : %f Barn', P1)
fprintf('T1 is :f Deg celsiusn', T1)
H1 = xstream('h_pt', P1, T1);
fprintf('S1 is : %f kj/kgknn', S1)
%% State point 2
disp('At state point 2:')
fprintf('p2 is : %f Barn', P2) %P2 input already taken
S2 = S1;
fprintf('S2 is : %f kj/kgkn', S2)
%predicting location of point 2 in T-s
if(S2<=S2g)
x2 = (S2 - S2f) / (S2fg); %Dryness Fraction at state point 2
else
x2=1;
end
fprintf('x2 is : %f n',x2)
%calculating T2 for superheat or wet or dry whenever it lies
if(x2<1)
T2=T2s;
else
%t2 cal by s2=s2g+low_cpv*(log(T2/T2s))
T2=(T2s+273.15)*exp((S2-S2g)/low_cpv) ; %2 in superheated region
T2=T2-273.15;
end
fprintf('T2 is : %f Deg celsius n', T2)
if(x2<1)
H2 = H2f + x2 * H2fg;
else
H2=H2g+ low_cpv*(T2-T2s);
end
fprintf('H2 is : %f kj/kgn', H2)
%% State point 3
%Assuming no subcooling in condensor
disp('At state point 3:')
P3 = P2;
fprintf('P3 is : %f Barn', P3)
V3 = xsteam('vL_p', P3);
T3 = T2s; %no subcooling assumed
Fprintf('T3 is : %f Deg celsiusn', T3)
H3 =H2f;
fprintf('S3 is : %f kj/kgnn', S3)
%% State point 4
disp('At state point 4:')
P4 = P1;
fprintf('P4 is : %f Barn', P4)
S4 = S3;
fprintf('S4 is : %f kj/kgkn', S4)
Wp = V3 * (P4 - P3) * 100;
H4 = Wp + H3;
fprintf('H4 is : %f kj/kgn', H4)
% to cal T4 s4=s3=sf1-high_cpl*ln(t1s/t4)
term=exp((S1f-S4)/high_cpl); %Use exp instead of Exp to take input as double
T4 = T1s/term;
fprintf('T4 is : %f Deg celsius nn', T4)
%% Work done,heat,SSc and efficiency calculations
Wt = H1 - H2;
fprintf('Work by turbine is : %f kj/kgn',Wt)
fprintf('Work by compressor is : %f kj/kgn', Wp)
Wnet = Wt - Wp;
fprintf('Net Work done is : %f kj/kgn', Wnet)
Qin = H1 - H4;
eff_thermal = Wnet / Qin ; %Efficiency
fprintf('Thermal efficiency is : %f',eff_thermal); disp('%')
SSC = 3600 / Wt; %Specific steam consumption
fprintf('S.S.C is : %f kg/kwh ', SSc)
%%Calculation for plotting Liquid and Vapour lines
%
% <<FILENAME.PNG>>
%
temp = linspace(1,373,500);
for i = 1 : length(temp)
H_L(i) = xstream('hL_T', temp(i));
H_V(i) = xstream('hV_T', temp(i));
S_L(i) = xstream('sL_T', temp(i));
S_L(i) = xstream(['sV_T'], temp(i));
end
%% Plotting T - S and H - S Diagrams
figure(1) % T-S
hold on
plot([S1 S2], [T1 T2],'r', 'linewidth', 1)
text(S1,T1,' 1')
text(S2,T2,' 2')
plot([S2 S2g], [T2 T2s], 'r', 'linewidth', 1)
text(S2g,T2s,' 2s')
plot([S2g S3], [T2s T3], 'r', 'linewidth',1)
text(S3,T3,' 3')
plot([S3 S4], [T3 T4], 'r', 'linewidth',1)
text(S4,T4,' 4')
plot([S4 S1f], [T4 T1s], 'r', 'linewidth',1)
text(S1f,T1s,' 4s')
plot([S1f S1g], [T1s T1s], 'r', 'linewidth',1)
text(S1g,T1s,' 1s')
plot([S1g S1],[T1s T1], 'r', 'linewidth', 1)
plot(S_L, temp,'b', 'linestyle','--','linewidth', 1)
plot(S_V, temp,'b', 'linestyle','--','linewidth', 1)
%marking direction
text(S1, (T1+T2)/2,'vee','HorizontalAlignment','center','color','r')
text((S2g+S2f)/2,T3,'langle','color','r')
text(S3, (T3+T4)/2,'wedge','HorizontalAlignment','center','color','r')
text((S1f+S1g)/2,T1s,'rangle','color','r')
title('T-S Diagram of Ideal Rankline cycle')
ylabel('Temperature (degC)')
xlabel('Specific Entropy (kj/kgk)')
figure(2) % H-S
hold on
plot([S1 S2],[H1 H2], 'r', 'linewidth',1);
text(S1,H1,' 1')
plot([S2 S3],[H2 H3], 'r', 'linewidth',1);
text(S2,H2,' 2')
plot([S3 S4],[H3 H4], 'r', 'linewidth',1);
text(S4,H3,' 3')
plot([S4 S1],[H4 H1], 'r', 'linewidth',1);
text(S4,H4,' 4')
plot(S_L, H_L, 'b','linestyle','--', 'linewidth',1.5)
plot(S_V, H_V, 'b', 'linewidth','--', 'linewidth', 1.5)
title('H-S Diagram', 'FrontSize', 15)
ylabel('Specific Enthalpy (kj/kg)')