Context awareness in process monitoring of additive manufacturing using a digital twin

Wire Arc Additive Manufacturing allows the cost-effective manufacturing of customized, large-scale metal parts. As the post-process quality assurance of large parts is costly and time-consuming, process monitoring is inevitable. In the present study, a context-aware monitoring solution was investigated by integrating machine, temporal, and spatial context in the data analysis. By analyzing the voltage patterns of each cycle in the oscillating cold metal transfer process with a deep neural network, temporal context was included. Spatial context awareness was enabled by building a digital twin of the manufactured part using an Octree as spatial indexing data structure. By means of the spatial context awareness, two quality metrics—the defect expansion and the local anomaly density—were introduced. The defect expansion was tracked in-process by assigning detected defects to the same defect cluster in case of spatial correlation. The local anomaly density was derived by defining a spherical region of interest which enabled the detection of aggregations of anomalies. By means of the context aware monitoring system, defects were detected in-process with a higher sensitivity as common defect detectors for welding applications, showing less false-positives and false-negatives. A quantitative evaluation of defect expansion and densities of various defect types such as pore nests was enabled.


Introduction
Wire Arc Additive Manufacturing (WAAM) allows the costeffective manufacturing of customized, large-scale metal parts and can be classified as Direct Energy Deposition (DED) method which is a subcategory of Additive Manufacturing (AM) [1,2]. The process is characterized by high deposition rates, low costs, and good mechanical properties of the parts [3]. It uses a solid metal wire as feedstock material and an electric arc as heat source to melt the wire. Potential application areas of parts manufactured by WAAM are aerospace, marine, railway, or healthcare [4,5]. However, the process still faces challenges in the industrialization [6,7]. Along the build-up procedure, defects such as delamination, oxidations, pores, geometrical deformations, or burn throughs can occur due to improper process parameters or process instabilities. These defects lower the part quality and can result in production scrap. Thus, quality assurance is indispensable for real-life application parts. As large parts can only be analyzed with high effort and high costs after the build-up procedure by non-destructive-testing methods such as X-ray or neutron diffraction, process monitoring is inevitable to industrialize the process [6,8]. Different research has been conducted to monitor the WAAM process by sensor data [9]. For instance, the quality of the welding can be analyzed by means of current or voltage data [10,11], and the arc intensity and stability can be monitored by means of acoustic emission data [12,13]. Several methods were proposed to fuse sensor data in WAAM. Reisch et al. presented a multivariate sensor system based on current, voltage, and vision to detect surface defects such as lack of fusion or form deviations [14]. Zhao et al. proposed a framework for defect detection based on spectrum and vision [15]. Xu et al. investigated the use of a diverse monitoring system in WAAM for monitoring and control [16]. Chen et al. provided a study on multisensory information fusion in welding processes [17].
State-of-the-art monitoring systems for WAAM focus on the detection of anomalies in time series data and videos and consult only recent sensor signals to evaluate the process [3,18]. However, when dealing with data such as temporal data, spatial data, or graph data, not only the individual data point but also its context is of great interest [19,20]. Besides the machine context, in AM, the spatial and temporal context is influencing the current deposition process substantially, resulting in spatiotemporal relations of the data instances. As Wang et al. mentioned, "some defects propagate from one layer to the subsequent layers," which cause the entire build to fail [21]. In Fig. 1, a selection of defects which propagate over several layers is shown.
For instance, oxidations in the previous layer can lead to lack of fusion and slag inclusion in the following layers due to a polluted surface, observable in (b) and (e) in Fig. 1. Form deviations, e.g., due to improper heat management [4] or an oxidation [14], can propagate and result in gaps or wavy structures over several layers as shown in (a), (c), (d) and (e) in Fig. 1.
To obtain information about propagating defects in-process, the spatial environment must be considered as context in the online quality evaluation by including historical data of previous tracks and layers in the data analysis. Additionally, the temporal context of each data instance reveals additional information for defect detection. This context can be gathered by a smart manufacturing system (SMS), which is a data-driven concept to improve manufacturing processes. Mittal et al. defined context as given, when the system is aware of its identity, location, status, and time [22]. Vater et al. mentioned the adaptability to a new context as key element of a SMS [23]. A potential application of context awareness in subtractive manufacturing is described by Lutz et al. who introduced a concept to classify material batches based on the material and cutting speed as given context [24]. In AM, research on context awareness is still sparse. In laser beam melting (LBM), concepts to integrate context in the process monitoring are introduced, for instance, by Majeed et al. who proposed a SMS for LBM. Their concept included modules for perception and acquisition, storage and preprocessing, data mining and decision-making, as well as additional services [25]. Evjemo et al. recently mentioned the great potential of SMS in WAAM due to the possible combination of the high customizability of AM parts and the flexibility of SMS [26]. Chong et al. suggest the use of SMS-based approaches for hybrid manufacturing by WAAM and machining [27]. A key challenge in SMS is the handling of big data which is characterized by volume, variety, and velocity according to Laney [28]. As central element of SMS, the digital twin (DT) allows the handling of big data and offers the chance to integrate context into a monitoring system [29,30]. A DT is the virtual representation of a physical object [30,31]. The main purposes of DTs are simulation, monitoring, and control for manufacturing assets and products [32]. For instance, by means of a DT, the problem of heterogeneous sensor signals and big data in monitoring applications of production systems can be solved [33]. In AM, DebRoy et al. suggested the use of DTs to minimize expensive trial and error tests, to decrease the time for product qualification, or to alleviate defects [34]. For the latter, continuous and dynamic changes in the physical space by means of DTs could be a suitable solution by enabling prescriptive analytic methods [35].
This study proposes and investigates context awareness in process monitoring applications for the WAAM process. Three kinds of context are integrated-namely machine context, temporal context, and spatial context-by using a DT as in-process digital representation of the physical WAAM part. The anomaly detection is realized by means of the machine and the temporal context. The tracking of the defect expansion and the local anomaly density as in-process quality metric is realized based on the awareness of all three kinds of context by means of the DT. The dimensions of the spatial region of interest (ROI) are investigated, and an inprocess visualization of the DT for the manufactured part is revealed. The methods are introduced for and validated on the WAAM process. However, the approach can be transferred to other AM process categories such as material extrusion. The study is structured as follows. The methods for context awareness as well as the materials and methods for the experimental validation are described in Sect. 2. Section 3 shows the visualization of the DT and the results of latency measurements for the DT, introduces the results of a parameter study regarding the dimensions of the ROI, and validates the context aware monitoring system on a WAAM part. In Sect. 4, the results and the transferability of the methods for context awareness to other AM process categories are discussed. Finally, Sect. 5 concludes the study and gives an outlook to future research.

