Challenge

Project 2 - Rankine cycle Simulator

OBJECTIVE:
*To make the program for a rankine cycle
*Plot the graph between the T-S, H-S and make it possible to compare the graphs for studying it.
*To calculate the equations of the cycle and its efficiency
CODE:

clear all
close all
clc
disp('RANKINE CYCLE SIMULATOR');
disp('1-2 is isentropic expansion in the turbine');
disp('2-3 is const pressure heat rejection in the condenser'); 
disp('3-4 is isentropic compression in the pump');
disp('4-1 is const pressure heat addiction by the boiler');

p1=input('Enter the pressure at the turbine inlet(in bar):');
t1=input('Enter the temperature at the turbine inlet(in degree celcius):');
p2=input('Enter the pressure at the condenser(in bar):');

% conditions at the inlet of the turbine
tsat=XSteam('Tsat_p',p1)
sf1=XSteam('sL_p',p1);
sg1=XSteam('sV_p',p1);
if t1>tsat
    tsup=t1;
    h1=XSteam('h_pT',p1,tsup);
    s1=XSteam('s_pT',p1,tsup);
elseif t1==tsat
    h1=XSteam('hL_p',p1);
    s1=XSteam('sL_p',p1);
else
    disp('temperature entered must be greater than or equal to saturation temperature')
end
% conditions at the condenser inlet or the Turbine exhaust
t2=XSteam('Tsat_p',p2);
hf2=XSteam('hL_p',p2);
hg2=XSteam('hv_p',p2);
s2=s1;
sg2=XSteam('sV_p',p2);
sf2=XSteam('sL_p',p2);
x2=(s2-sf2)/(sg2-sf2);
h2=hf2+(x2*(hg2-hf2));

% conditions at the condenser exit
p3=p2;
t3=t2;
h3=hf2;
s3=sf2;

% cinditions at the boiler inlet
p4=p1;
s4=s3;
cp4=XSteam('cp_ps',p4,s4);
cv4=XSteam('cv_ps',p4,s4);
gamma=cp4/cv4;
t4=t3*(p4/p3)^((gamma-1)/gamma);
vf=XSteam('vL_p',p3);
wp=vf*(p1-p2)*100; % input powwr to pump
h4=wp+h3;

wt=h1-h2; 
Qin=h1-h4;
Qout=h2-h3;
wnet=wt-wp;

Ntherm=(wnet/Qin)*100;

ssc=3600/wnet;
% plotting of T-S and H-Sdiagram
% T-S diagram

figure(1)
hold on
% plotting saturation lines
temp=linspace(1, 373, 500);
for i=1:length(temp)
    hl(i)=XSteam('hL_T',temp(i));
    hv(i)=XSteam('hV_T',temp(i));
    sl(i)=XSteam('sL_T',temp(i));
    sv(i)=XSteam('sv_T',temp(i));
end
plot(s1,temp,'k','linestyle','-','linewidth',1.5)
plot(sv,temp,'k','linestyle','-','linewidth',1.5)
xlabel('specific entropy(kj/kgk)')
ylabel('Temperature (degree C)')
grid on
title('T-S diagram','fontweight','bold','font size',16);
plot([s1 s2 s3 s4 sf1 sg1],[t1 t2 t3 t4 tat tast],'color','b','linewidth',1.5)
text(s1,t1,'1')
text(s2,t2,'2')
text(s3,t3-10,'3')
text(s4,t4+10,'4')

t=linspace(tsat,tsup,1000);
 for j=1:length(t)
     sinst(j)=XSteam('s_pT',p1,t(j));
 end
 plot(sinst,t,'color','b','linewidth',1.5);
 
 % H-S diagram
 figure(2)
 hold on
 grid on
 title('H-S diagram','fontweight','bold','font size',16);
 plot(s1,temp,'k','linestyle','-','linewidth',1.5)
 plot(sv,temp,'k','linestyle','-','linewidth',1.5)
 plot([s1 s2 s3 s4 sf1 sg1],[h1 h2 h3 h4],'color','b','linewidth',1.5);
text(s1,h1,'1')
text(s2,h2,'2')
text(s3,h3-100,'3')
text(s4,h4+100,'4')
ylabel('specific enthalpy(kj/kg)')
xlabel('specific entropy(kj/kgk')

% outputs
% at state 1
fprintf('rn')

disp('RESULTS -');
fprintf(n)

fprintf('At state point 1:n')
fprintf('P1 is : %.2f Barn',p1);
fprintf('nT1 is : %.2f Deg celcius',t1);
fprintf('nH1 is : %.2f kj/kgn',h1);
fprintf('nS1 is : %.2f kj/kgkrnn',s1);
fprintf('rn')

% at state 2
fprintf('At state point 2:n')
fprintf('P2 is : %.2f Barn',p2);
fprintf('T2 is : %.2f Deg celcius',t2);
fprintf('H2 is : %.2f kj/kgn',h2);
fprintf('S2 is : %.2f kj/kgkrnn',s2);
fprintf('rn')

% at state 3
fprintf('At state point 3:n')
fprintf('P3 is : %.2f Barn',p3);
fprintf('T3 is : %.2f Deg celcius',t3);
fprintf('H3 is : %.2f kj/kgn',h3);
fprintf('S3 is : %.2f kj/kgkrnn',s3);
fprintf('rn')

% at state 4
fprintf('At state point 4:n')
fprintf('P4 is : %.2f Barn',p4);
fprintf('T4 is : %.2f Deg celcius',t4);
fprintf('H4 is : %.2f kj/kgn',h4);
fprintf('S4 is : %.2f kj/kgkrnn',s4);
fprintf('rn')


fprintf('wt is : %.2f kj/kgn',wt);
fprintf('wp is : %.2f kj/kgkrnn',wp);
fprintf('wnet is : %.2f kj/kgn',wnet);
fprintf('Ntherm is : %.2f Percentn',Ntherm);
fprintf('ssc is : %.2f kg/kwhn',ssc);
REPORT:

First of to download the xsteam ,the values are put on the given data from 
question.Download file should be kept same position with the programming file saving space.
Using the code to add the temperature,pressure,saturation condition points,by using the if statements given temperature and the saturation conditions should be evaluated and the elements are run the equations.
Now the equations used and calculating the Qnet,Wnet for performance of the cycle is calculating with the given elements.Plot the element using plot statement and compare the values put with the graph.
For printing the values observed by the object and calculated values by fprintf command to read the performance of the cycle.
Error detected with the element to perform read conditional values of tsat,sfg,ect because the folder not saved with same of the programm saving position.
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.