Challenge

Project 2 - Rankine cycle Simulator

RANKINE CYCLE SIMULATOR :-

CODE :-

clear all 
close all 
clc

% Displaying the processes involved
disp('Rankine Cycle Simulator');
disp('1-2 Isentropic expansion int the turbine');
disp('2-3 Heat removal process in the condenser at constant pressure');
disp('3-4 is the isentropic compression in the pump');
disp('4-1 Heat addition Process in the boiler at constant pressure');

% Now getting the data for input,WE have already given the values of these inputs in the challenge  
p1=44; % inlet pressure of the turbine in bars 
t1=538; % Inlet temprature of the Turbine in degree celsius  
p2=5.83; % inlet pressure for condensor in bars

% Now extracting the data and defining the variables 
% For state 1 
h1=XSteam('h_pt',p1,t1); % where h is for enthalpy
s1=XSteam('s_pt',p1,t1);% where s is for entropy

% Now extracting the data and defining the variables 
% For state 2
s2=s1; % due to isentropic expansion

sf2=XSteam('sL_p',p2);% Entropy for saturated liquid 
sg2=XSteam('sV_p',p2);% Entropy for saturated vapour
x2=(s2-sf2)/(sg2-sf2);
hf2=XSteam('hL_p',p2);% Enthalpy for saturated vapour
hg2=XSteam('hV_p',p2);% Enthalpy for saturated vapour
h2=hf2 + (x2*(hg2-hf2));

% Now extracting the data and defining the variables 
% For state 3
p3=p2; % due to heat rejection in condenser at constant pressure 
s3=XSteam('sL_p',p3);
h3=XSteam('hL_p',p3);

% Now extracting the data and defining the variables 
% For state 4
s4=s3; % due to isentropic compression 
p4=p1;% due to heat addition at constant pressure 

% Now calculating the work done (wd) by the turbine 
wd=h1-h2;

% Now calculating the work done (wp) to run pump
v3=XSteam('vL_p',p3);
wp=v3*(p4-p3)*100;
h4=h3+wp;

% Now calculating the net workdone ( w_net)
w_net=wd-wp;

% calculating the heat input ( q_input ) to the system
q_input=h1-h4;

% calculating the heat input ( q_output ) to the system
q_output=h2-h3;

% Now calculating the thermal efficiency 
Thermal_eff= (w_net/q_input)*100;

% Now calculating the specific steam consumption (sc_specific) 
%formula used is :sc_specific= mass flow rate /power
sc_specific=(3600/w_net);

% Hence we are only left with the values of temprature at different states 
% so Now moving forward to calculate the temprature values respectively 
t3=XSteam('Tsat_p',p3);
t2=t3;
cp4=XSteam('cp_ps',p4,s4);% specific heat at constant pressure
cv4=XSteam('cv_ps',p4,s4);% specific heat at constant volume
k=cp4/cv4; % Heat capacity ratio
t4=t3/(p3/p4)^((k-1/k));

% Now calculating the temprature , entropy, enthalpy at the vapour and the 
% liquid line for the plotting purpose
t6=XSteam('Tsat_p',p1);
t5=t6;
s5=XSteam('sL_p',p1); 
s6=XSteam('sV_p',p1);
h5=XSteam('hl_p',p1);
h6=XSteam('hV_p',p1);

