Project 2 - Rankine cycle Simulator
% Create a Rankie Cycle simulator using MATLAB
close all
clear all
clc
%Print Process Description
fprintf('1-2 Isobaric heat Transfer\n')
fprintf('2-3 Isentropic Expansion\n')
fprintf('3-4 Isobaric heat Rejection\n')
fprintf('4-1 Isentropic Compression\n')
%step1:Enter Inputs
p1=input('Enter the Pressure at the Turbine Inlet(in bar):');
T1=input('Enter the Temperature at the Turbineinlet(in Degree Celcius):');
p2=input('Enter the Pressure at the Condensor(in bar):');
%step2:calculate each state point values.
%state point1
h1=xsteam('h_pt',p1,T1);
s1 XSteam('s_pt',p1,T1);
%step3:state point2
s2=s1;
sf2=xsteam('sl_p',p2);
sg2=xsteam('sV_p',p2);
hf2=xsteam('hL_p',p2);
hg2=xsteam('hv_p',p2); %x2=(s2-sf2)/(sg2-sf2);
xsteam('hv_p',p2);
s2=5g2;
h2=hg2; %hf2+(x2*(hg2-hf2));
T2=XSteam('T_hs',h2,s2);
%step4:state point3
T3=T2;
p3=p2;
s3=XSteam('SL_T',T3);
h3=xSteam('hL_T',T3);
v3 XSteam('VL_P',p2);
%step5:state point4
p4=p1;
s4=53;
Cp4 XSteam('Cp_ps',p4,54);
CV4 XSteam('Cv_ps',p4,54);
gamma=Cp4/CV4;
r=(gamma1)/gamma;
T4 T3*(p4/p3)^r;
%step6:Calculate other output values.
Wt h1-h2; %Turbine Work
Wp=v3*(p1-p2)*100; %Pump Work
h4=Wp+h3;
W_net= %Net Work unit in kj/kg
Qs h1=h4; %heat suppied
N_per=(W_net/Qs)*100; %Efficiency
steam_rate 3600/(Wt-Wp); %Steam rate per second
%step7:state point 5 and 6 which help in plotting
T5-XSteam('Tsat_p',p1);
T6=T5;
s5=XSteam('sl_p',p1);
s6-XSteam('sV_p',p1);
h5-XSteam('hL_p',p1);
h6-XSteam('hV_p',p1);
%step 8: print all state poont values to show.
fprintf('\n-------------RESULT-------------\n')
fprintf('At state point 1:\nP1 is : %4.2f Bar\nT1 is : %4.2f Degree celcius\nH1 is : %4.2f kJ/Kg\nS1 is : %4.2f kJ/kgk\n\n',p1,T1,h1,s1)
fprintf('At state point 2:\nP1 is : %4.2f Bar\nT1 is : %4.2f Degree celcius\nH1 is : %4.2f kJ/Kg\nS1 is : %4.2f kJ/kgk\n\n',p2,T2,h2,s2)
fprintf('At state point 3:\nP1 is : %4.2f Bar\nT1 is : %4.2f Degree celcius\nH1 is : %4.2f kJ/Kg\nS1 is : %4.2f kJ/kgk\n\n',p3,T3,h3,s3)
fprintf('At state point 4:\nP1 is : %4.2f Bar\nT1 is : %4.2f Degree celcius\nH1 is : %4.2f kJ/Kg\nS1 is : %4.2f kJ/kgk\n\n',p4,T4,h4,s4)
fprintf('wt is:%4.2f kJ/kg\nwp is:%4.2f kJ/kg\nwnet is:%4.2f kJ/kg\nNtherm is: %4.2f percent\nS.S.C is : %4.2f kg/KWh',wt,wp,w_net,N_per,steam_rate)
%step 9:plot T-S Diagram
subplot(1,2,1)
T_rankine=linspace(T5,T1,5000);
for i=1:length(T_rankine)
s_rankine(i)=XSteam('s_PT',p1,T_rankine(i));
end
plot([s1 s2 s3 s4 s5 s6 s_rankine],[T1 T2 T3 T4 T5 T6 T_rankine],'linewidth",1.5);
hold on
T_curve=linspace(1,400,500);
for i=1:length(T_curve)
s_1(i)=XSteam('sL_T',T_curve(i));
s_v(i)=XSteam('sV_T',T_curve(i));
h_1(i)=XSteam('hL_T',T_curve(i));
h_v(i)=XSteam('hV_T',T_curve(i));
end
plot(s_1,T_curve);
plot(s_v,T_curve);
text(s1,T1,'1','FontSize',15)
text(s2,T2,'2','FontSize',15)
text(s3,T3,'3','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','top')
text(s4,T4,'4','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','bottom')
text(s5,T5,'5','FontSize',15)
text(s6,T6,'6','FontSize',15)
xlabel('Entropy in kJ/KgK');
ylabel('Temperature in Degree Celcius');
%step 10:plotH-Sdiagram
subplot(1,2,2)
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1],'linewidth',2)
hold on
plot(s_v,h_v,'color','r')
plot(s_1,h_1,'color','r')
text(s1,h1,'1','FontSize',15)
text(s2,h2,'2','FontSize',15)
text(s3,h3,'3','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','top')
text(s4,h4,'4','FontSize',15,'HorizontalAlignment','right','VerticalAlignment','bottom')
xlabel('Entropy in kJ/KgK')
ylabel('Enthalpy in kJ/kg')
Code Explanation -
The Program begins with clear all, close all, clc to erase the workspace and plots.
Input variables p1,T1,p2 are given by input command whose values are entered in command window while executing the Program.
State-1, Values for Enthalpy & Entropy are extracted as a function of Pressure & Temperature.
State 2 is a Condenser inlet where the High-Pressure Steam is converted into Low-Pressure Water and hence Dryness Fraction, Enthalpy & Entropy for Saturated Vapour & Saturated Water are considered to Calculate the Specific Enthalpy.
State-3 The water is condensed back to its Saturation Temperature and fed to the Pump, This temperature of water at the exit of the Condenser and entry of the Pump is the same.
State-4 This is Constant Pressure Heat addition, hence pressure is equal to pl, but the temperature increases on heating at Constant Pressure & Constant Volume as our Entropy remains the same and hence Cp/Cv=gamma is considered to find temperature T4.
Finally, Work done & Heat Evolved & SSC are calculated by basic formulae. Introduction to Hybrid Introduction to CFD Virtual Product level
To plot the Saturation Curve, a Temperature range is defined using linspace command and for the overall length of this Temperature values of Enthalpy and Entropy are calculated at every temperature point. The Break in the Saturation Curve separates the Liquid Phase & Vapour Phase. Now all the necessary data is found out, Plotting is done for both T-S & H-S curves using the plot commands. Annotations are assigned using text command.
Results of the Cycle Simulation is displayed over Command window using fprintf command.