A Model to Construct and Predict Flow Curve of Materials from Compression Test Results with Machine Learning Models Using Python

In order to obtain flow curves from compression test results of a cold forging material and predict flow curves of the material at intermediate temperature and strain rate values, a model was developed using Python programming language in this study. The model consists of two parts: Flow curve determination and flow curve prediction. The compression test data including Force-Stroke values was processed to determine the flow curves in the first part, and the flow curve data constructed for certain temperature and strain rate values of the material was used as input for the machine learning algorithms to predict flow curve at desired intermediate temperature and strain rate values in the second part. Moreover, Ludwik material model parameters were estimated by using curve fitting methods in order to define the material model into the simulation software. Machine learning algorithms and various regression models in Python libraries were tested to predict the flow curves. The performances of different machine learning and regression models were compared with respect to the mean squared error and coefficient of determination performance measures. Support vector regression, k-Nearest Neighbour (kNN) and artificial neural network models were used to predict flow curves of cold forging materials and kNN regression model was able to found predictions with the lowest error rate. As a result, a model that can process the compression test data to predict flow curves at intermediate temperature or strain rate values was developed.


Introduction
Metal forming is widely used to produce cold forged fasteners for automotive, construction and machinery industries. Numerical simulations in metal forming are preferred to predict material flow, crack evolution, forging load, and die life. In order to be able to simulate the forming process, material characteristics must be integrated into the simulation program. One of the most preferred methods of this integration is to incorporate Ludwik parameters of the material. The mathematical formulation of Ludwik model was given in Eq. 1 in which is the true stress, is the yield stress, is the strength coefficient, is the true plastic strain and is the strain hardening exponent. Introducing robust material models of various temperatures and strain rates for a material increases the accuracy of the forming simulation. For this reason, compression tests were carried out on the raw materials used in production at different deformation rates and temperatures in order to obtain more realistic simulation results. In this study, a model was developed that processes the compression test data and converts them into Ludwik material model coefficients that can be integrated into simulation software. This model also predicts the coefficients at untested temperature and strain rate points using predictive machine learning libraries of Python.
Machine learning algorithms, especially Artificial Neural Network (ANN), are frequently used in the field of materials science to predict flow curves. The number of studies on cold forging applications and material flow curve estimations has increased recently. One of the first studies published in these area was by Osakada and Yang (1991) [1]. In the study, ANN was used to solve the problems on the expert system and to optimize the final shape of the cold forged product. Also, the number of forging stages was redesigned according to the results of neural network and the difference was taken into account by Finite Element Method (FEM) simulation. Mandal et al. (2008) [2] predicted the behaviour of 304L stainless steel against torsion using ANN. An ANN model based on flow curve estimation for Al-Mg alloys was created by Toros and Ozturk (2011) [3]. It was aimed to calculate flow curves at temperatures between 25⁰C and 300⁰C. The estimated values were compared with the experimental results. Bingöl and Misiolek (2015) [4] conducted compression tests at temperatures of 200-400⁰C and strain rate of 0.01-15 s -1 . Then, true stress and true strain values at certain temperature and strain rate points were estimated by using ANN and Gene Expressing Programming (GEP) models and compared with the experimental results. Both models were found to be successful, however ANN model was slightly more accurate than GEP model. Flow curves of ZAM100 magnesium alloy sheets were estimated by Mehtedi et al. (2019) [5] for use in hot forging applications. Within the scope of the study, a multivariable model was created using ANN. Results were tested by using cross validation and estimating the flow curves that are not included in the datasets. Machine learning algorithms were applied to phenomenological flow curve estimation by Stendal et al. (2019) [6]. In the study, flow curve estimation was made using a previously developed phenomenological model and machine learning separately and together. The obtained data were compared among the methods. Similar studies have been carried out not only for metals but also for polymers. As a result, it was revealed that the ANN model is successful in estimating material flow curves with respect to the studies in the literature, but regression-based machine learning models were not used to predict flow curves. In this study, firstly, the method of obtaining the material flow curves, which will form the inputs of the machine learning models, by processing from the experimental compression test data was automated, and then machine learning models were proposed to predict the flow curves at intermediate temperature and strain rate values without experimental results.