Materials and methods
The context awareness was realized by including three kinds of context: First, based on the machine context, the monitoring system was triggered (Sect. 2.1). By analyzing the short-term temporal behavior of the time series signal of a voltage sensor, an anomaly detection was realized (Sect. 2.2). The annotated data instances were used to create a digital twin of the part in production which enabled spatial context awareness (Sect. 2.3).

Machine context
The machine context was provided by the machine control. Binary values indicated the start and stop of the overall manufacturing program (R20), the start and stop command (R21) for the WAAM process, as well as the real start and stop (R22) of the WAAM process. Additionally, an integer value represented the currently chosen process parameter set (R25). These parameters were defined in the machine code (e.g., ISO 6983 G code) which was followed step by step by the control. In the monitoring system, R20, R21, and R22 triggered the anomaly detection module as well as the creation of the DT. By means of R25, the anomaly detection model was changed according to the current process parameter set, and the thresholds for the anomaly detection were adapted accordingly. The machine context was stored in a key value store which gave access to all software modules.

Temporal context
The temporal context enabled the analysis of current data points of the voltage signal in the context of previous data instances. Hereby, not only point anomalies but also contextual and conditional anomalies in the voltage signals can be detected. For instance, contextual anomalies can be seen in case of a jumping arc in the WAAM process. Here, the voltage patterns (samples shown in Fig. 2 as input signals) show slightly changed characteristics which are only detectable if the temporal context is given.
The voltage signal was analyzed by an autoencoder with several hidden layers. In general, an autoencoder consists of an encoder f e x; e and a decoder f d (z; d ) as described in Eqs. (1) and (2). The encoder maps the input feature vector x into the code vector z in the latent space. The code is then reconstructed by means of the decoder, resulting in x.
The input feature vector x includes not only the current data point but also previous data instances to provide the temporal context. The anomaly detection was realized by thresholding the reconstruction error x − x . A higher reconstruction error indicated a higher probability of a defect. The architecture of the autoencoder in Fig. 2 was derived by a grid search based hyperparameter optimization (parameters: layers, code-size, window size, regularization by batch normalization and/or drop-out) using as starting point an architecture proposed by Tan et al. [36]. The objectives of the optimization were to decrease the reconstruction error for normal data and increase it for abnormal data. The resulting encoder architecture consisted of two stacked blocks. Every block included a convolutional layer with a kernel size of 3 and a max-pooling layer with a kernel size of 2 as well as regularization by means of batch normalization and a drop-out rate of 0.2. The code size was equal to 16. The decoder architecture mirrored the encoder structure, consisting of two stacked blocks with a convolutional layer, an upsampling layer, batch normalization, and dropout. Finally, a convolutional layer provided the reconstructed signal.
For each process type (Cold Metal Transfer-CMT, Pulse Mode-CMT P), a model was trained to increase the detection sensitivity. The autoencoder was trained and validated on a normal training and validation data set and tested both on a normal and an abnormal test data set (see normal sample input and reconstructed signals for CMT and CMT P in Fig. 2). The final models were trained in 20 epochs with a batch size of 1028, the mean-squarederror as loss function, and the Adam-optimizer [37] in TensorFlow 2.3.0. As input feature vector x , a window of 256 timestamps was used which corresponds to 1.5 CMT P cycles or two CMT cycles as shown by the sample signals in Fig. 2. In production, as soon as 32 new sensor values arrived, the window was shifted forward by 32 timestamps. In case of a new parameter set (changed R25), the corresponding model was chosen. To reduce the data load, the reconstruction errors were compressed by the Anomaly Criticality Score (ACS), which represented the maximum reconstruction error along path increments of 1 mm. The means, standard deviations, and maximums of the reconstruction errors for the normal test data set were saved as meta-data for each model to threshold the resulting ACS and detect the anomalies in-process. In this study different thresholds were regarded: • The 3-sigma threshold was calculated by summing up the mean value and three times the standard deviation of the reconstruction error in the test data set. • The maximum threshold was derived by extracting the maximum reconstruction error in the test data set. • The custom threshold was defined based on operator knowledge and quality requirements to detect only major defects.
All thresholds were adapted dynamically to the chosen parameter set by including the machine context (R25).

