CH 10
CH 10
Abstract The paper presents a compact Matlab im-               fraction and then the program shows the correct optimal
plementation of a topology optimization code for com-          topology for comparison.
pliance minimization of statically loaded structures. The          In the literature, one can find a multitude of approaches
total number of Matlab input lines is 99 including opti-       for the solving of topology optimization problems. In the
mizer and Finite Element subroutine. The 99 lines are          original paper Bendsøe and Kikuchi (1988) a so-called
divided into 36 lines for the main program, 12 lines for the   microstructure or homogenization based approach was
Optimality Criteria based optimizer, 16 lines for a mesh-      used, based on studies of existence of solutions.
independency filter and 35 lines for the finite element              The homogenization based approach has been adopted
code. In fact, excluding comment lines and lines associ-       in many papers but has the disadvantage that the deter-
ated with output and finite element analysis, it is shown       mination and evaluation of optimal microstructures and
that only 49 Matlab input lines are required for solving       their orientations is cumbersome if not unresolved (for
a well-posed topology optimization problem. By adding          noncompliance problems) and furthermore, the resulting
three additional lines, the program can solve problems         structures cannot be built since no definite length-scale
with multiple load cases. The code is intended for edu-        is associated with the microstructures. However, the ho-
cational purposes. The complete Matlab code is given in        mogenization approach to topology optimization is still
the Appendix and can be down-loaded from the web-site          important in the sense that it can provide bounds on the
http://www.topopt.dtu.dk.                                      theoretical performance of structures.
                                                                   An alternative approach to topology optimization is
Key words topology optimization, education, optimal-           the so-called “power-law approach” or SIMP approach
ity criteria, world-wide web, Matlab code                      (Solid Isotropic Material with Penalization) (Bendsøe
                                                               1989; Zhou and Rozvany 1991; Mlejnek 1992). Here, ma-
                                                               terial properties are assumed constant within each elem-
                                                               ent used to discretize the design domain and the variables
                                                               are the element relative densities. The material proper-
1                                                              ties are modelled as the relative material density raised
Introduction                                                   to some power times the material properties of solid ma-
                                                               terial. This approach has been criticized since it was ar-
The Matlab code presented in this paper is intended            gued that no physical material exists with properties de-
for engineering education. Students and newcomers to           scribed by the power-law interpolation. However, a recent
the field of topology optimization can down-load the            paper by Bendsøe and Sigmund (1999) proved that the
code from the web-page http://www.topopt.dtu.dk.               power-law approach is physically permissible as long as
The code may be used in courses in structural optimiza-        simple conditions on the power are satisfied (e.g. p ≥ 3
tion where students may be assigned to do extensions           for Poisson’s ratio equal to 13 ). To ensure existence of so-
such as multiple load-cases, alternative mesh-independ-        lutions, the power-law approach must be combined with
ency schemes, passive areas, etc. Another possibility is to    a perimeter constraint, a gradient constraint or with fil-
use the program to develop students’ intuition for optimal     tering techniques (see Sigmund and Petersson 1998, for
design. Advanced students may be asked to guess the op-        an overview). The power-law approach to topology op-
timal topology for given boundary condition and volume         timization has been applied to problems with multiple
                                                               constraints, multiple physics and multiple materials.
Received October 22, 1999
                                                                   Whereas the solution of the above mentioned ap-
O. Sigmund                                                     proaches is based on mathematical programming tech-
Department of Solid Mechanics, Building 404, Technical Uni-    niques and continuous design variables, a number of pa-
versity of Denmark, DK-2800 Lyngby, Denmark                    pers have appeared on solving the topology optimization
e-mail: sigmund@fam.dtu.dk                                     problem as an integer problem. Beckers (1999) success-
                                                                                                                     121
fully solved large-scale compliance minimization prob-            A topology optimization problem based on the power-
lems using a dual-approach but other approaches based          law approach, where the objective is to minimize compli-
on genetic algorithms or other semi-random approaches          ance can be written as
require thousands of function evaluations even for small                                      N                 
                                                                                                               
number of elements and must be considered impractical.               min              T
                                                                          : c(x) = U KU =        (xe ) ue k0 ue 
                                                                                                      p T       
                                                                                                                
                                                                      x                                         
                                                                                                                
    Apart from above mentioned approaches, which all                                         e=1                
                                                                                                                
solve well defined problems (e.g. minimization of com-                       V (x)                               
                                                               subject to :   V0  =  f                            ,
pliance) a number of heuristic or intuition based ap-                                                           
                                                                                                                
                                                                                                                
                                                                                                                
proaches have been shown to decrease compliance or                        : KU = F                              
                                                                                                                
                                                                                                                
                                                                                                                
