0% found this document useful (0 votes)
22 views

An Efficient 3D Topology Optimization Code Written in Matlab

Uploaded by

The3edzon XD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

An Efficient 3D Topology Optimization Code Written in Matlab

Uploaded by

The3edzon XD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Struct Multidisc Optim (2014) 50:1175–1196

DOI 10.1007/s00158-014-1107-x

EDUCATIONAL ARTICLE

An efficient 3D topology optimization code written in Matlab


Kai Liu · Andrés Tovar

Received: 17 October 2013 / Revised: 19 March 2014 / Accepted: 22 April 2014 / Published online: 25 June 2014
© Springer-Verlag Berlin Heidelberg 2014

Abstract This paper presents an efficient and compact with the ability to find innovative, high-performance struc-
M ATLAB code to solve three-dimensional topology opti- tural layouts, which has attracted the interest of applied
mization problems. The 169 lines comprising this code mathematicians and engineering designers. From the work
include finite element analysis, sensitivity analysis, density of Lucien Schmit in the 1960s (Schmit 1960)—who recog-
filter, optimality criterion optimizer, and display of results. nized the potential of combining optimization methods with
The basic code solves minimum compliance problems. A finite-element analysis for structural design—and the semi-
systematic approach is presented to easily modify the defini- nal paper by Bendsøe and Kikuchi (1988), there have been
tion of supports and external loads. The paper also includes more than eleven thousand journal publications in this area
instructions to define multiple load cases, active and pas- (Compendex list as of September 2013), several reference
sive elements, continuation strategy, synthesis of compliant books (Hassani and Hinton 1998; Bendsøe and Sigmund
mechanisms, and heat conduction problems, as well as the 2003; Christensen and Klarbring 2009), and a number of
theoretical and numerical elements to implement general readily available educational computer tools for M ATLAB
non-linear programming strategies such as SQP and MMA. and other platforms. Some examples of such tools include
The code is intended for students and newcomers in the the topology optimization program by Liu et al. (2005) for
topology optimization. The complete code is provided in Femlab, the shape optimization program by Allaire and
Appendix C and it can be downloaded from http://top3dapp. Pantz (2006) for FreeFem++, the open source topology
com. optimization program ToPy by Hunter (2009) for Python,
and the 99-line program for Michell-like truss structures by
Keywords Topology optimization · M ATLAB · Sokół (2011) for Mathematica.
Compliance · Compliant mechanism · Heat conduction · For M ATLAB, Sigmund (2001) introduced the 99-line
Non-linear programming program for two-dimensional topology optimization. This
program uses stiffness matrix assembly and filtering via
nested loops, which makes the code readable and well-
1 Introduction organized but also makes it slow when solving larger
problems. Andreassen et al. (2011) presented the 88-line
Topology optimization is a computational material distribu- program with improved assembly and filtering strategies.
tion method for synthesizing structures without any precon- When compared to the 99-line code in a benchmark prob-
ceived shape. This freedom provides topology optimization lem with 7500 elements, the 88-line code is two orders of
magnitude faster. From the same research group, Aage et al.
(2013) introduced TopOpt, the first topology optimization
App for hand-held devices.
K. Liu () · A. Tovar Also for M ATLAB, Wang et al. (2004) introduced the
Department of Mechanical Engineering,
199-line program TOPLSM making use of the level-set
Indiana University-Purdue University Indianapolis,
Indianapolis, IN 46202, USA method. Challis (2010) also used the level-set method but
e-mail: [email protected] with discrete variables in a 129-line program. Suresh (2010)
1176 K. Liu and A. Tovar

presented a 199-line program ParetoOptimalTracing compliance. As an illustration, assume that a design has
that traces the Pareto front for different volume fractions one single hole. Then, it is possible to find an improved
using topological sensitivities. More recently, Talischi et al. solution with the same mass and lower compliance when
(2012a, b) introduced PolyMesher and PolyTop for this hole is replaced by two smaller holes. Improved solu-
density-based topology optimization using polygonal finite tions can be successively found by increasing the number
elements. The use of polygonal elements makes these pro- of holes and reducing their size. The design will progress
grams suitable for arbitrary non-Cartesian design domains towards a chattering design within infinite number of holes
in two dimensions. of infinitesimal size. That makes the compliance problem
One of the few contributions to three-dimensional M AT- unbounded and, therefore, ill-posed.
LAB programs is presented by Zhou and Wang (2005). This One alternative to make the compliance problem well-
code, referred to as the 177-line program, is a successor posed is to control the perimeter of the structure (Haber and
to the 99-line program by Sigmund (2001) that inherits Jog 1996; Jog 2002). This method effectively avoids chat-
and amplifies the same drawbacks. Our paper presents a tering configurations, but its implementation is not free of
169-line program referred to as top3d that incorporates complications. It has been reported that the addition of a
efficient strategies for three-dimensional topology opti- perimeter constraint creates fluctuations during the iterative
mization. This program can be effectively used in personal optimization process so internal loops need to be incorpo-
computers to generate structures of substantial size. This rated (Duysinx 1997) Op. cit. (Bendsøe and Sigmund 2003).
paper explains the use of top3d in minimum compli- Also, small variations in the parameters of the algorithm
ance, compliant mechanism, and heat conduction topology lead to dramatic changes in the final layout (Jog 2002).
optimization problems.
The rest of this paper is organized as follows. Section 2 2.2 Homogenization method
briefly reviews theoretical aspects in topology optimiza-
tion with focus on the density-based approach. Section 3 Another alternative is to relax the binary condition and
introduces 3D finite element analysis and its numerical include intermediate material densities in the problem for-
implementation. Section 4 presents the formulation of three mulation. In this way, the chattering configurations become
typical topology optimization problems, namely, minimum part of the problem statement by assuming a periodically
compliance, compliant mechanism, and heat conduction. perforated microstructure. The mechanical properties of the
Section 5 discusses the optimization methods and their material are determined using the homogenization theory.
implementation in the code. Section 6 shows the numer- This method is referred to as the homogenization method
ical implementation procedures and results of three dif- for topology optimization (Bendsøe 1995; Allaire 2001).
ferent topology optimization problems, several extensions The main drawback of this approach is that the optimal
of the top3d code, and multiple alternative implementa- microstructure, which is required in the derivation of the
tions. Finally, Section 7, offers some closing thoughts. The relaxed problem, is not always known. This can be allevi-
top3d code is provided in Appendix C and can also be ated by restricting the method to a subclass of microstruc-
downloaded for free from the website: http://top3dapp.com. tures, possibly suboptimal but fully explicit. This approach,
referred to as partial relaxation, has been utilized by many
authors including Bendsøe and Kikuchi (1988), Allaire
2 Theoretical background and Kohn (1993), Allaire et al. (2004), and references
therein.
2.1 Problem definition and ill-posedness An additional problem with the homogenization meth-
ods is the manufacturability of the optimized structure.
A topology optimization problem can be defined as a binary The “gray” areas found in the final designs contain micro-
programming problem in which the objective is to find scopic length-scale holes that are difficult or impossible
the distribution of material in a prescribed area or volume to fabricate. However, this problem can be mitigated with
referred to as the design domain. A classical formulation, penalization strategies. One approach is to post-process the
referred to as the binary compliance problem, is to find the partially relaxed optimum and force the intermediate den-
“black and white” layout (i.e., solids and voids) that min- sities to take black or white values (Allaire et al. 1996).
imizes the work done by external forces (or compliance) This a posteriori procedure results in binary designs, but it
subject to a volume constraint. is purely numerical and mesh dependent. Other approach
The binary compliance problem is known to be ill-posed is to impose a priori restrictions on the microstructure that
(Kohn and Strang 1986a, b, c). In particular, it is possible implicitly lead to black-and-white designs (Bendsøe 1995).
to obtain a non-convergent sequence of feasible black- Even though penalization methods have shown to be effec-
and-white designs that monotonically reduce the structure’s tive in avoiding or mitigating intermediate densities, they
An efficient 3D topology optimization code written in Matlab 1177

