Project 2 - Rankine cycle Simulator
AIM/OBJECTIVE:
Understand the concept of Rankine cycle by referring to standard thermal engineering text book.
- Create a Rankine Cycle Simulator using OCTAVE/MATLAB.
- Your code should calculate the state points of the Rankine Cycle (any type of your choice) based on user inputs.
- Then, plot the corresponding T-s and h-s plots for the given set of inputs. Title and axes labels are a must, while legends could be used if necessary.
- The presentation of your code will be taken into consideration while grading. Labelling sections of your code using comments is appreciated.
- Attach a report explaining the working of a rankine cycle simulator and also the research done by you.
Inputs Given:
Turbine Inlet temperature = 400° C
Turbine Inlet Pressure = 30 bars
Turbine Outlet Pressure = 0.05 bars = Condenser Inlet Pressure
Xsteam.m Library
Calculate the followings
- Net work output
- Back work ratio
RANKINE CYCLE
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. The Rankine cycle is named after William John Macquorn Rankine, a Scottish polymath professor at Glasgow University.
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.
Physical layout of the Rankine cycle
- Pump, 2. Boiler, 3. Turbine, 4. Condenser
The Rankine cycle closely describes the process by which steam engines commonly found in thermal power generation plants harness the thermal energy of a fuel or other heat source to generate electricity. Possible heat sources include combustion of fossil fuels such as coal, natural gas, and oil, use of mined resources for nuclear fission, renewable fuels like biomass and ethanol, or energy capture of natural sources such as concentrated solar power and geothermal energy. Common heat sinks include ambient air above or around a facility and bodies of water such as rivers, ponds, and oceans.
The ability of a Rankine engine to harness energy depends on the relative temperature difference between the heat source and heat sink. The greater the differential, the more mechanical power can be efficiently extracted out of heat energy, as per Carnot's theorem.
The efficiency of the Rankine cycle is limited by the high heat of vaporization of the working fluid.
RANKINE CYCLE'S FOUR PROCESSES
T–s diagram of a typical Rankine cycle operating between pressures of 0.06 bar and 50 bar. Left from the bell-shaped curve is liquid, right from it is gas, and under it is saturated liquid–vapour equilibrium.
There are four processes in the Rankine cycle. The states are identified by numbers (in brown) in the T–s diagram.
- 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.
In an ideal Rankine cycle the pump and turbine would be isentropic, i.e., the pump and turbine would generate no entropy and hence maximize the net work output.
Processes 1–2 and 3–4 would be represented by vertical lines on the T–s diagram and more closely resemble that of the Carnot cycle.
The Rankine cycle shown here prevents the state of the working fluid from ending up in the superheated vapor region after the expansion in the turbine, which reduces the energy removed by the condensers.
Logic used to code the MATLAB Program
- Display the steps of the Rankine cycle in the command window using disp() and fprintf() commands.
- Create three inputs to get the inputs from the user using input() and store the corresponding input in the appropriate state point variable. The working fluid is at state point 1 at the inlet of the turbine. Hence store inlet temperature in T1, inlet pressure in P1 and exit pressure in P2.
- Using XSteam() function, obtain the enthalpy, entropy and temperature of the saturation vapour. XSteam() takes the name of the data called for in the function and the corresponding state point values as input arguments. In the first argument, V stands for saturated vapour, L for saturated liquid, h for enthalpy and so on.
- Use if condition to check if the water superheated or saturated vapour at inlet of turbine.
- If water is superheated, obtain enthalpy and entropy at point 1 using XSteam() as a function of pressure and temperature.
- If water is saturated vapour, then enthalpy and entropy will be equal to previously obtained values.
- At state point 2, entropy remains unchanged.
- In order to calculate the dryness fraction, first obtain the values of entropy of saturated liquid and vapour at pressure P2 using XSteam() and substitute in the formula.
- Obtain the values of enthalpy and temperature of saturated vapour at pressure P2.
- Check for the dryness fraction to calculate the state point 2 values.
- If x2=1, then it is saturated vapour. In this case state point 2 properties are equal to properties at saturated vapour line at P2.
- If x2<1, then the water is mixture of liquid and vapour. In this case, obtain enthalpy value by supplying pressure P2 and dryness fraction value. T2 will be same as saturation temperature at P2.
- If x2>1, the water is still superheated steam. T2 and H2 values are obtained by using XSteam() for P2 and S2 values.
- At state point 3, pressure at this point remains the same.T3, S3, H3 values are obtained for saturated liquid at pressure P3.
- At state point 4, entropy remains the same and pressure increases back to P1 level, as ideal Rankine cycle is reversible. T4 and H4 values are obtained by using function of P4 and S4 values.
- Work done in Turbine, Work done for Pump, Thermal efficiency, Specific Steam Consumption, Net work done and Back work ratio are calculated by substituting the enthalpy values.
- Then data for the diagram is prepared. Temperature values are created from 0 deg Celcius to critical temperature using linspace(). For all the values of temperature, enthalpy and entropy values are obtained for saturated liquid phase and stored in arrays.
- Temperature values in array are reversed using fliplr(). Then again, corresponding enthalpy and entropy values are obtained from XSteam() for saturated vapour phase..
- Entropy array is created from S4 to S1 for 4-1 process. And respective enthalpy and temperature values are obtained at pressure P1 and sequential entropy data.
- Again, entropy array is created from S2 to S3 for process 2-3. And respective enthalpy and temperature values are obtained at pressure P2 and sequential entropy data.
- Using figure command, two different figures are created for T-S and H-S diagram.
- Plot command is used to plot the diagrams for saturated water first and then for rankine cycle. Legend is used to symbolize the various markers and line. Text command is used to mark all the points on the plot.
- The results are printed on the command window using fprintf() function.
Code Snippet
clear variables
close all
clc
%Displaying the Rankine Cycle Process
fprintf("\t\t\t\t RANKINE CYCLE SIMULATOR : \n\n")
disp("1-2 ==> Isentropic Expansion in the Turbine")
disp("2-3 ==> Constant Pressure Heat Rejection by the Condenser")
disp("3-4 ==> Isentropic Compression in the Pump")
disp("4-1 ==> Constant Pressure Heat Addition by the Boiler")
%Getting inputs from the user
Input1="\nEnter the Pressure at the Turbine Inlet (in bar):";
P1=input(Input1);
Input2="Enter the Temperature at the Turbine Inlet (in Degree Celcius):";
T1=input(Input2);
Input3="Enter the Pressure at the Condenser (in bar):";
P2=input(Input3);
%State point 1 calculation by taking data from XSteam
hg1=XSteam('hV_p',P1); %Saturated vapour enthalpy at pressure P1
sg1=XSteam('sV_p',P1); %Saturated vapour entropy at pressure P1
Tsat1=XSteam('TSat_p',P1);
%Checking whether the steam at turbine inlet is superheated or saturated vapour
if T1>Tsat1
H1=XSteam('h_pT',P1,T1);
S1=XSteam('s_pT',P1,T1);
else if T1==Tsat1
H1=hg1;
S1=sg1;
end
end
%State point 2 calculation by taking data from XSteam
S2=S1; %Isentropic Expansion
sf2=XSteam('sL_p',P2); %Saturated liquid entropy at pressure P2
sg2=XSteam('sV_p',P2); %Saturated vapour entropy at pressure P2
x2=(S2-sf2)/(sg2-sf2); %Calculating the dryness fraction
hg2=XSteam('hV_p',P2); %Saturated vapour enthalpy at pressure P2
hf2=XSteam('hL_p',P2); %Saturated liquid enthalpy at pressure P2
Tsat2=XSteam('TSat_p',P2);
%Checking if the steam at the turbine outlet is superheated,
%saturated vapour or mixture of vapour and liquid.
if x2==1 % Steam is saturated vapour
H2=hg2;
S2=sg2;
T2=Tsat2;
else if x2<1 %Steam is mixture
H2=XSteam('h_px',P2,x2);
T2=Tsat2;
else %Steam is superheated
T2=XSteam('T_ps',P2,S2);
H2=XSteam('h_ps',P2,S2);
end
end
% State point 3 calculation:
P3=P2; %Isobaric process, so pressure remains same.
H3=XSteam('hL_p',P3); %Saturated liquid enthalpy at pressure P3
S3=XSteam('sL_p',P3); %Saturated liquid entropy at pressure P3
T3=XSteam('Tsat_p',P3); %Saturation temperature at pressure P3
%State point 4 calculation:
P4=P1; %Constant pressure heat rejection
S4=S3; %Isentropic compression process
H4=XSteam('h_ps',P4,S4); %Entalpy as a function of pressure and entropy.
T4=XSteam('T_ps',P4,S4); %Temperature as a function of pressure and entropy
WD_Turbine=H1-H2; %Work done in Turbine for the Rankine cycle
WD_Pump=H3-H4; %Work done for Pump
WD_Net=WD_Turbine-WD_Pump; %Net work done for Rankine cycle
Q_in=H1-H4; %Heat addition to the system
Q_out=H2-H3; %Heat rejection from the system
Therm_effi=(WD_Net/Q_in)*100; %Thermal efficiency of Ranlkine cycle
SSC=(3600/WD_Net); %Specific steam consumption
BWR=WD_Pump/WD_Turbine; %Back Work Ratio
%Preparing data for T-S and H-S diagram of water
Tc=373.9457; %Critical temperature of water in deg Celcius
T_L=linspace(0,Tc,1000); %Temperature range for saturated liquid line
for i=1:length(T_L)
STL(i)=XSteam('sL_T',T_L(i));
HTL(i)=XSteam('hL_T',T_L(i));
end
T_V=fliplr(T_L); % Temperature range for saturated vapour line
for i=1:length(T_V)
STV(i)=XSteam('sV_T',T_V(i));
HTV(i)=XSteam('hV_T',T_V(i));
end
%Data for process 4-1 of Rankine cycle
s41=linspace(S4,S1,1000);
for i=1:length(s41)
T41(i)=XSteam('T_ps',P1,s41(i));
h41(i)=XSteam('h_ps',P1,s41(i));
end
%Data for process 1-2 of Rankine Cycle
s23=linspace(S2,S3,1000);
for i=1:length(s23)
T23(i)=XSteam('T_ps',P2,s23(i));
h23(i)=XSteam('h_ps',P2,s23(i));
end
%Plotting T-S diagram of water and Rankine cycle
figure(1)
plot([STL STV],[T_L T_V],'linewidth',1.5,'color','r');
hold on
%Marking the Temperature and entropy state points on the diagram
plot([S1,S2,S3,S4],[T1,T2,T3,T4],'*','color','g');
text([S1,S2,S3,S4],[T1,T2,T3-20,T4+20],{'1','2','3','4'});
plot([s41,s23],[T41,T23],'linewidth',2.5,'color','b')
xlabel('Entropy KJ/kg-C');
ylabel('Temperature degree C');
title('T-S diagram of H2O');
legend('Saturated Liquid and Vapour line','State points','Rankine Cycle');
%Plotting H-S diagram of water and Rankine cycle:
figure(2)
%Marking the Enthalpy and Entropy State points on the diagram
plot([S1,S2,S3,S4],[H1,H2,H3,H4],'*','color','g');
hold on
%Numbering the state points
text([S1,S2,S3,S4],[H1,H2,H3-20,H4+100],{'1','2','3','4'});
plot([STL STV],[HTL HTV],'linewidth',1.5,'color','r');
plot([s41 s23],[h41 h23],'linewidth',2.5,'color','b');
legend('State points','Saturated Liquid and Vapour line','Rankine Cycle');
xlabel('Entropy KJ/kg-C');
ylabel('Enthalpy KJ/kg');
title('H-S diagram of H2O');
fprintf("\n\t\t\t\t\tResults(Rankine Cycle)\n\n");
fprintf("At State point 1:\t\t\t\t\t");
fprintf("At State point 4:\n");
fprintf("P1 is : %5.2f Bar\t\t\t\t\t",P1);
fprintf("P4 is : %5.2f Bar\n",P4);
fprintf("T1 is : %5.2f deg Celcius\t\t\t",T1);
fprintf("T4 is : %5.2f deg Celcius\n",T4);
fprintf("H1 is : %5.2f KJ/kg\t\t\t\t",H1);
fprintf("H4 is : %5.2f KJ/kg\n",H4);
fprintf("S1 is : %5.2f KJ/kg-deg Celcius\t\t",S1);
fprintf("S4 is : %5.2f KJ/kg-deg Celcius\n\n",S4);
fprintf("At State point 2:\t\t\t\t\t");
fprintf("Wt is : %5.2f KJ/kg\n",WD_Turbine);
fprintf("P2 is : %5.2f Bar\t\t\t\t\t",P2);
fprintf("Wp is : %5.2f KJ/kg\n",WD_Pump);
fprintf("T2 is : %5.2f deg Celcius\t\t\t",T2);
fprintf("Wnet is : %5.2f KJ/kg\n",WD_Net);
fprintf("H2 is : %5.2f KJ/kg\t\t\t\t",H2);
fprintf("Ntherm is : %5.2f Percent\n",Therm_effi);
fprintf("S2 is : %5.2f KJ/kg-deg Celcius\t\t",S2);
fprintf("S.S.C is : %5.2f kg/kWh\n",SSC);
fprintf("X2 is : %5.2f \t\t\t\t\t\t",x2);
fprintf("B.W.R is : %5.2f \n\n",x2);
fprintf("At State point 3:\n");
fprintf("P3 is : %5.2f Bar\n",P3);
fprintf("T3 is : %5.2f deg Celcius\n",T3);
fprintf("H3 is : %5.2f KJ/kg\n",H3);
fprintf("S3 is : %5.2f KJ/kg-deg Celcius\n\n",S3);
OUTPUTS:

PLOTS GENERATED


ERRORS Encountered
Many typo errors were encountered and were resolved.