Project 2 - Rankine cycle Simulator
Aim:- Create a Rankine Cycle Simulator from given input using MATLAB.
Objective:-
1. Create a Rankine Cycle Simulator.
2. To calculate the state points of Rankine cycle based on user inputs.
3. To plot the T-S and H-S curve for given input in Rankine cycle. To get output in command window for each state points on cycle.
4. Calculate Efficiency ,Net work output and Back work ratio.
Theory:-
The Rankine cycle is an idealized thermodynamic cycle describing the process by which certain heat engines , such as steam turbines or reciprocating steam engines, allow mechanical work to be extracted from a fluid as it moves between a heat source and heat sink.
Heat energy is supplied to the system via a boiler where the working fluid (typically water) is converted to a high pressure gaseous state (steam) in order to turn a turbine. After passing over the turbine the fluid is allowed to condense back into a liquid state as waste heat energy is rejected before being returned to boiler, completing the cycle. Friction losses throughout the system are often neglected for the purpose of simplifying calculations as such losses are usually much less significant than thermodynamic losses, especially in larger systems.

There are four processes in the Rankine cycle.
- Process 1–2: 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 1-2 is isentropic compression.
- Process 2–3: The high-pressure liquid enters a boiler, where it is heated at constant pressure by an external heat source to become a dry saturated vapour. 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 or software. Process 2-3 is constant pressure heat addition in boiler.
- Process 3–4: The dry saturated vapour expands through a turbine, generating power. This decreases the temperature and pressure of the vapour, and some condensation may occur. The output in this process can be easily calculated using the chart or tables noted above. Process 3-4 is isentropic expansion.
- Process 4–1: The wet vapour then enters a condenser, where it is condensed at a constant pressure to become a saturated liquid. Process 4-1 is constant pressure heat rejection in condenser.
Matlab code:-
% A program for Rankine cycle simulator.
clear all
close all
clc
% Output Header
fprintf('Rankine cycle simulator\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\r\n')
% Inputs
p1 = input('Enter the pressure at turbine inlet (in bar):');
t1 = input('Enter the Temperature at turbine inlet (in degreesa):');
p2 = input('Enter the pressutr at condensor inlet (in bar):');
% Extracting specific heat values using function XSteam
cp1_l = XSteam('CpL_p',p1);
cp1_v = XSteam('CpV_p',p1);
cp1_l = XSteam('CpL_p',p2);
cp1_v = XSteam('CpV_p',p2);
% Inputs to the turbine
s1 = XSteam('s_pT',p1,t1);
h1 = XSteam('h_pt',p1,t1);
% Condenser inlet
s2=s1; % 1-2 is an isentropic expansion process
sf2=XSteam('sL_p',p2); % Saturated liquid entropy at pressure 2
sg2=XSteam('sV_p',p2); % Saturated vapour entropy at pressure 2
hf2=XSteam('hL_p',p2); % Saturated liquid enthalpy at pressure 2
hg2=XSteam('hV_p',p2); % Saturated vapour enthalpy at pressure 2
% saturated temperature
Tsat_p1=XSteam('Tsat_p',p1);
Tsat_p2=XSteam('Tsat_p',p2);
% calculating dryness fraction
if(s2<=sg2)
x2 = ((s2-sf2) / (sg2-sf2)); % dryness fraction at state point 2
else
x2=1;
end
if (x2<1)
t2= Tsat_p2;
else
% s2 = sg_2+cp2_v*(log(T2/Tsat_p2))
t2 = (Tsat_p2+273.15)*exp((s2-sg2)/cp1_v);
t2 = t2 - 273.15; % Temperature at state point 2
end
if(x2<1)
h2=hf2+(x2*(hg2-hf2));
else
h2 = XSteam('h_pT',p2,t2); % Enthalpy at state point 2
end
% condenser exit
p3=p2; % Constant pressure heat removal process
t3=XSteam('Tsat_p',p3); % Saturation temperature at Pressure 3
s3=XSteam('sL_p',p3); % Saturated liquid entropy at pressure 3
h3=XSteam('hL_p',p3); % Saturated liquid enthalpy at pressure 3
v3=XSteam('vL_p',p3); % Saturated liquid vapour at pressure 3
t2=t3; % Because of constant pressure heat addition
% boiler inlet
p4=p1; % constant pressure heat addition
s4=s3; % isentropic compression in the pump
h4=XSteam('h_ps',p4,s4); % Enthalpy at state 4
cp4=XSteam('Cp_ps',p4,s4); % Specific isobaric heat capacity
cv4=XSteam('Cv_ps',p4,s4); % Specific isobaric heat capacity
g4=(cp4/cv4);
% calculation for t4
% p4^(1-gamma)*t4^gamma=p3^(1-gamma)*t3^gamma;
t4=(t3*((p3/p4)^((1-g4)/g4))); % Temperature at state point 4
% calculations
% work done by the turbine
Wt=h1-h2;
% work done by the pump
Wp=h4-h3;
% net work done
W_net =Wt-Wp;
% heat added in the boiler
q_in =h1-h4;
% heat rejected in the condenser
q_out =h2-h3;
% thermal efficiency
n=(W_net/q_in)*100;
% back work ratio
bwr = Wp/Wt;
% steam rate
ssc = 3600/W_net; % Specific steam consumption = (Mass flow rate / Net work done )
% ploting the results
figure(1)
% ploting 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',1,'LineStyle','--','Color','r')
plot(s_v,t,'lineWidth',1,'LineStyle','--','Color','r')
grid on
% ploting for the work done by turbine (process 1-2)
plot([s1,s2],[t1,t2],'LineWidth',1,'Color','k')
hold on
title('T-s Diagram of Ideal Rankine Cycle')
xlabel('Entropy(KJ/KgK)')
ylabel('Temperature(k)')
% ploting for heat rejection in condenser (process 2-3)
plot([s2,s3],[t2,t3],'LineWidth',1,'Color','k')
hold on
% ploting for work done by the pump (process 3-4
plot([s3,s4],[t3,t4],'LineWidth',1,'Color','k')
hold on
% ploting 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',1,'Color','k')
hold on
tq = tp ;
sq = XSteam('sV_T',tq);
plot([sp,sq],[tp,tq],'LineWidth',1,'Color','k')
hold on
plot([sq,s1],[tq,t1],'LineWidth',1,'Color','k')
hold on
% Indicate state 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',1,'Color','k')
grid on
title('h-s Diagram')
xlabel('Entropy(KJ/KgK)')
ylabel('Enthalpy(KJ/Kg)')
hold on
plot([s2,s3],[h2,h3],'LineWidth',1,'Color','k')
hold on
plot([s3,s4],[h3,h4],'LineWidth',1,'Color','k')
hold on
plot([s4,s1],[h4,h1],'LineWidth',1,'Color','k')
% plot for liquid 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',1,'LineStyle','--','Color','r')
hold on
plot(s_v,h_v,'LineWidth',1,'LineStyle','--','Color','r')
% Indicate state with numbers
text(s1,h1,'1');
text(s2,h2,'2');
text(s3,h3,'3');
text(s4,h4,'4');
% Results output
fprintf('\nRESULTS\n');
fprintf('At state point 1:\n')
fprintf('P1 is : %f Bar\n',p1);
fprintf('T1 is : %f Degree Celcius\n',t1);
fprintf('H1 is : %f kJ/Kg\n',h1);
fprintf('S1 is : %f Kj/Kg.k\r\n',s1);
fprintf('At state point 2:\n')
fprintf('P2 is : %f Bar\n',p2);
fprintf('T2 is : %f Degree Celcius\n',t2);
fprintf('H2 is : %f kJ/Kg\n',h2);
fprintf('S2 is : %f Kj/Kg.k\n',s2);
fprintf('X2 is : %f \r\n',x2);
fprintf('At state point 3:\n')
fprintf('P3 is : %f Bar\n',p3);
fprintf('T3 is : %f Degree Celcius\n',t3);
fprintf('H3 is : %f kJ/Kg\n',h3);
fprintf('S3 is : %f Kj/Kg.k\r\n',s3);
fprintf('At state point 4:\n')
fprintf('P4 is : %f Bar\n',p4);
fprintf('T4 is : %f Degree Celcius\n',t4);
fprintf('H4 is : %f kJ/Kg\n',h4);
fprintf('S4 is : %f Kj/Kg.k\r\n',s4);
% Other calculations
fprintf('\n--------------Other calculations--------------\n')
fprintf ('Work Done By Turbine : %f kJ/kg\n',Wt)
fprintf ('Work supplied to Pump : %f kJ/kg\n',Wp)
fprintf ('Heat Added in The Boiler: %f KJ/kg\n' ,q_in)
fprintf ('Heat Rejected in The Condenser: %f KJ/kg\n' ,q_out)
fprintf ('Thermal Efficiency in percentage : %f \n',n)
fprintf ('Specific Steam Consumption : %f KJ/kWh\r\n' ,ssc)
fprintf ('Net Work Done : %f kJ/kg\n',W_net)
fprintf ('Back work ratio : %f \n',bwr)
Explanation:-
* Start the program with ..
clera all- To clear all variables from current workplace.
close all- close all figures whose handles are visible.
clc - clc clears all the text from the command window.
* Then print the process information.
*fprintf()-function is defined to write data as output either to a text file or to any result window.
* Inputs variables p1 ,T1, p2 are given by the input command whose value are entered in command window while executing the program.
* Then find the variables values from XSteam file which is possible.
* Then find the dryness fraction.
* and find the variables at each points of cycle.
* After finding the all required variables calculate the turbine work , pump work , heat rejected , heat supplied ,Specific steam consumption ,back work ratio and Net work ouput.
* After finding the above values we can plot the t-s and h-s graphs.
* Then print the result in command window.
*linspace()- This function will generate a vector of values linearly spaced between two endpoints.
*plot()- creates a 2-D line plot .
*xlabel()- It labels the x-axis of the current plot.
*ylabel()- It labels the y-axis of the current plot.
*title()- add a title to a plot.
*grid on- It displays grid lines.
*hold on -retains the current plot and certain axes properties so that subsequent graphing commands add to the existing graph.
Results:-


* The plots for T-S and H-S diagram are as follows -


Conclusion:-
* For given inputs , performance of Rankine cycle is predicted using MATLAB.
*T-S and H-S diagram is plotted.
* Back work ratio and Net work ouput and Efficiency for Rankine cycle are calculated.
Referenceses:-
https://en.wikipedia.org/wiki/Rankine_cyclRankine cycle - Wikipedia