Challenge

Project 2 - Rankine cycle Simulator

explanation

1.first the windows are cleared using the clear all, close all, clc command

2.next the process are explained using the disp command

3.the manual inputs like t1,p1,p2 are given

4.by using the thermodynamics equation and the XSteam library enthalpy, entropy, temperature, pressure are calculated

5.for plotting the curve we are using the linspace command fot temperature range between 0 to 500 with respect to enthalpy and entropy

6.net work done, efficiency, back work ratio, specific steam consumption are calculated using the formula

7.finally plotting the temperature, entropy(T-s) and enthalpy, entropy(h-s) diagram for rankine cycle

errors

1.using brackets instead of parantheses in line 21

2.using lower case letters for P1,T1 in line 22

3.not putting the downloaded XSteam library in the same folder as the program

4.error while input of the formula for ssc

5.using inverted commas in the disp section

steps taken to solve the errors

1.using the upper case letters

2.pasting the Xsteam library in the correct folder

3.changing the formula for ssc

4.not using the inverted commas in the disp section

clear all
close all
clc

disp('Rankine Cycle Simulator');
disp('1-2 = isentropic expansion in turbine');
disp('2-3 = constant pressure heat rejection by the condensor');
disp('3-4 = isentropic compression in the pump');
disp('4-1 = constant pressure heat addition by the boiler');

% typing inputs and getting the outputs

T1=input('enter the temperature at the turbine inlet(in degree celsius):');

P1=input('enter the pressure at the turbine inlet(in bar):');
P2=input('enter the pressure at the condensor(in bar):');

disp('RESULTS');

%calculating the enthalpy and entropy at state point 1
%entry from turbine to boiler
h1=XSteam('h_pT',P1,T1);
s1=XSteam('s_pT',P1,T1);

%calculating the enthalpy,entropy and temperature at state point 1
%exit from turbine to boiler
%since isentropic process
s2=s1;

% for isentropic process (T2/T1)=(P2/P1)*(1-(1/gamma))
gamma=1.4;
power_term=1-(1/gamma);

T2=T1*((P2/P1)^power_term);
h2=XSteam('h_pT',P2,T2);

%calculating the enthalpy,entropy,pressure and temperature at state point 3
%exit from condensor and entering the pump
%constant pressure heat rejection process
P3=P2;
T3=T2;
h3=XSteam('hL_T',T3);
s3=XSteam('sL_T',T3);

%calculating the enthalpy,entropy,pressure and temperature at state point 4
%entering into boiler from pump
%constant pressure and isentropic process
P4=P1;
s4=s3;
T4=XSteam('T_ps',P4,s4);
h4=XSteam('h_pT',P4,T4);

h41=XSteam('hL_P',P4);
h4v=XSteam('hV_p',P4);
s41=XSteam('sL_p',P4);
s4v=XSteam('sV_p',P4);
T41=XSteam('T_hs',h41,s41);
T4v=XSteam('T_hs',h4v,s4v);

%calculating entropy and enthalpy at the saturation curve

temp=linspace(0,500,1000);
for i=1:length(temp)
    % entropy
    sl(i)=XSteam('sL_T',temp(i));
    sv(i)=XSteam('sV_T',temp(i));
    % enthalpy
    hl(i)=XSteam('hL_T',temp(i));
    hv(i)=XSteam('hV_T',temp(i));
end

%plotting TS diagram
figure(1)
plot(s1,temp)
hold on
plot(sv,temp)
plot([s1 s2],[T1 T2],[s2 s3],[T2 T3],[s3 s4],[T3 T4],[s4 s41],[T4 T41],[s41 s4v],[T41 T4v],[s4v s1],[T4v T1],'linewidth',1,'color','b');
axis([0 10 0 450])
xlabel('Entropy(s) in kJ/kgK');
ylabel('Temperature(T) in K');


figure(2)
plot(s1,h1)
hold on
plot(sv,hv)
plot([s1 s2],[h1 h2],[s2 s3],[h2 h3],[s3 s4],[h3 h4],[s4 s1],[h4 h1],'linewidth',1,'color','y');
xlabel('Entropy(s) in kJ/kgK');
ylabel('Enthalpy(h) in kJ/K');
hold off

%wnet=net work output
%wt=work done by turbine
%wp=work done by pump
wt=h1-h2;
wp=h4-h3;
wnet=wt-wp;

%back work ratio
BWR=wp/wt;

%thermal efficiency
Qin=h1-h4;
thermal_efficiency=(wnet/Qin)*100;

%specific steam consumption
SSC=3600/wnet;

%result to be displayed
disp('The following are the results of Rankine Cycle');
disp(' ');
disp('At the state point 1');
disp(' ');
a1=sprintf('P1 is %.2f bar',P1);
disp(a1);
a2=sprintf('T1 is %.2f deg celsius',T1);
disp(a2);
a3=sprintf('h1 is %.2f kJ/kg',h1);
disp(a3);
a4=sprintf('s1 is %.2f kJ/kgK',s1);
disp(a4);


disp(' ');
disp('At the state point 2');
disp(' ');
a5=sprintf('P2 is %.2f bar',P2);
disp(a5);
a6=sprintf('T2 is %.2f deg celsius',T2);
disp(a6);
a7=sprintf('h2 is %.2f kJ/kg',h2);
disp(a7);
a8=sprintf('s2 is %.2f kJ/kgK',s2);
disp(a8);


disp(' ');
disp('At the state point 3');
disp(' ');
a9=sprintf('P3 is %.2f bar',P3);
disp(a9);
a10=sprintf('T3 is %.2f deg celsius',T3);
disp(a10);
a11=sprintf('h3 is %.2f kJ/kg',h3);
disp(a11);
a12=sprintf('s3 is %.2f kJ/kgK',s3);
disp(a12);



disp(' ');
disp('At the state point 4');
disp(' ');
a13=sprintf('P4 is %.2f bar',P4);
disp(a13);
a14=sprintf('T4 is %.2f deg celsius',T4);
disp(a14);
a15=sprintf('h4 is %.2f kJ/kg',h4);
disp(a15);
a16=sprintf('s4 is %.2f kJ/kgK',s4);
disp(a16);


disp(' ');
a17=sprintf('work done by turbine - wt is %.2f kJ/kg',wt);
disp(a17)
disp(' ');
a18=sprintf('work done by pump - wp is %.2f kJ/kg',wp);
disp(a18)
disp(' ');
a19=sprintf('net work done - wnet is %.2f kJ/kg',wnet);
disp(a19)
disp(' ');
a20=sprintf('thermal efficiency is %.2f percent',thermal_efficiency);
disp(a20)
disp(' ');
a21=sprintf('specific steam consumption - SSC is %.2f kg/kwh',SSC);
disp(a21)
disp(' ');
a22=sprintf('basic work ratio - BWR is %.5f',BWR);
disp(a22)
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.