Challenge

Project 2 - Rankine cycle Simulator

% rankin cycle is the operating cycle based on which all power plants work.
% the operating fluid conctantly evaporates and condences. this creates a
% movement generating power. its efficiency depends upon the operating
% fluids used and its temperature ramge.


clc
clear
close all

% the most important factor for the executation of this code is to
% understand and read the XSeam function data file. as all the most crutial
% calculations occur hear 

% The XSteam function itself uses a switch case methode to call the various
% lines of code embedded in it . for the below program we use the following
% calling functions
% ,,h_pT,,s_ph,,T_ps,,sL_p,,sV_p,,hL_p,,hV_p,,v_ph,,h_ps,,T_hs,,Tsat_p,,psat_T,,sL_T,,sV_T,,hL_T,,hV_T...

Rankine cycle simulator and its process

Inputes stage 1:
% at each stage we use the function Xsteam and then use the calling
% variable to extract the variables required. the calling function using a
% switch case methode will execute the following calculations.

p1 = input('please enter pressure @ stage 1\n');
t1 = input('please enter temperature @ stage 1\n');
h1 = XSteam('h_pT',p1,t1);
s1 = XSteam("s_ph",p1,h1);

fprintf('                 Results');
fprintf('             At state point 1');
fprintf('        P1 is   :%f        bar',p1);
fprintf('        T1 is   :%f        deg celcius',t1);
fprintf('        H1 is   :%f        KJ/Kg',h1);
fprintf('        S1 is   :%f        KJ/Kgk',s1);


Inputes stage 2:

p2 = input('please enter pressure @ stage 2 \n');
t2 = XSteam('T_ps',p2,s1);
s2 = s1;
sf2 = XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);

x = ((s2 - sf2)/(sg2 - sf2));
h2 = hf2 + (x*(hg2 - hf2));
v2 = XSteam('v_ph',p2,h2);

fprintf('              At state point 2');
fprintf('        P2 is   :%f        bar',p2);
fprintf('        T2 is   :%f        deg celcius',t2);
fprintf('        H2 is   :%f        KJ/Kg',h2);
fprintf('        S2 is   :%f        KJ/Kgk',s2);


Inputs at Stage 3:

p3 = p2;
t3 = t2;
s3 = XSteam('sL_p',p3);
h3 = XSteam('hL_T',t3);
v3 = XSteam('v_ph',p3,h3);

fprintf('              At state point 3');
fprintf('        P3 is   :%f        bar',p3);
fprintf('        T3 is   :%f        deg celcius',t3);
fprintf('        H3 is   :%f        KJ/Kg',h3);
fprintf('        S3 is   :%f        KJ/Kgk',s3);


Inputs at Stage 4:

p4 = p1;
v4 = v3;
s4 = s3;
h4 = XSteam('h_ps',p4,s4);
t4 = XSteam('T_hs',h4,s4);


fprintf('              At state point 4');
fprintf('        P4 is   :%f        bar',p4);
fprintf('        T4 is   :%f        deg celcius',t4);
fprintf('        H4 is   :%f        KJ/Kg',h4);
fprintf('        S4 is   :%f        KJ/Kgk',s4);


Inputs at Stage 5:

p5 = p4;
t5 = XSteam('Tsat_p',p5);
h5 = XSteam('hL_T',t5);
s5 = XSteam('sL_p',p5);

fprintf('              At state point 5');
fprintf('        P5 is   :%f        bar',p5);
fprintf('        T5 is   :%f        deg celcius',t5);
fprintf('        H5 is   :%f        KJ/Kg',h5);
fprintf('        S5 is   :%f        KJ/Kgk',s5);


Inputs at Stage 6:

t6 = t5;
p6 = XSteam('psat_T',t5);
s6 = XSteam('sV_T',t6);
h6 = XSteam('hV_T',t6);

fprintf('              At state point 6');
fprintf('        P6 is   :%f        bar',p6);
fprintf('        T6 is   :%f        deg celcius',t6);
fprintf('        H6 is   :%f        KJ/Kg',h6);
fprintf('        S6 is   :%f        KJ/Kgk',s6);

% loop to find variables on saturation lines

t = linspace(1,500,1000);

for i = 1:length(t)
    s_line1(i) = XSteam('sL_T',t(i));

    s_line2(i) = XSteam('sV_T',t(i));

    h_line1(i) = XSteam('hL_T',t(i));

    h_line2(i) = XSteam('hV_T',t(i));
end


output calculations:
% calculates and displays all the values in the rankine cycle 

disp('Work done by the turbine is '); w_turbine = (h1 - h2)
disp('Work done by the pump is '); w_pump = (h4 - h3);
disp('net Work output is '); work = (w_turbine - w_pump)
disp('Heat addition into the system '); q_in = (h1 - h4)
disp('Heat rejected by the system '); q_out = (h2 - h3)
disp('Thermal efficiency '); n = (work/q_in)
disp('Back work ratio is '); BWR = (w_pump/w_turbine)
disp('specific steam consumption is '); ssc = (3600/work)


plotting graphs:
disp('1-2 Isentropic Expansion in the turbine');
disp('2-3 constant pressure heat rejection by the condender');
disp('3-4 Isentropic compression in the pump');
disp('2-3 constant pressure heat addition by the boiler');

figure(1)
hold on
plot([s_line1 s_line2],[t t],"LineStyle","--",'LineWidth',2,"Color",'g');
plot([s1 s2 s3 s4 s5 s6 s1],[t1 t2 t3 t4 t5 t6 t1],"LineWidth",2);
% the text will display the the text at the points marked.
text(s1,t1,'1');
text(s2,t2,'2');
text(s3,t3,'3');
text(s4,t4,'4');
text(s5,t5,'5');
text(s6,t6,'6');
title('Rankine cycle entropy vs temperature diagram');
xlabel('Entropy');
ylabel('temperature');
axis([0,10,0,t1]);  % hear the axis limits are defined by the maximum values.
hold off

figure(2)
hold on
plot([s_line1 s_line2],[h_line1 h_line2],"LineStyle","--",'LineWidth',2,"Color",'g');
plot([s1 s2 s3 s4 s5 s6 s1],[h1 h2 h3 h4 h5 h6 h1],"LineWidth",2);
text(s1,h1,'1');
text(s2,h2,'2');
text(s3,h3,'3');
text(s4,h4,'4');
text(s5,h5,'4');
text(s6,h6,'6');
title('Rankine cycle eanthaply vs entropy diagram');
xlabel('Entropy');
ylabel('Eanthalpy');
axis([0,10,0,h1]);
hold off

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.