1 Introduction

With advances in the manufacturing industry, the demand for machine tools with improved manufacturing accuracy has significantly increased. Recently, the problems associated with the accuracy of machine tools and their solutions have attracted significant attention from researchers. Several studies have shown that thermal and geometric errors are the most critical among various error sources in machine tools. Approximately 40 to 70% of total machine tool errors are caused by thermal deformation [1].

There are two main methods for thermal error prediction. The first method involves calculating the thermal error numerically. The finite element method (FEM) and finite difference method (FDM) are the most commonly used methods for modelling thermal errors. Mian et al. [2] established a thermal error model using the FEM approach. Creighton et al. [3] suggested an FEM model to analyse the temperature field of a milling spindle. Mayr et al. [4] initially proposed an FDM model to calculate the temperature distribution and subsequently developed an FEM model to analyse the thermal error. Zhao et al. [5] used a numerical simulation method to analyse the temperature field and thermal deformation of spindles. Mian et al. [6] applied FEM to simulate the influence of the main internal heat source of a small vertical milling machine. However, the prediction accuracy of thermal errors by FEM and FDM approaches depends on the accurate determination of boundary conditions, such as the heat generation rate and convection heat dissipation. The complex structure and randomness of the machine tool create complex boundary conditions. Most of the existing literature did not consider the randomness of the influencing factors of thermal errors, which makes it difficult to accurately predict thermal errors.

The second method is to establish the correspondence between system temperatures and thermal errors using artificial intelligence. Various modern intelligent algorithms have been employed to model the thermal errors. Ma et al. [7] used back propagation (BP) and improved BP neural networks to investigate the temperature variables. Li et al. [8] established a modified particle swarm optimisation (PSO) to improve the BP neural network and used it to predict spindle thermal error. Huang et al. [9] used an improved neural network to develop a thermal error prediction method, which improved the convergence speed. Abdulshahed et al. [10] proposed a compensation method for thermal errors in numerically controlled machine tools using the grey neural network model with convolution integral. The PSO algorithm was applied to improve the proposed grey neural network; it simplifies the modelling process and improves the accuracy of the system. Guo et al. [11] presented a new neural network modelling method based on an artificial bee colony and used grey correlation analysis to obtain the system temperature testing points of a machine tool. Similarly, Yang et al. [12] used fuzzy clustering to study the temperature variables. Rojek et al. [13] used the error back propagation, radial basis function neural network, and Kohonen network to study a new ball screw thermal deformation compensation method without sensors. Miao et al. [14] used support vector machines to establish a thermal error model. Cheng et al. [15] proposed a radial basis function (RBF) neural network to calculate the thermal error of a machine tool, which effectively reduced the temperature measurement data points. Wang et al. [16] proposed a method based on clustering thermal sensor data using fuzzy C-means clustering algorithm and iterative self-organising data analysis and established an artificial neural network thermal model. Until now, most of the methods adopted the temperature of the key points collected by the temperature sensor as the input for the intelligent models, which can capture the influence of the heat generation rate and convective heat dissipation. However, the randomness in the measuring error of the temperature sensor itself was not considered in most studies. Moreover, there are chances of abnormal mutation data due to the instability of instrument measurement, which can hinder the accurate prediction of thermal errors.

In summary, most of the literature fails to consider the influence of random factors on thermal errors, which results in poor accuracy of thermal error prediction. To address the above-stated problems, novel inverse random radial basis function neural network (IR-RBFNN) and forward random radial basis function neural network (FR-RBFNN) models are proposed in this paper to accurately predict thermal error while considering the randomness of influencing thermal error factors. First, random input and output variables were introduced into the RBF; subsequently, the genetic algorithm was selected to obtain the statistical characteristics of the random variables to realise the inverse identification of the random index of influencing factors. Furthermore, the FR-RBFNN was used to predict the thermal error distribution according to the random indices of the identified influencing factors. The experimental results show that the proposed models consider the influence of random factors and can quickly obtain a more accurate description of thermal errors than traditional prediction models.

