Project 2 - Rankine cycle Simulator
Aim:
Create a Rankine Cycle Simulator using MATLAB with the help of XSteam function provided.
Rankine Cycle:
The Rankine cycle is the fundamental operating cycle of all power plants where an operating fluid is continuously evaporated and condensed. The selection of operating fluid depends mainly on the available temperature range. In this mechanism, fuel is used to produce heat within a boiler, converting water into steam which then expands through a turbine producing useful work.
The Rankine cycle operates in the following steps:
- 1-2: Isentropic compression in a pump
- 2-3: Constant pressure heat addition in a boiler
- 3-4: Isentropic expansion in a turbine
- 4-1: Constant pressure heat rejection in a condenser
Matlab code:
clear all
close all
clc
%four steps
fprintf('%50s','Rankine Cycle Simulator');
fprintf('\n \n \n')
fprintf('1-2 is Isentropic Expansion in the turbine \n');
fprintf('2-3 is Constant Pressure Heat Rejection by the Condensor \n');
fprintf('3-4 is Isentropic Compression in the Pump \n');
fprintf('4-1 is Constant Pressure Heat Addition by the Boiler \n \n');
%inputs from user
t1=input(' Enter turbine inlet temperature(in degrees) at point 1 = ');
p1=input(' Enter turbine inlet Pressure(in bar) at point 1 = ');
p2=input(' Enter the Condensor inlet pressure(in degrees) at point 2 = ');
%turbine inputs:
s1 = XSteam('s_pT',p1,t1);
h1 = XSteam('h_pt',p1,t1);
% condensor inlet
s2=s1; %1-2 is an isentropic expansion process
sf2=XSteam('sL_p',p2);
sg2=XSteam('sV_p',p2);
hf2=XSteam('hL_p',p2);
hg2=XSteam('hV_p',p2);
%calculating dryness fraction
if(s2<=sg2)
x2 = ((s2 - sf2) / (sg2-sf2)); % Dryness Fraction at state point 2
else
x2=1;
end
h2=hf2+(x2*(hg2-hf2));
% condensor exit
p3=p2;
t3=XSteam('Tsat_p',p3);
s3=XSteam('sL_p',p3);
h3=XSteam('hL_p',p3);
v3=XSteam('vL_p',p3);
t2=t3;
% boiler inlet
p4=p1; % constant pressure heat addition
s4=s3; %isentropic compression in the pump
h4=XSteam('h_ps',p4,s4);
cp4=XSteam('Cp_ps',p4,s4);
cv4=XSteam('Cv_ps',p4,s4);
g4=(cp4/cv4);
% calculation for t4
%p4^(1-gamma)*t4^gamma=p3^(1-gamma)*t3^gamma;
t4=(t3*((p3/p4)^((1-g4)/g4)));
% turbine work done
Wt=h1-h2;
%pump work done
Wp=h4-h3;
% net work done
W_net=Wt-Wp;
% heat added in the boiler
q_in=h1-h4;
% heat rejected in the condensor
q_out=h2-h3;
% Thermal efficiency
n= (W_net/q_in)*100
%plotting the results
figure(1)
%plotting liquid and vapour curves
t=linspace(1,t1,1000);
for i=1:length(t)
s_l(i)=XSteam('sL_T',t(i));
end
for i=1:length(t)
s_v(i)=XSteam('sV_T',t(i));
end
hold on
plot(s_l,t,'linewidth',2,'linestyle','-','color','g');
plot(s_v,t,'linewidth',2,'linestyle','- -','color','g');
grid on
% plotting for the work done by the tubrine(process 1-2)
plot([s1,s2],[t1,t2],'linewidth',2,'color','k')
hold on
title(' T-s Diagram of Ideal Rankine Cycle')
xlabel('Entropy(KJ/KgK)')
ylabel('Temperature(k)')
% Plotting for heat rejected in condensor (Process 2-3)
plot([s2,s3],[t2,t3],'linewidth',2,'color','k')
hold on
% Plotting for work done by the pump (Process 3-4)/
plot([s3,s4],[t3,t4],'linewidth',2,'color','k')
hold on
% Plotting for heat added by the boiler(Process 4-1)
tp = XSteam('TSat_p',p4);
sp = XSteam('sL_T',tp);
plot([s4,sp],[t4,tp],'lineWidth',2,'color','k')
hold on
tq = tp;
sq = XSteam('sV_T',tq);
plot([sp,sq],[tp,tq],'lineWidth',2,'color','k')
hold on
plot([sq,s1],[tq,t1],'lineWidth',2,'color','k')
hold on
%Indicate states with numbers
text(s1,t1,' 1');
text(s2,t2,' 2');
text(s3,t3,' 3');
text(s4,t4,' 4');
%Plot for enthalpy vs entropy
figure(2)
plot([s1,s2],[h1,h2],'lineWidth',2,'color','k')
grid on
title('h-s DIAGRAM')
xlabel('Entropy(KJ/kgK)')
ylabel('Enthalpy(KJ/kg)')
hold on
plot([s2,s3],[h2,h3],'lineWidth',2,'color','k')
hold on
plot([s3,s4],[h3,h4],'lineWidth',2,'color','k')
hold on
plot([s4,s1],[h4,h1],'lineWidth',2,'color','k')
%plot for liqiuid and vapour saturation curve
t = linspace(1,t1,1000);
for j = 1:length(t)
h_l(j) = XSteam('hL_T',t(j));
end
for j = 1:length(t)
h_v(j) = XSteam('hV_T',t(j));
end
plot(s_l,h_l,'lineWidth',2,'color','r')
hold on
plot(s_v,h_v,'lineWidth',2,'color','r')
%Indicate states with numbers
text(s1,h1,'1');
text(s2,h2,'2');
text(s3,h3,'3');
text(s4,h4,'4');
%Results output
fprintf('%40s \n \n \n','RESULT');
fprintf('%10s %54s \n','At State Point 1','At State Point 2');
fprintf('%s %.2f%s %44s %.2f%s \n','P1:',p1,' bar','P2:',p2,' bar');
fprintf('%s %.2f%s %35s %.2f%s \n','T1:',t1,' Deg Celcius','T2:',t2,' Deg Celcius');
fprintf('%s %.2f%s %40s %.2f%s \n','H1:',h1,' KJ/kg','H2:',h2,' KJ/kg');
fprintf('%s %.2f%s %42s %.2f%s \n','S1:',s1,' KJ/kgK','S2:',s2,' KJ/kgK');
fprintf('%58s %.2f \n \n','X2:',x2);
fprintf('%10s %54s \n','At State Point 3','At State Point 4');
fprintf('%s %.2f%s %45s %.2f%s \n','P3:',p3,' bar','P4:',p4,' bar');
fprintf('%s %.2f%s %35s %.2f%s \n','T3:',t3,' Deg Celcius','T4:',t4,' Deg Celcius');
fprintf('%s %.2f%s %41s %.2f%s \n','H3:',h3,' KJ/kg','H4:',h4,' KJ/kg');
fprintf('%s %.2f%s %42s %.2f%s \n \n','S3:',s3,' KJ/kgK','S4:',s4,' KJ/kgK');
fprintf('%40s %.2f %s \n','Work output by Turbine(Wt): ',Wt,' KJ/kg');
fprintf('%40s %.2f %s \n','Work input by Pump(Wp): ',Wp,' KJ/kg');
fprintf('%40s %.2f %s \n','Net Work(Wnet): ',W_net,' KJ/kg');
fprintf('%40s %.2f %s \n','Thermodynamic Efficiency(Ntherm): ',n,'Percent');
fprintf('%40s %.2f %s \n','Heat input in Boiler: ',q_in,' KJ/kg');
fprintf('%40s %.2f %s \n','Heat rejected in condenser: ',q_out,' KJ/kg');
fprintf('%40s %.2f %s \n','S.S.C.: ',p3,' Kg/kWh');
Matlab code Explanation:
- clear all,close all and clc commands are used to start everything fresh each and every time.
- While using the Xsteam function we have to mention the corresponding process name as 'switch case' is used. The process name is not mentioned in the below explanation for that, one has to see the above Matlab code.
- The four process names are printed using 'fprintf' command.
- The inputs are given as,
Turbine Inlet temperature = 400° C = t1
Turbine Inlet Pressure = 30 bars = p1
Turbine Outlet Pressure = 0.05 bars = Condenser Inlet Pressure = p2
- The turbine inputs s1 and h1 are calculated using the Xsteam function providing p1,t1 as inputs to the function.
- The condenser inputs s2=s1(from step 4) and sf2,sg2,hf2,hg2 values are calculated using the Xsteam function providing p2 as inputs to the function.
- Then the dryness factor is calculated(x2).
- Using the dryness factor (x2)(from step 6)and xsf2,sg2,hf2,hg2 (from step 5) ,the value of h2 is calculated.
- Now we have s1,h1 for condensor inlet.
- For condenser exit state, p3=p2(from input) and the vlues t3,s3,h3,v3 are calculated using the Xsteam function providing p3 as input to the function.
- From step9, t2=t3.
- For boiler input state, p4=p1(from input) and s4=s3. The values h4,cp4,cv4 are calculated using the Xsteam function providing p4,s4 as input to the function.
- g4 is calculated by cp4/cv4
- t4 is calculated as ------------> t4=(t3*((p3/p4)^((1-g4)/g4)))
-
turbine work done is calculated as,
Wt=h1-h2 -
pump work done is calculated as,
Wp=h4-h3 -
net work done is calculated as,
W_net=Wt-Wp -
heat added in the boiler is calculated as,
q_in=h1-h4 -
heat rejected in the condenser is calculated as,
q_out=h2-h3 -
Thermal efficiency is calculated as
n= (W_net/q_in)*100 - plotting is done separately for T-s plot and h-s plot
- For T-s plot, using for loop s_l and s_v are calculated using the for loop and XSteam function by providing time variable t as the input. Then s_l and s_v are plotted accordingly with their corresponding time values.
- In the same graph values of,
s1 and s2 with t1 and t2 ----->work done by the turbine
s2 and s3 with t2 and t3 ----->heat rejected in the condenser
s3 and s4 with t3 and t4 ---->work done by the pump
values of tp and sp are cal. using XSteam function by providing p4 and tp as inputs respectively.
s4 and sp with t4 and tp ------> heat added by the boiler
- tq=tp and sq is calculated with XSteam function as tq input to it( sp and sq with tp and tq)
- sq and s1 with tq and t1 is also plotted to complete the process.
- Then an indication of the process is done using 'text' command by providing their correct position.
- For h-s plot the values used for plotting are,
s1 and s2 with h1 and h2
s2 and s3 with h2 and h3
s3 and s4 with h3 and h4
s4 and s1 with h4 and h1
- plot for liquid and vapour saturation curve h_l and h_v are founded using Xsteam function giving time as input by running it through a for a loop. Then s_l,h_l and s_v,h_v are plotted.
- 'text' command is used to mention the state numbers on the graph.
- Then 'fprintf' command is used to show the result in the command window.
Results:
Command window for Results: