Research on Temperature Field Prediction Model of Electric Spindle Based on Improved BP Neural Network

The motorized spindle is the core component of CNC machine tools. In order to ensure its processing performance and processing safety, the temperature field of motorized spindle is studied. The three-dimensional model of the motorized spindle is established, and the convective heat transfer coefficient of the internal heat load and the simulation boundary condition are calculated by combining the heat transfer theory. The simulation is carried out by the finite element analysis software, and the internal temperature distribution of the motorized spindle under thermal steady state is calculated. Based on the numerical simulation analysis method and the thermal balance test method, the data basis for the prediction model of the motorized spindle temperature field is provided. The traditional BP neural network algorithm and PSO-BP neural network algorithm are used to predict the temperature of the motorized spindle measuring point under specific working conditions, and the temperature field prediction results are compared and analyzed. The results show that the PSO-BP neural network prediction model has good compatibility for variable data input, and the prediction results show little difference, which has high prediction accuracy and robustness.


Introduction
The high-precision cutting of high-speed motorized spindle can maximize the machining performance of CNC machine tools. Due to the high speed of high-speed motorized spindle and the heat between stator and rotor in the machine tool, a large amount of heat is generated in the motorized spindle. A large number of analysis and research show that 40% -70% of machining error of high precision machine tool is caused by thermal error (1990). A series of heat generation, heat transfer and heat dissipation problems within the motorized spindle have a great impact on the machining accuracy(2018).
Ultra-precision is one of the primary requirements of high-speed motorized spindle. Temperature distribution, speed control loading characteristics, precision maintenance, liberation strength and surrounding error are not only the key requirements of motorized spindle capacity, but also an important indicator to evaluate its performance(2013).The temperature rise and thermal displacement of motorized spindle seriously affect its dynamic characteristics. It is of great theoretical and practical significance to study the thermal behavior of motorized spindle(1682). Zhang et al.(2015) analyzed the deformation caused by temperature rise and loss of 170SD30 ceramic motorized spindle and metal motorized spindle. The results show that the electromagnetic loss and deformation of ceramic motorized spindle are less than those of metal motorized spindle, and the temperature of the former is lower than that of the latter under the same conditions. Li et al.(2021) used ANSYS to simulate the steady-state temperature field of the motorized spindle, discussed the influence of air gap eccentricity on the temperature field of the motorized spindle, and studied the circumferential temperature field distribution of the air gap of the motorized spindle.  analyzed the influence of air gap on the cooling of stator, rotor and bearing of motorized spindle. Wang and Bai(2018) explored the dynamic characteristics of motorized spindle under the influence of interference fit and thermal displacement. Using the heat transfer theory and bearing Harris theory, the temperature field model of motorized spindle is established to find the relationship between thermal displacement and interference. The results show that under the combined action of centrifugal force, load and thermal displacement, the interference fit between shaft and bearing decreases with the increase of rotational speed(2021). Cui et al.(2018) proposed temperature distribution and thermal deformation modeling and thermal-structural coupling simulation analysis method of vertical machining center motorized spindle system. Holkup et al.(2010) established a thermodynamic model based on the finite element method by fully considering the heat transfer generated by the internal motor and the factors of the spindle structure and coolant, and successfully analyzed the temperature distribution and the change of bearing stiffness and load.
With the increasing popularity of high-speed machining due to its high efficiency, it is urgent to predict the dynamic behavior of high-speed motorized spindle more accurately (2013).The thermal deformation prediction model of high speed motorized spindle is of great significance to improve machining accuracy and reduce spindle thermal error (2018).Thermal error is one of the important factors affecting the machining accuracy of machine tools. Dai and Xiong(2017) proposed two thermal error prediction models of motorized spindle based on adaptive neuro-fuzzy inference system and support vector machine. The results show that the adaptive neuro-fuzzy inference system model has higher prediction accuracy than the support vector machine model. Meng et al.(2020) established the mathematical model of motorized spindle considering the influence of various fractal parameters. According to the fractal theory, the thermal contact resistance (TCR) between the contact surfaces is proposed, and its accuracy is verified by the thermal contact conductance (TCC) verification experiment.Thermal deformation accounts for 40-70 % of the total size and shape errors caused by various sources of machine tools. Fan et al.(2018) proposed a hybrid model based on regression analysis and computational simulation to predict the thermal deformation of high-speed motorized spindle. The experimental results show that the hybrid model can effectively and accurately predict the thermal deformation, which can be used for real-time thermal deformation compensation and improve the machining accuracy of CNC machine tools. Yan et al.(2020) and Tao studied the variation of spindle temperature field and proposed a new thermal error modeling method based on the variation characteristics of spindle temperature field. Zhang et al.(2017) proposed a model to predict the temperature field of high-speed and high-precision motorized spindle under different working conditions by using the finite element model and experimental data. The genetic algorithm was used to optimize the heat transfer coefficient of the spindle, and the temperature field prediction model was established. Liu and Tie(2018) discussed and verified the influence of thermal coupling factor (TMCF) on the system cutting point transfer function and milling stability. The results show that the surface material properties and processing parameters have a certain influence on the milling stability(2018).Based on the adaptive chaotic particle swarm optimization algorithm, Yue et al. established the thermal error prediction model of the load machining state of the machine tool spindle system with the optimal specific cutting energy, and evaluated the prediction effect of the model. The results show that the temperature and thermal error of the spindle system are higher than those of the no-load state during the load machining(2012).
Temperature measurement method is one of the key issues in the study of thermal characteristics of high-speed motorized spindle. Guo et al.(2021) proposed a new method to optimize the position of thermal key points according to the position and number of thermal error temperature measuring points. Firstly, the temperature measuring points are grouped by fuzzy clustering method. Secondly, the grey correlation model is used to analyze the attention of each measuring point to thermal deformation in the temperature field distribution of motorized spindle. Finally, the temperature measuring points were optimized based on the modified determination coefficient. Zhou et al.(2021) affected the contact state of motorized spindle bearing by thermal deformation caused by temperature rise, and proposed an iterative method to solve the coupling equation, and built the motorized spindle temperature test bench to verify the proposed model. Deng et al.(2011) used highprecision sensors and high-frequency data acquisition system to establish the temperature and displacement measurement system, and established the thermal deformation compensation model based on the test results. Shi et al.(2019) established a special measurement system to measure the axial thermal deformation of the core cooling motorized spindle at different speeds. The thermal error compensation model based on exponential function is established by using the experimental data. The thermal deformation of the motorized spindle can be predicted by the model with only two parameters of the operating speed and duration of the motorized spindle. The experimental results show that the model has higher accuracy and better robustness. Liu et al.(2017) based on the five-point method synchronous measurement spindle temperature distribution and rotation accuracy of the test bench, reflects the coupling effect of thermal deformation and temperature, vibration curve and thermal tilt angle. Considering the influence of thermal deformation on the heat generated by the bearing, the results show that the front temperature of the spindle is high and has a great influence on the rotation accuracy, which needs to be controlled(2017).In the thermal error experiment, Liu and Zhu(2021) measured the thermal error of five-axis machining center motorized spindle by ball rod. BP neural network algorithm is introduced to predict the thermal error of five-axis machining center, and the prediction accuracy of these models is compared and analyzed.
Neural network technology has good data parallel processing ability and becomes the main research method of motorized spindle temperature prediction. Aiming at the problems of low machining accuracy and uncontrollable thermal error of CNC machine tools, Guo et al. established artificial neural network model and artificial bee colony model, and carried out the measurement experiments of heat source and thermal error. The experimental results show that the prediction model has high accuracy(2017). Henry and Rowley et al.(1998) established a forward face detection system based on neural network to improve the performance of a single network by arbitration between multiple networks . Chen et al.(2003) found that the prediction accuracy of regression analysis and neural network cannot meet the thermal elongation modeling, and then established an autoregressive dynamic thermal error model combined with historical temperature and speed data information, and proved that the model can improve the prediction accuracy. Kim et al.(2008) uses the artificial neural network algorithm to establish the network model with the tool length, feed rate, spindle speed, cutting path interval and jump as input neurons, and confirms that the neural network has good accuracy for the prediction of surface roughness. Burak(2018) explores the influence of drilling parameters on the tensile load of carbon fiber after drilling, and predicts the load by artificial neural network. The results show that the drilling data have an impact on the surface roughness, stratification and thrust, which proves that the calculation results of the network model are in good agreement with the experiment. Malghan et al.(2018) uses forward neural network to realize the demand response of terminal customers. This model can predict the processing response, and can also set the process parameters according to the experimental data .
In this paper, the heat transfer theory is mainly used to calculate the heat generation load number inside the motorized spindle and the convective heat transfer coefficient of the simulation boundary conditions. Based on the analysis of the steady-state temperature distribution of the motorized spindle, the experimental scheme for the temperature measurement of the motorized spindle is established and the experimental platform is built. After the temperature data of the measuring points required for the prediction model obtained by experiments, the traditional BP neural network algorithm and PSO-BP neural network algorithm are used to predict the temperature of the measuring points of the motorized spindle under specific working conditions, and the temperature prediction results are compared to verify the accuracy of the prediction model.

