Abstract
Compact and efficient Matlab implementations of compliance topology optimization (TO) for 2D and 3D continua are given, consisting of 99 and 125 lines respectively. On discretizations ranging from 3 ⋅ 104 to 4.8 ⋅ 105 elements, the 2D version, named top99neo, shows speedups from 2.55 to 5.5 times compared to the well-known top88 code of Andreassen et al. (Struct Multidiscip Optim 43(1):1–16, 2011). The 3D version, named top3D125, is the most compact and efficient Matlab implementation for 3D TO to date, showing a speedup of 1.9 times compared to the code of Amir et al. (Struct Multidiscip Optim 49(5):815–829, 2014), on a discretization with 2.2 ⋅ 105 elements. For both codes, improvements are due to much more efficient procedures for the assembly and implementation of filters and shortcuts in the design update step. The use of an acceleration strategy, yielding major cuts in the overall computational time, is also discussed, stressing its easy integration within the basic codes.
References
Amir O, Sigmund O (2011) On reducing computational effort in topology optimization: how far can we go? Struct Multidiscip Optim 44(1):25–29. https://doi.org/10.1007/s00158-010-0586-7
Amir O, Aage N, Lazarov BS (2014) On multigrid–CG for efficient topology optimization. Struct Multidiscip Optim 49(5):815–829. https://doi.org/10.1007/s00158-013-1015-5
Anderson DG (1965) Iterative procedures for nonlinear integral equations. J Assoc Comput Mach 12(4):547–560
Andreassen E, Andreasen CS (2014) How to determine composite material properties using numerical homogenization. Comput Mater Sci 83:488–495
Andreassen E, Clausen A, Schevenels M, Lazarov BS, Sigmund O (2011) Efficient topology optimization in matlab using 88 lines of code. Struct Multidiscip Optim 43 (1):1–16. https://doi.org/10.1007/s00158-010-0594-7
Arora JS, Chahande AI, Paeng JK (1991) Multiplier methods for engineering optimization. Int J Numer Methods Eng 32(7):1485–1525
Bendsøe MP, Sigmund O (1999) Material interpolation schemes in topology optimization. Arch Appl Mech 69(9):635–654. https://doi.org/10.1007/s004190050248
Bourdin B (2001) Filters in topology optimization. Int J Numer Methods Eng 50(9):2143–2158. https://doi.org/10.1002/nme.116
Brezinski C, Chehab JP (1998) Nonlinear hybrid procedures and fixed point iterations. Numer Funct Anal Optim 19(5–6):465–487. https://doi.org/10.1080/01630569808816839
Bruns TE, Tortorelli DA (2001) Topology optimization of non-linear elastic structures and compliant mechanisms. Comput Methods Appl Mech Eng 190(26):3443–3459. https://doi.org/10.1016/S0045-7825(00)00278-4. http://www.sciencedirect.com/science/article/pii/S0045782500002784
Challis VJ (2010) A discrete level-set topology optimization code written in matlab. Struct Multidiscip Optim 41(3):453–464. https://doi.org/10.1007/s00158-009-0430-0
Christensen P, Klarbring A (2008) An introduction to structural optimization. Solid mechanics and its applications. Springer, Netherlands
Davis TA (2009) User guide for CHOLMOD: a sparse Cholesky factorization and modification package
Davis T (2019) Suitesparse: a suite of sparse matrix software. http://faculty.cse.tamu.edu/davis/suitesparse.html
Engblom S, Lukarski D (2016) Fast matlab compatible sparse assembly on multicore computers. Parallel Comput 56:1–17
Eyert V (1996) A comparative study on methods for convergence acceleration of iterative vector sequences. J Comput Phys 124(2):271–285. https://doi.org/10.1006/jcph.1996.0059
Fang HR, Saad Y (2009) Two classes of multisecant methods for nonlinear acceleration. Numer Linear Algebra Appl 16(3):197–221. https://doi.org/10.1002/nla.617
Ferrari F, Sigmund O (2020) Towards solving large-scale topology optimization problems with buckling constraints at the cost of linear analyses. Comput Methods Appl Mech Eng 363:112,911. https://doi.org/10.1016/j.cma.2020.112911
Ferrari F, Lazarov BS, Sigmund O (2018) Eigenvalue topology optimization via efficient multilevel solution of the frequency response. Int J Numer Methods Eng 115(7):872–892
Guest JK, Prévost JH, Belytschko T (2004) Achieving minimum length scale in topology optimization using nodal design variables and projection functions. Int J Numer Methods Eng 61(2):238–254. https://doi.org/10.1002/nme.1064
Hestenes MR (1969) Multiplier and gradient methods. J Optim Theory Appl 4(5):303–320. https://doi.org/10.1007/BF00927673
Horn RA, Johnson CR (2012) Matrix analysis, 2nd edn. Cambridge University Press, New York
Li L, Khandelwal K (2015) Volume preserving projection filters and continuation methods in topology optimization. Engineering Stru 85:144–161
Li W, Suryanarayana P, Paulino G (2020) Accelerated fixed–point formulation of topology optimization: application to compliance minimization problems. Mech Rese Commun 103:103,469
Liu K, Tovar A (2014) An efficient 3d topology optimization code written in matlab. Struct Multidiscip Optim 50(6):1175–1196. https://doi.org/10.1007/s00158-014-1107-x
Peng Y, Deng B, Zhang J, Geng F, Qui W, Liu L (2018) Anderson acceleration for geometry optimization and physics simulation. ACM Trans Graph 37(4):42:1–42:14
Pratapa PP, Suryanarayana P, Pask JE (2016) Anderson acceleration of the jacobi iterative method: An efficient alternative to krylov methods for large, sparse linear systems. J Comput Phys 306:43–54. https://doi.org/10.1016/j.jcp.2015.11.018
Quarteroni A, Sacco R, Saleri F (2000) Numerical mathematics. Texts in applied mathematics. Springer
Ramiere I, Helfer T (2015) Iterative residual–based vector methods to accelerate fixed point iterations. Comput Math Appl 70:2210–2226
Saad Y (1992) Numerical methods for large eigenvalue problems. Manchester University Press
Sanders ED, Pereira A, Aguiló MA, Paulino GH (2018) Polymat: an efficient Matlab code for multi–material topology optimization. Struct Multidiscip Optim 58:2727–2759
Sigmund O (2001) A 99 line topology optimization code written in Matlab. Struct Multidiscip Optim 21(2):120–127. https://doi.org/10.1007/s001580050176
Sigmund O (2007) Morphology–based black and white filters for topology optimization. Struct Multidiscip Optim 33(4):401–424
Suresh K (2010) A 199–line Matlab code for Pareto–optimal tracing in topology optimization. Struct Multidiscip Optim 42(5):665–679
Talischi C, Paulino GH, Pereira A, Menezes IF (2012) Polytop: a matlab implementation of a general topology optimization framework using unstructured polygonal finite element meshes. Struct Multidiscip Optim 45(3):329–357. https://doi.org/10.1007/s00158-011-0696-x
Walker HF, Ni P (2011) Anderson acceleration for fixed point iterations. SIAM J Numer Anal 49(4):1715–1735
Wang MY (2007) Structural topology optimization using level set method. In: Computational methods in engineering & science. Springer, Berlin, pp 310–310
Wang F, Lazarov B, Sigmund O (2011) On projection methods, convergence and robust formulations in topology optimization. Struct Multidiscip Optim 43(6):767–784
Xia L, Breitkopf P (2015) Design of materials using topology optimization and energy-based homogenization approach in matlab. Struct Multidiscip Optim 52(6):1229–1241. https://doi.org/10.1007/s00158-015-1294-0
Xu S, Cai Y, Cheng G (2010) Volume preserving nonlinear density filter based on Heaviside functions. Struct Multidiscip Optim 41:495–505
Acknowledgments
The project is supported by the Villum Fonden through the Villum Investigator Project “InnoTop.” The authors are grateful to members of the TopOpt group for their useful testing of the code.
Author information
Authors and Affiliations
Corresponding author
Ethics declarations
Conflict of interests
The authors declare that they have no conflict of interest.
Additional information
Responsible Editor: Palaniappan Ramu
Publisher’s note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Replication of results
Matlab codes are listed in the Appendix and available at www.topopt.dtu.dk. The stenglib package, containing the fsparse function, is avaialble for download at https://github.com/stefanengblom/stenglib.
Appendices
Appendix A: Elaboration on the OC update
Let us consider (3) at a given design point xk assuming the reciprocal and linear approximation for the compliance and volume functions, respectively (Christensen and Klarbring 2008)
We set up the Lagrangian associated with (24)
and seek the pair \((\mathbf {x}_{k+1},\lambda ^{\ast }_{k})\in \mathbb {R}^{m}\times \mathbb {R}_{+}\) solving the subproblem
where \(\mathcal {C} = \{ \mathbf {x} \in \mathbb {R}^{m} \mid \delta _{-}\leq x_{e} \leq \delta _{+}, e = 1 \ldots , m \}\) and ψ(λ) is the dual function. Equation (25) is solved by primal-dual (PD) iterations, as x and λ are interlaced. Replacing ξ = xk and using subscripts (j) to denote inner PD iterations, we have
-
1.
Fixed λ = λ(j), the inner minimization in (25) gives
$$ {\xi^{2}_{e}}\partial_{e}c(\boldsymbol{\xi})x^{-2}_{e} + \lambda \partial_{e}V(\boldsymbol{\xi}) = 0 \Longrightarrow x_{e} = \xi_{e} \left( -\frac{\partial_{e}c(\boldsymbol{\xi})} {\lambda\partial_{e}V(\boldsymbol{\xi})} \right) ^{\frac{1}{2}} $$due to separability of the approximation. Let us denote the rightmost expression \(x_{e} = \mathcal {F}_{(j)e}(\lambda )\), and taking into account the box constraints in \(\mathcal {C}\), we have
$$ \mathcal{U}(x_{e}) = \begin{cases} x_{(j+1),e} = \delta_{-} & \text{if} e \in \mathcal{L} = \{e\mid x_{(j+1),e} \leq \delta_{-} \} \\ x_{(j+1),e} = \delta_{+} & \text{if} e \in \mathcal{U} = \{e\mid x_{(j+1),e} \geq \delta_{+} \} \\ x_{(j+1),e} = \mathcal{F}_{(j),e} & \text{if} e \in \mathcal{M} = \{e\mid\delta_{-} < x_{(j+1),e} < \delta_{+} \} \\ \end{cases} $$(26)where \(\mathcal {C} = {\mathscr{L}} + \mathcal {U} + {\mathscr{M}}\). The above is equivalent to (10).
-
2.
We then evaluate the dual function for x(j+ 1) given by (26), and the stationarity (∂λψ = 0) gives
$$ \sum\limits_{e=1}^{m} \partial_{e} V(\boldsymbol{\xi}) (\chi_{\mathcal{U}}\delta_{+} + \chi_{\mathcal{L}}\delta_{-} + \mathcal{F}_{(j),e}(\lambda)\chi_{\mathcal{M}} ) - f|{\Omega}_{h}| = 0 $$where χ[⋅] is the characteristic function of a set. In this simple case, the above can be solved for λ(j+ 1), the Lagrange multiplier enforcing the volume constraint for the updated density x(j+ 1), and after some simplifications, we obtain
$$ \lambda_{(j+1)} = \left( \frac{{\sum}_{e\in\mathcal{M}}x_{(j+1)e}(\partial_{e}c(\boldsymbol{\xi})/\partial_{e}V(\boldsymbol{\xi}))^{1/2}} {f|{\Omega}_{h}|/\partial_{e}V(\boldsymbol{\xi}) - |\mathcal{L}|\delta_{-} - |\mathcal{U}|\delta_{+}}\right)^{2} $$(27)where |⋅| denotes the number of elements in a set.
Equations (26) and (27) can be iteratively used to compute the new solution \((\mathbf {x}_{k+1},\lambda ^{\ast }_{k})\), as implemented in the code here below (again, note that lm here represents \(\sqrt {\lambda }\))
and, for the MBB beam example, this performs as shown by the green curves in Fig. 4b.
However, a closed form expression such as (27) cannot be obtained for more involved constraint expressions and therefore a root finding strategy must be employed to approximate the Lagrange multiplier. The application of (27) to the current, feasible design point (x(j+ 1) = xk) reduces to
since \(|{\mathscr{M}}| = |{\Omega }_{h}| = m\), \(|{\mathscr{L}}| = |\mathcal {U}| = 0\) and we made use of (7). We immediately verify that (28) is identical to (19).
Appendix B: The 2D code for compliance minimization
Appendix C: 3D code for compliance minimization
Rights and permissions
About this article
Cite this article
Ferrari, F., Sigmund, O. A new generation 99 line Matlab code for compliance topology optimization and its extension to 3D. Struct Multidisc Optim 62, 2211–2228 (2020). https://doi.org/10.1007/s00158-020-02629-w
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00158-020-02629-w