2 Random radial basis function model

The randomness of frictional heat and convection in the feed system causes randomness in the temperature rise. In addition, the randomness of the temperature sensor measurement itself will cause inaccuracies in the thermal error prediction model. Therefore, the randomness of the parameters affecting the thermal errors was considered in the model.

2.1 Random temperature field

The randomness of heat generation in friction heat sources, surface convection, and temperature collection measurements causes randomness in the measuring point temperatures.

The temperature field random variables are expressed as follows:

$$ {T}_m=N\left({\mu}_{Tm\kern0.5em },\kern0.5em {\delta}_{Tm}^2\right)\kern2.25em m=1,2,\cdots, M $$
(1)

where μTm, δTm, and M represent the mean value of the mth key temperature, standard deviation of the mth key temperature, and number of temperature key points, respectively.

Considering the influence of random factors on the thermal error, the random variables of the temperature field were used as the inputs.

2.2 Random thermal error

The randomness of thermal error was described as follows:

$$ {e}_j=N\left({\mu}_{ej},{\delta}_{ej}^2\right)\kern3em j=1,2,\cdots, J $$
(2)

where μej, δej, and J denote the mean value for the jth key point thermal error, standard deviation for the jth key point thermal errors, and number of thermal error key points, respectively.

2.3 Random RBFNN model

In this paper, a new random RBFNN model is presented to solve the randomness problem. The structure of the random RBFNN is illustrated in Fig. 1. The random RBFNN is composed of IR-RBFNN and FR-RBFNN modules.

Fig. 1
figure 1

Structure of random RBFNN

The radial basis function commonly used in radial basis neural networks is a Gaussian function, and the activation function of the RBFNN can be expressed as follows:

$$ {\displaystyle \begin{array}{c}H\left({T}_n-{d}_i\right)=\exp \left(-\frac{1}{2{\sigma}^2}{\left\Vert {T}_{\mathrm{n}}-{d}_i\right\Vert}^2\right)\\ {}n=1,2,3,\dots \kern5pt ,\mathrm{N}\kern0.5em i=1,2,3,\cdots, \mathrm{I}\end{array}} $$
(3)

where \( {T}_n={\left({T}_1^n,{T}_2^n,\cdots, {T}_m^n\right)}^T \) denotes the nth input sample, T denotes the temperature vector, ‖Tn − di‖ denotes the Euclidean norm, di indicates the centre of the ith node in the hidden layer, N represents the total number of samples, and σ denotes the variance of the Gaussian function.

However, Eq. 3 was not used to solve the random inputs.

In this study, to solve the random inputs and outputs, Eq. 3 was modified as follows:

$$ {\displaystyle \begin{array}{c}H\left({T}_n-{d}_i\right)=\exp \left(-\frac{1}{2{\sigma}^2}{\left\Vert {\mu}_{\mathrm{Tn}}-{d}_i\right\Vert}^2\right)\\ {}n=1,2,3,\dots \kern5pt ,\mathrm{N}\kern0.5em i=1,2,3,\cdots, \mathrm{I}\end{array}} $$
(4)

The output of random RBFNN was further deduced as

$$ {e}_j=\sum \limits_{i=1}^{\mathrm{I}}{w}_{ij}\exp \left(-\frac{1}{2{\sigma}^2}{\left\Vert {\mu}_{Tn}-{d}_i\right\Vert}^2\right)\kern0.5em i=1,2,3,\cdots, I\kern0.5em j=1,2,3\cdots, J $$
(5)

where wij denotes the connection weight of the ith node of the hidden layer to the jth node of the output layer, I represents the number of hidden layer nodes, and ej denotes the output value of the jth output node.

The variance σi of random RBFNN was expressed as follows:

$$ {\sigma}_i=\frac{D_{\mathrm{max}}}{\sqrt{2I}}\kern0.5em \left(i=1,2,\cdots, I\right) $$
(6)

