# Topology Optimization Based Material Design for 3D Domains Using MATLAB
## 2 Design of Materials by Means of STO  
For the needs of the optimal material design problem formulation, two different scales are utilized during the optimization procedure. The first one refers to the macro scale, where the structural domain is defined where the loads are applied, while the second one concerns the micro scale where the design domain (unit cell) is formulated. Compared to the classical STO problem formulation and in order to apply the topology optimization approach for the optimal design of materials, the main modification required concerns the design variables (material densities). More specifically, instead of assigning the unknown material densities \(x\) on every finite element of the macro domain discretization, unknowns \(x\) are assigned on each finite element of the micro design domain. The bridging between the two scales is implemented by means of the homogenization theory. The mathematical expression of the optimal design of materials problem is represented by the formulation of Equation (1) (Throughout the text, a common notation for all cases of the multiplication operators is used consistently and its correct interpretation depends on the context of the algebraic objects appearing on the left and right sides of the \"\(\cdot\)\" sign), which does not differ at the first site with the formulation of the classical problem. As denoted, earlier the difference is hidden in the two scales adopted by the material design problem (micro and macro ones). \[C(x) =F^{T}\cdot U(x)\] \[s.t.\] \[F =K\cdot U(x) \tag{1}\] \[V(x)/V_{0} =f\] \[0\leq x_{e}\leq 1\]  
where the structural compliance value \(C(x)\) is the objective function to be minimised, vector \(F\) contains the loading conditions applied to the macro domain, \(U(x)\) is the resulting displacements vector obtained through the solution of the \(F=K\cdot U(x)\) that refers to the structural equilibrium system of equations that is defined for the macro domain, \(V(x)\) and \(V_{0}\) denote the structural volume and the domain volume, respectively. The volume target percentage is denoted with \(f\) and \(x_{e}\), which are the material density of element \(e\) at the micro design domain level (also called unit cell). As denoted earlier, it can be observed that the formulation of Equation (1) is almost the same as that of the classical STO problem with the alteration on the scale where the material densities are applied. In order to solve the formulation presented by the expression of Equation (1), the derivative of the objective function (compliance) is needed. Taking advantage of the calculations used by the classical topology optimization theoretical framework, the derivative of the compliance with respect to the material densities \(\partial C/\partial x_{e}\) is computed from the following expression of Equation (2):  
\[\frac{\partial C}{\partial x_{e}}=-U_{e}^{T}\cdot\frac{\partial K_{e}}{ \partial x_{e}}\cdot U_{e} \tag{2}\]  
where \(U_{e}\) (\(e=1,\ldots,N_{e}\)) are the displacement vectors of every finite element \(e\) of the macro domain (\(N_{e}\) is the total number of elements used to discretize the macro domain), \(\partial K_{e}/\partial x_{e}\) is the derivative of the macro domain element's \(e\) stiffness matrix \(K_{e}\) with respect to the material densities assigned to finite elements of the micro design domain. The displacement vector \(U_{e}\) is obtained as the outcome of the solution of the equilibrium equation presented by Equation (1), expressed at the macro domain, whereas the derivative of the element stiffness matrix is computed from the following expression of Equation (3):  
\[\frac{\partial K_{e}}{\partial x_{e}}=\frac{\partial C^{H}}{\partial x_{e}} \cdot K_{e}^{0} \tag{3}\]  
where \(\partial C_{e}^{H}/\partial x_{e}\) is the derivative of the homogenized elasticity tensor with respect to the material densities and \(K_{e}^{0}\) is the element stiffness matrix without using the elasticity tensor for its calculation. To obtain the homogenized elasticity tensor, the theory of homogenization is utilized.