Structure and Thermal Analysis of Electric Spindle
In order to obtain the temperature distribution of the spindle, it is necessary to understand the structural characteristics of the motorized spindle. The axial position is the broach system, and the outward direction is composed of the spindle shaft body, the front and rear bearings, the built-in stator and rotor, the axial pre-tightening system, the oil and gas lubrication system and the water cooling system. The structural profile of high-speed motorized spindle is shown in Fig. 1. There are two heat sources in the actual work of the motorized spindle. One is the heat source generated by the surrounding environment affects the spindle, and the other is the internal heat of the motorized spindle. The external heat source is generally sunshine, heating equipment, and spindle working environment temperature and other factors, but these factors relative to the internal heat source for the motorized spindle less influence, can be ignored. The research content of this paper only considers the internal heat source of the motorized spindle. The internal heat source is mainly divided into two parts. One is the power loss heating of the built-in motor, and the other is the friction heat generated by the motorized spindle bearing due to the large centrifugal force and gyroscopic moment. The heat flow direction of motorized spindle can be represented by the heat exchange diagram of motorized spindle, as shown in Fig. 2

Heat generation of power system
The heat generation of power system is mainly the loss heating of built-in motor, in which the motor loss power generally has the following four types, namely, electrical loss, magnetic loss, mechanical loss and additional loss. Usually the additional loss is small, this article will ignore the impact of additional loss. 1.Electrical loss : The electrical loss is mainly due to the resistance of the wire wound by the stator and rotor of the motor, and there is loss when the current enters the stator and rotor along the wire.
In the formula, PW is the power of electric loss,ρ is the incoming current, L is the single winding distance of the copper wire, S is the cross-sectional area of the coil winding.
2.Magnetic loss : The magnetic loss is due to the influence of the harmonic of the frequency converter on the internal iron core of the stator and rotor of the built-in motor. The magnetic field will produce hysteresis loss and eddy current loss when it is rotated. max n mn P k fB = In the formula, Pm is hysteresis loss and correlation coefficient. kn is alternating frequency, f is the maximum magnetic induction intensity. 3.Mechanical loss : It is due to the high-speed rotation of the motorized spindle, and the friction between the shaft core rotor and the air in the stator gap of the motor generates the loss, which can be expressed by the following equation : In the formula, Pq is the power of mechanical loss,ρ is the air density of stator and rotor clearance, ω is the rotor angular velocity, L is the rotor axial length, Cq is the air flow resistance coefficient. L is the outer radius of rotor.

