An Initial Residual Stress Inference Method by Incorporating Monitoring Data and Mechanism Model

Initial residual stress is the main reason causing machining deformation of the workpiece, which has been deemed as one of the most important aspects of machining quality issues. The inference of the distribution of initial residual stress inside the blank has significant meaning for machining deformation control. Due to the principle error of existing residual stress detection methods, there are still challenges in practical applications. Aiming at the detection problem of the initial residual stress field, an initial residual stress inference method by incorporating monitoring data and mechanism model is proposed in this paper. Monitoring data during machining process is used to represent the macroscopic characterization of the unbalanced residual stress, and the finite element numerical model is used as the mechanism model so as to solve the problem that the analytic mechanism model is difficult to establish; the policy gradient approach is introduced to solve the gradient descent problem of the combination of learning model and mechanism model. Finally, the initial residual stress field is obtained through iterative calculation based on the fusing method of monitoring data and mechanism model. Verification results show that the proposed inference method of initial residual stress field can accurately and effectively reflect the machining deformation in the actual machining process.


Introduction
Initial residual stress is inevitable inside the workpiece due to thermal gradient, force load and phase transformation during the manufacturing process of blank, and the existence of initial residual stress can seriously affect the machining quality of the workpiece, which is especially critical in the field of aviation manufacturing. Take the high-strength aluminum alloy pre-stretched plate used in aircraft structural parts as an example, the blanks generally undergo processes, such as casting, quenching, hot rolling, forging, pre-stretching, and aging. During the manufacturing process, the blank will experience an uneven temperature field, and uneven elastoplastic deformation will occur. Therefore, residual stress will be generated inside the blank. The initial residual stress of the blank with initial residual stress will be broken due to the removal of the material in the machining process. Workpiece deformation will happen so as to achieve a new equilibrium state. The problem of machining deformation is particularly serious in the field of aircraft structural parts. Aircraft structural parts are characterized by large size, high material removal rate (up to 95% [1,2]) and thin wall, which will lead to large machining deformation of the parts, and serious deformation will directly lead to part scrap [3,4]. Relevant studies show that one of the most important reasons for machining deformation of structural parts is the initial residual stress inside the blank [5][6][7][8]. Therefore, it is significant to obtain the distribution of initial residual stress field for machining deformation control.
Because the distribution of initial residual stress field has the characteristics of complex spatial distribution, varied forms and large distribution scale influenced by the blank size, it is a great challenge to infer the residual stress field. At present, the methods to obtain residual stress are mainly divided into destructive testing and non-destructive testing, the main principle of the two methods is to detect some indirect physical quantities of the residual stress and obtain the residual stress with inverse problem-solving process. However, existing detection methods still have problems in practical applications. For example, destructive testing technique is carried out by pasting strain gauge, this method has the problems of low detection accuracy, poor reliability of detection results, and can only detect local residual stress. There are also some problems in nondestructive testing technique. Ultrasonic testing technique is easy to be disturbed by material internal defects, so the reliability of testing results is not high. Due to the X-ray penetration depth is limited, so it can only detect the residual stress on the workpiece surface. Neutron diffraction technique has strong penetration ability, but the detection principle of this method directly leads to the problem of high detection cost. It can be seen from the above that there are still many problems in the practical applications of the existing detection methods.
In order to obtain the initial residual stress inside the blank, an initial residual stress inference method by incorporating monitoring data and mechanism model is proposed in this paper. The deformation force is monitored during the machining process, and the policy gradient algorithm is used to incorporate the monitoring data with the finite element mechanism model so as to infer the initial residual stress field. The general idea of the proposed initial residual stress field inference method in this paper is shown in Figure 1. The neural network is used as a generator to generate initial residual stress field; the finite element mechanism model is used to calculate the deformation force corresponding to the generated initial residual stress field; the obtained deformation force will be compared with the real deformation force data to obtain deviation, and then the generator is adjusted according to the deviation to regenerate the initial residual stress which is closer to the real data. Iteration will be performed in this way until convergence, i.e., the deviation is satisfied to a threshold, and finally an initial residual stress field with required accuracy can be obtained.

