Challenge

Project 2 - Rankine cycle Simulator

1) Program for Simulating Rankine Cycle:

clear all 
close all
clc

%% Explanation of Rankine Cycle

%Disp and fprintf command is used to show the output or given text on command window
disp('<strong>Rankine Cycle (or) Rankine Vapor Cycle</strong>');
fprintf('\nProcess(1-2): Isentropic Expansion in the Turbine\n');
disp('Process(2-3): Constant Pressure Heat rejection in the Condensor');
disp('Process(3-4): Isentropic Compression in the Pump');
fprintf('Process(4-1): Constant Pressure Heat addition in the Boiler\n\n');

%% Getting the required input values from the user using 'input' command

disp('<strong>Provide the required Inputs for calculating various values of Rankine Cycle</strong>');

% Getting the pressure and temperature value of the turbine inlet and at condensor
t1 = input('\nEnter the Temperature as the Turbine Inlet (in degree celcius): ');

p1 = input('\nEnter the Pressure at the Turbine Inlet (in bar): ');

p2 = input('\nEnter the Pressure at the Condensor (in bar): ');

%% Getting the Entropy and Enthalpy value from XSteam library at the given pressure and temperature

%At state point 1 (Turbine inlet)
s1 = XSteam('s_pT',p1,t1);
h1 = XSteam('h_pT',p1,t1);

%% Getting the Entropy and Enthalpy value from XSteam library at the given pressure and temperature

%At state point 2 (Condensor inlet)
sf2 = XSteam('sL_p',p2);
sg2 = XSteam('sV_p',p2);
hf2 = XSteam('hL_p',p2);
hg2 = XSteam('hV_p',p2);

s2 = s1;
t2 = XSteam('Tsat_p',p2);

%% Calculating Dryness fraction and Enthalpy

x2 = ((s2 - sf2)/(sg2 - sf2));
h2 = hf2 + (x2 * (hg2 -hf2));

%% Getting the Entropy, Temperature and Enthalpy value from XSteam library at the given pressure value

% At state point 3 (Pump input)
 p3 = p2;
 
 t3 = XSteam('Tsat_p',p2);
 s3 = XSteam('sL_p',p3);
 h3 = XSteam('hL_p',p3);
 
 %Getting isochoric and isobaric heat capacity values
 cp4 = XSteam('cpL_p',p3);
 cv4 = XSteam('cvL_p',p3);
 gamma = (cp4/cv4);
 
 g = (gamma - 1)/ gamma;
 
 %% Calculating the Enthalpy, Entropy , Temperature and pressure value at state point 4 (Boiler inlet)
 
 p4 = p1;
 s4 = s3;
 
 h4 = XSteam('h_ps',p4,s4);
 t4 = t3*((p4/p3)^g);
 
 %% Calculating Work done by Turbine
 
 wt = h1 - h2;
 
 
 %% Calculating Work done by Pump
 
 wp = h4 - h3;
 
 
 %% Calculating Work done by System
 
 w_net = wt - wp;
 bwr = (h1 - h4)/(h2 - h3);
 
 %% Calculating Heat added and rejected in the system
 
 q_in = h1 - h4;
 q_out = h2 - h3;
 
 %% Efficiency of the system
 
 np = (w_net/ q_in)*100 ;
 
 %% Getting the saturated liquid and vapor values from XSteam library at the given pressure
 
 SSC = 3600/w_net;
 tf_sat = XSteam('Tsat_p',p1);
 sf_sat = XSteam('sL_p',p1);
 hf_sat = XSteam('hL_p',p1);
 sg_sat = XSteam('sV_p',p1);
 hg_sat = XSteam('hV_p',p1);
 
 %% Plotting the T-S diagram with obtained values of the system
 
 figure(1)
 
 hold on
 temp = linspace(0,t1,1000);
 
 for i = 1:length(temp)
     
     aa(i) = XSteam('sL_T',temp(i));
     
 end
 
 for j = 1:length(temp)
     
     bb(j) = XSteam('sV_T',temp(j));
 
 end
 
 plot(aa,temp,'color','b')
 plot(bb,temp,'color','b')

 temp = (XSteam('Tsat_p',p1));
 t0 = linspace(temp,t1,300);
 
 for i = 1:length(t0)
     
     c11(i) = XSteam('s_pt',p1,t0(i));
     
 end
 
 t5 = XSteam('Tsat_p',p4);
 s5 = XSteam('sL_T',t5);
 
 plot([s1 s2],[t1 t2],'color','r')
 plot([s2 s3],[t2 t3],'color','r')
 plot([s3 s4],[t3 t4],'color','r')
 plot([s4 s5],[t4 t5],'color','r')
 plot([sf_sat sg_sat],[tf_sat tf_sat],'color','r')
 plot(c11,t0,'color','r')
 
 title('T-S Diagram')
 xlabel('Entropy(KJ/kgK')
 ylabel('Temperature(K)')
 
 text(s1,t1,'1');
 text(s2,t2,'2');
 text(s3,t3,'3');
 text(s4,t4,'4');
 text(s5,t5,'4s');
 text(sg_sat,tf_sat,'1s');
 
 
 %% Plotting the H-S diagram with obtained values of the system
 
 figure(2)
 hold on
 
 temp1 = linspace(0,t1,1000);
 
 for i = 1:length(temp1)
     
     cc(i) = XSteam('hL_T',temp1(i));
     
 end
 
 for j = 1:length(temp1)
     
     dd(j) = XSteam('hV_T',temp1(j));
     
 end
 
 plot(aa,cc,'color','b');
 plot(bb,dd,'color','b');
 
 plot([s1 s2],[h1 h2],'color','r')
 plot([s2 s3],[h2 h3],'color','r')
 plot([s3 s4],[h3 h4],'color','r')
 plot([s4 s1],[h4 h1],'color','r')
 
 title('H-S Diagram')
 xlabel('Entropy(kJ/kgK)')
 ylabel('Enthalpy(kJ/kg)')
 
 text(s1,h1,'1');
 text(s2,h2,'2');
 text(s3,h3,'3');
 text(s4,h4,'4');
 