other objective functions. Among these methods are so-                                                          
called evolutionary design methods (see e.g. Xie and                      : 0 < xmin ≤ x ≤ 1
Steven 1997; Baumgartner et al. 1992). Apart from be-                                                               (1)
ing very easy to understand and implement (at least
                                                               where U and F are the global displacement and force
for the compliance minimization case), the main moti-
                                                               vectors, respectively, K is the global stiffness matrix, ue
vation for the evolutionary approaches seems to be that
                                                               and ke are the element displacement vector and stiffness
mathematically based or continuous variable approaches
                                                               matrix, respectively, x is the vector of design variables,
“involve some complex calculus operations and mathe-
                                                               xmin is a vector of minimum relative densities (non-zero
matical programming” (citation from Li et al. 1999) and
                                                               to avoid singularity), N (= nelx × nely) is the number
they contain “mathematical methods of some complex-
                                                               of elements used to discretize the design domain, p is the
ity” (citation from Zhao et al. 1998) whereas the evo-
                                                               penalization power (typically p = 3), V (x) and V0 is the
lutionary approach “takes advantage of powerful com-
                                                               material volume and design domain volume, respectively
puting technology and intuitive concepts of evolution
                                                               and f (volfrac) is the prescribed volume fraction.
processes in nature” (citation from Li et al. 1999). Two
                                                                   The optimization problem (1) could be solved using
things can be argued against this. First, the evolutionary
                                                               several different approaches such as Optimality Criteria
approaches become complicated themselves, once more
                                                               (OC) methods, Sequential Linear Programming (SLP)
complex objectives than compliance minimization are
                                                               methods or the Method of Moving Asymptotes (MMA by
considered and second, as shown in this paper, the “math-
                                                               Svanberg 1987) and others. For simplicity, we will here
ematically based” approaches for compliance minimiza-
                                                               use a standard OC-method.
tion are simple to implement as well and are compu-
                                                                   Following Bendsøe (1995) a heuristic updating scheme
tationally equally efficient. Furthermore, mathematical
                                                               for the design variables can be formulated as
programming based methods can easily be extended to
other non-compliance objectives such as non-self-adjoint       xnew
                                                                e   =
and multiphysics problems and to problems with multiple
                                                               
constraints (e.g. Sigmund 1999). Extensions of the evolu-
                                                               max(xmin , xe − m)
                                                               
                                                               
tionary approach to such cases seem more questionable.         
                                                                 if xe Beη ≤ max(xmin , xe − m) ,
                                                               
                                                               
    The complete Matlab code is given in the Appendix.         
                                                               
The remainder of the paper consists of definition and           
                                                               x B η
                                                                 e e
discussion of the optimization problem (Sect. 2), com-
                                                               
                                                                 if max(xmin , xe − m) < xe Beη < min(1, xe + m) ,
ments about the Matlab implementation (Sect. 3) fol-           
                                                               
                                                               
                                                               
lowed by a discussion of extensions (Sect. 4) and a conclu-    
                                                               min(1, xe + m)
                                                               
                                                               
sion (Sect. 5).                                                
                                                                  if min(1, xe + m) ≤ xe Beη ,
                                                                                                                 (2)
2
                                                               where m (move) is a positive move-limit, η (= 1/2) is
The topology optimization problem
                                                               a numerical damping coefficient and Be is found from the
                                                               optimality condition as
A number of simplifications are introduced to simplify the
Matlab code. First, the design domain is assumed to be                 ∂c
                                                                     −
rectangular and discretized by square finite elements. In              ∂xe
this way, the numbering of elements and nodes is simple        Be =       ,                                          (3)
                                                                      ∂V
(column by column starting in the upper left corner) and            λ
the aspect ratio of the structure is given by the ratio of            ∂xe
elements in the horizontal (nelx) and the vertical direc-      where λ is a Lagrangian multiplier that can be found by
tion (nely).1                                                  a bi-sectioning algorithm.
                                                                  The sensitivity of the objective function is found as
 1
   Names in type-writer style refer to Matlab variable names
                                                               ∂c
that differ from the obvious (see the Matlab code in the            = −p(xe )p−1 uTe k0 ue .                          (4)
Appendix)                                                      ∂xe
122
3.2                                                            1
                                                               0                        1
                                                                                        0
                                                               0
                                                               1                        0
                                                                                        1
Optimality criteria based optimizer (lines 37–48)              0
                                                               1                        0
                                                                                        1
The updated design variables are found by the opti-
                                                               0
                                                               1
                                                               0
                                                               1
                                                               0
                                                               1
                                                               0
                                                               1
                                                                        ?               0
                                                                                        1
                                                                                        0
                                                                                        1
                                                                                        0
                                                                                        1
                                                                                        0
                                                                                        1
mizer (lines 37–48). Knowing that the material volume          0
                                                               1                        0
                                                                                        1
(sum(sum(xnew))) is a monotonously decreasing func-
tion of the Lagrange multiplier (lag), the value of the
                                                               Fig. 2 Topology optimization of a cantilever beam. Left: de-
