In-situ porosity recognition for laser additive manufacturing of 7075-Al alloy using plasma emission spectroscopy

Poor quality and low repeatability of additively manufactured parts are key technological obstacles for the widespread adoption of additive manufacturing (AM). In-situ monitoring and control of the AM process is vital to overcome this problem. This paper describes the combined artificial intelligence and plasma emission spectroscopy to identify the porosity of AM parts during the process. The time- and position-synchronized spectra were collected during the directed energy deposition (DED) manufacturing process of a 7075-Al alloy part. Eighteen features extracted from spectra were coupled with the deposition qualities which were characterized by the 3D X-ray Computed Tomography (CT) scan and used to train a Random Forest (RF) classifier. The well-trained RF classifier achieved up to 83% precision for the porosity recognition of depositions. The feature importance recorded by the RF classifier indicates that the intensities of spectra at the wavelength of 414.234 (Fe I) nm and 396.054 (Al I) nm, and the kurtosis of spectra at wavelength ranges of 484–490 nm and 508–518 nm, are the most effective features for porosity recognition. The physical correlations between spectra, porosity formation, and thermal accumulation during the AM process were analyzed. This study demonstrates the great potentials, as well as challenges of plasma emission spectroscopy for in-situ quality monitoring of laser AM which allows the enhancement of AM technique.

in the manufacturing process, especially for the 7075-Al alloy which has high thermal conductivity and complex compositions including volatile materials such as Mg and Zn. For these types of porosity, signals which provide more fundamental information related to the porosity are needed. Recently, Leung 13 demonstrated the application of high-speed synchrotron X-ray imaging for porosity monitoring in laser PBF. This research revealed the pores formation mechanism and pores' dynamic behaviors under the build surface. However, the X-ray imaging technique can only be used for small samples for limits of X-ray image resolution, which hinders its adoption in practical applications together with the high cost of synchrotron X-ray implementation.
To overcome the above challenges in in-situ porosity detection, an advanced sensing technique named emission spectroscopy is employed in this study. The emission spectra are made up of photons emitted from excited atoms in the plasma generated during the laser AM process. Recorded with fine wavelength resolution, emission spectra contain much more physical information than other optical signals. The spectral emission wavelength reveals the chemistry of the plasma and the spectral intensity reflects the element concentrations and plasma conditions such as plasma temperature and electron density 14 . Owing to the rich information in the spectra, emission spectroscopy has the potential for monitoring multiple part qualities, from defects to composition. Research using emission spectroscopy on in-situ monitoring of laser AM has been done before, notably by Mazumder and his group members who have been carrying out an in-depth study on this topic for a considerable amount of time. They have demonstrated that emission spectroscopy is effective for in-situ monitoring of feedstock composition 15 , phase transformation 16 , and residual stress 17 of parts. In their recent patents, spectral features including spectral line intensity, line-to-line ratio, and plasma temperature are used for the closed-loop control in a Direct Energy Deposition (DED) system 18 . Lough 19 also equipped a spectrometer into the PBF system to measure the real-time spectra for melt pool size monitoring. Stutzman et al 20 demonstrated that the median line-to-continuum ratios of spectra at 430 nm and 520 nm significantly increased when the DED part presented non-fusion pores induced by suboptimal process parameters. However, this study doesn't detect the porosity quantitively and the physical relationship between pores and spectra were not analyzed. Montazeri et al 21 developed a machine learning model for porosity detection of laser PBF using the line-to-continuum ratio of Cr spectral emission. The proposed method can accurately recognize the porosity level of parts printed under different process parameters which has proved the great potential of spectroscopy for porosity recognition. The main limitation of this study is that it recognizes the porosity layer-by-layer which makes it not applicable for real-time defects correction.
A challenge in using this method is knowing which features in the spectra give the most meaningful information about the part quality. Various features can be extracted to interpret spectra in a different way, such as emission intensity, intensity ratios, and spectral profile properties. However, the importance of these spectral features for porosity detection has not been discussed. The physical principle of emission spectroscopy on defects recognition needs to be studied further. Therefore, an artificial intelligence method named Random Forest (RF) classifier has been employed in this study, which can estimate the importance of individual spectral features during developing the porosity recognition model. In summary, this study investigated the in-situ recognition of local porosity in the laser-based DED part produced under consistent parameters. Spectra signals were related to the porosity defects which were characterized by 3D X-ray Computed Tomography (CT). An intelligent RF classifier was developed for local porosity recognition using spectral features. Important spectral features for porosity detection were determined and analyzed.