revert the problem back to the original ill-possedness with where the operator dist(i, j ) is the distance between the cen-
respect to mesh refinement. ter of element i and the center of element j , and R is the
size of the neighborhood or filter size. The weight factor
2.3 Density-based approach Hij may be defined as a function of the distance between
neighboring elements, for example
An alternative that avoids the application of homogenization
theory is to relax the binary problem using a continu- Hij = R − dist(i, j ), (5)
ous density value with no microstructure. In this method, where j ∈ Ni . The filtered density x˜i defines a modi-
referred to as the density-based approach, the material dis- fied (physical) density field that is now incorporated in the
tribution problem is parametrized by the material density topology optimization formulation and the SIMP model as
distribution. In a discretized design domain, the mechan-
p
ical properties of the material element, i.e., the stiffness Ei (x̃i ) = Emin + x̃i (E0 − Emin ), x̃i ∈ [0, 1]. (6)
tensor, are determined using a power-law interpolation func-
The regularized SIMP interpolation formula defined by (6)
tion between void and solid (Bendsøe 1989; Mlejnek 1992).
used in this work.
The power law may implicitly penalize intermediate density
values driving the structure towards a black-and-white con-
figuration. This penalization procedure is usually referred
3 Finite element analysis
to as the Solid Isotropic Material with Penalization (SIMP)
method (Zhou and Rozvany 1991). The SIMP method does
3.1 Equilibrium equation
not solve the problem’s ill-possedness, but it is simpler than
other penalization methods.
Following the regularized SIMP method given by (6) and
The SIMP method is based on a heuristic relation
the generalized Hooke’s law, the three-dimensional consti-
between (relative) element density xi and element Young’s
tutive matrix for an isotropic element i is interpolated from
modulus Ei given by
void to solid as
p
Ei = Ei (xi ) = xi E0 , xi ∈]0, 1], (1)
Ci (x̃i ) = Ei (x̃i )C0i , x̃i ∈ [0, 1], (7)
where E0 is the elastic modulus of the solid material and p is
the penalization power (p > 1). A modified SIMP approach where C0i is the constitutive matrix with unit Young’s
is given by modulus. The unit constitutive matrix is given by
p
Ei = Ei (xi ) = Emin + xi (E0 − Emin ), xi ∈ [0, 1], (2) 1
C0i = ×
where Emin is the elastic modulus of the void material, (1 + ν)(1 − 2ν)
⎡1−ν ν ν 0 0 0 ⎤
which is non-zero to avoid singularity of the finite element
stiffness matrix. The modified SIMP approach, as (2), offers ⎢ ν 1−ν ν 0 0 0 ⎥
⎢ ν ν 1−ν 0 0 0 ⎥
⎢ ⎥ , (8)
a number of advantages over the classical SIMP formula- ⎢ 0 0 0 (1 − 2ν)/2 0 0 ⎥
⎣ ⎦
tion, as shown in (1), including the independency between 0 0 0 0 (1 − 2ν)/2 0
the minimum value of the material’s elastic modulus and the 0 0 0 0 0 (1 − 2ν)/2
penalization power (Sigmund 2007).
However, topology optimization methods are likely to where ν is the Poisson’s ratio of the isotropic material.
encounter numerical difficulties such as mesh-dependency, Using the finite element method, the elastic solid element
checkerboard patterns, and local minima (Bendsøe and stiffness matrix is the volume integral of the elements con-
Sigmund 2003). In order to mitigate such issues, resear- stitutive matrix Ci (x̃i ) and the strain–displacement matrix
chers have proposed the use of regularization techniques B in the form of
(Sigmund and Peterson 1998). One of the most common +1 +1 +1
approaches is the use of density filters (Bruns and Tortorelli ki (x̃i ) = BT Ci (x̃i )Bdξ1 dξ2 dξ3 , (9)
−1 −1 −1
2001). A basic filter density function is defined as
 where ξe (e = 1, . . . , 3) are the natural coordinates as
j ∈N Hij vj xj shown in Fig. 1, and the hexahedron coordinates of the cor-
x̃i =  i , (3)
j ∈Ni Hij vj ners are shown in Table 1. The strain–displacement matrix
where Ni is the neighborhood of an element xi with volume B relates the strain  and the nodal displacement u,  = Bu.
vi , and Hij is a weight factor. The neighborhood is defined Using the SIMP method, the element stiffness matrix is
as interpolated as

Ni = {j : dist(i, j ) R} , (4) ki (x̃i ) = Ei (x̃i )k0i , (10)


1178 K. Liu and A. Tovar

4 3 where K0i is a constant matrix. Using the interpolation


function defined in (6), one finally observes that
8 7 n
p
ξ2 K(x̃) = Emin + x̃i (E0 − Emin ) K0i . (15)
ξ1 i=1
ξ3
1 2 Finally, the nodal displacements vector U(x̃) is the solu-
tion of the equilibrium equation
5 6 K(x̃)U(x̃) = F, (16)
Fig. 1 The eight-node hexahedron and the natural coordinates
ξ1 , ξ2 , ξ3 where F is the vector of nodal forces and it is independent
of the physical densities x̃. For brevity of notation, we omit-
ted the dependence of physical densities x̃ on the design
where variables x, x̃ = x̃(x).
+1 +1 +1
k0i = BT C0 Bdξ1 dξ2 dξ3 . (11) 3.2 Numerical implementation
−1 −1 −1

Replacing values in (11), the 24 × 24 element stiffness Consider the discretized prismatic structure in Fig. 2 com-
matrix k0i for an eight-node hexahedral element is posed of eight eight-noded cubic elements. The nodes
identified with a number (node ID) ordered column-wise
⎡ ⎤ up-to-bottom, left-to-right, and back-to-front. The position
k1 k2 k3 k4
1 ⎢ kT k5 k6 kT4 ⎥ of each node is defined with respect to Cartesian coordinate
0
ki = ⎢ 2 ⎥ (12)
(ν + 1)(1 − 2ν) ⎣ kT3 k6 kT5 kT2 ⎦ system with origin at the left-bottom-back corner.
k4 k3 k2 kT1 Within each element, the eight nodes N1 , . . . , N8 are
ordered in counter-clockwise direction as shown in Fig. 3.
where km (m = 1, . . . , 6) are 6 × 6 symmetric matrices (see Note that the “local” node number (Ni ) does not follow the
Appendix A). One can also verify that k0i is positive definite. same rule as the “global” node ID (NIDi ) system in Fig. 2.
The global stiffness matrix K is obtained by the assembly Given the size of the volume (nelx × nely × nelz) and
of element-level counterparts ki , the global coordinates of node N1 (x1 , y1 , z1 ), one can iden-
tify the global node coordinates and node IDs of the other
K(x̃) = n
i=1 ki (x̃i ) = n 0
i=1 Ei (x̃i )ki , (13) seven nodes in that element by the mapping the relationships
as summarized in Table 2.
where n is the total number of elements. Using the global Each node in the structure has three degrees of free-
versions of the element stiffness matrices Ki and K0i , (13) dom (DOFs) corresponding to linear displacements in x-y-z
is expressed as directions (one element has 24 DOFs). The degrees of free-
dom are organized in the nodal displacement vector U
n n
as
K(x̃) = Ki (x̃i ) = Ei (x̃i )K0i . (14)
T
i=1 i=1
U = U1x , U1y , U1z , . . . , U8×nz ,

Table 1 The eight-node hexahedral element with node numbering


conventions

Node ξ1 ξ2 ξ3 1 3 5 7 9
11 13 15 17 19
1 −1 −1 −1 y 23
25 27 29
21
2 +1 −1 −1 2 x 4 6 8 10
3 +1 +1 −1 12 z 14 16 18 20
4 −1 +1 −1 22 24 26 28 30
5 −1 −1 +1
6 +1 −1 +1
7 +1 +1 +1
8 −1 +1 +1 Fig. 2 Global node IDs in a prismatic structure composed of 8
elements
An efficient 3D topology optimization code written in Matlab 1179

N4 N3 the node IDs for each element. For the volume in Fig. 2,
nelx = 4, nely = 1, and nelz = 2, which results in
⎡ ⎤
N8 N7 4 5 6 · · · 31 32 33 ← Element 1
⎢ 10 11 12 · · · 37 38 39 ⎥ ← Element 2
y ⎢ ⎥
⎢ 16 17 18 · · · 43 44 45 ⎥ ← Element 3
x ⎢ ⎥
z ⎢ 22 23 24 · · · 49 50 51 ⎥ ← Element 4
edofMat = ⎢ ⎢ ⎥
N1 N2 ⎥
⎢ 34 35 36 · · · 61 62 63 ⎥ ← Element 5
⎢ 40 41 42 · · · 67 68 69 ⎥ ← Element 6
⎢ ⎥
N5 N6 ⎣ 46 47 48 · · · 73 74 75 ⎦ ← Element 7
52 53 54 · · · 79 80 81 ← Element 8 .
Fig. 3 Local node numbers within a cubic element
The element connectivity matrix edofMat is used to
assemble the global stiffness matrix K as follows:

where n is the number of elements in the structure. The loca-


tion of the DOFs in U, and consequently K and F, can be
determined from the node ID as shown in Table 2.
The node IDs for each element are organized in a con-
nectivity matrix edofMat with following M ATLAB lines:
The element stiffness matrix KE (size 24×24) is obtained
from the lk H8 subroutine (lines 99-146). Matrices iK
(size 24 nele × 24) and jK (size nele × 242 ), reshaped as
column vectors, contain the rows and columns identifying
the 24 × 24 × nele DOFs in the structure. The three-
dimensional array xPhys (size nely × nelx × nelz)
corresponds to the physical densities. The matrix sK (size
242 × nele) contains all element stiffness matrices. The
assembly procedure of the (sparse symmetric) global stiff-
ness matrix K (line 71) avoids the use of nested for
loops.
Finally, the nodal displacement vector U is obtained
where nele is the total number of elements, nodegrd from the solution of the equilibrium equation (16) by pre-
contains the node ID of the first grid of nodes in the x-y multiplying the inverse of the stiffness matrix K and the
plane (for z = 0), the column vector edofVec contains vector of nodal forces F,
the node IDs of the first node at each element, and the con-
nectivity matrix edofMat of size nele × 24 containing

Table 2 Illustration of relationships between node number, node coordinates, node ID and node DOFs

Node Number Node coordinates Node ID Node Degree of Freedoms

x y z

N1 (x1 , y1 , z1 ) NID†1 3 ∗ NID1 − 2 3 ∗ NID1 − 1 3 ∗ NID1


N2 (x1 + 1, y1 , z1 ) NID2 = NID1 + (nely + 1) 3 ∗ NID2 − 2 3 ∗ NID2 − 1 3 ∗ NID2
N3 (x1 + 1, y1 + 1, z1 ) NID3 = NID1 + nely 3 ∗ NID3 − 2 3 ∗ NID3 − 1 3 ∗ NID3
N4 (x1 , y1 + 1, z1 ) NID4 = NID1 − 1 3 ∗ NID4 − 2 3 ∗ NID4 − 1 3 ∗ NID4
N5 (x1 , y1 , z1 + 1) NID5 = NID1 + NID‡z 3 ∗ NID5 − 2 3 ∗ NID5 − 1 3 ∗ NID5
N6 (x1 + 1, y1 , z1 + 1) NID6 = NID2 + NIDz 3 ∗ NID6 − 2 3 ∗ NID6 − 1 3 ∗ NID6
N7 (x1 + 1, y1 + 1, z1 + 1) NID7 = NID3 + NIDz 3 ∗ NID7 − 2 3 ∗ NID7 − 1 3 ∗ NID7
N8 (x1 , y1 + 1, z1 + 1) NID8 = NID4 + NIDz 3 ∗ NID8 − 2 3 ∗ NID8 − 1 3 ∗ NID8


NID1 = z1 *(nelx+1)*(nely+1)+x1 ∗(nely+1)+(nely+1 − y1 )

NIDz = (nelx+1)*(nely+1)
1180 K. Liu and A. Tovar

where the indices freedofs indicate the unconstrained The derivative of the volume constraint v(x̃) in (18) with
DOFs. For the cantilevered structure in Fig. 2, the con- respect to the design variable xe is given
strained DOFs
∂v(x̃) ∂v(x̃) ∂ x̃i
= (19)
∂xe ∂ x̃i ∂xe
i∈Ne

where
where jf, and kf are the coordinate of the fixed nodes, ∂v(x̃)
= vi (20)
fixednid are the node IDs, and fixeddof are the ∂ x̃i
location of the DOFs. The free DOFs, are then defined as
and
∂ x̃i Hie ve
= . (21)
∂xe j ∈Ni Hij vj
where ndof is the total number of DOFs. By default, the
code constraints the left face of the prismatic structure and The code uses a mesh with equally sized cubic elements of
assigns a vertical load to the structure’s free-lower edge as unit volume, then vi = vj = ve = 1.
depicted in Fig. 2. The user can define different load and The derivative of the compliance is
support DOFs by changing the corresponding node coordi-
∂c(x̃) ∂c(x̃) ∂ x̃i
nates (lines 12 and 16). Several examples are presented in = (22)
∂xe ∂ x̃i ∂xe
Section 6. i∈Ne

where ∂ x˜i /∂xe is given by (21) and


4 Optimization problem formulation
∂c(x̃) ∂U(x̃)
= FT
Three representative topology optimization problems are ∂ x̃i ∂ x̃i
described in this section, namely: minimum compliance, ∂U(x̃)
= U(x̃)T K(x̃) . (23)
compliant mechanism synthesis, and heat conduction. ∂ x̃i
The derivative of (16) with respect to x̃i is
4.1 Minimum compliance
∂K(x̃) ∂U(x̃)
U(x̃) + K(x̃) = 0, (24)
The objective of the minimum compliance problem is to ∂ x̃i ∂ x̃i
find the material density distribution x̃ that minimizes the
which yields
structure’s deformation under the prescribed support and
loading condition. The structure’s compliance, which pro- ∂U(x̃) ∂K(x̃)
= −K(x̃)−1 U(x̃). (25)
vides a global measure of deformation, is defined as ∂ x̃i ∂ x̃i

c(x̃) = FT U(x̃), (17) Using (15),


n
where F is the vector of nodal forces and U(x̃) is the vector ∂K(x̃) ∂ p
= Emin + x̃i (E0 − Emin ) K0i
of nodal displacements. Incorporating a volume constraint, ∂ x̃i ∂ x̃i
i=1
the minimum compliance optimization problem is p−1
= px̃i (E0 − Emin ) K0i . (26)
find x = [x1 , x2 , . . . , xe , . . . , xn ]T Using (25) and (26), (23) results in
minimize c(x̃) = FT U(x̃) 
(18) ∂c(x̃)
= −U(x̃)T px̃i (E0 − Emin )K0i U(x̃).
p−1
T
subject to v(x̃) = x̃ v − v̄ 0 (27)
∂ x̃i
x ∈ ,  = {x ∈ n
:0 x 1},
Since K0i is the global version of an element matrix, (27)
where the physical densities x̃ = x̃(x̃) are defined by (3), may be transformed from the global level to the element
n is the number of elements used to discretize the design level, obtaining
domain, v = [v1 , . . . , vn]T is a vector of element volume, ∂c(x̃) 
p−1
and v̄ is the prescribed volume limit of the design domain. = −ui (x̃)T px̃i (E0 − Emin )k0i ui (x̃). (28)
∂ x̃i
The nodal force vector F is independent of the design vari-
ables and the nodal displacement vector U(x̃) is the solution where ui is the element vector of nodal displacements. Since
of K(x̃)U(x̃) = F. k0i is positive definite, ∂c(x̃)/∂ x̃i < 0.
An efficient 3D topology optimization code written in Matlab 1181

The numerical implementation of minimum compliance where udi (k0i ) is the part of the adjoint vector associated
problem can be done as the following: with element i. In this case, ∂c(k0i )/∂ x̃i may be positive or
negative.
The numerical implementation of the objective function
(31) and sensitivity (32) are

The objective function in (18) is calculated in Line 75.


The sensitivities of the objective function and volume frac-
tion constraint with respect to the physical density are given Vector Ud (Line 74a) is the dummy load displacement
be lines 76-77. Finally, the chain rule as stated in (22) is field and vector U (line 74b) is the input load displace-
deployed in lines 79-80. ment. The codes for the implementation of chain rule are
not shown above since they are same as lines 79-80.
4.2 Compliant mechanism synthesis
4.3 Heat conduction
A compliant mechanism is a morphing structure that under-
goes elastic deformation to transform force, displacement, Heat in physics is defined as energy transferred between
or energy (Bruns and Tortorelli 2001). A typical goal for a a system and its surrounding. The direct microscopic
compliant mechanism design is to maximize the output port exchange of kinetic energy of particles through the bound-
displacement. The optimization problem is ary between two systems is called diffusion or heat con-
find x̃ = [x1 , x2 , . . . , xe , . . . , xn ]T duction. When a body is at a different temperature from its
surrounding, heat flows so that the body and the surround-
minimize c(x̃) = −uout (x̃) = −LT U(x̃) ings reach the same temperature. This condition is known
  (29)