Heating of transmission system
The motorized spindle generates power through the motor, and the power is transmitted to the shaft core for rotation. The bearing is the main working part of the transmission. Due to the centripetal force and gyroscopic torque caused by rotation, the rolling body and the inner and outer rings of the raceway generate friction and heat. The spindle speed is fast and the internal structure is complex. The heat generated by the bearing accumulates inside the spindle. Once the temperature is too high to exceed the safe working temperature of the bearing, it will affect the working performance and life of the bearing, and affect the accuracy and service life of the motorized spindle. Therefore, it is necessary for the bearing to accurately predict the bearing temperature within the normal working range. Calculation of bearing friction heat is mainly through the overall method, bearing heat power can be calculated by the following formula (4): In the formula, Qf represents the friction heat generation power of the bearing, n represents the speed of the bearing, and M represents the friction torque of the bearing. The heat generation rate of front bearing can be solved by formula (5) : ( ) The heat generation rate of rear bearing can be solved by (6)  : ( ) In the formula, Db1 is the diameter of ceramic roller of front bearing, Db2 is the diameter of ceramic roller of back bearing, dm1 is the middle diameter of front bearing, dm2 is the middle diameter of back bearing.

Calculation of Heat Transfer Coefficient of Electric Spindle System
When calculating the convective heat transfer of cooling water, the outer air of the spindle shell, the compressed air in the working interval of the front and rear bearings, and the air gap between the stator and rotor, there are similarities, which belong to the fluid category. Therefore, the calculation method can be classified as the forced convective heat transfer generated by the fluid, which can be obtained by the following Equations (7) : 0.8 9.7 5.33 ll u α = +⋅ In the formula, α1 is the convective heat transfer coefficient between the rotor end face and the external air, and u1 is the rotor end face velocity.

