Optimization in the Resistant Spot-Welding Process of AZ61 Magnesium Alloy

In this paper, an integrated artificial neural network (ANN) and multi-objective genetic algorithm (GA) are developed to optimize the resistance spot welding (RSW) of AZ61 magnesium alloy. Since the stability and strength of a welded joint are strongly dependent on the size of the nugget and the residual stresses created during the welding process, the main purpose of the optimization is to achieve the maximum size of the nugget and minimum tensile residual stress in the weld zone. It is identified that the electrical current, welding time, and electrode force are the main welding parameters affecting the weld quality. The experiments are carried out based on the full factorial design of experiments (DOE). In order to measure the residual stresses, an X-ray diffraction technique is used. Moreover, two separate ANNs are developed to predict the nugget size and the maximum tensile residual stress based on the welding parameters. The ANN is integrated with a multi-objective GA to find the optimum welding parameters. The findings show that the integrated optimization method presented in this study is effective and feasible for optimizing the RSW joints and process.


INTRODUCTION
In recent years, alloys of Magnesium (Mg) have become of great attraction and significance as easy-tomachine metals with exceptional strength-to-weight ratios, for various sectors including automotive, aerospace, and structural applications [1]. Magnesium is the lightest of all commonly used structural metals; with a density that is approximately two thirds that of aluminium and one quarter that of steels. Other than this, magnesium alloys have a high strength-to-density ratio, high specific heat, low melting temperature, and good castability, hot formability, recyclability, and sound-damping capabilities [1] to [5]. These properties bring a significant interest in many industrial applications to reduce the weight of the structures. Despite these considerable interests, using magnesium alloys in the industry remains limited compared with aluminium and steel alloys due to some technical problems. For example, the resistance spot welding (RSW) of magnesium alloys is more complex than in steel and aluminium alloys and needs different welding parameters.
Although many new welding processes have been developed and presented for magnesium alloys (such as friction stir welding [6] to [9], laser welding [10] and [11]), RSW remains the most common joining process. In RSW, a high electric current is passed through the sheets via electrodes for a short time, which results in the generation of a melting zone between the sheets. After switching off the electrical current and undergoing a cooling process, a nugget is created in the welding area. Studies have shown that the nugget size is the most important controlling factor to determine the mechanical strength of the joint. The larger nugget results in higher mechanical strength [12] to [14]. In addition, when the molten metal starts cooling down to room temperature, a large temperature gradient occurs in the heat-affected zone (HAZ). This non-uniform temperature change leads to residual stresses in the welded joint. The residual stresses significantly affect stress corrosion cracking, hydrogen-induced cracking, and fatigue strength. Regardless of the loading conditions on spotwelded joints, tensile residual stress deteriorates the fatigue strength and the quality of the joint [15] to [17].
Therefore, selecting the optimum welding parameters to achieve the maximum nugget size and the minimum tensile residual stress is the key factor in obtaining high-quality welding and joint strength.
Yi et al. [18] introduced a non-linear multiple orthogonal regression assembling model to optimize the welding parameters of RSW on galvanized steel sheet. They evaluated the effects of the welding parameters on the nugget size and optimized the parameters to maximize it. Hamidinejad et al. [19] predicted the mechanical strength of the RSW in the galvanized steel joints based on the welding parameters. They also optimized the welding parameters with a genetic algorithm (GA) to improve the tensile-shear strength. A multi-objective Taguchi method was applied to optimize the welding parameters in RSW of low-carbon steel by Muhammad et al. [20]. The main purpose of the study was to select the optimum RSW parameters to increase the nugget size and decrease the heat-affected zone (HAZ). Zhao et al. [21] utilized the response surface methodology (RSM) to optimize the nugget size, the mechanical strength, and the failure load in small-scale RSW of titanium alloy.
A hybrid ANN-GA model was developed by Pashazadeh et al. [22] to optimize the welding parameters of RSW on AISI 1008 steel alloy and achieve the maximum nugget size. Mirzaei et al. [23] developed a finite element (FE) model to predict the nugget size in RSW on galvanized steel. They used the RSM to optimize the welding parameters and obtain the maximum nugget size and maximum mechanical strength. Valera et al. [24] applied the Taguchi design of experiments to optimize the RSW of TRIP steel. The optimized electrical parameters were presented to increase the tensile-shear strength of the welded joints. The dissimilar RSW of AISI 316L austenitic stainless steel and 2205 duplex stainless steel were optimized by Vignesh et al. [25] using Taguchi's L27 orthogonal array (OA) design. Their results revealed that the welding current is the most dictating factor in achieving the highest tensile strength with superior weld quality.
The literature indicates that the optimization in the RSW of magnesium alloys has not been studied extensively. The purpose of this study is to contribute to the optimization of the welding parameters: electrical current, welding time, and electrode force of AZ61 magnesium alloy RSW joints. A full factorial design of the experimental (DOE) results is carried out and then two separate ANN models are developed to predict the nugget size and the maximum residual stress. Finally, an integrated ANN-ANN-GA algorithm is developed to optimize the welding parameters.

METHODS
In this study, AZ61 magnesium alloy has been used to prepare the welded samples. The nugget size has been measured experimentally for all the samples and an X-ray method has been utilized to measure the residual stresses. To predict the nugget size and the residual stresses, two ANN models have been developed. Finally, the welding parameters have been optimized by an integrated ANN-ANN-GE to obtain the maximum nugget size and the minimum tensile residual stress.

EXPERIMENTAL
AZ61 magnesium alloy sheets have been used to prepare the welding samples and their chemical composition is given in Table 1.   The surfaces of the specimens have been cleaned using a hard brush before welding. RSW has been performed by using a Novin Sazan Company Machine (model SSA014, IRAN, Fig. 2) with a CU08 controller and nominal welding power of 120 kVA. Both copper electrodes were cooled by circulating water during the welding. The welded samples have been cut along the centreline and the nugget size has been measured using an optical microscope (Fig. 3). A SEIFERT X-ray diffractometer (model 3000PTS, Fig. 4) has been utilized for the residual stress measurements. Measurements have been performed in the centre of the welded zone where the maximum tensile residual stress occurs [17]. The residual stresses have been measured on both sides of the welded samples in radial and transverse directions. The average of measured residual stresses has been reported as the maximum tensile residual stress in the welded zone.

The Full Factorial Experiment Design
In this study, a full factorial design of an experiment has been used to design the welding parameters schedule. Electrical current, welding time, and electrode force have been considered to be the main influencing welding parameters. The lower bond of each welding parameter was selected to achieve the nugget size recommended by AWS [26], and the higher bond was chosen to prevent weld splash and spatter. The appropriate ranges of the welding parameters are given in Table 2. The full factorial 2 k design of experiments has been designed, k is the number of variables, which is 3 here with lower and higher bonds of −1 and +1, respectively. According to the full factorial DOE, a total of 8 combinations of the input parameters were considered. The samples have been welded based on the welding parameters given in Table 3, and the results obtained from the nugget and the residual stress measurement are displayed in Table 3. Fig. 5 illustrates the results of the DOE analysis for the nugget size. The Pareto diagram shows that although the electrical current, welding time, and their interaction affect the nugget size, the electrode force and its interaction with other variables have almost no effect. In addition, the electrical current is the most influential parameter on the nugget size. The Normal diagram confirms the results obtained from the Pareto diagram. The electrical current is the furthest point from the normal line, which means it is the most significant parameter. The points close to the normal line have no impact on the output. Similar results have been reported in previous studies for other materials [12] to [15] and [18] to [24].
The results of the DOE analysis for the residual stress are displayed in Fig. 6. According to the Pareto and Normal diagrams, the welding time and the electrode force affect the residual stresses. Although the welding time is the most influential parameter on the residual stress, the electrical current has almost no effect. The results are similar to those previously reported for RSW of Al joints [16].

The Artificial Neural Networks
ANN is a powerful and reliable model to predict complex phenomena with multiple variables. ANN is also very flexible in terms of the number of variables, the training algorithm, transfer functions, and the structure. An ANN consists of several layers: an input layer, some hidden layers, and an output layer. In addition, each layer involves some neurons.
The number of hidden layers is usually one or, in specific cases, two. Using more than two layers is rarely done and is not recommended [27].
Two separate multilayer backpropagation feedforward ANNs have been used to predict the nugget size and the maximum tensile residual stress. Theses ANNs have been implemented using Matlab.  The Levenberg-Marquardt training algorithm has been utilized to train the ANNs. This algorithm minimizes a combination of squared errors and weights and then determines the correct combination. The transfers between layers have been done by using a combination of Tansig and Purelin transfer functions. Finally, the mean square error (MSE) function determines the ability of the ANNs to predict the outputs. According to the number of the welding parameters and the output, the number of neurons in the input and output layers of both ANNs are three and one, respectively. The performance of the ANNs depends on the number of hidden layers and the number of their neurons. Hence, many trials need to be made to find the optimum structure for the ANN by changing the number of hidden layers and their neurons. Since there were two different ANN, two different structures have been considered. The proper structure for the first ANN to predict the nugget size was 3×6×1. The best structure for the second ANN to predict the maximum residual stress has been found to be 3×10×1 using a trial-and-error procedure. In addition, the values of the variables and outputs have been normalized between 1 and 2 (Eq. (1)) in order to increase the accuracy and speed of training the ANNs.
where P is the real value of each parameter, P n is the normalized value, P min and P max are the minimum and maximum values respectively. Eq. (2) also has been used to de-normalize the results obtained from the model. (2) According to the DOE results, the electrical current is the most effective parameter on the nugget size, and the welding time has the most influential impact on the residual stress. Although the electrode force has almost no effect on the nugget size, it affects the residual stress. To run the ANNs, the five levels have been considered for both electrical current and welding time and just three levels have been selected for the electrode force. A total of 75 sets of welding parameters have been chosen to run the ANNs. Table  4 displays the level of the RSW parameters considered to run the ANNs. However, the nugget sizes have been measured experimentally; the maximum residual stresses have been obtained from the FE model [6] since the experimental testing would have been time consuming. The overfitting is the usual phenomenon that may occur in the training of ANN. It happens when the ANN memorizes the training data instead of building input-output mapping for the problem. Thus, determining the number of training and test data has a very important role in avoiding overfitting. In this study, approximately 10 % of the total tests (i.e., 7 tests) have been randomly selected as the test data, and the remaining 68 tests have been considered for training data. Fig. 7 illustrates the results obtained from the training and testing of the first ANN to predict the nugget size. The results indicate that the ANN has been trained successfully, and the first ANN can predict the nugget size very well. Table 5 displays the comparison between the results predicted from the first ANN and the results obtained from the experimental test. The results obtained from the second ANN model are almost similar to the first model. The results indicate that the second ANN model can predict the residual stress based on the RSW parameters with high accuracy. Fig. 8 presents the results of the training and testing of the second ANN model.

The Multi-Objective Genetic Algorithm
The genetic algorithm (GA) is a repeat-based optimization method and its principles are adapted from genetic science. In the GA, a set of design variables are encoded by fixed-length or variablelength strings, which the biological systems refer to them as chromosomes or individuals. GA is based on natural and biological science, and it is widely used to solve optimization problems in engineering. A non-dominated sorting genetic algorithm II (NSGA II) has been developed to optimize the RSW parameters to obtain a set of desired values for maximizing the nugget size and minimizing the residual stress. Since the GA is the minimizing algorithm, Eq. (3) has been used as the fitness function to achieve the desired goal.
where R is the residual stress, d is the nugget size, α and β are the weight coefficients for the residual stress and the nugget size, respectively. Because in this study there is no priority between the nugget size and residual stress, both α and β have been considered 1⁄2. Thus, the final fitness function is as follows: The flowchart of the developed multi-objective ANN-ANN-GA algorithm is presented in Fig.  10. The initial population size was 100 and was the same for each generation. According to this presented optimization algorithm, the nugget size and the residual stress were predicted by the ANNs. A different set of RSW parameters were born in each generation, and the nugget size and residual stress were predicted by ANNs inside of the integrated optimization algorithm. A two-point crossover rate of 0.5 and a uniform mutation probability of 0.05 were considered for the GA. In addition, 300 generations were chosen as the maximum generation and the condition for ending the algorithm.  Fig. 12. Since all the variables and outputs have been normalized between 1 and 2, the normalized parameters have been used in both ANNs and multi-objective GA.
high accuracy, and the optimum RSW parameters lead to high strength and good joint quality.

CONCLUSIONS
In this study, the RSW parameters of the electric current intensity, welding time, and electrode force have been optimized to achieve the largest nugget along with the lowest tensile residual stress in the RSW of the magnesium alloy AZ61. The full factorial DOE has been employed to investigate the effects of the RSW parameters on the nugget and the residual stress. The results of the DOE have been used to develop two separated ANN models. The ANN models have been utilized to predict the dimensions of the nugget and the maximum tensile residual stress in the welded zone. The results display that the proposed ANNs have a high accuracy in predicting the dimensions of the nugget and the residual stress. Finally, an integrated multi-objective ANN-ANN-GA has been developed to optimize the RSW parameters.
The results show that the presented optimization model can be used very well to optimize the RSW parameters.

REFERENCES
[ Thus, the optimized RSW parameters obtained from the proposed optimization algorithm are between 1 and 2. The real values of optimized RSW parameters are presented in Table 5.  Fig. 11. The results of the optimization algorithm, a) the best fitness value, b) average distance between individuals In order to evaluate the accuracy of the proposed multi-objective GA, a sample was welded based on the optimized RSW parameters. The nugget size and the residual stress were measured experimentally and were compared with the predicted one by the integrated optimization algorithm. Table 5 presents the results of this comparison. The results indicate that the integrated ANN-ANN-GA presented in this study can predict the nugget size and residual stress with