subject to v x̃ = x̃T v − v̄ 0 as thermal equilibrium. The equilibrium condition for heat
x ∈ ,  = {x ∈ n
:0 x 1}, transfer in finite element formulation is described by

where L is a unit length vector with zeros at all degrees K(k0i )U(k0i ) = F,
of freedom except at the output point where it is one, and
   −1 where U(k0i ) now donates the finite element global nodal
U x̃ = K x̃ F. temperature vector, F donates the global thermal load vec-
To obtain the sensitivity of the new cost function c(x̃) in tor, and K(k0i ) donates the global thermal conductivity
(29), let us define a global adjoint vector Ud (x̃) from the matrix. For a material with isotropic properties, conductivity
solution of the adjoint problem is the same in all directions.
The optimization problem for heat conduction is
K(x̃)Ud (x̃) = −L. (30)
find k0i = [x1 , x2, . . . , xe , . . . , xn ]T
Using (30) in (29), the objective function can be expressed
as minimize c(k0i ) = FT U(k0i )
  (33)
subject to v x̃ = x̃T v − v̄ 0
c(x̃) = Ud (x̃)T K(x̃)U(x̃). (31)
x ∈  ,  = {x ∈ n : 0 x 1},
The derivative of c(x̃) with respect to the design variable    −1
xe is again obtained by the chain rule, where U x̃ = K x̃ F, and K(x̃) is obtained by the
assembly of element thermal conductivity matrices ki (x̃i ).
∂c(x̃) ∂c(x̃) ∂ x̃i
= , Following the interpolation function in (6), the element
∂xe ∂ x̃i ∂xe conductivity matrix is expressed as
i∈Ne
p
where ∂ x̃i /∂xe is described by (21), and ∂c(x̃)/∂ x̃i can be ki (x̃i ) = kmin + (k0 − kmin )x̃i k0i , (34)
obtained using direct differentiation. The use of the interpo-
where kmin and k0 represent the limits of the material’s
lation given by (6) yields an expression similar to the one
thermal conductivity coefficient and k0i donates the ele-
obtained in (28),
ment conductivity matrix. Note that (34) may be considered
∂c(x̃) 
p−1 as the distribution of two material phases: a good thermal
= udi (x̃)T px̃i (E0 − Emin )k0i ui (x̃). (32)
∂ x̃i conduction (k0 ) and the other a poor conductor (kmin ).
1182 K. Liu and A. Tovar

The sensitivity analysis of the cost function in (33) is approximation of the minimum compliance problem in (18)
given by can be expressed as

find d
∂c(x̃) ∂c(x̃) ∂ x̃i
= , 1 T 2 (k) T
∂xe
i∈Ne
∂ x̃i ∂xe minimize d ∇ c d + ∇c(k) d (36)
2
subject to Ad = 0,
where ∂ x̃i /∂xe is described by (21) and
where c(k) is the value of the objective function evaluated at
 x(k) and d = x − x(k) , and A is the matrix of active con-
∂c(x̃) p−1
= −ui (x̃)T (k0 − kmin )px̃i k0i ui (x̃). (35) straints. The optimality and feasibility conditions of (36)
∂ x̃i
yield

The numerical implementation only requires an optional ∇ 2 c(k) d + AT λ = − ∇c(k)


change in the material property name: (37)
Ad = 0

This SQP approach, referred to as the active set algorithm


(Nocedal and Wright 2006), allows to determine a step d̃ (k)
from the solution of the of system of linear equations in (37)
expressed as
 2 (k) T   (k)   
∇ c A d −∇c(k)
where k0 and kmin are the limits of the material’s thermal = . (38)
A 0 λ(k) 0
conductivity. The chain rule is applied same as before.
The updated design is given by

5 Optimization algorithms x(k+1) = x(k) + α (k) d(k) , (39)

where the step size parameter α (k) is determined by a


Non-linear programming (NLP) problems, such as mini-
line search procedure. The Hessian ∇ 2 c(k) can be numeri-
mum compliance (18), compliant mechanism (29), and heat
cally approximated but, for the problems considered in this
conduction (33), can be addressed using sequential convex
paper, one can determined the closed-form expression (see
approximations such as sequential quadratic programming
Appendix B), which is given by
(SQP) (Wilson 1963) and the method of moving asymptotes
(MMA) (Svanberg 1987). The premise of these methods is ⎧

⎪ 0, i = j,
that, given a current design x(k) , the NLP algorithm is able ⎨ 2
∂ 2c p−1
to find a convex approximation of the original NLP prob- = 2 px̃i (E0 − Emin )
∂ x̃i ∂ x̃j ⎪
⎪ i = j.
lem from which an improved design x(k+1) can be derived. ⎩ p −1
Emin + x̃i (E0 − Emin ) uTi k0i ui ,
The nature of the problem’s approximation is determined
by the type of algorithm, e.g., quadratic programming (QP) (40)
or MMA. An special case of the latter approach, which is
This line-search, active-set SQP algorithm is summarized in
historically older than SQP and MMA, is the optimality
Algorithm 1.
criterion (OC) method. This method still find its place in
topology optimization due to its numerical simplicity and
numerical efficiency (Christensen and Klarbring 2009). The Algorithm 1 SQP Algorithm
following sections presents the implementation of the SQP,
MMA, and OC methods to the solution of the minimum Choose an initial feasible design x(0); set k ← 0;
compliance topology optimization problems presented in while (convergence criteria are not met) do
this paper. Evaluate c(k) , ∇c(k) (28), ∇ 2 c(k) (40);
Identify active constraint matrix A in (36);
5.1 Sequential quadratic programming Solve for d(k) (38);
Find appropriate step size α (k) ;
A QP problem has a quadratic objective function and linear Set x(k+1) ← x(k) + α (k) d(k) ;
constraints (Nocedal and Wright 2006). Given the current Set k ← k + 1
design x(k) and all corresponding active constraints, the QP end while
An efficient 3D topology optimization code written in Matlab 1183

The implementation of (40) in the program can be done where


in just two lines, since the term uTi + k0i + ui has already
(k)
been calculated, namely matrix ce in line 74: γi =
⎧   

⎪ 0.7 x
(k)
− x
(k−1)
x
(k−1)
− x
(k−2)
<0

⎨  i i  i i 
(k) (k−1) (k−1) (k−2)
(45)
1.2 xi − xi x − xi >0

⎪   i 