Spatial context
The annotated data instances were used to create the DT. The DT provided the spatial context based on the use-case specific spatial relevancy of the data instances. Two quality metrics based on the spatial context awareness are proposed. To track the expansion of defect clusters in-process, the weld bead was modeled as ROI. To introduce the local anomaly density as quality metric, a spherical context is regarded.

Digital twin
The DT corresponds to the in-process digital representation of the manufactured WAAM part. To create the DT, the annotated data instances of the anomaly detection were mapped to the position of the tool center point. The mapping was conducted using a spatial indexing data structure based on an Octree which enabled the efficient spatial analysis inprocess even in case of prints with long duration. Octrees are based on nodes which are recursively subdivided into octants if the number of node elements rises above a predefined threshold. Hereby, queries for specific positions can be handled efficiently [38], for instance, to check for points in the ROI around the tool center point (TCP). In case of a balanced search tree, the Octree data structure restricts the complexity of the spatial search to O(log(n)) instead of O(n). The size of the Octree was derived by analyzing the machine code of the part for the highest and lowest x-, y-, and z-values. For each path increment, an item with a spatial index based on the Cartesian position of the data point was added to the Octree. As payload, the ACS, the defect type, the defect identifier (ID), the position of the preceding data point, as well as the timestamp were stored as shown in Table 1. Items were only added when the manufacturing process took place according to the machine context. By means of the Octree-based DT, the spatial context awareness was enabled. Additionally, the DT was visualized in-process as shown in Fig. 3 to provide the machine operator and the process engineer with additional process information. The human-machine-interface allowed the interaction with the 3D geometry/point cloud and illustrated the current position of the TCP by a hexagonal pyramid. Detected anomalies were marked in red. The visualization was accessible in-process for the machine operator at the machine as well as remotely for the process planer and quality engineer over the cloud by an interface provided by an edge device cluster to enable a continuous quality assurance.

Defect correlation
The spatial relevancy for the defect correlation was defined based on the dimensions of the weld bead as affected zone during the welding process. These dimensions depend on the welding velocity, the substrate temperature, the heat input per unit length, and the material. In numerical simulations, the double-ellipsoidal heat source model by Goldak et al. [39] is commonly used to model the weld bead geometry. The double-ellipsoid consist of a front part (annotated with f) and a rear part (annotated with r), where radius a f and a r correspond to the ellipsoidal dimensions to the front and to the rear in the direction of welding, while b and c define the vertically and horizontally dimensions of the ellipsoid as shown in Fig. 4. The corresponding heat flux q f and q r are described in Eqs. (3) and (4), where Q w is the average heat input. f r and f f are the distributions of energy in the front and the rear. When q f and q r undershoot a material-dependent threshold, the weld bead solidifies.
These findings were used for spatial context modelling in the scope of spatial defect correlation. The enveloping body of a double-ellipsoid is characterized by Eq. (5) in quadric form where ⇀ x corresponds to the position vector, ⇀ x 0 is an offset vector for the center point of the double-ellipsoid, and A r,f is a positive definite matrix whose eigenvalues are the squared reciprocals of the ellipsoidal semi-axes a r,f , b and c and whose eigenvectors are the principal axes of the double-ellipsoid. As mentioned beforehand, the front part of the double-ellipsoid is characterized by the radius a f and the rear part by the radius a r .
(3)  A r,f can be written as a product of a diagonal matrix D which contains the squared reciprocals of the semi-axes and the orthogonal matrix Q as shown in Eqs. (6) and (7).
The columns of Q represent the principal axes of the double-ellipsoid. As the spatial orientation of the doubleellipsoid is altering depending on the welding direction, the principal axes were calculated by an intrinsic rotation of the identity matrix I based on the rotational matrices R x (∝) , R y ( ) , and R z ( ) (Eqs. 8 and 9).
Equation (10) proposes the analytical solution for the intrinsic rotated double-ellipsoid in a right-handed coordinate system by which the Octree was queried.
The angles and were calculated based on the latest path increment in the manufacturing operation. The angle ∝ is commonly equal to zero to avoid deformations of the weld bead due to gravitational force. In case of tilted parts, ∝ corresponds to the lead and tilt angles of the welding torch and the tiltturntable as shown in Fig. 4.
In AM processes with layer-wise deposition along the z-axis, is equal to zero as well. The simplified equation for this case is shown in Eq. (14), respectively, and in Eq. (15).
To evaluate whether the rear (a r ) or front (a f ) ellipsoidal equation had to be applied in the query of the Octree, an enveloping body, for instance, a sphere or a cube, was defined. For each point ⇀ x in this region, the corresponding distance vector to the working point ⇀ x 0 was calculated. By conducting the dot-product between the distance vector ( ⇀ x − ⇀ x 0 ) and the velocity vector ⇀ v , the relative position (front or rear) was derived as shown in Eq. (16). If the product was positive, the point was in the front and a f was applied. If the value was negative, the point was located in the rear and a r was used. In case of a value equal to zero, the position was indefinite as the distance vector was perpendicular to the velocity vector, resulting in the first term of Eq. (15) being equal to zero.
To define the values of the semi-axes a r, f , b, and c, the discretization of the data points in the Octree had to be considered. Information about defects were stored in the center of each welding track profile as shown in Fig. 5.
b and c were derived from the AM deposition strategy. The layer height h l was the minimum value of c, and the hatching distance d h was the minimum value of b in case of multitrack structures. h l and d h were hidden as meta-data in the machine code. To model the context of a weld bead in which only a part of the previous layer was remelted, b and c must fit Eqs. (17) and (18): When no filling structure and thus no hatching distance is present, for instance, in thin wall structures, b can be set Common dimensions (a f , a r , b, c) for doubleellipsoids in numerical simulations for GMAW and CMT welding applications with various materials were noted in Table 2. Additional information about weld bead dimensions for processes such as submerged arc welding or butt joint welding can be found in literature [40][41][42][43][44].
As WAAM is a multilayer and multitrack process, the temperature is changing along the build due to the heat input [47]. Additionally, the welding velocity as well as the wire feed rate might be adapted along the print, for instance, by a closed-loop-control. Thus, the dimensions a r , a f , b, and c of the weld bead are changing dynamically. To validate the values found in literature, ensure their transferability to the context use case in this paper and investigate the influence of the wire feed rate and the welding velocity on the weld bead, experiments on the dimensions a r and a f , as well as b and c of the doubleellipsoid were conducted which are described in Sect. 2.4. Due to the discretization in the Octree, the dimensions which were found in the empirical tests were enlarged by a factor of 1.2.
By querying the Octree with the resulting double-ellipsoid, information about relevant data instances in the surrounding was received. By linking a defect ID to every defect as noted in Table 1, a semantic correlation of near defects was conducted, resulting in the definition of defect clusters. If a new anomaly occurred, the immediate vicinity was checked for other defects and their IDs, and where appropriate, the IDs  were linked. Thus, the expansion of defect clusters in the part was tracked in-process and served as quality metric for the manufacturing process.

