Challenge

Project 2 - Rankine cycle Simulator

close all

clear all

clc

fprintf('Process (1-2) - Isentropic Expansion in the Turbine\n')

fprintf('Process (2-3) - Isobaric Heat Rejection by the Condenser\n')

fprintf('Process (3-2) - Isentropic Compression in the Pump\n')

fprintf('Process (4-1) - Isobaric Heat Addition by the Boiler\n')

% For Inputting state variables at point 1,

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 Turbine Outlet (in bar): ');

%% State variable at state point 1(i.e Turbine Inlet )

h1 = XSteam('h_pT',p1,t1); % Enthalpy in [kJ/kg]

s1 = XSteam('s_pT',p1,t1); % Specific entropy in [kJ/kg K]

v1 = XSteam('v_pT',p1,t1); % Specific volume in [m3/kg]

%% State variable at state point 2(i.e Conderser Inlet)

s2 = s1; % Specific entropy in [kJ/kg K]

h2 = XSteam('h_px',p2,XSteam('x_ps',p2,s2)); % Enthalpy in [kJ/kg]

t2 = XSteam('T_ps',p2,s2); % Temperature in [degree C]

v2 = XSteam('v_ps',p2,s2); % Specific volume in [m3/kg]

%% State variable at state point 3 (i.e Pump Inlet)

p3 = p2; % Pressure in [bar]

t3 = XSteam('Tsat_p',p3); % Temperature in [degree C]

h3 = XSteam('hL_p',p3); % Enthalpy in [kJ/kg]

s3 = XSteam('sL_p',p3); % Specific entropy in [kJ/kg K]

v3 = XSteam('vL_p',p3); % Inlet Specific volume in [m3/kg]

%% State variable at state point 4 (i.e Boiler Inlet)

s4 = s3; % Specific entropy in [kJ/kg K]

p4 = p1; % Pressure in [bar]

h4 = XSteam('h_ps',p4,s4); % Enthalpy in [kJ/kg]

t4 = XSteam('T_ps',p4,s4); % Temperature in [degree C]

v4 = XSteam('v_ps',p4,s4); % Specific volume in [m3/kg]

%% Ploting Graph for Ideal Rankine cycle in "T" vs "s".

figure(1)

hold on

plot([s1 s2],[t1 t2],'color','r','linewidth',5);

plot([s2 s3],[t2 t3],'color','k','linewidth',5);

plot([s3 s4],[t3 t4],'color','c','linewidth',5);

Trange = linspace(t4,t1,500);

for i = 1:length(Trange)

s_range(i) = XSteam('s_pT',p1,Trange(i));

h_range23(i) = XSteam('h_ps',p1,s_range(i));

h_range41(i) = XSteam('h_ps',p2,s_range(i));

end

plot(s_range,Trange,'color','b','linewidth',5);

legend('ReversibleAdiabaticExpansion', 'ConstantPressureHeatRejection', 'ReversibleIsentropicCompression', 'ConstantPressureHeatAddtion');

%% Ploting Graph for Ideal Rankine cycle in 'h' vs 's'.

figure(2)

hold on

plot([s1 s2],[h1 h2],'color','r','linewidth',5);

plot(s_range,h_range23,'color','k','linewidth',5);

plot([s3 s4],[h3 h4],'color','c','linewidth',5);

plot(s_range,h_range41,'color','b','linewidth',5);

legend('ReversibleAdiabaticExpansion', 'ConstantPressureHeatRejection', 'ReversibleIsentropicCompression', 'ConstantPressureHeatAddtion');

%% Ploting graphs for 'T' vs 's'

t_range = linspace(0,374.15,500); % Temperature from 0 to critical point of water in [degree C]

figure(1)

hold on

for i = 1:length(t_range)

plot(XSteam('sL_t',t_range(i)),t_range(i),'.','color','g')

plot(XSteam('sV_t',t_range(i)),t_range(i),'.','color','g')

end

%% Ploting graphs for 'h' vs 's'

figure(2)

hold on

for i = 1:length(t_range)

plot(XSteam('sL_t',t_range(i)),XSteam('hL_t',t_range(i)),'.','color','g')

plot(XSteam('sV_t',t_range(i)),XSteam('hV_t',t_range(i)),'.','color','g')

end

%% Ploting Diagram for All state points for Ideal Rankine cycle in 'T' vs 's'

figure(1)

hold on

