Challenge

Project 2 - Rankine cycle Simulator

RANKINE CYCLE SIMULATOR

1) Step - wise explanation of code.

a) Name the state points 1,2,3 and 4, starting with turbine .

b) Enter the pressure inlet for Turbine, Condenser and Temperature of Turbine inlet.

c) Entering state points 1 (Turbine), Enthalpy, entropy, saturated vapor entropy (Because Turbine rotates with vapor - hence no phase change, isentropic expansion) and saturated temperature at stage 1.

d) Entering state points 2 (Condenser) - Condenser transforms vapor into liquid. Hence phase change. Saturated liquid and vapor entropy values needed from Xsteam function file.

e) Entering state points 3 (Pump - isentropic compression). Using Xsteam file entering the value for saturated liquid enthalpy and entropy.

f) Entering state points 4 (Boiler)- pressure and temperature values remain same as state point 1. water is transformed into vapor leaving pump which requires isobaric and isochoric points from the Xsteam function file.

g) Calculate the net work done at pump and at Turbine.

h)calculating overall thermal efficiency by dividing the amount of net workdone by amount of heat in.

i) Constructing the curves using inputs from xsteam function file.

j)

clear all 
close all
clc
fprintf("\n                          RANKINE CYCLE SIMULATOR");
fprintf("\n  1-2 Isentropic expansion in the turbine" );
fprintf("\n  2-3 Constant pressure heat rejection in the condenser" );
fprintf("\n  3-4 Isentropic compression by pump");
fprintf("\n  4-1 Constant pressure heat addition \n ");
p1=input("Enter the pressure for turbine inlet\n")
t1=input("Enter the temperature for turbine inlet\n")
p2=input("Enter the pressure for condenser inlet\n")
%t=linspace(0,373.15,200);
% state point 1
h1=XSteam('h_pT',p1,t1);
s1=XSteam('s_pT',p1,t1);
Tsat1=XSteam('Tsat_p',p1);
sg1=XSteam('sV_p',p1);

% state point 2
% this is a condenser, phase changes, saturated vapor entropy, saturated
% liquid entropy
s2=s1
sf2=XSteam('sV_p',p2);% saturated vapor entropy with respect to pressure, because we don't have temperature value
sg2=XSteam('sL_p',p2);%saturated liquid entropy with respect to pressure
hf2=XSteam('hV_p',p2);%saturated vapor enthalpy with respect to pressure
hg2=XSteam('hL_p',p2);%saturated liquid enthalpy with respect to pressure
x2=((s2-sf2)/(sg2-sf2));
h2=hf2*(x2*(hg2-hf2));
Tsat2=XSteam('Tsat_p',p2);%saturated temperature

% state point 3
% pump, no phase change 
p3=p2;
s3=XSteam('sL_p',p3);%saturated liquid entropy
h3=XSteam('hL_p',p3);%saturated liquid enthalpy
v3=XSteam('vL_p',p3);
t3=XSteam('Tsat_p',p3);%saturated temperature
t2=t3;
%state point 4
%boiler - phase 
p4=p1;
t4=t1;
s4=s3;
cp4=XSteam('Cp_ps',p4,s4)%specific isobaric heat capacity as a function of pressure and entropy
cv4=XSteam('Cv_ps',p4,s4)%specific isochoric heat capacity as a function of pressure and entropy
g4=cp4/cv4;
o=(g4-1)/g4;
t4=t3*((p4/p3)^o);

% work done at pump
wp=v3*(p4-p3)*100;
h4=h3+wp;
%wp=h3-h4;

% work done at Turbine
wt=h1-h2;

% Net workdone
wnet=wt-wp;
%Heat in and out
qin=h1-h4;
qout=h2-h3;


% Thermal efficiency
NThermal=wnet/qin;

%BWR
bwr=wp/wt;