⎩ 1 x −x (k) (k−1) (k−1) (k−2)
i i xi − xi =0
Finally, M ATLAB has built-in constrained NLP solver
fmincon. The implementation of using fmincon as an
Note from (45) that the signs of three successive iterations
optimizer in our top3d program is quite easy, but need
are stored. If the signs are opposite, meaning xi oscillates,
some reconstructions of the program (one needs to divide (k)
the two asymptotes are brought closer to xi to have a more
program into different subfunctions, e.g., objective function,
conservative MMA approximation. On the other hand, if
constraint function, Hessian function). To further assist on
the signs are same, the two asymptotes are extended away
the implementation of an SQP strategy, the reader can find (k)
from xi in order to speed up the convergence. The MMA
a step-by-step tutorial on our website http://top3dapp.com.
algorithm is explained in Algorithm 2.
5.2 Method of moving asymptotes
Algorithm 2 MMA Algorithm
The MMA algorithm (Svanberg 1987) was proposed to
adjust the curvature of the convex linearization (CON- Choose an initial feasible design x(0); set k ← 0;
LIN) method introduced by Fleury (1989). Give the cur- while (convergence criteria are not met) do
rent design x(k) the MMA approximation of the minimum if k = 1 or k = 2 then
compliance problem in (18) yields to the following linear Update Lki , and Uik using (43);
programming problem: else
Update Lki , and Uik using (44) and (45);
find x end if
⎡  ⎤ Calculate derivate (28);
(k) (k) 2
n xi − Li   Solve the MMA subproblem (41) to obtain x̃(k+1) ;
⎢ ∂c ⎥
minimize − ⎣ (k)
x̃(k) ⎦ Set x(k−2) ← x(k−1) , x(k−1) ← x(k) , x(k) ← x(k+1) ;
i=1 xi − Li ∂xi (41)
Set k ← k + 1;
subject to x̃T v − v̄ 0 end while
x∈ (k)
,
The MMA algorithm is available for M ATLAB
where (mmasub). The reader may obtain a copy by contacting
 Prof. Krister Svanberg (http://www.math.kth.se/∼krille/
 (k) = x ∈  | 0.9Li + 0.1xi
(k) (k)
xi 0.9Ui
(k)
Welcome.html) from KTH in Stockholm Sweden. Although
(k) 
+0.1xi , i = 1, . . . , n . (42) mmasub has total of 29 input and output variables, its
implementation for top3d is straightforward. The details
(k) (k) can be found at http://top3dapp.com.
The lower and upper asymptotes Li and Ui are iter-
atively updated to mitigate oscillation or improve conver-
5.3 Optimality criteria
gence rate. The heuristic rule proposed by Svanberg (1987)
is as follows: For k = 1 and k = 2,
A classical approach to structural optimization problems
(k) (k) (k) is the Optimality Criteria (OC) method. The OC method
Ui + Li = 2xi , is historically older than sequential approximation methods
(k) (k)
(43)
Ui − Li = 1. such as Sequential Linear Programming (SLP) or SQP. The
OC method is formulated on the grounds that if constraint
For k  3, 0 x 1 is inactive, then convergence is achieved when
the KKT condition
(k) (k) (k)
Ui + Li = 2xi , ∂c(x̃) ∂v(x̃)
(k) (k) (k)
(44) +λ = 0, (46)
Ui − Li = γi , ∂xe ∂xe
1184 K. Liu and A. Tovar

is satisfied for k = 1, . . . , n, where λ is the Lagrange mul- Algorithm 3 OC Algorithm


tiplier associated with the constraint v(x̃). This optimality
Choose an initial design x(k) ; set k ← 0;
condition can be expressed as Be = 1, where
while (convergence criteria are not met) do
 
∂c(x̃) ∂v(x̃) −1 FE-analysis using (16) to obtain the corresponding
Be = − λ . (47) nodal displacement U(k) ;
∂xe ∂xe
Compute objective function, e.g., compliance c, out-
The code implements the OC updating scheme proposed put displacement uout ;
by (Bendsøe 1995) to update design variables: Sensitivity analysis by using the equations as dis-
⎧ cussed in Section 4;
η
⎨ max(0, xe − m), ifxe Be max(0, xe − m), Apply filter techniques, e.g. (3) in Section 2.3 or any
= min(1, xe + m), ifxe Be  min(1, xe − m),
η
xenew (48)
⎩ η other filters like those discussed in Section 6.1.4
x e Be , otherwise,
Update design variables using (48) to obtain x(k+1) ;
where m is a positive move-limit, and η is a numerical Set x(k+1) ← x(k) ; Set k ← k + 1;
damping coefficient. The choice of m = 0.2 and η = 0.5 is end while
recommended for minimum compliance problems (Bendsøe
1995; Sigmund 2001). For compliant mechanisms, η =
0.3 improves the convergence of the algorithm. The only code to minimum compliance problems, and its exten-
unknown in (48) is the value of the Lagrange multiplier λ, sion to compliant mechanism synthesis and heat
which satisfies that condition.

v(x̃(xnew (λ))) = 0. (49) 6.1 Minimum compliance


Numerically, λ is found by a root-finding algorithm such
By default, the code solves a minimum compliance problem
as the bisection method. Finally, the termination criteria are
for the cantilevered beam in Fig. 4. The prismatic design
satisfied when a maximum number of iterations is reached
domain is fully constrained in one end and a unit distributed
or
vertical load is applied downwards on the lower free edge.
||xnew − x||∞ , (50) Figure 4 shows the topology optimization results for solving
minimum compliance problem with the following M ATLAB
where the tolerance is a relatively small value, for example input lines:
= 0.01.
The numerical implementation begins with the initializa-
tion of design and physical variables,

where volfrac represents the volume fraction limit. Ini- y


z x
tially, the physical densities are assigned a constant uniform
value, which is iteratively updated following the OC updat-
ing scheme (Algorithm 3).

6 Numerical examples

The code is executed M ATLAB with the following com-


mand:

where nelx, nely, and nelz are number of elements


along x, y, and z directions, volfrac is the volume
fraction limit (v̄), penal is the penalization power (p),
and rmin is filter size (R). User-defined variables are
set between lines 3 and 18. These variables determine the
material model, termination criteria, loads, and supports. Fig. 4 Topology optimization of 3D cantilever beam. Top Initial
The following examples demonstrate the application of the design domain, bottom topology optimized beam
An efficient 3D topology optimization code written in Matlab 1185

y
z x
Secondly, defining the corresponding boundary condi-
tions

then the problem can be promoted by line:

6.1.2 Multiple load cases

In order to solve a multiple load cases problem, as shown


in Fig. 6, a few changes need to be made. First, the loading
Fig. 5 Topology optimization of 3D wheel. Top Initial design domain, conditions (line 12) are changed correspondingly:
bottom topology optimized result

6.1.1 Boundary conditions Also the force vector (line 22) and displacement vector
(line 23) become more than one column:
The boundary conditions and loading conditions are defined
in lines 12-18. Since the node coordinates and node numbers
The objective function is now the sum of different load
are automatically mapped by the program, defining different
cases
boundary conditions is very simple. To solve a 3D wheel
M M
problem as shown in Fig. 5, which is constrained by planar  
joint on the corners with a downward point load in the center c(x̃) = cl (x̃) = FTl Ul x̃ (51)
l=1 l=1
of the bottom, the following changes need to be made:
Firstly, changing loading conditions where M is the number of load cases.

2
y
z x

1
Fig. 6 Topology optimization of cantilever beam with multiple load cases. Left Initial design domain, middle topology optimized beam with one
load case, and right topology optimized beam with two load cases
1186 K. Liu and A. Tovar

Then lines 74–76 are substituted with lines

y
z x

This example is promoted by the line

6.1.3 Active and passive elements

In some designs, some elements may be desired to be solid


or void. A nely × nelx × nelz matrix with ones at ele-
ments desired to be solid, and a nely × nelx × nelz
matrix with zeros at elements desired to be void can be
added to the program. To solve the problem as shown in Fig. 7 Topology optimization of cantilever beam with passive design
domain. Top Initial design domain, bottom topology optimized beam
Fig. 7, the passive elements need to be defined first by
adding the following lines after line 62:
filters (Sigmund 2007), filtering technique using M ATLAB
built-in function conv2 (Andreassen et al. 2011), filtering
based on Helmholtz type differential equations (Andreassen
et al. 2011), Heaviside filter (Guest et al. 2004, 2011), and
gray scale filter (Groenwold and Etman 2009). All the filters
pursue a simple goal to achieve black-and-white structures.
Two of them are chosen, which stand for classic and better
performance, as well as easy implementation.

Sensitivity filter Sigmund (1994, 1997) introduced the sen-


sitivity filter. The working principle is to replace the real
In addition, one line is added in the OC subroutine under sensitivities by the filtered sensitivities. In addition, the sen-
line 85: sitivity filter is implemented in the 99-line code as the
default filtering scheme. It modifies the element sensitivity
during every iteration by the following
The optimized beam shown in Fig. 7 is promoted by the 
∂c(x) 1 ∂c(x)
line =  Hij xj .
∂xi max(γ , xi ) j ∈Ni Hij ∂xj
j ∈Ni

where γ (= 10−3 ) is a small number in order to avoid


division by zero.
6.1.4 Alternative filters
The implementation of the sensitivity filter can be
achieved by adding and changing a few lines.
In the topology optimization, filters are introduced to avoid
Change line 2 by adding one input variable ft (ft = 1
numerical instabilities. Different filtering techniques may
for density filter, ft = 2 for sensitivity filter)
result different discreteness of the final solutions, and some-
times may even contribute to different topologies. In addi-
tion to density filter, in the literatures there are bunch of
different filtering schemes. For example, sensitivity filter Adding the sensitivity filter to the program, by changing
(Sigmund 1994, 1997), morphology based black and white lines 79-80
An efficient 3D topology optimization code written in Matlab 1187

