Project 2 - Rankine cycle Simulator
%% Rankine Cycle Simulator
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%objective of this programme is to simulate the rankine cycle
%plotting t-s and h-s diagram using data from XStream data
%water and steam properties according to IAPWS IF-97
clear all
close all
clc
%%
disp('RANKINE CYCLE'); %Displaying
disp('1-2 Isentropic Expansion in the turbine');
disp('2-3 costant pressure heat removal in the condenser');
disp('3-4 Isentropic compression in the pump');
disp('4-1 Constant pressure heat addition in the boiler');
%%
%Obtaining the input data
p1 = input('nValue of pressure at turbine inlet,p1(in bar) = ');
T1 = input('nValue of temperature at turbine inlet, T1(in degree.C') = ');
P2 = input('nValue of temperature at condenser inlet, p2(in bar) =');
%%
% Extracting data_defining variables
% State 1
h1 = XSteam('h_pT',p1, T1); % extracting at state pt 1
s1 = XSteam('s_PT', p1,T1); % similarly
% State 2
s2 = s1; % Isentropic expansion
sf2= Xsteam('sL_p' , p2); % saturated liquid entropy
sg2= Xsteam('sL_p' , p2); % saturated vapour entropy
x2 = (s2-sf2)/(sg2-sf2);
hf2= Xsteam('hL_p' , p2);
hg2= Xsteam('hV_p' , p2);
h2 = hf2 + (x2*(hg2-hf2));
% State 3
p3 = p2;
s3 = XSteam('sL_p' , p3)
h3 = XSteam('hL_p', p3);
% State 4
s4 = s3;
p4 = p1;
%%
% Work done by turbine
wt = h1 - h2:
% Work done to run pump
v3 = XSteam('vL_p', p3);
Wp = v3*(p4 - p3)*100;
h4 = h3 + Wp;
%net work
Wnet = Wt - Wp;
%Heat into the system
Qin = h1 - h4;
%Heat out of the system
Qout = h2 - h3;
%Thermal efficiency
eff = (Wnet/Qin)*100;
%Specific steam consumption
%SSC = mass flow rate/power
SSC = (3600/Wnet);
%%
%calculating temperatures at state points
T3 = XSteam('Tsat_p' , p3);
T2 = T3;
Cp4 = XSteam('Cp_ps' , p4,s4);
k = Cp4/Cv4;
T4 = T3/((p3/p4)^((k-1)/k));
%Calculating temperature , entropy and enthalpy at the vapour and liquid
%line for plotting
T6 = Xsteam('Tsat_p', p1);
s5 = XSteam('sL_p' , p1);
s6 = Xsteam('sV_p', p1);
h5 = XSteam('hL_p',p1);
h6 = XSteam('hV_p',p1);
T5 = T6;
%%
%Plotting the saturation curve
T = linspace(1,375,1000);
for i = 1:length(T)
sf(i) = XSteam('sL_T', T(i));
sg(i) = XSteam('sV_T', T(i));
hf(i) = XSteam('hL_T', T(i));
hg(i) = XSteam('hV_T', T(i));
end