Project

Rankine cycle simulator

PROJECT TITLE: CREATING A RANKINE CYCLE SIMULATOR USING MATLAB.

OBJECITVE: 1. Coding for obtaining the rankine cycle.

2. Calculating all the state points as per user inputs.

3. Plotting the corresponding T-s and h-s plots for the given set of inputs.

Obtaining the efficiency.

CODING PART:

Here is the Code for The Rankine cycle Simulator using Matlab:

This program will deal with the basic rankine cycle and it will give all the relevant data and plots related to the cycle according to the user defined input values.

Here is how the code goes:-

clc
clear all
close all

disp('                     RANKINE CYCLE SIMULATOR                           ');
disp('   1-2 Isentropic Compression in the Pump');
disp('   2-3 Constant Pressure Heat addition in Boiler');
disp('   3-4 Isentropic Expansion in Turbine');
disp('   4-1 Constant Pressure Heat rejection in Condenser');

p3=input('Enter the pressure at the turbine inlet(in bar):');
t3=input('Enter the temperarure at the turbine inlet(in degree celsius):');
p4=input('Enter the condenser pressure(in bar):');


p2=p3;
p1=p4;

%at the inlet of the pump,State point 1-2


h1=XSteam('hL_p',p1);
s1=XSteam('sL_p',p1);
t1=XSteam('Tsat_p',p1);
s2=s1;

%specific heat calculation
cp=XSteam('Cp_ps',p1,s1);
cv=XSteam('Cv_ps',p1,s1);

% value of gamma
gamma=(cp/cv);
o=(1-gamma)/gamma;

%inlet of boiler, State point 2-3
t2= (t1*(p1/p2)^o);
h2=XSteam('h_pT',p2,t2);

%pump work
Wp=h2-h1;

%turbine inlet,State point 3-4
s3=XSteam('s_pT',p3,t3);
h3=XSteam('h_pT',p3,t3);
s4=s3;
t4=t1;

sf=XSteam('sL_p',p1);
sg=XSteam('sV_p',p1);
sf1=XSteam('sL_p',p2);
sg1=XSteam('sV_p',p2);

%at state point 4, enthalpy and dryness fraction calculation
x=((s4-sf)/(sg-sf));
hf=XSteam('hL_p',p1);
hg=XSteam('hV_p',p1);
h4=(hf+x*(hg-hf));

%turbine work
Wt=h3-h4;

%heat added at the boiler
q1=h3-h2;

%heat rejected from the condenser
q2=h4-h1;

%net workdone
Wnet=Wt-Wp;

%efficiency
Ntherm=Wnet/q1;

%T vs S
hold on

%saturation curves plot
Tsat=linspace(1,400,800);

for i=1:length(Tsat)
    s(i)=XSteam('sL_T',Tsat(i));
end

for j=1:length(Tsat)
    s11(j)=XSteam('sV_T',Tsat(j));
end

%plotting of vapour domes
plot(s,Tsat,'linestyle','--','color','b')
plot(s11,Tsat,'linestyle','--','color','c')
hold on


temp=XSteam('Tsat_p',p2);
s_temp=XSteam('sL_T',temp);
T=linspace(t2,temp,100);


% plot of the curve in the wet region

S=linspace(s2,XSteam('sL_p',p2),100);


%plot of the curve in the dry region

T1=linspace(temp,t3,500);

for i=1:length(T1)
    
    S1(i)=XSteam('s_pT',p2,T1(i));
end

%plot of pump work
plot([s1 s2],[t1 t2],'red')


hold on



%turbine work
plot([s3 s4],[t3 t4],'black')

%condenser
plot([s4 s1],[t4 t1],'g')


%plot of heat addition
plot(S,T,'y')
plot([sf1 sg1],[temp temp],'y')
plot(S1,T1,'y')

text(s1,t1,'1')
text(s2,t2,'2')
text(s3,t3,'3')
text(s4,t4,'4')

legend('Saturation Curve L','Saturation Curve V','pump','Turbine','condenser','boiler')
title('T-S Diagram')
xlabel('Entropy')
ylabel('Temperature')

%H vs S
figure(2)
hold on

Tsat1=linspace(1,400,800);

%saturation curves plot(vapour dome)

for i=1:length(Tsat1)
    h(i)=XSteam('hL_T',Tsat1(i));
end

for j=1:length(Tsat)
    h11(j)=XSteam('hV_T',Tsat1(j));
end


plot(s,h,'linestyle','--','color','b')
plot(s11,h11,'linestyle','--','color','c')


hold on

%pump plot
plot([s1 s2],[h1 h2],'red')

%boiler plot
H=linspace(h2,h3,500);
S11= linspace(s2,s3,500);


plot(S11,H,'y')

%turbine plot
plot([s3 s4],[h3 h4],'black')

%condenser plot
plot([s4 s1],[h4 h1],'g')


text(s1,h1,'1')
text(s2,h2,'2')
text(s3,h3,'3')
text(s4,h4,'4')


legend('Saturation Curve L','Saturation Curve V','pump','boiler','Turbine','condenser')
title('H-S Diagram')
xlabel('Entropy')
ylabel('Enthalpy')


%outputs
%at state 1
fprintf('\n\n At State Point 1:\n\n')
fprintf('P1 is : %f Bar\n',p1)
fprintf('T1 is : %f Deg Celcius\n',t1)
fprintf('H1 is : %f KJ/Kg\n',h1)
fprintf('S1 is : %f KJ/KgK\n\n',s1)

%at state 2
fprintf('At State Point 2:\n\n')
fprintf('P2 is : %f Bar\n',p2)
fprintf('T2 is : %f Deg 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',x)

