6.2. Truss optimization

A simple optimization example is shown to display Abaqus2Matlab functioning. The weight of the 2-bar plane truss shown in Fig. 1 will be optimized by minimizing the members' cross-sectional area. The truss is characterized by the following quantities: Young's modulus E = 68.948 GPa, density = 2767.99 kg/m3, bar length L = 9.144 m and applied concentrated forces P = 444.974 kN. Material costs can be lowered by reducing the weight, which implies - for a constant density and bar length - minimizing the sum of the cross-sectional areas. The latter are the design variables under consideration. Constraints are imposed on the displacements, where their maximum value should be limited to d_max = 0.0508 m in both directions, and stresses, where their magnitudes should be lower than sigma_max = 172.369 MPa in both tension and compression (absolute value). The design variables are the cross section area of each member in the interval [0.00365, 0.02258] m2, with the lower bound being a consequence of the upper limit imposed on the axial stress. The truss to be optimized is shown in Figure 1. The main script employed to solve the problem is shown in Listing 1. The number of elements is first specified and an initial guess for the 2 cross sectional areas assigned. Before calling the main optimization function, design variable limits are defined and tolerances provided; the latter include an upper bound on the variation of the objective function (i.e., truss weight) during a step and an upper bound on the magnitude of the constraint functions.

% Declare Abaqus time counter as global variable (used also in
% TrussConfun.m)
global tABAQUS
% Specify the number of elements of the truss.
NumElements=2;
% Make a starting guess for the solution.
x0 = [0.0037; 0.0049];
% Set the lower and upper limit of the cross section areas of the two
% members of the truss.
AreaMin=0.003650822800775; % P*sqrt(2)/maxstress
AreaMax=0.0225806;
lb=AreaMin*ones(1,NumElements);
ub=AreaMax*ones(1,NumElements);
% Set FunctionTolerance and StepTolerance
options=optimset('fmincon');
options.Display='iter-detailed';
options.TolFun=1e-3;
options.TolCon=1e-3;
% Start timer
tic
tABAQUS=0;
% Perform constrained optimization of the truss
[X,fval,exitflag,output,lambda]=fmincon(@TrussObjfun,x0,[],[],[],[],...
lb ,ub,'TrussConfun',options)
% Report elapsed times (total, required by Abaqus and required by Matlab
% respectively)
tTOTAL=toc
tABAQUS
tMATLAB=tTOTAL-tABAQUS

Code listing 1

The function TrussObjfun.m basically provides as output the weight of the truss for given values of the design variables:

function f = TrussObjfun(x)
% Horizontal length
u=9.144;
% total weight
f = 9.81*2767.990471*x'*u*[1;sqrt(2)];
end

Code listing 2

TrussConfun.m, shown in listing 3, is employed to construct the Abaqus input file and subsequently perform the calculations. The input file is created through TrussInpFileConstr.m on every constraint evaluation, changing the data lines corresponding to the cross section area. Next, postprocessing of the aforementioned results takes place, which concludes in the formation of the inequality and equality vectors required as an output of the constraint function in Matlab (c and ceq, respectively). All the required information is then available for Matlab's function fmincon to perform the optimization analysis.

function [c,ceq] = TrussConfun(x)
% Declare Abaqus timer as global variable
global tABAQUS
% Set the displacement limits of the 2-bar truss
% maximum absolute value of horizontal displacement (m)
Dmaxhor=0.0508;
% maximum absolute value of vertical displacement (m)
Dmaxver=0.0508;
% Construct the Abaqus input file TrussABAQUS.inp
TrussInpFileConstr(x)
% Report time before Abaqus analysis starts
t1=toc;
% Run the input file TrussABAQUS.inp with Abaqus
!abaqus job=TrussABAQUS
% Pause Matlab execution to give Abaqus enough time to create the
% TrussABAQUS.lck file
pause(10)
% If the TrussABAQUS.lck file exists then halt Matlab execution
while exist('TrussABAQUS.lck','file')==2
pause(0.1)
end
% Report time after Abaqus analysis terminates
t2=toc;
% Add elapsed time to Abaqus time counter
tABAQUS=tABAQUS+t2-t1;
% Obtain the nodal displacements
NodalDisplacements=out2{1,1}(:,2:3);
% Delete the files of last Abaqus run to avoid rewriting them
delete('TrussABAQUS.fil');
delete('TrussABAQUS.prt');
delete('TrussABAQUS.com');
delete('TrussABAQUS.sim');
% Calculate the maximum nodal displacements
maxNodDisplX1=max(abs(NodalDisplacements(:,1)));
maxNodDisplY1=max(abs(NodalDisplacements(:,2)));
% Assemble the constraints
c = [maxNodDisplY1-Dmaxver;
maxNodDisplX1-Dmaxhor];
ceq = [];
end

Code listing 3

Results show that design variables at the local minimum are equal to [0.00365, 0.00482] m2, while the minimum truss weight becomes 2.5987 kN. For the particular example under consideration, this has been achieved after 6 iterations and 21 objective function evaluations. Optimization methodologies, like the one outlined here, can be used at the concept stage of the design process to achieve a proposal that best fits performance and manufacturability requirements. Such tools have proven to substantially reduce design development costs by avoiding expensive and time consuming design iterations.

Results can be obtained in a few minutes and all the necessary files can be freely downloaded from Abaqus2Matlab website. The results of the optimization problem described here are the following:

First-order      Norm of
Iter F-count            f(x)  Feasibility   optimality         step
0       3    2.639299e+03    0.000e+00    1.731e+03
1       6    2.222749e+03    9.909e-03    1.348e+02    1.155e-03
2       9    2.221682e+03    9.944e-03    5.491e+01    2.938e-06
3      12    2.233984e+03    9.533e-03    1.664e+03    3.466e-05
4      15    2.519902e+03    1.695e-03    1.008e+05    8.157e-04
5      18    2.595075e+03    7.575e-05    8.515e+03    2.146e-04
6      21    2.598717e+03    1.718e-07    1.473e+02    1.135e-05

Optimization completed: The relative first-order optimality measure, 4.195356e-04,
is less than options.TolFun = 1.000000e-03, and the relative maximum constraint
violation, 1.717630e-07, is less than options.TolCon = 1.000000e-03.

Optimization Metric                                         Options
relative first-order optimality =   4.20e-04       TolFun =   1e-03 (selected)
relative max(constraint violation) =   1.72e-07    TolCon =   1e-03 (selected)

X =

0.003651106365609
0.004819002266391

fval =

2.598717321129937e+03

exitflag =

1

output =

iterations: 6
funcCount: 21
constrviolation: 1.717630013498006e-07
stepsize: 1.134970839769077e-05
algorithm: 'interior-point'
firstorderopt: 1.473172563314147e+02
cgiterations: 0
message: 'Local minimum found that satisfies the constrai...'

lambda =

eqlin: [0x1 double]
eqnonlin: [0x1 double]
ineqlin: [0x1 double]
lower: [2x1 double]
upper: [2x1 double]
ineqnonlin: [2x1 double]

tTOTAL =

5.431887016466463e+02

tABAQUS =

5.420298590808136e+02

tMATLAB =

1.158842565832742

_________________________________________________________________________
Abaqus2Matlab - www.abaqus2matlab.com
Copyright (c) 2017 by George Papazafeiropoulos

If using this application for research or industrial purposes, please cite:
G. Papazafeiropoulos, M. Muniz-Calvente, E. Martinez-Paneda.
Abaqus2Matlab: a suitable tool for finite element post-processing.
Advances in Engineering Software. Vol 105. March 2017. Pages 9-16. (2017)