[11:05 pm, 01/06/2020] Kannv Mittal: %Project-2
% Rankine Cycle Simulator
clear all;
close all;
clc;
% Initial parameters
t = linspace(0,373.15,400);
P1 = input('Enter the pressure at the Turbine inlet(in bar) : ');
T1 = input(['Enter the temperature at the Turbine inlet(in ' char(176) 'C) : ']);
P2 = input('Enter the pressure at the Condenser(in bar) : ');
disp(' ')
% State 1
h1 = XSteam('h_pT',P1,T1);
s1 = XSteam('s_pT',P1,T1);
hl1 = XSteam('hL_p',P1);
hg1 = XSteam('hV_p',P1);
sl1 = XSteam('sL_p',P1);
sg1 = XSteam('sV_p',P1);
Tsat1 = XSteam('Tsat_p',P1);
% State 2
s2 = s1;
sl2 = XSteam('sL_p',P2);
sg2 = XSteam('sV_p',P2);
d = (s2-sl2)/(sg2-sl2);
hl2 = XSteam('hL_p',P2);
hg2 = XSteam('hV_p',P2);
h2 = hl2 + d*(hg2-hl2);
T2 = XSteam('T_ph',P2,h2);
Tsat2 = XSteam('Tsat_p',P2);
% State 3
h3 = hl2;
s3 = sl2;
P3 = P2;
T3 = T2;
% State 4
s4 = s3;
P4 = P1;
h4 = XSteam('h_ps',P4,s4);
T4 = XSteam('T_ps',P4,s4);
% Plot the graph
figure(1), clf
hold on
for i = 1:length(t)
plot(XSteam('sL_T',t(i)),t(i),'b.')
plot(XSteam('sV_T',t(i)),t(i),'b.')
end
% Plot Command
plot([s1 s2],[T1 T2],'linew',2)
text(s1,T1,'1','FontSize',15)
if d > 1
T3 = Tsat2;
plot([s2 sg2 s3 s4],[T2 Tsat2 T3 T4],'linew',2)
T2 = Tsat2;
text(s2,T2,'2','FontSize',15)
text(s3,T3,'3','FontSize',15)
else
plot([s2 s3 s4],[T2 T3 T4],'linew',2)
text(s2,T2,'2','FontSize',15)
text(s3,T3,'3','FontSize',15)
end
n = linspace(T1,T2,500);
for i = 1:length(n)
plot(XSteam('s_pT',P1,n(i)),n(i),'.','linew',2)
end
plot([sl1 sg1],[Tsat1 Tsat1],'linew',2)
text(sl1,Tsat1,'4','FontSize',15)
xlabel('Entropy')
ylabel('Temperature')
title('T-S')
% Next Graph
figure(2), clf
hold on
for i = 1:length(t)
plot(XSteam('sL_T',t(i)),XSteam('hL_T',t(i)),'g.')
plot(XSteam('sV_T',t(i)),XSteam('hV_T',t(i)),'g.')
end
%Plotting
plot([s1 s2 s3 s4 s1],[h1 h2 h3 h4 h1],'linew',2)
text(s1,h1,'1','FontSize',15)
text(s2,h2,'2','FontSize',15)
text(s3,h3,'3','FontSize',15)
text(s4,h4+90,'4','FontSize',15)
xlabel('Entropy')
ylabel('Enthalpy')
title('H-S')
%Work Done by Various Sources
% Turbine
Wt = h1 - h2
% Pump
Wp = h4 - h3
% Dome
Wnet = Wt - Wp
% Calculate the Thermal efficiency
Ntherm = (1 - ((h2 - h3)/(h1 - h4)))*100
% Back work ratio
BWR = Wp/Wt
% Specific Steam Conductivity
S.S.C = 3600/Wt
% Displaying commands for all
disp('RESULTS :')
disp('At state point 1: ')
fprintf('P1 = %.2f bar n',P1)
fprintf(['T1 = %.2f' char(176) 'C n'],T1)
fprintf('h1 = %.2f kJ/kg n',h1)
fprintf('s1 = %.2f kJ/kgK n',s1)
disp(' ')
disp('At state point 2: ')
fprintf('P2 = %.2f bar /n',P2)
fprintf(['T2 = %.2f' char(176) 'C n'],T2)
fprintf('h2 = %.2f kJ/kg n',h2)
fprintf('s2 = %.2f kJ/kgK n',s2)
disp(' ')
disp('At state point 3: ')
fprintf('P3 = %.2f bar n',P3)
fprintf(['T3 = %.2f' char(176) 'C n'],T3)
fprintf('h3 = %.2f kJ/kg n',h3)
fprintf('s3 = %.2f kJ/kgK n',s3)
disp(' ')
disp('At state point 4: ')
fprintf('P4 = %.2f bar n',P4)
fprintf(['T4 = %.2f' char(176) 'C n'],T4)
fprintf('h4 = %.2f kJ/kg n',h4)
fprintf('s4 = %.2f kJ/kgK n',s4)
disp(' ')
fprintf('Work done by turbine = %.2f kJ/kg n', Wt)
fprintf('Work done by pump = %.2f kJ/kg n', Wp)
fprintf('Net work done = %.2f kJ/kg n', Wnet)
fprintf('Thermal efficiency = %.2f %% n', Ntherm)
fprintf('Back-work ratio = %f n', BWR)
fprintf('Specific Steam Conductivity = %.2f kg/kWh n', S.S.C)
[11:05 pm, 01/06/2020] Bhavya Tuteja: certificate request from bhar de?
[11:05 pm, 01/06/2020] Kannv Mittal: In dono ke bad
[11:15 pm, 01/06/2020] Kannv Mittal: https://in.mathworks.com/help/gads/how-the-genetic-algorithm-works.html
[11:31 pm, 01/06/2020] Kannv Mittal: %Program to Define the Stalagmite Function
function [f] = stalagmite_func(input_vector)
%Inputs
x = input_vector(1);
y = input_vector(2);
term1 = (sin((5.1*pi*x )+ 0.5))^6;
term2 = (sin((5.1*pi*y) + 0.5))^6;
term3 = exp(-4*log(2)*((x-0.0667)^2)/0.64);
term4 = exp(-4*log(2)*((y-0.0667)^2)/0.64);
f = -(term1*term2*term3*term4);
end
[11:31 pm, 01/06/2020] Kannv Mittal: %Program to calculate Global maxima of a Stalagmite function
clear all
close all
clc
%Creating lines
x = linspace(0,0.6,150);
y = linspace(0,0.6,150);
num_cases=50;
% Creating Plots
[xx yy] = meshgrid(x,y);
for i = 1 : length(xx);
for j = 1 : length(yy);
input_value(1)= xx(i,j);
input_value(2) = yy(i,j);
f(i,j) = stalagmite_func(input_value);
end
end
%For Calculating and Genrating the Plot
tic
for i=1:num_cases;
[inputs1,fopt1(i)]=ga(@stalagmite_func,2);
xopt(i)=inputs1(1);
yopt(i)=inputs1(2);
end
study1_time=toc;
figure(1)
subplot(2,1,1)
hold on
surfc(xx,yy,-f)
zlabel('function value')
shading interp
plot3(xopt,yopt,-fopt1,'marker','o','markersize',5,'markerfacecolor','r')
title('Unbounded Statistical Behvai…