plot(s1,t1,'ko')

plot(s2,t2,'ko')

plot(s3,t3,'ko')

plot(s4,t4,'ko')

grid on

title('T-s Diagram of RANKINE CYCLE')

xlabel('Temperature in [degree C]')

ylabel('Specific entropy in [kJ/kg K]')

%% Ploting Diagram for All state points for Ideal Rankine cycle in 'h' vs 's'

figure(2)

hold on

plot(s1,h1,'ko')

plot(s2,h2,'ko')

plot(s3,h3,'ko')

plot(s4,h4,'ko')

grid on

title('h-s Diagram of RANKINE CYCLE')

xlabel('Enthalpy in [kJ/kg]')

ylabel('Specific entropy in [kJ/kg K]')

%% Finally Calculating Work and Efficiency

Work_turbine = h1 - h2; % work transferred from the working fluid (kJ/kg)

Q_taken_out_condenser = h2 - h3; % heat rejected from the working fluid (kJ/kg)

Work_pump = h4 - h3; % work transferred into the working fluid (kJ/kg)

Q_given_boiler = h1 - h4; % heat transferred to the working fluid (kJ/kg)

Back_Work_Ratio = Work_turbine / Work_pump; % Back Work Ratio % Specific Steam Consumption [kg/kWh]

Work_net = Work_turbine - Work_pump; % Net work on the working fluid (kJ/kg)

Effi_rankine = Work_net/Q_given_boiler; % Rankine Cycle Efficiency

clc

%% Printing Results to the USER GIVING input

fprintf('Turbine Inlet Temperature T1 = %.5f in [degree C]\n',t1);

fprintf('Turbine Inlet Pressure p1 = %.5f in [bar]\n',p1);

fprintf('Turbine Inlet Enthalpy h1 = %.5f in [kJ/kg]\n',h1);

fprintf('Turbine Inlet Specific entropy s1 = %.5f in [kJ/kg K]\n',s1);

fprintf('Turbine Inlet Specific volume v1 = %.5f in [m3/kg]\n\n',v1);

fprintf('Conderser Inlet Temperature T1 = %.3f in [degree C]\n',t2);

fprintf('Conderser Inlet Pressure p1 = %.3f in [bar]\n',p2);

fprintf('Conderser Inlet Enthalpy h1 = %.3f in [kJ/kg]\n',h2);

fprintf('Conderser Inlet Specific entropy s1 = %.3f in [kJ/kg K]\n',s2);

fprintf('Conderser Inlet Specific volume v1 = %.3f in [m3/kg]\n \n',v2);

fprintf('Pump Inlet Temperature T1 = %.3f in [degree C]\n',t3);

fprintf('Pump Inlet Pressure p1 = %.3f in [bar]\n',p3);

fprintf('Pump Inlet Enthalpy h1 = %.3f in [kJ/kg]\n',h3);

fprintf('Pump Inlet Specific entropy s1 = %.3f in [kJ/kg K]\n',s3);

fprintf('Pump Inlet Specific volume v1 = %.3f in [m3/kg]\n\n',v3);

fprintf('Boiler Inlet Temperature T1 = %.4f in [degree C]\n',t4);

fprintf('Boiler Inlet Pressure p1 = %.4f in [bar]\n',p4);

fprintf('Boiler Inlet Enthalpy h1 = %.4f in [kJ/kg]\n',h4);

fprintf('Boiler Inlet Specific entropy s1 = %.4f in [kJ/kg K]\n',s4);

fprintf('Boiler Inlet Specific volume v1 = %.4f in [m3/kg]\n \n',v4);

fprintf('Work transferred from the working fluid Wturbine = %.4f in [kJ/kg]\n',Work_turbine);

fprintf('Heat rejected from the working fluid Qcondenser = %.4f in [kJ/kg]\n',Q_taken_out_condenser);

fprintf('Work transferred into the working fluid Wpump = %.4f in [kJ/kg]\n',Work_pump);

fprintf('Heat transferred to the working fluid Qboiler = %.4f in [kJ/kg]\n \n',Q_given_boiler);

fprintf('Back Work Ratio BWR = %.4f \n',Back_Work_Ratio);

fprintf('Net work on the working fluid Wnet = %.4f in [kJ/kg] \n',Work_net);

fprintf('Rankine Cycle Efficiency ETArankine = %.4f %% \n\n',Effi_rankine*100);

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.