Local anomaly density
In addition to the semantic correlation of defects, an in-process quality metric based on the local anomaly density was defined. The local anomaly density was calculated in-process based on the averaged ACS in a sphere around the TCP. By applying the density function, the ACS got blurred in a spatial manner. Hereby spatial aggregations of minor defects such as arc instabilities were detected which were missed by the binary detector due to the thresholding. In certain areas, these aggregations can result in an insufficient part quality. Depending on the chosen radius, the included number of data instances cubes. Thus, an appropriate definition of the relevant context is needed. The effect of different spherical dimensions on the local anomaly density is shown in Sect. 3.

Validation
The proposed methods were validated on real parts. The experimental setup and the experimental process settings are described in the following.

Experimental setup
An experimental setup consisting of a robot-based WAAM equipment with tilt-turntable as well as a welding source by Fronius and a CNC control by Siemens was used as shown in [9]. To print complex parts, the control was based on G code which was retrieved from a Computer Aided Manufacturing (CAM) software where the process planning and a machine simulation were conducted beforehand. The G code was modified automatically according to the needs of the WAAM process and included triggers for the monitoring system (R20), welding commands (R21), and their corresponding handshakes (R22) as well as an identifier for the chosen process parameter set (R25). The process was monitored by a voltage sensor (P1000-S3 by HKS Prozesstechnik), a welding camera (C300 by Cavitar), and two temperature sensors (Almemo 2490-1L by Ahlborn). The machine data (R20, R21, R22, R25) as well as the voltage data and the positional data were synchronized and analyzed on an edge device. The relevant signals are detailed in Table 3.
The signal of the voltage sensor was used to conduct the anomaly detection of Sect. 2.2 in-process.

Parameter study
Three walls with 15 layers each were built on an AW6060 substrate plate with a 1.2-mm diameter AW5087 wire and a constant wire feed rate v w of 3 m/min, 4 m/min, and 5 m/ min. The welding parameter was chosen based on the characteristic line CMT876 of Fronius. The stick-out was fixed to 13 mm and the Argon gas flow was set to 8 l/min. In the first layers, the substrate was heated by two CMT P tracks with a wire feed rate of 5 m/min. In the following layers, the corresponding wire feed rate was chosen (3 m/min, 4 m/min, or 5 m/min) and six layers were deposited with CMT to realize a stable temperature distribution in the wall. Finally, the welding speed v r was adapted for each additional layer starting from 250 mm/min to 500 mm/ min. Along the deposition, the temperature was measured with Pt100 elements (Almemo 2490-1L by Ahlborn) at the substrate to ensure a stable temperature in the last layers of the part. Additionally, a welding camera (C300 by Cavitar) monitored the process with an angle of 30° from the side to measure the weld bead dimensions a r and a f as shown in Fig. 6. Cross-sections of the resulting walls were excised in the middle of the tracks, grinded, and etched with potassium hydroxide (KOH). a r a f Fig. 6 Image of the welding camera with marked areas for a r and a f