Related Work
The initial residual stress in the workpiece is the main cause of machining deformation, it seriously affects the machining quality of the workpiece. Therefore, it is of great significance to detect the workpiece and understand the initial residual stress inside the workpiece to control the machining deformation and improve the machining quality. At present, the widely applied and relatively techniques in the aspect of residual stress detection are mainly divided into two categories: destructive testing techniques and nondestructive testing techniques [9].
Non-destructive testing (NDT) can be realized without damaging the tested object. At present, the mainstream  non-destructive testing methods mainly include X-ray diffraction method [10], ultrasonic method [11][12][13], neutron diffraction [14], etc. Compared with the destructive testing techniques, the nondestructive testing technique has the advantages of not damaging the tested object. However, limited to the testing principle and characteristics of NDT, these testing techniques still have some shortcomings. The depth of X-ray diffraction measurement is shallow, the inspection area is limited to the surface and subsurface of the material, and it is sensitive to the treatment of material surface, surface roughness and surface curvature will affect the measurement accuracy. In addition, due to the limitation of measurement space, large structural parts cannot be measured [15]. Compared with X-ray diffraction, neutron diffraction method has the advantage of more depth of penetration, it can detect the internal residual stress of large-size materials; however, the high construction and operation costs of the equipment seriously affect the applicability of neutron diffraction method, and it is impossible to realize in-situ measurement for large-scale parts in industrial field [16]. The measurement of residual stress by ultrasonic method is mainly based on the acoustoelastic theory. When the ultrasonic wave passes through the material containing residual stress, the speed of sound will change because of the residual stress and the residual stress inside the material can be obtained by analyzing and calculating the change of the speed of sound. Therefore, the measurement effect of ultrasonic method depends on the uniformity of the material microstructure, and the internal defects of the material will seriously affect the measurement accuracy [17].
Destructive testing would damage the tested object for obtaining residual stress. This method needs to remove the material in the part of the detected object for releasing the residual stress to get local strain, and the corresponding residual stress can be obtained based on the strain data. Destructive testing techniques mainly have the following several methods: blind-hole drilling [18,19] is a simple and quick method which is widely used at present, where the measurement area of the detected object is drilled to produce deformation, and the deformation around the small holes is measured with strain gauges, so the residual stress in the area can be calculated based on the measured data. The layer removal method [20] is more destructive than the blind-hole drilling, where the whole workpiece is deformed by milling the tested object layer by layer. The deformation data of the workpiece is measured by a strain gauge, and finally the residual stress is calculated based on the data of the strain gauge. The indentation method [21] is based on the inverse relationship between the hardness of the material surface and the residual stress to solve the residual stress. Compared with the blind-hole drilling and the layer removal method, this method has less damage on workpiece. The slitting method [22], similar to the blind-hole drilling, is realized through releasing the residual stress by machining the slit on the tested object, and then the residual stress is calculated by measuring the strain at the specified position. All of the above destructive testing techniques need to destroy the workpiece, and only local residual stress can be obtained according to the Saint-Venant principle. Although the indentation method has less damage to the workpiece, and no need to use strain gauges for testing, due to the low accuracy of hardness measurement and the existence of plastic zone on the surface of the object to be measured, the accuracy of retro-inferring residual stress through hardness is either not high.
In order to make up for the deficiency of traditional nondestructive testing and destructive testing techniques, related testing methods were proposed so as to improve the applicability of traditional testing technologies. Mao et al. [23] proposed a residual stress inference method by combining the detected surface residual stress and residual stress balance equation. Wang et al. [24] proposed a model to solve the complete surface residual stress field by measuring some limited residual stress at some points on the surface through X-ray technology. Hatamleh et al. [25] quantified the uncertainty of X-ray detection results so as to improve the reliability of the data by introducing the joint probability density function. Chukkan et al. [26] proposed an iterative solving method under simulation environment using limited detection data by neutron diffraction method, so as to obtain the residual stress meeting accuracy requirements. Farrahi et al. [27] proposed a reverse solving method of residual stress field based on Airy stress function, and reconstructed the residual stress field by finite measurement of the residual stress existing in the welded plate. Despite these studies improve the applicability of traditional detection techniques, they did not improve the traditional detection technology on the principle level, so the problems of low detection accuracy and high cost still exist.
Most of the above solutions are based on the mechanism relationship between the residual stress and the measured quantities to establish mechanism models, and then solve the residual stress according to the established mechanism models. Since mechanism models are the simplification of actual situations, when the actual situations are more complicated, the performance of the mechanism models is often unsatisfactory. Therefore, the solving method based on mechanism model has larger errors for complex residual stress fields. With the continuous development of artificial intelligence technology, it has gradually produced transformative results in different disciplines [28][29][30]. However, the outstanding performance of artificial intelligence technology is often inseparable from a large amount of data. In many practical situations, the cost of collecting data is often high, and we will inevitably face the dilemma of lack of data. In the case of insufficient data, most artificial intelligence technologies will suffer from the lack of robustness. In order to solve the problem of accuracy issue of mechanism model in complex situations and large amount data demand of artificial intelligence, the new idea of fusing mechanism model and machine learning has been an effective solution. As the mechanism model reflects the natural law of data, through the fusing of mechanism model and machine learning, the prior knowledge in mechanism model can be used to guide the training of machine learning model, amplify the information volume of the training data, and reduce the demand for the data volume of the machine learning model. There has been some existing research on the fusing of mechanism model and machine learning model. Nataniel et al. [31] used neural networks to solve the optimal parameters of the simulation model, which improved the calculation accuracy of the simulation model. Raissi et al. [32] proposed a physics-informed neural networks, which can solve the problem of partial differential equation in physical formula, the combination of machine learning and mechanism models is realized, and the applicability of the mechanism model is improved. Michael et al. [33] combined the Lagrange mechanical mechanism model with the neural network and established deep Lagrangian Networks, which can learn the equations of motion of a mechanical system with a deep network efficiently while ensuring physical plausibility. Greydanus et al. [34] trained the machine learning model following the conservation of energy through unsupervised learning according to Hamiltonian mechanics theory, which can learn the Hamiltonian mechanics formula directly from the data compared with the traditional methods.
For the problem of inference, the initial residual stress field, the physical relationship between the initial residual stress inside the workpiece and the deformation data is complicated, and it is difficult to establish an analytical mechanism model of the mechanism relationship; most of the existing data-driven and mechanism model fusing methods are used when the mechanism model is known. Therefore, the existing data-driven and mechanism model fusing methods are still insufficient to solve the problem of initial residual stress.
Aiming at the shortcomings of the existing methods, this paper will establish a numerical model between initial residual stress and deformation force through a finite element method (FEM). Since the calculation process of the finite element numerical model from the residual stress to the deformation force is not differentiable, it is difficult to update the data-driven model through a gradient descent method, which brings some difficulty to combine the data-driven model and the mechanism model. To address this issue, the policy gradient algorithm will be studied to achieve the fusing of the data-driven model and the mechanism model.