%% Now plotting the saturation curve
t=linspace(1,380,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

%% Now plotting the t-s Diagram
figure(1)
hold on
plot(sf,t,'r','linewidth',2);
plot(sg,t,'r','linewidth',2);
plot([s1 s2],[t1 t2],'b','LineWidth',3);
plot([s2 s3],[t2 t3],'b','LineWidth',3);
plot([s3 s4],[t3 t4],'b','LineWidth',3);
plot([s4 s5],[t4 t5],'b','LineWidth',3);
plot([s5 s6],[t5 t6],'b','LineWidth',3);
sc1=linspace(s6,s1,1000);
for j=1:length(sc1)
    tc1 (j)=XSteam('T_ps',p1,sc1(j));
end
plot(sc1,tc1,'b','linewidth',3);
title('Temprature Vs Entropy Diagram');
xlabel('Enstropy(S) in KJ/Kg-K');
ylabel('Temprature in degree celcius');
legend('Saturation curve');

%% Now plotting the H-S Diagram 
figure(2)
hold on
plot(sf,hf,'r','lineWidth',2);
plot(sg,hg,'r','linewidth',2);
plot([s1 s2],[h1 h2],'b','linewidth',3);
plot([s2 s3],[h2 h3],'b','linewidth',3);
plot([s3 s4],[h3 h4],'b','linewidth',3);
hc=linspace(h4,h5,1000); 
for k=1:length(hc)
    sch(k)=XSteam('s_ph',p1,hc(k));
end
plot(sch,hc,'b','LineWidth',3);
plot([s5 s6],[h5 h6],'b','LineWidth',3);
for m=1:length(sc1)
    hc1(m)=XSteam('h_ps',p1,sc1(m));
end
plot(sc1,hc1,'b','linewidth',3);
title('Entahlpy Vs Entropy diagram');
xlabel('Entropy in KJ/kg-K ');
ylabel('Enthalpy in KJ/kg');
legend('Saturation curve');

% Displaying the results as per input
disp('INPUTS')
disp('Inlet pressure in turbine inlet = 44 bars')
disp('Inlet tempratur at turbine inlet = 538 deg.celcius')
disp('Pressure at the condenser =5.83 bars')
disp('RESULTS')

%At state 1
disp('At state point 1 :')
disp('p1 is : 44 Bar')
disp('t1 is : 538 Deg.Celcius')
disp('h1 is : 3528.8 KJ/Kg') %% Calculated the value mannually by converting 3.5288e+03
disp('s1 is : 7.15 KJ/kg-k')

%At state 2
disp('At state point 2 :')
disp('p2 is : 5.83 Bar')
disp('t2 is : 157.7 Deg.Celcius')
disp('h2 is : 2920.8 KJ/Kg')%% Calculated the value mannually by converting 2.9208e+03
disp('s2 is : 7.15 KJ/kg-k')
disp('x2 is : 1.07')

%At state 3
disp('At state point 3 :')
disp('p3 is : 5.83 Bar')
disp('t3 is : 157.7 Deg.Celcius')
disp('h3 is : 665.6 KJ/Kg')
disp('s3 is : 1.91 KJ/kg-k')

%At state 4
disp('At state point 4 :')
disp('p4 is : 44 Bar')
disp('t4 is : 377.4 Deg.Celcius')
disp('h4 is : 669.8 KJ/Kg')
disp('s4 is : 1.91 KJ/kg-k')


disp('wd is :608 kj/kg') % here wd is used in place of wt
disp('wp is :4.19 kj/kg')
disp('w_net is :603.8 kj/kg')
disp('Thermal_eff is  :21.11 Percent')% here Themal_eff isused in place of Nthermal
disp('sc_specific is :5.96')% here sc_specific is used in place of SSC.

EXPLAINATION OF CODE & LOGIC :-

clear all ( to clear all the variables from the current workspace )
close all ( to close all the figure)
clc ( to clear the command window)
% Displaying the processes involved ( COMMENTS )
disp('Rankine Cycle Simulator');( to display the text mentioned in between the (' '))
disp('1-2 Isentropic expansion int the turbine'); ( to display the text mentioned in between the (' '))
disp('2-3 Heat removal process in the condenser at constant pressure');( to display the text mentioned in between the (' '))
disp('3-4 is the isentropic compression in the pump');( to display the text mentioned in between the (' '))
disp('4-1 Heat addition Process in the boiler at constant pressure');( to display the text mentioned in between the (' '))
% Now getting the data for input,WE have already given the values of these inputs in the challenge ( COMMENTS )
p1=44; % inlet pressure of the turbine in bars ( assigned the value to p1)
t1=538; % Inlet temprature of the Turbine in degree celsius ( assigned the value to t1)
p2=5.83; % inlet pressure for condensor in bars ( assigned the value to p2)
% Now extracting the data and defining the variables ( COMMENTS )
% For state 1 ( COMMENTS )
h1=XSteam('h_pt',p1,t1); % where h is for enthalpy ( Calculating the value of h1 with the help of XSteam(fun,input1,input2))
s1=XSteam('s_pt',p1,t1);% where s is for entropy( Calculating the value of s1 with the help of XSteam(fun,input1,input2))
% Now extracting the data and defining the variables( COMMENTS)
% For state 2( COMMENTS)
s2=s1; % due to isentropic expansion ( Here s2=s1 , so assigned and defined the value , as s1 is already defined )
sf2=XSteam('sL_p',p2);% Entropy for saturated liquid ( Calculating the value of sf2 with the help of XSteam(fun,input1,input2))
sg2=XSteam('sV_p',p2);% Entropy for saturated vapour( Calculating the value of sg2 with the help of XSteam(fun,input1,input2))
x2=(s2-sf2)/(sg2-sf2); ( Here x2 is calculated with help of s2,sf2,sg2 ,as they are already defined )
hf2=XSteam('hL_p',p2);% Enthalpy for saturated vapour ( Calculating the value of hf2 with the help of XSteam(fun,input1,input2))
hg2=XSteam('hV_p',p2);% Enthalpy for saturated vapour( Calculating the value of hg2 with the help of XSteam(fun,input1,input2))
h2=hf2 + (x2*(hg2-hf2));( Calculating the value of of h2 , as the variables used are already defined )
% Now extracting the data and defining the variables ( COMMENTS )
% For state 3
p3=p2; % due to heat rejection in condenser at constant pressure ( as p2 is already defined , and p3=p2 )
s3=XSteam('sL_p',p3);( Calculating the value of s3 with the help of XSteam(fun,input1,input2))
h3=XSteam('hL_p',p3);( Calculating the value of h3 with the help of XSteam(fun,input1,input2))
% Now extracting the data and defining the variables
% For state 4
s4=s3; % due to isentropic compression
p4=p1;% due to heat addition at constant pressure
% Now calculating the work done (wd) by the turbine
wd=h1-h2;
% Now calculating the work done (wp) to run pump
v3=XSteam('vL_p',p3);
wp=v3*(p4-p3)*100;
h4=h3+wp;
% Now calculating the net workdone ( w_net)
w_net=wd-wp;
% calculating the heat input ( q_input ) to the system
q_input=h1-h4;
% calculating the heat input ( q_output ) to the system
q_output=h2-h3;
% Now calculating the thermal efficiency
Thermal_eff= (w_net/q_input)*100;
% Now calculating the specific steam consumption (sc_specific)
%formula used is :sc_specific= mass flow rate /power
sc_specific=(3600/w_net);
% Hence we are only left with the values of temprature at different states
% so Now moving forward to calculate the temprature values respectively
t3=XSteam('Tsat_p',p3);
t2=t3;
cp4=XSteam('cp_ps',p4,s4);% specific heat at constant pressure
cv4=XSteam('cv_ps',p4,s4);% specific heat at constant volume
k=cp4/cv4; % Heat capacity ratio
t4=t3/(p3/p4)^((k-1/k));
% Now calculating the temprature , entropy, enthalpy at the vapour and the
% liquid line for the plotting purpose
t6=XSteam('Tsat_p',p1);
t5=t6;
s5=XSteam('sL_p',p1);
s6=XSteam('sV_p',p1);
h5=XSteam('hl_p',p1);
h6=XSteam('hV_p',p1);
%% Now plotting the saturation curve
t=linspace(1,380,1000);( lisnpace command is used to create an array containg 1000 values between 1 & 380 )
for i=1:length(t) ( for loop is used to generate the data for the saturation curve )
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
%% Now plotting the t-s Diagram
figure(1)
hold on
plot(sf,t,'r','linewidth',2);
plot(sg,t,'r','linewidth',2);
plot([s1 s2],[t1 t2],'b','LineWidth',3);
plot([s2 s3],[t2 t3],'b','LineWidth',3);
plot([s3 s4],[t3 t4],'b','LineWidth',3);
plot([s4 s5],[t4 t5],'b','LineWidth',3);
plot([s5 s6],[t5 t6],'b','LineWidth',3);
sc1=linspace(s6,s1,1000);
for j=1:length(sc1)
tc1 (j)=XSteam('T_ps',p1,sc1(j));
end
plot(sc1,tc1,'b','linewidth',3);
title('Temprature Vs Entropy Diagram');
xlabel('Enstropy(S) in KJ/Kg-K');
ylabel('Temprature in degree celcius');
legend('Saturation curve');
%% Now plotting the H-S Diagram
figure(2)
hold on
plot(sf,hf,'r','lineWidth',2);
plot(sg,hg,'r','linewidth',2);
plot([s1 s2],[h1 h2],'b','linewidth',3);
plot([s2 s3],[h2 h3],'b','linewidth',3);
plot([s3 s4],[h3 h4],'b','linewidth',3);
hc=linspace(h4,h5,1000);
for k=1:length(hc)
sch(k)=XSteam('s_ph',p1,hc(k));
end
plot(sch,hc,'b','LineWidth',3);
plot([s5 s6],[h5 h6],'b','LineWidth',3);
for m=1:length(sc1)
hc1(m)=XSteam('h_ps',p1,sc1(m));
end
plot(sc1,hc1,'b','linewidth',3);
title('Entahlpy Vs Entropy diagram');
xlabel('Entropy in KJ/kg-K ');
ylabel('Enthalpy in KJ/kg');
legend('Saturation curve');
% Displaying the results as per input ( disp is used to display the content in the command window )
disp('INPUTS')
disp('Inlet pressure in turbine inlet = 44 bars')
disp('Inlet tempratur at turbine inlet = 538 deg.celcius')
disp('Pressure at the condenser =5.83 bars')
disp('RESULTS')
%At state 1
disp('At state point 1 :')
disp('p1 is : 44 Bar')
disp('t1 is : 538 Deg.Celcius')
disp('h1 is : 3528.8 KJ/Kg') %% Calculated the value mannually by converting 3.5288e+03
disp('s1 is : 7.15 KJ/kg-k')
%At state 2
disp('At state point 2 :')
disp('p2 is : 5.83 Bar')
disp('t2 is : 157.7 Deg.Celcius')
disp('h2 is : 2920.8 KJ/Kg')%% Calculated the value mannually by converting 2.9208e+03
disp('s2 is : 7.15 KJ/kg-k')
disp('x2 is : 1.07')
%At state 3
disp('At state point 3 :')
disp('p3 is : 5.83 Bar')
disp('t3 is : 157.7 Deg.Celcius')
disp('h3 is : 665.6 KJ/Kg')
disp('s3 is : 1.91 KJ/kg-k')
%At state 4
disp('At state point 4 :')
disp('p4 is : 44 Bar')
disp('t4 is : 377.4 Deg.Celcius')
disp('h4 is : 669.8 KJ/Kg')
disp('s4 is : 1.91 KJ/kg-k')
disp('wd is :608 kj/kg') % here wd is used in place of wt
disp('wp is :4.19 kj/kg')
disp('w_net is :603.8 kj/kg')
disp('Thermal_eff is :21.11 Percent')% here Themal_eff isused in place of Nthermal
disp('sc_specific is :5.96')% here sc_specific is used in place of SSC.
Contuinuing with explaination : Most of the explaination of code used is same for the state points .
1. formulas are respectively used to calculate the state points ,based upon that the variables that are used has already been defined.
2. plot command is used to plot the respective diagrams
3.linewidth command is used to increase or decrease the line thickness.
4. for loops are used to create the thermodynamic relationships and data for the curves.
OUTPUT : - We will be getting the values of p,t,h,& s at all the state points and also the required T-S & H-S plot for the respective rankine cycle . The results has also been displayed in the command window .
Results :-
Plots :-
Explaination about the 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

Working Process can be explained with the below Screen shot:-

Also used this helpfull info provided in the challenge and also very thankfull for providing this info :

Error faced :- the error i faced was , i am using the wrong keyword ie Xsteam, instead of XSteam , which has caused a lot of problem .

References :-

https://en.wikipedia.org/wiki/Rankine_cycle

https://www.youtube.com/watch?v=xIg-1srHxRM

https://www.thermopedia.com/content/1072/

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.