Project 2 - Rankine cycle Simulator
https://screenrec.com/share/KCjfEtreIg
clear
close
clc
fprintf('RANKINE CYCLE SIMULATOR')
fprintf('1-2: Isentropic Expansion in the Turbine')
fprintf('2-3: Constant Pressure Heat Rejection in the Condenser')
fprintf('3-4: Isentropic Compression in the Pump')
fprintf('4-1: Constant Pressure Heat Addition in the Boiler')
% 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): ')
h1=XSteam('h_pT',P1,T1)
s1=XSteam('s_pT',P1,T1')
% isentropic efficiency 100%
s2=s1
P4=P1
P3=P2
sf2=XSteam('sL_p',P2)
sg2=XSteam('sV_p',P2)
hf2=XSteam('hL_p',P2)
hg2=XSteam('hV_p',P2)
x2=(s2-sf2)/(sg2-sf2)
h2=hf2+x2*(hg2-hf2)
vf3=XSteam('vL_p',P2)
h3=XSteam('hL_p',P2)
T3=XSteam('Tsat_p',P2)
s3=XSteam('sL_p',P2)
T2=XSteam('T_hs',h2,s2)
Wturbine =h1-h2
Wpump=vf3*(P1-P2)*10^2
h4=h3+Wpump
s4=XSteam('s_ph',P1,h4)
T4=XSteam('T_hs',h4,s4)
s5=XSteam('sL_p',P1)
T5=XSteam('Tsat_p',P1)
s6=XSteam('sV_p',P1)
T6=XSteam('Tsat_p',P1)
h5=XSteam('hL_p',P1)
h6=XSteam('hV_p',P1)
P5=P1
P6=P1
Wnet=Wturbine-Wpump
back_work_ratio=Wpump/Wturbine
Thermal_efficiency=Wnet/(h1-h4)
% Output:
fprintf(' RESULTS ')
fprintf('state point 1:n ')
fprintf('P1 = %f bar n' ,P1)
fprintf('T1 = %f Degree Celsius n' ,T1)
fprintf('h1 = %f kJ/kg n' ,h1)
fprintf('s1 = %f kJ/kgK n' ,s1)
fprintf('nAt state point 2: n')
fprintf('P2 = %f bar n' ,P2)
fprintf('T2 = %f Degree Celsius n' ,T2)
fprintf('h2 = %f kJ/kg n' ,h2)
fprintf('s2 = %f kJ/kgK n' ,s2)
fprintf('nAt state point 3: n')
fprintf('P3 = %f bar n' ,P3)
fprintf('T3 = %f Degree Celsius n' ,T3)
fprintf('h3 = %f kJ/kg n' ,h3)
fprintf('s3 = %f kJ/kgK n' ,s3)
fprintf('nAt state point 4: n')
fprintf('P4 = %f bar n' ,P4)
fprintf('T4 = %f Degree Celsius n' ,T4)
fprintf('h4 = %f kJ/kg n' ,h4)
fprintf('S4 = %f kJ/kgK n' ,s4)
fprintf('nAt state point 5: n')
fprintf('P5 = %f bar n' ,P5)
fprintf('T5 = %f Degree Celsius n' ,T5)
fprintf('h5 = %f kJ/kg n' ,h5)
fprintf('s5 = %f kJ/kgK n' ,s5)
fprintf('nAt state point 6: n')
fprintf('P6 = %f bar n' ,P6)
fprintf('T6 = %f Degree Celsius n' ,T6)
fprintf('h6 = %f kJ/kg n' ,h6)
fprintf('s6 = %f kJ/kgK n' ,s6)
fprintf('nOther parameters: n')
fprintf('Wturbine = %f kJ/kg n', Wturbine)
fprintf('Wpump = %f kJ/kg n', Wpump)
fprintf('Wnet = %f kJ/kg n', Wnet)
fprintf('nThermalefficiency = %f percent n', Thermal_efficiency)
% Plot:
figure(1)
plot(s1,T1,'*','Color','r')
hold on
plot(s2,T2,'*','Color','r')
hold on
plot([s1 s2],[T1 T2],'color','r')
plot(s3,T3,'*','Color','r')
hold on
plot([s2 s3],[T2 T3],'color','r')
plot(s4,T4,'*','Color','r')
hold on
plot([s3 s4],[T3 T4],'color','r')
plot(s5,T5,'*','Color','r')
hold on
plot([s4 s5],[T4 T5],'color','r')
plot(s6,T6,'*','Color','r')
hold on
plot([s5 s6],[T5 T6],'color','r')
plot([s6 s1],[T6 T1],'color','r')
xlabel('Entropy','FontSize',9,'FontWeight','bold','Color','r')
ylabel('Temperature','FontSize',9,'FontWeight','bold','Color','r')
figure(2)
plot(s1,h1,'*','Color','r')
hold on
plot(s2,h2,'*','Color','r')
hold on
plot([s1 s2],[h1 h2],'color','r')
plot(s3,h3,'*','Color','r')
hold on
plot([s2 s3],[h2 h3],'color','r')
plot(s4,h4,'*','Color','r')
hold on
plot([s3 s4],[h3 h4],'color','r')
plot(s5,h5,'*','Color','r')
hold on
plot([s4 s5],[h4 h5],'color','r')
plot(s6,h6,'*','Color','r')
hold on
plot([s5 s6],[h5 h6],'color','r')
plot([s6 s1],[h6 h1],'color','r')
xlabel('Entropy','FontSize',9,'FontWeight','bold','Color','r')
ylabel('Enthalpy','FontSize',9,'FontWeight','bold','Color','r')