Help with script for multi-variable non-linear optimisation problem

3 views (last 30 days)
Hello,
So I'm basically dealing with a problem whereby I need to maximise a function in which I can change two variables, but there is a set of constraints to adhere to. I've tried reading around how to do this but I'm literally no further in mu understanding. Here is the script:
clc;
clear;
T = 220+273;
roh = 0.73;
mu = 1.467 * 10^-5;
Pr = 0.685;
K = (1.5207e-11)*T^3 - (4.8574e-8)*T^2 + (1.0184e-4)*T - (3.9333e-4);
H = input('Please enter the value for height');
D1 = 0.18*H;
HD = 1/0.18;
L = 1.4*H;
u = input('Please enter value for velocity');
Re = (roh.*D1.*u)/mu;
f = (pi./4).*(D1./L).^2;
disp('The relative nozzle area is');
disp(f);
sf = sqrt(f);
disp('The reynolds number is');
disp(Re);
A = (1 + (HD./(0.6./sf)).^6).^-0.05;
B = (1-(2.2.*sf))./(1+0.2.*(HD-6).*sf);
NuPr = A*sf*B*(Re^(2/3))
Nu = (Pr^0.42)*NuPr;
%Nu = hD/K;
h = (Nu*K)./D1;
disp('The average heat transfer coefficient is');
disp(h);
Basically, within my script the function that I would like to maximise is that of "NuPr", where this is a function of "A","B","sf" and "Re", all of which are then functions of the two variables which I can alter, which are "H" and "u".
The constraints are as follows:
2000<=Re<=100,000
0.004<=f<=0.04
20<=u<=60
I'm aware this is quite a complicated optimisation problem, but it's very important I get this done quite quickly. If anyone could please tell me how that would be amazing.
Thanks guys.

Answers (2)

Alan Weiss
Alan Weiss on 31 Jan 2017
Sometimes it is better to slow down, take the time to understand something, and then proceed.
Optimization is the process of taking control variables (the variables you can move) and moving them around to try to minimize an objective function (the function you are trying to optimize). If you want to maximize the objective, minimize its negative.
In MATLAB, you have to put your control variables into one vector, typically called x. You might say x(1) = H and x(2) = u.
From there, write your nonlinear objective function as a function of x. If you have more parameters that are constants during the optimization, you can either define them in the objective function , or pass them as extra parameters.
For your constraints, you have bounds on u = x(2), and some nonlinear constraints as well.
There are plenty of examples of constrained nonlinear optimization.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Torsten
Torsten on 31 Jan 2017
From your equations, any feasible combination of H and u that makes Re = 100,000 solves your optimization problem. This is because A, sf and B are independent of H and u.
Best wishes
Torsten.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!