# Quality Prediction and Parameter Optimisation of Resistance Spot Welding Using Machine Learning
## 4 Results and Discussion
### Objective Optimisation Based on the Particle Swarm Algorithm  
Based on the prediction model, the particle swarm optimisation algorithm was used to find the best welding process parameters. The objective of the optimisation problem was to set the required tensile shear load, positive electrode nugget diameter, and negative electrode nugget diameter to obtain the optimal process parameters.  
The quality of weld joints can be classified according to the following criteria [31,32]:  
\[\text{D}=\frac{3.2\text{t}}{\text{f}} \tag{9}\]  
where, D is the critical nugget diameter and t is the thickness of the plate metal--in this paper, t = 0.2 mm; f is the weld porosity factor--f = 1.0 means perfect weld quality, free of porosity and irregularity. The value of f was set to 0.8, taking into account the porosity and irregularity of the weld seam under real production conditions. The critical nugget diameter was approximately 0.8 mm. Therefore, the positive electrode nugget diameter and the negative electrode nugget diameter were both greater than or equal to 0.8 mm.  
Through experiments, it was found that welding quality performs well when the nugget diameter is in the range of [0.8, 1.1], especially when the nugget diameter is \(1\pm 0.1\) mm and the maximum tensile shear load reaches 250 N. To reflect the particle swarm optimisation algorithm that can effectively optimise the process parameters, this paper used two methods to verify the effectiveness of the PSO algorithm. The optimisation problems of the two optimisation methods are shown in Table 6.  
To balance the search capability and computation of the particle swarm algorithm, the initial settings of the particle swarm were as shown in Table 7.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Method I** & **Method II** \\ \hline
**Object** & \multicolumn{2}{c}{**Maximise TSL**} & **TSL = 230 N** \\ Subject to & 0.8 mm \(\leq\) PEN, NEN \(\leq\) 0.9 mm & 1 mm \(\leq\) PEN, NEN \(\leq\) 1.1 mm & PEN = NEN = 1 mm \\  & 2100 \(\leq\) WVI, WV2 \(\leq\) 2400, 2 \(\leq\) WT1, WT2 \(\leq\) 3.5, 0.2 \(\leq\) CT \(\leq\) 2, 0.2 \(\leq\) SRT, SDT \(\leq\) 0.8 \\ \hline \hline \end{tabular}
\end{table}
Table 6: Two optimisation methods.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Variable** & **Population Size** & **Iteration Times** & \multicolumn{2}{c}{**Dimensionality of**} & \multicolumn{2}{c}{**SOLUTION Space**} \\  & & **Particle** & **Accelerating Factor \(C_{1}\)\(C_{2}\)** & **Range** \\ \hline Value & 30 & 100 & 7 & 1.5 & [0, 1] \\ \hline \hline \end{tabular}
\end{table}
Table 7: Initial value of the PSO.  
Figure 7: Comparison of predicted values and experimental values. (**a**) PEND of comparison chart; (**b**) NEND of comparison chart; (**c**) TSL of comparison chart.  
In Method I, the maximum tensile shear load for nugget diameters in the ranges of [0.8, 0.9] and [1, 1.1] was proposed. The best process parameters obtained under this method were [2173, 2, 2, 2100, 3.5, 0.2, 0.8] and [2400, 3.5, 0.2, 2300, 3.5, 0.4, 0.5], corresponding to the predicted weld quality (PEND, NEND, TSL) of [0.8771, 0.8508, 173.2029 ] and [1.03, 1.01, 253.287 N]. Specific experimental values and predicted values of the relative error are shown in Table 8, and the actual welding nugget diameter is shown in Figure 8.  
In Method II, the proposed tensile shear load was 230 N, and the nugget diameter was 1 mm in the case of the optimal set of parameters [2400, 3.5, 0.6, 2129, 3.5, 0.5, 0.3]. This set of parameters was used in two experiments; the results of each experiment, and their predicted results, are shown in Table 9. The welding results are shown in Figure 9.  
lithium battery manufacturing. Especially when predicting tensile shear load, the accuracy of tensile shear load is more stringent in actual production.