Validation experiment
The proposed methods for context awareness were validated for a thin wall structure represented by a curved pipe. The deposition strategy was based on a helix with a lead of h l = 2.3 mm. The first revolution of the helix was manufactured by a CMT P process with a wire feed rate of 4 m/ min to introduce additional heat into the substrate. For the rest of the helix, the CMT process was chosen with a fixed welding speed of v r = 350 mm/min and a wire feed rate of v w = 3 m/min. The G code was derived from a corresponding path planning in the CAD/CAM software NX1926 as shown in Fig. 7. Along the build process, three defect clusters were intentionally introduced. Defect cluster A showed the propagation of a material gap in the end of the first revolution over five revolutions in total. Defect cluster B was created by manually reducing the gas flow, resulting in an oxidation of the welding track and lack of fusion defects and gaps in the subsequent two revolutions. Defect cluster C was the result of an oxidation which was propagating by lack of fusion defects and material gaps in the next three revolutions. In the upper part, an instable arc was introduced by increasing the stick-out which resulted in instabilities in the argon inert gas atmosphere. The data set was gathered and analyzed inprocess on the edge device. Additional tests regarding the different spherical radii and thresholds were conducted in an offline simulation setup.
Based on the G code, the Octree dimensions were set to 88 mm * 88 mm * 88 mm. Every tool path increment of 1.0 mm, an item, and its payload were stored in the Octree. For the double-ellipsoid, b and c were set to 1.5 times the lead of the helix. a r and a f were defined based the findings in Sect. 4.2 and an enlargement factor of 1.2 to face the spatial discretization. To analyze the defect expansions, the three thresholds were applied, and the detected defects were tagged with corresponding defect IDs. Additionally, the local anomaly density was analyzed with spherical radii of 0 mm, 2.5 mm, 5 mm, 10 mm, 20 mm, and 40 mm.

Results
In the following, the results of the validation experiments are shown to validate the proposed methods for context awareness in WAAM.

Parameter study on the dimensions of the double-ellipsoid
The cross-sections of the resulting walls in the parameter study are shown in Fig. 8. The measured weld bead dimensions a f , a r , b, and c are visualized in the graphs of Fig. 9 for the different wire feed rates (3 m/min, blue; 4 m/min, green; 5 m/min, violet) and welding speeds.
The length of the weld bead (see Fig. 9a, b) decreased with increasing welding speed. In case of lower wire feed rates, the increased welding speed had a high impact on a r , namely, an increase of 73% with a doubled welding speed for a wire feed rate of 3 m/min. At the same time, a f changed With regard to the weld bead width (see Fig. 9c), which corresponds to the doubled ellipsoidal semiaxis b, an increasing welding speed resulted in decreasing values as the deposited volume per path increment decreased with a higher welding speed (change of up to 38%). The wire feed rate had a high impact on b, resulting in a change of up to 75% in case of an increased wire feed rate.
For the weld bead height c (see Fig. 9d), an increasing welding speed and decreasing wire feed rate resulted in a decreasing weld bead height. The impact of the increased welding speed could be quantified as a maximal difference of up to 91%. The reduced wire feed rate resulted in a maximum difference of up to 44%.

Anomaly detection
To detect anomalies, two autoencoder models were trained. Based on the machine context given by R25, the correct model was chosen according to the current process parameter set. Thus, a model for the CMT Pulse process was used in the first revolution of the helix and a model for the CMT process was chosen for the rest of the helix. In Fig. 10, the reconstruction error which was scaled by the maximum reconstruction error in the normal test data sets is shown. For reference, the ACS was compared to a rolling mean defect detector on the raw voltage data as it is commonly provided with welding setups, for instance, by Fronius. As stated by Fronius, the averaging is commonly conducted for a time range of 0.5 s [50], resulting in the averaging of 2000 time stamps for the standard rolling mean defect detector. Additionally, the averaging for a window size of 256 is shown to compare it to the size of the input feature vector of the autoencoder. The averaged values were scaled with the mean of the corresponding data. In red and orange, the described defects and their propagations are highlighted. Additionally, every 180° revolution is marked as vertical blue line corresponding to the local maximum or minimum in y direction to ease the spatial correlation of anomalies in the time domain.
In the first revolution, the use of the CMT P model resulted in a higher mean of the ACS in comparison to the CMT model. A considerably higher ACS is apparent, where the first revolution was finished. Here, a process parameter and a model change took place. Additionally, the sudden height deviation at the end of the first revolution resulted in a material gap which propagated in the following five revolutions (defect cluster A). This defect cluster was seen four times in peaks of the ACS. Additionally, form deviations due to humping effects in the first revolution resulted in peaks of the ACS in the second revolution. In the second half of the print, the For defect cluster B, the peaks in the ACS matched the real expansion of the defects in the next two revolutions. Defect C and its propagations were seen as ACS peaks in the following three revolutions. In the upper revolutions, the ACS revealed a high number of anomalies, matching the instabilities of the arc due to the increased stick-out.
Looking at the rolling means, an increased value is apparent at the end of the first revolution. In the following five revolutions, the defect propagation was seen two times in peaks of the rolling mean with a window size of 256. The rolling mean with a window size of 2000 time stamps showed only minor deviations. In the second half of the print, the defect clusters B and C resulted in increased values. Also, the form deviation in the subsequent revolutions was detectable. The instabilities in the upper revolutions were detected by both rolling mean detectors.

Spatial context Integration
The spatial context integration is evaluated based on latency measurements for the Octree, the results of the data-driven tracking of defect expansion along the build, as well as the results of the local anomaly density estimation.

