I am getting same intial guess value in fmincon
조회 수: 2 (최근 30일)
이전 댓글 표시
this is my fitness function
clear all
close all
xo=[0.0011,0.0049,0.36]; % assumptions
%nvars=5;
A=[];
b=[];
Aeq=[];
beq=[];
lb=[0.001,0.002,0.01]; %lower bound
ub=[0.01,0.08,0.5]; %upper bound
nonlincon = @(X)constraint_new(X); % calling constraint function
Fitnessfun=@(X)weight_testvariable(X); %calling objective function
options = optimoptions(@fmincon,'Display','iter-detailed','Algorithm','sqp','MaxIterations',1500)
[X,fval]=fmincon(Fitnessfun,xo,[],[],[],[],lb,ub,nonlincon,options)
this is my constraint
function [c,ceq] = constraint_new(X)
D_i=X(1);D_io=.0014;D_o=X(2);D_oo=.0075;L=X(3);
Qreq=30;
c(3)=(D_io+.004)-D_o;
c(1)=(D_i-D_io);
c(2)=(D_o-D_oo);
ceq =[heatload1_new(D_i,D_io,D_o,D_oo,L)-Qreq];
end
this is my heatload calculation of doublepipe heat exchanger
function [Q]=heatload1_new(D_i,D_io,D_o,D_oo,L)
T_ri=373;
T_ro=303;
T_wi=293;
rho_r=21;
rho_w=998;
C_p_r=1936.8;
C_p_w=4218;
m_dot_r=.0002;
m_dot_w=.005;
miu_r=14.58*10^-6;
miu_w=10.5*10^-4;
k_r=35.958*10^-3;
k_w=.5918;
no_tu_r=1;
rho_ss=8000;
rho_cop=8960;
% D_i =input('dia of ref side(in m)=');
% D_o =input('dia of water side(in m)=');
% D_io=input('thickness of inside(in m)=');
% D_oo=input('thickness of outer (in m)=');
% L=input('length of tube(in m)=');
%% assumptions
X=[0.001;0.006;0.4];
X=[X(1);X(2);X(3)];
D_i=X(1);
D_io=.0014;
D_o=X(2);
D_oo=.0075;
L=X(3);
%A.*x<=b;
%D_i=x(1);D_io=x(2);D_o=x(3);D_oo=x(4);L=x(5);
%% CALCULATE THE GEOMETRY
%equation on ref side
A=pi/4*(D_i)^2;
G_r=m_dot_r/(no_tu_r*A);
Re_r=((G_r*D_i)/miu_r);
Pr_r=((miu_r*C_p_r)/k_r);
if Re_r>2100
h_i=(k_r/D_i)*.023*Re_r^.8*Pr_r^.4;
else
Re_r<2100
h_i=(k_r/D_i)*4.36;
end
h_io=h_i*(D_i/D_io);
%equations for water side
a=(pi/4)*(D_o^2-(no_tu_r*D_io^2));
Dia_h=(4*a)/((pi*no_tu_r*D_io));
G_w=m_dot_w/(a);
Re_w=((G_w*(Dia_h))/miu_w);
Pr_w=((miu_w*C_p_w)/k_w);
if Re_w>2100
h_o=(k_w/Dia_h)*.023*Re_w^.8*Pr_w^.3;
else
Re_w<2100
h_o=(k_w/Dia_h)*4.36;
end
%find UA
UA=(h_io*pi*D_i*no_tu_r*L*h_o*D_io*pi*no_tu_r*L)/((h_io*pi*D_i*no_tu_r*L)+(h_o*D_io*pi*no_tu_r*L));
NTU=UA/(m_dot_r*C_p_r);
%effectiveness
C_R=(min(m_dot_r*C_p_r,m_dot_w*C_p_w))/(max(m_dot_r*C_p_r,m_dot_w*C_p_w));
fsylm=(1-exp(-NTU*(1-C_R)))/(1-(C_R*exp(-NTU*(1-C_R))));
Q=fsylm*m_dot_r*C_p_r*(T_ri-T_wi);
end
this is my objective function
function [fval]=weight_testvariable(X)
clear all;
clc;
rho_ss=8000;
rho_cop=8960;
% defined thickness
X=[0.001;0.006;0.4];
%D_i=0.002;D_o=0.006;L=0.4;
D_i=X(1);D_o=X(2);L=X(3);
thick_i=0.0014-X(1);
thick_o=0.0075-X(2);
fval=(((rho_ss*pi*thick_i*X(1)*X(3))+(rho_cop*pi*thick_o*X(2)*X(3))));% objective function
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!