# Optimization of a Multi-Type PMSM Based on Pyramid Neural Network
## 2 Dataset Preparation
### Database Generation  
In this paper, by adjusting the structural parameters of four different types of motors, 500 groups of electromagnetic field distribution data of each type of motors were obtained using FEM solver. Although the calculation time of electromagnetic field distribution takes about 1 min in a single case, it will still take a huge amount of time to establish the whole training database if the parameter is adjusted manually. Therefore, Python scripts were created to automate FEM simulations of different types of HPMSM with different structural \begin{table}
\begin{tabular}{c c c c} \hline
**Parameters** & **Values** & **Parameters** & **Values** \\ \hline Outer stator diameter & 120 mm & Rated speed & 100 kppm \\ Inner stator diameter & 60 mm & Rated power & 10 kW \\ Air gap length & 2 mm & Rated voltage & AC 380 V \\ Axial length & 70 mm & Rated current & 20 A \\ PM thickness & 4 mm & PM type & N38 UH \\ \hline \end{tabular}
\end{table} 
Table 1: Main design parameters of the PMSM. \begin{table}
\begin{tabular}{c c} \hline
**Type** & **Design Parameters** & **Value Ranges** \\ \hline \multirow{4}{*}{Stator} & Slot opening width & 0.5–2.0 mm \\  & Slot width & 1–2 mm \\  & Tooth tip height & 1–2 mm \\  & Slot depth & 10–20 mm \\ \hline \multirow{4}{*}{Rotor} & PM width & 3–6 mm \\  & PM length & 3–10 mm \\  & (except for surface-mounted type) & \\  & Magnetic gap length & \\  & (except for surface-mounted type) & \\  & Angle of magnetic pole & \\  & (only for surface-mounted type) & \\  & Pole pair number & 1 or 2 \\ \hline \end{tabular}
\end{table} 
Table 2: Initial design parameters of the HPMSM. Figure 2: Configuration and mechanical structure of the HPMSM. (**a**) Stator slot. (**b**) Side view of the mechanical structure. parameters, and batch commands were used to realize parallel calculation process. The calculations covered in this article were all performed on a High Performance Computing (HPC) supercomputer platform. Figure 3 shows the flow chart of HPMSM parameter database generation. First, the structural parameters were randomly combined using Python script, corresponding material properties and boundaries were added through input and excitation was assigned, and then FEM simulation was carried out. The calculated electromagnetic field distribution was an ultra-long sequence containing magnetic potential data of all nodes, which, together with the (\(x\), \(y\)) coordinates of all nodes, constituted a sample. However, with the change of motor structure, the number of nodes changed, leading to different sequence lengths of different samples. If it was directly trained in the deep learning model, the program could not be read. Secondly, the electromagnetic field data generated using the finite element calculation is often multi-digit decimal, and the derived data may contain non-numeric lines, which makes it difficult to identify the program. Therefore, it was essential to adopt the corresponding method to preprocess the data. The preprocessing steps used in this paper included data cleaning and data transformation. According to the range and equal step size of the above design variables, the four design variables were combined with each other in accordance with the principle of controlling the shift of a single variable to produce 600 groups of structural coordination, that is, 600 different motor structure schemes. Examples of the motor schemes are shown in Tables 3 and 4.