%at state 3
fprintf('At State Point 3:\n\n')
fprintf('P3 is : %f Bar\n',p3)
fprintf('T3 is : %f Deg Celsius\n',t3)
fprintf('H3 is : %f KJ/Kg\n',h3)
fprintf('S3 is : %f KJ/KgK\n\n',s3)

%state 4
fprintf('At State Point 4:\n\n')
fprintf('P4 is : %f Bar\n',p4)
fprintf('T4 is : %f Deg Celsius\n',t4)
fprintf('H4 is : %f KJ/Kg\n',h4)
fprintf('S4 is : %f KJ/KgK\n\n',s4)

%calculations
fprintf('Work Done By Turbine : %f kJ/kg\n',Wt)
fprintf('Work Done By Pump : %f kJ/kg\n',Wp)
fprintf('The net workdone is:%f kJ/kg\n',Wnet)
fprintf('Heat Added in The Boiler: %f KJ/kg\n',q1)
fprintf('Heat Rejected in The Condenser: %f KJ/kg\n',q2)
fprintf('Thermal Efficiency is : %f\n\n ',Ntherm*100)




Now, the output part:-

                     RANKINE CYCLE SIMULATOR                           
   1-2 Isentropic Compression in the Pump
   2-3 Constant Pressure Heat addition in Boiler
   3-4 Isentropic Expansion in Turbine
   4-1 Constant Pressure Heat rejection in Condenser
Enter the pressure at the turbine inlet(in bar):35
Enter the temperarure at the turbine inlet(in degree celsius):450
Enter the condenser pressure(in bar):4


 At State Point 1:

P1 is : 4.000000 Bar
T1 is : 143.612533 Deg Celcius
H1 is : 604.723474 KJ/Kg
S1 is : 1.776598 KJ/KgK

At State Point 2:

P2 is : 35.000000 Bar
T2 is : 208.565698 Deg Celcius
H2 is : 891.774683 KJ/Kg
S2 is : 1.776598 KJ/KgK
X is  : 1.021820 

At State Point 3:

P3 is : 35.000000 Bar
T3 is : 450.000000 Deg Celsius
H3 is : 3337.860287 KJ/Kg
S3 is : 7.007109 KJ/KgK

At State Point 4:

P4 is : 4.000000 Bar
T4 is : 143.612533 Deg Celsius
H4 is : 2784.605475 KJ/Kg
S4 is : 7.007109 KJ/KgK

Work Done By Turbine : 553.254812 kJ/kg
Work Done By Pump : 287.051209 kJ/kg
The net workdone is:266.203603 kJ/kg
Heat Added in The Boiler: 2446.085603 KJ/kg
Heat Rejected in The Condenser: 2179.882001 KJ/kg
Thermal Efficiency is : 10.882841

 >> 

And the plots of T-S and H-S:-

Temperature vs Entropy

Enthalpy vs Entropy

The Project Report:

                                 RANKINE CYCLE SIMULATOR


1. First I have shown the processes that are going on in the rankine cycle along with the state position.

2. Then i have written the code for taking the input from the user in terms of temperature and pressure at different states.

3. Then i have used the steam table file that will provide me the necessary values of different parameters which will eventually help me to find the other state variables so that i can simulate the cycle.

4. I have found the values of enthalpy, entropy, temperature at state point 1-2.

5. Since 1-2 is an isentropic process i need to find out the value of gamma,for that i have found the specific heat at constant pressure and at constant volume and got the value of gamma.

6. Then with the help of adiabatic equation i have found out the value of temperature at state point-2.

7. In process 2-3, similarly i have found out the values of the other parameters.

8. Same for the processes 3-4 and 4-1.

9. Taking into consideration that since the two processes are isentropic so the values of corresponding entropy will be same.

10. Now if after the expansion in the turbine, the outlet of the turbine gives a mixture of water and steam, then we have to calculate the dryness fraction.

11. For that we know that the entropy is same, and we will find out the values of 
entropy of the fluid at the saturated liquid line and saturated vapour line respectively at the lower pressure(condenser pressure).

12. Then with the help of the dryness fraction we will be able to calculate the other parameters.

13. Then i have calculated the turbine(work producing device) work and the pump(work absorbing device) work.

14. Then i have calculated the heat added in the boiler and heat rejected in the condenser.

15. And then the thermal efficiency.
                                      
                       Plot of T vs S

16. For the saturation lines, i have made an array taking in random values of temperatures and then with the help of the size of the array i have extracted the values of entropy for that corresponding temperature from the steam table.

17. Similarly for the other saturation line.(command used- sV_T for the vapour line, sL_T for the liquid line).

18. Then i have plotted the pump work which will be a staright line.

19. now i have divided the boiler plotting region into 3 parts,
             - first i have plotted from state 2 to the point where the pressure 
               line(higher pressure) touches the saturation line with the help of an 
               array which has values of temperatures from t2 to the satuartion liquid 
               temperature at that pressure and extracted the corresponding values of 
               entropy from the steam table.
             - then the second part will be a straight line since it is a phase change 
               process
             - then again i have used the same logic for plotting the part from the 
               point where the pressure line cuts the saturation vapour line to the 
               point till which the fluid has been superheated.
                        (except the middle line both the lines are curved lines)
20. Then i have used legends to distinguish between the parts, labelles the processes and put the state points in the plot via 'text' command.

21. I have repeated the same process for plotting the H vs S diagram.

22. At last i have printed the processes which are going on along with their respective state points.

23. Then i have printed the values of temperature,entropy,enthalpy and pressure at each state points.

24. At last i have printed the values of the calculation part which includes pump work, efficiency and many more.										
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.