%% Printing the Obtained state point values of the system

 fprintf('\n');
 disp('<strong>RESULTS</strong>');
 
 % Temperature, Pressure, Enthalpy, Entropy values at state point 1
 disp('<strong>At state point 1:</strong>')
 fprintf('P1 is : %f bar\n',p1)
 fprintf('T1 is : %f celcius\n',t1)
 fprintf('H1 is : %f kJ/kg\n',h1)
 fprintf('S1 is : %f kJ/kgK\n\n',s1)
 
 % Temperature, Pressure, Enthalpy, Entropy values at state point 2
 disp('<strong>At state point 2:</strong>')
 fprintf('P2 is : %f bar\n',p2)
 fprintf('T2 is : %f celcius\n',t2)
 fprintf('H2 is : %f kJ/kg\n',h2)
 fprintf('S2 is : %f kJ/kgK\n',s2)
 fprintf('X is : %f \n\n',x2)
 
 % Temperature, Pressure, Enthalpy, Entropy values at state point 3
 disp('<strong>At state point 3:</strong>')
 fprintf('P3 is : %f bar\n',p3)
 fprintf('T3 is : %f celcius\n',t3)
 fprintf('H3 is : %f kJ/kg\n',h3)
 fprintf('S3 is : %f kJ/kgK\n\n',s3)
 
 % Temperature, Pressure, Enthalpy, Entropy values at state point 4
 disp('<strong>At state point 4:</strong>')
 fprintf('P4 is : %f bar\n',p4)
 fprintf('T4 is : %f celcius\n',t4)
 fprintf('H4 is : %f kJ/kg\n',h4)
 fprintf('S4 is : %f kJ/kgK\n\n',s4)
 
 % Work done by the system
 disp('<strong>Work Done:</strong>')
 fprintf('Work done by Turbine (Wt) is : %f kJ/kg\n',wt)
 fprintf('Work done by Pump (Wp) is : %f kJ/kg\n',wp)
 fprintf('Net Work done by system (W-net) is : %f kJ/kg\n',w_net)
 fprintf('Back work ratio is : %f \n\n',bwr)
 
 % Efficiency of the system
 disp('<strong>Thermal Efficiency:</strong>')
 fprintf('Thermal Efficiency is : %f %%\n',np)
 fprintf('SSC : %f kJ/kWh\n',SSC)
 

The XSteam function should be saved in the same directory in order to obtain the values from it.

<strong> and </strong> is used in disp command for showing the text in Bold

2) Errors Faced and steps taken to rectify them:

There was no major error faced during the execution of the program

3) Result obtained:

Rankine Cycle (or) Rankine Vapor Cycle

Process(1-2): Isentropic Expansion in the Turbine
Process(2-3): Constant Pressure Heat rejection in the Condensor
Process(3-4): Isentropic Compression in the Pump
Process(4-1): Constant Pressure Heat addition in the Boiler

Provide the required Inputs for calculating various values of Rankine Cycle

Enter the Temperature as the Turbine Inlet (in degree celcius): 400

Enter the Pressure at the Turbine Inlet (in bar): 30

Enter the Pressure at the Condensor (in bar): .05

RESULTS
At state point 1:
P1 is : 30.000000 bar
T1 is : 400.000000 celcius
H1 is : 3231.571027 kJ/kg
S1 is : 6.923259 kJ/kgK

At state point 2:
P2 is : 0.050000 bar
T2 is : 32.875490 celcius
H2 is : 2110.708212 kJ/kg
S2 is : 6.923259 kJ/kgK
X is : 0.814256

At state point 3:
P3 is : 0.050000 bar
T3 is : 32.875490 celcius
H3 is : 137.765119 kJ/kg
S3 is : 0.476254 kJ/kgK

At state point 4:
P4 is : 30.000000 bar
T4 is : 36.834000 celcius
H4 is : 140.762226 kJ/kg
S4 is : 0.476254 kJ/kgK

Work Done:
Work done by Turbine (Wt) is : 1120.862815 kJ/kg
Work done by Pump (Wp) is : 2.997107 kJ/kg
Net Work done by system (W-net) is : 1117.865709 kJ/kg
Back work ratio is : 1.566598

Thermal Efficiency:
Thermal Efficiency is : 36.167417 %
SSC : 3.220423 kJ/kWh

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.