Digital twin and latencies
To evaluate the Octree as spatial data structure for AM parts, latency measurements were conducted along the build for spheres with a radius of 5 mm as ROI. As the Octree level was defined for each item before the process started, every adding event required a similar amount of time (median 0.04 ms). The edge device was no hard-real-time system; thus, the latencies were spreading, resulting in a minimum latency of 0.02 ms and a maximum latency of 3.36 ms for adding an item to the Octree. The latencies of the Octree queries for a sphere with a radius of 5 mm is shown along the build of the helix in Fig. 11. For reference, the z-Position is visualized as well. The median latency for an Octree query was 1.80 ms, the minimum latency 0.19 ms and the maximum one 18.94 ms. The latency graph is dominated by seasonal patterns and an upward trend. For bigger spheres, the total query latency increased as the amount of queried Octree branches increased.

Defect correlation
In Fig. 12, the ACS is shown in logarithmic color scale along the toolpath. The areas where defects were introduced featured considerably higher ACS than the non-abnormal areas. In the areas above, an increased ACS was apparent as the defects were propagating. Additionally, an aggregation of higher ACS was seen in the upper area of the helix.
Defects were detected by thresholding the ACS. In Fig. 13, detected defects are visualized depending on the chosen thresholds:( a) 3-sigma rule; (b) maximum threshold; and (c) custom threshold). All thresholds were adapted dynamically to the CMT P and CMT process. Detected defects which were spatially correlated were colored in the same way. The expansion of each detected defect cluster was monitored along the printing process by means of the defect IDs. The dimensions of the double-ellipsoid were derived by the empirical tests in Sect. 4.1 and its orientation by the formulas stated in Sect. 2.3.
In total, 6669 items were stored in the Octree corresponding to a deposition path length of 6.7 m. Except for the items in the first revolution, every item obtained a neighborhood of nine to eleven relevant items out of whom four to five were part of the current revolution. In (a), 13.6% of the items were found anomalous and grouped in 309 defect clusters. While most defect clusters consisted of single instances, one defect cluster had an expansion of 66 instances and two clusters had expansions of 44 and 40 instances. The largest clusters fit to the forced oxidations and their propagations as well as to an area with no apparent defects. The smaller clusters could not be correlated to real defects. In (b), 2.0% of the instances surpassed the threshold, resulting in 40 defect clusters. Two defect clusters corresponded to cluster A and B with expansions of 40 instances respectively 39 instances. Smaller defect clusters were seen mainly in the upper part of the helix. In c), 1.0% of the instances were identified as abnormal. In total, three defect clusters were present. The largest ones consisted of 34 and 32 instances and matched the defect clusters B and C. Additionally, a defect cluster of four instances was found which matched the defect cluster A.

Local anomaly density
The local anomaly density is shown in Fig. 14  All values which surpassed a threshold defined by the 3-sigma rule on the corresponding density distribution were colored in white to increase the comprehensibility of the figure. Figure 14a is showing the reconstruction error as reference for the densities. As no spatial context was included, the spherical radius was equal to 0 mm, resulting in a maximal value of 10.9 and a minimal one of 0.4. In (b), four to five instances were included to calculate the density based on a spherical radius of 2.5 mm. Thus, the previous track was included, resulting in density values between 0.2 and 5.9 per instance (p.i.). In (c), the radius of 5 mm resulted on average in 16 relevant instances of three revolutions and density values between 0.4 and 4.9 p.i.. With a radius of 10 mm, on average 64 instances of five layers were included in the density calculation, resulting in values between 0.5 and 2.9 p.i. as shown in d). In (e), a sphere radius of 20 mm was used, resulting in about 247 relevant instances on average, a minimal density of 0.6 p.i. and a maximal density of

Discussion
In the following, the results of the validation experiments and the transferability of the proposed methods for context awareness to other AM technologies is discussed.

Parameter study on the dimensions of the double-ellipsoid
The weld bead geometry is heavily affected by the deposited volume and by the heat input per path increment which is dependent on the welding speed and the wire feed rate. A higher wire feed rate corresponds to a higher deposition volume as well as to a higher heat input Q due to a higher current and voltage as defined by the characteristic line for the welding parameter. Thus, an increasing wire feed rate results in an increasing weld a) b) c) bead length, height, and width. The highest impact of a changed wire feed rate is seen on the rear weld bead length. Besides, a changed wire feed rate affects particularly the width of the weld bead. A higher welding speed results in a lower deposition volume per path increment and thus in a decreasing height and width of the weld bead. The length of the weld bead is also decreasing as the average heat input per path increment is reduced and the weld bead solidifies faster. A higher impact is seen on the length of the rear part of the weld bead, while the length of the front part is less impacted by the welding speed. The value range for a, b, and c which was found in the experiments corresponds to the magnitude which was seen in the literature for the CMT process in Table 2. On top, the results highlight the importance of including the impacts of welding speed and wire feed rate on the dimensions of the double-ellipsoid in the contextual analysis. By using the proposed monitoring system with additional contextual information (welding speed, wire feed rate), the findings serve as parameter table for the inprocess calculation of the double-ellipsoid for the defect correlation shown in Sect. 4.3. However, an enlargement factor must be applied due to the spatial discretization in the Octree. The dimensional data of the experiments are only valid for AW5087 as material properties such as the thermal conductivity and the melting point affect these dimensions. Additionally, the temperature has a high impact on a, b, and c. To deal with these thermal and material dependencies, an in-process monitoring approach could analyze the current track width and length. Therefore, a welding camera could be mounted at the robot flanch to follow the track continuously and evaluate the weld bead geometries.