Methodology
Plasma emission spectroscopy in laser AM. Unlike the laser-induced breakdown spectroscopy (LIBS), spectra are directly produced by the laser in the additive manufacturing process. As shown in Fig. 1, metal deposition and powder are melted and partially evaporated under the illumination of a highly energetic laser. Atoms in the metal vapor and the shielding gas are excited to high energy level states and then transit to lower energy level states based on spontaneous transition theory 22 . During these spontaneous transitions, photons with specific wavelengths determined by the energy gaps of transitions are released and recorded as emission spectra. Since the energy gap is a characteristic of each element, the wavelengths of the emission spectrum are identifiers for the radiating atoms. Further information on emission spectroscopy can be found in references 14 . The spectral plot in Fig. 1, for instance, is a spectrum collected during laser additive manufacturing of 7075-Al alloy. Peaks at wavelengths 383.229 nm, 396.054 nm, 414.234 nm are respectively identified as the peaks of Mg I, Al I, and Fe I which are the main elements in the target material.
The intensity of the spectrum is proportional to the density of emitted photons. Under the local thermal equilibrium assumption, the emission density ( I i j ( ) ) of photons is: where the partition function U(T) is the statistical occupation fraction of every level of the atomic species: There are two types of variables: (1) the element-determined variables, including the wavelength of the photon ( ), the transition probability ( A ij ), the degeneracy of the upper level ( g i ), the energy at level i ( E i ) and level j ( E j ); (2) and the plasma-determined variables, including the number of neutral atoms in plasma ( n 0 ), the temperature of plasma ( T ), and the spectral line profile ( I( ) ). These variables are directly correlated with process parameters and the quality of the manufactured parts. For example, the laser power density affects the temperature and electron density of the plasma, which in turn affects the intensity and profile of spectra. Parameters, including www.nature.com/scientificreports/ laser properties (wavelength and power distribution), powder delivery rate, and shielding gas flow also influence the spectral properties significantly. Therefore, the close relationships between spectra signal and manufacturing parameters and quality make emission spectroscopy a great candidate for in-situ defects detection.
Theory of random forest. Random Forest (RF) is an ensemble model that is constructed by multiple classifications or regression trees (CARTs) and makes predictions based on majority voting from individual trees 23 . The building procedures of an RF classifier are shown in Fig. 2 in which a two-stage randomization procedure contributes unique advantages of the RF model. One is that examples used to grow individual decision trees are randomly selected from the training dataset with replacement, known as bootstrap aggregating 24 . By assembling trees grown from different training data subsets, the RF model becomes more robust when facing slight variations in input data and, in turn, achieve greater classification stability. Several studies have proved that models based on bootstrapping, like RF, are less sensitive to noise and more effective for handling imbalanced data compared to other models 25,26 . Also, as growing trees, only 2/3 of the bootstrapped dataset is used to train the current tree and the other 1/3 of the dataset forms another subset named out-of-bag (OOB). The OOB dataset is used to get an unbiased estimate of the classification error as trees are added, which avoids the RF model overfitting data.
The OOB method has a similar function with cross-verification but almost no additional computational task is needed. Another randomization stage is that rather than using all features only a random subset of features is used as candidates for splitting each node of a tree. This can reduce the correlation between trees so that RF gets a higher generation accuracy although the strength of an individual tree is decreased. As growing trees, a feature selection measurement is required to split examples at each node. One of the most popular measurements, named the Gini impurity criterion, is used in this study. The Gini impurity indicates how pure the node is, and it goes to zero when all examples at the node are purely classified. At each node, the decision tree searches through the subset features for the value to split on that results in the greatest reduction  RF also provides an assessment of the relative importance of each feature for classification. This property is significant because it is important to know how each feature influences porosity recognition, and which feature is most relevant to porosity defects. To get the relative importance of each feature, the RF model replaces one of the input random features and measures the resulting decrease in accuracy by seeing the change in the OOB error estimation and the Gini impurity 24 . Investigating the response of the most important features to additive manufacturing quality is helpful to reveal the underlying fundamentals of defects formation.