Finite Element Analysis of Electric Spindle Temperature Field
In this paper, the steady-state thermal analysis is carried out by ANSYS Workbench software as a tool for analysis and research. The simplified model is imported into the analysis software, entered into the Steady-State Thermal and selected the material library. The material parameters of the motorized spindle components are added in the material library. The detailed material parameters are shown in table 1. The convective heat transfer coefficient of motorized spindle is shown in table 2. Convection heat transfer coefficient between motorized spindle system and external environment 9.7 Convection heat transfer coefficient between the end of motorized spindle and air 129 Convection heat transfer coefficient between front and rear bearings and compressed air 147、116 Convection heat transfer coefficient between motor stator and cooling water 328 Convection heat transfer coefficient of gas between stator and rotor 165 The grid model of motorized spindle is shown in Fig. 3. The heat generation rate of each heat source of the motorized spindle is shown in table 3.  The initial temperature of the motorized spindle is set to 22℃, and the analysis speed is 8000 r/min. The steady-state temperature field of the motorized spindle is analyzed. The analysis results are shown in Fig. 4. It can be seen from the steady-state internal temperature nephogram of the motorized spindle in Fig. 4 that the higher temperature part is the air gap between the stator and rotor of the motor and the contact part between the rotor and the shaft core, and the temperature is about 72.2℃. Due to the working of cooling water jacket outside the motor, the outer temperature is relatively low, but the temperature rise is higher because the air gap between the stator inner ring and the rotor is at the shaft core due to the accumulation of heat due to the poor heat flow. In addition, there are also some heating phenomena in the front and rear bearings, the front bearing is about 34.62℃, and the rear bearing is about 45.36℃. The front bearing is surrounded by cooling water, even if the heat generation rate is higher than the rear bearing, the temperature of the front bearing is still lower than the rear bearing. The lowest temperature is that the shell far away from the heat source is at the back end of the spindle, so the temperature is low.

of Electric Spindle System
In the study of motorized spindle temperature prediction technology, it is necessary to obtain a large number of experimental temperature data at the corresponding temperature measuring points. In this paper, 3101A motorized spindle as the experimental object, through the built-in sensor to contact with the external sensor, measuring the spindle key components bearing and spindle surface temperature point.