Relationship between Deformation Force and Residual Stress
In the actual machining process, the workpiece is clamped by fixtures. As the material of the workpiece is removed during machining process, the original balanced initial residual stress inside the workpiece is broken, and the workpiece-fixture system will be balanced by the fixtures, so the reaction force will be reflected by the fixtures, here the reaction force is defined as deformation force [35] which can be deemed as the force resisting workpiece deformation. In order to measure the deformation force, special fixtures and fixture layout are designed, as shown in Figure 2(a). A fixed clamping area is formed through three fixed clamping points, the six degrees of freedom of the workpiece are constrained. According to the clamping way of the workpiece, we take the half of the workpiece as a simple beam for force analysis, as shown in Figure 2(b) and (d).
The deformation force of the workpiece is caused by the imbalance of initial residual stress inside the workpiece, and the deformation force can be deemed as the macroscopic characterization quantity of the initial residual stress inside the workpiece. The unbalanced residual stress inside the workpiece is superimposed and acts on the workpiece in the form of bending moments ( M z ,M x ), causing the workpiece deformation. The workpiece is constrained by clamping points, and the deformation trend acts on the clamping points to produce deformation force In order to facilitate the description of the relationship between the deformation force and the initial residual stress, we simplified the force state of the workpiece to two dimensions, as shown in Figure 2(c). When the material of the workpiece is removed, the internal unbalanced residual stress forms a bending moment, which causes the workpiece deformation. Do integration for the initial residual stress on each section along the thickness direction, and the integral formula is shown in Eq. (1): where σ is the internal stress of the workpiece; a and b are the distances from the top and bottom surfaces of the workpiece to the neutral surface, respectively. From Eq. (1), it can be seen that the unbalanced initial residual stress forms a bending moment with respect to the neutral area. As shown in Figure 2(c), if the workpiece is not constrained, the workpiece will be deformed. When the workpiece is restrained by clamping, the deformation tendency caused by the bending moment acts on the clamping point with deformation force. The balance equation can be obtained from Figure 2