Experiment
Experiments were conducted using the smart DED system developed at SenSigma company, USA. The DED system consists of a high power Trumpf 6 kW Nd: YAG laser, a six-axis robot, a material supplier, and a Smart Optical Monitoring System (SOMS). The experimental setup is shown in Fig. 3. A Gaussian laser beam with a wavelength of 1030 nm is focused on the build surface. An optical head and a customized nozzle are assembled on the robot arm. Argon gas is used to shield the powder flow into the laser beam, and create an inert environment around the metallic deposition. The 7075 powders are delivered co-axially with the laser beam and are melted and deposited as the delivery nozzle moving relative to the base plate. An optical probe collects the light emitted from the plasma and transmits the light to the spectrometer (Ocean Hr2000). The optical probe is set to be nearly parallel to and 2 mm above the substrate, and 150 mm away from the laser beam. Spectra are collected during the DED process using the SOMS system with a spectrometer having a 277-570 nm wavelength range and a resolution of 0.154 nm. The integration time of the spectrometer is set to be 0.01 s.
The 7075 powder is gas-atomized with a particle size ranging between 44 µ m and 105 µ m (− 140/ + 325 mesh). Table 1 presents the chemical composition of the powder. To print a part with qualified dimensions and containing the proper number of pores, optimization experiments were conducted following the Taguchi design method with laser power, scanning speed and the powder delivery rate between 1000-1200 w, 6-8 mm/s, and 0.5-1.5 g/min, respectively. Only the parameters as listed in Table 2 were used to print the part for the porosity recognition investigation in this study, as all other parameters produced parts with unacceptably high numbers of pores. Figure 4a schematically illustrates the scanning path, which consists of 10 layers and 14 bidirectional lines in each layer. The layer thickness and hatching space are set to be 0.35 mm and 0.75 mm, respectively. At the beginning of each layer, a square periphery would be printed along the edge of the deposition to avoid collapse. The nozzle goes back to the start point after each layer being done, and rises 0.35 mm, then repeats to print the next layer. In this way, a rectangular part, shown in Fig. 4b, with dimensions of 12.6 × 12.6 × 3.5 mm, was deposited upon a 7075-Al alloy substrate with a thickness of 12.7 mm (1/2 in.). Spectra signals were synchronously collected for each deposition layer.
The printed part was cut off from the substrate using an abrasive cutting machine and inspected in the as-built condition. Post-inspection was implemented for the presence of pores in the part using a 3D X-ray Computed Tomography system (Zeiss Versa 520) with a voxel resolution of 7.5 µm in each direction (x, y, and z). The part was mounted on a high-precision stage and incrementally rotated by 0.225 degrees for a full 360° rotation. As the sample rotating, X-ray beams were transmitted through the part at a power of 7 w and a voltage of 80 kV  www.nature.com/scientificreports/ getting one projection image at each rotated angle with an exposure time of 3 s. The source filter used during the scanning is LE2 glass filter. 1601 projections were taken in 360° of the part and reconstructed to a complete 3D X-ray CT scan representation of the part. The outputs of the X-ray CT characterization were used to manually label the local deposition as dense or porous.

Experimental data analysis
Spectra signal possessing. The raw spectra signals collected from one layer printing process are plotted in Fig. 5a. There are 3480 spectral frames collected in each layer in which each spectral frame consists of a spectrum with 2047 variables in wavelength dimension. Since the spectra signals are collected synchronously during the printing process, each frame of the spectra can be located at a specific voxel of deposition based on Eq. (4).
where L is the printing length corresponding to the N th frame of spectra. τ and V are the integration time of spectrometer and printing speed, respectively. Therefore, the spectra data can be labeled with the quality of deposition qualified by X-ray CT scans. As shown in Fig. 5b, the raw spectrum is made of continuums spectrum (background continuum) and emission spectrum (emission lines) which are produced in completely different mechanisms and hold distinct information about the process. Thus, the background continuum and emission lines were extracted from the raw spectrum and interpreted separately. The first lower envelope of the raw spectrum is calculated using a linear interpolation formula shown in Eq. (5). Then the lower envelope of the first lower envelop curve was calculated in the same way and served as the background continuum of the spectrum.    Table 3 presents the details of the eighteen spectral features.
Since the laser-material interaction area equals the laser beam diameter, which is 1.2 mm in this study, the prediction resolution was set to be 1.2 × 1.2 mm in the XY plane. Within each interaction area, 20 frames of spectra were collected. An average of 20 frames was taken for each feature and served as the input of the classification model.

