a new title
Rankine cycle Simulator
%Rankine cycle plotting programt1 = input('Enter turbine inlet temperature(degree celsius) : ');p1 = input('Enter turbine inlet pressure(bar) : ');p2 = input('Enter turbine exhaust/condenser inlet pressure : ');%point 1, turbine inlettsat1 = XSteam('Tsat_p',p1);sf1 = XSteam('sL_p',p1);sg1 = XSteam('sV_p',p1);if t1>tsat1 s1 = XSteam('s_pT',p1,t1); h1 = XSteam('h_pT',p1,t1);elseif t1 == tsat1 s1 = XSteam('sV_p',p1); h1 = XSteam('hV_p',p1);else disp('Invalid temperature, must be equal to or greater than saturation temperature'); end%point 2, turbine exhaust/condenser inlets2 = s1;sf2 = XSteam('sL_p',p2);sg2 = XSteam('sV_p',p2);sfg2 = sg2 - sf2;x = (s2-sf2)/sfg2;t2 = XSteam('Tsat_p',p2);hf2 = XSteam('hL_p',p2);hg2 = XSteam('hV_p',p2);h2 = hf2 + x*(hg2-hf2);%point 3, compressor inlet/condenser dischargep3 = p2;t3 = t2;h3 = hf2;s3 = sf2;%point 4, compressor exhaust/boiler inletvf = XSteam('vL_p',p3);w = vf*(p1-p2)*100;h4 = w + h3;s4 = s3;p4 = p1;cp4 = XSteam('Cp_ps',p4,s4);cv4 = XSteam('Cv_ps',p4,s4);gamma = cp4/cv4;t4 = t3*((p4/p3)^((gamma-1)/gamma));%plotting TS graphsfigure(1)hold on%plotting saturation dome for TS Diagramfor i = 1:0.2:221.2 tsat = XSteam('Tsat_p',i); sl = XSteam('sL_p',i); sg = XSteam('sV_p',i); plot(sl,tsat); plot(sg,tsat); if i == 221 xlabel('Specific Entropy') ylabel('Temperature') endend%plotting cardinal points on TS Diagramplot(s1,t1,'*');plot(s2,t2,'*');plot([s1 s2],[t1 t2] ,'color','r');plot(s3,t3,'*');plot([s2 s3],[t2 t3] ,'color','r');plot(s4,t4,'*');plot([s3 s4],[t3 t4] ,'color','r');plot(sf1,tsat1,'*');plot(sg1,tsat1,'*');plot([sf1 sg1], [tsat1 tsat1],'color','r');plot([s4 sf1],[t4 tsat1],'color','r'); %XSteam does not provide function to determine entropy of subsaturated/compressed water, hence a straight line was drawnif t1>tsat1 %Plotting curve in saturated reigon for j = tsat1:t1 sinst = XSteam('s_pT',p1,j); plot(sinst,j,'color','r'); endendhold off%plotting HS diagram / mollierfigure(2)hold on%plotting saturation dome on HS Diagram for i = 1:0.2:221.2 hg = XSteam('hV_p',i); sg = XSteam('sV_p',i); plot(sg,hg);end%plotting cardinal points on HS diagram plot(s1,h1,'*');plot(s2,h2,'*');plot([s1 s2], [h1 h2], 'color', 'k');plot(s3,h3,'*');plot([s2 s3], [h2 h3], 'color', 'k');plot(s4,h4,'*');plot([s3 s4], [h3 h4], 'color', 'k');plot([s4 s1], [h4 h1], 'color', 'k');xlabel('Entropy');ylabel('Enthalpy');%displaying values of T,P,S,H at cardinal pointsdisp('RESULTS');fprintf('Temperature at point 1 : %f ',t1);fprintf('\n Pressure at point 1 : %f ',p1);fprintf('\n Entropy at point 1 : %f ',s1);fprintf('\n Enthalpy at point 1 : %f ',h1);fprintf('\n Temperature at point 2 : %f ',t2);fprintf('\n Pressure at point 2 : %f',p2);fprintf('\n Entropy at point 2 : %f',s2);fprintf('\n Enthalpy at point 2 : %f',h2);fprintf('\n Temperature at point 3 : %f',t3);fprintf('\n Pressure at point 3 : %f',p3);fprintf('\n Entropy at point 3 : %f',s3);fprintf('\n Enthalpy at point 3 : %f',h3);fprintf('\n Temperature at point 4 : %f',t4);fprintf('\n Pressure at point 4 : %f',p4);fprintf('\n Entropy at point 4 : %f',s4);fprintf('\n Enthalpy at point 4 : %f',h4);This program takes 3 inputs, turbine inlet temperature, pressure and turbine exhaust/condenser inlet pressure.
Then it calculates the value of enthalpy, temperature, pressure and entropy at all the cardinal points using basic thermodynamic relations and the concept of dryness fraction. It then plots the saturation curve for water and the rankine cycle. It also plots a HS Diagram/Mollier Diagram using XSteam function.
It must be noted that the plot between compressor/pump outlet/boiler inlet to the saturation of water is not a straight line. The state of water on the left side of saturation curve is called "Sub Saturated" or it is called compressed water. However, there was no function on the XSteam function to provide entropies of water in the sub saturated reigon. Hence I plot it as a straight line.
Graphs and output screen :
TS DIAGRAM :
HS DIAGRAM
OUTPUT ON COMMAND WINDOW