Challenge

Project 2 - Rankine cycle Simulator

%% RANKINE CYCLE ::

purppse::

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.

process::

>>Process 1–2: The working fluid is pumped from low to high pressure. As the fluid is a liquid at this stage, the pump requires little input energy. Process 1-2 is isentropic compression.

>>Process 2–3: The high-pressure liquid enters a boiler, where it is heated at constant pressure by an 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 or software. Process 2-3 is constant pressure 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, and some condensation may occur. The output in this process can be easily calculated using the chart or tables noted above. Process 3-4 is isentropic expansion.

>>Process 4–1: The wet vapour then enters a condenser, where it is condensed at a constant pressure to become a saturated liquid. Process 4-1 is constant pressure heat rejection in condenser.

%%Rankine code::

clear all
close all
clc


% Inputs required
Turbine_inlet_temp= 400;(degree celcius)
Turbine_inlet_pressure= 30;(bars)
Turbine_outlet_pressure= 0.05;(bars)

>> 'fprintf' is used to print the data whcih contains in the file.

>>'\n'is an new line character used to insert the new lines

>>'(1-2-3-4) contains four stages of rankine cycle


fprintf('Rankine cycle simulator \n');
fprintf('\n1-2 isentropic expansion in the turbine');
fprintf('\n2-2 const pressure heat rejection in the turbine');
fprintf('\n3-4 isentropic compression in pump');
fprintf('\n4-1 const pressure heat addition in boiler');

>> 'p1 is an inlet pressure at turbine inlet as assumed

>> 'T1' is temp at turbine inlet

>>'p2' pressure at turbine outlet


% user inputs required
p1=input('\n enter the pressure at the turbine inlet(in bars): ');
T1=input('Enter the Temp at the turbine inlet(in degree celcius): ');
p2=input('Enter the pressure at the turbine outlet(in bars): ');

>>'xsteam' is an file which contains all data which we are considered

% at point 1

>> Turbine inlet conditions


H1= XSteam('h_Pt',p1,T1); % Enthalpy
S1= XSteam('s_pt',p1,T1); % Entropy
Hf1= XSteam('hl_p',p1); % Enthalpy of saturated liquid
Hg1= XSteam('hV_p',p1); % Enthalpy of saturated vapour
Ts1= XSteam('Tsat_p',p1); % Saturation Temperature
Sf1= XSteam('sL_p',p1); % Entropy of saturated liquid
Sg1= XSteam('sV_p',p1); % Entropy of saturated vapour

% at point 2
S2=S1;
Sf2=XSteam('sL_p',p2);
Sg2=XSteam('sV_P',p2);
x=(S2-Sf2)/(Sg2-Sf2); % Dryness fraction
Hf2=XSteam('hL_p',p2); % Enthplay of saturated liquid
Hg2=XSteam('hV_p',p2); % entropy of saturated vapour
H2=Hf2+ x*(Hg2-Hf2);
T2=XSteam('T_ph',p2,H2);
Ts2=XSteam('Tsat_p',p2); % saturation temp

% at point 3

>> pump inlet conditions

H3=Hf2;
S3=Sf2;
T3=T2;
p3=p2;

% at point 4

>> Boiler inlet coditions


p4=p1;
S4=S3;
H4=XSteam('h_ps',p4,S4);
T4=XSteam('T_ps',p4,S4);

% at state 5

S5 = XSteam('sL_p',p1);
H5 = XSteam('hL_p',p1);
T5 = XSteam('Tsat_p',p1);

% at state 6
S6 = XSteam('sV_p',p1);
H6 = XSteam('hV_p',p1);
T6 = T5;

%temp space for plotting saturation curves
t=linspace(0,400,1000);