where Dmax denotes the maximum distance between centres. The least-squares method was used to calculate the connection weights from the hidden layer to the output layer.

In this study, the connection weights between the hidden and output layers are obtained as shown in Eq. 7.

$$ w=\exp \left(-\frac{I}{D_{\mathrm{max}}^2}{\left|\left|{\mu}_{Tn}-{d}_i\right|\right|}^2\right)\kern2.25em i=1,2,\cdots, I\kern1em n=1,2,\cdots, N $$
(7)

2.3.1 IR-RBFNN model

To accurately investigate the randomness of the parameters in practical applications, the standard deviation in the input of the key point temperatures was obtained from inverse identification through the experiments. Hence, a genetic algorithm (GA), which is a parallel stochastic search optimisation method, was combined with a random RBFNN to realise inverse random parameter identification.

In this study, the generated random variables were used as the input of the trained random RBFNN. Initially, the simulation calculation was repeated K times. From the results of the K times simulations, the mean value and standard deviation of the random parameters were obtained. Then, the mean value differences and the standard deviation between the simulation results and experimental data were used as the individual fitness values to execute GA. Subsequently, random RBFNN and GA were combined. The differences in the mean values and the standard deviation between the simulation results and experimental data were the objective functions, and the minimum values of the two objective functions were searched by GA.

Encode

In this study, individual coding was real number coding. During the execution of the genetic algorithm, the initial variables T and δ were coded separately.

Fitness function

The absolute value of the mean difference between the simulated results and the experimental data was used for the individual fitness value F1, which can be expressed as

$$ {F}_1=\mathrm{abs}\left({\mu}_e^{\mathrm{Sim}}-{\mu}_e^{\mathrm{Exp}}\right) $$
(8)

where \( {\mu}_e^{\mathrm{Exp}} \) represents the mean value of the measuring results obtained through experiment.

The mean value of the thermal errors \( {\mu}_e^{\mathrm{Sim}} \) of the random RBFNN simulation output is expressed as

$$ {\mu}_e^{\mathrm{Sim}}=\frac{\sum \limits_{k=1}^K{\mu}_{ej}^k}{K} $$
(9)

where K represents the number of repeated simulations with random parameters and \( {\mu}_{ej}^k \) denotes the mean value of the jth key point thermal error after simulations repeated k.

The absolute value of the standard deviation difference between the simulation calculation and the experimental data was used for the individual fitness value F2, which can be expressed as

$$ {F}_2=\mathrm{abs}\left({\delta}_e^{\mathrm{Sim}}-{\delta}_e^{\mathrm{Exp}}\right) $$
(10)

where \( {\delta}_e^{\mathrm{Exp}} \) denotes the standard deviation of the measuring data.

The standard deviation \( {\delta}_e^{\mathrm{Sim}} \) of the network simulation output value is expressed as

$$ {\delta}_e^{\mathrm{Sim}}=\sqrt{\frac{\sum \limits_{k=1}^K{\left({\mu}_{ej}^k-{\mu}_e^{\mathrm{Sim}}\right)}^2}{K}} $$
(11)

Selection, crossover, and mutation operations

The selection operation in GA directly affects its performance. In this algorithm, the probability of its selection pi was obtained as follows:

$$ {p}_i=\frac{f_i}{\sum \limits_j^N{f}_i} $$
(12)

where fi = 1/Fi. Fi indicates the fitness value of the individual Xi, and N denotes the number of population individuals.

The real crossover method was used in this study, and the g chromosome zg and the h chromosome zh are used in the l bit cross operation method as follows:

$$ \left.\begin{array}{c}{z}_{gl}={z}_{gl}\left(1-r\right)+{z}_{il}r\\ {}{z}_{hl}={z}_{hl}\left(1-r\right)+{z}_{gl}r\end{array}\right\} $$
(13)

where r represents a random number between [0, 1].

