As mentioned in the Introduction Section, the optimization works reported in the state of the art do not consider the mesh size of mechanical elements as a variable with potential benefits in the optimization problem. For this reason, the present work proposes a four-step meta-heuristic-based methodology, as depicted in the general diagram shown in
Figure 1. The first step consists of the problem statement, where two case studies are addressed by defining all the conditions and constraints, including the mathematical background required for solving the problem. The second step is a MATLAB implementation, where a script is developed for programming the optimization algorithm based on a pseudocode reference, which means the differential evolution (DE) algorithm takes place. Once the initial population is created, the third step is to carry out static or frequency analysis with the ANSYS evaluator. ANSYS APDL is used to conduct these analyses, because it allows the calculations to run in batch mode, reducing the computational overhead. This process takes place within the MATLAB implementation described in the pseudocode. After evaluating all generations, the results are written to an external file, which is then read by the MATLAB pseudocode to initiate the fourth step: the post-processing. In this last step, the results are processed and the corresponding graphs are generated.
2.1. Problem Statement
In the present paper, the two case studies are related to beams, with a beam defined as a line member of finite length in a range from X = 0 to X = L [
13]. For the study of beams, two well-known theories exist: Euler–Bernoulli and Timoshenko. In this case, the Timoshenko theory is selected because it does not assume the shear force to be zero. It is known that the Computer Aided Engineering (CAE) software, such as ANSYS, uses this mathematical background for the resolution of the problems. In the case of beam problems, three principal reactions are developed depending on the case study: the axial force, represented by the letter
N in Equation (1), where
E is the Young modulus of the material,
A refers to the cross-section area of the beam, and
ε0x is the X component of the axial strain on the referenced line. The bending moment represented by the letter
M in Equation (2), where
I refers to the moment of inertia, and
φ is the curvature of the beam. Finally, the shear stress is represented by the letter
V in Equation (3) [
13], where
As is the shear area of the cross-section, and
σxy is the shear stress; at the same time, shear stress (
σxy) can be represented as the product of shear modulus,
G, times shear strain,
γxy. Meanwhile shear area (
As) can be represented as the product of shear factor,
k, times cross-section area (
A); the shear factor is used for improving the accuracy of the results.
The mathematical solution is guided by Equation (4), where the stress (
σ) is calculated as the product of the stiffness matrix (
D) and the deformation vector (
ε).
The first problem is related to micro-electro-mechanical systems (MEMS), which are known for having small moving parts that function as sensors and actuators. The investigation in [
14] is taken as reference for the optimization problem. In that work, the authors proposed tuning the resonance frequency of a cantilever microbeam by introducing square cutouts. The objective of this study is to determine the optimal location and size of the cutouts to maintain a specific activation frequency, which, in this case, corresponds to the beam’s first natural frequency. The shape of the cutout is constrained to a square, and its possible locations are limited to the central axis of the beam along the X direction, according to a traditional coordinate system.
Figure 2 illustrates how the location and length of the cutout change iteratively. The first variable is the cutout location (
Esx), measured from the beam’s fixed end to the left edge of the cutout; the second variable is the length of the cutout (
Lc), specifically referring to the side of the square cutout.
Natural frequencies are characterized by a mathematical model, where the function describing the natural frequency (
ω) of the cantilever beam is based on its eigenvalues (
β) multiplied by the square root of the quotient operation of beam properties, including Young’s modulus (
E), the moment of inertia (
I), density (
), and cross-sectional area (
A). Thus, it is transformed and can be applied for any beam length (
l), as is shown in Equation (5) [
15].
For this study, only the first vibration mode is considered due to limitations in the method, since considering more than one vibration mode makes the method prone to fail to evolve correctly. In consequence, the first eigenvalue is found in the parent and the second in the offspring, resulting in a selection loop where the values do not change along generations. The characteristics of the cantilever beam are listed in
Table 1.
The second case study addresses a structural problem, where the aim is to reduce the final weight on a cellular beam by varying the hole diameter and the number of holes along the beam length. Another variable considered in the problem is the beam’s cross-sectional area, which is limited to different profiles of American wide flanges (W-Beams).
A cellular beam is formed by cutting an “I” section beam that is cut twice with a semi-circle in their mid-center line [
16]. This cutting produces two parts that are slid and welded at the joints, as is shown in
Figure 3.
The main reason for using cellular beams in structural systems is their lighter weight compared to traditional beam profiles. At the same time, cellular beams present higher bending resistance, increasing their resistance by 40–60% compared to original profiles.
Table 2 summarizes the properties of the cellular beams considered in this work.
2.2. MATLAB Implementation
Among all meta-heuristic algorithms, the differential evolution (DE) algorithm is selected for the proposed methodology due to its robustness and quick convergence, in comparison with a contemporary algorithm like particle swarm optimization (PSO) that presents a similar behavior, but DE is capable of finding a global solution most of the time; meanwhile PSO sometimes get stuck in local solutions [
17]. The DE pseudocode is presented in
Figure 4 and corresponds to the variant
DE/rand/1/bin [
18], which is the classical implementation of the algorithm; this variant does not take the best member of the population, and it is selected for easy implementation and programming.
The pseudocode begins with the creation of the population, defining (
Np) fathers, (
D) number of variables, (
U) upper limit, and (
L) lower limit. The while loop makes each father of the population take place in the mutation and crossover process. The mutation process begins with the selection of the father (
Vx); this takes the value of the current member of the population that corresponds to the present iteration number. Then a trial vector is generated (
Vy) with three members of the population, all of them selected randomly. The only conditions for the selections are, first, that the members cannot be repeated among themselves, and second, that none of them can be equal to the current father (
Vx). Also, a mutation factor is defined (
F). Once the three members are selected, the operation presented on the seventh line of
Figure 4 is performed. The mutation process is presented graphically in
Figure 5.
Then the crossover takes place; in this step of the process, a combination of information can be made; first, the crossover rate (Cr) and the offspring (u) are defined; the coefficient is low and set in a range from 0 to 1. After that, a random number (randj) is generated, and if this number is lower than the cross rate, the offspring takes the value of the current father; otherwise, it takes the value of the trial vector; it is important to clarify that the crossover is performed for each element of the trial vector, which corresponds to the dimension of the vector.
Then, the evaluation of the O.F is made, and if the cost function of the father is better than the offspring, the father remains on the population; otherwise, the current father is substituted for the offspring; this process makes sure that the population is constantly updated, ensuring that only one member survives per iteration. This process is repeated until all the fathers participate, which corresponds to the while loop, and the generation condition is satisfied.
The DE algorithm is based on the natural selection process, in which the best candidates survive, and information is transmitted from parents to offspring across generations. Like other meta-heuristic algorithms, the process involves an initial population, crossover, mutation, and selection.
Figure 6 shows the block diagram followed for the MATLAB implementation.
First, the O.F for each case of study needs to be defined; for this reason, each one has its own script on MATLAB; for the first case of study, the problem addressed is about the tuning of natural frequency in a cantilever beam with cutouts placed along the centerline of the lateral face [
14]. The purpose is to maintain the value of the first eigenvalue while removing material. The DE algorithm is used to find the length and position of the cutout, as well as the appropriate mesh element size that best fits the O.F. The objective function to be minimized is the difference between the eigenvalue of a cantilever beam without any cutout (
λo) and the eigenvalue evaluated using the optimization algorithm (
λf) [
14]. Thus, this function is presented in Equation (6), where the variable limits are specified. The three variables were selected because they modify the eigenvalue.
The second case study, related to weight reduction in a cellular beam, involves three variables: hole diameter (
Sc), beam section (
Bs), and mesh element size (
Size). Since the beam section is treated as a discrete variable, the hole diameter (
Sc) is defined as a percentage of the corresponding beam section height, limited to avoid geometric errors. The objective function is presented in Equation (7), including the three variables and their respective limits.
The initial population in both cases is generated randomly; each member (
Pi) is generated by the operation shown in Equation (8) where (
Li) is referred to the lower limit, (
Ls) is the upper limit, and (
rand()) is the command that generates a random number between zero and one; the random generation does not depend on a seed; for this reason, the random numbers generated can never be the same for each code execution. The use of an initial random population is advantageous because a uniform distribution across the searching area of design variables improves the convergence of the DE technique.
Then the number of fathers (
Np) and generations is set at 50 and 200, respectively (case of study 1). On the other hand, for the case of study 2, the number of parents and generations is set at 20 for both. This number is selected following the rule of the ten times the number of variables the problem has [
20]. By this rule, the recommended number of fathers needs to be 30 for both cases, but it is known that at initialization the population should be spread; for this reason for the first case, the number of fathers is set at 200, almost seven times the recommend value, and also because the computational cost is lower, allowing an increase in the values for better results. In the second case, the selection was different; it is because this problem represents a higher computational cost; for this reason it was decided to set it at 20. For the values of mutation factor (
F) and crossover rate (
Cr), the selection was conducted following the recommended values given by Storn [
20].
Afterwards, the mutation and crossover processes were performed, as shown in
Figure 4; it is important to mention that this is an iterative process, and for this reason, for each father iteration, an offspring is generated, always having a father (of current iteration) and an offspring. The next step is the execution of the ANSYS evaluator. To do this, APDL is selected due to the reduction in computational cost, by using Batch Mode. This means that APDL is called from an external program and does not need to be opened manually to run the simulation and calculations. The MATLAB script is called APDL execution program, and once it runs in batch mode, another script (previously generated by MATLAB) with variables of the O.F (Equations (6) and (7)) that are obtained from the father, is run for APDL; the script generates the geometry of the beams; after that, the meshing process is performed by considering that the value of the variable “size” is changing constantly during the optimization process. Finally, the mechanical analysis is performed, and the O.F is evaluated. The solution is computed, and the results are stored in an internal variable for writing to an external file. This process needs to be repeated, but now with the values obtained from the offspring; that is why ANSYS evaluator runs twice. The values written in the external file are read by MATLAB script and the comparison is carried out. If the father provides better value for the O.F than the offspring, the parent remains in the population; otherwise, the offspring remains in the population. As was mentioned before, this is an iterative process, and for each iteration, the population is updated; this process is repeated until the two stop conditions are satisfied; the first one is the father stop condition, where, once that the iteration arrives at the last father, this condition is true and arrives at the second one, the generation condition, where, to be satisfied, it needs to arrive at the last generation; once that happens, the condition is true, and the implementation finishes. The pseudocode for methodology implementation is shown in
Figure 7.
2.3. MATLAB Post-Procesing
The next step is the post-processing of the information obtained from the optimization algorithm, beginning with the analysis of the mesh element size and how this could affect the optimization results. For the first case study, a mesh sweep is performed, and the optimized values of “Esx” and “Lc” are taken, while the mesh element size of the elements is treated as the variable that changes through an iterative process. The mesh sweep is conducted considering an upper and lower limit; the upper limit is a coarse mesh where the element size is set to 0.06 mm (326 nodes), and the lower limit is a fine mesh set to 0.0015 mm (1,065,066 nodes). These limits are selected based on the smallest element size in the optimization algorithm, and the upper limit is selected when the element distribution begins to change due to its size in comparison with the geometry. Ultimately, an analysis is conducted to compare the time consumed by the optimization algorithm with the time required if the analysis is conducted using a fine mesh. Considering that the latter time corresponds to a single iteration, and that the optimization process was executed with 50 parents and 200 generations, this time needs to be multiplied by the total number of the iterations performed by the algorithm for obtaining the total execution time.
For the second analysis, the same sweep is performed; in this case the upper and lower limits are set to 15 mm (49,664 nodes) and 6.5 mm (262,331 nodes), respectively.