Anomaly detection
The machine context enabled the process parameter specific data analysis and reduced the total amount of monitoring data significantly. The results of the anomaly detection by the autoencoder matched the defect clusters in the real part. The oxidations, lack of fusions and material gaps in the part corresponded to peaks in the ACS and thus were detected correctly. As shown in Fig. 15c, unexpected peaks in the reconstruction error and thus in the ACS appeared due to abnormal voltage signal patterns which are an indicator for an unstable deposition process. In comparison to the rolling mean with a window size of 2000 time stamps, the ACS showed a higher sensitivity for short-term defects for instance in defect cluster A due to the analysis of the temporal context in the data patterns. The rolling mean with a window size of 2000 time stamps deflected in case of oxidations, lack of fusions, and form deviations. However, short-term defects were not detected due to the long-term averaging. The use of a rolling-mean with a window size of 256 increased the sensitivity and partly enabled the detection of short-term defects, for instance, in defect cluster A or in Fig. 15c. Also, the oxidations, lack of fusions, and form deviations were apparent in the means. However, when looking at the peaks in detail, which were unexpected or only generated by one of the methods, the rolling mean with a window size of 256 revealed certain disadvantages. As shown in Fig. 15b, the material gap of cluster A in the 5th revolution of the helix resulted in a peak in the reconstruction error due to the instable voltage signal. In the rolling mean, a deviation was not apparent, leading to a false-negative. In Fig. 15a, a drop in the rolling mean was investigated which was caused by a faulty sensor signal. This faulty sensor signal was seen several times in the data set and was created due to errors in the high frequency data transmission which resulted in missing values in the voltage signal. In case of a missing peak value, it heavily influenced the rolling mean, resulting in a false positive. As the autoencoder had already seen similar patterns in the training data, the pattern was reconstructed sufficiently, resulting a) b) c) Fig. 15 Detail view on certain peaks of Fig. 10 in a small deviation of the reconstruction error. The window size of 256 timestamps resulted in a high volatility of the rolling mean. An increasing window size reduced the volatility but decreased the sensitivity. The voltage instabilities in the later phase of the build were detected by all methods and corresponded to an increased stick-out, which caused a less stable inert gas atmosphere and thus arc instabilities. However, cross-sections at the corresponding areas in the part and a CT scan did not reveal any indicators for major defects. As the different means of the reconstruction errors of the two autoencoders have shown, a calibration of the ACS must be conducted to avoid a high false-positive or false-negative rate. Additionally, a more robust ACS could be obtained by introducing a multivariate anomaly detection framework as stated in previous work [14].

Spatial context integration
By means of the DT, context awareness was realized, and two quality metrics based on the surrounding context were introduced.

Latencies
The graph of the latencies is dominated by seasonal patterns and an upward trend. The trend is caused by the increasing number of items in the Octree. The seasonal patterns are caused by the local granularity of the Octree (affected Octree branches) and the parts geometry. For instances, the transitions along the z-direction between the blocks of Octree level 2 (red vs. blue vs. green colored areas) and Octree level 3 (lighter vs. shaded areas of each color) in Fig. 11 resulted in changed patterns in the query latencies. Additionally, seasonal patterns in terms of local minima and maxima in the latencies were created in every revolution due the different Octree nodes which were passed. For the chosen spatial compression rate of one Octree item per millimeter of the toolpath, the performance of the Octree (median 1.80 ms, minimum 0.19 ms, maximum 18.94 ms) was sufficient. In case of the chosen welding speed of 350 mm/min, a new item was added every 171 ms. However, with increasing number of items in the Octree and larger spatial context, the query performance of the Octree decreased. Thus, further performance tests must be conducted on large-scale parts. In case of a bigger spherical radius, the query time increased. To increase the performance, the information compression could be increased, and the data structure could be further optimized. For instance, many AM parts are not perfectly balanced, thus an Octree query is not as efficient as in the optimal case. To increase the search efficiency in case of unbalanced data, anisometric or semi-isometric Octrees [51] or alternative spatial indexing data structures [52] could be investigated.

Defect correlation
The defect cluster expansion was tracked based on the IDs in the spatial context of each data instance. The average number of relevant instances fits to the theoretical presumptions. Due to the spatial discretization of the data instances in the Octree based DT, the dimensions of the double-ellipsoid must be larger than the weld bead dimensions to correlate defects. In case of spatial correlation, data instances received the same ID. In certain cases, several IDs were present in the same spatial context. To correlate the correct defect, further research must be conducted on how different defects are caused by each other as spatial correlation does not imply causality.
The comparison of the different thresholds highlights the importance of setting a consistent threshold value. The threshold based on the three-sigma rule on non-abnormal test data resulted in a high number of potential defects which cannot be seen in the appearance of the manufactured part. Most of the detected anomalies correspond to deviations in the voltage data but did not result in major defects. The threshold based on the maximum reconstruction error in the test data resulted in less identified defects. By means of the custom threshold, the amount of defect clusters was reduced to three which corresponded to the defect clusters A, B, and C. These defect clusters represent defects with a high impact on the parts quality. However, other anomalous areas in the part are neglected. In general, a lower threshold enables a more sensitive detector, resulting in a higher number of false positives; a higher threshold leads to higher number of false negatives. An additional quality metric with focus on aggregations of minor anomalies as shown by the local anomaly density is useful at this place. For all thresholds, the expansion of the defect clusters was derived by means of the defect identifiers. The biggest clusters matched the real expansions of the defect clusters A, B, and C. In case of a lower threshold, the number of defect clusters and the maximum defect expansion increased. In case of a higher threshold, the defect clusters became less and smaller. For all thresholds, the data instances of the three defect clusters were correlated and their expansion had been derived inprocess based on the position and voltage data. Thus, the proposed method for spatial correlation of defects by means of the DT has shown reasonable results. The expansion of the defect clusters can be used as an additional quality metric which is deduced in-process.

Local anomaly density
The local anomaly density serves as quantitative in-process quality metric for anomaly aggregations and allows an objective evaluation of the parts quality for instance in case of pore nests. The included number of data instances increased with the power of three with increasing radius. As seen in Fig. 14, with increasing radius, the value range of the local anomaly density is reduced, and less extreme values are present. If the radius is large in comparison to the parts size, the averaging cannot serve as quality metric for the local structures. If the context is too small, the defect density does not offer any additional information in comparison to the ACS as no anomaly aggregations are detected. To determine the appropriate radius, the dimensions of the part and the layer height are of interest. A parameter study on the spherical radii was seen in Fig. 14 for the validation part. The density which was derived with a spherical radius of 0 mm resembles the image for the ACS in Fig. 12. The ACS is a special case of the local anomaly density where only the last path increment and its maximum reconstruction error is considered. In theory, a radius of 2.5 mm includes the previous revolution of the helix as the helical lead is 2.3 mm. However, due to the discretized form of the data, this context is not comprised at every location. For that reason, the density heatmap shows abrupt gradients which indicate an undersized radius. In the heatmaps for radii of 5 mm and 10 mm, no abrupt gradients are present. However, the differences of the densities in the local structures are well distinguishable. Especially, in the upper area of the part, a higher density of anomalies in the voltage data can be seen. This corresponds to minor instabilities in the inert gas atmosphere caused by the increased stick-out in this area. In case of radii of 20 mm and 40 mm, the chosen context is excessive as the spatial averaging results in indistinguishable densities in the local structures of the part. No additional information was derived by the local anomaly density in this case in comparison to the ACS data. Thus, for the validation part, a sphere with a radius of 5 mm to 10 mm is providing the most informative results, correlating to an included context of two to four revolutions.
As the local anomaly density is calculated along the build in-process, no knowledge about future defects is available. To obtain a final density heatmap of the part, a recalculation at the end of the manufacturing process is needed. If the density value is used as trigger for a process stop, the chosen threshold must fit to the quality requirements. To investigate the local anomaly density for specific defect types (see Table 1) such as pores, future research could focus on robust defect classification.

Transferability
AM processes can be grouped in seven categories according to ISO/ASTM52900:2015 [2]. In the following, the transferability of the previously proposed methods for context awareness is evaluated for these categories in a qualitative manner based on the authors' experiences with other layer-and multi-axes-based AM processes. The integration of machine context is transferable to all AM processes with voxel wise deposition. If the process occurs layer upon layer, the sequence of process states must be adapted. The proposed method for temporal context awareness is based on the analysis of patterns in the time series data. For each process and parameter set, the deep neural network must be retrained. In case of less complex patterns in the data, the temporal context can be realized by defining process limits, for instance, for the laser power or the temperature of the melt pool. Spatial context awareness and its applications (defect correlation and defect cluster expansion tracking, local anomaly density as quality metric, …) can be transferred to all AM process as material is deposited layer upon layer or voxel-wise on previously deposited material. For processes with multi-axes capability such as DED and material extrusion, the Octree matches the needs for a complete representation of the part as all items on the surface of the part can belong to future ROIs. In case of powder-bed-based processes such as LBM, the manufacturing is conducted layer upon layer. Thus, only the current and a limited number of previous layers are needed to analyze future ROIs. Less complex 2D data structures for each layer such as Quadtrees might be sufficient and could decrease data processing latencies. The data pooling for the whole part could then be conducted batchwise Quadtree upon Quadtree respectively layer upon layer. The defect correlation by means of a doubleellipsoid is linked to melt-pool-based process such as DED or LBM. The local anomaly density metric could be transferred to all categories.

Conclusion
In the present work, an approach for context awareness in WAAM monitoring applications by means of a DT was proposed and investigated. Three kinds of context namely machine context, temporal context and spatial context were integrated to enable advanced in-process quality monitoring. The following conclusions were drawn: -Machine context helps to reduce the total amount of monitoring data and enables parameter specific data analysis. -The inclusion of temporal context increases the sensitivity of the anomaly detector. Autoencoders reveal a higher sensitivity than rolling mean detectors regarding the defect detection in WAAM based on voltage data as they rely on the CMT patterns. Systematically faulty sensor signals can be interpreted as normal by autoencoders, resulting in the avoidance of false positives. -Spatial context awareness enables the usage of advanced monitoring methods. The Octree as spatial indexing data structure reveals a high applicability to create an in-process DT for spatial context awareness. The expansion of defects can be tracked data-driven by means of a ROI based on a double-ellipsoid whose orientation is following the welding direction. The local anomaly density based on a spherical context enables the detection of aggregations of minor anomalies such as pore nests and serves as in-process quantitative quality metric.
Future research will focus on predictive and prescriptive analytics based on the DT to reduce production scrap by compensating detected defects autonomously and to increase the detection capability and robustness of the anomaly detector. Hereby, a bidirectional connection between the DT and the WAAM process will be established.