2.3.2 FR-RBFNN model

To predict the thermal errors accurately while considering the randomness of the parameters, random inputs \( {T}_m=N\left({\mu}_{Tm},{\delta}_{Tm}^2\right) \) were introduced to the RBFNN. The standard deviation δTm of the inputs was obtained from the identification of the IR-RBFNN.

In most of the existing literature, the inputs of the network are obtained directly by reading temperature data from the sensors. Although this method can obtain the key point temperature data, this data contains the randomness of the instrument’s measurement. Furthermore, large amounts of abnormal data caused by instrument instability may occur. Directly reading the data cannot exclude the measurement error of the instrument, which affects the accuracy of the thermal error prediction.

In this paper, a new real-time dynamic moving average algorithm is proposed to solve the problem of randomness and instability caused by instrument measurement errors.

The exponential moving average algorithm can be written as

$$ {F}_{i+1}=\alpha {Y}_t+\left(1-\alpha \right)\alpha {Y}_{t-1}+{\left(1-\alpha \right)}^2\alpha {Y}_{t-2}+\dots +{\left(1-\alpha \right)}^n\alpha {Y}_{t-n}+\dots +{\left(1-\alpha \right)}^t{F}_i $$
(14)

where Yt, α, Fi, and Fi + 1 represent the actual measuring value of the tth period, smoothing coefficient, average prediction value of the tth period, and average prediction value of the (t+1)th period, respectively.

Equation 14 is suitable for data without abnormal mutation. However, owing to the instability of instrument measurements, there is a probability of abnormal mutation data occurrence. Therefore, this method is not applicable in our case.

In this paper, an improved real-time dynamic moving average algorithm that eliminates abnormal mutation data is proposed.

The mutation value was identified by comparing the predicted and measured values. If the difference between the predicted and measured values is larger than the mutation threshold, the measured value considered abnormal and will be replaced by the predicted value.

$$ {\displaystyle \begin{array}{l}\left|{Y}_{t+1}-{F}_{i+1}\right|>\Delta, {Y}_{t+1}={F}_{i+1}\\ {}\left|{Y}_{t+1}-{F}_{i+1}\right|<\Delta, {Y}_{t+1}={Y}_{t+1}\end{array}} $$
(15)

where Δ represents the mutation threshold.

This method is suitable for removing abnormal mutations in gradually changing signals; the temperature rise in machine tools corresponds to gradually changing signals.

Using the real-time measuring temperature data, the mean μTm of the inputs can be obtained through the new real-time dynamic moving average algorithm.

2.4 Flowchart of the random RBF model

The algorithm consists of IR-RBFNN and FR-RBFNN modules. The IR-RBFNN module realises random parameter identification, and the FR-RBFNN module completes the thermal error prediction. A flowchart for random RBFNN is shown in Fig. 2.

Fig. 2
figure 2

Algorithm flowchart of the random RBFNN

