1 Introduction

Educational papers have become an important class of contributions for expanding topology optimization research. In recent years, the number of educational publications on topology optimization subjects has increased, and their contributions have had a substantial influence on both research and education. For example, the work of 99-line MATLAB that introduced the Solid Isotropic Material with Penalization (SIMP) approach is one of the most popular instructional articles (Sigmund 2001). This work was followed by several compact versions as 88 line, (Andreassen et al. 2011). Also, 99 lines were renewed (Ferrari and Sigmund 2020). Furthermore, the level-set method was addressed by many educational papers such as the topological derivative-based level-set (Challis 2010), the extension of reaction diffusion (Otomori et al. 2015), and parametrized level-set method (PLSM; Wei et al. 2018). Also the use of evolutionary structural optimization (ESO) was introduced (Lin et al. 2020).

This educationally oriented research is aiming toward introducing the methodology of multiphysics concurrent multiscale topology optimization for attaining designs of lightweight, high heat conductive, and stiff porous structures. Furthermore, a MATLAB code that demonstrates the problem is introduced. In the following sections, we will discuss the practical importance and the logic as well as the necessary mathematical and physical backgrounds to attain this purpose.

In general, weight reduction of structures is vital for minimizing energy consumption and reducing pollutant emissions. For example, the role of aviation in global warming has prompted ongoing efforts to reduce aviation pollution emissions by reducing structural weight (Zhu et al. 2018).

Also, with the advancement of engineering applications, the compact layout is an important aspect of modern design. For example, passive heat sinks due to their zero-energy consumption, compactness, and quiet are utilized in massive multiple-input multiple-output (MMIMO) systems of 5G communications, high-power LEDs (Lazarov et al. 2018), and a variety of other industrial applications. These passive heat sinks are utilized as an integrated part of the metal package of the MMIMO and LEDs which serve the purpose of structural enforcement and fan heat dissipater. Furthermore, with the advancement in integrated circuits downscaling of micro and nanoelectronics, the demand is increased for reducing the size and the weight of the heat passive components as well as sustaining appropriated structural stiffness, such that the weight reduction will lead to a rapid decrease in the structural stiffness which makes the heat passive component highly susceptible to the mechanical forces of the operating environment. To attain heat and stiffness maximization, optimization methods are used by engineers, and one of the optimization trends is topology optimization. For achieving the optimal design of lightweight, high conductive, and stiff porous structures. This goal is attained by utilizing several engineering concepts which are multiphysics modeling (i.e., the heat conductivity and structural stiffness for this study), multi-objective and multiscale optimization. In order not to confuse the reader, in the following sections, these concepts are discussed, respectively. First, let us discuss topology optimization. Topology optimization is presented as one of the rapidly advancing methodologies for achieving innovative designs. Associated with additive manufacturing topologically optimized structures increasingly find the way in industrial applications to produce lightweight structures with high functionality. Therefore, the goal of structural topology optimization is to discover the best and robust material distribution to maximize structural performance to weight ratio while meeting various design conditions. When compared to the known parametric optimization, topology optimization gives the designers a lot more leeway, allowing them to come up with completely new and extremely efficient conceptual designs.

Topology optimization was first created for structures with mechanical loading, and it was based on a series of research published by Maxwell (1890) in which the traction effect on frame structures was formulated using a simplified version of discretization. For deterministic and nondeterministic problems, Maxwell developed a virtual energy formulation to analyze displacement and applied forces. Some researches were performed to utilize Maxwell lemma, but the most successful and considered as the foundation of topology and layout optimization is the study conducted by Michell (Michell 1904). Michell used the Maxwell lemma and did exact analysis formulation and optimization. The feasible optimal design was achieved due to conditioning-based optimization. Many kinds of researches were conducted after Michell (Drucker and Shield 1956; Chan 1960; Hegemier and Prager 1969; Bartel 1969; Charrett and Rozvany 1972; Rozvany and Prager 1976; Cheng and Olhoff 1981), which built the basis of modern topology optimization. Efficient integration of mathematical and modern computational methods was done by implementing the homogenization for topology optimization as a target of the discretized continuous optimality criterion (DCOC) by Bendsoe et al. (Bendsøe and Kikuchi 1988). This work led to the development of the concept of fictitious material by Bendsoe (Bendsøe 1989) which then derived the Solid Isotropic Material with Penalization method (SIMP) that is widely used in commercial finite element solver nowadays.

On the other hand, the development of nonparametric optimization techniques for thermal conductivity problems has relatively less attention compared with structural problems. The early work of thermal problems was utilizing the parametric optimization approaches. The implementation of discretization methods in the optimization of the thermal problem (Rao and Narayanaswami 1978; Haftka 1981) has been the first step toward adopting nonparametric optimization for the thermal conductivity problem. Several attempts were conducted to shift toward nonparametric optimization were performed (Saigal and Chandra 1991; Lee 1993), yet the most successful attempt was performed by Li et al. (1999) in which several examples were studied to optimize 2D cases using evolutionary structural optimization (ESO). Constructal law by Bejan (1997) led to the design of conductive channels from the design domain of low conductivity. In his methodology, heat generation was distributed in the design domain. Thenceforth, the vast majority of researchers adopted Bejan’s approach and utilized heat compliance as the objective function in order to maximize structural heat conductivity. Li et al. (2004) have addressed the issue of extremum of heat conduction by adopting ESO, to topology optimize temperature-controlled point problem. Gersborg-Hansen et al. (2006) investigated the use of finite volume as a discretization method for topology optimization for thermal conductivity problems. Al Ali and Shimoda (2022) investigated the multiscale topology optimization of 2D and 3D high thermal conductive structures using topology optimization of SIMP, ESO, as well as Level-set method. It is important to mention that, in addition to SIMP and ESO topology optimization, there are robust methods that are used by many researchers such as H1 gradient method (Liu and Shimoda 2014), Mesh morphing (Cenni et al. 2015), Phase field (Bourdin and Chambolle 2006; Burger and Stainko 2006), and Level set (Allaire et al. 2002; Abass et al. 2019).

Multiphysics is the process of linking various physical phenomena (Jabbar and Naguib 2020, 2019) such as heat and mass transfer, fluid flows, and solid elastic stresses. Each problem has its dedicated mathematical solution based on its physical assumptions, fields, and boundary conditions. In this research, heat conduction in solid and mechanical stiffness is using a dedicated finite element model for each physics on the macro and the microscale. However, the design variables are the same as the design domain due to the implicit nature (Farin et al. 2002) of the topology optimization. Topology optimization has been widely used in a variety of engineering challenges dictated by single physics, such as constructing optimal conductive and convective heat transfer (Zhou et al. 2016), fluid flow (Duan et al. 2008), wave propagation (Chen et al. 2020), and piezoelectricity problems (Kim et al. 2010; Yoon et al. 2018). Also, multiphysics problems have been successfully investigated with topology optimization for various fields such as fluid-thermal problems (Yu et al. 2019), fluid permeability and structural stiffness (Challis et al. 2012). Multiphysics optimization is attained by updating the physical–mathematical criteria with the optimization process. The multicriteria are often transformed to an appropriate multi-objective function layout, and the most commonly used one is the weighted sum of multi-objective functions. Here, the objectives are optimized systematically with assigning importance (by decreasing or increasing the “weight” of a criterion in the favor of another) to draw Pareto front to identify the best design variables that offer the best trade-off. Convexity of all functions within the multi-objective criteria might not have existed for some engineering problems. As such modifying the weighted sum of multi-objective function is needed. The modifications are taken many forms such as normative weighted sum (Carpinelli et al. 2014) which is called Euclidean distance for using the power of 2 (Carpinelli et al. 2014), or scalarization form (Shimoda et al. 1996), normalization (Rao and Freiheit 1991) and sometimes, the combination of power and normalization forms (Wu et al. 2019). The selection of the modification for the multi-objective function is related to the nature of the problem and the design space (Pardalos et al. 2017).

Although weight minimization for the multiphysics problem is addressed in topology optimization, weight minimization is reaching the physical limit of the bulk material. Nature is successfully dealing with this matter by implementing cellular structures (for example bones, and plants skeletons). To mimic the nature, researches were conducted to make porous designs instead of bulks to furtherly decrease the weight of the product, and with maintaining high strength and robustness at the same time (Stampfl et al. 2004; Ajdari et al. 2008; Gibson et al. 1982; Gibson 1989). This led to implementing multiscale optimization to design macrostructure and microstructure at the same time (Wu et al. 2021). To perform integrated multiscale structural design, the macrostructures and the microstructures are designed simultaneously, to assimilate the spatial field response between microstructural properties (i.e., the effective elastic and heat conductivity tensors) and the macroscale layouts. To directly optimize the material attribute (such as elastic tensor) of each element, free material optimization was proposed (Ringertz 1993; Bendsoe et al. 1994). Rodrigues et al. (2002) introduced the SIMP technique for hierarchical macrostructure and microstructure optimization, and many researchers have since done research of concurrent multiscale optimization (Li et al. 2019; Liu et al. 2020, 2008; Xu and Xie 2015; Wang et al. 2018; Yan and Cheng 2020). Some work was performed to extend multiscale mechanical stiffness maximization to including thermal bulk conductivity extremum of microscale only (Yan et al. 2015). However, multiscale and multiphysics concurrent topology optimization has not yet been performed. This work’s objective is to introduce and examine the formulations of full-scale concurrent topology optimization for multiphysics problem of maximizing structural stiffness and heat conductivity on the macro and the microscale. The work is implementing the normalized weight sum of multi-objective functions to solve this multiphysics problems. The formulations and the sensitivity analysis are introduced. And since MATLAB is a high-level programming language that is known for being used to solve a wide range of scientific problems with optimizing the time of coding, this paper presents a MATLAB program for solving the multiscale and multiphysics problem. The program was written taking into consideration, the simplicity, the ease of connotation of mathematical concepts in the program, and compatibility with most available MATLAB versions.

As such, the paper is organized as follows: Section 2 is dedicated to the mathematical modeling of multiscale topology optimization methods introduction. In Section 3, the formulations of the mathematical modeling of multi-objective for the multiphysics of maximizing the heat conduction and mechanical stiffness are discussed. The normalized sum of multi-objective function and sensitivity analysis are derived. Also, the systematic step to perform multiscale multiphysics optimization is summarized. Section 4 is dedicated to describing the numerical implementation of Sections 2 and 3 for the numerical layout as MATLAB code. Section 5 is dedicated to resenting the numerical models and presenting the results. Finally, the concluding remarks are presented in Section 6. A MATLAB code for the concurrent multiphysics multiscale optimization problem utilizing the SIMP method is also provided in Appendix 1 to provide the reader, particularly the newcomer to the topic of multiscale topology optimization, with a brief and easy-to-use example of how to perform the multiphysics multiscale problem for maximizing heat conduction and structural mechanical stiffness.

2 Mathematical modeling for mechanical and heat conductivity on micro and macroscales

A concurrent topology optimization framework is performed by introducing two separate representations of the design problem, i.e., macro and microscale domains. Macro and microscale design domains are discretized using two distinctive finite element systems such that the design variables (i.e., the artificial densities) associated with discretization for topology optimization are \({\mathbf{x}}_{\text{M}}\) and \({\mathbf{x}}_{\text{m}}\), respectively. Here, SIMP is adopted as a material interpolation scheme to describe the flow of the updating material distribution. The microscale structure, by design, is considered as representative volume element (RVE) which is statistically homogeneous with respect to the macroscale domain. By utilizing the numerical homogenization method, the effective properties are calculated for the microstructure. These effective properties are used as the macroscale’s base material constant tensors, i.e., the effective conductivity tensor \({{\varvec{\Lambda}}}^{\text{H}}\) and the elastic tensor \({\mathbf{E}}^{\text{H}}\) in this study. In this work, the thermal conductivity is considered uniformly distributed within the material with no interface layer of the void and material such that the interface layer of the RVE is assumed to be a single-phase infinitesimal solid material and void. Also, the heat is in a linear form such that, the high transmission rate is not been considered. Similarly, for elastic tensor, small deformation is considered (ideal elastic range). Homogenization is performed numerically using finite element method by setting periodic boundary conditions on the RVE and calculating the effective properties in terms of the average field. The periodic boundary condition has been chosen such that the boundaries of opposite edges within the cell finite element model are linked with identical displacement functions that interpolate the displacement in terms of the discretization segments (Hollister and Kikuchi 1992). To ease the calculations, the microstructure’s finite element model has to be bilinear and structured mesh. The detailed derivative of homogenization theory of RVE is not the main topic of this research, therefore; a brief explanation and the key equation for multiscale topology optimization are given in the following section. For more detailed derivatives and investigation, the basics of homogenization theory, the reader may refer to these references (Hill 1965; Hassani and Hinton 1998; Qin and Yang 2008).

2.1 Effective elasticity tensor and mechanical compliance derivative for multiscale

Let us start the investigation for the evaluation of the effective elastic tensor, and starting from the assumption that using homogenization approach, Hooks law in tensor for 2D problem is taking the tensor form shown in Eq. (1)

$$\left\{ {\begin{array}{*{20}c} {\sigma_{x} } \\ {\sigma_{y} } \\ {\tau_{xy} } \\ \end{array} } \right\} = \left[ {\begin{array}{*{20}c} {E_{11} } & {E_{12} } & {E_{14} } \\ {E_{21} } & {E_{22} } & {E_{23} } \\ {E_{31} } & {E_{32} } & {E_{33} } \\ \end{array} } \right]\left\{ {\begin{array}{*{20}c} {\varepsilon_{x} } \\ {\varepsilon_{y} } \\ {\varepsilon_{xy} } \\ \end{array} } \right\}.$$
(1)

To calculate effective elastic tensor of the RVE of a volume V, Eq. (2) is used:

$${\mathbf{E}}_{{}}^{\text{H}} = \frac{1}{\left| V \right|}\int\limits_{V} {{\mathbf{E}}_{ijqp}^{{}} \left( {{{\varvec{\upvarepsilon}}}_{qp}^{0(kl)} - {{\varvec{\upvarepsilon}}}_{qp}^{*(kl)} } \right)} \,dV,$$
(2)

where \({\mathbf{E}}_{{}}^{\text{H}}\) is the homogenized elastic tensor, \({\mathbf{E}}_{ijqp}^{{}}\) is the elastic tensor of the ingredient materials that consisting the RVE, \({{\varvec{\upvarepsilon}}}_{qp}^{0(kl)}\) is the linearly independent unit strain test (as shown in Fig. 1), and \({{\varvec{\upvarepsilon}}}_{qp}^{*(kl)}\) is periodic characteristic strain which is obtained by solving Eq. (3)

$$\int\limits_{{\Omega_{m} }} {{\mathbf{E}}_{ijqp} {{\varvec{\upvarepsilon}}}_{qp}^{*(kl)} \partial \gamma_{n} dV = \int\limits_{{\Omega_{m} }} {{\mathbf{E}}_{ijqp} {{\varvec{\upvarepsilon}}}_{qp}^{0(kl)} \partial \gamma_{n} } } dV,$$
(3)
Fig. 1
figure 1

The three mechanical deformation modes of 2D RVE

where \(\partial \gamma_{n}\) is the arbitrary virtual displacement associated with unit strain case. Equation (2) is solved for the three cases of kl = 11, 22, and 12, respectively, within Eq. (3). Returning to macroscale of the problem, the structure compliance in terms of the micro and macrodesign variables (\({\mathbf{x}}_{\text{M}}\) and \({\mathbf{x}}_{\text{m}}\), respectively) is given by

$$C_{mech} \left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right)\, = \sum\limits_{i = 1}^{N} {{\mathbf{U}}_{i}^{T} } {\mathbf{K}}_{i} \left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right){\mathbf{U}}_{i} ,$$
(4)

where Ui and Ki represent the nodal displacement and the stiffness matrix of the ith element with respect to the macrostructure of the total number of the element equal to N. The general form of the elemental stiffness matrix is taking the form:

$${\mathbf{K}} = \int\limits_{V} {{\mathbf{B}}^{T} {\mathbf{E}}} {\mathbf{B}}dV,$$
(5)

where \({\mathbf{B}}\) is the strain displacement matrix, and \({\mathbf{E}}\) is the elastic tensor of the element. For microstructure case, the elastic tensor \({\mathbf{E}}_{ijqp}^{\text{m}}\) is formulated to comply with the SIMP interpolation scheme such that, the penalized design variable \({\mathbf{x}}_{\text{m}}\) to power (\(p = 3\); Bendsøe 1989) is associated with the elastic tensor of the based material \({\mathbf{E}}_{ijqp}^{0}\) such that

$${\mathbf{E}}_{ijqp}^{\text{m}} = {\mathbf{x}}_{\text{m}}^{3} {\mathbf{E}}_{ijqp}^{0} .$$
(6)

The associated effective elastic tensor of the microstructure \({\mathbf{E}}^{\text{H}}\), which is calculated using homogenization method as shown in Eq. (7) is used to establish the elemental elastic tensor of the macroscale \({\mathbf{E}}_{macro}\) with similar material interpolation scheme as for the microstructure system.

$${\mathbf{E}}^{\text{H}} = \frac{1}{\left| V \right|}\int\limits_{V} {{\mathbf{E}}_{ijqp}^{\text{m}} \left( {{{\varvec{\upvarepsilon}}}_{qp}^{0(kl)} - {{\varvec{\upvarepsilon}}}_{qp}^{*(kl)} } \right)} \,dV,$$
(7)
$${\mathbf{E}}_{macro} = {\mathbf{x}}_{\text{M}}^{3} {\mathbf{E}}^{\text{H}} .\,\,\,\,$$
(8)

2.2 Effective heat conductivity tensor and thermal compliance derivative for multiscale

For evaluating the effective heat conductivity tensor \({{\varvec{\Lambda}}}_{{}}^{\text{H}}\), and with similar analogy to Eq. (2) gives

$${{\varvec{\Lambda}}}_{{}}^{\text{H}} = \frac{1}{\left| V \right|}\int\limits_{V} {{{\varvec{\Lambda}}}_{ijqp}^{{}} \left( {{\mathbf{G}}_{qp}^{0(kl)} - {\mathbf{G}}_{qp}^{*(kl)} } \right)} \,dV,$$
(9)

where \({\mathbf{G}}_{qp}^{0(kl)}\) represents the unit temperature gradient test, and \({\mathbf{G}}_{qp}^{*(kl)}\) periodic characteristic gradient. Also, the finite element representation of the steady-state heat conduction problem using finite element is taking the form:

$${\mathbf{P}} = {\mathbf{K}}^{th} {\mathbf{T}},$$
(10)

where \({\mathbf{P}}\) is the nodal thermal load, \({\mathbf{T}}\) is the nodal temperature, and \({\mathbf{K}}^{th}\) is the global heat conductivity matrix. Topology optimization of design high thermal conductive structure to weight ratio is achieved by minimizing heat compliance \(C_{\text{H}}\).

$$C_{{H}} = {\mathbf{P}}^{T} {\mathbf{T}}.$$
(11)

Here, the heat compliance in terms of the macro and microdesign variables is given by Eq. (12).

$$C_{{H}} \left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right)\, = \sum\limits_{i = 1}^{N} {{\mathbf{T}}_{i}^{T} } {\mathbf{K}}_{i}^{th} \left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right){\mathbf{T}}_{i}$$
(12)

where Ti and Ki represent the nodal temperature vector, and the thermal conductivity matrix of the i.th element with respect to the macrostructure of the total number of the element equal to N. The general form of the thermal conductivity matrix is taking the form:

$${\mathbf{K}}^{th} = \int\limits_{V} {{\mathbf{D}}^{T} {{\varvec{\Lambda}}}\,} {\mathbf{D}}\,dV,$$
(13)

where \({\mathbf{D}}\) is the conversion matrix of temperature gradient to nodal temperature. For microstructure domain, the material’s thermal conductivity tensor \({{\varvec{\Lambda}}}_{ijqp}^{\text{m}}\) is formulated similarly to the elastic tensor of Eq. (7), and it is associated with heat conductivity tensor of the based material \({{\varvec{\Lambda}}}_{ijqp}^{0}\) and the microdesign variable \({\mathbf{x}}_{\text{m}}\) such that

$${{\varvec{\Lambda}}}_{ijqp}^{\text{m}} = {\mathbf{x}}_{\text{m}}^{3} {{\varvec{\Lambda}}}_{ijqp}^{0} ,$$
(14)

where \({{\varvec{\Lambda}}}^{\text{H}}\) is calculated using the homogenization method (as shown in Eq. (15)) and is also used to establish the elemental heat conductivity tensor of the macroscale \({{\varvec{\Lambda}}}_{macro}\) with a similar material interpolation scheme as for the microstructure system (As shown in Eq. (16)).

$${{\varvec{\Lambda}}}_{{}}^{\text{H}} = \frac{1}{\left| V \right|}\int\limits_{V} {{{\varvec{\Lambda}}}_{ijqp}^{\text{m}} \left( {{\mathbf{G}}_{qp}^{0(kl)} - {\mathbf{G}}_{qp}^{*(kl)} } \right)} \,dV,$$
(15)
$${{\varvec{\Lambda}}}_{macro} = {\mathbf{x}}_{\text{M}}^{p} {{\varvec{\Lambda}}}^{\text{H}} .$$
(16)

Figure 2 is summarizing the modeling of multiscale topology optimization for stiffness and heat conductivity problems.

Fig. 2
figure 2

Micro and macroscales coupling for mechanical and heat conductivity cases for multiscale optimization

3 Multi-objective optimization of heat conductivity and mechanical stiffness

In this section, we will go over the fundamentals of optimization before moving on to multiphysics optimization. Furthermore, multiphysics of multi-objective optimization for minimizing heat, and mechanical compliance will be derived and summarized.

3.1 Multiphysics topology optimization fundamentals

Topology optimization is a methodology that has the same concepts as the orthodox parametric optimization methods. Generally speaking, optimization is the process of finding the extrema of a mathematically modeled problem. The model consists of variables, constraints (if any), and the objective function. Variables define the objective function formulation, optimization methodology, and even the constraints. Constraints if it has been introduced to the optimization process will guide the solution to what so-called feasibility scope of the solutions set. The objective function (presuming the smoothness through the design period) is the one that took the extremum process. As optimization is the process for which, a search for extrema is conducted for the design space bounded by the objective function using search algorithms, the extrema are identified for the function in terms of the design variable to be chosen, which also control the foundation of the objective function. Luckily, for the nonparametric optimization methods (i.e., topology optimization), the discretization representatives are chosen, which makes the change in the objective function will not heavily affect the design topological freedom (due to the implicit nature of the topology representation within the objective function). For this study, two distinctive sets are used to represent the macro (\({\mathbf{x}}_{M}\)) and microartificial (\({\mathbf{x}}_{m}\)) densities. The extrema of the objective function are considered as global when the design variables are satisfying the following criterion:

$$\,f({\mathbf{x}}_{\text{M}}^{*} ,{\mathbf{x}}_{\text{m}}^{*} ) < f({\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} )\,\,,\{ {\mathbf{x}}_{\text{M}}^{*} ,{\mathbf{x}}_{\text{m}}^{*} \} \ne \{ {\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} \} ,\forall \{ {\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} \} \, \in {\mathbf{R}},$$
(17)

while strong local extrema lay on the neighborhood area \(N({\mathbf{x}}_{\text{M}}^{*} ,{\mathbf{x}}_{\text{m}}^{*} )\) at which the global extrema existed. This remark is generally applied for many functions; however, the researcher should consider the functional behavior within the design space before considering this assumption. The objective function is created and, in certain circumstances, substantially rectified in order to get the satisfactory extrema. Also, the degree of objective function convexity is important factor to be considered to identify the best solution with the sensitivity analysis. The more convexity existed; the more global extrema solutions are possible. Convexity can be described clearly by the following: Consider the set in which the distance of each two points within the envelope of the objective function in it as follows:

$$L = \left\{ {({\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} )|({\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} ) = ({\mathbf{x}}_{\text{M}}^{a} ,{\mathbf{x}}_{\text{m}}^{a} ) + \lambda (({\mathbf{x}}_{\text{M}}^{a} ,{\mathbf{x}}_{\text{m}}^{a} ) - ({\mathbf{x}}_{\text{M}}^{b} ,{\mathbf{x}}_{\text{m}}^{b} )),\lambda \in {\mathbf{R}}} \right\}.$$
(18)

The function \(f\) is convex such that

$$f(\lambda + (1 - \lambda )({\mathbf{x}}_{\text{M}}^{a} ,{\mathbf{x}}_{\text{m}}^{a} )) \le \lambda f(({\mathbf{x}}_{\text{M}}^{b} ,{\mathbf{x}}_{\text{m}}^{b} )) + (1 - \lambda )f({\mathbf{x}}_{\text{M}}^{a} ,{\mathbf{x}}_{\text{m}}^{a} ).$$
(19)

This can be described graphically in Fig. 3 in terms of minimization. The global minimum in n-dimensional design space, is existing such that

$$f({\mathbf{x}}) \ge f({\mathbf{x}}^{*} )\,\,,\forall \,{\mathbf{x}} \in {\mathbb{R}}^{n} .$$
(20)
Fig. 3
figure 3

Functional example of convexity

In general, optimality smoothness is important for attaining a good sensitivity analysis and robust solution which can be achieved by approximation of the problem to be confined within the smooth mathematical formulation. The approximation is extensively used for modeling engineering problems. Getting a global extremum can be a difficult task since the path of the function test is usually confined by the local extremum (Fig. 4). For example, minimization problems are searching and seeking the global minima (Fig. 4), so it highly probably hits a local minimum especially if the local minima are strong. Random multi-start application of the local minimization process is a practical approximation to find the global minimum. So, the minimum value was obtained after several “sufficient trials.” The number of trials is proportional to the degree of convexity.

Fig. 4
figure 4

Mathematical optimization with multiple minima

Consider the set in which the distance of each two points in the Saddlepoint (Fig. 4) is

$$\left\{ {{\mathbf{x}}|{\mathbf{x}} = x^{a} + \Delta (x^{a} - x^{b} ),\,\,\Delta \in \,{\mathbb{R}}^{n} } \right\}.$$
(21)

With the presumption of smoothness in second-order differentiation (\(f({\mathbf{x}}) \in {\mathbb{R}}^{2}\)), the single variable function (\(F(\Delta )\)) along the line (\(\overline{{x^{a} x^{b} }} = {\mathbf{x}}(\Delta ) = {\mathbf{x^{\prime}}} + \Delta {\mathbf{u}}\)) is

$$F(\Delta ) = f({\mathbf{x}}(\Delta )) = f({\mathbf{x^{\prime}}} + \Delta {\mathbf{u}}).$$
(22)

The first-order derivative is

$$\frac{dF(\Delta )}{{d\Delta }} = \left. {\frac{{df({\mathbf{x}}(\Delta ))}}{d\Delta }} \right|_{u} = \nabla^{T} f({\mathbf{x}}(\Delta ))u,$$
(23)

while the second-order derivative is

$$\frac{{d^{2} F(\Delta )}}{{d\Delta^{2} }} = \nabla^{T} (\nabla^{T} f({\mathbf{x}}(\Delta )){\mathbf{u}}){\mathbf{u}} = {\mathbf{u}}^{T} {\mathbf{H}}({\mathbf{x}}(\Delta )){\mathbf{u}},$$
(24)

where \({\mathbf{H}}({\mathbf{x}}(\Delta ))\) is widely known as the Hessian matrix. If the Hessian matrix is positive definitive for all the points within the chosen test set and the tangent of the function is zero, then the point is a strong minimum. The Hessian matrix is used efficiently for seeking an extremum; however, it will impact the computational efficiency due to the extra numerous calculations. As such, this work is not using the second-order derivative to decrease the computational cost. In order to extremum function, generally, a direct search algorithm is commonly used. It starts from a starting point of estimated strong convexity. The general extremum optimality criterion takes the form:

$$\begin{gathered} Extremum\,\,F(\delta )\, = f({\mathbf{x}}^{i - 1} + \delta \,{\mathbf{u}}^{i} ) \hfill \\ \left\| {{\mathbf{x}}^{i} - {\mathbf{x}}^{i - 1} } \right\|\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, < \,\varepsilon_{1} \hfill \\ \left\| {\nabla f({\mathbf{x}}^{i} )} \right\|\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\, < \,{{\varepsilon}}_{2} \hfill \\ \left\| {f({\mathbf{x}}^{i} ) - f({\mathbf{x}}^{i - 1} )} \right\|\,\,\, < \,\varepsilon_{3} \hfill \\ \end{gathered}$$
(25)

where \(\varepsilon_{1 \to 3}\) are larger than zero.

For robustness, constraint usually implies to specify the searching area. These conditions whether they have equality or inequality properties, are playing an important role for confining the design to “feasible search space.” Searching algorithm is starting from an assumed point, and then the search is marching with controlled speed by the searching step (As shown in Fig. 4).

Extremizing function with special conditions (i.e., constraints) will lead to attaining what the so-called feasibility of the designed problem. Constraint extremum can be transformed into substitute unconstraint optimization by introducing penalty function form.

$$\left. {\begin{array}{*{20}c} {Extremum\,\,\,f({\mathbf{x}})} \\ {s.t.\,\,\,\,\,g({\mathbf{x}})} \\ \end{array} } \right\} \to Extremum\,P({\mathbf{x}}) = f({\mathbf{x}}) + \sum {\beta g^{2} ({\mathbf{x}})} ,$$
(26)

where (β) is the penalty parameter. Choosing penalty parameters is crucial for the optimization problem. Furthermore, the Lagrangian function is another method that is successfully applied for solving the constraint problem. This is done by introducing Lagrange multipliers (\(\ell\)).

$$\left. {\begin{array}{*{20}c} {Extremum\,\,\,f({\mathbf{x}})} \\ {s.t.\,\,\,\,Cond = \left\{ {\begin{array}{*{20}c} {g({\mathbf{x}}) = 0} \\ {h({\mathbf{x}}) = 0} \\ \end{array} } \right.\,} \\ \end{array} } \right\} \to Extremum\,P({\mathbf{x}},\ell ) = f({\mathbf{x}}) + \sum {\ell Cond} .$$
(27)

Constraint’s type plays an important role in solving the optimization problem. In general, the constraints are classified as equality constraints (g(x) = 0), and non-equality constraints (g(x) < 0). In this work, the Lagrange method with equality constraint is adopted as main method of updating the design variables. The process is discussed in detail in Sects. 47 and the associated program is given in Appendix A1-7. Optimizing with search Lagrangian is considerably fast, but the search speed will degrade with increasing the problem resolution (i.e., the number of elements in both, the macro (\(\Omega_{dM}\)) and microdesign (\(\Omega_{dm}\))domains). There are some techniques to speed up the process that used adaptive acceleration for the searching process by changing the search steps based on some statistical measurements, yet this is beyond the scope of this paper. Moreover, there are metaheuristic optimization methods (Benaissa et al. 2021) that do not necessitate sensitivity analysis. However, for topology optimization, metaheuristic approach will take a huge computational cost which makes it not suitable for the multiscale and multiphysics topology optimization problems.

