Abstract
Explicit topology optimization methods have received ever-increasing interest in recent years. In particular, a 188-line Matlab code of the two-dimensional (2D) Moving Morphable Component (MMC)-based topology optimization method was released by Zhang et al. (Struct Multidiscip Optim 53(6):1243-1260, 2016). The present work aims to propose an efficient and easy-to-extend 256-line Matlab code of the MMC method for three-dimensional (3D) topology optimization implementing some new numerical techniques. To be specific, by virtue of the function aggregation technique, accurate sensitivity analysis, which is also easy-to-extend to other problems, is achieved. Besides, based on an efficient identification algorithm for load transmission path, the degrees of freedoms (DOFs) not belonging to the load transmission path are removed in finite element analysis (FEA), which significantly accelerates the optimization process. As a result, compared to the corresponding 188-line 2D code, the performance of the optimization results, the computational efficiency of FEA, and the convergence rate and the robustness of optimization process are greatly improved. For the sake of completeness, a refined 218-line Matlab code implementing the 2D-MMC method is also provided.
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig1_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig2_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig3_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig4_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig5_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig6_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig7_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig8_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig9_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig10_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig11_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig12_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig13_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig14_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig15_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig16_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig17_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig18_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig19_HTML.png)
![](http://media.springernature.com/m312/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fig20_HTML.png)
Notes
It should be noted that, alternatively, the p-norm function is another choice for approximating the max operation and analytical sensitivities could also be obtained accordingly (Picelli et al. 2018).
The “fsparse” routine developed by Engblom and Lukarski (2016) is required (available at https://github.com/stefanengblom/stenglib).
Phimax is regularized with a minimum value of \(-10^3\) to avoid possible singularity.
The non-design solid domains also belong to the load transmission path.
The MMA code of 2007 version is used (Svanberg 2007). Available at http://www.smoptit.se/
References
Aage N, Andreassen E, Lazarov BS (2015) Topology optimization using petsc: an easy-to-use, fully parallel, open source topology optimization framework. Struct Multidisc Optim 51(3):565–572
Andreassen E, Clausen A, Schevenels M, Lazarov BS, Sigmund O (2011) Efficient topology optimization in matlab using 88 lines of code. Struct Multidisc Optim 43(1):1–16
Bathe KJ (2006) Finite element procedures. Pearson Education Inc., New York
Challis VJ (2010) A discrete level-set topology optimization code written in matlab. Struct Multidisc Optim 41(3):453–464
Cui T, Du Z, Liu C, Sun Z, Guo X (2022) Explicit topology optimization with moving morphable component (mmc) introduction mechanism. Acta Mech Solid Sin. https://doi.org/10.1007/s10338-021-00308-x
Du Z, Chen H, Huang G (2020) Optimal quantum valley hall insulators by rationally engineering berry curvature and band structure. J Mech Phys Solids 135(103):784
Engblom S, Lukarski D (2016) Fast matlab compatible sparse assembly on multicore computers. Parallel Comput 56:1–17
Ferrari F, Sigmund O (2020) A new generation 99 line matlab code for compliance topology optimization and its extension to 3d. Struct Multidisc Optim 62:2211–2228
Guo X, Zhang W, Zhong W (2014) Doing topology optimization explicitly and geometrically-a new moving morphable components based framework. J Appl Mech 81(8):0810089
Guo X, Zhang W, Zhang J, Yuan J (2016) Explicit structural topology optimization based on moving morphable components (mmc) with curved skeletons. Comput Methods Appl Mech Eng 310:711–748
Guo X, Zhou J, Zhang W, Du Z, Liu C, Liu Y (2017) Self-supporting structure design in additive manufacturing through explicit topology optimization. Comput Methods Appl Mech Eng 323:27–63
Hoang VN, Nguyen-Xuan H (2020) Extruded-geometric-component-based 3d topology optimization. Comput Methods Appl Mech Eng 371(113):293
Huang X, **e YM (2010) A further review of eso type methods for topology optimization. Struct Multidisc Optim 41(5):671–683
Kreisselmeier G, Steinhauser R (1980) Systematic control design by optimizing a vector performance index. In: Computer aided design of control systems, Proceedings of the IFAC symposium, pp 113–117
Liu C, Zhu Y, Sun Z, Li D, Du Z, Zhang W, Guo X (2018) An efficient moving morphable component (mmc)-based approach for multi-resolution topology optimization. Struct Multidisc Optim 58(6):2455–2479
Liu K, Tovar A (2014) An efficient 3d topology optimization code written in matlab. Struct Multidisc Optim 50(6):1175–1196
Luo J, Du Z, Guo Y, Liu C, Zhang W, Guo X (2021) Multi-class, multi-functional design of photonic topological insulators by rational symmetry-indicators engineering. Nanophotonics 10(18):4523–4531
Niu B, Wadbro E (2019) On equal-width length-scale control in topology optimization. Struct Multidisc Optim 59(4):1321–1334
Picelli R, Townsend S, Brampton C, Norato J, Kim HA (2018) Stress-based shape and topology optimization with the level set method. Comput Methods Appl Mech Eng 329:1–23
Raponi E, Bujny M, Olhofer M, Aulig N, Boria S, Duddeck F (2019) Kriging-assisted topology optimization of crash structures. Comput Methods Appl Mech Eng 348:730–752
Sigmund O (1997) On the design of compliant mechanisms using topology optimization. J Struct Mech 25(4):493–524
Sigmund O (2001) A 99 line topology optimization code written in matlab. Struct Multidisc Optim 21(2):120–127
Smith H, Norato JA (2020) A matlab code for topology optimization using the geometry projection method. Struct Multidisc Optim 62:1579–1594
Svanberg K (1987) The method of moving asymptotes-a new method for structural optimization. Int J Numer Methods Eng 24(2):359–373
Svanberg K (2007) Mma and gcmma, versions september 2007. Optimization and Systems Theory 104
Takalloozadeh M, Yoon GH (2017) Implementation of topological derivative in the moving morphable components approach. Finite Elements Anal Des 134:16–26
Wang MY, Wang X, Guo D (2003) A level set method for structural topology optimization. Comput Methods Appl Mech Eng 192(1–2):227–246
Wei P, Li Z, Li X, Wang MY (2018) An 88-line matlab code for the parameterized level set method based topology optimization using radial basis functions. Struct Multidisc Optim 58(2):831–849
Xue R, Li R, Du Z, Zhang W, Zhu Y, Sun Z, Guo X (2017) Kirigami pattern design of mechanically driven formation of complex 3d structures through topology optimization. Extreme Mech Lett 15:139–144
Xue R, Liu C, Zhang W, Zhu Y, Tang S, Du Z, Guo X (2019) Explicit structural topology optimization under finite deformation via moving morphable void (mmv) approach. Comput Methods Appl Mech Eng 344:798–818
Yoon GH, Kim YY (2003) The role of s-shape map** functions in the simp approach for topology optimization. KSME Int J 17(10):1496–1506
Zhang W, Li D, Zhang J, Guo X (2016) Minimum length scale control in structural topology optimization based on the moving morphable components (mmc) approach. Comput Methods Appl Mech Eng 311:327–355
Zhang W, Yuan J, Zhang J, Guo X (2016) A new topology optimization approach based on moving morphable components (mmc) and the ersatz material model. Struct Multidisc Optim 53(6):1243–1260
Zhang W, Chen J, Zhu X, Zhou J, Xue D, Lei X, Guo X (2017) Explicit three dimensional topology optimization via moving morphable void (mmv) approach. Comput Methods Appl Mech Eng 322:590–614
Zhang W, Li D, Yuan J, Song J, Guo X (2017) A new three-dimensional topology optimization method based on moving morphable components (mmcs). Comput Mech 59(4):647–665
Acknowledgements
The authors are grateful to Prof. Krister Svanberg for providing the MMA optimizer code.
Funding
This work is supported by the National Natural Science Foundation (11821202, 11732004, 12002073, 12002077, 11922204, 11872141), the National Key Research and Development Plan (2020YFB1709401), the Fundamental Research Funds for the Central Universities (DUT20RC(3)020, DUT21-RC(3)076), Dalian Talent Innovation Program (2020RQ099), Liaoning Revitalization Talents Program (XLYC1907119), Doctoral Scientific Research Foundation of Liaoning Province (2021-BS-063) and 111 Project (B14013).
Author information
Authors and Affiliations
Corresponding author
Ethics declarations
Conflict of interest
The authors declare that they have no conflict of interest.
Replication of results
Matlab codes are listed in the Appendix. The stenglib package, containing the fsparse function, is available at https://github.com/ stefanengblom/stenglib. The MMA subroutines can be downloaded at http://www.smoptit.se/.
Additional information
Responsible Editor: Seonho Cho
Publisher’s note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Appendices
Appendix 1: Exact expressions of \(\frac{\partial \phi ^i}{\partial d_j^i}\) in the MMC3d code
For conciseness, the following notations are introduced
Then the exact formulations of \(\partial \phi ^i/\partial d_j^i\) can be expressed as
with the following identities
where \(\zeta =\alpha ,\beta ,\gamma\) respectively.
Appendix 2: Modifications of the MMC3d code for the initial design 2 of compliant mechanism design example
The main code is updated as
vInt = [1.2 0.2 0.2 atan(2.5) atan(0.75) atan(0.3)];
MMC3d(10, 1, 5, 200, 20, 100, 5/6, 1/4, 5/8, vInt, 0.2);
In the MMC3d.m, the modifications in SEC 2, SEC 3, the finite element analysis and sensitivity analysis subsections are the same as the modifications for initial design 1. Nevertheless, lines 44-53 in SEC 4 for the generation of initial design variables are modified as:
x0 = xInt:2*xInt:DL; y0 = yInt:2*yInt:DW; z0 = zInt:2*zInt:DH;
xn = length(x0); yn = length(y0); zn = length(z0);
x0 = kron(x0,ones(1,1*yn*zn));
y0 = repmat(repmat(y0,1,1*zn),1,1*xn);
z0 = repmat(reshape(repmat(z0,2,1),1,8),1,xn);
N = length(x0);
l1 = repmat(vInt(1),1,N);
l2 = repmat(vInt(2),1,N);
l3 = repmat(vInt(3),1,N);
alp = repmat(vInt(4),1,N);
bet = repmat([repmat([-1 -1 1 1],1,2) repmat([1 1 -1 -1],1,2)]*vInt(5),1,3);
gam = repmat([repmat([1 -1],1,4) repmat([-1 1],1,4)]*vInt(6),1,3);
Appendix 3: Exact expressions of \(\frac{\partial \phi ^i}{\partial d_j^i}\) in the MMC2d code
For conciseness, the following notations are introduced
And the derivatives of intermediate variables \(x',y',l^i\) with respect to design variables are first detailed as
Then the exact expressions of \(\frac{\partial \phi ^i}{\partial d_j^i}\) in the MMC2d code can be formulated as
Appendix 4: A 256-line MATLAB code for the 3D-MMC method
![figure ms](http://media.springernature.com/lw685/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Figma_HTML.png)
![figure mb](http://media.springernature.com/lw685/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Figmb_HTML.png)
![figure mc](http://media.springernature.com/lw685/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Figmc_HTML.png)
![figure md](http://media.springernature.com/lw685/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Figmd_HTML.png)
Appendix 5: A 218-line MATLAB code for the 2D-MMC method
![figure na](http://media.springernature.com/lw685/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Figna_HTML.png)
![figure nb](http://media.springernature.com/lw685/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fignb_HTML.png)
![figure nc](http://media.springernature.com/lw685/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fignc_HTML.png)
![figure nd](http://media.springernature.com/lw685/springer-static/image/art%3A10.1007%2Fs00158-022-03239-4/MediaObjects/158_2022_3239_Fignd_HTML.png)
Rights and permissions
About this article
Cite this article
Du, Z., Cui, T., Liu, C. et al. An efficient and easy-to-extend Matlab code of the Moving Morphable Component (MMC) method for three-dimensional topology optimization. Struct Multidisc Optim 65, 158 (2022). https://doi.org/10.1007/s00158-022-03239-4
Received:
Revised:
Accepted:
Published:
DOI: https://doi.org/10.1007/s00158-022-03239-4