Challenge

Project 2 - Rankine cycle Simulator

TITLE : Understand the concept of Rankine cycle by referring to standard thermal engineering text book.

Create a Rankine Cycle Simulator using OCTAVE/MATLAB.
Your code should calculate the state points of the Rankine Cycle (any type of your choice) based on user inputs. 
Then, plot the corresponding T-s and h-s plots for the given set of inputs. Title and axes labels are a must, while legends could be used if necessary.

# PROCESS

* process 1-2: the working fluid is pumped from low to high pressure .as the fluid is liquid at this stage.the pump requires little input energy.
in other words process 1-2 is isentropic compression in pump.

* procrss 2-3: the high pressure liquid enters a boiler, where it is heated at constant pressure by external heat source to become a dry saturated vapour.the input energy required can be easily calculated graphically,using an enthalpy -entropy chart(h-s chart)or numerically using steam tables.
in other words process 2-3 constant presure heat addition in boiler.

* process 3-4: the dry saturated vapour expands through a turbine generating power.this decreases the temperature and pressure of the vapour andsome condensation may occur.the outlet in this process can be easily calculated using the chart or tables.
in other words process 3-4 is isentropic expansion in turbine.

* the wet vapour then enters a condenser,where it is codensated at a constant pressure to become a saturated liquid.
in other words process 4-1 is constant pressure heat rejection in condenser.

# CALCULATE NET WORK DONE AND EFFICIENCY

Wnet=Wt-Wp

ntherm=(Wnet/Qi).100

where,
Wt=H1-H2
Wp=H4-H3
Qi=H1-H4

# TO CALCULATE THE SPECIFIC STEAM CONSUMPTION

S.S.C=3600/Wnet

# TO CALCULATE THE BACK WORK RATIO

B.W.R=(H1-H4/H2-H3)



# MAIN CODE

clear all
close all
clc
fprintf('%75s \n\n','RANKINE CYCLE SIMULATOR')
fprintf('1-2 is isentropic expansion in turbine \n');
fprintf('2-3 is constant pressure heat rejection in condenser \n')
fprintf('3-4 is isentropic compression in pump \n')
fprintf('4-1 is constant pressure heat addition in boiler \n\n')

% inputs 
P1=input('Enter the pressure at the turbine inlet (in Bar) :');
T1=input('Enter the temperature at the turbine inlet( in degree Celsius) :');
P2=input('Enter the pressure at condenser( in bar) :');

% computing results
fprintf ('\n %65s','RESULTS')

% calculating required values at all state points

% At state point 1
S1=XSteam ('s_pT',P1,T1);
H1=XSteam ('h_pT',P1,T1);

% at state point 2
S2=S1;
sf2=XSteam ('sL_p',P2);
sg2=XSteam ('sV_p',P2);
hf2=XSteam ('hL_p',P2);
hg2=XSteam ('hV_p',P2);

T2=XSteam ('Tsat_p',P2);
x2=((S2-sf2)/(sg2-sf2));

H2=hf2+(x2*(hg2-hf2));

% at point 3

P3=P2;
T3=XSteam ('Tsat_p',P3);
S3=XSteam ('sL_p',P3);
H3=XSteam ('hL_p',P3);

% to calculate gamma
cp=XSteam ('cpL_p',P3);
cv=XSteam ('cvL_p',P3);
gamma=(cp/cv);


% at state point 4

P4=P1;
S4=S3;
H4=XSteam ('h_ps',P4,S4);
T4=T3*((P4/P3)^((gamma-1)/gamma));

% calculating work done

Wt=H1-H2;
Wp=H4-H3;
W_net=Wt-Wp;

q_in=H1-H4;
q_out=H2-H3;

n=W_net/q_in;
n_percent=n*100;

SSC=3600/W_net;

BWR=q_in/q_out;

% at state point 5 and 6

T5=XSteam ('Tsat_p',P1);
T6=T5;
S5=XSteam ('sL_p',P1);
S6=XSteam ('sV_p',P1);
H5=XSteam ('hL_p',P1);
H6=XSteam ('hV_p',P1);

% plotting the required graphs

% T-S graph
figure(1)
T_zone1=linspace(T5,T1,500);