Temperature rise test of motorized spindle
The temperature detection system includes the detection of the outer surface temperature of the motorized spindle and the internal bearing temperature. The surface temperature of the motorized spindle collects the temperature signals collected by the temperature sensor through a multichannel data acquisition instrument, and records and stores them in the temperature detection system. The bearing temperature inside the motorized spindle can be collected into the motorized spindle dynamic data control box by the built-in sensor. The PT101 thermal resistance sensor is selected as the built-in temperature sensor at the bearing of the motorized spindle, and the K-type thermocouple is selected as the external contact sensor. The PT101 thermal resistance sensor extends the sensor to the bearing chamber through the punch at the back end of the spindle, and then the sensor probe is partially fixed by the punch in the bearing chamber and closely bonded with the bearing outer ring to obtain the temperature at the bearing. In addition, in order to facilitate the measurement of the surface data of the motorized spindle, the K-type thermocouple is equipped with a new BNC adapter to ensure the accuracy of data collection, increase the extension length of the Ktype thermocouple sensor, and the contact point is effectively fitted with the temperature measuring point to ensure the stability of data collection. The junction of Ktype thermocouple sensor and BNC is shown in Fig. 5.
The built-in motor stator and front and rear bearings are the main heat sources inside the motorized spindle, so the layout temperature measurement should be arranged as far as possible at or closest to the thermal distance, so as to better reflect the temperature of the motorized spindle heat source. The layout of the motorized spindle temperature measurement points is shown in Table 4  In Fig. 5, the measuring points from the front end to the back end of the outer surface of the motorized spindle are T3, T4 and T5, respectively, which are close to the surface of the motorized spindle. The positions of T3 and T5 correspond to the positions of T1 and T2 of the internal front and rear bearings of the motorized spindle respectively. a) K-type thermocouple wire b) BNC connector Donghua DH5922 multi-channel data acquisition instrument is used in the experiment to receive the temperature data transmitted back by the thermocouple sensor. The USB data connection line is connected to the PC, and the Donghua multi-channel data acquisition software is run in the PC to form a multi-channel data acquisition and analysis system.The composition of temperature acquisition system is shown in Fig. 7. After the completion of the instrument connection, the channel is debugged whether it works properly, and the parameters in the acquisition system are set after confirmation. The acquisition channel corresponding to the temperature measurement point is opened, and the acquisition frequency is set to 1HZ after initializing the parameters. The initial cold end temperature is set to 22℃, the type of temperature measurement is thermocouple, the type of temperature measurement is K-type (Ni-Cr-Ni-Si) thermocouple, the default value of the range is 485, and the input mode is differential input DIF_DC, which is used to differential capture electrical signals. The upper limit frequency is 10 Hz by default. Considering that the signal stacking in the acquisition signal causes the acquisition turbulence, it is necessary to open the anti-aliasing filtering function. The detailed parameter setting interface is shown in Fig. 8.   Fig.8. Internal bearing temperature acquisition system of motorized spindle A total of 5 points on the outer surface and internal bearing of 3101A motorized spindle were taken for temperature measurement. In order to facilitate the observation of temperature fluctuation, the time interval of acquisition temperature was adjusted to 1 min, and the total acquisition time was 180 min. The detailed operation scheme of motorized spindle is shown in Table 5. When the ambient temperature and the cooling water temperature of the water cooler are both 22℃, the temperature setting is shown in Fig. 9.

Experimental results and analysis
According to the four different influencing factors of time, rotational speed, ambient temperature and cooling water temperature, the temperature data of the five points measured by the experimental scheme are arranged. The temperature of the environment and the cooling water is set to 22℃, and the change curve of temperature with time and rotational speed is shown in Fig. 10. The spindle speed is 4000r / min, the working time is the same, the cooling water temperature is 22℃, and the environmental temperature is 25℃. The influence of time-varying environmental temperature is shown in Fig. 11.The spindle speed is 4000r / min, the working time is the same, the ambient temperature is 22℃, and the cooling water temperature is 25℃. The influence of cooling water temperature on the temperature of the motorized spindle is studied, as shown in Fig. 12. It can be seen from Fig. 10 that the temperature of the internal bearing of the motorized spindle is higher than that of each point on the surface, and the temperature difference between the internal front and rear bearings is large. All the measuring points of the motorized spindle are in a state of gradually rising temperature and tending to dynamic and stable equilibrium, and the upper and lower floating systems of the curve are affected by the intermittent cooling of the water cooler. Under the action of working time, the spindle temperature changes obviously from the beginning to the steady state. When it reaches the steady state and lasts for a period of time, the time influence factor is decreasing. It can be seen that working time is one of the reasons affecting the temperature of the motorized spindle. In the same time node, the same environmental temperature and cooling water temperature can be found that the higher the speed of motorized spindle temperature is relatively higher.
By comparing Fig. 10 and Fig. 11, it can be seen that when the ambient temperature is adjusted from 22℃ to 25℃ and other influencing factors remain unchanged, the points T3, T4 and T5 are directly contacted with the environment, resulting in an increase in the corresponding temperature, and the maximum temperature is above 25℃.
Because the T1 and T2 measuring points are deep inside the spindle, although these two points have a slight change, the overall temperature change range is smaller than that of T3, T4 and T5. However, it can also be found that the change of ambient temperature has an impact on the temperature measurement points of motorized spindle.
Comparing Fig. 10 with Fig. 12, it can be seen that when the cooling water temperature is adjusted from 22℃ to 25℃, and other influencing factors remain unchanged, the temperature of each measuring point changes to varying degrees. The highest temperature of T1 increased from 34.6℃ to 36.8℃, and the highest temperature of T2 increased from 39.2℃ to 40.8℃. The temperature of T3, T4 and T5 points increased, and T4 point was the highest point of the outer surface temperature of the motorized spindle, which reached 26.1℃ and increased by about 1.2℃.
From the experimental results, it is found that the rear bearing is the most serious key component in the internal bearing, and the outer surface measuring point corresponding to the stator of the motor is the highest point of surface heating. Therefore, selecting these two measuring points as the prediction points of the prediction model can better reflect the highest heating area of the spindle.