In this study, an IR-RBFNN model was first established, which uses GA for searching the dataset to obtain the distribution characteristics of random parameters. Subsequently, the FR-RBFNN model was used for thermal error prediction. The implementation process is as follows:

  1. 1)

    The RBFNN was trained with experimental data to obtain the network model.

  2. 2)

    The μTm and σTm values of the initial variables were set, and the normrnd function was used to generate the values of normal random variable, which were used as an IR-RBFNN input. The mean of the thermal error \( {\mu}_e^s \) was obtained as output after the network repeated the simulation Q times. The difference between the mean of the random RBF output and the mean of the experimental thermal error was calculated.

  3. 3)

    The GA was first used to encode the initial temperature variable, and the absolute difference of the mean value was considered the fitness value. Subsequently, selection, crossover, and mutation were performed to generate a normal random variable for each new individual, and the network simulation was iterated K times to produce the output.

  4. 4)

    The fitness value F1 was calculated through Eq. 8. If the fitness value did not meet the conditions, the model returned to the selection operation and repeated the cycle until the best fitness value was obtained. If the required conditions were met, the results were directly considered output. Finally, the optimal value of the temperature variable was returned, and the inverse identification of the mean of the temperature input was realised.

  5. 5)

    The initial temperature variable was updated by replacing the original temperature with the optimal temperature. Then, normrnd function was used to generate the normal random variable values, RBFNN was used again, and thermal error standard deviation \( {\delta}_e^s \) was obtained after Q iterations. The difference between the standard deviation of the output thermal error and the measured thermal error was determined.

  6. 6)

    The GA was used to encode the standard deviation of the initial temperature. The absolute value of the difference in the standard deviation was considered the fitness value according to Eq. 10, and the selection, crossover, and mutation were carried out. The new individuals obtained were generated into the normal random variables again, and the network simulation was continued K times to output the thermal error standard deviation. Then, the operation of fitness value was calculated. If the fitness value did not meet the conditions, the model returned to the selection operation and repeated the cycle until the best fitness value was obtained. If the required conditions were met, the results were considered output directly. Finally, the optimal temperature standard deviation was returned; that is, the reverse identification of the temperature standard deviation was realised.

  7. 7)

    Using the real-time temperature value read from the sensors, the mean μTm of the inputs can be obtained by the new real-time dynamic moving average algorithm.

  8. 8)

    According to the results of step 7, the random variables were generated and then used in the FR-RBFNN to complete the thermal error prediction.

3 Experimental setup and testing process

3.1 Experimental setup

In this study, the thermally deduced positioning error of a ball screw system was investigated experimentally using a computer numerical control (CNC) lathe. The entire experimental device was composed of a CNC lathe, laser interferometer, temperature acquisition equipment, and microcomputers, as shown in Fig. 3.

Fig. 3
figure 3

Components of experimental device

A random time-varying prediction model based on an x-axis feed system is investigated in this study. Table 1 lists the parameters of the system.

Table 1 Parameters of the x-axis system

3.2 Distribution of measuring points

The three temperature measuring points T1, T2, and T3 were at the bearing 1 seat, screw-nut flange, and bearing 2 seat, respectively. The stroke of the thermal error measuring points was 220 mm, and 6 measuring points P1–P6 were evenly distributed, as shown in Fig. 4.

Fig. 4
figure 4

Structure of feed system and distribution of measurement points

According to ISO 230–2 standards, the temperature of key points T1, T2, and T3 were observed by a thermocouple at an interval of 0.5 s. The positioning error of the system was recorded using a laser interferometer. The positioning errors of uniformly distributed P1–P6 points were recorded at a distance of 44 mm between the measuring points. During the experimental measurement, the lathe was operated at a feed rate of 15 m/min. Positioning errors of points P1–P6 after heating on the lathe for 10, 20, 30, 40, and 50 min were measured and recorded with a laser interferometer. In this study, 30 independent experiments were conducted under the same initial and operating conditions. Under a constant temperature without a cutting load, the thermal error caused by screw rotation at a spindle speed of 0 r/min was measured. The time-varying random prediction model of the random RBFNN was verified through 30 cutting-free load tests.

4 Results and discussion

In this study, the measured values of the three temperature sensors and the corresponding thermal errors of the measuring points were considered the training data set. A set of temperature and thermal error values were recorded after every 10 min, and 30 sets of data were selected as training sets to train the RBFNN. The normrnd function was used to generate the normal random temperature variables as input to predict the thermal errors. The mean and standard deviation of the thermal error were calculated using the random RBFNN and compared with those obtained from the experimental data.

The standard deviation of the thermal error was calculated from the experimental data, and the value was δe = 0.029. The parameters of GA used in this study are listed in Table 2.

Table 2 The parameters of GA