Multiphysics problem generally consists of models that might not have something in common except the physical layout. The optimization of the multiphysics is taking the form of extremum, a set of collective sub-functions (i.e., multi-objective optimization). The challenging task is to optimize the problem in the best way possible by taking into consideration the conflict of the design variable’s update for each sub-function (i.e., to optimize with a good trade-off).

In general, the solution of the multi-objective problem has multiple solutions. As such, solving a specific multi-objective function formulation might require a sufficient condition for Pareto optimality. In the best-case scenario for multi-objective optimization problem, a dominant solution may obtain. The dominant solution by definition should be strictly better than all solutions for one sub-function and least good as the other solution for the rest of the sub-functions. If the solution is satisfying, the later conditions alone are called the Pareto solution. The general form of multi-optimization is shown in Eq. (28).

$$\begin{gathered} find\,\mathop {Extremum}\limits_{{{\mathbf{x}} \in {\text{A}} }} \,\,\,{\text{x}} \, \mapsto \overline{f}({\mathbf{x}}) = (f_{1} ({\mathbf{x}}),f_{2} ({\mathbf{x}}),..,f_{n} ({\mathbf{x}})) \hfill \\ {\text{A}} \, = \,\left\{ {{\mathbf{x}} \in {\mathbb{R}}|\,g_{i} ({\mathbf{x}}) \le 0,i = 1,2,..,k} \right\}, \hfill \\ \end{gathered}$$
(28)

where \(\overline{f}({\mathbf{x}})\) is the multi-objective function of the nth sub-functions, and the design variable \({\mathbf{x}}\) is searched within the feasible region (\({\text{A}} \subset {\mathbb{R}}\)). The feasibility is bounded by suitable constraints \(g_{i} ({\mathbf{x}})\).

One of the most common configurations of the multi-objective function is to transform it to a sum of the sub-function. In this work, the multi-functions are reduced to a single function of the weighted sum of the multi-objective functions, and the weight is set before the optimization phase.

$$\overline{f} = \sum\limits_{i = 1}^{2} {w_{i} f_{i} } .$$
(29)

The fitness of the function's solution and prioritization is determined by the weight of an objective function (\(w_{i}\)). When an objective function is given significant weight, it indicates that it has higher importance than those with a smaller weight (As shown in Fig. 5).

Fig. 5
figure 5

Multi-objective functions optimization

Practically, the attainability of the design variable for all the objective functions does not necessarily exist. This means that the Pareto front may not be properly represented for the objective functions, and the competitiveness might lead to a non-proper Pareto optimal solution, but first, we need to define what is the proper Pareto. The proper Pareto front contains the solution \({\mathbf{x}}\) such that for each sub-objective function \(f_{i}\), there exists at least one \(f_{j}\) such that

$$f_{j} \left( {{\mathbf{x}} } \right) < f_{j} \left( {{\mathbf{x}}_{{}}^{*} } \right)\,\,\,and,\,\,\,\frac{{f_{i} \left( {{\mathbf{x}}_{{}}^{*} } \right) - f_{i} \left( {{\mathbf{x}} } \right)}}{{f_{j} \left( {{\mathbf{x}} } \right) - f_{j} \left( {{\mathbf{x}}_{{}}^{*} } \right)}} \le M,$$
(30)

where \(M\) is a scalar larger than 0. To efficiently achieve a good trade-off, the multi-objective problem is usually rearranged with some modification methods (Jeyakumar et al. 2010; Kashfi et al. 2011; Yun et al. 2001; Rao and Freiheit 1991; Shimoda et al. 1995). The method of normalization has been reported as one of the most reliable methods for achieving proper multi-objective optimization such that no single function is over-privileged due to its initial value (Koski and Silvennoinen 1987; Rao and Freiheit 1991). In this work, we adopt the goal programming method (Ramos et al. 2014; Shimoda et al. 1995), such that it is searching for the goal of attaining the solution vector that makes the multi-objective function to be as close as possible to the minimum of each constitutive objective functions. The Pareto front for goal programming method shows the best possible solutions for each weighting criteria, but the knee point on the Pareto front which has the shortest distance from the utopia point (Fig. 5) is considered as the general best. The normalization objective function for the goal programming method is taking the form:

$$f_{i}^{normalized} = \frac{{f_{i} - f_{{_{i} }}^{Best} }}{{f_{{_{i} }}^{Worst} - f_{{_{i} }}^{Best} }},$$
(31)

where \(f_{{_{i} }}^{Best}\) and \(f_{{_{i} }}^{Worst}\) are calculated for each objective function.

3.2 Multiphysics optimization for heat conductivity and mechanical stiffness maximization

In order to maximize heat conductivity, heat compliance \(C_{H}\) is minimized. Using the same analogy, mechanical stiffness maximization is achieved by minimizing mechanical compliance \(C_{mech}\). The generalized form of the main mechanical objective function takes the form:

$$\begin{gathered} \min \,\,:\,C_{H} \left( {{\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} } \right),C_{mech} \left( {{\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} } \right)\, \mapsto \,\overline{f}_{{}} \left( {C_{H} ,C_{mech} } \right)\, = \overline{f}_{{}} \left( {f_{\kappa } ,f_{c} } \right) \hfill \\ {\text{s}} .t.\,\,\left\{ \begin{gathered} \,{\mathbf{K}}\left( {{\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} } \right){\mathbf{U}} = {\mathbf{F}} \hfill \\ \,{\mathbf{K}}^{th} \left( {{\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} } \right){\mathbf{T}} = {\mathbf{P}} \hfill \\ \end{gathered} \right. \hfill \\ \,\,\,\,\,\,\,\,\,\int\limits_{{\Omega_{dM} }}^{{}} {{\mathbf{x}}_{\text{M}} d{\mathbf{x}}_{\text{M}}^{{}} \, \le \,\,v_{\text{M}} \,\,,\,\,0\, < {\mathbf{x}}_{\text{M}} < 1\,\,\,\,\,\,\,\forall {\mathbf{x}}_{\text{M}} \in \,\,\Omega_{dM} } \hfill \\ \,\,\,\,\,\,\,\,\int\limits_{{\Omega_{dm} }}^{{}} {{\mathbf{x}}_{\text{m}} d{\mathbf{x}}_{\text{m}}^{{}} \, \le \,\,v_{\text{m}} \,\,,\,\,0\, < {\mathbf{x}}_{\text{m}} < 1\,\,\,\,\,\,\,\forall {\mathbf{x}}_{\text{m}} \in \,\,\Omega_{dm} } \hfill \\ \end{gathered}$$
(32)

where \(v\) are the volume fraction constrain of the macro-\(\left( {} \right)_{\text{M}}\) and microsystem \(\left( {} \right)_{\text{m}}\). As such, transforming the objective function to the normalized form is adopted in this work, and it takes the form of

$$\overline{f}_{{}} \left( {{\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} } \right) = w_{1} \overline{f}_{c} + w_{2} \overline{f}_{k} = w_{1} \frac{{f_{c} - f_{c}^{*} }}{{f_{c}^{ini} - f_{c}^{*} }} + w_{2} \frac{{f_{\kappa } - f_{\kappa }^{*} }}{{f_{\kappa }^{ini} - f_{\kappa }^{*} }},$$
(33)

where \(f_{c}^{*}\) and \(f_{\kappa }^{*}\) are, respectively, the function at the attainable design for the compliance and thermal conductivity problems, which is calculated by optimizing each case separately and evaluate each objective function to the optimal design. \(f_{c}^{ini}\) and \(f_{\kappa }^{ini}\) are, respectively, the compliance of the initial topology and the thermal conductivity of the microstructure respectively. \(w_{1}\) and \(w_{2}\) are the weighting factors such that \(w_{1} + w_{2} = 1\). In terms of normalized multi-objective functions that are used as the target of multiscale and multiphysics topology optimization in this work, it takes the form:

$$\begin{gathered} \min \,\,:\,w_{1} \frac{{f_{c} - f_{c}^{*} }}{{f_{c}^{ini} - f_{c}^{*} }} + w_{2} \frac{{f_{\kappa } - f_{\kappa }^{*} }}{{f_{\kappa }^{ini} - f_{\kappa }^{*} }} \hfill \\ {\text{s}} .t.\,\,:\,\left\{ \begin{gathered} \,{\mathbf{K}}\left( {{\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} } \right){\mathbf{U}} = {\mathbf{F}} \hfill \\ \,{\mathbf{K}}^{th} \left( {{\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} } \right){\mathbf{T}} = {\mathbf{P}} \hfill \\ \end{gathered} \right. \hfill \\ \,\,\,\,\,\,\,\,\,\,\int\limits_{{\Omega_{dM} }}^{{}} {{\mathbf{x}}_{\text{M}} d{\mathbf{x}}_{\text{M}}^{{}} \, \le \,\,v_{\text{M}} \,\,,\,\,0\, < {\mathbf{x}}_{\text{M}} < 1\,\,\,\,\,\,\,\forall {\mathbf{x}}_{\text{M}} \in \,\,\Omega_{dM} } \hfill \\ \,\,\,\,\,\,\,\,\,\int\limits_{{\Omega_{dm} }}^{{}} {{\mathbf{x}}_{\text{m}} d{\mathbf{x}}_{\text{m}}^{{}} \, \le \,\,v_{\text{m}} \,\,,\,\,0\, < {\mathbf{x}}_{\text{m}} < 1\,\,\,\,\,\,\,\forall {\mathbf{x}}_{\text{m}} \in \,\,\Omega_{dm} } . \hfill \\ \end{gathered}$$
(34)

Optimization is necessitating sensitivity analysis in order to establish the search algorithm for finding the extremum point. For the function shown in Eq. (34), and because the denominator is a fixed value with respect to the objective function, the sensitivity of the function itself is given as shown in Eq. (35).

$$\begin{gathered} d\overline{f}_{{}} = \frac{{w_{1} df_{c} }}{{f_{c}^{ini} - f_{c}^{*} }} + \frac{{w_{2} df_{\kappa } }}{{f_{\kappa }^{ini} - f_{\kappa }^{*} }}. \hfill \\ \hfill \\ \end{gathered}$$
(35)

In terms of variation design, the adjoint variable method is utilized to provide a coherent formulation for representing response variation and reduce the computational time and numerical accumulative error, compared to numerical derivatives. As shown in Eq. (34), the objective function is depending on the macro and microdesign variables, so the sensitivity has to be driven with respect to the variational densities \(\left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right)\). For the case of mechanical compliance, the sensitivity takes the form:

$$\dot{C}_{mech} \left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right) = {\dot{\mathbf{F}}}_{\text{M}}^{T} {\mathbf{U}}_{\text{M}} + {\mathbf{F}}_{\text{M}}^{T} {\dot{\mathbf{U}}}.$$
(36)

