Genetic Algorithm for CFD Optimization

조회 수: 10 (최근 30일)
MOHAMED
MOHAMED 2016년 5월 23일
답변: Wojciech Regulski 2017년 7월 7일
Hi,
I would like to use GA for Computational Fluid Dynamics (CFD) optimization.
In my application, I have 2 parameters (L1 & L2) that need to be optimized to obtain the maximum value of the Torque coefficient (Ct). L1 & L2 are allowed to vary between [0.2 : 0.9] with step size of 0.05. For each different combination of L1 & L2, a new mesh is generated for which the CFD analysis is performed and the value of Ct is determined. The obtained Ct value is compared against a baseline value in order to determine the GA fitness function (fitness = Ct_base / Ct).
To simplify the problem, I have run all possible scenarios of L1 & L2 and saved the Ct values in an excel table. I do not know how can I define the step size constrain (0.05). Also, I do not know how can I select the initial population.
Since my fitness function is not related to the optimization parameters through an equation, is it possible to read the Ct value from excel table based on the selected L1 & L2?
Your help is much appreciated. Thanks.

채택된 답변

MOHAMED
MOHAMED 2016년 5월 28일
Here is my update on the solution I have reached. The following code does what is explained in the question:
clear; clc;
%%Real Variables
L1 = 0.2:0.05:0.9;
L2 = 0.2:0.05:0.9;
%%GA Variables
ObjectiveFunction = @simple_fitness;
nvars = 2; % Number of variables
LB = [1 1]; % Lower bound
UB = [15 15]; % Upper bound
IntCon = [1,2]; % Both Variables are Integers
%%Run GA
opts = optimset('PlotFcn',{@gaplotbestf,@gaplotbestindiv,@gaplotselection});
opts.PopulationSize = 5;
opts.EliteCount = 1;
%opts.MaxGenerations = 20;
[x,fval,exitFlag,Output] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,[],IntCon,opts);
%%GA Outputs
fprintf('The number of generations was : %d\n', Output.generations);
fprintf('The number of function evaluations was : %d\n', Output.funccount);
fprintf('The best function value found was : %g\n', fval);
%%Disply Outputs
disp(' ')
disp('Position of Slot #1 =')
disp(L1(x(1)))
disp('Position of Slot #2 =')
disp(L1(x(2)))
disp('Ct =')
disp(0.083036369/fval)
Here is how I defined the fitness function to read the Ct value from the excel sheet:
function y = simple_fitness(x)
Ct = xlsread('CtVsPitch.xlsx');
y = 0.083036369 / Ct(x(1),x(2));

추가 답변 (1개)

Wojciech Regulski
Wojciech Regulski 2017년 7월 7일
Dear Mohamed, please check out the QuickerSim CFD Toolbox for MATLAB - there is a case on the optimization: https://www.youtube.com/watch?v=Gx4PSI70Uww On top of the solver you can use any otimisation algorithm you wish. Good luck!

카테고리

Help CenterFile Exchange에서 Computational Fluid Dynamics (CFD)에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by