Table 3 Time usage of finite element analysis time for different


solvers

Mesh size Direct solver Iterative solver

30 × 10 × 2 0.018 sec 0.129 sec


60 × 20 × 4 0.325 sec 0.751 sec
Changing the design variable update strategy (line 86) in 150 × 50 × 10 74.474 sec 22.445 sec
the optimal search procedure

Figure 8 demonstrates the optimized beams applying dif-


ferent filtering techniques. As can be seen from final results,
both sensitivity filter, density filter and gray scale filter sup-
press checkerboard patterns. The gray scale filter combines
with the sensitivity filter provides the most black-and-white
Gray scale filter A simple non-linear gray-scale filter or solution.
intermediate density filter has been proposed by Groen-
wold and Etman (2009) to further achieve black-and-white 6.1.5 Iterative solver
topologies. The implementation of the gray scale filter is by
changing the OC update scheme as the following If the finite element mesh size becomes large, the tra-
ditional direct solver (line 72) used to address the finite
⎧ η element analysis is suffered by longer solving time and
⎨ max(0, xi − m), ifxi Bi max(0, xi − m)
= min(1, xi + m), ifxi Bi  min(1, xi − m)
η some other issues. However, iterative solver (Hestenes and
xinew
⎩ η Stiefel 1952; Augarde et al. 2006) can solve large-scale
(xi Bi )q , otherwise problems efficiently. To this end, line 72 is replaced by
(52) a built-in M ATLAB function pcg, called preconditioned
conjugate gradients method, as shown in the following
The standard OC updating method is a special case of
(52) with q = 1. A typical value of q for the SIMP-based
topology optimization is q = 2.
The implementation of the gray scale filter to the code
can be done as follows:
Adding one input variable q to the program (line 2)

Direct solver is a special case by setting the precondi-


tioner (line 72c) to
Change the OC updating method (line 85) to Table 3 gives the comparison of two different finite ele-
ment analysis solvers. As shown in the table, a speed up
factor of 30.81 has been measured when solving large scale
The factor q should be increased gradually by adding one problem. Hence, the iterative solver is more suitable for
line after line 68 large-scale problems, and vice versa.
Some examples include a cantilever beam, the
Messerchimitt-Bölkow-Blohm (MBB) beam and L-shape
problems (Table 4) are solved by using iterative solver

Fig. 8 Topology optimized design used a mesh with 30 × 10 × 2 ele- filter and gray scale filter, and right optimized design using sensitivity
ments. Left optimized design using density filter, middle left optimized filter and gray scale filter
design using density filter, middle right optimized design using density
1188 K. Liu and A. Tovar

Table 4 Three-dimensional
examples: Cantilever, MBB,
and L-shape problem. Left:
Initial design domains, right:
topology optimized results

and applying gray scale filter. The underlined triangle perform a continuation step. As previously presented by
represents a three-dimensional planar joint. Groenwold and Etman (2010), the continuation step is given
as

6.1.6 Continuation strategy 1 k 20,
pk = (53)
min{pmax , 1.02pk−1 } k > 20,
Convexity is a very preferable property since every local
where k is the iteration number, and pmax is the maximum
minima is also the global minima, and what the pro-
penalization power.
gram is solving for is the global minima. Unfortunately,
Though this methodology is not proven to converge to
the use of SIMP method to achieve binary solution will
the global optimum, it regularizes the algorithm and allows
destroy the convexity of the optimization problem. For such
the comparison of different optimization strategies.
problems, it is possible that for different starting points
Implementing the continuation strategy is done by adding
the program converges to totally different local minima.
a single line after line 68:
In order to penalize intermediate densities and mitigate
the premature convergence to one of the multiple local
minima when solving the non-convex problem, one could
An efficient 3D topology optimization code written in Matlab 1189

6.2 Compliant mechanism synthesis Out


Top face
A compliant mechanism problem involves loading cases: constrained
for symmetric
input loading case and dummy loading case. The code
also needs to implement a new objective function and
its corresponding sensitivity analysis. To demonstrate this
implementation, let us consider a three-dimensional force
inverter problem as shown in Fig. 9. With an input load In
defined in the positive direction, the design goal is to max-
imize the negative horizontal output displacement. Both Side face
the top face and the side force are imposed with sym- constrained y
for symmetric z
metric constraints; i.e., nodes can only move within the x
plane.
Fig. 9 Design domain of 3D force inverter problem
The new loading conditions as well as input and output
points are defined as follows:

The convergence criteria for the bi-sectioning algorithm


(lines 82-83) is improved by the following lines:

and the boundary conditions are defined as below:


To improve the convergence stability, the damping factor
of OC-method changes from 0.5 to 0.3 and also takes the
positive sensitivities into account, then line 85 is changed to:

The final design shown in Fig. 10 is promoted by the line


in the M ATLAB:

6.3 Heat conduction

The implementation of heat conduction problems is not


more complex than the one for compliant mechanism syn-
thesis since the number of DOF per node is one rather

The external springs with stiffness 0.1 are added at input


and output points after line 71.

The expressions of the objective function (31) and sensi-


tivity (32) are modified in lines 74-76. Fig. 10 Topology optimized force inverter
1190 K. Liu and A. Tovar

than three. Following the implementation of heat conduc-


tion problems in two dimensions (Bendsøe and Sigmund
2003), the implementation for three dimension problems is
suggested in the following steps.
First, the elastic material properties (lines 8-10) are
changed to the thermal conductivities of materials

Furthermore, the boundary conditions for the heat condi-


tion problem, i.e., a rectangular plate with a heat sink on the
middle of top face and all nodes are given a thermal load as
shown in Fig. 11, are changed corresponding (lines 10-18). Fig. 12 Resulting topology of heat conduction problem

Also, since there is only one DOF per node in heat The finite element connectivity matrix edofMat is
condition problems, some variables need to change corre- changed in lines 30–35
spondingly, such as ndof, edofMat.
Change the total number of DOFs and the force vector in
lines 21–22

The element conductivity matrix is called in line 25 by

The global conductivity matrix is assembled in a different


and it is defined in lines 99–145
way, hence line 70 need to change as

The evulation of the objective function and analysis of


the sensitivity are given in lines 75–76

Sink

The optimized topology is derived as shown in Fig. 12 by


promoting the following line in the M ATLAB:

y
z x
7 Conclusions

This paper presents M ATLAB the analytical elements


and the numerical implementation of an academic three-
dimensional structural topology optimization algorithm
referred to as top3d. In this topology optimization algo-
Fig. 11 Initial design domain of heat conduction problem rithm, the problem formulation follows a density-based
An efficient 3D topology optimization code written in Matlab 1191

approach with a modified SIMP interpolation for physi- for e = 1, . . . , 3 and q = 1, . . . , 8. The corresponding
cal densities. The finite element formulation makes use shape functions nq in a natural coordinate systems ξe are
of eight-node hexahedral elements for which a closed- defined by
form expression of the element stiffness matrix is derived ⎧ ⎫

⎪ (1 − ξ1 )(1 − ξ2 )(1 − ξ3 )⎪ ⎪
and numerically implemented. The hexahedral finite ele- ⎪
⎪ ⎪


⎪ (1 + ξ )(1 − ξ )(1 − ξ3 ⎪
)⎪
ments are used to uniformly discretize a prismatic design ⎪
⎪ 1 2 ⎪


⎪ ⎪

domain and solve three related topology optimization ⎪
⎪ (1 + ξ )(1 + ξ )(1 − ξ )⎪



1 2 3


problems: minimum compliance, compliant mechanism, ⎨
1 (1 − ξ1 )(1 + ξ2 )(1 − ξ3 )⎬
and heat conduction problems. For each problem, this nq (ξe ) = .
8⎪
⎪ (1 − ξ1 )(1 − ξ2 )(1 + ξ3 )⎪ ⎪
paper includes the analytical derivation of the sensitiv- ⎪
⎪ ⎪


⎪ (1 + ξ1 )(1 − ξ2 )(1 + ξ3 )⎪ ⎪
ity coefficients used by three gradient-based optimiza- ⎪
⎪ ⎪


⎪ ⎪

