Abstract
Thermal error is the key factor affecting the machining accuracy of high-precision CNC machine tools. In order to solve the problem of thermal error of dual-spindle turning and milling machine tools, this study proposes an optimized CNN-BiLSTM Hybrid Network based on the SCSSA. Firstly, the thermal error experiment was carried out on the 1200MSY turning-milling double-spindle composite machine, and the temperature field data and thermal error data corresponding to the two spindles were collected. The K-means clustering-grey association coupling algorithm was used to screen the temperature-sensitive measurement points. Subsequently, the hyperparameters of the CNN-BiLSTM network were optimized with SCSSA to improve its modeling efficacy. The experimental findings indicate that: (1) SCSSA exhibits a superior convergence rate and enhanced global search capability compared to GWO and WOA algorithms during parameter optimization; (2) the proposed model achieves reductions in RMSE and MAE by 38.77% and 47.06%, respectively, when compared to benchmark models; (3) the prediction error variations are maintained within ± 4.6 μm under multiple speed conditions and ± 5 μm across various spindle types. This study provides an intelligent prediction scheme with high engineering practicality for thermal error prediction of dual-spindle turning-milling compound machine tools.
Similar content being viewed by others
Introduction
The machining accuracy of CNC machine tools is affected by multiple factors, primarily including errors caused by thermal errors, geometric errors, cutting forces, and other types of errors that collectively influence machine tool machining accuracy1. Among these, thermal errors are the main source of precision errors in machine tool processing, accounting for 40%-70% of the total errors and being a key factor limiting the improvement of machining accuracy2. Therefore, researching efficient and accurate thermal error modeling methods is of great significance for improving the machining accuracy of CNC machine tools.
Currently, methods for modeling external heat error are mainly divided into two categories: heat error avoidance and data-driven heat error compensation3,4. Thermal error avoidance focuses on reducing the generation of thermal errors from the source by optimizing machine tool hardware design, such as improving structures, adopting low-energy components, and optimizing cooling systems. In contrast, thermal error compensation establishes thermal error models to predict and compensate for the original errors of the machine tool. Compared to thermal error avoidance, thermal error compensation offers multiple advantages, including low cost, high flexibility, and strong adaptability. However, during machine tool operation, thermal errors vary in real time according to changes in environmental and operational conditions, exhibiting highly nonlinear characteristics, numerous influencing factors, and strong coupling5. Therefore, thermal errors are difficult to predict. In recent years, with the development of machine learning technology, numerous scholars have made significant progress in machine tool thermal error modeling.
Li6 established a thermal error prediction model based on optimizing a BP neural network using an improved particle swarm optimization (IPSO) algorithm. A SOM neural network was employed to cluster temperature measurement points, and a correlation analysis method was utilized to investigate the correlation between thermal sensitive points and thermal error. The IPSO algorithm was used to optimize the initial weights and thresholds of the BP neural network. The results indicate that, compared to the GA-BP prediction model, the IPSO-BP neural network prediction model demonstrates superior modeling efficiency, robustness, and accuracy. Additionally, it can accurately predict the main spindle thermal error under different working conditions.Ali M7 proposed a grey prediction model optimized by cuckoo search (CS) for machine tool thermal error prediction, and by comparing it with a grey prediction model based on PSO, demonstrated the feasibility of the CS-optimized grey model.Li8 addresses the nonlinear time-varying characteristics of thermal errors in machine tools by proposing a BP neural network optimized with a bat algorithm (BA-BP). By employing swarm intelligence optimization, the limitations of traditional BP networks in cross-condition robustness are overcome, where the bat algorithm optimizes the initial weights and thresholds of the BP network. Experimental validation demonstrates that, compared to traditional BP networks, the BA-BP model exhibits superior stability, prediction accuracy, and robustness.Ye9 combined the variable selection capability of the least absolute shrinkage and selection operator (LASSO) with the efficient modeling of eXtreme Gradient Boosting (XGBoost), addressing the limitations of traditional methods under collinearity and dynamic conditions. Compared with OLS, LASSO-SVM, and RF algorithms, the prediction accuracy of thermal error improved by more than 14.5%.Zhu10 addresses the issue of thermal error non-linearly affecting the precision of machine tools by proposing a thermal error prediction method based on random forests and feature optimization. The model optimizes hyperparameters through grid search combined with cross-validation. By iteratively eliminating redundant features, it achieves the selection of key temperature points. Additionally, a time lag determination method based on feature importance permutation is proposed, effectively considering the lag effects between temperature changes and deformation. Experimental validation demonstrates that, compared to traditional machine learning methods, this approach offers advantages such as reduced training data requirements, faster and more intuitive parameter tuning, and higher prediction accuracy.Shi11 In order to decrease the thermally induced positioning error of machine tools, by proposing a Bayesian neural network (BNN)-based thermal error prediction approach. Temperature-sensitive points were selected using fuzzy c-means clustering with Dunn index optimized group numbers, effectively inhibiting multicollinearity among measuring points. Experimental validation demonstrated that the BNN model reduced maximum positioning error by 71% (from 18.2 μm to 5.14 μm) compared to BP neural networks and multiple linear regression, while maintaining superior prediction accuracy and robustness across varying working conditions. Chen et al.12 to address temporal lags among temperature measurement points in thermal error prediction, developed a thermal error prediction using a GRU based time series neural network with an attention mechanism. This approach leverages weighted historical temperature sequences to capture thermoelastic hysteresis effects while integrates real-time working condition data from CNC systems for thermal error prediction. Experimental validation demonstrates that the proposed model outperforms conventional RNN/LSTM methods, achieving a compensation rate exceeding 75% and reducing thermal error from 20 μm to 5 μm.
The modeling process for thermal errors in machine tools described above is largely based on temperature and thermal error data collected through experiments, with the data of temperature-sensitive points after screening being used as input for modeling. Optimization algorithms are employed to optimize parameters in order to enhance the performance of the predictive model. Although the above research has made remarkable progress, there are still many limitations: for example, insufficient consideration of the time series characteristics of thermal error leads to limited prediction accuracy. Although network models such as gated recurrent units (GRU) are used, which possess strong adaptability to data temporal sequences, GRU can only process data in temporal order and cannot utilize future information for prediction. At the same time, most of them use a single neural network model, which is difficult to capture the high nonlinearity of thermal error and the correlation between many influencing factors and high degree of coupling. In addition, most models are only validated at a fixed speed of a single spindle, lacking the operating conditions of multiple speeds in a two-spindle machine The performance evaluation restricts the engineering practicability of the model in the real-world multi-spindle collaborative machining scenario.
In order to solve these problems, this paper proposes a thermal error prediction model for dual-spindle turning and milling machine tools based on SCSSA-CNN-BiLSTM to further improve the dual-spindle turning and milling machine tools thermal error prediction effect.The convolutional neural network (CNN) component is highly effective in automatically extracting these spatial local features and sensor relationships from multiple temperature input data, which has a significant advantage over simply using flat LSTM inputs. BiLSTM is composed of forward and backward LSTM layers, and combines the characteristics of LSTM with the ability to process bidirectional data. This bidirectional structure is of great value because it enables the model to understand background information from past and future states, which is helpful in capturing the lag effects that often occur during heat treatment processes.For the screening of thermal sensitive points, the temperature rise data under the set speed of the machine tool was processed by combining K-means and gray correlation, and the temperature rise data of the temperature sensitive points of the machine tool was used as the input of the model, and then the CNN was analyzed by the SCSSA optimization algorithm-The structural parameters of the BiLSTM network model were optimized to improve the accuracy of the prediction model. In addition, a multi-angle comparative experiment is constructed for different working conditions of the same spindle and the same working condition of the double spindle to verify the thermal error modeling for the dual-spindle turning and milling machine tools proposed in this paper validity.
Thermal error modeling method
Convolutional neural networks
Convolutional Neural Network is a well-known and widely used algorithm in deep learning, a deep neural network that achieves deep learning of data representation through local connections, weight sharing, and hierarchical feature extraction, serving as the core tool for processing spatial data13. Compared with other network models, CNNs can better identify features and make use of existing features. The convolutional layer is one of the core parts of CNN, which performs convolution operations on the input data and extracts the latent features of the data. The calculation formula is as follows:
where:\({H_i}\)represents the feature quantity output by the i layer; \({W_i}\)and \({b_i}\)denote the bias and weights; \(\otimes\)represents the convolution operation; \({X_i}\)represents the input data; g is the \(\operatorname{Re} lu\)activation function.
The main function of the pooling layer is to reduce the dimensionality of the output data of the convolutional layer, remove the redundancy of information, and speed up the calculation. At the same time, the feature has translational invariance. The calculation formula is as follows:
Where:\({P_i}\) is the pooling function,\({H_i}\)and \({H_{i+1}}\)are the feature quantities before and after pooling, respectively.
Bidirectional long short-term memory network
Recurrent neural network (RNN) is a powerful neural network that processes sequential data, but RNN neural network has the problem of gradient vanishing. Gradient vanishing refers to the fact that in RNNs, it is difficult for RNNs to capture long-distance data dependencies as the length of the time series increases. LSTM can effectively solve the gradient vanishing problem in RNNs, especially in processing long-distance time series data, which is much better than recurrent neural networks14. The LSTM structure is shown in Fig. 1.
LSTM structure diagram.
The LSTM has three new basic gating structures: the forgetting gate, the input gate, and the output gate. The formula is as follows:
Where:\({f_t}\) represents the state of the forget gate at time t ;\({i_t}\) represents the state of the input gate at time t; \({o_t}\)represents the state of the output gate at time t; \({x_i}\)represents the input vector at time t; \({h_{i - 1}}\)is the output vector at time t; \(\sigma\) is the \(sigmoid\)activation function; Wis the weight matrix; b is the bias; \(\widetilde {{{C_t}}}\)is the candidate cell state; and \({C_t}\)is the new cell state.
The BiLSTM model consists of a forward-facing LSTM layer and a backward LSTM layer, and the two LSTM layers are trained from the front and back of the data, so that the sequence can be processed in both directions, and the internal relationship between the current data and the data in the past and future tense can be further explored. It can improve data utilization and model prediction accuracy. The BiLSTM structure is shown in Fig. 2.
Structure of BiLSTM.
Sparrow search algorithm that fuses sine and cosine and cauchy variation
Sparrow search algorithm combining sine-cosine and cauchy mutation
Sparrow Search Algorithm (SSA)15 is a meta-heuristic optimization algorithm based on the foraging and anti-predation behaviors of sparrow groups. SSA achieves global optimization in the parameter space through the synergistic interaction of three functional categories: discoverers, scroungers and investigation early warning mechanism. However, SSA has the problems of insufficient ability, loss of population diversity, and easy to fall into local extremes in the later stage of optimization. Therefore, this paper introduces a Sparrow Search Algorithm Combining Sine-Cosine and Cauchy Mutation(SCSSA).
Refractive inverse learning strategy
SCSSA uses a dimension-by-dimension inverse learning strategy for small hole imaging. By synergizing the inverse learning strategy of small hole imaging and dimension-by-dimension reverse learning, the algorithm can get rid of the local extremum16 by performing a dimension-by-dimension inverse solution for a feasible solution. This strategy takes the top individuals in fitness ranking as the initial population, which reduces the risk of the algorithm falling into the local optimal solution. The initialization formula for the sparrow population is:
Where:\({x_{_{{i,j}}}}\) represents the position of the i sparrow in the j dimensional space, \(x_{{i,j}}^{*}\) represents the reverse refraction solution of \({x_{i,j}}\); \({l_j}\) and \({u_j}\) are respectively the minimum and maximum values of the j dimension in the search space; kas a regulatory factor
Sine-cosine algorithm
In the sparrow search algorithm, the spatial distribution of food sources directly affects the search direction and collaboration efficiency of individuals in the population, and the uneven distribution of food sources will lead to the producers falling into the local optimal solution. The homogeneous migration of scroungers leads to a decrease in population diversity and increases the likelihood of falling into local extremes. In view of this phenomenon, the sine-cosine algorithm (SCA)17 is embedded in the producers position update. SCA uses the oscillation variation characteristics of the sine and cosine model to act on the position of the discoverer, and performs global and local optimization to obtain the global optimal value. Get a new producers location update formula as:
Where: \({r_2} \in \left[ {0,2\pi } \right]\)is a random number that determines the movement distance of the sparrow; \({r_3} \in \left[ {0,2\pi } \right]\) is a random number used to control the influence of the optimal individual on the subsequent position of the sparrow; \(r_{1}^{\prime }\) is a nonlinear decreasing search factor; \(\omega\)is a nonlinear weight factor.
Cauchy mutation strategy
In the process of foraging for sparrows, the competition between individuals for food often makes scroungers become discoverers, resulting in the decline of population diversity. To prevent the algorithm from falling into local optima, the Cauchy mutation strategy is introduced in the scrounger update formula to enhance global optimization capabilities. Below is the updated follower position formula:
Where:\(cauchy\left( {0,1} \right)\) represents the standard Cauchy distribution function. The Cauchy distribution and the normal distribution are both continuous real-valued probability distributions, but the Cauchy distribution has lower probability near the origin, slower tail exponential decay with higher probability, and a significantly higher probability of extreme values compared to the normal distribution. Therefore, by applying Cauchy variation to perturb the position of the sparrow, the search range of the sparrow search algorithm can be expanded, thereby enhancing the algorithm’s potential to escape local optimal solutions18.
Investigation early warning mechanism
Considering the safety of the sparrow population and the ability to obtain food, the sparrow will select 10%~20% of the individuals from the population for reconnaissance and vigilance, and the location will be updated as follows:
Where:\(\beta\) is a random number generated from the standard normal distribution; k is a random number between \(\left[ { - 1,1} \right]\); \(\varepsilon\) is a very small constant, the purpose of which is to avoid the inability to update the position when the denominator is 0; \({f_i}\) represents the fitness of the i th sparrow, \({f_{_{g}}}\) and \({f_w}\) are respectively the best and worst fitness values of the current sparrow population.
In summary, the SCSSA algorithm integrates the adaptive adjustment mechanism of the SCA, the initialization strategy of the refractive reverse learning, and the global disturbance ability of the Cauchy mutation. By doing so, it significantly improves the convergence speed, accuracy, and robustness while maintaining the original framework of SSA, providing a more effective solution for complex optimization problems.
Screening of temperature sensitive points
In order to improve the efficiency of model modeling and reduce the amount of calculation, K-means and grey correlation analysis are used to screen the temperature sensitive points of the machine tool spindle. The basic steps are: K-means divides the data into K groups in advance, randomly selects K objects as the initial clustering center, and then The Euclidean distance from each sequence to the center of mass is calculated. According to the similarity between the data and the clustering center, the position of the clustering center is continuously updated, and the Sum of Squared Error (SSE) of the cluster is continuously reduced ), when the SSE no longer changes or the objective function converges, the clustering ends to obtain the final result19. In the K-means clustering algorithm, determining a suitable K value (i.e., the number of clusters) is a key problem. In this paper, the Gap Statistical method is used to determine the indicators. The following is the definition of Gap:
Where:\(\log \left( {{D_k}} \right)\)represents the dispersion of observed data clustering; \({E_n}^{*}\left( {\log \left( {{D_K}} \right)} \right)\)is the expected value of \(\log \left( {{D_k}} \right)\). The basic process of the algorithm is first to generate uniformly distributed random samples in the region where the samples are located, with the same number as the original samples, and to perform K-means clustering on this random sample multiple times to obtain multiple \({D_k}\) values. The logarithms of these multiple \({D_k}\) values are taken and averaged to obtain an approximate value of \({E_n}^{*}\left( {\log \left( {{D_K}} \right)} \right)\). When the interval statistic \({E_n}^{*}\left( {\log \left( {{D_K}} \right)} \right)\) achieves its maximum value, the corresponding k value is the opti.mal number of clusters20.
Grey relational analysis determines the relationship between temperature rise data and thermal error by calculating their correlation. In the K classes obtained from K-means clustering, the temperature measurement point with the highest correlation in the temperature rise data is identified as the temperature sensitive point for that class, thereby screening out the temperature sensitive points for predicting the main axis thermal error.The grey correlation analysis is as follows:
Where:\(\rho =0.5\)is the resolution coefficient; \(y\left( t \right)\) is the target sequence; \({x_j}\left( t \right)\) is the comparison sequence.
Experimental data processing
To enhance the training efficiency and generalization performance of the model, the input data of the model is preprocessed. At the same time, to preserve the integrity of the original data and ensure the correct scaling of the model input, only normalization is used to preprocess the original data. Normalization converts the original temperature data into a range of [-1, 1]. The formula for normalization is as follows:
Where: X represents the original temperature data;\({X_{\hbox{min} }}\)and\({X_{\hbox{max} }}\) represent the minimum and maximum values of the dataset, respectively༛\({X_{norm}}\) represents the normalized value (range).
Thermal error experiment of machine tool spindle
Design of experiments
To verify the feasibility of the proposed SCSSA-CNN-BiLSTM thermal error prediction model, experiments were conducted on a dual-spindle turning-milling machine to obtain temperature field data and thermal error data for the left and right spindles. In the experiment, two thermal error sensors were mounted on the workbench with the workpiece to measure the axial and radial thermal displacement data of the spindles. Eleven PT100 platinum resistance temperature sensors were arranged at the core parts of the machine spindles to measure the temperature rise of the machine spindles. It was found during the experiment that the radial thermal error values of the spindles were within ± 0.2 μm, while the axial thermal error of the spindles was more pronounced. Therefore, this paper selects the axial thermal error of the spindles as the primary research object. The thermal error sensor and temperature sensor arrangement are shown in Fig. 3.
The distribution of the main shaft sensors on the right side of the machine tool. T1, T3, T4, T6, T8 measure the temperature change at various points of the spindle, T2, T5, T7, T9, T10 measure the temperature change throughout the headstock, and T11 is the ambient temperature.
In the actual machining process, the machine spindle will show a variety of working states. In order to ensure that the thermal error prediction model has generalization ability and accuracy, experiments on the right spindle at different speeds (spindle idling) were designed to target different working conditions. The details are shown in Table 1.
In order to verify the applicability of the dual-spindle thermal error prediction model to the dual-spindle structure, the left-hand spindle 8000r/min corresponding to the 8000r/min condition of the right-hand spindle was designed Thermal error experiments to test the predictive performance of the model on different spindles. The arrangement of the left main shaft thermal error sensor and temperature sensor is shown in Fig. 4.
Temperature distribution points of the main spindle on the left side of the machine tool.
Experimental data presentation
To address the issues of data set sufficiency and model generalization ability, a total of 2000 data samples were collected during the experiment. Each sample contained a multi-dimensional input vector (temperature readings from 11 sensors) and the corresponding axial thermal error measurement value. The data was collected every 5 s and was continuously run for several hours at different rotational speeds (2000 rpm, 5000 rpm, 8000 rpm, and 10000 rpm) to capture transient and steady-state thermal behaviors. The data set was divided using a systematic approach: one sample out of every 10 was selected as the test set, resulting in 200 test samples and 1800 training samples. Figures 5 and 6 are the timing diagrams of the 11 temperature rise data and the axial thermal error of the spindle at 8000 r/min, respectively.
Temperature rise sequence diagram of the main shaft at different measurement points at 8000 r/min.
Thermal error time sequence diagram of the main spindle operating at 8000 r/min.
Establishment of thermal error model
Critical temperature sensitive points are determined
During the experimental design phase, in order to ensure that the temperature rise data of various parts of the machine tool spindle could be collected, 11 temperature sensors were placed at different locations on the spindle. However, too many temperature measurement points may cause the problem of data collinearity, and excessive data collinearity will lead to an increase in the complexity of thermal error modeling calculations and a decrease in modeling efficiency.
Through K-means clustering analysis and grey correlation analysis, the classification and correlation degree of the 11 temperature measurement points were calculated respectively. The specific flowcharts of K-means clustering analysis and grey correlation analysis are shown in Fig. 7.
K-means clustering analysis and grey correlation analysis flowchart.
The grey correlation analysis shows that under the condition where the right main shaft rotates at a speed of 8000 r/min, the calculation results of the grey correlation degrees at 11 temperature points are presented in Table 2.
The final clustering results and the selected key temperature-sensitive points are shown in Table 3. The temperature-sensitive points under five different operating conditions are presented in Table 4.
Design and comparison of CNN-BiLSTM hybrid network model architecture
To verify the superiority of the CNN-BiLSTM architecture, we conducted preliminary experiments on different architectures and evaluated the performance of several models on the dataset, including: CNN, LSTM, BP, and CNN-BiLSTM.The results are summarized briefly as shown in Table 5, and the predictions are explained based on the operating conditions of the operation at a rotational speed of 8000 revolutions per minute on the right main axis.
From the results, our CNN-BiLSTM model performed the best, indicating that it has a strong predictive ability. Therefore, we chose the CNN-BiLSTM architecture as the base model for our thermal error modeling problem.
(2) The sequence folding layer is used to reconstruct the dimension of the input data to adapt to the requirements of convolution operation; The CNN feature extraction module consists of two layers of convolutional layer and one layer of pooling layer, and the size of the first layer of convolutional kernel is set to [2,1], The second layer convolution kernel size is [1,1], and the number of convolution kernels is 10, and the step size is1. Convolutional layers are used to capture the local spatial correlation of temperature data. The pooling layer adopts the maximum pooling layer method, and the [1 × 5] window is selected for feature compression, and the dimensionality reduction process is realized while retaining the salient features. Time series feature extraction module: After the data format is converted through the sequence expansion layer and the flattening layer, the time series network composed of three layers of BiLSTM stacking is input. Each BiLSTM layer is followed by Dropout layer with 0.3 probability of randomly discarding input data to enhance the generalization ability of the model; Regression output layer: The high-order spatiotemporal features are mapped to the target dimension through the fully connected layer, and the predicted value of the axial thermal error is finally output. Figure 8 shows the structure of the CNN-BiLSTM network model.
CNN-BiLSTM hybrid network model structure.
SCSSA-optimized CNN-BiLSTM prediction model
The hyperparameters in the network structure have a significant impact on the prediction accuracy and model fitting ability to ensure the best prediction results. The specific steps of SCSSA optimization are as follows:
Step 1: Set the sparrow population size to 30, the number of iterations to 50, and the proportion of discoverers to 30%. The search range for the number of hidden neurons in the three BiLSTM layers is set to [5,200], [5,100], and [5,100], respectively. The search range for the initial learning rate is set to [0.0001,0.01], and the search range for the L2 regularization coefficient is set to [0.0001,0.1].
Step 2: Improve the initialization of the population according to the refractive inverse learning strategy.
Step 3: Calculate the fitness of sparrow individuals according to the Root Mean Square Error (RMSE), record the position and fitness of the optimal individuals and rank them.
Step 4: Iteratively update the producers position and its fitness according to Eq. 5.
Step 5: Iteratively update the scroungers position and its fitness according to Eq. 6.
Step 6: Iteratively update the location of the sentinel and its fitness according to Eq. 7.
Step 7: When the termination iteration condition is satisfied, the optimal hyperparameters of the network are obtained. Otherwise, go back to the third step and iterate in a loop.
Step 8: After the iteration, the number of hidden layer neurons, the initial learning rate and the optimal combination of L2 regularization coefficient of the three BiLSTM layers optimized by SCSSA are input into CNN-BiLSTM network for prediction.
The overall optimization process of the SCSSA-CNN-BiLSTM prediction model is shown in Fig. 9.
The overall optimization process of the SCSSA-CNN-BiLSTM prediction model.
Performance verification and parameter optimization results of SCSSA optimization algorithm
To test the performance of the SCSSA algorithm, a comparison was conducted using commonly employed algorithms: the Grey Wolf Optimizer (GWO)21, the Whale Optimization Algorithm (WOA)22, the Ocean Prey Algorithm (MPA)23, and the Dung Beetle Optimizer (DBO)24. It is applied to the CNN-BiLSTM network model for comparison and evaluation, and the number of populations and iterations in the algorithm is set to be consistent, and the experimental input data are consistent to ensure the reliability of the experimental results. Under the condition that the spindle speed is 8000r/min, the fitness values of the five optimization algorithms change in the iterative process as shown in Fig. 10.
Five types of algorithm iterative change curves.
Experimental results show that the five optimization algorithms have completed convergence within 35 iterations, and the SCSSA has a significant advantage, ranking 14thThe generation completes the convergence, and the convergence speed is the fastest. In terms of the final convergence value, the fitness value of SCSSA after convergence is 0.69267, which is the best among the five algorithms. Observing the iterative process, it is found that the GWO and WOA algorithms will experience a long period of fitness stagnation during the iteration process, while SCSSA does not have a long-term stagnation of fitness values. Among the five algorithms, the SCSSA algorithm exhibits the lowest convergence value, the fastest convergence speed and less fitness value stagnation when optimizing the hyperparameters, which is very important for CNN-BiLSTM The optimization ability of network hyperparameters is more prominent, and it has certain advantages compared with other algorithms. The hyperparameter search results of the SCSSA optimization algorithm are shown in Table 6.
Model prediction results and validation of the thermal error prediction model
Comparison and analysis of prediction results with different algorithms
The hyperparameter results after SCSSA algorithm optimization are input into the CNN-BiLSTM hybrid network model, and the working condition that the shaft speed is 8000r/min on the right spindle is predicted The prediction results of the test set are compared with the real values, and the comparison results are shown in Fig. 11.
Comparison between model predicted values and actual values.
In order to verify the superiority of the SCSSA-CNN-BiLSTM prediction model used in this paper. A comparative analysis of thermal error prediction using BP, CNN, and CNN-BiLSTM models, and the hyperparameters of the three models were manually adjusted. The input data is consistent with the SCSSA-CNN-BiLSTM prediction model. Figure 11 illustrates the prediction results. Table 5 shows the prediction performance of each model.
Comparison of prediction results from different models.
Figure 12 provides an intuitive comparison of the thermal error prediction curves of different models. Among them, the SCSSA-CNN-BiLSTM prediction model has the highest degree of coincidence with the actual thermal error values. When comparing the prediction data of the three models, the prediction error fluctuation of the SCSSA-CNN-BiLSTM model is smaller, and it has better stability in data fitting.From Table 7 shows that compared with the three contrast models, the root mean square error (RMSE) of the SCSSA-CNN-BiLSTM prediction model has decreased by 64.92%, 56.15%, and 38.77% respectively; the mean absolute error (MAE) has decreased by 66.50%, 62.11%, and 47.06% respectively, indicating that the prediction results are stable and have fewer extreme values.
This is not only a statistical improvement, but also very important in the context of industrial precision processing. Firstly, the halving of MAE indicates a significant improvement in the average prediction deviation, greatly enhancing the daily stability and consistency of processing accuracy. Secondly, the significant reduction in RMSE indicates that the model is more effective in suppressing large prediction deviations, directly helping to reduce product defects and scrap rates caused by outliers. The magnitude of this error reduction is undoubtedly sufficient to significantly improve production accuracy. The compensation model supported by these increased prediction accuracies can enhance the capabilities of the machine tool, enabling the machine to always meet more stringent tolerance requirements, which is crucial for manufacturing high-value components in industries such as aerospace, automotive, and medical equipment.
Prediction results and comparative analysis of different working conditions
In order to determine the generalization ability of the SCSSA-CNN-BiLSTM prediction model under different rotational speeds and different spindle working conditions, the optimized hyperparameters of the SCSSA algorithm under four different rotational speed conditions (2000/5000/8000/10000 r/min) were input into the CNN-BiLSTM hybrid network of the same spindle for thermal error prediction; at the same time, to verify the adaptability of the model to different spindles, the optimized hyperparameters of SCSSA under the 8000 r/min working condition of the right spindle were input into the CNN-BiLSTM network of the other spindle for prediction effect verification. During this process, all input temperature data were preprocessed uniformly (as described in Sect. 2.5), converting the original temperature values to the range of [-1, 1]. This effectively eliminated the differences in absolute temperature values and distribution ranges caused by individual spindle differences and different rotational speeds, enabling the model to focus on learning the mapping relationship between temperature and thermal error rather than the unique characteristics of specific spindles or specific rotational speeds. This is the core prerequisite for this unified model architecture to be able to adapt to multiple rotational speeds and generalize to different spindles. The comparison results of the predicted values and the true values are shown in Figs. 13 and 14. The results indicate that the prediction results of the SCSSA-CNN-BiLSTM model under different rotational speed conditions and different spindles are all good, effectively supporting the precise prediction and compensation of thermal errors in the actual processing of the dual-spindle machine tool.
Comparison of predictions under four different rotational speed conditions.
Comparison of dual-axle model predictions.
From Figs. 13 and 14, it can be seen that the consistently high prediction accuracy demonstrated at multiple speeds and between two different spindles highlights the inherent robustness of the proposed SCSSA-CNN-BiLSTM model. This robustness mainly stems from the model’s ability to learn and generalize the underlying thermal-mechanical relationships, rather than merely memorizing the data patterns of specific operating conditions. When dealing with speed variations, the performance of this model indicates that it effectively separates the influence of thermodynamics from the motion state of the shaft. Although the speed determines the magnitude and rate of heat generation, the fundamental physical principles governing heat transfer and subsequent thermal deformation remain consistent. Through its spatial-temporal feature extraction, the model has learned these invariant physical laws, thereby being able to accurately infer untested speeds within the operational range from the training speed.
Regarding the performance on different spindles, the maximum model prediction error observed was between ± 4.6 μm and ± 5.0 μm. This confirms that the model performs well across different spindles. Although there may be inevitable minor differences in cooling conditions, assembly tolerances, or surrounding structures, the spindles of the same model and construction are generally consistent in this regard. The model successfully ignores these unique noise factors and focuses on the main, shared thermal characteristics. This ability to standardize subtle differences between spindles is crucial for practical applications, as it indicates that a well-trained single model has the potential to be deployed in multiple identical machines without the need for extensive individual recalibration, thereby significantly reducing the engineering cost of thermal error compensation for the entire fleet.
Discussion
Implementation path and expansion plan for the model
To achieve the stable deployment of the thermal error compensation model in the actual industrial environment, the first step is to install a temperature sensor array on the target CNC machine to collect sufficient and representative thermal characteristic data. Subsequently, the proposed model is used for offline training to obtain optimized parameters. The trained model will be embedded as a thermal error prediction module into the CNC system. This module can be extended through API interfaces or user-defined NC codes to achieve real-time communication with the CNC control system. After inputting the real-time collected temperature data into the model, the system can obtain the thermal error compensation value and provide it in real time to the control unit, thereby achieving dynamic compensation of the tool path and the origin of the coordinate system. At the system integration level, this model can rely on programmable logic controllers (PLC) or dedicated compensation hardware for real-time calculation and transmit the compensation instructions to the CNC system through digital I/O, EtherCAT, and other fieldbus protocols to ensure the reliability and stability of the compensation process.
At the same time, to further expand to different machines, we plan to adopt the transfer learning strategy to achieve efficient model expansion: using the trained model from the source machine (1200MSY) as the pre-training base network, when deploying to a new model machine, only a small amount of thermal data of the new machine needs to be collected to fine-tune the last layer or some layers of the model, which can quickly adapt without having to retrain from scratch. This method will significantly reduce the engineering cost of data collection and model calibration on multiple machines and provide an efficient and feasible solution for large-scale engineering applications.
Limitations and future work
Although the proposed SCSSA-CNN-BiLSTM model demonstrates excellent accuracy and strong generalization ability on different speeds and spindles within the same machine, this research constitutes a basic stage of the study. It is necessary to acknowledge several important limitations inherent in this stage. These limitations not only define the current working boundaries of our work but also clearly indicate the direction for our future research work.
(1)This research project aims to further integrate multiple sensing signals such as temperature, vibration, spindle current, and cutting force, and construct a thermal error collaborative modeling framework that integrates multiple physical information. By extracting complementary features of the thermodynamic behavior during dynamic machining, the model’s prediction accuracy and robustness under varying conditions will be enhanced. Additionally, future work will focus on lightweight model design, neural architecture search, and hardware-in-the-loop testing, with the goal of optimizing the computational efficiency and inference speed of the system, providing a technical foundation for real-time embedded deployment.
(2)This model was developed and validated only on a specific machine model (1200MSY). Its performance in comparison with other machine architectures and configurations has not yet been empirically verified. Moreover, the selection of temperature-sensitive points relies on data-driven methods (K-means clustering and grey relational analysis), and there is a lack of confirmation of the true representativeness of the sensitive points through physical models (such as finite element analysis - FEA) or thermal imaging. We also plan to use techniques such as SHAP or LIME for analysis, to quantify feature importance, and to make the decision-making process of the model transparent and trustworthy for engineers.
(3)All the experiments were conducted in a controlled laboratory environment. The performance of this model has not yet been evaluated under various real production conditions, such as different cutting loads, intermittent operation, the presence of coolant and dust, or significant macroscopic environmental changes (for example, large diurnal or seasonal fluctuations in workshop temperatures). Therefore, its long-term stability against sensor drift, gradual mechanical wear, and long-term (several months) performance degradation has not yet been assessed.
Conclusion
In order to solve the problems in the thermal error modeling of CNC machine tools, such as insufficient mining of timing features, limited model generalization ability, and verification at the fixed speed of a single spindle, this paper uses 1200MSY dual-spindle turning and milling machine tools As the research object, SCSSA-CNN based on K-means clustering (K-means) combined with grey correlation analysis based on temperature measurement points was established -BiLSTM Thermal Error Prediction Model for Dual-Spindle Turning and Milling Machines, and the following conclusions are obtained:
-
(1)
Comparison between SCSSA-CNN-BiLSTM dual-spindle thermal error prediction model and commonly used thermal error algorithms, SCSSA- The root mean square error (RMSE) predicted by the CNN-BiLSTM dual-spindle model was reduced by up to 64.92%;The absolute percentage error (MAE) was reduced by up to 66.50%. Indicates the prediction accuracy of the model used.
-
(2)
The proposed SCSSA-CNN-BiLSTM dual-spindle thermal error prediction model can achieve good prediction results under multi-speed conditions. The thermal error prediction of the double spindle also has high accuracy, which provides a better high-precision and strong generalization solution for the collaborative thermal error compensation of the double-spindle turning and milling machine.
Data availability
All the data generated or analyzed during this research are included in this article [and its supplementary information file].
References
Li, Y., Zhao, J., Ji, S. & Wang, Y. A review on spindle thermal error compensation in machine tools. Int. J. Mach. Tools Manuf. 95, 20–38. https://doi.org/10.1016/j.ijmachtools.2015.04.008 (2015).
Deng, X. et al. Review on thermal design of machine tool spindles. Opt. Precision Eng. 26, 1415–1429. https://doi.org/10.3788/OPE.20182606.1415 (2018).
Yang, Z. et al. Intelligent sensing of thermal error of CNC machine tool spindle based on multi-source information fusion. Sensors 24, 3614. https://doi.org/10.3390/s24113614 (2024).
Zhang, Z. et al. Geometric error measuring, modeling, and compensation for CNC machine tools: a review. Chin. J. Aeronaut. 37, 163–198. https://doi.org/10.1016/j.cja.2023.02.035 (2024).
Guo, Q. & Yang, J. Application of projection pursuit regression to thermal error modeling of a CNC machine tool. Int. J. Adv. Manuf. Technol. 55, 623–629. https://doi.org/10.1007/s00170-010-3114-4 (2011).
Li, B., Tian, X. & Zhang, M. Thermal error modeling of machine tool spindle based on the improved algorithm optimized BP neural network. Int. J. Adv. Manuf. Technol. 105, 1497–1505. https://doi.org/10.1007/s00170-019-04375-w (2019).
Abdulshahed, A. M., Longstaff, A. P. & Fletcher, S. A cuckoo search optimisation-based grey prediction model for thermal error compensation on CNC machine tools. Grey Systems: Theory Application. 7, 146–155. https://doi.org/10.1108/GS-08-2016-0021 (2017).
Li, Y., Zhao, J. & Ji, S. Thermal positioning error modeling of machine tools using a Bat algorithm-based back propagation neural network. Int. J. Adv. Manuf. Technol. 97, 2575–2586. https://doi.org/10.1007/s00170-018-1978-x (2018).
Ye, H., Wei, X., Zhuang, X. & Miao, E. An improved robust thermal error prediction approach for CNC machine tools. Machines 10, 624. https://doi.org/10.3390/machines10080624 (2022).
Zhu, M. et al. Robust modeling method for thermal error of CNC machine tools based on random forest algorithm. J. Intell. Manuf. 34, 2013–2026. https://doi.org/10.1007/s10845-021-01894-w (2023).
Shi, H. et al. Bayesian neural network-based thermal error modeling of feed drive system of CNC machine tool. Int. J. Adv. Manuf. Technol. 108, 3031–3044. https://doi.org/10.1007/s00170-020-05541-1 (2020).
Chen, Y., Chen, J. & Xu, G. A data-driven model for thermal error prediction considering thermoelasticity with gated recurrent unit attention. Measurement 184, 109891. https://doi.org/10.1016/j.measurement.2021.109891 (2021).
Alzubaidi, L. et al. Review of deep learning: concepts, CNN architectures, challenges, applications, future directions. J. Big Data. 8, 53. https://doi.org/10.1186/s40537-021-00444-8 (2021).
Liu, J. & Song, Z. A survey of research on recurrent neural networks. Control Decis. 37, 2753–2768. https://doi.org/10.13195/j.kzyjc.2021.1241 (2022).
Xue, J. & Shen, B. A novel swarm intelligence optimization approach: sparrow search algorithm. Syst. Sci. Control Eng. 8, 22–34. https://doi.org/10.1080/21642583.2019.1708830 (2020).
Zhang, D. et al. Whale optimization algorithm embedded with circle mapping and dimension-wise small hole imaging reverse learning. Control Decis. 36, 1173–1180. https://doi.org/10.13195/j.kzyjc.2019.1362 (2021).
Mirjalili, S. & SCA A sine cosine algorithm for solving optimization problems. Knowl. Based Syst. 96, 120–133. https://doi.org/10.1016/j.knosys.2015.12.022 (2016).
Li, A., Quan, L., Cui, G. & Xie, S. Sparrow search algorithm combining sine-cosine and cauchy mutation. Comput. Eng. Appl. 58, 91–99. https://doi.org/10.3778/j.issn.1002-8331.2106-0148 (2022).
Yang, J. & Zhao, C. Survey on K-means clustering algorithm. Comput. Eng. Appl. 55, 7–14. https://doi.org/10.3778/j.issn.1002-8331.1908-0347 (2019).
El-Mandouh, A. M. et al. Optimized K-means clustering model based on gap statistic. Int. J. Adv. Comput. Sci. Appl. 10, 1. https://doi.org/10.14569/IJACSA.2019.0100124 (2019).
Mirjalili, S., Mirjalili, S. M. & Lewis, A. Grey Wolf optimizer. Adv. Eng. Softw. 69, 46–61. https://doi.org/10.1016/j.advengsoft.2013.12.007 (2014).
Mirjalili, S. & Lewis, A. The Whale optimization algorithm. Adv. Eng. Softw. 95, 51–67. https://doi.org/10.1016/j.advengsoft.2016.01.008 (2016).
Faramarzi, A. et al. Marine predators algorithm: a nature-inspired metaheuristic. Expert Syst. Appl. 152, 113377. https://doi.org/10.1016/j.eswa.2020.113377 (2020).
Xue, J. & Shen, B. Dung beetle optimizer: a new meta-heuristic algorithm for global optimization. J. Supercomputing. 79, 7305–7336. https://doi.org/10.1007/s11227-022-04959-6 (2023).
Funding
This research was financially supported by the National Natural Science Foundation of China (No. 5217472), the Joint Funds of the Zhejiang Provincial Natural Science Foundation of China under Grant (No. LZY24E050003), the Major Project of Zhejiang Provincial Natural Science Foundation (No. 050011), Construction of Zhejiang Key Laboratory of Intelligent Manufacturing for Aerodynamic Equipment (No. 2025ZY01027), Zhejiang Key Laboratory of Intelligent Manufacturing for Aerodynamic Equipment (No. 2025E10033).
Author information
Authors and Affiliations
Contributions
L.W.T. conducted analyzed the data; wrote the main manuscript textand; prepared Figs. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 and 13.W.J.C. and W.H.Y Provided Conceptualization, Methodology.W.J.C.and Z.L. conducted the experimental design and data acquisition.W.J.C.,Z.J.Q. and D.X.L.provided manuscript Reviewing and Editing.All authors reviewed the manuscript.
Corresponding author
Ethics declarations
Competing interests
The authors declare no competing interests.
Additional information
Publisher’s note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Supplementary Information
Below is the link to the electronic supplementary material.
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Lu, W., Wang, J., Zhou, J. et al. Modeling of thermal errors for dual-spindle turning-milling compound machine tools based on hybrid networks. Sci Rep 15, 45697 (2025). https://doi.org/10.1038/s41598-025-27599-1
Received:
Accepted:
Published:
Version of record:
DOI: https://doi.org/10.1038/s41598-025-27599-1
