Combination of Mechanism Model and Monitoring Data
In the previous section, we have established the mechanism model of initial residual stress to deformation force in two dimensions by Eq. (3). As the initial residual stress exists in a form of field, it is not easy to explicitly express the mechanism model of Eq. (3) for the whole workpiece.
In order to address this issue, the mechanism model of residual stress to deformation force is constructed by FEM in this paper. The main method is to establish a mechanism model between initial residual stress and deformation force under FEM simulation environment. The initial residual stress was added to the workpiece in the simulation environment, and the deformation force corresponding to initial residual stress can be obtained during the simulation process. In this paper, the numerical mechanism model is established to replace the analytical mechanism model to realize the modeling relationship of initial residual stress and deformation force. The proposed method is based on the deformation force data obtained during the workpiece machining process, and the initial residual stress field inside the workpiece is iteratively solved by data-driven method incorporated with the finite element numerical mechanism model. The flowchart of the proposed initial residual stress solving method is shown in Figure 3. Firstly, a random initial residual stress of the workpiece is preliminarily generated by a residual stress generator composed of a neural network and a Gaussian multi-peak fitting function. The generated initial residual stress is used as the input of the finite element numerical model to analyze and calculate the corresponding deformation force. Then the deformation force calculated by the numerical model is compared with the real deformation force to obtain deviation. Finally, the weights of the neural network are updated using error back propagation to adjust the initial residual stress output from the residual stress generator to be closer to the expected value. Repeat iteratively until the deviation is minimized within the preset error.
In the proposed method, the generator will generate the coefficients of the initial residual stress function by a neural network firstly, and the initial residual stress is determined by the coefficients of the function. A neural network is used for a specific workpiece with fixed input, and the output of the neural network is adjusted by updating the weights according to the errors. In actual situation, the residual stress in the thickness direction is much smaller than the residual stress in the width and length directions, and the machining deformation of the workpiece is mainly affected by the residual stress in the length and width directions, so the residual stress in the thickness direction can be ignored. As shown in Figure 4, it is a typical initial residual stress distribution curve inside the workpiece [36]. It can be seen from the figure that the initial residual stress inside the workpiece changes continuously along the thickness direction with multiple peaks. Considering the characteristics of the variation curve of residual stress along the thickness direction, it is fitted by a Gaussian multi-peak fitting function. It has many advantages using Gaussian multi-peak fitting function, i.e., more discrete residual stress values can be represented by less parameters, which is very important for the neural network, and physical prior can be easily considered for better solution. The Gaussian multi-peak fitting function used in this paper is shown in Eq. (4):  The length and width of the aluminum alloy prestretched plate are much greater than the thickness, and the quenching and aging treatment effects in the manufacturing process are symmetrical to the neutral plane of the pre-stretched plate. Therefore, the initial residual stress of the pre-stretched sheet can be deemed as symmetrically distributed along the neutral plane and satisfies the stress balance condition [20]. In order to reduce the size of the solving space and improve the efficiency of the proposed algorithm, the Gaussian multi-peak fitting function of initial residual stress is set as even function according to the distribution characteristics of initial residual stress. And the generator is constrained according to the stress balance condition. As mentioned above, we use prior data and knowledge to define the fitting function of the initial residual stress field in advance to narrow the gap between the solving value of the initial residual stress and the target value, which can effectively improve solving efficiency and accuracy.
It can be found from above that the generator will generate the fitting coefficients of the multimodal Gaussian fitting function firstly. After the fitting coefficients are obtained, the initial residual stress distribution curve can be determined. Then the initial residual stress function is input into the finite element numerical model to calculate the corresponding deformation force. The deformation force obtained by the numerical mechanism model is compared with the data obtained in the real machining environment to calculate the deviation. Root mean square error (RMSE) is used to measure the difference between (4) the real data and the solving data, and the error is back propagated in the network of generator. Then the weight of the network is adjusted through continuous iteration to minimize the deviation ( L ) between the output results and the real data ( D val ). This is a typical optimization problem, and the optimization goal is shown in the following Eq. (5): where c is the coefficients of the initial residual stress function generated by the neural network generator, and the value is determined by the neural network weight ω , h c is the mapping between the coefficients of the initial residual stress function c and deformation force. The solving method proposed in this paper involves the finite element numerical mechanism model, in which the process from initial residual stress to deformation force is not differentiable and the gradient descent is difficult to be calculated. In order to address this problem, inspired by reinforcement learning, the policy gradient algorithm [37] is introduced so as to solve the problem, and the fusing of the monitoring data and the mechanism model can be realized. The main idea is that the output values (i.e., the coefficient c ) of the neural network is transformed to a Gaussian distribution, and coefficient c can be sampled from the Gaussian distribution so as to generate residual stress as well as calculate deformation force deviation. Then, a reward function can be defined and statistical expectation of the reward can be obtained. Finally, the weight is updated according to the optimization goal of the maximum reward. The detailed method of policy gradient will be described as follows. We set the inference process of the initial residual stress field according to the idea of policy gradient. As shown in Figure 3, the output of the neural network is the mean μ of the fitting function coefficients and the corresponding variance σ, which obeys a Gaussian distribution. After the output is obtained, K times of sampling is performed according to the mean and variance of the output to obtain a sample of the fitting coefficients. The corresponding K samples of initial residual stress can be obtained from the fitting coefficient samples. The reward (i.e., the negative error) corresponding to the initial residual stress sample can be calculated to obtain the expectation of the reward. It can be found from that above problem is an optimization problem, and the optimization goal is the maximum reward expectation. The optimization objective is shown in the following Eq. (6), where the reward ( R ) is computed as the negative error (L), i.e., R = 1/L . According to REINFORCE rule [37], we can get the gradient of updated weight as shown in Eq. (7). Therefore, when we obtain the reward expectation, we can obtain the gradient through calculation to update the weight of the neural network and adjust the output.
The unbiased empirical estimate of the gradient is shown in Eq. (8): where A = R(c k ) − b is the advantage estimate, b is the baseline, whose value is the exponential moving average over previous rewards. The baseline can accelerate the convergence speed and improve the convergence accuracy. K is the number of samples sampled according to the mean value and variance during each iteration. R(c k ) is the reward for each sample in K samples.
The pseudocode of the proposed algorithm is shown in Algorithm 1. The deformation force data set ( D val ) collected in actual machining and the error threshold ( ) are input into the algorithm, and the algorithm will automatically carry out iterative solving until the error ( L ) is less than the threshold ( ). Finally, the coefficients of the initial residual stress function ( c * ) is output corresponding to the deformation force data ( D val ).

Case Study and Verification
The proposed method in this paper is verified both in simulation environment and actual machining. In simulation environment, a benchmark initial residual stress field is set as the ground truth, and the deformation force of the benchmark initial residual stress is obtained by finite element calculation. The initial residual stress is inferred based on the deformation force generated under the set initial residual stress, and the obtained initial residual stress is compared with the ground truth residual stress to verify the accuracy of the results. In actual machining environment, the initial residual stress field inside the workpiece is solved based on the deformation force monitoring data during the actual machining process, the initial residual stress field was inferred based on the proposed method. As there is no ground truth of initial residual stress for actual situation, we verify the solution by comparing the deformation data collected in the actual machining process with the corresponding deformation data calculated according to the inferred initial residual stress field.

Theoretical Verification under Simulation Environment
In order to facilitate comparison, verification and explanation, this paper simplified the three-dimensional entity into a two-dimensional sheet as the machining object for theoretical verification under simulation environment. A two-dimensional plane of 10 mm × 100 mm was built in the simulation environment through the secondary development of ABAQUS, and the units of the workpiece were quadrilateral units. Under the premise of satisfying the finite element calculation accuracy, the unit discrete size is set as 1 mm × 1 mm, and the material properties are set based on the 7050-T7451 aluminum alloy commonly used in aircraft structural parts in the aviation field. The specific parameters are shown in Table 1.
The main principle of finite element simulation analysis is to discretize the continuous solving domain into the combination of elements. Therefore, the initial residual stress field inside the workpiece under the simulation environment is discrete. The initial residual stress inside the workpiece changes continuously along the thickness direction. In order to realize the reasonable addition of the initial residual stress of the workpiece in the simulation environment, the workpiece is layered along the thickness direction, and the initial residual stress field that changes linearly along the thickness direction is discretized according to the number of layers divided. Then, the discretized stress value is applied to the unit grid of each layer so as to realize the modeling of the workpiece with initial residual stress in the simulation environment. In order to make the initial residual stress field in theoretical verification close to the actual situation, the initial residual stress of 7050-T7451 aluminum alloy blank detected in the experiment of related research [36] is referred, and set in the simulation environment, as shown in Figure 5a. During the machining process, the deformation force monitoring of the workpiece is mainly realized by installing force sensors on the fixtures of the workpiece. In the simulation environment, the force sensor is simulated by adding a ground spring at the monitoring point of the workpiece, and extracts the strain data of the spring to obtain the deformation force of the workpiece. In order to ensure the restraint effect of the spring on the workpiece, the spring rate of the monitoring point is set to a larger value, i.e., the spring rate is 50000 N/mm. The boundary conditions are set in the simulation environment by referring to the clamping mode of the workpiece in the actual machining situation. As shown in Figure 5a, a fixed constraint is set on the workpiece at the unit node in the middle position to constrain the 6 degrees of freedom of the workpiece and fix the spatial pose of the workpiece. A ground spring is arranged at the corners of both ends of the workpiece to fix the workpiece and measure the deformation force of the workpiece.
During the machining process, the residual stress contained in the material to be removed is peeled from the originally balanced residual stress field inside the workpiece as the machining progresses, resulting in an imbalance of the residual stress field. In order to simulate the material removal process of the workpiece in the simulation environment, the birth and death element method is used to simulate the removal of materials during machining based on the ABAUQS simulation platform.
The actual machining is a sequential dynamic process. The material of the workpiece is removed layer by layer along the thickness direction as the machining progresses. In the process of material removal, the deformation force will change constantly, so it is necessary to simulate the continuous machining process of the workpiece and record the change process of deformation force. The time-series dynamic machining process of the workpiece is simulated by establishing continuous analysis steps in a simulation environment. The analysis steps of ABAQUS are set through secondary development, each analysis step is set corresponding to the machining of a single slot on each layer of the workpiece, multiple continuous analysis steps are set according to the number of machining slots so as to simulates the dynamic machining process of the workpiece sequence. Since the mesh size of the workpiece is 1 mm, the number of machining layers is 7 layers. Each layer mills 5 slots, only one slot is milling at each analysis step, so the total is 35 analysis steps. After the simulation analysis is over, the ABAQUS simulation software will generate an .odb file, which contains simulation environment modeling data and finite element analysis results. We accessed the .odb file through Python script, extracted the deformation force data generated in the simulation process, and saved it in .csv file format. The specific process is shown in Figure 6 Based on the deformation force data, the initial residual stress field corresponding to the deformation force is inferred according to the proposed method. As shown in Figure 7, after continuous iterative solving, the solving results are finally converged. The solving results with the minimum iteration error are taken as output.
The output of the proposed inference method is the distribution of initial residual stress field (i.e., mean value and variance). In order to evaluate the validity of the output results more reasonably, the deformation force corresponding to the mean value is compared with that corresponding to the benchmark initial residual stress. As shown in Figure 8, the true value is the deformation force corresponding to the benchmark initial residual stress field (Figure 5(a)). Solution is the deformation force corresponding to the inferred initial residual stress. Error indicates the difference between true value and the solution. It can be found from Figure 8 that the deformation force extracted by spring 1 and spring 2 is basically the same, which is mainly because the structure of the workpiece is basically symmetrical (as shown in Figure 5(b)), and the initial residual stress field inside the workpiece is symmetrically distributed (as shown in Figure 5(a)). In this experiment, a two-dimensional piece is used, so the deformation force is small. The contrast results show that the maximum error is no more than 0.30 N, the minimum error is approaching 0.0003 N, and the average error is 0.105 N, which indicates the effectiveness of the solving results.
The unbalanced residual stress inside the workpiece will cause deformation force in the process of machining. When the clamping constraints of the workpiece are released after machining, the workpiece will be deformed. Therefore, the final machining deformation of the workpiece is equivalent to the deformation force of the workpiece, which can reflect the level of initial residual stress inside the workpiece. We compared the deformation corresponding to the solved results with the deformation corresponding to the benchmark initial residual stress field (as shown in Figure 5(a)) to verify the effectiveness of the solved results. We extracted the deformation according to the position shown in Figure 5(b). The deformation caused by initial residual stress of the workpiece was mainly warping, so we extracted the variation in the Y-direction as the deformation of the workpiece.
The relative deformation data are shown in Table 2, where the deformation of solving is the corresponding deformation by the solved initial residual stress field. The ground truth is the deformation corresponding to the benchmark initial residual stress field. According to the data in Table 2, the deformation of the workpiece is a bit large at both ends and small in the middle. And the deformation of measuring points 1, 2 and 3 is similar to that of measuring points 6, 5 and 4. This is mainly because the geometric structure of the workpiece is symmetrical and the initial residual stress distribution inside the workpiece is also symmetric. In addition, the difference between the deformation of solving and the ground truth is small. The maximum error between the ground truth and the deformation of solving is only 0.02462 mm, the minimum error is 0.00134 mm, and the average error is 0.01132 mm.
The current solution of the initial residual stress field is based on the deformation force with a milling depth of 7 mm. To further verify the effectiveness of the solving results, the initial residual stress field obtained by the inferred method is applied to the simulation environment to calculate the deformation force and the deformation when milling the depth of 8 mm, and compare this value with the corresponding data corresponding to the benchmark initial residual stress field (as shown in Figure 5(a)), which means that we use the inferred initial residual stress to predict future machining trends. Figure 9 shows the deformation force comparison diagram when milling the depth of 8 mm. After comparison, the maximum error is 0.096 N, and the minimum error is 0.008 N. The deformation data is shown in Table 3. The maximum error is 0.0354 mm, the minimum error is 0.0037 mm, and the average error is 0.0186 mm.
In order to further verify the validity of the solving results, different benchmark initial residual stress fields are solved and analyzed. As shown in Figure 10, it can be found that very good solving results are obtained for different initial residual stress fields. Since the verification is performed on a two-dimensional plane, the initial residual stress has only one direction.

Actual Machining Verification
In order to verify the feasibility of the proposed method in practical machining, the blank with an external contour size of 640 mm × 240 mm × 26 mm is selected as the machining object to extract the deformation force, as shown in Figure 11(a), and the corresponding numerical calculation model is established under the simulation environment. 7050-T7451 aluminum alloy was used in the experiment. The actual clamping method of the workpiece is shown in Figure 11(a). In the position of the monitoring point 1, 2, 3 and 4, the force measuring fixtures are installed to measure the deformation force of the workpiece. The spring constraint is set at the corresponding position in the simulation environment. Points 1, 2 and 3 are fixed fixtures, and fixed constraints are set at corresponding positions in the simulation environment to fix the spatial pose of the workpiece.
As shown in Figure 11(a), there are 7 slots in total, the machining depth is 22 mm, the number of machining layers is 11, and the single cutting depth is 2 mm. The number of machining layers is 11, and each layer has 7 slots. The simulation environment is set according to the actual machining situation. Milling a slot in one layer is an analysis step, so there are 77 analysis steps in total. The cutting depth of the workpiece is 2 mm, so the size of the cell in the thickness direction is 1mm corresponding to the actual working condition. The deformation force is extracted from the measurement points shown in Figure 11(a), and the deformation force data of the workpiece is shown in Figure 12. The deformation force is obtained in the simulation environment by adding springs in accordance with the method adopted in theoretical verification.
According to the method proposed in this study, the initial residual stress field corresponding to the deformation force data in Figure 12 was solved. As shown in Figure 13, after continuous iterative calculation, the calculation results finally converge.
After iterative solving, the minimum RMSE is 6.71 N. In accordance with the same verification idea as in the theoretical verification, we compare the solving results with the data monitored during actual machining (i.e., true value in the Figure 14). The comparison result is shown in Figure 14, and it can be seen that the solving results are in good agreement with the data monitored in actual machining. We calculated the average relative error corresponding to the iterative solution result, and the result showed that the average relative error was only  where δ mean is the average relative error,F ground_truth is the deformation force monitored during machining, F solution deformation force corresponding to the solving result; n is the amount of deformation force monitored in the actual machining.
The inference result of the initial residual stress is based on the deformation force with a milling depth of 22 mm. In order to further verify the validity of the inference results, we continue to mill down to 23 mm on the basis of 22 mm and compare the difference between the deformation force corresponding to the inference result and (9) the deformation force monitored in the actual machining process (i.e., true value in the Figure 15). It means that we use the inferred initial residual stress to predict future trends. Figure 15 shows Since the main influence of initial residual stress on the workpiece is machining deformation, here we compare the deformation corresponding to the solved initial residual stress with the actual deformation of the workpiece after machining. After machining (the milling depth is 23 mm), we released the constraint of the force measuring fixture on the workpiece to deform the workpiece. The deformation was measured by the probe Figure 10 The inferred initial residual stress and compared with ground truth provided with the machine tool ( Figure 11(b)) according to the position shown by the monitoring points in Figure 11(a). The deformation caused by initial residual stress of the workpiece was mainly manifested as warping, so we extracted the variation in the Z direction as the deformation of the workpiece. The measurement results are shown in Table 4. As shown in Table 4, the solved deformation is the deformation corresponding to the initial residual stress field obtained by the method in this paper; the ground truth is the deformation measured in the actual machining. From the data in Table 4, it can be seen that the difference between the solved deformation and the ground truth is small, the maximum error between the real deformation and the solving deformation is only 0.0671 mm, and the average error is 0.0446 mm. It can be seen from the verification that the inferred result can reflect the deformation trend of the workpiece machining, but there is a certain error with the actual result. This part of the error is mainly related to the size of the grid in the finite element calculation. When the grid size is large, the error will increase, and the error will be correspondingly small when the grid size is small. However, the decrease of the grid size will directly lead to the increase of the computational amount and affect the computational efficiency. In this paper, the mesh size is selected according to the actual error requirement and calculation efficiency.

Discussion
The inference method of initial residual stress field proposed in this paper is to solve the mean value and variance of initial residual stress field. Therefore, there is uncertainty in the solving result. In order to evaluate the uncertainty of the data, we use confidence and confidence interval to quantify the reliability of the solving results to ensure the integrity of the data expression  information. Here we take the error corresponding to the solving result as the object to evaluate the uncertainty. Firstly, initial residual stress samples were obtained according to the solving results. Here, the number of samples in this paper is 1000. Secondly, the deformation force corresponding to the initial residual stress sample is calculated. Finally, the calculated deformation force sample is compared with the real deformation force to obtain the sampling error. The error distribution is shown in Figure 16. As shown in Figure 16, the error distribution is skewed. The confidence of the confidence interval [6.5, 7.2] is 95%. That is, the error of result has a 95% probability of falling between 6.5 N and 7.2 N. It can be seen that when the confidence level is 95%, the maximum RMSE of the solving result is 7.2 N, and the corresponding deformation force is shown in Figure 17.
In the actual machining, machining deformation is not only affected by initial residual stress, but also by the machining-induced residual stresses. The proposed method does not consider the machining-induced residual stresses in the machining process. This is mainly because in the rough machining process, the machininginduced residual stresses is only distributed in a very small range of the machining surface, especially for aluminum alloy material. Ref. [36] shows that in the process of aluminum alloy processing, the maximum distribution depth of residual stress is no more than 0.1 mm. In this paper, the data were monitored in the rough machining stage, and the wall thickness of the parts in the whole machining process was greater than 3 mm, so the influence of the machining-induced residual stresses can be ignored. When deducing the residual stress field of the finishing process and the difficult material, the influence of machining-induced residual stresses shall be considered.
The proposed method is to infer the global initial residual field inside the workpiece, which can be used for the analysis of the workpiece's overall machining deformation and the control of the workpiece's machining deformation. Most of the existing traditional residual stress detection methods can only be used for local residual stress detection. Although neutron diffraction technique has strong penetration ability, it has a large error when detecting the overall residual stress. Therefore, the existing test results cannot effectively reflect the overall initial residual stress level inside the workpiece.
The proposed method achieves the iterative solving of residual stress field by simulating the actual machining process with finite element analysis software (ABAQUS). When the actual machining conditions such as the geometric structure, machining path and clamping layout of the workpiece change, the residual stress field under different machining conditions can be inferred by modifying the finite element analysis conditions.

Conclusions
In order to infer the initial residual stress field inside the workpiece, this paper proposes a method to infer the initial residual stress of blank by incorporating the monitoring data with the mechanism model. This method uses the deformation force during the machining of the workpiece as the basis for inference, and solves the initial residual stress field inside the blank. Finally, the experimental verification shows that the deformation force average relative error is 9%, and the average machining deformation error is 0.0446 mm. The results can well reflect the initial residual stress field inside the workpiece, which can provide a very good basis for deformation control of structural parts.
To sum up, the research of this paper has made the following contributions: Figure 16 The error distribution of the solved deformation force Figure 17 The comparison between the deformation force with a solution error of 7.2 N and the real monitored deformation force Firstly, the method proposed in this paper can infer the initial residual stress field inside the workpiece from the monitoring data during the machining process. This provides an effective basis for optimizing machining process and improving workpiece quality.
Secondly, the initial residual stress for simulation is firstly generated randomly by a generator composed of neural network, and the gradient descent of simulation errors is realized by using the strategy gradient approach. Therefore, the research of this paper also provides an idea for the optimization of finite element simulation.
Finally, the method proposed in this paper is an exploration for incorporating the online monitoring data and the finite element simulation model, which provides a research reference for the fusing of machine learning model and mechanism model. Although the proposed method can effectively infer the initial residual stress inside the workpiece in experiments, there is still much work to be done in the future. This paper has only been effectively verified in blanks with regular initial residual stress field distribution such as pre-stretched plates and the material of aluminum alloy. This method still faces many challenges for blanks with complex structures such as die forgings. For blanks such as die forgings, the distribution of initial residual stress field is more complex. For difficult-to-machine materials, such as Titanium alloy, the machining-induced residual stress cannot be neglected, further study is still required.