You are on page 1of 8

Educational article Struct Multidisc Optim 21, 120–127  Springer-Verlag 2001

A 99 line topology optimization code written in Matlab
O. Sigmund

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 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 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: problem as an integer problem. Beckers (1999) success-

xe − m) . Baumgartner et al.     lowed by a discussion of extensions (Sect.     proaches have been shown to decrease compliance or : KU = F     other objective functions. Xie and : 0 < xmin ≤ x ≤ 1 Steven 1997. 1999). we will here ematically based” approaches for compliance minimiza- use a standard OC-method.g. as shown in this paper.   The complete Matlab code is given in the Appendix. 1999) and to avoid singularity). 121 fully solved large-scale compliance minimization prob. Two The optimization problem (1) could be solved using things can be argued against this. 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. p is the ity” (citation from Zhao et al. 5).1 a bi-sectioning algorithm. N (= nelx × nely) is the number they contain “mathematical methods of some complex- of elements used to discretize the design domain. Sigmund 1999). the “math- Svanberg 1987) and others. Among these methods are so. xe + m) sion (Sect. For simplicity. respectively.  if min(1. Sequential Linear Programming (SLP) complex objectives than compliance minimization are methods or the Method of Moving Asymptotes (MMA by considered and second. min T : c(x) = U KU = (xe ) ue k0 ue  p T   x   Apart from above mentioned approaches. First. xe − m)   tionary approach to such cases seem more questionable.g. the evolutionary several different approaches such as Optimality Criteria approaches become complicated themselves. 2). η ments about the Matlab implementation (Sect. (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). tion are simple to implement as well and are compu- Following Bendsøe (1995) a heuristic updating scheme tationally equally efficient. x is the vector of design variables. η (= 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. which all e=1   solve well defined problems (e. 1998) whereas the evo- penalization power (typically p = 3). “involve some complex calculus operations and mathe- xmin is a vector of minimum relative densities (non-zero matical programming” (citation from Li et al. 3) fol.  called evolutionary design methods (see e. (2) 2 where m (move) is a positive move-limit. where λ is a Lagrangian multiplier that can be found by tion (nely). Furthermore. K is the global stiffness matrix. 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. the numbering of elements and nodes is simple Be = . once more (OC) methods. Apart from be.g. xe − m) < xe Be < min(1. processes in nature” (citation from Li et al. 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 . A topology optimization problem based on the power- lems using a dual-approach but other approaches based law approach. V (x) and V0 is the lutionary approach “takes advantage of powerful com- material volume and design domain volume. V (x)  subject to : V0 = f .   if xe Beη ≤ max(xmin .   The remainder of the paper consists of definition and  x B η e e discussion of the optimization problem (Sect. pliance) a number of heuristic or intuition based ap. respectively. First. minimization of com. In ∂xe this way. (4) Appendix) ∂xe . 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. (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. xe + m) . Extensions of the evolu- max(xmin . respectively puting technology and intuitive concepts of evolution and f (volfrac) is the prescribed volume fraction. the design domain is assumed to be ∂c − rectangular and discretized by square finite elements. 1992). com-   if max(xmin . the main moti- vectors. 4) and a conclu. xe + m) ≤ xe Beη .    min(1.

H (5) 111 000 ∂xe  N f =1 ∂xf 111 000 000 111 xe ˆf H Fig. respectively. variables as well as boundary conditions are defined in The current compliance as well as other parameters are the Matlab code itself and can be edited if needed. Main program (lines 1–36) The main program (lines 1–36) starts by distributing the 3 material evenly in the design domain (line 4). 000 111 000 111 tering technique (Sigmund 1994. the elem- called from the Matlab prompt by the line ent stiffness matrix subroutine is called only once (line 14). f ) ≤ rmin }. penal is the penalization power sis is followed by a call to the mesh-independency filter and rmin is the filter size (divided by element size). Here we use a fil. convolution operator H ˆ f is zero outside the filter area. but numerous applications by the author have proven the the filter produces mesh- 0 1 0 1 0 1 0 1 ? independent designs in practice.5.1 ity Criteria update (3). N . . for an overview). Since the element stiffness matrix dard topology optimization code.5) be decreased if needed . is built up as a stan. the modified sensitivities (5) are used in the Optimal. 0 1 The mesh-independency filter works by modifying the 0 1 111 000 element sensitivities as follows: ∂c 1  N = ˆ f xf ∂c . the following subsections. if the change in design variables (change determined in Figure 1 shows the resulting density distribution obtained line 30) is less than 1 percent2 . 3. Top: full f =1 design domain. 1997).nely. middle: half design domain with symmetry boundary conditions and bottom: resulting topology opti- ˆ f is written as The convolution operator (weight factor) H mized beam (both halves) ˆ f = rmin − dist(e. 0 1 0 1 sure existence of solutions. The sensitivity analy- is the volume fraction. (6) “MBB-beam” (Fig. some sort of restriction ? on the resulting design must be introduced (see Sigmund 111 000 111 000 and Petersson 1998. The main loop is terminated generates a picture of the current density distribution. Otherwise above steps are by the code given in the Appendix called with the input repeated. .0. volfrac the global displacement vector U. f ) is defined as the distance be. Important details of the Matlab code are discussed in The convolution operator decays linearly with the dis. f ) . For printed by lines 30–33 and the resulting density distri- each iteration in the topology optimization loop. the main loop starts with a call to the Finite Element subroutine (line 12) which returns the The Matlab code (see the Appendix). Other (line 26) and the Optimality Criteria optimizer (line 28).20.penal. . 1 0 0 1 phasized that this filter has not yet been proven to en. In order to ensure existence of solutions to the top- ology optimization problem (1). Following this.1. The main program is for solid material is the same for all elements. conditions along the left edge and the structure is sup- tween centre of element e and centre of element f . displacement vector U. the reader is referred to the literature (e. e = 1.0. . The ported horizontally in the lower right corner.rmin) The variables n1 and n2 denote upper left and right element node numbers in global node numbers and are where nelx and nely are the number of elements in the used to extract the element displacement vector Ue from horizontal and vertical directions. Instead of the original sensitivities (4). the code bution is plotted (line 35).volfrac. 1 Topology optimization of the MBB-beam. H The default boundary conditions correspond to half of the {f ∈ N | dist(e. a loop over all elements (lines 16– 24) determines objective function and sensitivities (4).3. line 2 this is a rather “sloppy” convergence criterion and could top(60. tance from element f . After some Matlab implementation other initializations. Bendsøe 1995). 1).122 For more details on the derivation and implementation of the optimality criteria method. The load is applied vertically in the upper left corner and there is symmetric boundary where the operator dist(e. top(nelx.g. It must be em.

20.freedofs) \ F(freedofs. less than the convergence criteria (line 40). 2 Topology optimization of a cantilever beam. Finite element code (lines 65–99) The finite element code is written in lines 65–99.4 following. it is easier to define the de. variables n1 and n2 denote upper left and right port conditions in order to solve other optimization prob- element node numbers in global node numbers and are lems. the difference between all degrees of freedom and the fixed grangian multiplier is repeatedly halved until its size is degrees of freedom (line 82). Note 4. the value of the Fig.1)=-1.1) = -1. Matlab can do this very elegantly with the line top(32. 80 fixeddofs = [1:2*(nely+1)]. The global stiffness matrix is formed by a loop over all elements (lines 70–77). Furthermore. numbered column wise from left to right. . The element stiffness matrix is calculated in lines 86– 99.3.0. each node has two degrees of freedom (horizontal and ver- tical). 1) such that its compliance is minimized.1 that the solver makes use of the sparse option in Mat. 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.2 Multiple load cases where freedofs indicate the degrees of freedom which are unconstrained.1. Other boundary conditions lab. As mentioned before. As was the case in the main It is very simple to change boundary conditions and sup- program. lem of optimizing the material distribution in the MBB- ginal sensitivities making the filter inactive. this can be done by adding freedofs are found automatically using the Matlab oper. a few of which are mentioned in the 3. The interval which bounds the La. The 8 by 8 matrix for a square bi-linear 4-node elem- ent was determined analytically using a symbolic manip- 3. It is also very simple to extend the algorithm to account grees of freedom that are fixed (fixeddofs) thereafter the for multiple load cases. both nodes and elements are 79 F(2*(nelx+1)*(nely+1). 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). Knowing that the material volume 00 11 10 (sum(sum(xnew))) is a monotonously decreasing func- tion of the Lagrange multiplier (lag). 2. the filtered sensitivities will be equal to the ori.4. thus the command F(2. By selecting rmin less than one in the call of the The Matlab code given in the Appendix solves the prob- routine. the input line for the case shown Supports are implemented by eliminating fixed de. Lines 49–64 represent the Matlab implementation of (5). beam (Fig. In order to solve the short cantilever example shown used to insert the element stiffness matrix at the right in Fig. With these changes.2) 84 U(freedofs.:). Mostly. (line 79) applies a vertical unit force force in the upper left corner. in Fig. A number of extensions and changes in the algorithm can be thought of.2 11 00 01 00 11 10 Optimality criteria based optimizer (lines 37–48) 00 11 1010 The updated design variables are found by the opti- 00 11 00 11 00 11 00 11 ? 10 1010 mizer (lines 37–48).:) = K(freedofs. only lines 79 and 80 must be changed to places in the global stiffness matrix. only three additional lines and making minor changes to ator setdiff which finds the free degrees of freedoms as another 4 lines.3 ulation software. The bi-sectioning algorithm is initialized by guessing a lower l1 and an upper l2 bound for the Lagrangian multiplier (line 39).0. 2 is grees of freedom from the linear equations. 4. 123 3. Note that not all elements in the design domain are 4 searched in order to find the elements that lie within Extensions the radius rmin but only those within a square with side lengths two times round(rmin) around the considered element. In fact.

3 passive(ely.2*n1+1.1. Left: design domain. F(2*(nelx)*(nely+1)+2.. 3 Topology optimization of a cantilever beam with two load-cases.0.2) = 1.001. which then becomes top(45.e.4.5. 4 Topology optimization of a cantilever beam with 21 c = c + x(ely. 2*n2-1. 2*n2+1. their density equal to the minimum density (0. a unit the input upward load in the top-right corner is added to line 79.)^2) < nely/3.0. Fig. In order to install a better optimizer.)^2+(elx-nelx/3. force and displacement 1 1 1 vectors must be defined as two-column vectors which means that line 69 is changed to 11 00 00 11 1 0 0 1 1 0 0 1 00 11 0 1 0 1 69 F = sparse(2*(nely+1)*(nelx+1). 10 1010 1010 ? 10 1010 1010 19c for i = 1:2 20 Ue = U([2*n1-1.3.elx) = 0. 3 is (nely/2. some of the elements may be required to passive(ely.i). 00 11 00 11 00 11 00 11 ? 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 00 11 0 1 0 1 2 1 2 The objective function is now the sum of two compli- ances.2*n2. 22b end Figure 4 shows the resulting structure obtained with To solve the two-load problem indicated in Fig..2).2*n2+2. and center The input line for Fig.0. 4. the optimality criteria based optimizer im- plemented here is only good for a single constraint and it in the OC subroutine looks for passive elements and sets is based on a heuristic fixed point type updating scheme. end An nely × nelx array passive with zeros at elements end free to change and ones at elements fixed to be zero can end be defined in the main program and transferred to the OC subroutine (adding passive to the call in lines 28 and 38).3.) top(30.2). else In some cases. Left: design domain and right: topology opti- 22 dc(ely. take the minimum density value (e.4 Alternative optimizer 42b xnew(find(passive)) = 0. for ely = 1:nely for elx = 1:nelx if sqrt((ely-nely/2. a fixed hole. The added line 4.2).1. Admittedly.124 In the case of two load cases.. i. U = sparse(2*(nely+1)*(nelx+1). nelx/3. 3. Fig. middle: topology optimized beam using one load case and right: topology optimized beam  2 using two load cases c(x) = UTi KUi (7) i=1 01 01 thus lines 20–22 are substituted with the lines 1010 1010 19b dc(ely. one can obtain (free .elx) = 0.001).30.elx) = 0. 79 F(2*(nelx+1)*(nely+1)..elx)^(penal-1)*Ue’*KE*Ue.5).001.elx)^penal*Ue’*KE*Ue.elx) = dc(ely.elx) = 1.30.2*n1. Passive elements x(ely.1) = -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.elx) . mized beam penal*x(ely.0. a hole for a pipe).2*n1+2].g.

. Bendsøe. 193–202 tion algorithm.P. Comp. O. using topology optimization.html.dtu. The code is implemented using only 99 Bendsøe.P. Acknowledgements This work was supported by the Dan- ish Technical Research Council through the THOR/Talent- 4. Int.ikp. 14–24 This paper has presented a very simple implementation Bendsøe. Matlab input lines and includes optimizer. Technical University of Denmark simplicity of the program. Harzheim. where the total number of input/output variables is 20. 1988: Generating optimal topolo- page http://www. Mattheck. ment alternative boundary conditions and multiple load timization problem using less iterations at the cost of cases. M. M. 17. but requires the definition of several auxiliary 2000). The modification is suggested by Andreas Rietz from Link¨oping University who uses Sigmund. KTH. 387–393 5 Conclusions Beckers. mesh-indepe. 635–654 Running the code in Matlab is rather slow compared to a Fortran implementation of the same code which can Li.. Mech. The MMA code is called with the The code was intentionally kept compact in order following input line to keep the total number of lines below 100. 1989: Optimal shape design as a material dis- of a mathematical programming base topology optimiza. M. C. M. The reader may down-load his code at the web-page: 526 . for his inputs to an earlier Extensions to three dimensions should be straight for. 69. etc. simplify the code. ucational the MMA-algorithm (Svanberg 1987) from Krister Svan. gies in optimal design using a homogenization method. 71. H. Implementing the MMA-optimizer is fairly more than 500 times by different users (as of August simple. Struct.dtu..topopt. tural optimization. Baumgartner. The Matlab code can be down-loaded from the web. Fatigue 14. 1999: Material interpolations in areas. M. topology optimization.D.mekanik. Arch. The simplicity of the Matlab commands References allow for easy extensions of the graphical output.. it allows for the solving of more com. Steven. G. ward whereas more complex problems such as compliant mechanism design (Sigmund 1997) requires the imple- mentation of the MMA optimizer and the definition of ex- tra constraints. Among other positive feedbacks. 125 of charge for academic purposes) the Matlab version of http: //www. Optim. the Matlab code has been down-loaded densities. stress criterion and stiffness criterion in evolutionary struc- However. O. 197–224 include multi load problems and the definition of passive Bendsøe. Xie. 18. It should be noted that speed can be gained by modifying the Mat. 25. N. and is intended for ed. Mach. an add-on package to Matlab (MATLAB Com. however the speed is gained on the cost of ology optimization. Struct. Mech. The code can easily be extended to Meth. tribution problem. Appl. Sigmund. A. 5. theory. 1. 1997: On the design of compliant mechanisms sparsity options in the assembly of the global stiffness ma.P. 1999: On equivalence between be tested at the web-site http://www.dtu.P. 1992: Some aspects of the genesis of structures. Struct. Mech. interac- tive input etc. 1999: Topology optimization using a dual method with discrete variables. sors reported that they have used the code in courses on plex design problems with more than one constraint. old and new October 1999.topopt. Optim. Department of Solid Me- chanics. Optim. constraints. Sweden. 1992: SKO (Soft Kill Option): The biological way to find an optimum structure topology. Optim. has not been tested by the author). Technical University of Denmark. M. Struct. 67–73 piler) allows for the generation of more efficient C-code Mlejnek. 64–69 ever. . . several profes- variables. how. Sigmund. the author would be happy to re- OUTPUT-variables) ceive suggested modifications that can be implemented in the public domain code (the author’s e-mail address is Appl. Thesis. Engrg. shape and material . L.. version of the code. Struct. Heidelberg.liu.5 programme: Design of MicroElectroMechanical Systems Other extensions (MEMS). that can be optimized for run-time (this option. Ph. If users of the code should find ways to further compactify or mmasub(INPUT-variables. The author would also like to thank Thomas Buhl.. 1995: Optimization of structural topology. berg. New York: Springer ndency filtering and Finite Element code. 495– trix. The structural optimization and have let their students imple- Matlab optimizer will solve the standard topology op. a slightly increased CPU-time per iteration. J. O. Berlin.P.P. 1994: Design of material structures using top- lab code itself. However. Kikuchi. Since its first publication on the World Wide Web in including objective function.

i)/(x(j.2*n1+2]. 33 ’ ch. 1987: The method of moving asymptotes – a new 38 function [xnew]=OC(nelx..5*(l2+l1). 2*n2-1. Petersson.0. Struct. Steven. Y.change )]) Sigmund.M.pause(1e-6).nely.M. 2*n2+2.: ’ 83 % SOLVING . O. 74 edof = [2*n1-1. 82 freedofs = setdiff(alldofs. 59 dcn(j.2*n2. x(ely. 16.loop) ’ Obj. 61 end 6 change = 1. Xie.1).min(1. 197–224 50 function [dcn]=check(nelx. 32 ’ Vol.2*n1+1. Steven.rmin. grg.nelx) 56 for l = max(j-round(rmin).01 64 end 9 loop = loop + 1.I.volfrac.nely./lmid))))). 1998: Numerical instabilities in 34 % PLOT DENSITIES topology optimization: a survey on procedures dealing with 35 colormap(gray).nely.126 Sigmund.min(x+move. 2*(nelx+1)* 14 [KE] = lk. 2*n2. 13 % OBJECTIVE FUNCTION AND SENSITIVITY ANALYSIS 68 K = sparse(2*(nelx+1)*(nely+1). 69 F = sparse(2*(nely+1)*(nelx+1).1)..c) . Meth. 2*n1+1. move = 0.edof) = K(edof. 68–75 36 end 37 %%%%%%%%%% OPTIMALITY CRITERIA UPDATE %%%%%%%%% Svanberg. 1998: A gener- 44 l1 = lmid.volfrac. Op- 46 l2 = lmid. axis off.edof) + Ue’*KE*Ue.fac)*x(l. 251–260 47 end 48 end Zhou. 73 n2 = (nely+1)* elx +ely. 62 dcn(j.. Zhao. 43 if sum(sum(xnew)) . Mech. alized evolutionary method for numerical topology optimiza- 45 else tion of structures under static loading conditions.x..nelx).penal. 71 for elx = 1:nelx 19 n2 = (nely+1)* elx +ely.dc) method for structural optimization. New York: Springer *sqrt(-dc.k) 3 % INITIALIZE *dc(l.k).: ’ sprintf(’%6.. OCTOBER 1999 %%% 58 sum = sum+max(0.4f’. 30 change = max(max(abs(x-xold))).: ’ sprintf(’%6.P. 2*n1. nely) 1 %%%% A 99 LINE TOPOLOGY OPTIMIZATION CODE BY OLE 57 fac = rmin-sqrt((i-k)^2+(j-l)^2). WCSMO-3 (held in Buffalo. G.2*n1. 1999: Topology optimization of multi-physics. 31 disp([’ It. 72 n1 = (nely+1)*(elx-1)+ely. J. 359–373 40 while (l2-l1 > 1e-4) 41 lmid = 0.. part II: Topological. 39 l1 = 0. 20 Ue = U([2*n1-1. Proc.x. imagesc(-x). axis equal. Y.elx) = -penal*x(ely. 28 [x] = OC(nelx. 1997: Evolutionary structural opti- 42 xnew = max(0.dc) 51 dcn=zeros(nely.nely. 22 dc(ely. sprintf(’%10. 27 % DESIGN UPDATE BY THE OPTIMALITY CRITERIA METHOD 80 fixeddofs = union([1:2:2*(nely+1)].. 49 %%%%%%%%%% MESH-INDEPENDENCY FILTER %%%%%%%%%%% Comp.1).: ’ sprintf(’%4i’. 52 for i = 1:nelx 53 for j = 1:nely 6 54 sum=0. 29 % PRINT RESULTS 81 alldofs = [1:2*(nely+1)*(nelx+1)].elx)^(penal-1)* 75 K(edof. tim.fac).3f’. 15. U = 16 for ely = 1:nely sparse(2*(nely+1)*(nelx+1). Xie. J. 65 %%%%%%%%%% FE-ANALYSIS %%%%%%%%%%%% 11 % FE-ANALYSIS 66 function [U]=FE(nelx.x. G. (nely+1)). K. Berlin. 15 c = 0.2. 4 x(1:nely. 10 xold = x.i)*sum). Struct. Appendix – Matlab code 55 for k = max(i-round(rmin). 7 % START ITERATION 63 end 8 while change > 0. Appl.volfrac.P.1) = -1. multi-material structures. Rozvany. 2 function top(nelx. Int. 79 F(2.. axis checkerboards.max(x-move.volfrac*nelx*nely > 0. mesh-dependencies and local minima. 2*n2+2. geometry and generalized shape optimization.penal). tight. Numer.1): min(i+round(rmin). mization.nely.i) + max(0. 60 end 5 loop = 0.. 2*n1+2].nely.rmin).1): min(j+round(rmin)..x.N.001. SIGMUND.dc).elx)^penal*KE. Heidelberg. C. l2 = 100000.. Meth. 24. 89.elx)^penal*Ue’*KE*Ue.penal) 12 [U]=FE(nelx. G.sum(sum(x))/ NY) (nelx*nely)) . En. 67 [KE] = lk.i) = dcn(j. 23 end 76 end 24 end 77 end 25 % FILTERING OF SENSITIVITIES 78 % DEFINE LOADS AND SUPPORTS (HALF MBB-BEAM) 26 [dc] = check(nelx..dc). Hornby.nely.i) = dcn(j. [2*(nelx+1)*(nely+1)]). 2*n2+1.1:nelx) = volfrac. 17 for elx = 1:nelx 70 for ely = 1:nely 18 n1 = (nely+1)*(elx-1)+ely.rmin.3f’. 2*n2-1. O. 21 c = c + x(ely.. P.fixeddofs). 1991: The COC algorithm. M.x. Optim.x. Engrng.x. 2*n2+1.

97 k(6) k(5) k(4) k(3) k(2) k(1) k(8) k(7) 90 k=[ 1/2-nu/6 1/8+nu/8 -1/4-nu/12 -1/8+3*nu/8 ..3. 127 84 U(freedofs. 99 k(8) k(3) k(2) k(5) k(4) k(7) k(6) k(1)]. 98 k(7) k(4) k(5) k(2) k(3) k(8) k(1) k(6) 91 -1/4+nu/12 -1/8-nu/8 nu/6 1/8-3*nu/8]. 96 k(5) k(6) k(7) k(8) k(1) k(2) k(3) k(4) 89 nu = 0. [ k(1) k(2) k(3) k(4) k(5) k(6) k(7) k(8) 85 U(fixeddofs.freedofs) \ 92 KE = E/(1-nu^2)* F(freedofs..:)= 0. 93 k(2) k(1) k(8) k(7) k(6) k(5) k(4) k(3) 86 %%%%%%%%%% ELEMENT STIFFNESS MATRIX %%%%%%% 94 k(3) k(8) k(1) k(6) k(7) k(4) k(5) k(2) 87 function [KE]=lk 95 k(4) k(7) k(6) k(1) k(8) k(3) k(2) k(5) 88 E = 1.:) = K(freedofs.:). ..