% plot T-S Digram
figure(1)
hold on
%plot saturation curve
for i=1:length(t)
plot(XSteam('sL_T',t(i)),t(i),'.','color','g')
plot(XSteam('sL_T',t(i)),t(i),'.','color','g')
end
% plot cycle
plot([S1 S2],[T1 T2],'linewidth','color','g')
if x>1
T3=Ts2;
plot([S1 S2 Sg2 S3 S4 S5 S6],[T1 T2 Ts2 T3 T4 T5 T6],'linewidth',2,'color','r')
T3=Ts2;
else
plot([S1 S2 Sg2 S3 S4 S5 S6],[T1 T2 Ts2 T3 T4 T5 T6],'linewidth',2,'color','r')
T3=Ts2
end
l=linspace(T1,T2,500);
for i=1:length(l)
plot(XSteam('s_pT',p1,l(i)),l(i),'.','color','r')
end
plot([Sf1 Sg1],[Ts1 Ts1],'color','r')
xlabel('Entropy[kj/kg-k]')
ylabel('Temprature[k]')
title('T-S Diagram')
legend('saturate liquid','saturated vapour');

%plot H-S Diagram
figure(2)
hold on
%plot saturation curve
for i=1:length(t)
plot(XSteam('sL_T',t(i)),XSteam('hL_T',t(i)),'.','color','b')
plot(XSteam('sV_T',t(i)),XSteam('hV_T',t(i)),'.','color','b')
end
%plot cycle
plot([S1 S2 S3 S4 S5 S6 S1],[H1 H2 H3 H4 H5 H6 H1],'linewidth',2,'color','g')
xlabel('Entropy[kj/kg-k]')
ylabel('Enthalpy[kj/kg]')
title('H-S Diagram')
legend('saturation curve');

% calculations

%Turbine Work
Wt=H1-H2;

%Pump Work
Wp=H4-H3;

% Heat Addition
Qin=H1-H4;

%Heat Rjection
Qout=H2-H3;

%Net Work
Wnet=Wt-Wp;

% Efficiency
Ntherm=(Wnet/Qin)*100;

%Specific steam consumption
SSC=3600/Wnet;

%Back work ratio
BWR=Wp/Wt;

%print results

fprintf('\n\nResults\n')
fprintf('At state point 1:\n')
fprintf('P1 is : %2f bar\n',p1)
fprintf('T1 is : 2%f Deg Celcius\n',T1)
fprintf('H1 is : %2f lj/kg-k\n',H1)
fprintf('S1 is : %2f kj/kg=k\n',S1)


fprintf('\nAt state point 2:\n')
fprintf('P2 is : %2f bar\n',p2)
fprintf('T2 is : 2%f Deg Celcius\n',T2)
fprintf('H2 is : %2f lj/kg-k\n',H2)
fprintf('S2 is : %2f kj/kg=k\n',S2)

fprintf('\nAt state point 3:\n')
fprintf('P3 is : %2f bar\n',p2)
fprintf('T3 is : 2%f Deg Celcius\n',T3)
fprintf('H3 is : %2f lj/kg-k\n',H3)
fprintf('S3 is : %2f kj/kg=k\n',S3)

fprintf('\nAt state point 4:\n')
fprintf('P4 is : %2f bar\n',p2)
fprintf('T4 is : 2%f Deg Celcius\n',T4)
fprintf('H4 is : %2f lj/kg-k\n',H4)
fprintf('S4 is : %2f kj/kg=k\n',S4)


fprintf('\nWt is : %2f kj/kg/n',Wt)
fprintf('Wp is : %2f lj/kg\n',Wp)
fprintf('Wnet is : %2f kj/kg\n',Wnet)
fprintf('Thermal Efficiency is : %2f percent\n',Ntherm)
fprintf('S.S.C is : %2f kg/kWh\n',SSC)
fprintf('Back Work Ratio is : %3f \n',BWR)

%%COMMAND WINDOW OUTPUT

>>H-S PLOT and T-S PLOT

>> error:: Here after i executed the code i am unable to plot the T-S plot please rectify my error

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.