tion algorithms: SQP, MMA, and OC, which is imple- ⎪
⎪ (1 + ξ )(1 + ξ )(1 + ξ3 ⎪
)⎪


1 2 ⎪

mented by default. For the implementation of SQP, this ⎩ ⎭
(1 − ξ1 )(1 + ξ2 )(1 + ξ3 )
paper derives an analytic expression for the second order
derivative. Substituting values to (11), the 24 × 24 element stiffness
The use of top3d is demonstrated through several matrix k0i for an eight-node hexahedral element can be
numerical examples. These examples include problems with expressed as ⎡ ⎤
k1 k2 k3 k4
a variety of boundary conditions, multiple load cases, active 1 ⎢ kT k5 k6 kT ⎥
and passive elements, filters, and continuation strategies k0i = ⎢ 2 4 ⎥,
(ν + 1)(1 − 2ν) ⎣ kT3 k6 kT5 kT2 ⎦
to mitigate convergence to a local minimum. The archi-
k4 k3 k2 kT1
tecture of the code allows the user to map node coor-
dinates of node degrees-of-freedom boundary conditions. where
In addition, the paper provides a strategy to handle large ⎡ ⎤
k1 k2 k2 k3 k5 k5
models with the use of an iterative solver. For large- ⎢ k2 k1 k2 k4 k6 k7 ⎥
⎢ ⎥
scale finite-element models, the iterative solver is about ⎢ k2 k2 k1 k4 k7 k6 ⎥
k1 =⎢
⎢ k3
⎥,
30 times faster than the traditional direct solver. While
⎢ k4 k4 k1 k8 k8 ⎥

this implementation is limited to linear topology opti- ⎣ k5 k6 k7 k8 k1 k2 ⎦
mization problems with a linear constraint, it provides a k5 k7 k6 k8 k2 k1
clear perspective of the analytical and numerical effort ⎡ ⎤
k9 k8 k12 k6 k4 k7
involved in addressing three-dimensional structural topol-
⎢ k8 k9 k12 k5 k3 k5 ⎥
ogy optimization problems. Finally, additional academic ⎢ ⎥
⎢ k10 k10 k13 k7 k4 k6 ⎥
resources such the use of MMA and SQP are available at k2 =⎢
⎢ k6
⎥,
⎢ k5 k11 k9 k2 k10 ⎥

http://top3dapp.com. ⎣ k4 k3 k5 k2 k9 k12 ⎦
k11 k4 k6 k12 k10 k13
⎡ ⎤
Appendix A: Symbolic expression of k0 k6 k7 k4 k9 k12 k8
⎢ k7 k6 k4 k10 k13 k10 ⎥
⎢ ⎥
This appendix presents the analytical results of the element ⎢ k5 k5 k3 k8 k12 k9 ⎥
k3 =⎢
⎢ k9
⎥,
stiffness matrix k0 as discussed in Section 3. This sym- ⎢ k10 k2 k6 k11 k5 ⎥⎥
bolic expression of k0 is also been used by the program ⎣ k12 k13 k10 k11 k6 k4 ⎦
subroutine lk H8. k k12 k9 k4 k5 k3
⎡ 2 ⎤
Recall that, for an eight-node hexahedral element, the k14 k11 k11 k13 k10 k10
strain-displacement matrix B is defined by ⎢ k11 k14 k11 k12 k9 k8 ⎥
⎢ ⎥
⎡ ⎤ ⎢ k11 k11 k14 k12 k8 k9 ⎥
∂nq (ξe ) k4 =⎢
⎢ k13
⎥,
k14 k7 k7 ⎥
∂n1 (ξe )
0 0 · · · 0 0 k12 k12
⎢ ∂ξ 1 ∂ξ 1 ⎥ ⎢ ⎥
⎢ ∂nq (ξe ) ⎥ ⎣ k10 k9 k8 k7 k14 k11 ⎦
⎢0 ∂n1 (ξe )
0 · · · 0 ⎥
⎢ ∂ξ2 ∂ξ2 ⎥ k k8 k9 k7 k11 k14
⎢ ∂nq (ξe ) ⎥ ⎡ 10 ⎤
⎢0 0 ∂n1 (ξe )
· · · 0 0 ⎥ k1 k2 k8 k3 k5 k4
⎢ ∂ξ3 ∂ξ3 ⎥
B=⎢ ⎥, ⎢ k2 k1 k8 k4 k6 k11 ⎥
⎢ ∂n1 (ξe ) ∂n1 (ξe ) 0 ∂nq (ξe ) ∂nq (ξe )
· · · ∂ξ ⎥ ⎢ ⎥
⎢ ∂ξ2 ∂ξ1 ∂ξ1 0 ⎥ ⎢ k8 k8 k1 k5 k11 k6 ⎥
⎢ 2
⎥ k5 =⎢ ⎥,
⎢ ∂n1 (ξe ) ∂n1 (ξe ) ∂nq (ξe ) ∂nq (ξe ) ⎥ ⎢ k3 k1 k8 k2 ⎥
⎢0 · · · 0 ∂ξ2 ⎥ ⎢ k4 k5 ⎥
⎣ ∂ξ3 ∂ξ2 ∂ξ3
⎦ ⎣ k5 k6 k11 k8 k1 k8 ⎦
∂n1 (ξe ) ∂n1 (ξe ) ∂nq (ξe ) ∂nq (ξe )
∂ξ3 0 ∂ξ1 · · · ∂ξ3 0 ∂ξ1 k4 k11 k6 k2 k8 k1
1192 K. Liu and A. Tovar

 
⎡ ⎤ ∂ 2c ∂ ∂ki
k14 k11 k7 k13 k10 k12 = −ui T ui
∂ x̃i ∂ x̃j ∂ x̃j ∂ x̃i
⎢ k11 k14 k7 k12 k9 k2 ⎥    
⎢ ⎥ ∂ui T ∂ki ∂ki
⎢ k7 k7 k14 k10 k2 k9 ⎥
=− ui − ui T ui
k6 = ⎢ ⎥, ∂ x̃j ∂ x̃i ∂ x̃i ∂ x̃j
 
⎢ k13 k12 k10 k14 k7 k11 ⎥ ∂ki ∂ui
⎢ ⎥ − ui T (B2)
⎣ k10 k9 k2 k7 k14 k7 ⎦ ∂ x̃i ∂ x̃j

k12 k2 k9 k11 k7 k14 From (B1), the middle term of (B2) goes to zero. In order
to get the expression for ∂ui /∂ x̃j in the first and third terms,
and
let us rewriting (16) as
k1 = −(6ν − 4)/9, ki ui = fi .
k2 = 1/12,
Now if we differentiate both sides with respect to x̃j , we
k3 = −1/9, get
k4 = −(4ν − 1)/12, ∂ki ∂ui
ui + ki = 0,
∂ x̃j ∂ x̃j
k5 = (4ν − 1)/12,
which yields
k6 = 1/18,  
∂ui ∂ki
k7 = 1/24, = −k−1
i ui . (B3)
∂ x̃j ∂ x̃j

k8 = −1/12,
k9 = (6ν − 5)/36, Substitute (B3) into (B1), we have
k10 = −(4ν − 1)/24,
   T    
k11 = −1/24, ∂2c ∂ki ∂ki ∂ki ∂ki
= − −k−1 i ui ui − uTi −k−1
i ui ,
∂ x̃i ∂ x̃j ∂ x̃j ∂ x̃i ∂ x̃i ∂ x̃j
k12 = (4ν − 1)/24, 
∂ki
 
∂ki

= 2uTi k−1 ui ,
k13 = (3ν − 1)/18, ∂ x̃j i
∂ x̃i
k14 = (3ν − 2)/18.
where the last equality holds since
As can be seen from above, the 64 × 64 entries in the
   
element stiffness matrix can be represented by fourteen uTi
∂ki
k−1
∂ki
ui
i
components (but not independent!). ∂ x̃j ∂ x̃i
      !T
∂ki ∂ki
= uTi k−1
i ui
∂ x̃j ∂ x̃i
  T    T
Appendix B: Derivation of the Hessian Matrix =
∂ki
ui uTi
∂ki
k−1
i
∂ x̃i ∂ x̃j
   