\({\dot{\mathbf{U}}}\) is obtained by differentiating (\({\mathbf{K}}\left( {{\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}^{{}} } \right){\mathbf{U}} = {\mathbf{F}}\))and separating the variables which give

$${\dot{\mathbf{U}}}_{\text{M}} = {\mathbf{K}}\left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right)^{ - 1} {\dot{\mathbf{F}}}_{\text{M}} - {\mathbf{K}}\left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right)^{ - 1} ({\dot{\mathbf{K}}}\left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right){\mathbf{U}}_{\text{M}} ).$$
(37)

And, by substituting Eq. (36) into Eq. (37), we obtain

$$\dot{C}_{mech} = 2{\dot{\mathbf{F}}}_{\text{M}}^{T} {\mathbf{U}}_{\text{M}} - {\mathbf{U}}_{\text{M}}^{T} {\dot{\mathbf{K}}}\left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right){\mathbf{U}}_{\text{M}} .$$
(38)

Because the problem is load independent; therefore, Eq. (38) is reduced to

$$\dot{C}_{mech} \left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right) = - {\mathbf{U}}_{\text{M}}^{T} {\dot{\mathbf{K}}}\left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right){\mathbf{U}}_{\text{M}} .$$
(39)

Equation (39) has two parts, first one is the sensitivity with respect \({\mathbf{x}}_{\text{M}}\) which is used to update the macroscale design domain. This derivative is shown in Eq. (40):

$$\dot{C}_{mech} \left( {{\mathbf{x}}_{\text{M}} } \right) = \frac{{\partial C_{mech} }}{{\partial {\mathbf{x}}_{\text{M}} }} = - p\left( {{\mathbf{x}}_{\text{M}}^{p - 1} } \right){\mathbf{U}}_{\text{M}}^{T} \int\limits_{{\left| {\Omega_{\text{M}} } \right|}} {{\mathbf{B}}_{\text{M}}^{T} {\mathbf{E}}^{\text{H}} \left( {{\mathbf{x}}_{\text{m}} } \right){\mathbf{B}}_{\text{M}} } d\Omega_{\text{M}} {\mathbf{U}}_{\text{M}} .$$
(40)

The second part is the microscale sensitivity \({\mathbf{x}}_{\text{m}}\), which is given in Eq. (41):

$$\dot{C}_{mech} \left( {{\mathbf{x}}_{\text{m}} } \right) = \frac{{\partial C_{mech} }}{{\partial {\mathbf{x}}_{\text{m}} }} = - \left( {{\mathbf{x}}_{\text{M}}^{p} } \right){\mathbf{U}}^{T} \int\limits_{{\left| {\Omega_{\text{m}} } \right|}} {{\mathbf{B}}_{\text{M}}^{T} \frac{{d{\mathbf{E}}^{\text{H}} \left( {{\mathbf{x}}_{\text{m}} } \right)}}{{d{\mathbf{x}}_{\text{m}} }}{\mathbf{B}}_{\text{M}} \,} d\Omega_{\text{m}} \,{\mathbf{U}}_{\text{M}} .$$
(41)

The derivative of the homogenized material’s elastic tensor with respect to microdesign variable \(\frac{{d{\mathbf{E}}^{\text{H}} \left( {{\mathbf{x}}_{\text{m}} } \right)}}{{d{\mathbf{x}}_{\text{m}} }}\) can be determined by taking Eq. (2) into consideration:

$$\frac{{d{\mathbf{E}}^{\text{H}} \left( {{\mathbf{x}}_{\text{m}} } \right)}}{{d{\mathbf{x}}_{\text{m}} }} = \frac{p}{{\left| {\Omega_{m} } \right|}}\int\limits_{{\Omega_{m} }} {\left( {{\mathbf{I}} - {\mathbf{B}}_{\text{m}} {\mathbf{U}}_{\text{m}} } \right)^{T} \left( {{\mathbf{x}}_{\text{m}}^{p - 1} } \right){\mathbf{E}}\left( {{\mathbf{I}} - {\mathbf{B}}_{\text{m}} {\mathbf{U}}_{\text{m}} } \right)} \;d\Omega_{m} \,.$$
(42)

And with a similar analogy, the sensitivity analysis for the heat compliance \(\dot{C}_{{H}} \left( {{\mathbf{x}}_{\text{M}} ,{\mathbf{x}}_{\text{m}} } \right)\) with respect to the macrodesign variable \({\mathbf{x}}_{\text{M}}\) is given in Eq. (43):

$$\dot{C}_{{H}} \left( {{\mathbf{x}}_{\text{M}} } \right) = \frac{{\partial C_{{H}} }}{{\partial {\mathbf{x}}_{\text{M}} }} = - p\left( {{\mathbf{x}}_{\text{M}}^{p - 1} } \right){\mathbf{T}}_{\text{M}}^{T} \int\limits_{{\left| {\Omega_{\text{M}} } \right|}} {{\mathbf{D}}_{\text{M}}^{T} {{\varvec{\Lambda}}}^{\text{H}} {\mathbf{D}}_{\text{M}} \,} d\Omega_{\text{M}} \,{\mathbf{T}}_{\text{M}} .$$
(43)

The second part is the derivative with respect to \({\mathbf{x}}_{\text{m}}\) is given in Eq. (44):

$$\dot{C}_{{H}} \left( {{\mathbf{x}}_{\text{m}} } \right) = \frac{{\partial C_{{H}} }}{{\partial {\mathbf{x}}_{\text{m}} }} = - {\mathbf{T}}^{T} \int\limits_{{\left| {\Omega_{\text{m}} } \right|}} {{\mathbf{D}}_{\text{M}}^{T} \frac{{d{{\varvec{\Lambda}}}^{\text{H}} \left( {{\mathbf{x}}_{\text{m}} } \right)}}{{d{\mathbf{x}}_{\text{m}} }}{\mathbf{D}}_{\text{M}} \,} d\Omega_{\text{m}} \,{\mathbf{T}}_{\text{M}} .$$
(44)

The derivative of the homogenized material’s thermal conductivity tensor with respect to microdesign variable \(\frac{{d{{\varvec{\Lambda}}}^{\text{H}} \left( {{\mathbf{x}}_{\text{m}} } \right)}}{{d{\mathbf{x}}_{\text{m}} }}\) can be determined similarly to the mechanical compliance case such that

$$\frac{{d{{\varvec{\Lambda}}}^{\text{H}} \left( {{\mathbf{x}}_{\text{m}} } \right)}}{{d{\mathbf{x}}_{\text{m}} }} = \frac{p}{{\left| {\Omega_{m} } \right|}}\int\limits_{{\Omega_{m} }} {\left( {{\mathbf{I}} - {\mathbf{D}}_{\text{m}} {\mathbf{T}}_{\text{m}} } \right)^{T} \left( {{\mathbf{x}}_{\text{m}}^{p - 1} } \right){{\varvec{\Lambda}}}\left( {{\mathbf{I}} - {\mathbf{D}}_{\text{m}} {\mathbf{T}}_{\text{m}} } \right)} \;d\Omega_{m} \,.$$
(45)

The optimization process can be summarized in the following steps:

Step 1: Define the design domain parameters for macro and microscale. The input parameters are the discretization size (number of elements in the x- and y-directions), the targeted volume fraction, and the material properties of the base materials that will be used for establishing the design of microstructure, concurrently with the macrostructure design.

Step 2: Preparing the design domain and the finite element analysis, such that a dedicated multiscale finite element model is built for each physical phenomenon of the design domain. Here, for a single physical model, we are considering each element of the macrodesign domain as a unit cell to be discretized using the microscale discretization system. Using the homogenization method, the effective macroscopic properties of the RVE are calculated by taking into consideration the robustly identifiable phases of the microscale consisting materials (Pélissou et al. 2009). Robustness here is referring to retrieving the ergodicity of mechanical properties of the chosen RVE for the macrostructure, such that, if the RVE size is infinitesimal, it will cause passing material phases out of consideration (Yvonnet 2019). As such, the size of the RVE to its sub-constructive phases should be big enough to assure numerical stability during the application of periodic conditions, as well as ensure a valid representation of the effective properties for the chosen macrostructure (Sab and Nedjar 2005).

Step 3: The calculation of the initial design values for the thermal and the mechanical compliances (\(f_{c}^{ini}\) and \(f_{\kappa }^{ini}\), respectively) is needed as the preparation to build the scalarized form of the normalized multi-objective function (Eq. (34)).

Step 4: Calculating the optimized results for each physical model to identify the values of \(f_{c}^{*}\) and \(f_{\kappa }^{*}\).

Step 5: Calculating the objective function of the macro and microscale (Eq. (34)). Because the summation of the weights is 1, therefore, the weighing can be written in terms of a general weight (\(\eta\)). As such, the weights are rewritten as \(w_{1} = \eta\), and \(w_{2} = (1 - \eta )\).

Step 6: Performing the sensitivity analysis and evaluating the design domains with the optimality criteria, and updating the design domain.

Step 7: Evaluating the design variables against the constraints function to satisfy the weight minimization condition for both, the macro and microdesign variables.

Step 8: Establishing the design domain by assigning the macrodesign variables \({\mathbf{x}}_{\text{M}}\) as 1 for solid element and associated it with microdesign variables \({\mathbf{x}}_{\text{m}}\) that have the value of 1 for solid, and 0 for the void of the microscale design domain. As the result, the layouts of the macrostructure and the microstructure are updated simultaneously. This will construe into a porous macrostructure with the highest possible heat conductivity and high stiffness with high weight reduction.

Step 9: Repeating steps 5–8 until the structural layout with the assigned constraint is satisfied.

The general algorithm for concurrent multiscale and multiphysics topology optimization for heat conductivity and mechanical stiffness maximization is illustrated in Fig. 6.

Fig. 6
figure 6

Flowchart of concurrent multiscale heat and stiffness optimization

4 MATLAB code description

The concurrent multiscale optimization steps for the multiphysics problem that are given in Sect. 3.2 are presented practically in a MATLAB code which is shown in Appendix 1. This code is utilizing the SIMP method for topology optimization. The MATLAB codes of topology 88-line and homogenization programs by Andreassen et al. (Andreassen et al. 2011; Andreassen and Andreasen 2014) are used as a starting point. The MATLAB code consists of seven parts that are distributed on several separated MATLAB files for the purpose of providing highly customizable code for the readers. The MATLAB code parts are the input data part, the finite element preparations, calculating the normalization factors, asymptotic homogenization, constructing the goal programming multi-objective function, and finally performing the concurrent multiscale optimization. These parts are divided between 7 MATLAB functions which are Concurrent_MOO.m, get_Initials.m, Concurrent_solver.m, Homogenization_full.m, elementMatVec.m, Objective_Calculator.m, and OC_2D.m. The main program is Concurrent_MOO.m in which all the main optimization process and producing the data are happening. The other programs are functions that are called inside the main program (i.e., Concurrent_MOO.m). The program flow is shown in Fig. 7.

