Optimizacion Con Matlab y Abaqus
Optimizacion Con Matlab y Abaqus
Optimizacion Con Matlab y Abaqus
This program is designed for six-parameter optimization, and includes two MATLAB files:
main.m and objfunction.m. It will execute external programs pre.exe, ABAQUS, and
post.exe, which should be supplied by user to solve direct finite element analysis. The
interface files: initial.txt is for initial guess of parameters; param.txt stores the latest
parameters; history.txt records convergence history; test.txt and result.txt are experimental
and predicted data, respectively.
The following is the code for main.m.
clear; close all;
% Declaration of global variables
global Iter FunEvals ParamHistory c1 c2 c3 c4 c5 c6
global nob nop k0 M mu lamda Ef1 Ef0
load initial.txt
% Initial parameters
k0=initial(1,1); M=initial(1,2); mu=initial(1,3); lamda=initial(1,4);
Ef1=initial(1,5); Ef0=initial(1,6);
% The total number of optimizing parameters
nop=6;
% The scale coefficients for corresponding parameters
c1=1.0e11; c2=1.0e-5; c3=1.0e-9; c4=1.0e-9; c5=1.0e-14; c6=1.0e-11;
% Scale initial parameters
IniGuess=[k0*c1, M*c2, mu*c3, lamda*c4, Ef1*c5, Ef0*c6];
% Initialize counters
Iter=0; FunEvals=0; ParamHistory=[];
% Set optimization options.
options=optimset('TolFun',1e-7, 'TolX',1e-7, 'MaxIter',100)
%Solve the nonlinear least squares problem. It needs "objfunction.m"
[x, ErrNorm]=lsqnonlin(@objfunction,IniGuess,[0 0 0 0 0 0], [inf inf inf inf inf inf],options)
% Scale the optimized parameters to normal values
x1=x(1)/c1; x2=x(2)/c2; x3=x(3)/c3; x4=x(4)/c4; x5=x(5)/c5; x6=x(6)/c6;
OptParam=[x1 x2 x3 x4 x5 x6];
% Save the optimized parameters in "param.txt".
save param.txt OptParam -ascii
% Save the parameter evolution history in "history.txt".
ParamHistory=[ParamHistory; [Iter FunEvals x1 x2 x3 x4 x5 x6 ErrNorm]];
save history.txt ParamHistory -ascii
% Call external programs to solve direct problem and get "result.txt".
! del tempfile.*
! pre
! copy inputfile.inp tempfile.inp
! abaqus job=tempfile interactive
! post