for i=1:length(T_zone1)
    S(i)=XSteam ('s_pt',P1,T_zone1(i));
end

hold on

plot([S1 S2 S3 S4 S5 S6 S],[T1 T2 T3 T4 T5 T6 T_zone1],'linewidth',3,'color','r')

axis([0 10 0 430]);
text(S1,T1,'1','FontSize',15);
text(S2,T2,'2','FontSize',15);
text(S3,T3,'3','FontSize',15,'VerticalAlignment','top');
text(S4,T4,'4','FontSize',15,'VerticalAlignment','bottom','HorizontalAlignment','right');
text(S5,T5,'5','FontSize',15,'VerticalAlignment','top');
text(S6,T6,'6','FontSize',15,'VerticalAlignment','top','HorizontalAlignment','right');


T_zone2= linspace(0,T1,500);
for j=1:length(T_zone2);

    sl(j)=XSteam ('sL_T',T_zone2(j));
    sv(j)=XSteam ('sV_T',T_zone2(j));
    hl(j)=XSteam ('hL_t',T_zone2(j));
    hv(j)=XSteam ('hV_T',T_zone2(j));
end

plot(sl,T_zone2,'LineWidth',1.5,'Color','r');
plot(sv,T_zone2,'LineWidth',1.5,'Color','r');
xlabel('Entropy')
ylabel('Temperature');
title('Entropy vs Temperature')


% H-S Graph

figure(2)
hold on
plot([S1 S2 S3 S4 S1],[H1 H2 H3 H4 H1],'LineWidth',3,'Color','k');
axis([0 10 -100 3500]);
text(S1,H1,'1','FontSize',15)
text(S2,H2,'2','FontSize',15)
text(S3,H3,'3','FontSize',15,'VerticalAlignment','top','HorizontalAlignment','left');
text(S4,H4,'4','FontSize',15,'VerticalAlignment','bottom','HorizontalAlignment','right');

plot(sv,hv,'LineWidth',1.5,'color','r');
plot(sl,hl,'LineWidth',1.5,'color','r');
xlabel('Entropy');
ylabel('Enthalpy');

% displaying the results

fprintf('\n At state point 1 : \n');
fprintf('P1 is : %f Bar \n',P1);
fprintf('T1 is : %f Deg Celsius \n',T1);
fprintf('H1 is : %f KJ/Kg \n',H1);
fprintf('S1 is : %f KJ/Kgk \n',S1)


fprintf('\n T state point 2 : \n');
fprintf('P2 is : %f Bar \n',P2);
fprintf('T2 is : %f Deg celsius \n',T2);
fprintf('H2 is : %f  KJ/Kg \n',H2);
fprintf('S2 is : %f KJ/KgK \n',S2);



fprintf('\n At state point 3 : \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',S3);


fprintf('\n At state point 4 : \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',S4);



fprintf('Wt : %f KJ/Kg \n',Wt);
fprintf('Wp : %f KJ/Kg \n',Wp);
fprintf('Wnet : %f KJ/Kg \n',W_net);
fprintf('Ntherm : %f percent \n',n_percent);
fprintf('SSC : %f Kg/KWh \n',SSC);
fprintf('BWR : %f \n',BWR)



# EXPALNATION


* clear,close any open windows and clear command window commands are provided.
* following that, using 'fprintf' basic details areprinted onto the command window.
* then it is programmed to get input from user for the pressure at state points 1 nd 2 
  and temperature at state point 1.
* then by taking the provided steam table as a function the parameters at different 
  state point is found.
* once all the parameters are found the values are substituted in the above equation to obtained the required datas.

# PLOTTING

* since the path of change between the point 5 & 1 is unknown a temperature zone is assumed for the temperatures between the said points & corresponding values of entropy is found using steam table.

* using the plot command, all the values ar plotted & wwith the help of text command, the state points are marked.
* the temperature vs entropy values at liquid & vapour phases are found from the steam table & plotted alongside.
* the same is done for enthalpy vs entropy graph also.

# DISPLAYING RESULTS

 finally, using the fprintf command ,all the calculated state parameters are displayed onto the command window in required format.





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.