Figures 5, 6, and 7 show the axial thermal errors of the screw obtained by the random RBFNN model, FEM simulation, and experiment for heating the machine under a feed rate of 15 m/min for 10, 30, and 50 min, respectively. As shown from these figures, the mean value of the thermal error calculated by the random RBFNN is in good agreement with the mean value of the experimental values and FEM calculation results. The upper and lower limits of the thermal error calculated by the random RBFNN are in good agreement with the experimental data of the system. Moreover, the standard deviation of the thermal error is in good agreement with the experimental data.

Fig. 5
figure 5

Thermal error at different positions of screw at the 10th min

Fig. 6
figure 6

Thermal error at different positions of screw at the 30th min

Fig. 7
figure 7

Thermal error at different positions of screw at the 50th min

In addition, there are some differences between the random RBFNN model and the FEM simulation results.

Figure 5 shows the thermal error distribution at different screw positions at the 10th min. According to the FEM results, the screw thermal error from 0 to 176 mm is less than the threshold value of 10 μm, which is deemed “qualified.” However, according to the random RBFNN model and experimental data, the failure probability of the screw gradually increased from 0 to 50%—from 150 to 176 mm. According to the FEM results, when the thermal error of the screw from 176 to 220 mm is larger than the threshold value of 10 μm, this is considered “failure.” However, according to the random RBFNN model and experimental data, the screw failure probability from 176 to 215 mm gradually increased from 50 to 100%.

Figure 6 shows the thermal error at different positions of the screw at 30th min. Based on the FEM results, when the thermal error of the screw from 0 to 110 mm is less than the threshold value of 10 μm, it is considered “qualified,” similar to the 10th min case. However, according to the random RBF model and the measured data, the failure probability of the screw from 100 to 110 mm gradually increased from 0 to 50%. According to the FEM results, when the thermal error of the screw from 110 to 220 mm is larger than the threshold value of 10 μm, it is considered “failure.” However, according to the random RBFNN model and experimental data, the failure probability from 110 to 123 mm gradually increased from 50 to 100%.

Figure 7 shows the thermal error at different positions of the screw at 50th min. Based on the FEM simulation, the screw thermal error from 0 to 98 mm is less than the threshold value of 10 μm, which is deemed qualified, similar to the 10th min case. However, according to the random RBFNN model and the measurement results, the failure probability of the screw from 87 to 98 mm gradually increases from 0 to 50%. The FEM simulation results indicate that the thermal error of the screw from 98 to 220 mm is larger than the threshold value of 10 μm, which denotes failure. However, according to the random RBFNN model and experimental data, the failure probability from 98 to 110 mm gradually increases from 50 to 100%.

From Figs. 5, 6, and 7, it can be seen that the random RBF model proposed herein considers the parameter randomness. Hence, it can describe the real-time thermal error of the screw from the perspective of reliability, which is more accurate.

In addition, the aforementioned results show that the mean value and the discreteness of the thermally induced error of the screw were affected by the mean value and standard deviation of the random variable. In this study, because the influence of random factors is considered, the prediction results of the random RBFNN model are more accurate than those of the FEM. Moreover, the running time of the random RBFNN prediction model was approximately 190 ms and that of the FEM model was approximately 50 min. The comparison results show that the running speed of the proposed model is significantly higher than that of the FEM model. Therefore, the random RBFNN prediction model can quickly obtain accurate results.

5 Conclusions

In this study, a novel IR-RBFNN model is proposed by combining the stochastic theory, GA, and RBFNN. Subsequently, using IR-RBFNN, the randomness index of the influencing factors was identified. Furthermore, through the combination of the stochastic theory, RBFNN, and the modified exponential moving average method with abnormal data elimination, the FR-RBFNN model is established according to the identified influencing factor random index. Using the two models, a novel prediction model for thermal error is proposed, considering the randomness of factors affecting the thermal error. This work considers the randomness of the friction heat, ambient temperature, and equipment measurement that directly affect the accuracy of thermal error prediction of the feed system. Compared with the traditional method, the experimental data of the lathe show that the proposed random RBFNN can obtain a more accurate error description considering the randomness of factors affecting thermal error.