Lagrangian multiplier that satisfies the volume constraint      sign domain and right: topology optimized beam
can be found by a bi-sectioning algorithm (lines 40-48).
The bi-sectioning algorithm is initialized by guessing
a lower l1 and an upper l2 bound for the Lagrangian
multiplier (line 39). The interval which bounds the La-        the difference between all degrees of freedom and the fixed
grangian multiplier is repeatedly halved until its size is     degrees of freedom (line 82).
less than the convergence criteria (line 40).                      The element stiffness matrix is calculated in lines 86–
                                                               99. The 8 by 8 matrix for a square bi-linear 4-node elem-
                                                               ent was determined analytically using a symbolic manip-
3.3                                                            ulation software. The Young’s modulus E and the Pois-
Mesh-independency filtering (lines 49–64)                       son’s ratio nu can be altered in lines 88 and 89.
84 U(freedofs,:) = K(freedofs,freedofs) \
                   F(freedofs,:);                              4.2
                                                               Multiple load cases
where freedofs indicate the degrees of freedom which
are unconstrained. Mostly, it is easier to define the de-       It is also very simple to extend the algorithm to account
grees of freedom that are fixed (fixeddofs) thereafter the      for multiple load cases. In fact, this can be done by adding
freedofs are found automatically using the Matlab oper-        only three additional lines and making minor changes to
ator setdiff which finds the free degrees of freedoms as        another 4 lines.
124
                                                              0110                             0110
thus lines 20–22 are substituted with the lines                  1010                             1010
19b      dc(ely,elx) = 0.;
                                                                    1010
                                                                       1010
                                                                                     ?               1010
                                                                                                        1010
19c      for i = 1:2
20        Ue = U([2*n1-1;2*n1; 2*n2-1;2*n2;
               2*n2+1;2*n2+2;2*n1+1;2*n1+2],i);
                                                              Fig. 4 Topology optimization of a cantilever beam with
21        c = c + x(ely,elx)^penal*Ue’*KE*Ue;
                                                              a fixed hole. Left: design domain and right: topology opti-
22        dc(ely,elx) = dc(ely,elx) -                         mized beam
             penal*x(ely,elx)^(penal-1)*Ue’*KE*Ue;
22b      end
79 F(2*(nelx+1)*(nely+1),1) = -1.;
             F(2*(nelx)*(nely+1)+2,2) = 1.;                   when the following 10 lines were added to the main
                                                              program (after line 4) in order to find passive elem-
                                                              ents within a circle with radius nely/3. and center
The input line for Fig. 3 is                                  (nely/2., nelx/3.)
This paper has presented a very simple implementation         Bendsøe, M.P. 1989: Optimal shape design as a material dis-
of a mathematical programming base topology optimiza-         tribution problem. Struct. Optim. 1, 193–202
tion algorithm. The code is implemented using only 99
                                                              Bendsøe, M.P. 1995: Optimization of structural topology,
Matlab input lines and includes optimizer, mesh-indepe-       shape and material . Berlin, Heidelberg, New York: Springer
ndency filtering and Finite Element code.
    The Matlab code can be down-loaded from the web-          Bendsøe, M.P.; Kikuchi, N. 1988: Generating optimal topolo-
page http://www.topopt.dtu.dk and is intended for ed-         gies in optimal design using a homogenization method. Comp.
ucational purposes. The code can easily be extended to        Meth. Appl. Mech. Engrg. 71, 197–224
include multi load problems and the definition of passive      Bendsøe, M.P.; Sigmund, O. 1999: Material interpolations in
areas.                                                        topology optimization. Arch. Appl. Mech. 69, 635–654
    Running the code in Matlab is rather slow compared
to a Fortran implementation of the same code which can        Li, Q.; Steven, G.P.; Xie, Y. M. 1999: On equivalence between
be tested at the web-site http://www.topopt.dtu.dk.           stress criterion and stiffness criterion in evolutionary struc-
However, an add-on package to Matlab (MATLAB Com-             tural optimization. Struct. Optim. 18, 67–73
piler) allows for the generation of more efficient C-code       Mlejnek, H.P. 1992: Some aspects of the genesis of structures.
that can be optimized for run-time (this option, how-         Struct. Optim. 5, 64–69
ever, has not been tested by the author). It should be
noted that speed can be gained by modifying the Mat-          Sigmund, O. 1994: Design of material structures using top-
lab code itself, however the speed is gained on the cost of   ology optimization. Ph.D. Thesis, Department of Solid Me-
                                                              chanics, Technical University of Denmark
simplicity of the program. The modification is suggested
by Andreas Rietz from Linköping University who uses          Sigmund, O. 1997: On the design of compliant mechanisms
sparsity options in the assembly of the global stiffness ma-   using topology optimization. Mech. Struct. Mach. 25, 495–
trix. The reader may down-load his code at the web-page:      526
126