Post-built porosity calculation.
The actual quality (ground-truth) of each local deposition in the part is labeled by the X-ray CT scanning results. To correlate the synchronized spectral data with the porosity distributions, the CT scans of the part were manually rotated and translated to register the CT scan volume to the same coordinate system. The CT scanning volume was sectioned into 250 slices perpendicularly to the building direction. Based on the deposition layer thickness, 24 CT scanning slices were assigned to each printing layers and ten slices were assigned to the attached substrate for porosity rate calculations.
To eliminate the complications arising from the effects of the edge depositions, analysis of the CT image is limited to a region of interest (AOI) which is approximately 1.8 mm away from the edges. Figure 6a gives a representative slice of CT scans, in which the red box and dash lines illustrate the AOI and the 12 printing paths (from the second line to the thirteenth line), respectively.
The porosity distribution in each layer of the part can be calculated as follows: (1) Convert each slice in one deposition layer to a binary image using a threshold of 140 lightness, so that the pores in the slice are converted into black pixel contrasting to the white dense deposition areas. (2) Get the spatial porosity rates by calculating the ratios of the black pixels to the white pixels in the local area. As shown in Fig. 6b, the local area is outlined by a window with a size of 111 × 111 pixels, which correspond to an area of 1.2 × 1.2mm deposition. (3) By moving the window along the printing path with 50 pixels overlap, the spatial porosity rate of the whole slice can be obtained. (4) Calculate the porosity rate of each slice in this layer using the same method. Average the porosity rate at the same position in the XY plane of all slices in this layer. (5) Label the local deposition region as porous (class 0) if the average porosity rate is higher than 0.02%, otherwise, label the deposition region as dense (class 1). Implementing these steps on each layer, the spatial porosity rates of the whole part were calculated, and consequently, each local deposition was labeled. Figure 6c presents the calculated porosity distribution for the second layer, with the horizontal axis representing the printing time.
A combination of spectral features and ground-truth quality of a local region ( 1.2 × 1.2mm ) is regarded as one example used for the RF classifier training and testing. Consequently, 156 examples are obtained from each layer. To eliminate the effects of the substrate, data from the first layer was discarded. The spectra signals from the eighth layer were not saved due to operator error. Altogether, a dataset consisting of 1092 examples from seven layers (2nd, 3rd, 4th, 5th, 6th, 7th, and 9th layers) was created and used for porosity recognition. Since  Average raw spectra intensity

Results and analysis
Porosity recognition performance. Figure  . The F1-score for the prediction of these two layers is 82%. Table 4 presents the confusion matrix of the test result for these layers. (2) The recognition accuracies for the quality of the subsequent deposition layers decrease layer after layer. Furthermore, the recognition accuracies of the training layers and the layers close to the training layers have shown a lower standard deviation than the layers far behind the training layers. (3) The precision for recognizing the porous examples is higher than the precision for recognizing the dense examples, except for the last two layers. The decrease of the recognition performance for the subsequent layers is mainly caused by the variability in deposition thickness. In this study, the probe of the spectrometer is assembled on the optics head and focused on a specific plasma zone. The optics head as well as the probe rose a predetermined height after each printed layer under the assumption of a constant deposition thickness. However, since the over-and under-building are common occurrences in the DED process, the deposition layer may be slightly thinner or thicker than the preset layer thickness. In that case, the relative location between the probe and plasma will change. Then the probe would focus on a different zone of plasma which can cause a change of spectra intensity or even spectral profile 29 . Consequently, the change of spectra caused by the variability of deposition thickness induced errors for porosity recognition. Besides, the thickness deviation would increase the error of post-build porosity characterization. Thus, spectra data may be labeled incorrectly and this error accumulated with layers. These limitations are great  Visualization of the important spectral feature. The relative importance of the eighteen spectral features during the classification process was recorded by the RF classifier. This information can describe how closely spectral features are associated with the printing quality and help to reveal the fundamental physics of defects recognition. Table 5 lists the four most important features reported by the RF classifier. It can be seen that the intensities of Al (396.054 nm) and Fe (414.234 nm) emissions, the kurtosis of spectra in two wavelength ranges (508-518 nm and 484-490 nm) are mostly associated with the porosity defects. The distribution of the most important features (I 414.234 ) for the second deposition layer was compared with the porosity distribution getting from the CT scans in this layer, as shown in Fig. 8. The I 414.234 vector of this layer is reshaped to a matrix in sort of printing path in which each row of the matrix corresponding one printing line and mapped to a contour as shown in Fig. 8b. In the contour image the horizontal axis represents the printing line numbers, the vertical axis represents the distance from the lower deposition edge, and contour color represents the amplitudes of spectral feature I 414.234 . The binary CT images of this layer are overlaid together so that all pores produced in this deposition layer can be shown in one image as Fig. 8a. As can be seen, the second half of the deposition layer is more porous which corresponds to a higher I 414.234 . The first half part, by contrast, has a lower porosity rate which corresponds to lower I 414.234 . The spectral feature (I 414.234 ) increased markedly when pores are produced, especially the large pores. Therefore, the selected important spectral features match well with the porosity rate of the deposition. The significant increase of Fe spectral intensity indicates that more Fe elements were evaporated and excited in the plasma when pores present.   www.nature.com/scientificreports/ Figure 9 presents the specific spectra taken from areas with large pores (blue lines), without pores (black lines), and small concentrated pores (red lines), respectively. As shown, emission lines as well as the background continuum of spectra for depositions with pores are much stronger than those for fully dense depositions. Intense metal emission lines are observed in the spectra when pores are produced, especially for the spectra corresponding to the large pores. The large pore was randomly produced around dense areas and is believed to be randomly caused by abnormal conditions, for instance, unstable laser input or metal spatter. These abnormal conditions create an active environment in which more elemental emissions are excited. As shown in Fig. 9, small pores are mostly concentrated in the second half part of the deposition layer. That is because the temperature of the build surface kept increasing during the printing process of the aluminium alloy, which increased the unstable depression within the molten pool and in turn entrapped gas as pores. Moreover, another factor for the pore formation is the metal evaporation under the high-temperature conditions. It has been proved that the evaporation of alloy elements in materials influences the convection dynamics as well as the uptake of hydrogen in the melted alloy which results in the formation of pores 28 . On the other hand, the high temperature and increased evaporation of alloy elements contribute to the strong intensity of spectra. In summary, emission spectroscopy is an excellent in-situ monitoring technique for AM not only for academic research but also for commercial use. It is cheap and easy to access and can provide a large amount of fundamental information about the AM process. The multiple functions including composition recognition and defects detection make emission spectroscopy suitable for developing a cost-efficient monitoring system. Despite its obvious benefits, it is important to note the limitations of this technique. As can be shown in "Porosity recognition performance" section, spectra collection is highly sensitive to the relative position of the sensor, thus deposition thickness needs to be strictly controlled when using spectroscopy in the DED system. Furthermore, some kinds of material may not be easy to emit line emissions which result in a low signal-to-noise ratio of the spectra signals, especially when the system working under a low laser power.

Conclusions
This work investigated the application of combined artificial intelligence and plasma emission spectroscopy for in-situ porosity recognition of additive manufacturing. Spectra signals synchronously collected during DED for 7075-Al alloy were analyzed and correlated with the quality of deposition which is characterized by the 3D X-ray CT scans. An RF classifier was developed and trained by examples consisting of spectral features and groundtruth deposition qualities with a resolution of 1.2 × 1.2 mm in the XY plane. This classifier achieved a porosity recognition precision up to 83% for the examples from the training layers or their adjacent layers. However, with the printing layer going up the recognition precision decreased to a low level which is mainly caused by the variability of deposition thickness.
The importance values of eighteen spectral features for porosity recognition were recorded by the RF classifier. The comparison of the most important spectral feature (I 414.234 ) with the porosity distribution presents a good response to the random pores and concentrated small pores. Thermal accumulation and abnormal conditions increase the evaporation of element and the temperature of plasma which increase the porosity rate in the part as well as the intensity of spectra.
This work shows the potentials as well as the challenges of plasma emission spectroscopy applying on the in-situ quality monitoring of laser AM. It is significant for facilitating the online quality assurance and understanding the physical phenomena in the laser AM process. In future work, parts will need to be printed with strict deposition thickness control and used for further verification of the proposed method in this study. Deep learning classification models, such as long short-term memory models, may also be utilized to mine comprehensive and efficient information from spectra for defects recognition of AM.