Numerical simulation and test of automatic discrete failure of ball bearing without cage
The motorized spindle has complex structure and no intuitive detection method can directly explore the internal temperature condition. There is no good warning mechanism for the temperature change of internal parts in the machining process. The temperature prediction of the motorized spindle can clarify the specific situation of the internal temperature and surface temperature of the spindle, so as to ensure the safety of the spindle operation and react to the abnormal temperature in time.

Temperature Prediction Based on BP Neural Network
The input layer of BP neural network is the receiving data layer, the hidden layer is the processing layer of information, and the output layer is the information release layer. After the error is found, BP neural network will complete the error feedback by the gradient descent method. The two modes of transmission are circulated, and the weights and thresholds of each layer are continuously adjusted to output the output value of the acceptable error range or the output value of the number of studies. In this paper, the four factors affecting the temperature of the motorized spindle are taken as the input layer of the BP neural network, and the output layer is the temperature of the corresponding prediction point. The structure of the BP neural network is shown in Fig. 13.
x 1 x 2 x 3 The number of hidden layer neurons is usually related to the number of input and output neurons. The number of neurons can be obtained by empirical formula : where m represents the number of neurons in the hidden layer, n represents the number of nodes in the input layer of the network, q represents the number of neurons in the output layer of the network, a represents the adjustment coefficient of neurons in the hidden layer, and the optional range is between [1, 10]. Sigmod function is selected as the activation function of the hidden layer and the output layer, and its function form is : The normalization method of maximum and minimum values is used to normalize the data. This method is suitable for the disorder of data fluctuation, and can approximate the data into the quasi-normal distribution, which is more conducive to the training and learning of samples.
Formulas maxY and minY represent the maximum and minimum values in the sample data respectively, and xi represents the original value of the sample. The original value in the sample data is mapped to the interval [0,1] by means of mean, and stored as xi'.
The tansig tangent function is used as the transfer function in the hidden layer in this paper. Other network settings parameters are shown in Table 6.

Temperature Prediction Based on BP Neural Network
Combining PSO optimization algorithm with BP neural network algorithm, the temperature rise prediction model of motorized spindle is constructed, which can give full play to the excellent global search ability of PSO algorithm. By optimizing the poor adjustment of weights and thresholds in the network structure of the neural network, the network matches the global optimal weights and threshold parameters to improve the neural network, so as to achieve more accurate prediction results. The flow chart of PSO-BP algorithm is shown in Fig. 14 If PSO particle swarm optimization algorithm wants to connect with BP neural network structure, it is necessary to determine the dimension D and number M of population particles in PSO algorithm. According to Formula (11), the particle dimension D in the population can be expressed as : The convergence effect of PSO optimization algorithm can be obtained by fitness function, and the corresponding optimization effect is the best when the fitness function reaches the minimum value. The fitness function is calculated according to formula (12).  Table 7 : The BP neural network is input into MATLAB to establish the network structure, and its hierarchical structure is shown in Fig. 15. The BP neural network and PSO-BP neural network are trained with the same experimental data to ensure the unification of the initial conditions of the prediction model. Based on the experimental data and the four influencing factors in Table 5 of the detailed operation scheme of the motorized spindle, the temperature data of measuring points reflected by different ambient temperatures and different cooling water temperatures at 6000 r/min at different times are used as the training sample set of the prediction model. The measured temperature data of cooling water and ambient temperature at 22℃ at 4000 r/min and 8000 r/min are used as the validation sample set of the prediction model. The temperature of the measuring point of the motorized spindle under the target condition is predicted, and the prediction results and prediction accuracy of the two models are further analyzed.

