Project 2 - Rankine cycle Simulator
Writing a program to Create a Rankine Cycle Simulator using MATLAB.
About Rankine cycle :
The Rankine cycle or Rankine Vapor Cycle is the process widely used by power plants such as coal-fired power plants or nuclear reactors. 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 and it is a model used to predict the performance of steam turbine systems. It was also used to study the performance of reciprocating steam engines. The Rankine cycle is an idealized thermodynamic cycle of a heat engine that converts heat into mechanical work while undergoing a phase change. It is an idealized cycle in which friction losses in each of the four components are neglected. The heat is supplied externally to a closed loop, which usually uses water as the working fluid
There are four processes in the Rankine cycle. The states are identified by numbers in the T–s diagram.
Process 1–2 [Isentropic compression] :
The working fluid is pumped from low to high pressure. As the fluid is a liquid at this stage, the pump requires little input energy.
Process 2–3 [Constant pressure heat addition in boiler]:
The high-pressure liquid enters a boiler, where it is heated at constant pressure by an external heat source to become a dry saturated vapor. The input energy required can be easily calculated graphically, using an enthalpy–entropy chart (h–s chart, or Mollier diagram), or numerically, using steam tables.
Process 3–4 [Isentropic expansion]:
The dry saturated vapor expands through a turbine, generating power. This decreases the temperature and pressure of the vapor, and some condensation may occur. The output in this process can be easily calculated using the chart or tables noted above.
Process 4–1 [Isentropic expansion] :
The wet vapor then enters a condenser, where it is condensed at a constant pressure to become a saturated liquid.
we also know governing equations
1)Turbine Work(WT) = H1 - H2
2)Pump Work(WP) = H4 - H3
3)Net Work(WNET)= WT - WP
4) Qin = H1-H4
5)Thermal Efficiency(η)= WNET/(H1 - H4)
6) Back Work Ratio(BWR): WP /WT
7)Specific Steam Conductivity(S.S.C)= 3600/WT
Where,
H1,H2,H3,H4 are the enthalpy at the respective state points.
To get the steam table data for water we use the standard Xsteam library: https://drive.google.com/file/d/1RK_fvrOj38CIaQvmLT1S3daqHnxKCGU-/view
Explanation of the code :
- to calculate the state points of the Rankine Cycle based on user inputs lets first display the heading information as Rankine cycle and process of Rankine cycle as information using disp command and now using input command we allowing user input data which generates the input data
- now calculating the pressure, temperature, enthalpy, and entropy for state 1,2,3, and 4 using standard Xsteam library
- now we have the all the required data for the calculation using governing equations
- now using fprintf we show all the calculated data in command window here we use \n for proper alignment
- now for T-S and H-S graphs, we use the for loop in fashion of plot(XSteam('sL_T',t(i)),t(i),'r.') to get the all values
Code :
% Program for simulation of Rankine cycle
close all
clear all
clc
%displaying the Heading and cycle processes
disp(' Rankine Cycle Simulator')
disp(' ')
disp('1-2 : Isentropic Expansion in the turbine')
disp('2-3 : Isobaric Heat Rejection by the condenser ')
disp('3-4 : Isentropic Compression in the pump ')
disp('4-1 : Isobaric Heat Addition by the boiler ')
disp(' ')
%generating inputs
t = linspace(0,374.5,400); %temerature for plotting saturation curve
T1 = input('Enter the Turbine inlet temperature(in Degree Celcious) : ');
P1 = input('Enter the pressure at the Turbine inlet(in bar) : ');
P2 = input('Enter the turbine outlet pressure/Condender inlet pressure(in bar): ');
disp(' ')
% Calculating state points
% At state 1
h1 = XSteam('h_pT',P1,T1); % Enthalpy
s1 = XSteam('s_pT',P1,T1); % Entropy
h_l1 = XSteam('hL_p',P1); % Saturated liquid enthalpy
h_g1 = XSteam('hV_p',P1); % Saturated vapour enthalpy
s_l1 = XSteam('sL_p',P1); % Saturated liquid entropy
s_g1 = XSteam('sV_p',P1); % Saturated vapour entropy
t_sat1 = XSteam('Tsat_p',P1); % Saturation temperature
% At state 2
s2 = s1;
s_l2 = XSteam('sL_p',P2);
s_g2 = XSteam('sV_p',P2);
d = (s2-s_l2)/(s_g2-s_l2); % dryness fraction
h_l2 = XSteam('hL_p',P2);
h_g2 = XSteam('hV_p',P2);
h2 = h_l2 + d*(h_g2-h_l2); % enthalpy at state 2
T2 = XSteam('T_ph',P2,h2);
t_sat2 = XSteam('Tsat_p',P2);
% At state 3
h3 = h_l2;
s3 = s_l2;
P3 = P2;
T3 = T2;
% At state 4
s4 = s3;
P4 = P1;
h4 = XSteam('h_ps',P4,s4);
T4 = XSteam('T_ps',P4,s4);
% Calculations
% Work done by the turbine
Wt = h1 - h2;
% Work done by the pump
Wp = h4 - h3;
% Net work done
NWD = Wt - Wp;
% heat gain
Q_in = h1-h4;
% Thermal efficiency
n = (NWD/Q_in)*100 ;
% Back work ratio
BWR = Wp/Wt;
% Specific Steam Conductivity
SSC = 3600/Wt;
% Displaying the results
% Values of state point 1
disp(' RESULTS');
disp('At State point 1');
fprintf('P1 is : %.2f Bar \n',P1);
fprintf('T1 is : %.2f Deg Celcius \n',T1);
fprintf('H1 is : %.2f KJ/kg \n',h1);
fprintf('S1 is : %.2f KJ/kgK \n',s1);
disp(' ');
% Values of state point 2
disp('At State point 2');
fprintf('P2 is : %.2f Bar \n',P2);
fprintf('T2 is : %.2f Deg Celcius \n',T2);
fprintf('H2 is : %.2f KJ/kg \n',h2);
fprintf('S2 is : %.2f KJ/kgK \n',s2);
disp(' ');
% Values of state point 3
disp('At State point 3');
fprintf('P3 is : %.2f Bar \n',P3);
fprintf('T3 is : %.2f Deg Celcius \n',T3);
fprintf('H3 is : %.2f KJ/kg \n',h3);
fprintf('S3 is : %.2f KJ/kgK \n',s3);
disp(' ');
% Values of state point 4
disp('At State point 4');
fprintf('P4 is : %.2f Bar \n',P4);
fprintf('T4 is : %.2f Deg Celcius \n',T4);
fprintf('H4 is : %.2f KJ/kg \n',h4);
fprintf('S4 is : %.2f KJ/kgK \n',s4);
disp(' ');
% Values from calculations
fprintf('Work done by turbine = %.2f kJ/kg \n', Wt)
fprintf('Work done by pump = %.2f kJ/kg \n', Wp)
fprintf('Net work done = %.2f kJ/kg \n', NWD)
fprintf('Thermal efficiency = %.2f percent \n', n)
fprintf('Back-work ratio = %f \n', BWR)
fprintf('Specific Steam Conductivity = %.2f kg/kWh \n', SSC)
disp(' ')
%plotting
%plotting of T-S curve
figure(1)
hold on
for i = 1:length(t)
plot(XSteam('sL_T',t(i)),t(i),'r.')
plot(XSteam('sV_T',t(i)),t(i),'r.')
end
% For Cycle
plot([s1 s2],[T1 T2],'linewidth',2,'color','g')
text(s1,T1,'1','FontSize',10)
if d > 1
T3 = t_sat2;
plot([s2 s_g2 s3 s4],[T2 t_sat2 T3 T4],'linewidth',2,'color','g')
T2 = t_sat2;
text(s2,T2,'2','FontSize',10)
text(s3,T3,'3','FontSize',10)
else
plot([s2 s3 s4],[T2 T3 T4],'linewidth',2,'color','g')
text(s2,T2,'2','FontSize',10)
text(s3,T3,'3','FontSize',10)
end
n = linspace(T1,T2,500);
for i = 1:length(n)
plot(XSteam('s_pT',P1,n(i)),n(i),'.','linewidth',2,'color','g')
end
plot([s_l1 s_g1],[t_sat1 t_sat1],'linewidth',2,'color','g')
text(s_l1,t_sat1,'4','FontSize',10)
xlabel('Entropy(kJ/kg-K)')
ylabel('Temperature(k)')
title('T-S graph')
% h-s graph
figure(2)
hold on
for i = 1:length(t)
plot(XSteam('sL_T',t(i)),XSteam('hL_T',t(i)),'r.')
plot(XSteam('sV_T',t(i)),XSteam('hV_T',t(i)),'r.')
end
% for Cycle
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1],'linewidth',2,'color','g')
text(s1,h1,'1','FontSize',10)
text(s2,h2,'2','FontSize',10)
text(s3,h3,'3','FontSize',10)
text(s4,h4,'4','FontSize',10)
xlabel('Entropy(kJ/kg-K)')
ylabel('Enthalpy(kJ/kg)')
title('H-S graph')
Output :
Error faced :
Invalid characters are been solved by using the using proper notations of valid character
Not finding the values of entities from Xsteam table solved by using Xsteam in a proper way
Graph not being complete solved by using the red dots