In this appendix, we will discuss the derivation of the second ∂k ∂k
k−1
i i
= uTi i ui . (B4)
∂ x̃i ∂ x̃j
order derivative of the objective function. Structure compli-
ance will be used as the objective function, the expression
for other objective functions can be derived similarly. As discussed earlier, when i = j , ∂ki /∂ x̃j = 0. When i = j,
Recall that the first order derivative of the compliance is subsituting (B1), (10) and (6) into (B4), we have
given by
∂2c 
p−1
  ∂ x̃2i
= 2 uTi p x̃i (E0 − Emin )k0i [Emin +
∂c ∂ki
= −ui T ui , p
−1
p−1

∂ x̃i ∂ x̃i x̃i (E0 − Emin )k0i p x̃i (E0 − Emin )k0i ui
2
p−1 p −1
where by applying the modified SIMP method (6), we have = 2 p x̃i (E0 − Emin ) Emin + x̃i (E0 − Emin )

uTi k0i ui .
∂ki p−1
= px̃i (E0 − Emin )k0i . (B1) Therefore, the Hessian of the structural compliance is
∂ x̃i
given by:

Note that for brevity of notation, we omitted the depen- ⎪
⎨0,
∂ 2c i  = j,
dence on x̃ in this appendix. =  −1
∂ x̃i ∂ x̃j ⎪
⎩2 p x̃p−1 (E − E ) 2 E p 0
min + x̃i (E0 − Emin ) uT
i ki ui , i = j.
A second differentiation of the compliance yields i 0 min
An efficient 3D topology optimization code written in Matlab 1193

Appendix C: MATLAB Program top3d


1194 K. Liu and A. Tovar
An efficient 3D topology optimization code written in Matlab 1195

References Allaire G, Jouve F, Toader AM (2004) Structural optimization using


sensitivity analysis and a level-set method. J Comput Phys
194(1):363–393
Aage N, Nobel-Jørgensen M, Andreasen CS, Sigmund O (2013) Andreassen E, Clausen A, Schevenels M, Lazarov BS, Sigmund O
Interactive topology optimization on hand-held devices. Struct (2011) Efficient topology optimization in matlab using 88 lines of
Multidiscip Optim 47(1):1–6 code. Struct Multidiscip Optim 43(1):1–16
Allaire G (2001) Shape optimization by the homogenization method. Augarde C, Ramage A, Staudacher J (2006) An element-based dis-
Springer, New York placement preconditioner for linear elasticity problems. Comput
Allaire G, Kohn R (1993) Optimal design for minimum weight and Struct 84(31–32):2306–2315
compliance in plane-stress using extremal microstructures. Eur J Bendsøe MP (1989) Optimal shape design as a material distribution
Mech 12(6):839–878 problem. Struct Multidiscip Optim 1(4):193–202
Allaire G, Pantz O (2006) Structural optimization with freefem++. Bendsøe MP (1995) Optimization of structural topology shape and
Struct Multidiscip Optim 32(3):173–181 material. Springer, New York
Allaire G, Belhachmi Z, Jouve F (1996) The homogenization method Bendsøe MP, Kikuchi N (1988) Generating optimal topologies in
for topology and shape optimization. single and multiple loads structural design using a homogenization method. Comput Meth-
case. Eur J Finite Elem 5:649–672 ods Appl Mech Eng 71(2):197–224
1196 K. Liu and A. Tovar

Bendsøe MP, Sigmund O (2003) Topology optimization: theory, Liu Z, Korvink JG, Huang I (2005) Structure topology optimization:
method and applications. Springer fully coupled level set method via FEMLAB. Struct Multidiscipl
Bruns TE, Tortorelli DA (2001) Topology optimization of non-linear Optim 6(29):407–417
elastic structures and compliant mechanisms. Comput Methods Mlejnek H (1992) Some aspects of the genesis of structures. Struct
Appl Mech Eng 190(26–27):3443–3459 Optim 5(1–2):64–69
Challis VJ (2010) A discrete level-set topology optimization code Nocedal J, Wright S (2006) Numerical optimization, 2nd edn. Springer
written in matlab. Struct Multidiscip Optim 41(3):453–464 Schmit LA (1960) Structural design by systematic synthesis. In: 2nd
Christensen PW, Klarbring A (2009) An introduction to structural ASCE conference of electrical compounds. Pittsburgh, pp 139–
optimization. Springer 149
Duysinx P (1997) Layout optimization: A mathematical program- Sigmund O (1994) Design of material structures using topology
ming approach, DCAMM report. Technical report, Danish Center optimization, PhD thesis, Technical University of Denmark
of Applied Mathematics and Mechanics, Technical University of Sigmund O (1997) On the design of compliant mechanisms using
Denmark, DK-2800 Lyngby topology optimization. Mech Struct Mach 25(4):495–526
Fleury C (1989) CONLIN: an efficient dual optimizer based on convex Sigmund O (2001) A 99 line topology optimization code written in
approximation concepts. Struct Optim 1(2):81–89 matlab. Struct Multidiscip Optim 21(2):120–127
Groenwold AA, Etman LFP (2009) A simple heuristic for gray-scale Sigmund O (2007) Morphology-based black and white filters for
suppression in optimality criterion-based topology optimization. topology optimization. Struct Multidiscip Optim 33:401–424
Struct Multidiscip Optim 39(2):217–225 Sigmund O, Peterson J (1998) Numerical instabilities in topology
Groenwold AA, Etman LFP (2010) A quadratic approximation for optimization: a survey on procedures dealing with checkerboards,
structural topology optimization. Int J Numer Methods Eng mesh-dependencies and local minima. Struct Optim 16:68–75
82(4):505–524 Sokół T (2011) A 99 line code for discretized michell truss optimiza-
Guest JK, Prevost JH, Belytschko T (2004) Achieving minimum tion written in mathematica. Struct Multidiscip Optim 43(2):181–
length scale in topology optimization using nodal design vari- 190
ables and projection functions. Int J Numer Methods Eng 61:238– Suresh K (2010) A 199-line matlab code for pareto-optimal tracing in
254 topology optimization. Struct Multidiscip Optim 42:665–679
Guest JK, Asadpoure A, Ha SH (2011) Elimiating beta-continuation Svanberg K (1987) The method of moving asymptotes-a new method
from heaviside projection and density filter algorithms. Struct for structural optimzation. Int J Numer Methods Eng 24:359–
Multidiscip Optim 44:443–453 373
Haber R, Jog C (1996) A new approach to variable-topology shape
design using a constraint on perimeter. Struct Optim 11(1):1–12 Talischi C, Paulino GH, Pereira A, Menezes IFM (2012a) Polymesher:
Hassani B, Hinton E (1998) Homogenization and structural topology a general-purpose mesh generator for polygonal elements written
optimization: theory, practice and software. Springer in matlab. Struct Multidiscip Optim 45:309–328
Hestenes MR, Stiefel E (1952) Methods of conjugate gradients for Talischi C, Paulino GH, Pereira A, Menezes IFM (2012b) Polytop: a
solving linear systems. J Res Natl Bur Stand 49(6) matlab implementation of a general topology optimization frame-
Hunter W (2009) Predominantly solid-void three-dimensional topol- work using unstructured polygonal finite element meshes. Struct
ogy optimisation using open source software. Master’s thesis, Multidiscip Optim 45:329–357
University of Stellenbosch Wang MY, Chen S, Xia Q (2004) Structural topology optimization
Jog C (2002) Topology design of structures using a dual algorithm with the level set method. http://www2.acae.cuhk.edu.hk/cmdl/
and a constraint on the perimeter. Int J Numer Methods Eng download.htm
54(7):1007–1019 Wilson RB (1963) A simplicial method for convex programming, PhD
Kohn R, Strang G (1986a) Optimal design and relaxation of variational thesis, Harvard University
problems (part I). Commun Pure Applied Math 39(1):113–137 Zhou M, Rozvany G (1991) The COC algorithm, part II: topological,
Kohn R, Strang G (1986b) Optimal design and relaxation of variational geometrical and generalized shape optimization. Comp Meth Appl
problems (part II). Commun Pure Appl Math 39(2):139–182 Mech Eng 89:309–336
Kohn R, Strang G (1986c) Optimal design and relaxation of variational Zhou S, Wang MY (2005) 3d structural topology optimization with the
problems (part III). Commun Pure Appl Math 39(3):353–377 simp method. http://www2.acae.cuhk.edu.hk/cmdl/download.htm

You might also like