Challenge

Project 2 - Rankine cycle Simulator

close all
clear all
clc
%rankine cycle
disp('      RANKINE CYCLE     ');
disp('1-2 is Isentropic expansion in turbine');
disp('2-3 is contact pressure heat rejection by condensor')
disp('3-4 is Isentropic expansion in pump');
disp('4-1 is Contact pressure heat addition in boiler');
%inputs
disp('   inputs   ');
P1=input('Enter the pressure at turbine inlet');
T1=input('Enter the temperature at turbine inlet');
P2=input('Enter the pressure at the condensor');
% using xsteam functions and calculating entropy, enthalpy at various
% points
% calculating enthalpy(h)and entropy(s) at point1
h1=XSteam('h_pT',P1,T1);
s1=XSream('s_pT',P1,T1);
% calculating pressure,entropy and enthalpy at point2
%since isentropic expansion
s2=s1;
% for isentropic expansion
%(T2/T1)=(P2/P1)^(1-(1/g));
g=1.4;
p=(1-(1/g));
% therefore (T2/T1)=(P2/P1)^p
T2=T1*((P2/P1)^p);
h2=XSteam('h_pT',P2,T2);
%calculating pressure,emtropy and enthalpy at point 3
%since constant pressure heat removal
P3=P2;
T3=T2;
h3=XSteam('hL_T',T3);
s3=XSteam('sL_T',T3);
%calculating pressure,entropy and enthalpy at point4
%since isentropic compression
s4=s3;
%constant pressure process
P4=P1;
T4=XSteam('T_ps',P4,s4);
h4=XSteam('h_pT',P4,T4);
h41=XSteam('hL_p',P4);
s41=Xsteam('sL_p',P4);
h42=XSteam('hV_p',P4);
s42=XSteam('sV_p',P4);
T41=XSteam('T_hs',h41,s41);
T42=Xsteam('T_hs',h42,s42);
%Calculating entropy and enthalpy at saturation curve
Temp=linspace(0,500,500);

for i=1:length(Temp)
  sv(i)=Xsteam('sV_T',Temp(i));  
  sl(i)=Xsteam('sL_T',Temp(i));

  hv(i)=Xsteam('hV_T',Temp(i));
  hl(i)=Xsteam('hL_T',Temp(i));

end

% Displaying the results in command window
disp('    Results   ');
P1=P1;
T1=T1;
P2=P2;
disp('At point1 stage');
n1=sprintf('P1 is %f.3',P1);
disp(n1);
n2=sprintf('T1 is %f.3',T1);
disp(n2);
n3=sprintf('h1 is %f.3',h1);
disp(n3);
n4=sprintf('s1 is %f.3',s1);
disp(n4);

disp('At stage point 2')
n11=sprintf('P2 is %f.3',P2);
disp(n11);
n21=sprintf('T2 is %f.3',T2);
disp(n21);
n31=sprintf('h2 is %f.3',h2);
disp(n31);
n41=sprintf('s2 is %f.3',s2);
disp(n41);

disp('At stage point 3')
n12=sprintf('P3 is %f.3',P3);
disp(n12);
n22=sprintf('T3 is %f.3',T3);
disp(n22);
n32=sprintf('h3 is %f.3',h3);
disp(n32);
n42=sprintf('s3 is %f.3',s3);
disp(n42);

disp('At stage point 4');
n13=sprintf('P4 is %f.3',P4);
disp(n13);
n23=sprintf('T4 is %f.3',T4);
disp(n23);
n33=sprintf('h4 is %f.3',h4);
disp(n33);
n43=sprintf('s4 is %f.3',s4);
disp(n43);
 % plotting
 figure(1)
 plot([s1 s2],[T1 T2],[S2 S3],[T2 T3],[s3 s4],[T3 T4],[s4 s41],[T4 T41],[s41 s42],[T41 T42],[s42 s1],[T42 T1]);
 hold on
 plot(sv,Temp);
 plot(sl,Temp);
 xlabel('Entropy');
 ylabel('Temperature');

figure(2)
plot([s1 s2],[h1 h2],[s2 s3],[h2 h3],[s3 s4],[h3 h4],[s4 s1],[h4 h1],'marker','*','color','g');
hold on
plot(sv,hv);
plot(s1,h1);
xlabel('Entropy');
ylabel('Enthalpy');


Rankine cycle is an thermodynamic cycle which governs the working of heat engine.The rankine cycle mainly consists of four components like turbine,condensor,pump and boiler.In rankine cycle the process takes place in four stages.In the stage 1-2,it is an isentropic expansion in the turbine.In process 2-3,it is an constant pressure heat rejection in the condensor.In process 3-4,it is an isentropic expansion in the pump.In process 4-1,it is an constant pressure heat addition in the boiler.

First mentioning all the process of the rankine cycle to displaying it in the command window.The input variables P1,T1 and P2 were given by input comand whose values are given in command window.
At state 1 the values of entropy and enthslpy was calculated as a function of pressure and temperature.The input variables in the function are default variables which are in the XSteam data file.
Similarly the pressure,temperature,entropy and enthalpy for all the state points was calculated as a function of dependent variables in the XSteam data file.The two more points were defined to plot cycle

A temperature range is defined to plot so that linspace command is used.Now after calculating all the data points displaying of it is done in the command window.

For plotting figure(1),temperature vs entropy all the state variables were taken accordingly.For plotting figure(2),entropy vs enthalpy all the required state variables were considered like enthalpy and entropy terms.
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.