Project 2 - Rankine cycle Simulator using MATLAB
AIM: To create a Rankine Cycle Simulator using MATLAB.
THEORY:
- What is a Rankine cycle?
Rankine cycle is a vapour power cycle commonly found in thermal power plants to generate power. The Rankine cycle is an idealized thermodynamic cycle of a heat engine .It is idealized because the friction losses in each of the four components (Turbine, Condenser, Pump and Boiler) are neglected. Here, the working fluid is water . Power depends on the temperature difference between maximum temperature and minimum temperature. Higher the difference, the more mechanical power can be efficiently extracted out of heat energy as per Carnot’s theorem.
The four processes in a basic Rankine cycle are:
- Isentropic expansion in the turbine
- Constant pressure heat rejection by the condenser
- Isentropic compression in the pump
- Constant pressure heat addition by the pump
Efficiency of a Rankine cycle can be calculated as follows:
Here, T2 is the outlet temperature of Turbine. Tm1 is the mean temperature of heat addition.
Figure - Basic Rankine cycle
- Net work output of a Rankine cycle:
Wnet = Wexpansion – Wcompression
= m(h1 – h2) – m(h4 – h3)
- Back work ratio:
The fraction of the work produced by the turbine that is consumed by the compressor is called the back work ratio of a Rankine cycle.
Back work ratio = Wcompression / Wexpansion
= m(h1 – h2) / m(h4 – h3)
CODE:
Main code:
clear all
close all
clc
fprintf('------------------------RANKINE CYCLE SIMULATOR---------------------\n\n')
fprintf('1-2 is Isentropic expansion in the turbine \n')
fprintf('2-3 is Constant pressure heat rejection by the condenser \n')
fprintf('3-4 is Isentropic compression in the pump \n')
fprintf('4-1 is Constant pressure heat addition by the boiler \n\n')
%taking the inputs from the user
prompt = 'ENTER THE TURBINE INLET TEMPERATURE \n';
t1=input(prompt);
prompt = 'ENTER THE TURBINE INLET PRESSURE \n';
p1=input(prompt);
prompt = 'ENTER THE TURBINE OUTLET PRESSURE \n';
p2=input(prompt);
fprintf('\n\n-----------------------------RESULTS----------------------------\n\n')
fprintf('At state point 1 \n')
%finding parameters at point 1
v1=XSteam('v_pt',p1,t1) %specific volume
t1 %temperature
p1 %pressure
s1=XSteam('s_pt',p1,t1) %specific entropy
h1=XSteam('h_pt',p1,t1) %specific enthalpy
fprintf('At state point 2 \n')
%finding parameters at point 2
v2=v1
t2=XSteam('tsat_p',p2)
p2
s2=s1
xa=XSteam('x_ps',p2,s2);
h2=XSteam('h_px',p2,xa)
fprintf('At state point 3 \n')
%finding parameters at point 3
v3=XSteam('vl_p',p2)
t3=t2
p3=p2
s3=XSteam('sl_p',p2)
h3=XSteam('hl_p',p2)
fprintf('At state point 4 \n')
%finding parameters at point 4
v4=v3
p4=p1
s4=s3
t4=XSteam('t_ps',p4,s4)
h4=XSteam('h_pt',p4,t4)
fprintf('At state point 5 \n')
%finding parameters at point 5
t5=XSteam('tsat_p',p1)
v5=XSteam('vl_p',p1)
s5=XSteam('sl_p',p1)
p5=p1
h5=XSteam('hl_p',p1)
fprintf('At state point 6 \n')
%finding parameters at point 6
t6=t5
v6=XSteam('vv_p',p1)
s6=XSteam('sv_p',p1)
p6=p1
h6=XSteam('hv_p',p1)
if(t1==0)
fprintf('The cycle cannot have %f as the inlet temperature of the cycle',t1)
end
temp=linspace(0,t1,500);
%finding different parametres for drawing the saturated liquid line and
%saturated vapour line in t-s and h-s plots
for i=1:500
sat_liq_s1(i) =XSteam('sl_t',temp(i)); %saturated liquid entropy
sat_vap_s1(i) =XSteam('sv_t',temp(i)); %saturated vapour entropy
sat_liq_h(i) =XSteam('hl_t',temp(i)); %saturated liquid enthalpy
sat_vap_h(i) =XSteam('hv_t',temp(i)); %saturated vapour enthalpy
psat(i)=XSteam('psat_t',temp(i)); %saturated pressure
sat_liq_s2(i) =XSteam('s_ph',psat(i),sat_liq_h(i)); %saturated liquid entropy at a particular pressure and enthalpy
sat_vap_s2(i) =XSteam('s_ph',psat(i),sat_vap_h(i)); %saturated vapour entropy at a particular pressure and enthalpy
end
%plotting temperature vs specific entropy plot
figure(1)
plot(sat_liq_s1,temp,'color','b') %saturated liquid line
hold on
plot(sat_vap_s1,temp,'color','b') %saturated vapour line
%marking the points
plot(s1,t1,'-O','MarkerSize',5,'MarkerFaceColor','k')
plot(s2,t2,'-O','MarkerSize',5,'MarkerFaceColor','k')
plot(s3,t3,'-O','MarkerSize',5,'MarkerFaceColor','k')
plot(s4,t4,'-O','MarkerSize',5,'MarkerFaceColor','k')
plot(s5,t5,'-O','MarkerSize',5,'MarkerFaceColor','k')
plot(s6,t6,'-O','MarkerSize',5,'MarkerFaceColor','k')
%joining points
plot([s1 s2],[t1 t2],[s2 s3],[t2 t3],[s3 s4],[t3 t4],[s4 s5],[t4 t5],[s5 s6],[t5 t6],[s6 s1],[t6 t1],'linewidth',2,'color','cyan')
xlabel('SPECIFIC ENTROPY(J/K-Kg)')
ylabel('TEMPERATURE(celsius)')
title('temperature vs specific entropy')
hold off
%plotting specific enthalpy vs specific entropy plot
figure(2)
plot(sat_liq_s2,sat_liq_h,'color','b') %saturated liquid line
hold on
plot(sat_vap_s2,sat_vap_h,'color','b') %saturated vapour line
%marking the points
plot(s1,h1,'-O','markersize',5,'markerfacecolor','k')
plot(s2,h2,'-O','markersize',5,'markerfacecolor','k')
plot(s3,h3,'-O','markersize',5,'markerfacecolor','k')
plot(s4,h4,'-O','markersize',5,'markerfacecolor','k')
plot(s5,h5,'-O','markersize',5,'markerfacecolor','k')
plot(s6,h6,'-O','markersize',5,'markerfacecolor','k')
%joining points
plot([s1 s2],[h1 h2],[s2 s3],[h2 h3],[s3 s4],[h3 h4],[s4 s5],[h4 h5],[s5 s6],[h5 h6],[s6 s1],[h6 h1],'linewidth',2,'color','green')
xlabel('SPECIFIC ENTROPY(J/Kg-K)')
ylabel('SPECIFIC ENTHALPY(J/Kg)')
title('specific enthalpy vs specific entropy')
hold off
%Calculating back work ratio and net work output of the Rankine cycle
W_exp = h1-h2; %For mass = 1kg
W_com = h4-h3; %for mass = 1kg
BACK_WORK_RATIO = W_com/W_exp
NET_WORK_OUTPUT__joule = W_exp - W_com
OUTPUT:
Snip of command window, showing different parameters at different state points
snip - required output
EXPLANATION OF CODE AND OUTPUT:
In the main code, I have first taken the required inputs from the user. Then I found different parameters (specific volume, temperature, pressure, specific entropy and specific enthalpy) for state points 1 to 6 using function XSteam(). Then I found different parametres for drawing the saturated liquid line and saturated vapour line in t-s and h-s plots. Then I plotted temperature vs specific entropy plot. Then plotting of enthalpy vs specific entropy plot is done.
In the output, I have shown 2 plots – temperature vs specific entropy and specific enthalpy vs specific entropy. In the command window, I have shown different parameters at different state points. I calculated the Back work ratio and net work output of the Rankine cycle.
ERROR:
Error 1. Following error was displayed. The h vs s plot was not proper.
Error 1
STEPS TAKEN TO OVERCOME ERROR:
The error was in line no. 111 of the main code. I first calculated the values of saturated vapour entropy at a particular pressure and enthalpy in line no. 85. Then I used it in line no. 111 for plotting. This resolved my error.
RESULT:
Rankine Cycle Simulator using MATLAB is created.
REFERENCE: