GA Toolbox maximization fucntion
조회 수: 2 (최근 30일)
이전 댓글 표시
In GA toolbox in Matlab we are getting fitness curve in form of minimization. How can I get maximization (fitness function) curve?
Can anyone help me in getting GA code for optimization?
this is my code
function [e] = mohfun(r)
dt = r(1);
ltt = r(2);
dss = r(3);
%% Data of cold fluid
tci=30; %Input temperature of cold fluid (C)
%tco=35; %Output temperature of cold fluid (C)
rowc=1000; %Density (kg/m3)
mioc=0.000797; %Viscosity (Pa s)
kc=.613; %Thermal conductivity (W/m K)
prc=5.83; %Prandtl number
cpc=4186; %Heat capacity (kJ/kg K)
mc=42; %Mass flow rate of cold fluid
vec=1.14; %velocity of cold fluid
%rec; %Reynold’s number OF COLD fluid
%hc; %hot stream of cold fluid
%ftc, %Darcy friction factor of cold fluid
%qc=input('Enter heat duty of cold fluid = '); %heat duty (W)
%% Data of hot fluid
thi=60; %Input temperature of hot stream (C)
%tho=45; %Output temperature of hot stream (C)
rowh=865.8; %Density (kg/m3)
mioh=0.023; %Viscosity (Pa s)
kh=0.141; %Thermal conductivity (W/m K)
prh=1205; %Prandtl number
cph=2000; %Heat capacity (kJ/kg K)
mh=17.2; %Mass flow rate
%veh=1.5; %velocity of hot fluid
%qh=input('Enter heat duty of hot fluid = '); %heat duty (W)
%pit=.005; %triangular pitch
%res %reynolds number (res) for shell side
%hs %hot stream of hot fluid
%% data of tube
%nt=input('Enter number of tube = '); %number of tube
dti=dt; %Tube inside diameter (m)
st=0.0043; %Tube thickness (m)
Rft=0.00042; %fouling factor
%dto %outer dimeter of tube
lt=ltt; %lt=input('Enter the length of tube = '); %Tubes length (m)
%% Data of shell
ds=dss; %Shell inside diameter (m)
np=1; %Number of tube passes
Rfs=0.0002; %fouling factor
%dh %hydraulic diameter
%% Equation
fprintf('dti %f \n ',dti)
fprintf('ltt %f \n ',ltt)
fprintf('dss %f \n ',dss)
dto=dti+st;
fprintf('dto %f \n ',dto)
%nt=mc/(rowc*(pi/4)*(dti^2)*vec);
v1=pi/4;
v2=dti^2;
v3=rowc*v2;
v4=v3*v1*vec;
nt=mc/v4;
ntt=nt*2;
fprintf('nt %f \n',nt)
%nt=nt1*2;
fprintf('ntt %f \n',ntt)
as=pi*dto*lt*nt*np;
fprintf('as %f \n',as)
rec = (rowc*vec*dti)/(mioc);
fprintf('rec %f \n',rec)
ftc = ((1.82*log(rec))-1.64)^(-2);
fprintf('ftc %f \n',ftc)
if rec < 2300
hc = (kc/dti)*(3.657+((0.0677*rec*prc*(dti/3.050))^1.33)/(1+0.1*prc*((rec*(dti/3.050))^0.3)));
elseif 2300 < rec && rec < 10000
hc = (kc/dti)*((1+(dti/3.050))^0.67)*(((ftc/8)*(rec-1000)*(prc))/(1+12.7*((ftc/8)^0.5)*((prc^0.667)-1)));
elseif rec > 10000
hc = (0.027)*(kc/dti)*(rec^0.8)*(prc^(1/3))*(mioc/mioc)^0.14;
end
fprintf('hc %f \n',hc)
%dh = (4*(0.43*pit^2-(pi*0.125*dto^2)))/(0.5*pi*dto);
%d1=ds^2-(dto^2*nt);
%d2=ds+(dto*nt);
%dh=d1/d2;
dh=(ds^2-(dto^2*nt))/(ds+(dto*nt));
fprintf('dh %f \n',dh)
f1=pi/4;
f2=f1*dh^2;
f3=f2*rowh;
veh=mh/f3;
fprintf('veh %f \n',veh)
res=(rowh*veh*dh)/mioh;
fprintf('res %f \n',res)
hs=(0.36*kh*res^0.55*prh^0.33)/dh;
fprintf('hs %f \n',hs)
%U = ((1/hs)+Rfs+(dto/dti)*(Rft+(1/hc)))^(-1);
U = ((1/hs)+Rfs+Rft+(1/hc))^(-1);
fprintf('U %f \n',U)
c1=mc*cpc;
fprintf('c1 %f \n',c1)
c2=mh*cph;
fprintf('c2 %f \n',c2)
if c1>c2
c_x=c1;
c_m=c2;
else
c_x=c2;
c_m=c1;
end
fprintf('c_m %f \n',c_m)
fprintf('c_x %f \n',c_x)
ntu= (as*U)/c_m;
fprintf('ntu %f \n',ntu)
cr=c_m/c_x;
fprintf('cr %f \n',cr)
%ef=1-exp(-cr^-1 * (1-exp(1-cr(ntu))));
e1=exp(-cr*ntu);
e2=1-e1;
e3=-cr^-1;
e4=e3*e2;
e5=exp(e4);
ef=1-e5;
%e7=1+e6;
%ef=1/e7;
e=ef;
fprintf('ef %f \n',ef)
tho=thi-ef*(thi-tci);
fprintf('tho %f \n',tho)
qh=mh*cph*(thi-tho);
fprintf('qh %f \n',qh)
tco=(qh/(mc*cpc))+tci;
fprintf('tco %f \n',tco)
lt= as/(pi*dto*nt);
fprintf('lt %f \n',lt)
end
댓글 수: 0
채택된 답변
Walter Roberson
2020년 11월 21일
To maximize a function, minimize the negative of the function
@(x) -f(x)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fluid Network Interfaces Library에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!