Efficient topology optimization in MATLAB using 88 lines of code
- 15k Downloads
The paper presents an efficient 88 line MATLAB code for topology optimization. It has been developed using the 99 line code presented by Sigmund (Struct Multidisc Optim 21(2):120–127, 2001) as a starting point. The original code has been extended by a density filter, and a considerable improvement in efficiency has been achieved, mainly by preallocating arrays and vectorizing loops. A speed improvement with a factor of 100 is obtained for a benchmark example with 7,500 elements. Moreover, the length of the code has been reduced to a mere 88 lines. These improvements have been accomplished without sacrificing the readability of the code. The 88 line code can therefore be considered as a valuable successor to the 99 line code, providing a practical instrument that may help to ease the learning curve for those entering the field of topology optimization. The paper also discusses simple extensions of the basic code to include recent PDE-based and black-and-white projection filtering methods. The complete 88 line code is included as an appendix and can be downloaded from the web site www.topopt.dtu.dk.
KeywordsTopology optimization MATLAB Education Computational efficiency
This work was financially supported by the Eurohorcs/ESF European Young Investigator Award (EURYI), by a Center of Advanced User Support (CAUS) grant from the Danish Center of Scientific Computing (DCSC), and by an Elite Research Prize from the Danish Minister of Research. The third author is a postdoctoral fellow of the Research Foundation—Flanders and a member of K.U.Leuven-BOF PFV/10/002 OPTEC-Optimization in Engineering Center.
- Allaire G (2009) Shape and topology optimization by the level set method. http://www.cmap.polytechnique.fr/~allaire
- Bendsøe M, Sigmund O (2003) Topology optimization. Theory, methods and applications. Springer, BerlinGoogle Scholar
- Dabrowski M, Krotkiewski M, Schmid D (2008) MILAMIN: MATLAB-based finite element method solver for large problems. Geochemistry Geophysics Geosystems 9(4). doi: 10.1029/2007GC001719
- Davis T (2007) Creating sparse finite-element matrices in MATLAB. Guest blog in Loren on the art of MATLAB. http://blogs.mathworks.com/loren/2007/03/01/creating-sparse-finite-element-matrices-in-matlab/; http://blogs.mathworks.com/loren/
- Davis T (2008) User guide for CHOLMOD: a sparse Cholesky factorization and modification package. Department of Computer and Information Science and Engineering, University of Florida, Gainesville, FL, USAGoogle Scholar
- Lazarov B, Sigmund O (2009) Sensitivity filters in topology optimisation as a solution to helmholtz type differential equation. In: Proc. of the 8th world congress on structural and multidisciplinary optimizationGoogle Scholar
- Sigmund O (1994) Design of material structures using topology optimization. PhD thesis, DCAMM S-report S69, Department of Solid Mechanics, Technical University of DenmarkGoogle Scholar
- The MathWorks (2010) MATLAB programming fundamentalsGoogle Scholar
- Wang F, Lazarov B, Sigmund O (2010) On projection methods, convergence and robust formulations in topology optimization (submitted)Google Scholar