Fig. 7
figure 7

MATLAB code flow for multiphysics concurrent topology optimization

Fig. 8
figure 8

The input data section of MATLAB main code (Concurrent_MOO.m)

4.1 Input data

The main program is written in the main MATLAB file (i.e., Concurrent_MOO.m). The program is starting from line 4. In this line, the input of the microscale is listed: Micro_nelx and Micro_nely are the numbers of elements in the x- and y-directions, respectively.

Micro_volfrac is the volume fraction constraint on the microscale \(v_{\text{m}}\). penal is the power of the SIMP power-law function (\(P\) in Eq. (16)). Micro_rmin is the mesh independency filter radius which will be described latter in the description of optimality criteria section (Fig. 8).

In the same manner, the macroscale initial design domain spatial configurations are listed in line 6. The input of the macroscale of the problem: Macro_nelx and Macro_nely are the numbers of elements in the x- and y-directions respectively, and Macro_volfrac is the volume fraction constraint on the macroscale \(v_{\text{M}}\) which is written in line 7. The element aspect ratio with respect to the macroscale spatial configuration is dx and dy.

In line 9, the maximum iteration numbers maxIter of the optimization are identified. The mesh independence filtering method is density filtering which is placed in the function OC_2D.m. This filter is discussed in more detail in Sects. 47. Finally, the weighting factor of the multi-objective function that is described in Step5 in Sect. 3.2 is set as the constant eta (i.e., \(\eta\)) in line 9.

4.2 Finite element analysis of the macroscale structure

In our analysis, we have two models of heat and mechanical physics to be built in order to calculate the heat and mechanical compliances. Therefore, two dedicated finite element systems are used. Because the Eulerian base of analysis is used for SIMP method, i.e., the element weight which is represented by the design variable x is diminishing instead of deleting the non-desire element through the process of topology optimization, and it is possible to prepare the finite element frame prior to the optimization process. The element used for both heat and mechanical analysis is a structured bilinear element of a uniform length of unity (Fig. 9).

Fig. 9
figure 9

Bilinear quadratic element used

For the mechanical compliance physics, the finite element analysis preparations are presented in lines 11–22 (Fig. 10). The initial degree of freedom index for all elements is determined using the matrix Macro_nodenrs_mech, which is in a vector form named Macro_edofVec_mech. Finally, the Macro_edofVec_mech is utilized to calculate each element's eight degrees of freedoms indices and store it in the degree of freedom matrix Macro_edofMat_mech for efficient building of the stiffness matrix in the optimization loop. For the case in Fig. 11, which consists of 25 elements, the Macro_edofMat_mech is

Fig. 10
figure 10

Mechanical finite element section of MATLAB main code of the main function Concurrent_MMO.m

Fig. 11
figure 11

Node definition and degree of freedom for mechanical analysis

Macro_edofMat_mech = \(\left[ {\begin{array}{*{20}c} {\begin{array}{*{20}c} 3 & 4 & {11} & {\begin{array}{*{20}c} {12} & 9 & {10} & {\begin{array}{*{20}c} 1 & 2 \\ \end{array} } \\ \end{array} } \\ \end{array} } \\ {\begin{array}{*{20}c} 5 & 6 & {13} & {\begin{array}{*{20}c} {14} & {11} & {12} & {\begin{array}{*{20}c} 3 & 4 \\ \end{array} } \\ \end{array} } \\ \end{array} } \\ {\begin{array}{*{20}c} 7 & 8 & {15} & {\begin{array}{*{20}c} {16} & {13} & {14} & {\begin{array}{*{20}c} 5 & 6 \\ \end{array} } \\ \end{array} } \\ \end{array} } \\ {.\,\,\,\,\,\,\,\,\begin{array}{*{20}c} {.\,\,} & {.\,\,} & {.\,} & {\begin{array}{*{20}c} {.\,\,} & {.\,\,} & {.\,} & {\begin{array}{*{20}c} {.\,\,} & . \\ \end{array} } \\ \end{array} } \\ \end{array} } \\ \end{array} } \right]\begin{array}{*{20}c} { \leftarrow \,\,{\text{Element}} \,1} \\ { \leftarrow \,\,{\text{Element}} \,2} \\ { \leftarrow \,\,{\text{Element}} \,3} \\ {} \\ \end{array}\).

Then, the Macro_edofMat_mech matrix is used to produce the row and column index vectors (iK_mech and jK_mech, respectively, in lines 15 and 16). A Kronecker matrix product with the 8-length unit vector is used, followed by a reshaping procedure. These two vectors are used to build the global mechanical stiffness matrix for the macroscale case and will not change for the whole optimization process, such that, as been mentioned before, Eulerian approach is utilized in this work.

Displacement and forces are reserved in the computer’s ram with lines 17 and 18 (Fig. 10). The boundaries of the studied cases are in lines 19 and 20 (Fig. 10). Free degrees of freedom are identified in line 22 by subtracting the fixed degrees of freedom on line 20 from the full degrees of freedom that identified in line 21. As shown in Fig. 11, the degrees of freedom of the macroscale in the x- and y-directions are presented with the red and blue colors, respectively. The microdesign domain is following a similar analogy for assigning the degrees of freedom.

Similarly, for the heat conductivity problem, the finite element preparations are in a similar order of mechanical stiffness case, and it is listed in lines 24–34 (as shown in Fig. 12).

Fig. 12
figure 12

Mechanical finite element section of MATLAB main code of the main function Concurrent_MMO.m

4.3 Calculating the normalization factors for the multi-objective function

The next step is to calculate the factors that are used for the goal programming (Eq. (31)) i.e., utopia points (\(f_{{_{i} }}^{Best}\)) and nadir point (\(f_{{_{i} }}^{Worst}\)). These points are calculated for each objective function for each physics. These factors are calculated in a dedicated MATLAB functions (Concurrent_solver.m and Objective_Calculator.m, respectively). As presented in Eq. (34), nadir points (which are the initial design’s mechanical and heat compliances (i.e., \(f_{c}^{ini}\) and \(f_{\kappa }^{ini}\) respectively)) as well as the mechanical utopia point (\(f_{c}^{*}\)), and heat utopia point (\(f_{\kappa }^{*}\)) are needed to perform the multi-objective optimization (which are the separately optimized results for each physical model); therefore, in lines 36 to 46, the values of \(f_{c}^{ini}\) and \(f_{c}^{*}\) are calculated (As shown in Fig. 13). Also, \(f_{\kappa }^{ini}\) and \(f_{\kappa }^{*}\) are calculated in lines 49–58 as shown in Fig. 14. As shown in Figs. 13 and 14, this process is necessitating the call of several MATLAB functions. The process is given in more details in subsections 4–3-1 to 4–3-3.

Fig. 13
figure 13

Nadir and Utopia points for mechanical compliance of the main function Concurrent_MMO.m

Fig. 14
figure 14

Nadir and Utopia points for heat compliance of the main function Concurrent_MMO.m

4.3.1 Initial design domain initiation

In line 36, the initial sets of the macro and microscale are calculated with the sub-function get_Initials (in the functionget_Initials.m in Appendix 1–2). This function is constructing the initial macroscale set Macro_x and the initial microscale set Micro_x. The macrodesign domain is set to have an initial value equal to the 0.5 (as shown in Fig. 15). In line 38, the design variables Macro_x, and Micro_x are assigned to intermediate variables Macro_xPhys and Micro_xPhys to eliminate the possibility of accumulative error while handling.

Fig. 15
figure 15

Initial design domains of (a) the microstructure and (b) the macrostructure

Fig. 16
figure 16

The calculation of macro and micro-objective functions and sensitivity for macro and microscale

In line 39, the elastic tensor and the associated variables are calculated using the function Homogenization_full which are discussed in Sect. 4.3.2).

4.3.2 Homogenization and elemental stiffness matrix functions

For our MATLAB implementation of homogenization (i.e., Homogenization_full that is shown in Appendix 1–3), the finite element is also a bilinear (as shown in Fig. 9). The RVE in our case is a composite of two different phases, i.e., material and void. In this code, Lamé's constant (Juvinall 1967) representation is used. This is to decrease the computational time and compress the two physics’ effective properties calculations in one homogenization code.

Here, the same homogenization program is used for calculating the thermal and mechanical properties for the designed RVE; therefore, the identifier flag select_case is needed to identify which case to be calculated such that, for evaluating the elastic tensor, select_case should be 1 and 2 for evaluating the heat conductivity tensor. Lines from 2 to 11 are dedicated to preparing the input data for the homogenization process.

In line 8, Lambda is a vector that contains Lame's first parameter (\(\lambda\)) for the material and void. Similarly, mu is a vector with Lamé's second parameter (\(\mu\)). In line 12, the physical compatible elemental stiffness matrix is calculated using the function elementMatVec. Inside elementMatVec, the stiffness matrix is calculated as follows:

$${\mathbf{K}}_{{}} = \sum\limits_{{\text{e = 1}}}^{{\text{N}}} {{\mathbf{B}}_{{\text{e}}}^{{\text{T}}} {\mathbf{C}}_{{\text{e}}} {\mathbf{B}}_{{\text{e}}} {\text{dV}}_{{\text{e}}} .}$$
(46)

The assembly of \({\text{N}}\) finite elements is denoted by the summation, and \({\mathbf{C}}_{{\text{e}}}\) is the element's constitutive matrix, for which the 2D mechanical static physics of isotropic material is

$${\mathbf{C}}_{{\text{e}}} = {\mathbf{C}}_{\lambda } + {\mathbf{C}}_{\mu } ,$$
(47)

where \({\mathbf{C}}_{\lambda }\) and \({\mathbf{C}}_{\mu }\) are presented in Eqs. (48) and (49), respectively.

$${\mathbf{C}}_{\lambda } = \lambda_{{\text{e}}} \left[ {\begin{array}{*{20}c} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 0 & 0 & 0 \\ \end{array} } \right],$$
(48)
$${\mathbf{C}}_{\mu } = \mu_{{\text{e}}} \left[ {\begin{array}{*{20}c} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1 \\ \end{array} } \right].$$
(49)