Constructing Flow Curve of Materials from Compression Test Results
Introducing material data is mandatory in order to perform the necessary numerical simulations and analyses. For this reason, experimental compression tests results must be processed to get the flow curves of the materials. Experimental results are usually processed manually in statistical programs which leads to great loss of time.
Within the scope of this study, a model was developed that converts the Force-Stroke data obtained from the experimental compression test to the flow curve data of material by using the necessary formulations on Python. Curve fitting operation was applied to the flow curve by using the curve_fit function of Scipy.Optimize library on Python. The obtained coefficients of the Ludwik material model can be defined into the analysis program. In addition, the model can perform these operations by taking the average of multiple compression tests conducted to reduce the error rate in the test results.
Materials and Experimental Setup. The operability of the developed program was tested using compression tests of a Stainless Steel (SS) and a Medium Carbon Alloyed Steel (MCAS) material. Compression tests were carried out at different temperatures and strain rates in accordance with the ASTM E9 standard [11]. Compression tests were carried out with ZWICK universal tensile/compression test device for the temperature values of 25-100-200 °C and strain rates of 0.001 and 0.275 s -1 . The friction condition affecting the material flow was minimized by using MoS2 based lubricant for machine compression tables before each compression test. In general, it is expected that Key Engineering Materials Vol. 926 the true stress values decreased as the temperature increased, and the true stress values increased as the strain rate increased. In other words, increasing the strain rate generally increases the work hardening rate at smaller strains, which may contribute to a wider initial strain distribution in compression. However, the work hardening rate decreases with increasing strain rate due to adiabatic heating at larger strains. Experimental flow curves for MCAS material at different strain rates for 100 °C was given in Fig. 1. Yield strength values were increased as the strain rate increased for 1 00 °C. Experimental flow curves for MCAS material at different temperatures for strain rate 0.001 s -1 was depicted in Fig. 2. One can observe that true stress values were decreased as the temperature increased for strain rate 0.001 s -1 .  Flow Curve Construction Model. In order to convert manual flow curve construction method into a model, experimental data must be subjected to certain intermediate regulations in order to apply necessary formulations. These steps are removal of faulty data at the beginning of the test,

2024
Achievements and Trends in Material Forming determination of the proportional limit point, translation of the data, determination of the slope of the elastic region and the determination of the yield point. The respective engineering stress value was calculated by using the line equation of the elastic region for each experimental engineering strain value starting from the smallest one and compared to the corresponding experimental stress value. These process was iterated until the difference between the experimental stress value and calculated stress value becomes negative. The last calculated engineering strain was determined as the respective strain value of the yield point searched for. After finding the yield point, the model constructs the flow curve of the material. The obtained flow curve can be curve fitted according to Ludwik material model and the coefficients can be obtained (Fig. 3).

Machine Learning Methods to Predict Flow Curve
It was aimed to predict flow curves for the intermediate temperature and strain rate values with the flow curves created from the force-stroke data by using the developed flow curve construction model. Temperature, strain rate and plastic strain parameters were used as independent variables or input variables to predict true stress dependent variable or output variable in this study. Machine learning applications such as k-nearest neighbour (kNN), support vector regression (SVR) and ANN models were chosen to predict flow curves, since ANN is known to be successful to predict continuous target variable [8] and regression models are generally used in numerical estimations. The predictive performances of classification, regression and neural network models was analysed in this study.
SVR was developed by Drucker et al. (1997) [12] and the aim was to determine the line or curve so that the maximum point in the range of a margin can be taken with the lowest error rate. Compared to other traditional learning methods, this method performs much better in solving nonlinear problems. SVR model has different kernel functions to optimize the equational structure of the flow curve. They are specified as linear, polynomial and radial basis function (RBF). The mathematical formulations of linear, polynomial and RBF were presented in Eq. 2, 3 and 4, respectively. In these equations, and represent the vector of independent and dependent variables, respectively. SVR function included in the regression part of support vector machines api of scikit-learn library was tested for these kernel functions on Python. Mean squared error rates (MSE) and determination coefficients (R 2 ) were reported to obtain the optimum function within the scope of the study.

Key Engineering Materials Vol. 926
( , ) = ( . + 1) . (3) The kNN algorithm, which is one of the supervised learning methods, is a versatile algorithm that can be used both in classification and regression. In this study, KNeighborsRegressor function of scikit-learn library was used. A simple implementation of kNN regression is to calculate the average of the numerical target of the k nearest neighbours by selecting "uniform" option in weights function of KNeighborsRegressor. Another approach uses an inverse distance weighted average of the k nearest neighbors with "distance" option. Both approaches have been tested and errors rates were compared in this study. In general, ANN is a feed forward Multi Layer Perceptron (MLP) application consisting of input, hidden and output layers. Activation functions are used to switch between layers, and back propagation method is used to optimize the weight parameters connecting the layers and neurons in the hidden layers, aiming to reduce the error rate between the estimated value and the actual value of the output parameter. In this study, two different ANN models consisting of one and two hidden layers are proposed by using the MLPRegressor function in the scikit-learn library. For both ANN models, 3 input parameters as temperature, strain rate and plastic strain were used and true stress value was determined as output parameter. The "lbfgs" algorithm, which is considered to perform well in small data sets, was used as the solution algorithm, and the hyperbolic tangent function, f (x) = tanh(x), was determined as the activation function. In order to determine the number of neurons used in the hidden layers and to determine the "random_state" parameter, which significantly affects the ANN performance, an optimization study was carried out to obtain the predictions with the lowest error. Parameter optimization of the ANN models was carried out for both materials (MCAS, SS) investigated in this study. For the model consisting of two hidden layers, the number of neurons in both layers was optimized with respect to the R 2 value for all integer values between 1-40 and the "random_state" parameter for integer values between 0-9. For the ANN model with single hidden layer, the number of neurons was optimized according to the R 2 value for all integer values between 0-150 and the "random_state" parameter for integer values between 0-9. The parameter setting results of ANN models with single and two hidden layers were presented in Table 1 for both materials. In Fig. 4, schema of the ANN model with two hidden layers was depicted in which n1 is the number of neurons in the first hidden layer and n2 is the number of neurons in the second hidden layer. This ANN model was represented shortly as (3, n1, n2, 1). Accordingly, for MCAS material, the ANN model with a single hidden layer obtained the highest R 2 value with 136 neurons and random_state=6, i.e. (3, 136, 1), the ANN model with two hidden layers had 32 neurons in the first layer, 23 neurons in the second layer and random_state=6, i.e. (3, 32, 23, 1). For SS material, the ANN model with a single hidden layer obtained the highest R 2 value with 82 neurons and random_state=9, i.e. (3, 82, 1), the ANN model with two hidden layers had 32 neurons in the first layer, 37 neurons in the second layer and random_state=0, i.e. (3,32,37,1).

Result and Discussion
In order to verify the generalization capability of the developed machine learning algorithms, 20% of the data obtained by the experimental compression tests was determined as test data and remaining data was determined as training data by using "train_test_split" function of scikit-learn library. In order to measure the performance of the developed machine learning algorithms; the determination coefficient, R 2 , and MSE were utilized. As can be seen in Table 1, SVR with the kernel RBF and the kNN algorithm with both weight can predict the test dataset at lowest error rates and above 0.99 R 2 values for both material types. The prediction performances of ANN models with single and two hidden layers were presented in Table 2 for both materials. The test data for both ANN models were estimated very close to each other with high R 2 values for both material types. When the obtained MSE values were considered, the ANN model with two hidden layers was able to predict the test data with less error rate for both material types. Therefore, while estimating the flow curve for the intermediate temperature and strain rate values, the ANN model with two hidden layers was used with the best neuron and "random_state" parameter values found for the material types. Flow curve estimation was performed for intermediate temperature and strain rate values by using the SVR model with the RBF kernel function and the kNN model with the "uniform" weight option.   Fig. 5(b). In the flow curve predicted with kNN, oscillation in the data was observed due to the number of neighbours used in the model. The oscillation can be eliminated by increasing the training data size and the number of neighbours in correlation.
(a) (b) Figure 6. Flow curve prediction for SS material at 150 °C and strain rate 0.275 s -1 with the (a) kNN, (b) ANN models.
In Fig. 6(a), the estimation results of the kNN model at 0.275 s -1 strain rate and 150 °C for SS material were compared with the experimental flow curves performed for SS material at 0.275 s -1 strain rate and at 100 and 200 °C. The flow curve predicted by the kNN model was between the experimental true stress values obtained at 100 and 200 °C. In Fig. 6(b), the estimation results of the ANN model for SS material were compared with the experimental flow curves performed for SS material at 0.275 s -1 strain rate and at 100 and 200 °C. The flow curve predicted by the ANN model was obtained between the two experimental curves as expected, that is, the true stress values obtained at 150 °C were found between the true stress values obtained at 100 and 200 °C. Due to the smaller data size at high strain rates, the ANN model showed a lower performance in prediction than the kNN

2028
Achievements and Trends in Material Forming model. Since the kNN model calculates the average of the points within the determined neighbourhood, it obtained more accurate results at high strain rate values.
(a) (b) Figure 7. Flow curve prediction for MCAS material at 100 °C and strain rate 0.100 s -1 with the (a) SVR, (b) ANN models.
In Fig. 7(a), the prediction results of the SVR model for the MCAS material at a strain rate of 0.100 s -1 and at 100 °C were compared with the experimental flow curves of the MCAS at strain rates of 0.001 and 0.275 s -1 at 100 °C. The flow curve estimated by the SVR model was obtained close to the experimental flow curve of 0.001 s -1 strain rate. The flow curve prediction of SVR for the intermediate strain rate values gives more inconsistent results than the predicted flow curves for the intermediate temperature values. It is assumed that this consistency is due to the fact that the number of strain rate levels is less than the number of temperature levels in the experimental training data. In Fig. 7(b), the estimation results of the ANN model were compared with the experimental flow curves performed for MCAS material at the same conditions. The flow curve predicted by the ANN model was obtained between the two experimental curves as expected and more harmonious results were found than the SVR model.

Conclusion
In this study, a model was developed that converts the Force-Stroke data obtained from the experimental compression tests to true stress-plastic strain flow curve using the necessary formulations on Python programming language. Then, experimentally obtained flow curves at different temperatures and strain rates were used to train the proposed machine learning models to make flow curve estimation at intermediate temperature and strain values. Parameter optimization of these models was carried out using 20% of the experimental data as test data and the remainder as training data. Then, the estimation performances of the three models with optimum parameters were compared at intermediate temperature and strain rate values. According to the results, kNN and ANN models obtained similar and favourable results for flow curve estimation at intermediate temperature value, while ANN model with two hidden layers predicted the flow curve more reasonable at intermediate strain rate value. As a result, a model that can process the compression test data to predict flow curves at intermediate temperature or strain rate values was developed.