Forecasting results
Taking the PSO-BP neural network prediction surface temperature model at 8000 r / min as an example, the fitness convergence curve is shown in Fig. 15. According to Figure 16 curve, PSO converges quickly to the optimal solution in the 7th generation. The training sample set and verification sample set are input into MATLAB for calculation, and the final prediction results are output. The comparison of surface temperature prediction results between BP neural network and PSO-BP neural network at 4000 r/min is shown in Fig. 17. The comparison of the prediction results of the built-in bearing temperature of BP neural network and PSO-BP neural network at 4000 r/min is shown in Fig. 18. The comparison of surface temperature prediction results between BP neural network and PSO-BP neural network at 8000 r / min is shown in Fig. 19. 8000r/min BP neural network and PSO-BP neural network built-in bearing temperature prediction results are shown in Fig. 20 Compared with the surface temperature of each speed and the temperature of the built-in bearing, the PSO-BP algorithm is closer to the expected sample value for the temperature prediction curve of different parts than the traditional BP neural network.

Results and analysis of precision
The prediction performance index can comprehensively reflect the prediction performance of the prediction model. In order to more intuitively reflect the prediction error of BP neural network and PSO-BP neural network, the difference between it and the expected value is directly output through MATLAB. The comparison of surface temperature prediction errors between BP neural network and PSO-BP neural network is shown in Fig. 21.The comparison of prediction errors of built-in bearing temperature between BP neural network and PSO-BP neural network is shown in Fig. 22.  The average absolute error MAE is to adjust the average difference weight of all difference individuals to the same value, and directly calculate the average of the residual results. According to the data obtained from the two prediction methods and the judgment index of prediction ability, the statistical table of model prediction ability is made. According to the error results shown in Fig. 21 and Fig.  22, compared with Table 8 and Table 9, PSO-BP neural network shows better prediction performance under the corresponding prediction speed. PSO-BP neural network has higher determination coefficient R 2 , and RMSE and MAE are less than the traditional BP neural network, showing better prediction stability and prediction accuracy.

Conclusions
The actual heating temperature inside the motorized spindle is mainly studied, and the temperature distribution inside the spindle is analyzed. The temperature model is established according to the numerical simulation analysis method and the thermal balance experiment method. The temperature distribution of the motorized spindle is obtained by simulating the motorized spindle with the integral advance of the motorized spindle and the boundary conditions such as the internal heat source and the ambient temperature applied to the spindle. Experimental instruments such as temperature sensors are attached to the spindle surface to directly read the temperature to obtain the temperature information and temperature distribution of the motorized spindle. According to BP neural network and PSO-BP neural network, the internal and external temperature of the motorized spindle is predicted, which provides an early warning means for the temperature rise of internal and external parts, and prevents the overheating of the main parts of the motorized spindle to reduce the service life of the motorized spindle.
The conclusions of this study are as follows: 1)The overall structure, operation mode and heat transfer theory of the motorized spindle are studied, and the sources and components of the internal heating of the motorized spindle are analyzed. The heat generation rate and convective heat transfer coefficient of the main heat source inside the motorized spindle are calculated as the thermal load and boundary conditions of the finite element simulation, and the steady-state analysis is carried out by ANSYS Workbench to clarify the internal temperature distribution. Finally, it is found that the power loss of the stator and rotor of the motorized spindle and the friction between the front and rear bearings are the main heating causes and the main heat source locations.
2)After the internal temperature distribution of the motorized spindle is clarified, the internal temperature and surface temperature of the motorized spindle are measured. The results show that the rear bearing is the key component with the most serious heating in the internal bearing, and the measuring point of the outer surface of the motor stator is the highest point of surface heating. Therefore, selecting these two measuring points as the prediction points of the prediction model can better reflect the highest heating area of the spindle.
3)Based on the experimental data, the temperature prediction model of motorized spindle is established. The traditional BP neural network and PSO-BP neural network are compared as the prediction models. The final results show that the PSO-BP neural network has higher prediction accuracy and adaptability than the traditional BP neural network, and has better robustness to complex changes in data. It can better adapt to the input data and obtain more accurate results, which provides a new method for the temperature prediction of motorized spindle.

Declarations
Conflict of interest The authors declare no confict of interest.

Ethics approval
The authors confirm that they have abided by the publication ethics and state that this work is original and has not been used for publication anywhere before.

Consent to participate
The authors are willing to participate in journal promotions and updates.

Consent for publication
The authors give consent to the journal regarding the publication of this work.