# Multi-Scale Concurrent Topology Optimization Based on BESO, Implemented in MATLAB
## 6 Numerical Results
% USER-DEFINED LOAD DOFs
3. ii = nelx/2; j1 = 0; kl = nelz/2; % Coordinates
4. loadnid = kl*(nelx+1)*(nely+1)+i1*(nely+1)+(nely+1-j1); % Node IDs
5. loaddof = 3*loadnid(:) - 1; % DOFs
6. F = sparse(loaddof,1,-load,ndof,1);
7. % USER-DEFINED SUPPORT FIXED DOFs
8. iif = [0 0 nelx nelx]; jf = [0 0 0 0]; kf = [0 nelz 0 nelz ]; % Coordinates
9. fixednid = kf*(nelx+1)*(nely+1)+iif*(nely+1)+(nely+1-jf); % Node IDs
10. fixeddof = [3*fixednid(:); 3*fixednid(:)-1; 3*fixednid(:)-2]; % DOFs

Whereas, for the 3D cantilever test case, _Lines_ 12-19 are modified following Listing 19. **Listing 19** Definiton of loading conditions and fixed degrees of freedom for the 3D cantilever test case

1. [leftmargin=*]
2. % USER-DEFINED LOAD DOFs
3. ii = nelx; j1 = 0; kl = 0:nelz; % Coordinates
4. loadnid = kl*(nelx+1)*(nely+1)+i1*(nely+1)+(nely+1-j1); % Node IDs
5. loaddof = 3*loadnid(:) - 1; % DOFs
6. F = sparse(loaddof,1,-load,ndof,1);
7. % USER-DEFINED SUPPORT FIXED DOFs
8. [jf,kf] = meshgrid(1:nely+1,1:nelz+1); % Coordinates

Figure 5: The 3D test cases—Resulting geometries for both structural (macro-scale) and periodic unit cell (micro-scale). * fixedmid = (kf-1)*(nely+1)*(nelx+1)+jf; %  Node IDs
* fixeddof = [3*fixedmid(:); 3*fixedmid(:)-1; 3*fixedmid(:)-2]; % DOFs

## 7 Code Extensions

This section introduces the expansion of the MATLAB implementation discussed in Section 5 to accommodate two-phase composite microstructures. Additionally, it includes additional numerical tests to those presented in Section 6 that are compared to results obtained from existing literature for assessment purposes. ### Two-Phase Composites

In this sub-section, the extension of the two MATLAB codes for two-phase composite microstructures is presented, along with the modification of the volume constraint applied for the micro-scale to accommodate the two different materials. The integration of the two different volume constraints into a single optimization constraint. The single volume constraint is designed to enable the optimization algorithm to allocate the allowed volume fraction target value between the micro and macro-scales. The extension for the use of two-phase composite microstructures in the code implementations is relatively straightforward through the use of the modified SIMP approach. Thus, in Equation (7) the second material can be simulated by replacing the term \(E_{min}\) with the Young's modulus of the second material denoted as \(E_{2}\). Thus, if additionally term \(E^{0}\) is denoted as \(E_{1}\) representing the Young's modulus of the first material, the expression of Equation (7) is modified into the Equation (22). \[E_{d}(y)=E_{2}+y_{el}^{p}\cdot(E_{1}-E_{2}) \tag{22}\]

Thus, for elements with \(y_{el}\) equal to one their Young's modulus is equal to, \(E_{1}\) whereas for elements with \(y_{el}\) equal to zero their Young's modulus is equal to \(E_{2}\). Another popular implementation includes the modification of Equation (22) to a more straightforward expression following Equation (23). \[E_{el}(y)=y_{el}\cdot E_{1}+(1-y_{el})\cdot E_{2} \tag{23}\]

where the sensitivity of the term \(E_{el}\) is following the expression of Equation (24). Figure 1:0

The modification of the volume constraint for the micro-scale is based on the constraint presented by [PERSON] et al. in [24]. Thus, in order to balance the two phases, the new volume constraint in addition to the material densities \(y\) takes into consideration the difference in density between the two phases. Therefore, the term \(V(y)\) of the volume constraint presented in multi-scale problem formulation (1) is modified following the expression of Equation (25). Figure 1:1

where terms \(\rho_{1}\) and \(\rho_{2}\) refer to the densities of phases one and two, respectively. The implementation of the two-phase composite microstructures into the two MATLAB codes requires small changes.