%curves
%T-S curve.
figure(1),clf
hold on
%saturation curves-pb,pc.
t=linspace(0,373.15,200)
for i=1:length(t)   %t-s curve, hence no enthalpy
    plot(XSteam('sV_T',t(i),'k'))%saturated vapor entropy with respect to temperature as it is a T-S curve.
    plot(XSteam('sL_T',t(i),'k'))%saturated liquid entropy,temp,T-S curve
    plot(XSteam('hL_T',t(i),'k'));%saturated vapor enthalpy,temp,T-S curve
    plot(XSteam('hV_T',t(i),'k'));%saturated liquid enthalpy,temp,T-S curve
end
% cycle
plot([s1 s2],[t1 t2],'LineWidth',2);

if x2>1
    t3=Tsat2;
    plot([s2 sg2 s3 s4],[t2 Tsat2 t3 t4],'LineWidth',2);
    t2=Tsat2;
    text(s2,t2,'2','FontSize',15) 
    text(s3,t3,'3','FontSize',15)
else
    plot([s2 s3 s4],[t2 t3 t4],'LineWidth',2);
    text(s2,t2,'2','FontSize',15)
    text(s3,t3,'3','FontSize',15)
end
n=linspace(t1,t2,500);
for i=1:length(n)
    plot(XSteam('S_PT',p1,n(i)),'.','LineWidth',2)
end
plot([s1 sg1 ],[Tsat1,Tsat1],'LineWidth',2)
text(s1,Tsat1,'4','FontSize',15)
xlabel('Entropy(KJ/Kg-K)')
ylabel('Temperature(K)')
title('T-s graph')

%h-s graph
figure(2),clf
hold on
%saturation curve
for i=1:length(t)
    plot(XSteam('sL_T',t(i))) %saturated liquid entropy
    plot(XSteam('hL_T',t(i),'k') ) %saturated liquid enthalpy
    plot(XSteam('sV_T',t(i)))%saturated vapor entropy
    plot(XSteam('hV_p',t(i),'k'))%saturated vapor enthalpy
end

%cycle
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1],'LineWidth',2)
text(s1,h1,'1','FontSize',15)
text(s2,h2,'2','FontSize',15)
text(s3,h3,'3','FontSize',15)
text(s4,h4,'4','FontSize',15)
xlabel('Entropy(kJ/Kg-k)')
ylabel('Enthalpy(KJ/Kg)')
title('h-s graph')

% DISPLAYING RESULTS IN COMMAND WINDOW
%At state point 1
disp('At State Point 1:')
fprintf('p1=%.2f bar \n',p1)
fprintf('t1=%.2f  Deg.celsius \n',t1 )
fprintf('h1=%.2f KJ/Kg-K \n ',h1)
fprintf('s1=%.2f KJ/Kg-K \n\n',s1)

%At state point 2
disp('At State Point 2:')
fprintf('p2=%.2f bar \n',p2)
fprintf('t2=%.2f  Deg.celsius \n',t2 )
fprintf('h2=%.2f KJ/Kg-K \n ',h2)
fprintf('s2=%.2f KJ/Kg-K \n\n',s2)

%At state point 3
disp('At State Point 3:')
fprintf('p3=%.2f bar \n',p3)
fprintf('t3=%.2f  Deg.celsius \n',t3 )
fprintf('h3=%.2f KJ/Kg-K \n ',h3)
fprintf('s3=%.2f KJ/Kg-K \n\n',s3)

%At state point 4
disp('At State Point 4:')
fprintf('p4=%.2f bar \n',p4)
fprintf('t4=%.2f  Deg.celsius \n',t4 )
fprintf('h4=%.2f KJ/Kg-K \n ',h4)
fprintf('s4=%.2f KJ/Kg-K \n\n',s4)

fprintf('Work done by the Turbine=%.2f KJ/Kg \n',wt)
fprintf('Work done by the pump=%.2f KJ/Kg \n',wp)
fprintf('Net Work done=%.2f KJ/Kg \n',wnet)
fprintf('Thermal Efficiency=%.2f  % % \n',NThermal)
fprintf('Back Work Ratio=%f \n',bwr)






0utput:-

graphs:

References :- 1) https://www.youtube.com/watch?v=O3Hww4MnkIE

2) https://www.youtube.com/watch?v=xIg-1srHxRM

screenshots showing error:-

The error was variable name entered incorrect.

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.