Project 2 - Rankine cycle Simulator
Aim: To create a Rankine Cycle Simulator using MATLAB using a set of inpute and to plot T-s and h-s plots for the given set of inputs.
Processes:
1-2 : Isentropic expansion in turbine.
2-3 : Constant pressure heat adddition in condenser.
3-4 : Isentropic compression by Pump.
4-1 : Constant pressure heat rejection in boiler.
Main code:
clear all
close all
clc
%turbine property calculation
turbine_temp_inlet = input('Input turbine inlet temperature in degreeC :');
turbine_pr_inlet = input('Input turbine inlet Pressure in bar :');
turbine_pr_outlet = input('Input turbine outlet Pressure in bar :');
turbine_enthalpy_inlet = XSteam('h_pT',turbine_pr_inlet,turbine_temp_inlet);
turbine_entropy_inlet = XSteam('s_ph',turbine_pr_inlet,turbine_enthalpy_inlet);
turbine_entropy_outlet = turbine_entropy_inlet;
turbine_enthalpy_outlet = XSteam('h_ps',turbine_pr_outlet,turbine_entropy_outlet);
turbine_temp_outlet = XSteam('T_hs',turbine_enthalpy_outlet,turbine_entropy_outlet);
turbine_dryness_outlet = XSteam('x_ph',turbine_pr_outlet,turbine_enthalpy_outlet);
%Condenser property calculation
condenser_pr_inlet = turbine_pr_outlet;
if turbine_dryness_outlet<1
condenser_temp_inlet = turbine_temp_outlet;
condenser_entropy_inlet = turbine_entropy_outlet;
condenser_enthalpy_inlet = turbine_enthalpy_outlet;
else
condenser_temp_inlet = XSteam('Tsat_p',condenser_pr_inlet)
condenser_entropy_inlet = XSteam('sV_p',condenser_pr_inlet)
condenser_enthalpy_inlet = XSteam('hV_p',condenser_pr_inlet)
end
%Pump property calculation
pump_pr_inlet = condenser_pr_inlet;
pump_temp_inlet = XSteam('Tsat_p',pump_pr_inlet);
pump_enthalpy_inlet = XSteam('hL_p',pump_pr_inlet);
pump_entropy_inlet = XSteam('sL_p',pump_pr_inlet);
%Boiler property calculation
boiler_entropy_inlet = pump_entropy_inlet;
boiler_pressure_inlet = turbine_pr_inlet;
boiler_enthalpy_inlet = XSteam('h_ps',boiler_pressure_inlet,boiler_entropy_inlet);
boiler_temp_inlet = XSteam('T_hs',boiler_enthalpy_inlet,boiler_entropy_inlet);
upper_sattemp = XSteam('Tsat_p',boiler_pressure_inlet);
boiler_satenthalpy_inlet = XSteam('hL_T',upper_sattemp);
boiler_satenthalpy_outlet = XSteam('sV_T',upper_sattemp);
boiler_satentropy_inlet = XSteam('sL_T',upper_sattemp);
boiler_satentropyvapour_inlet = XSteam('sV_T',upper_sattemp);
temp = linspace(1,400,100);
for i = 1:length(temp)
entropy_V(1,i) = XSteam('sV_T',temp(i));
entropy_L(1,i) = XSteam('sL_T',temp(i));
enthalpy_V(1,i) = XSteam('hV_T',temp(i));
enthalpy_L(1,i) = XSteam('hL_T',temp(i));
end
figure(1)
hold on
%Plotting the curve 1 t-s curve
plot([turbine_entropy_inlet turbine_entropy_outlet],[turbine_temp_inlet turbine_temp_outlet],'-','linewidth',1.2,'color','b')
plot([turbine_entropy_outlet condenser_entropy_inlet],[turbine_temp_outlet condenser_temp_inlet],'-','linewidth',1.2,'color','c')
plot([condenser_entropy_inlet pump_entropy_inlet],[condenser_temp_inlet pump_temp_inlet],'-','linewidth',1.2,'color','c')
plot([pump_entropy_inlet boiler_entropy_inlet],[pump_temp_inlet boiler_temp_inlet],'-','linewidth',1.2,'color','g')
plot([boiler_entropy_inlet boiler_satentropy_inlet],[boiler_temp_inlet upper_sattemp],'-','linewidth',1.2,'color','r')
plot([boiler_satentropy_inlet boiler_satentropyvapour_inlet],[upper_sattemp upper_sattemp],'-','linewidth',1.2,'color','r')
plot([boiler_satentropyvapour_inlet turbine_entropy_inlet],[upper_sattemp turbine_temp_inlet],'-','linewidth',1.2,'color','r')
plot([entropy_L entropy_V],[temp temp],'linewidth',1.2,'color','k')
legend('Turbine','Condenser','Pump','Boiler','location','northeast')
ylabel('Temperature (^oC)')
xlabel('Entropy (kJ/kgK)')
axis([0 10 0 500])
title('Temperature V/s Entropy')
%Plotting the curve 1 h-s curve
figure(2)
hold on
plot([turbine_entropy_inlet turbine_entropy_outlet],[turbine_enthalpy_inlet turbine_enthalpy_outlet],'-','linewidth',1.2,'color','b')
plot([turbine_entropy_outlet condenser_entropy_inlet],[turbine_enthalpy_outlet condenser_enthalpy_inlet],'-','linewidth',2,'color','c')
plot([condenser_entropy_inlet pump_entropy_inlet],[condenser_enthalpy_inlet pump_enthalpy_inlet],'-','linewidth',2,'color','c')
plot([pump_entropy_inlet boiler_entropy_inlet],[pump_enthalpy_inlet boiler_enthalpy_inlet],'-','linewidth',1.2,'color','g')
plot([boiler_entropy_inlet turbine_entropy_inlet],[boiler_enthalpy_inlet turbine_enthalpy_inlet],'-','linewidth',1.2,'color','r')
plot([entropy_L entropy_V],[enthalpy_L enthalpy_V],'linewidth',1.2,'color','k')
ylabel('Enthalpy (kJ/kg)')
xlabel('Entropy (kJ/kgK)')
axis([0 10 0 4000])
legend('Turbine','Condenser','Pump','Boiler','location','northeast')
title('Enthalpy V/s Entropy')
%To print the values at each points
fprintf('At state 1: \n P1 = %f \n T1 = %f \n H1 = %f \n S1 =%f\n\n',turbine_pr_inlet,turbine_temp_inlet,turbine_enthalpy_inlet,turbine_entropy_inlet)
fprintf('At state 2: \n P2 = %f \n T2 = %f \n H2 = %f \n S2 =%f\n\n',condenser_pr_inlet,condenser_temp_inlet,condenser_enthalpy_inlet,condenser_entropy_inlet)
fprintf('At state 3: \n P3 = %f \n T3 = %f \n H3 = %f \n S3 =%f\n\n',pump_pr_inlet,pump_temp_inlet,pump_enthalpy_inlet,pump_entropy_inlet)
fprintf('At state 4: \n P4 = %f \n T4 = %f \n H4 = %f \n S4 =%\n\nf',boiler_pressure_inlet,boiler_temp_inlet,boiler_enthalpy_inlet,boiler_entropy_inlet)
Code explanation:
- Initiallly the code starts with the input of turbine inlet and outlet pressure and the inlet temperature
- The turbine inlet enthalpy is calculated by using inlet temperature and pressure.
- Subsequently the inlet entropy is calucalted by inputting the enthalpy found and pressure inputted.
- Being an isentropic process the outlet and inlet entropy of the turbine are same.
- Outlet enthalpy was found by using pressure outlet and entropy outlet.
- The outlet temperature was calculated by using outlet enthalpy and entropy.
- now the dryness of the outlet steam is calculated if the dryness is less than 1 then the inlet entropy, enthalpy and temperature of the condenser equals that of the property of turbine at outlet
- Else inlet entropy, enthalpy and temperature of the condenser will be sturated and the saturated vapour values of this is calculated with the help of turbine outlet pressure.
- The entropy, enthalpy and temperature at the boiler entropy is equal to the saturated liquid values at turbine outlet pressure.
- Now, the boiler entropy and pressure are same as that of the turbine.
- The temperature at inlet of boiler is computed from upper pressure limit and the entropy at inlet of the pump.
- The saturated liquid and vapour values are found at upper temperature limit.
- Each values are plotted.
- Also saturated liquid and vapour values of entropy and enthalpy was found for a set of temperature by using a for loop.
Results:
Screen shots of properties at each states:

Plot of Temperature v/s Entropy:

Plot of Enthalpy v/s Entropy:
