Step heating thermography supported by machine learning and simulation for internal defect size measurement in additive manufacturing

A methodology based on step-heating thermography for predicting the length dimension of small defects in additive manufacturing from temperature data measured on thermal images is proposed. Regression learners were applied with different configurations to predict the length of the defects. These algorithms were trained using large datasets generated with Finite Element Method simulations. The different predictive methods obtained were optimized using Bayesian inference. Using predictive methods generated and based on intrinsic performance results, knowing the material characteristics, the defect length can be predicted from single temperature data in defect and non-defect zone. Thus, the developed algorithms were implemented in a laboratory set-up carried out on ad-hoc manufactured parts of Nylon and polylactic acid which include induced defects with different sizes and thicknesses. Using the trained algorithm, the deviation of the predicted results for the defect size varied between 13% and 37% for PLA and between 13% and 36% for Nylon.


Introduction
Additive manufacturing (AM) is integrated within the industry to increase the perceived value in any of the following three areas: profit, risk, and time [1].Furthermore, AM is one of the cornerstones of the 4.0 Industry which seeks to define a methodology to induce a transformation from machine dominant manufacturing to digital manufacturing, [2].Non-destructive testing (NDT) is a core technology for quality and safety assurance of critical engineering equipment and product manufacturing, and is an effective means of ensuring the quality of both materials and control [3].Since quality control and inspection are one of the main steps of additive manufacturing, NDT techniques are applied in different manufacturing processes, especially in those related to critical sectors (e.g.nuclear reactors [4]).However, the complexity of the geometry, together with the difficulty of finding the optimum parameters to achieve the desired end result and problems arising from poor process repeatability, makes it difficult to manufacture qualityassured parts, with implications for certification [5] and, finally, the absence of inspection international standards for NDT on additive manufactured pieces can induce important inspection limitations like inaccessible surfaces or specific defects generated in the layers not easily detectable.
The active thermography is based on the effect that any type of discontinuity in the structure of materials can alter thermal diffusivity and cause alterations in heat flow [6].This principle allows the detection of internal defects in materials [7], and for dimensional evaluation of these [8].Also for intermediate elements in materials or construction elements [9].
So active thermography is really an NDT that can be applied for material evaluation and defect detection, even in AM materials [10,11], or polymers and/or carbon fiber reinforced plastics (CFRP) [12][13][14][15][16][17][18] in the latter case, even with portable devices [19,20] or new approaches like pulse-compression thermography nondestructive evaluation [21] which improves the defect capability with respect pulsed thermography.Also, thermography can be applied to extract information about the welding zones during the extrusion [22], and for AM metallic materials, for example, to detect defects for lack of fusion in selective laser melting processes [23], to detect corrosion [24] or for evaluating welded unions [25], to characterize the fatigue of the material [26] or in combination with other optical non-destructive techniques like shearography [27].
The detectability of defects in flash thermography in low diffusivity materials such as additive manufacturing has been extensively studied [16,28] but this is not the case in easier application modalities such as the applied for this research: step heating [28].This modality requires less equipment, is lower cost, and causes less thermal stress to the objects compared to the flash mode [28].
In AM, the Finite Element Method (FEM) has been used as a tool to predict various parameters and outcomes, such as the mechanical properties of the parts generated, the shape of the melting bath, the microstructure, and dimensions [29].FEM methods are also useful to complement and optimize the cost and efficiency of the active thermography processes [10,11].In [10], numerical simulations for Stepheating thermography were experimentally validated.
Different studies have addressed the application of the Finite Element Method (FEM) in active thermography for testing CFRP, [12], for thermal predictions in the manufacturing process [29], for composites and metals using pulse thermography [30,31], for glass-epoxy composites using step phase thermography [32], in robotized devices [33] and for simulation of eddy current thermography in composites.Some of them have used well-known FEM solutions like Ansys ® [34,35] or Abaqus ® [11].The thermal conductivity equations can be numerically solved using sophisticated simulation tools [36], which can be both deterministic and probabilistic.Therefore, FEM models can be useful for estimating the physical parameters in active thermography tests.Additionally, these FEM models can also be used to extract a massive set of data that allows to feed predictive models based on artificial intelligence as a starting point.
Machine Learning/Deep Learning (ML/DL) techniques are currently applied in many industrial fields and these techniques have been also used to optimize the processes and parameters in AM [37].In fact, it is trending that researchers in the field of AM are paying more and more attention to taking advantage of the important benefits of Artificial Intelligence (AI) for the optimization of design tasks for process control [29].
In [38], ML/DL was applied for detecting cracks, in [4,39] to reduce the thermographic noise for defect detection on metallic pieces, and, in [29], ML was applied for the study of the evolution of the thermal field during direct energy deposition in stainless steels.In [40], DL was applied to characterize defects in composites, also using step-heating thermography.In [41] a DL model was applied to classify defects in fiberglass.
Within the most recent state of the art, thermography has been combined with ML strategies in the context of AM, for example, in [11] a theoretical different predictive algorithm feed from simulation data was proposed.This study analyzed the predictive performance of some algorithms for Nylon parts based on different measures of error and variability of the outputs without optimizing or applying experimental validation.That work [11] has served as the basis for this work because it allowed the selection of the predictive algorithms that would potentially be most effective (Support Vector Machine and Gaussian Process Regression methods).
The main research objectives of the work are: I) Generate a based-on active thermography method to measure the size of an internal defect of small thickness like layer defects in additively manufactured materials (materials with a clear lack of standardization at the quality testing level).II) Feed the method only with easy-to-extract temperature data with a simplified and well-known modality of active thermography: step-heating thermography.III) Validate the method under laboratory conditions and analyze the differences in error data as a function of flaw size and thickness.The presented research seeks to cover the research objectives and in this, a specific method (Fig. 1) for predicting the defect length dimension from thermal imagery was designed and validated using experimental data based on a simplified Step-Heating (S-H) thermography modality.Thus, a Mean Square Error (MSE) optimization algorithm is applied to optimize the predictive model and obtain the most appropriate hyperparameters and this predictive model is experimentally validated.Different processes are carried out which finally converge towards obtaining the results of deviations and predictive performance (Fig. 1).The reiterated FEM simulations generated many datasets that allowed us to train different predictive models.These datasets were independently generated for PLA and for Nylon, taking into account the physical properties and characteristics of each of them.Finally, the results of the experiment were used for the validation of the method.This process was repeated for both Nylon and PLA to compare the responses of predictive methods in the two types of materials.All this flow work will be explained in detail in the following sections.

Simulation
In [10], the usefulness of FEM simulation for active thermography processes in additive manufacturing materials was demonstrated and validated.For that reason, in this work, a specific approach is designed based on FEM simulation iteration with a probabilistic component that serves as a basis to feed ML models.
To simulate the thermal behavior of the additive material specimens, Abaqus2019® program was used and different analyses were automated using python.Firstly, the simulation setup and the boundary conditions established for the FEM analysis will be exposed.Secondly, the methodology to generate the datasets from the reiterative simulation procedure will be detailed.

Boundary conditions and simulation setup
A solid model with the shape of a rectangular cube was prepared with the same dimensions as the physical specimens (Fig. 2) that will be experimentally tested.A tetrahedral-shaped internal defect was generated in the model with a length and width in the interval indicated in Table 1 which also shows the input and output variables that have been considered for the FEM analysis.Regarding the input variables, Table 1 shows their baseline values, as well as the range of variation (in percentage) that have been studied both for the thermal properties of the two materials and for the dimensions of the tested specimens.In this way, 5,020 elements and 6,534 nodes were used to build the model.The type of element used was the one called in Abaqus DC3D8, which is an 8node linear isoparametric transfer brick, an element capable of simulating the thermal behavior of a material.A biased type of mesh was used that varied the size of the element used: from a resolution of 10 mm in the areas far from the defect, which are therefore of less interest, to a resolution of 1 mm in the closest ones.The size and number of elements with the biased mesh were established after performing a convergence analysis, observing that, the finer meshes did not yield better results.Fewer elements in the model allow for more interactions without increasing processing time.
To define the thermal behavior of the material, the thermal variables of conductivity and specific heat, and density must be specified as baseline values (Table 1).To characterize the heat exchange by radiation and by convection between the surface and the surrounding air, the baseline for emissivity (ε), and film coefficient (h) parameters also had to be defined, respectively.Please note that ε depends not only on the type of material but also on the surface finish.Furthermore, a predefined field was specified for all the surfaces of the solid, both internals and externals, to specify the ambient temperature surrounding the solid, which was considered to be 20 • C. Next, in the so-called Step-Heating (S-H) configuration, the upper surface of the solid was heated by means of an external heat energy source applied for 180 s trying to obtain the maximum contrast between the defect zone and the non-defect zone.Once this temperature is reached, the supposed external heat source is removed, and the solid is cooled to ambient temperature.
The temperature distribution that appears on the surface of the solid during the heating and cooling steps is not theoretically uniform due to the presence of the defect.The lack of material in this position causes the area close to the defect is heated faster and the same happens during the cooling step.The key is to compare the surface temperature (on the side to which the heat source is applied) in the position over the defect, with Fig. 2. Geometry and measures of the specimen.A and B are 4x4 px regions of interest where the temperature is monitored (up, left).Cut specimen to visualize the defect (thickness of the defect 0.9 mm, defect length LD, 10 mm) (up, right) Mesh of the FEM model with the defect in its center (down).
another one far from it (B and A regions respectively in Fig. 2) at the moment of higher thermal contrast between the temperature of the two points.It allows to see how the defect affects the heating and cooling processes, trying to establish a relationship between the difference in temperatures in these surface positions (A and B) to corroborate the presence of the defect and also its possible size.To this end, the maximum contrast (ΔT max ) variable was defined as the maximum difference in temperatures between the point over the defect and another one far from it during the studied period.This variable was measured throughout the whole thermal process, determining its maximum value and recording the time in which it occurs.The maximum temperature reached on the surface of the test piece, just above the defect, was also determined.Although this maximum temperature occurs just at the end of the heating stage, due to thermal inertia, the maximum (ΔT max ) value does not always occur at the final moment of the application of the heat source, being this last data considered since it is the moment of better visualization of the defect.

Reiterative FEM analysis
Once the model was defined according to all previous indications, the script generated by Abaqus in Python programming language was programmed to include the input variables (Table 1) and to obtain the output variables listed.An example of a visual result for the simulation is shown in Fig. 3.In this figure, the reader can see how the heat is distributed on the surface and inside the material, which justifies the need for additional methods to obtain measurements of the defect since no clear reflection of the defect on the surface is obtained.
From the baseline values of the seven input variables (Table 1) that have been considered in the study and considering their ranges of variation, different combinations of their values based on Design of Experiments (DoE) were performed.With this technique, it is possible to approximate the space of results, whose dimension is equal to the number of input variables and which is also continuous and therefore infinite, from the results obtained from a discrete number of iterations and therefore from a finite number of combinations of the input variables.
When using this methodology, it is of paramount importance to define adequately both, the number of iterations to be done and the methodology to define the combinations, hence, with the least number of iterations, the best possible approximation of the output fields can be obtained.In this study, the so-called Optimal Latin Hypercube (OLH) methodology was used, employing a total of 1,000 combinations.The advantage of this methodology is that the chosen combinations are

Table 1
Different considered features for each task, SC is the "Specimen Characteristics", I is the "input" and O is the "output".The feature "Defect Length" (LD) is the length of the quadrangular side of the defect and the feature "Defect thickness" (L_T) is the thickness of the defect.R is the "Response" and F is the "Feature".spread evenly, allowing a higher order effect to be captured, having the disadvantage that it increases the time required to obtain the optimal combinations, especially when the number of combinations and the number of input variables is large.

FEM
With the 1,000 combinations of output variables obtained, it is possible, using extrapolation and approximation techniques, to generate the mathematical equations that define the continuous results space for the ranges of the input variables studied.
The model was simulated 1000 times, modifying, within previously proposed ranges of values, the input variables within the established ranges (Table 1).Thank to this, a database of values of the input and output variables was obtained, which in this study, it is used to feed the ML methods.
Being a dataset generated by random inputs (within the bounds of Table 1), a subset of that data can still be also considered random.Therefore, to analyze the sensitivity of the model to different training data set sizes, alternative experiments can be done with a subset of 100 or 500 data.The error parameters based on RMSE and MAE remained in the same order of magnitude although a larger dataset (1000) was used because it was considered that a larger training set size would make the model more reliable.

ML algorithms
With the simulation, the thermal contrast is calculated for a multitude of defects of different dimensions and with different thermal properties.The data to feed the models are numerical, of dimension 1.These are obtained from the reiterative FEM simulation described in the last section and are used to train the predictive algorithms which allow predicting the defect length dimension from the thermal data (Fig. 1).
For the generation of the prediction models, different regression learning algorithms were used and tested.These algorithms are fed with the datasets generated by reiterative FEM simulation.Different typologies of learning regression models were tested to this aim: (i) linear regression, (ii) Support Vector Machine (SVM), and (iii) Gaussian regression.These models are configurated with different hyperparameters and characteristics which allow to raise a better result and they have been used for the classification of defects in materials [3].
On the one hand, there exist various regression learner models: linear regression using a constant and linear term, linear interaction regression considering intercept, linear and interaction terms that applies the interaction between predictors, and, finally, stepwise linear regression, which applies a method to analyze the importance and weight of each variable.Please note that this last model is not as fast as the other two.Based on [11], linear interaction regression since was the best because it provided adequate performance (similar to the stepwise regression and better than linear regression) while consuming much less computational resources.
On the other hand, SVM are flexible and customizable models with different kernel functions (Radial Base Function (RBF), Quadratic, Cubic, or Linear).However, the SVM are really non-parametric methods that sometimes are highly affected by outliers [42].In this research, the four kernel functions were tested.Specifically, for the RBF kernel, three different kernel scales were included: fine, medium, and coarse.Those prediction errors that were less than the threshold (ε) were ignored and treated as equal to zero.
Finally, the Gaussian Processes Regression (GPR) methods are based on the application of non-parametric kernel functions based on probabilistic models (Bayesian inference) [43].They are non-parametric methods that are usually more suitable for complex problems than the previously described standard regression methods, especially for the treatment of complex and noisy nonlinear functions [44] and for their cross-validation.Different kernel functions and basic functions can be used for the GPR mode: while the firsts determine the form of the prior mean function, the seconds determine the correlation in the response as a function of the distance between the predictor values.
The evaluation of the models has been traditionally implemented by computing the difference between the observed values and the predicted value.The goodness of the regression learning models can be evaluated using classical statistical performance results (e.g.[11,45]) which are calculated from the observed and predicted values.In this research, three statistical error types were obtained for each model: correlation coefficient (R2), Mean Absolute Error (MAE), and Root Mean Square Error (RMSE).
The training time is also considered a reportable parameter.Since all the experiments were implemented using the same workstation, the training time was measured for each model in order to compare the training speed of each algorithm.This information is useful to study the operability of the method, mainly its integration into industrial software.Additionally, the distribution and morphology of the residuals were considered for each model.
Once the different regression learners were applied to the data, the optimization of the models was implemented to obtain the maximum performance that each method can provide.MSE optimization based on Bayesian Optimization was applied to find the optimum hyperparameters.The optimization was applied for each studied model to obtain the hyperparameters and performance of each optimized model.

Experimental validation
For the experimental validation of the method, 18 ad-hoc designed specimens with the same shape (Fig. 2) were manufactured by 3D printing.Nine of them were manufactured in Polylactic Acid (PLA) and the other nine in Nylon (PA-12).Each specimen has the same size as the model generated for the FEM simulation: the thickness of 6 mm and a size of 100 × 100 mm.
Different square defects were generated in the specimens with an empty volume in the center to simulate a lack of material in one or various layers.The defect is completely covered by the AM material both above and below.
The sizes of the defect (L D ) were within the range established in Table 1 (5, 10, and 15 mm).For each size, three specimens were manufactured with thicknesses (L T ) of 0.3, 0.6, and 0.9 mm (Table 2).That is, the depth of the defect is sited at the same depth from the front or back of faces, 2.85, 2.7, and 2.55 mm, respectively.Please note that a thickness of 0.3 mm is almost the minimum layer height that many 3D printers allow.These measures were the same for the Nylon and the PLA specimens.
The specimen depth was not directly considered since the objective is to be able to predict different defect sizes with different thicknesses in a specimen of the same characteristics, simulating a layer defect during additive manufacturing.However, since the specimen width is constant (6 mm), the defect depth is directly proportional to the thickness.All the specimens were manufactured using a 100 % filler to fit the thermal properties with respect to the simulations performed, which consider solid material.Fig. 2 shows the generic location of the defects in the sample and a physical realization of them.On the specimen, two temperature measurement 4x4 pixel regions for defect and non-defect area (B and A in Fig. 2 respectively) have been established, both are separated at 25 mm (as in the FEM simulation) which is considered sufficient based on the dimension of the specimen, dimension of the defect, thermal diffusivity of the material and also o on heat conduction previous FEM analysis.Each defect was generated in a specimen (one single defect by specimen) to avoid alterations in the heat flow.
A validation setup is an ad-hoc experiment to obtain results that allow us to know the level of fitting of the predictions using ML models.To do this, the S-H thermography in reflection modality was applied using a ring of flash lamps (6 lamps of 600 W) arranged in convergent orientation toward the object (Fig. 4).The distance from the camera to the object was established at 50 cm to cover the complete target it the frame view and to guarantee the minima focal distance of the camera.The configuration of the set-up was kept constant for all experiments to ensure the same optical conditions and also to keep the radiated energy on the object constant.
The set-up characteristics were set to reply to the thermal conditions of the FEM simulation.A heating sequence of 180 s was applied to all specimens and subsequently, a cooling sequence of 540 s was recorded (the same parameters that were used for the simulation).This coolingheating time was applied based on trial-and-error seeking a balance between the efficiency of the method and its effectiveness.The frequency was established at 3 fps, being sufficient for the used lowthermal conductivity materials [46].The 18 specimens described in the materials section (9 of PLA and 9 of Nylon) were tested for the internal defect using this set-up.Environmental parameters measured in the laboratory using Testo probes (temperature and humidity) were considered in the data acquisition.Data were collected based on two little Regions of Interest (ROI's) of 4x4 px, one for the defect area and the other for the non-defect area (Fig. 2).The mean of the pixels values was calculated to do the procedure more robust.
Once the data collection was implemented, each sequence was processed using Thermographic Signal Reconstruction (TSR) [47] in the heating phase and in the cooling phase, independently.As a result, the noise was reduced and the maximum contrast values between the defect area (center of the specimen) and the non-defect area were extracted.

Results
The results section will be divided into 4 subsections.The results of the FEM method are first exposed.Next, the predictive performance results for each of the regression learning methods applied are presented.Subsequently, the results of the optimization carried out to the previous methods are indicated.Finally, the experimental validation of the method is properly considered.

Reiterative FEM results and Pareto analysis
From the FEM prepared in Abaqus, the temperature-time curves were obtained for the measurement positions just above the defect (B region in Fig. 2) and far from it (A region in Fig. 2), for the two materials (PLA and Nylon) when heating of 180 s to achieve a thermal contrast of 15 • C in the surface of materials [48].This heating time will be also applied for the experimental validation.
The maximum contrast and the times in which they appear in these curves are automatically extracted by means of the modified Python script of the model.A total of 1,000 iterations were carried out giving 1,000 combinations of results with which the mathematical equations of order n that approximate the results are adjusted, where n is the number of input variables.From the results obtained, it is possible to carry out various types of analysis, such as the Pareto analysis (Fig. 4), which makes it possible to determine the input variables that have the greatest effect on the output variables.Specifically, Fig. 5 shows, from the highest to the lowest, the percentage of effect that the seven input variables considered have on the maximum value of the Contrast Front curve.It can be observed that the Pareto diagram shows that the length of the defect causes the biggest effect over the Contrast Front maximum value ΔT max ).These results justify the generation of the models for the defect length prediction based on thermal contrast.

Predictive performance and optimization results
The different models were trained considering all the predictor variables (Table 3) and using 10-fold cross-validation.The preprocessing using Principal Components Analysis (PCA) was applied but gave notably worse results.For this reason, it was not used.Please note that other thermal variables such as the time required to reach the maximum contrast between defect and non-defect zones or the average temperature during the experiment were tested (including within the features set for training).As the predictive performance worsened in general terms, they were rejected and those that added value to the model were not finally considered.
The results for each ML algorithm that provided a better predictive performance are reported for the PLA (Table 4), being these similar to the two materials studied (Nylon and PLA).For each model, three datasets were generated using FEM, one of 100, one of 500, and one of 1,000, in order to feed the predictive models.
The regression learner algorithms were trained with the three data sets (100, 500, and 1,000) to evaluate the evolution of performance while the amount of data for training increases.The results obtained Fig. 4. Thermographic set-up for the validation of the method (left).Converged halogen lamps (600 W) used for the experiment (right).

M. Rodríguez-Martín et al.
were based on 1,000 datasets generated models with higher performance (Table 4).The predictive model of defects in Nylon follows a similar trend.Training the algorithms with the 100 and 500 datasets allowed verifying the convergence of the model because the error results were slightly higher for little datasets (100 and 500) than for bigger datasets (1,000).This can be a favorable indicator because it corresponds to the expected behavior and implies that the number of training data favors the effectiveness and learning capability of the model.
MAE is in the scale of the response (defect length).Therefore, it can be said that the mean error is of the order of mm for all algorithms trained.Specifically, GPR model is the one that gives the best predictive performance, even for small data training sets.However, training times are significantly longer (in the order of tens of seconds) than SVM models and linear regression models (in the order of a second).This trend is repeated in the predictive model for Nylon.In GPR models it was detected a slight non-linear trend between predicted and real valuesThis trend is repeated in the predictive model for Nylon.In GPR models it was detected a slight non-linear trend between predicted and real values.It is also possible to check how the variability of the prediction response is higher for large defect lengths.This could indicate the less favorable suitability of the method for such extreme values.Additionally, in the predicted vs real data, a higher error is observed for the higher values of defect length for all the trained models, being this compatible with [11].

Optimization
In the predictive model for PLA, when the SVM was optimized using 20 iterations, better results are not really achieved (RMSE 0.0018532, R2 0.79, and MAE 0.001425).However, the optimization of the GPR, once the optimization method has applied all the iterations, does slightly improve the results.The hyperparameters obtained are shown in Table 5.
In the predictive model for Nylon, when the SVM was also optimized using 20 iterations, better results are not achieved (RMSE 0.001317, R2 0.89, and MAE 0.0010517).However, the optimization of the GPR does slightly improve the results (RMSE 0.0011785, R2 0.92, MAE 0.000949).The hyperparameters obtained are shown in Table 5.The models also show less favorable performance for the higher values of dimension length.

Validation results
The experimental methodology described in section 4 was applied.The different defects were shown in the image (an example of a PLA specimen is shown in Fig. 6, being the results for the other specimens very similar).As the reader can see, the defect is better visualized for the higher length defects, but although the defect when well visualized can be measured on the image (once it is scaled), the token measure is really ambiguous (due to the heat flux diffusion and limitations image resolution) so the actual geometry of the defect may not be well-shown (Fig. 3).The average heating time to reach the maximum thermal contrast was 179.72 s.
The results obtained by simulation for the fabricated specimens (adhoc manufactured for this research as the reader can see in Fig. 2-right) were compared with the results of the experimental test described in Section 2 in order to evaluate the consistency of the methods and to detect possible a priori errors.In Fig. 7, the reader can observe the similarity between the results, which is proof that the simulation approach is consistent prior with the physical phenomenon evaluated.This trend was similar to the rest of the specimens evaluated.
Once this check had been carried out, we conducted an experimental study based on S-H thermography in reflection modality applied to real    physics specimens with known size defects (Fig. 2) and thermal properties (Table 1), to record the thermal contrast and introduce it to the predictive models to estimate the defect length.In this way, once predictive algorithms were trained from the parameters generated by FEM (c, k, ρ, ε, h, T M , ΔT max ) following the steps indicated in the last sections, the algorithms allowed to predict the length dimension of the defect (L D ) as a response from the maximum thermal contrast data (ΔT max ): f(c, k, ρ, ε, h, T M , ΔT max )→L D .Since the first four parameters are really physical properties that can be known, the predictive method should allow the prediction of defect length from the measurement of two thermal parameters that can be easily measured with thermography: T M and ΔT max .The defect length, in this experimental phase, is known for each physical specimen (it was a manufacturing parameter), so we were able to calculate the deviations between the real dimension and the ones provided by the predictive models based on the thermal maximum contrast moment.
The deviation between the length dimension predicted by the algorithm and the real length dimension (experimentally obtained) is shown in Table 6 and Table 7 for both Nylon and PLA materials.As can be seen, this deviation is greater when the thickness of the defect is smaller.In addition, as can be seen, the optimized model does not necessarily give better values, hypothetically due to the uncertainty of the experimental process and the anisotropy performance of the additive materials.

Discussion
The predictive algorithms have been designed to predict the length dimension of the square defect using only the physical characteristics of the material and the maximum thermal contrast from the temperature measures in two points when applying a step heating approach.The S-H thermography modality is simple and ML algorithms help to obtain a defect prediction without the need to use sophisticated and expensive techniques.So, in this research, we have on purpose simplified the Fig. 6.Left: Thermogram at the instant of the greatest contrast between the defect zone and the non-defect zone for PLA specimen of 0.6 mm thickness and 5 mm of defect length (up), 10 mm of defect length (center), and 15 mm (down).Right, contour map (30 levels) generated from each thermogram.number of thermal parameters as possible and we have used the simplest thermographic methodology.The methods have been trained with different thermal parameters (applying a variability in the training data), which would make it robust to material characteristics.
As a result, it is possible to predict the length dimension of the defects using only this data and the features of the material.For this purpose, we have used data from FEM simulation that adequately reproduce the results of the test, being the results compatible with the literature [10,11].
On the other hand, it has been shown that the results of the

Table 6
Error results from the comparison between the experimental value and the predicted value for PLA.Average Error (In absolute value) for the different thickness (t) and length (l).AV mean average for all the tested specimens for the same defect length (AVd) and defect thickness (AVt).

Table 7
Error results from the comparison between the experimental value and the predicted value for Nylon.Average Error (In absolute value) for the different thickness (t) and length (l).AV mean average for all the tested specimens for the same defect length (AVd) and defect thickness (AVt).prediction of the length dimension are more inaccurate in the defects of a smaller thickness (0.3 mm).This was to be expected given the lower detectability of these defects and the lower thermal alteration they cause (also considering the limitations of the speed of capture).A tendency to overestimate the dimension was detected in 15 mm defects.As the defects are larger, the measurement zone is closer to the beginning of the defect, which can lead to a bias in the result due to the high influence of the transition zone (Fig. 3).
Finally, the experimental results may be affected by an irregular heat distribution and also by the fact that the specimens are manufactured with 3D printing (non-uniform material), which could cause an anisotropic behavior in the distribution of the heat depending on the characteristics and direction of the filling process.In addition, inaccuracies of thermographic cameras (within the range of uncertainty indicated by the manufacturer), environmental factors, and possible additional reflections, could provide uncertainty to the final prediction outcome.However, since the proposed algorithms allow self-learning, if the experimental data are used to feed the training dataset, it is possible that the accuracy of the method is improved.Finally, it should be noted that the defects used in this work simulate defects of lack of coating but are of ideal shapes.Therefore, the actual defects may have a different thermal response and the effectiveness of the procedure may be affected by complex geometries.

Conclusions
This work has presented the results of a methodology based on artificial intelligence (ML) that uses data from repeated numerical simulations (FEM) to generate prediction models of the size of defects in AM materials based on the thermal contrast (S-H thermography) and the physical characteristics of the material.The creation of these models was justified by a cause-and-effect analysis applied to the FEM model, in which it was found that the length of the defect is the variable with more weight for the calculation of the thermal contrast by numerical simulation.
These models have been applied separately to two different materials: Nylon and PLA, to firstly estimate the intrinsic performance parameters of the predictive method (RMSE, MAE, and R2) of three different types of predictive algorithms: linear regression, SVM, and Gaussian regression.
The algorithms designed and optimized have been applied experimentally to real specimens of both materials that have been ad-hoc manufactured including defects of different sizes (5x5, 10x10, and 15x15 mm) and thicknesses (0.3, 0.6, and 0.9 mm).With this, it is possible to carry out an in-depth study of the accuracy of the method taking into account the factors that can affect the actual application (explained in the Discussion section) and not just taking into account the intrinsic performance of predictive models.
The intrinsic error of the algorithms (MAE) was in the order of a millimeter.However, in the experimental validation, this error was overcome in some cases.This is to be expected since the error of the trained algorithms is calculated from a subset of the simulation process data.When experimental data are obtained and entered in the models, different physical phenomena cause the error for length predicted to be larger, although in some cases a deviation of the real results with respect to the predicted ones was compatible (even more favorable) with the intrinsic error of the models: in some cases, the predictive algorithm manages to predict the size of the defect with a deviation close to 1 % while in other cases that deviation increases significantly.In general terms, it can be said that the bigger the thickness of the defect, the greater the accuracy of the prediction.Furthermore, the prediction performance is less favorable for higher defect lengths.
The proposed method could be compatible with other methods fed from S-H thermography to estimate the depth of the defect.The obtained length using this method could even be used as a predictive input parameter for depth defect prediction.Additionally, Futures works could address this issue.Furthermore, the results of this method applied to different internal structures and fills of additive manufacturing materials could also be addressed in future work and, also, noise could be considered in the FEM model to study if the final results are affected.

Fig. 1 .
Fig. 1.Methodological workflow to predict the length of the defect from the thermal data.

Fig. 3 .
Fig. 3. Results of FEM simulation for a defect where the different temperature area are shown.

Fig. 5 .
Fig. 5. Pareto diagram to visualize the weight of the different features in the maximum value of the variable ContrastFront (ΔT max ), Nylon (left), and PLA (right).

Fig. 7 .
Fig. 7. Differences in the heating and cooling curves between the defect (blue) and non-defect (brown) zone for 10 mm defect length and PLA: results from FEM simulation (up) and from the experimental test (in raw) (down).The X-axis represents the time and the Y-axis the temperature for all plots.(For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this article.) *Defect thickness is not considered for the prediction model generations because is considered an unknown parameter.***TM is the maximum temperature raised in the non-defect zone for the highest contrast thermogram. *

Table 2
Different manufactured specimens for this research.

Table 3
ML Algorithms which raised an adequate predictive performance.

Table 4
Intrinsically performance evaluation of the trained algorithms for the 1,000 sets of data.

Table 5
Hyperparameters obtained from the MSE optimization of the algorithms developed for the PLA and Nylon.