So, in plane strain elements, Lamé’s parameters can be computed from material Young's modulus \(E_{{\text{e}}}\) and the Poisson’s ratio \(\nu_{{\text{e}}}\) as follows:

$$\lambda_{{\text{e}}} = \frac{{\nu E_{{\text{e}}} }}{{(1 + \nu_{{\text{e}}} )(1 - 2\nu_{{\text{e}}} )}}\,\,\,\,,\,\,\,\mu_{{\text{e}}} = \frac{{E_{e} }}{{2(1 + \nu_{{\text{e}}} )}}\,.\,\,\,\,\,\,\,\,\,\,\,\,$$
(50)

As such, for static mechanical case, the stiffness matrixis

$${\mathbf{K}} = \sum\limits_{{{\text{e}} = 1}}^{\text{N}} {({\mathbf{B}}_{{\text{e}}}^{{\text{T}}} {\mathbf{C}}_{\lambda } {\mathbf{B}}_{{\text{e}}} {\text{dV}} + {\mathbf{B}}_{{\text{e}}}^{{\text{T}}} {\mathbf{C}}_{\mu } {\mathbf{B}}_{{\text{e}}} {\text{dV}}} ).$$
(51)

The elemental stiffness matrix, which is the term between brackets of Eq. (51) is calculated in the function elementMatVec (As presented in Appendix 1–5) sis>within lines 18 to 36. Line 34 is giving the function the freedom to calculate the elemental stiffness matrix directly for the sensitivity analysis. The forcing vector in terms of Lamé’s parameters is calculated with a similar analogy as above in lines 37 and 38 (Fig. 16).

$${\mathbf{F}} = \sum {(\lambda_{{\text{e}}} {\mathbf{F}}}_{\lambda } + \mu_{{\text{e}}} {\mathbf{F}}_{\mu } ).$$
(52)

To calculate the heat conductivity tensor, the correspondent \({\mathbf{B}}_{{\text{e}}}\) and the degree of freedom are different (So in our finite element analysis of heat problem, the degree of freedom has similar numbering as node numbering which is shown in Figs. 11 and 17). \({\mathbf{C}}_{{\text{e}}}\) for heat physics takes the form (Fig. 18):

$${\mathbf{C}}_{{\text{e}}} = \mu_{e} \left[ {\begin{array}{*{20}c} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 0 \\ \end{array} } \right].$$
(53)
Fig. 17
figure 17

Finite element model example of 25 elements

Fig. 18
figure 18

The mesh independency filtering scheme

Fig. 19
figure 19

The mesh independency filter within the optimizer function

Fig. 20
figure 20

The spatial layout of the numerical examples

This technique allows the utilization of compressed code to calculate both physics’ stiffness matrices (i.e., \({\mathbf{K}}\) and \({\mathbf{K}}^{th}\)) in a compact code (Figs. 19, 20).

Returning to the homogenization code (Homogenization_full), the nodes and elemental degrees of freedom are calculated in lines 20 to 29. Lines 30 to 55 are the steps for the stiffness matrices assembly of homogenization problem and the calculations of the periodic characteristic strain and thermal gradient (i.e., \({{\varvec{\upvarepsilon}}}_{qp}^{*(kl)}\) and \({\mathbf{G}}_{qp}^{*(kl)}\), respectively).

The calculations of the linearly independent unit of strain and thermal gradient (\({{\varvec{\upvarepsilon}}}_{qp}^{0(kl)}\) and \({\mathbf{G}}_{qp}^{0(kl)}\), respectively) are calculated in lines 60 to 69. Finally, the homogenization for the effective Young's modulus (Eq. (2)) and for the effective heat conductivity (Eq. (8)) is calculated in lines 74 to 80. Loop has the value of 3 for mechanical physics to calculate the 3 by 3 effective elastic tensor and 2 to calculate the 2 by 2 effective heat conductivity tensor for our 2D problem. In Line 82, the derivatives of the homogenized property tensors with regard to microdesign variables (Eqs. (42) and (45)) are calculated. It is worth to mention that, this line is note used for compliance calculations of ( \(f_{c}^{ini}\) \(f_{\kappa }^{ini}\) \(f_{c}^{*}\), \(f_{\kappa }^{*}\)).

4.3.3 Normalization factors calculations

elementMatVec function (Appendix 1–5) is utilized to calculate the elemental stiffness matrix in line 40, which is used in the sub-function Objective_Calculator, to calculate \(f_{c}^{ini}\)(which is denoted by N_macro_Mech), for the purpose of calculating the normalized mechanical compliance multi-objective function (Eq. (34)). The function Concurrent_solver is used to calculate the \(f_{c}^{*}\)(which is denoted by U_macro_Mech). Also, the same function is used for calculating \(f_{\kappa }^{ini}\) and \(f_{\kappa }^{*}\)(which is denoted by N_macro_Heat and U_macro_Heat respectively). So, for Concurrent_solver (Appendix 1–4), lines from 2 to 9 are the preparation for the single physics concurrent optimization. According to select_case, for mechanical case, select_case is equal to 1 and the lines from 12 to 19 are used to calculate the objective function of the macroscale and the sensitivity analysis. Line 18 calculates Eq. (4) and the sensitivity of Eq. (40) in line 19. Also, the sensitivity of the microdesign variable \({\mathbf{x}}_{\text{m}}\) in terms of mechanical compliance (Eq. (41)) is calculated in line 27. Similarly, and for heat transfer physics, the macroscale sensitivity analysis (Eq. (43)) and the microscale sensitivity (Eq. (44)) are calculated in lines 40 and 48 respectively.

4.4 Concurrent multiscale optimization

After the preparations of the normalized optimization function (i.e., \(f_{c}^{ini}\) \(f_{\kappa }^{ini}\) \(f_{c}^{*}\), \(f_{\kappa }^{*}\)), a re-initiation of the macro and microdesign variables (i.e., Macro_x, and Micro_x) as well as the intermediate design domains (i.e., Macro_xPhys, and Micro_xPhys) have happened in lines 60–62. Furthermore, a variable called loop is initiated to be used as an indication number for optimization iteration. The optimization is carried out in the section of lines 63–121 of the main function Concurrent_MMO.m. Starting from line 63, the while condition runs till the loop function reaches the prescribed max iteration condition that is set in line 5 (maxIter = 500). In line 64, loop increases by 1 at each iteration. The optimization starts with the calculation of the mechanical compliance.

In line 66, the homogenized elastic tensor (QM) and the derivatives of the homogenized elastic tensor (dQM) with regard to microdesign variable \({\mathbf{x}}_{\text{m}}\) (as shown in equation Eq. (42)) are calculated. The line 67 is used to calculate the elemental stiffness matrix with respect to the homogenized elastic tensor (QM) in the function elementMatVec in the file elementMatVec.m (Appendix 1–5). In lines 68–72, the mechanical compliance and the sensitivity of the macrodesign domain are calculated. In line 73, Eq. (40) is calculated. Furthermore, line 74 presents the objective function of mechanical compliance alone \(f_{c}\) in a similar manner for calculating \(f_{c}^{*}\) inside Concurrent_solver function. The sensitivity for the macroscale is calculated in line 73. The sensitivities of the macroelement stiffness matrix with respect to microelement densities are computed using the derivatives of the homogenized elastic tensor with respect to microdesign variables (Lines 74–82).

Similarly, the finite element preparation of the heat physics is performed in lines (84–89), and the heat compliance objective and sensitivities are calculated in lines 90–101, such that the sensitivity in terms of macro and microscale design variables is calculated in lines 92 and 100, respectively. The term (dv) sis>is calculated in line 102 which is called later by the optimality criteria code (OC_2D.m). The total sensitivities in terms of macro and microdesign domains for the normalized multi-objective functions are calculated in lines 104 and 105, respectively. The update of the design variables (\({\mathbf{x}}_{\text{M}}^{{}} ,{\mathbf{x}}_{\text{m}}\)) is performed using the optimality criteria function OC_2D.m that is called in lines 107 for the macrodesign variable and 108 for the microdesign variable. Lines from 112 to 119 are dedicated for printing the results and showing the design of the macro and the microscale for each iteration.

For all cases, the material properties of the base material on the microscopic level are given as the following. The heat conductivity of the solid materials (\({{\varvec{\Lambda}}}_{ijqp}^{0}\)) is given in Eq. (53) for solid materials and infinitesimal value for the void materials to eliminate the numerical instability (Luo et al. 2006). Similarly for elastic tensor for solid material, (\({\mathbf{E}}_{ijqp}^{0}\)) is given in Eq. (54).

$${{\varvec{\Lambda}}}_{ijqp}^{0} = \left[ {\begin{array}{*{20}c} 1 & 0 \\ 0 & 1 \\ \end{array} } \right]\,\,\,\,\,\,,$$
(54)
$${\mathbf{E}}_{ijqp}^{0} = \left[ {\begin{array}{*{20}c} 3 & 1 & 0 \\ 1 & 3 & 0 \\ 0 & 0 & 1 \\ \end{array} } \right].$$
(55)

Furthermore, for finite element systems, the problems and the loads are set to be dimensionless. The design domain is assumed to be rectangular, and finite element analysis for micro and macrosystems was implemented using the square element with a side length equal to 1 (Fig. 17). The mesh is structured for the whole design domain. Each physical model is sharing the same structural element and shares the design variables \({\mathbf{x}}_{\text{M}}\) and \({\mathbf{x}}_{m}\) ( Macro_x and Micro_x respectively). An example of finite element mesh consisting of 25 elements of nodal temperature (T), nodal displacement in the x- and y-directions (U, and V respectively), and element density field of \({\mathbf{x}}_{\text{M}}\) and \({\mathbf{x}}_{m}\) is presented in Fig. 17.

The optimization of the heat conduction physical model has the volume-to-point approach, which necessitates a uniformly distributed heat load to be applied for the whole macroscale design domain. The heat load is set to be 0.01(P = 0.01 in line 30). The boundaries are adiabatic except for the section of zero-temperature portion to represent the place of the heat sink (Line 31). In general, heat compliance problem is by nature a monotonously decreasing function (Al Ali and Shimoda 2022), so volume fraction is important to implement a robust design, and for our design problems, volume fraction was set to be 0.5 weight reduction as a condition to be satisfied with the optimization process for both, the macro (\(v_{\text{M}}\)) and microscale (\(v_{\text{m}}\); Macro_volfrac = Micro_volfrac = 0.5). The heat compliance and the sensitivity analysis are calculated and the sensitivity function is hierarchically inferring the macrodesign variables. The microstructure has been solved with periodic boundary conditions. Heat compliance sensitivity in terms of the microdesign domain is used to update the value of the microdesign domain variables simultaneously with updating the macrodesign set at each iteration. For the physical model of mechanical compliance, the design domain is fixed from the support points such that the displacement in the x- and y-direction is set to zero. The force of magnitude 1 is assigned to the loading points. The modeling and sensitivity of the multiscale case are similar to what has been discussed in the heat transfer case.

