Challenge

Project 2 - Rankine cycle Simulator

clear all 
close all
clc
% printing indtroduction
fprintf('RANKINE CYCLE SIMULATOR\n')
fprintf('1-2 is isentropic expanssion in the turbine\n')
fprintf('2-3 is constant heat  rejection in the condensor\n')
fprintf('3-4 is isentropic compression in the pump\n')
fprintf('4-1 is the constant process heat addition in the boiler\n')
% input of rankine cycle
% temperature in Celcius
t1=400
% pressure in bar
p1=30
p2=.05
% variables at state point 1
p1
t1=400
h1=XSteam('h_pT',p1,t1)
s1=XSteam('s_pT',p1,t1)
sf1=XSteam('sL_p',p1)
sg1=XSteam('sV_p',p1)
tf1=XSteam('Tsat_p',p1)
tg1=XSteam('Tsat_p',p1)
% variables at state point 2
p2
s2=s1
sf2=XSteam('sL_p',p2)
sg2=XSteam('sV_p',p2)
hf2=XSteam('hL_p',p2)
hg2=XSteam('hV_p',p2)

t2=XSteam('T_ps',p2,s2)
x=(s2-sf2)/(sg2-sf2)
h2=hf2+x*(hg2-hf2)

% state variables at point 3
p3=p2
t3=t2
h3=XSteam('hL_p',p3)
s3=XSteam('sL_p',p3,t3)

% state variables at point 4
p4=p1
s4=s3
h4=XSteam('h_ps',p4,s4)
t4=XSteam('T_ps',p4,s4)


% Turbine work 
fprintf('Turbine work')
Wt=h1-h2
% pump work
fprintf('Pump work')
Wp=h4-h3
% net work done
fprintf('Net work')
Wnet=Wt-Wp
% Back work ratio
fprintf('Back work ratio')
rb=Wt/(h1-h4)
% plot T vs S daigram
t=linspace(0,400,500);
figure(1)
hold on

for i=1:length(t)
    plot(XSteam('sL_T',t(i)),t(i),'.','color','r')
    plot(XSteam('sV_T',t(i)),t(i),'.','color','r')
    
end
% plot cycle
plot([s1 s2],[t1 t2],'linewidth',3,'color','b')
if x>1
    t3=ts2
    plot([s2 s3 s4],[t2,t3,t4],'linewidth',3,'color','b')
else
    plot([s2 s3 s4],[t2 t3 t4],'linewidth',3,'color','b')
    
end
l=linspace(t1,t2,500);
hold on
for i=1:length(l)
    plot(XSteam('s_pT',p1,l(i)),l(i),'.','color','b')
end
plot([sf1 sg1],[tf1,tg1],'linewidth',3,'color','b')
xlabel('Entropy')
ylabel('temperature')
title('T-S daigram')

% plot H vs S daigram
figure(2)
hold on
for i=1:length(t)
    plot(XSteam('sL_T',t(i)),XSteam('hL_T',t(i)),'.','color','g')
    plot(XSteam('sV_T',t(i)),XSteam('hV_T',t(i)),'.','color','g')
    
end
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1],'linewidth',3,'color','b')
xlabel('Entropy')
ylabel('Enthalpy')
title('H-S daigram')
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.

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.