Single objective function, single variable optimization using GA: Not enough input arguments
显示 更早的评论
Design of a Furnace. Function File
function qr = Solution(Q)
THD = 3773.09; %Total heat duty Gcal/h
%Target fluid
Ti = 251.9; %Fluid in degC
T0 = 386.1; %Fluid/gas out degC
%cpl = 0.674; %Cp fluid Kcal/kgdegC
LHV = 10.515; %Fuel value Kcal/kg
%flowL = 12.9; %flowrate fluid
%Air
ea = 0.15; %excess air
cpair = 0.171; %Kcal/kgdegK
cpstm = 0.5125; %Kcal/kgdegK
Tairin = 114;
Tstmin = 141;
Tref = 41; %Ambient
%Fuel
%Hea = 111.5; %Heat released by fuel Gcal/h
Ef = 0.9320; %Fuel efficiency
atfr = 10.344; %in notebook
stfr = 0.5; %literature
%Dimensions
Tg = 869; %degC
Tw = 100+0.5*(Ti+T0); %Tube wall temperature
ctc = 0.3048*20; %ctc in m
Lh = 19.236; %Exposed tube length- horizontal m
Lv = 18.431; %Exposed tube length- vertical m
%d0 = 0.168; %Tube diameter m
pi = 22/7;
%dstk = 4.435;
%lstk = 42.405;
h = 2; %approximation
sig = 0.173*10^-08;
%Radiant section Calcuations
qfuel = THD/Ef;
mfuel = qfuel/LHV;
mreqair = mfuel*atfr;
mair = mreqair*(1+ea);
qair = mair*cpair*(Tairin - Tref);
mstm = mfuel*stfr;
qstm = mstm*cpstm*(Tstmin - Tref);
A = pi*d0*(Lh + Lv);
Tavg = (Ti + T0)/2; %Assumption
qr = h*A*(Tw - Tavg);
qout = 0.1*Q;
qlibr = qfuel+qair+qstm-qr-qout;
nt = qlibr/A.*Q;
Acp = (Lh + Lv)*nt*ctc;
Ar = Acp;
r = ctc/d0;
al = 1 - (0.0277+0.0927*(r - 1))*r - 1;
%Vrad = 4*A; %4cuft/sqft of radiant area (neglecting convection section)
%Vstk = pi*dstk*lstk;
%VF = Vrad + Vstk;
Di = 10.000; %Furnace Diameter
Lm = Di; %Assuming L/D >=2
P = 0.288 - 0.229*ea + 0.09*ea^2;
pl = P*Lm;
z = (Tg + 460)/1000;
a = 0.47916 - 0.19847*z + 0.022569*z*z;
b = 0.047029 + 0.0699*z - 0.01528*z*z;
c = 0.000803 - 0.00726*z + 0.00159*z*z;
e = a + b*(pl) + c*pl*pl;
Aw = 2*pi*Di*Di - Acp;
%Exchange factor
y = Aw/(al*Ar);
u = 0.00064 + 0.0591*y + 0.00101*y*y;
v = 1.0256 + 0.4908*y - 0.058*y*y;
w = -0.144 - 0.552*y + 0.040*y*y;
F = u + e*v + w*e*e;
Qr = ((Tg+460)/1000.^4 - (Tw+460)/1000.^4) + h*(Lh + Lv)*((pi*d0)^2)*Q*((Tg+460)/1000 - (Tw+460)/1000)/(sig*al*qlibr*ctc*F);
qr = Qr*pi*d0*Q/(sig*al*qlibr*ctc*F);
end
Solution File:
for d0 = 0.05:0.01:0.2
%Q = 5900000:10000:8800000;
diff = (Q) > qr - 1000;
[Q,fval] = ga (@Solution, Q, 1, qr - 1000, 5900000, 8800000);
Q
disp(Q);
d0
disp(d0);
%F
%disp(F);
%e
%disp(e);
%pl
%disp(pl);
%a
%disp(a);
%b
%disp(b);
%c
%disp(c);
%y
%disp(y);
%u
%disp(u);
%v
%disp(v);
%w
%disp(w);
%Tw
%disp(Tw);
%qr
disp(qr);
end
Error:
Error using qr
Not enough input arguments.
Error in Sol_solution (line 3)
diff = (Q) > qr - 1000;
回答(2 个)
Walter Roberson
2017-11-30
编辑:Walter Roberson
2017-11-30
At that point in the "Solution file" you have not assigned anything to qr and have not run Solution yet and assigned the output to qr. Your reference to qr in
diff = (Q) > qr - 1000;
is therefore taken to be equivalent to
diff = (Q) > qr() - 1000;
where qr() is the standard MATLAB Orthogonal Triangular Decomposition function.
You do not appear to be using diff in your code, so delete the line (or comment it out). Or alternately, define
obj = @(Q) Solution(Q) - 1000 - Q;
A = []; b = [];
Aeq = []; beq = [];
lb = 5900000; ub = 8800000;
[Q,fval] = ga(obj, 1, A, b, Aeq, beq, lb, ub);
Devdatt Thengdi
2017-11-30
3 个评论
Walter Roberson
2017-11-30
At that point in "Solution file" you have not defined Q. You have defined obj but as a function handle.
If you have a specific Q you could use b = [obj(Q) - Q]
However, you should not be attempting to set linear constraints at that point, and you are passing the wrong parameters in the wrong positions for ga. You should be using what I posted above,
obj = @(Q) Solution(Q) - 1000 - Q;
nvars = 1;
A = []; b = [];
Aeq = []; beq = [];
lb = 5900000; ub = 8800000;
[Q,fval] = ga(obj, nvars, A, b, Aeq, beq, lb, ub);
The exact position you pass in values is important.
Do not try to set obj - Q or obj(Q)-Q as a linear constraint: let ga() search for the value that makes Solution(Q) - 1000 - Q most negative, which is the point at which Q is most greater than Solution(Q) - 1000 .
Devdatt Thengdi
2017-12-4
Walter Roberson
2017-12-5
ga is part of the Global Optimization Toolbox, which has to be licensed separately. It is not one of the licenses included in the Student Suite, but can be added on to the Student license.
类别
在 帮助中心 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!