4.5 Optimality criteria program

This work is utilizing optimality criteria to update the design variables. The optimality criterion approach is used to solve the optimization problem (Eq. (34)). The optimality criterion is written in the function OC_2D that is listed in the MATLAB file OC_2D.m (Appendix 1–7). First of all, to guarantee that solutions to the topology optimization problem exist and that checkerboard problem do not arise, a sensitivity filter is introduced to modify the sensitivities \(\dot{C}_{mech} \left( {{\mathbf{x}}_{\text{M}} } \right)\) \(\dot{C}_{mech} \left( {{\mathbf{x}}_{\text{m}} } \right)\),\(\dot{C}_{H} \left( {{\mathbf{x}}_{\text{M}} } \right)\) and \(\dot{C}_{H} \left( {{\mathbf{x}}_{\text{m}} } \right)\) as follows:

$$\hat{\dot{C}} = \frac{\partial C}{{\partial {\mathbf{x}}_{e} }} = \frac{1}{{{\mathbf{x}}_{e} \sum\nolimits_{f = 1}^{N} {H_{f} } }}\sum\nolimits_{f = 1}^{N} {H_{f} } {\mathbf{x}}_{f} \frac{\partial C}{{\partial {\mathbf{x}}_{f} }}$$
(56)

where \(H_{f}\) is the convolution operator to perform the modification, \({\mathbf{x}}_{e}\) is the design variable at which the sensitivity is calculated, and \({\mathbf{x}}_{f}\). The \(H_{f}\) is defined as follows:

$$H_{f} = r - dist(e,f),\,\,\{ f \in \left. N \right|dist(e,f) \le r\} ,$$
(57)

where \(dist(e,f)\) is the distance between the center of \(e^{th}\) element and the center of \(f^{th}\). Outside of the filter region, the convolution operator \(H_{f}\) is zero. The filtering program is written in OC_2D.m from lines 1 to 21. Furthermore, the topological derivative dv which is unity in this case is also modified in line 22.

After modifying the sensitivity, the following is a heuristic updating technique that is identical to the one employed in this paper:

$${\mathbf{x}}_{e}^{updated} = \left\{ {\begin{array}{*{20}c} {\max (0,{\mathbf{x}}_{e} - \varepsilon )\,\,\,if\,\,{\mathbf{x}}_{e} B_{e}^{\omega } \le \max (0,{\mathbf{x}}_{e} - \varepsilon )} \\ {\max (0,{\mathbf{x}}_{e} + \varepsilon )\,\,\,if\,\,{\mathbf{x}}_{e} B_{e}^{\omega } \ge \max (1,{\mathbf{x}}_{e} - \varepsilon )} \\ {{\mathbf{x}}_{e} B_{e}^{\omega } \,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,Otherwise\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,} \\ \end{array} } \right.$$
(58)

where \(\varepsilon\) denotes a positive search step (As shown in Fig. 4). Moreover, \(\omega\) which is equal to 1/2 denotes a numerical damping coefficient, and \(B_{e}^{{}}\) denotes the optimality condition:

$$B_{e} = \frac{{ - \frac{\partial C}{{\partial {\mathbf{x}}_{e} }}}}{{L\frac{\partial V}{{\partial {\mathbf{x}}_{e} }}}},$$
(59)

where \(L\) here is a Lagrangian multiplier, and \(\frac{\partial V}{{\partial {\mathbf{x}}_{e} }}\) is the volumetric topological derivative.

Equation (58) is performed in the function OC_2D from lines 24 to 30.

5 Numerical examples and discussion

In order to present the concurrent multiscale and multiphysics topology optimization for maximizing the heat conductivity and stiffness on the macro and the microscale, numerical examples using the introduced MATLAB code are presented in this section. The code was performed with the MATLAB (R2021b). The first model consists of a rectangular domain of 200 elements in the x-direction and 90 elements in the y-direction. It has a periodic square microdesign domain of 100 element edge length. They share a weight reduction of 0.5 of the total volume fractions. The mechanical model has a fixation alongside the left edge while the loading is placed on a point in the third quarter part of the right side measured from the top, and directed downward (as shown in Fig. 20a). To depict the heat conduction physics model, the temperature at the middle of the left edge of the domain in Fig. 20b was set to zero. The domain's remaining boundaries were set as adiabatic (i.e., zero heat transfer). Heat generation was set to be constant and homogeneous throughout the domain of 0.01, which was meshed also with 200 by 90 elements in the x- and y-directions, respectively (i.e., Macro_nelx = 200 and Macro_nely = 90 as shown in Fig. 21). The microdesign domain has 100 by 100 elements (i.e., Micro_nelx = 100 and Micro_nely = 100) with periodic boundary conditions to comply with the numerical homogenization evaluation scheme. Regarding the initial microdesign domain, it is set to have the value of 0.5 except the central circular domain of the radius equal to 50 elements. This central sub-design domain was set to have a quarter value of initial value than for the other of the design domain. This is to encourage achieving design by the optimality criteria with less computational cost (Sigmund 2000) as well as minimizing the grayscale area of the microcell (Fujioka et al. 2021). In order to have a good insight about the trade-off of the consisting multiphysics objective functions, a study is performed to optimize the macroscale alone for several waiting factors. The results of optimizing the macroscale alone (which are presented in Fig. 22) show a strong shift between the objective function which gave a strong Pareto front. The Pareto front shows a clear trade-off between the heat compliance and the mechanical compliance minimization such that, branching in the cases of the high value of \(\eta\) is presented, while it tends to shrink and fade with decreasing the value of \(\eta\). Branching is good for heat dissipation yet it tends to decrease the structural stiffness significantly. Extending the optimization for the concurrent multiscale dimension is giving the results shown in Fig. 23. The influence of the trade-off of multi-objectives multiscale problem is shown on the change of the macro and the microstructures. The microstructure is trying to adapt to the stronger physics while balancing the microdesign variables with the overall objective of decreasing the value of the general weighting factor \(\eta\). The Pareto front shows that the best result (knee point) for the first example is for the weighting factor (\(\eta\) = 0.6). The history of the heat compliance, mechanical compliance, and the multi-objective function are shown in Figs. 24, 25, and 26. All design cases result of this example are shown in Appendix 2.

Fig. 21
figure 21

The initiation constants of example 1

Fig. 22
figure 22

Pareto front of first example for optimizing the macroscale only

Fig. 23
figure 23

Pareto front of the concurrent multiphysics optimization of example 1

Fig. 24
figure 24

The normalized heat compliance history of the concurrent optimization for example 1

Fig. 25
figure 25

The normalized mechanical compliance history of the concurrent optimization for example 1

The mechanical physical model of the second studied example (Fig. 20c) has a square macrodesign domain of 150 element side length (i.e., Macro_nelx = Macro_nely = 150 as shown in Fig. 27), with a fixed left side and a load placed on the middle of the right side, pointing toward the positive y-direction.

Fig. 26
figure 26

The multi-objective history of the concurrent optimization for example 1

The solid heat conduction physics has similar properties to the previously studied case except for the location of the heat sink (Fig. 20d). Similarly, the general weighting factor was changed in a similar way to the first case and shows the following Pareto front (Fig. 28) for the multiphysics optimization of the macroscale alone. The Pareto front for optimization of the macro and microscale is presented in Fig. 29. And all design cases’ result of this example is shown in Appendix 3. The layout transition of the macrostructure for the two cases is strongly presented also on the microscale design, especially for case 2. This transition is a direct response to the effect of the physical model's combination. The material distribution transitions of each competitive physical model are changing with the boundary condition of each physical model, so for the first example (Fig. 20a and b), the boundary conditions are forcing the design of each domain to extend the design toward the middle of the left side with the exception of the mechanical model which is shifted a bit toward the downside. The microdesign domain is responding by distributing the material diagonally for the heat conduction model but with a center mass around the middle to distribute the thermal energy inside the bulk of the microstructure. While for the mechanical strain energy, the microstructure is distributing the energy by sides alongside diagonal distribution, which is shown with the branching layout. Here, also distribution of strain energy in terms of triangular truss is allocated around the central circular space of the microstructure. Tables 1 and 2 present the best results of the only macroscale and the multiscale optimization, respectively, for examples 1 and 2.

Fig. 27
figure 27

The initiation constants of example 2

Fig. 28
figure 28

Pareto front of second example for optimizing the macroscale only

Fig. 29
figure 29

Pareto front of the concurrent multiphysics optimization of second example

Table 1 The outline of sample firms and interviewee profile
Table 2 The outline of sample firms and interviewee profile

6 Conclusions

This work presents concurrent multiscale and multiphysics topology optimization for reducing weight, and maximizing heat conductivity and structural stiffness for macro and periodic microstructure. The objective is to demonstrate the optimization formulation and examine the design criteria for topology optimization using MATLAB code intended for educational purposes. The formulations for the multiscale and multiphysics problems were established in this study, and the derivative of the sensitivity analysis was successfully implemented using the adjoint method to reduce the computational cost. Using MATLAB, the concurrent multiphysics optimization for maximizing heat conductivity and stiffness is attained by minimizing the thermal and mechanical compliances and was examined in several numerical examples. The examined cases indicate a significant shift in the objective function, resulting in a strong Pareto front. The Pareto front demonstrates a clear trade-off between heat compliance and mechanical compliance minimization, with branching appearing in cases when the general weighting factor is high for the heat objective function, and shrinking and fading as the general weighting factor is decreased. Although branching is beneficial for heat dissipation, it reduces structural rigidity greatly. Extending the optimization to the concurrent multiscale dimension yields a favorable heat and mechanical compliance minimization trade-off. The influence of the multi-objective trade-off on macro and microstructure evolution is also demonstrated. The microstructure is attempting to adapt to the stronger physics while balancing microdesign with the overall goal of lowering the general weighting factor's value. Also, in this paper, the MATLAB code for multiscale topology optimization is presented to provide researchers and newcomers with a simple implementation of concurrent multiphysics and multiscale optimization. MATLAB code is provided in the appendix for users’ reference, to be used for educational reasons. The code is distributed in multiple sections with a dedicated function to make the concurrent multiphysics and multiscale problem as comprehended and user-friendly as possible. Moreover, users can edit the code according to their requirements.