1 Introduction

Direct metal deposition (DMD) is one of the prominent additive manufacturing (AM) methods, which involves melting metallic particles selectively utilizing a laser beam. This particular technique is independent of a powder bed, in contrast to the majority of other methods. Instead, it employs a feed nozzle mechanism to project the powder material into the path of the laser beam. This process is sequential in that the laser’s thermal energy is applied to each layer after it is created on top of the previous one. Temperature gradients and quick solidification are important properties that must be controlled, but high cooling rate, severe gradients, and uneven shrinkage can cause large thermal residual stress and deformation, particularly in thin powder layers. Similar problems may occur in other laser-based AM processes such as selective laser melting, but DMD process presents special potential and difficulties that demand further study due to its unique characteristics. Controlling temperature, residual stress and distortion properly and developing predictive models are essential challenges that guarantee the effectiveness of DMD production operations [1,2,3,4,5].

In the DMD process, the energy of the laser plays a crucial role in accelerating the melting of the powder layer. This is achieved by heating the spot of the laser beam and causing thermal expansion in that particular spot. Following this, when the beam spot undergoes a transition to another spot, the region that was previously heated initiates a process of cooling and contraction. The occurrence of cooling and contraction might result in the generation of residual stress in the surface area as a consequence of the tightening effect exerted by the constricted region inside the deposited material. Furthermore, the repetitive process of depositing layers one by one might result in an accumulation of compressive stress within the interior of the manufactured component. These stresses can cause the part to deform or warp, affecting its dimensional accuracy and structural integrity [6, 7]. In order to predict and effectively control the behavior of the manufactured parts and enable the fabrication of high-quality parts with lower residual stress, it is critical to have a thorough understanding of melting pool temperature in distinct layers and their distortion [8,9,10,11].

Mianji et al. [12] conducted the research to find dependencies between the number of deposited layers, the radius of curvature, and the distribution of thermal fields, providing insights into strategies for stabilizing wall thickness and reducing surface roughness through modulation of laser power through numerical simulations and analysis of SS 316L samples in DMD process. Also, Mirkoohi et al. [7] studied analytical model of residual stress in DMD process by considering the temperature history from layers and scans strategy. Comparative analysis with X-ray diffraction measurements of IN718 specimens demonstrates the model’s accuracy in predicting residual stresses.

According to a study conducted by Vrancken [13], it has been shown that increasing the heat input during the selective laser melting (SLM) procedure for Ti6Al4V alloys has the potential to reduce macroscopic residual stresses. Increased heat input may be attained by implementing several strategies, including the utilization of smaller layer thicknesses, lower scan speed, higher laser powers, and preheating the base plate. Furthermore, the temperature gradient mechanism and cooling phase mode were introduced by Mercelis and Kruth [14] in order to examine residual stress at the macroscopic level. Similarly, Gusarov et al. [15] employed a combination of numerical and experimental methodologies to investigate residual stress in materials subjected to single-track laser scanning. Their study highlighted the notable influence of temperature differentials on the development of residual stress. The bending angle of thin plates along the y-axis in laser forming processes was investigated by Shi et al. [16], who incorporated heat transport and elastoplastic mechanics into their study. Furthermore, previous studies have observed that the utilization of unidirectional scanning strategies in additive manufacturing can result in significant residual stresses along the build direction as a consequence of varying cooling rates. Consequently, it becomes essential to investigate alternative scanning methods in order to alleviate these stresses and improve the mechanical properties of the material [7, 13, 17].

The DMD technique is characterized by a complex microstructure that has a direct connection to its distinct thermal behavior and residual stress dynamics. Nevertheless, the challenge of measuring or tracking the thermal characteristics and distortion throughout the process of depositing multiple layers in DMD presents difficulties because of the concentrated heating and rapid melting/solidification. Conducting experiments individually to establish an internal relationship between heat processes and microstructure properties is a challenging task. A computer simulation using metal thermomechanical theory and finite element (FE) analysis can be invaluable for predicting material behavior and optimizing process parameters for quality and accuracy in DMD [18, 19]. So, the FE methodology has become a preferred approach for investigating temporary heat phenomena and predicting deformation and melting/solidification mechanisms [20,21,22].

Although there have been many studies on the thermal dynamics of single-layer DMD process, with a specific focus on the distribution of temperature, characteristics of fluid flow, and migration of particles within the molten pool, there has been limited research on the thermal behavior and distortion during manufacturing in multi-layer DMD processes. However, despite this distinction, artificial neural network (ANN) models have been developed as an effective tool for the processing of information, development of knowledge, and resolution of problems. The utilization of the ANN models has the potential to improve manufacturing processes, leading to enhanced efficiency, reduced mistakes, and improved quality in digital fabrication initiatives [23,24,25,26].

The present study utilized a FE model to understanding the thermal behavior of various layers and the distortion during multi-layer DMD process of SS 304. Incorporation of thermomechanical variables was carried out to ensure accurate simulations. The validation process involved comparing the simulation results with data released in previous studies. The results demonstrated improved precision in comparison to previous studies through the utilization of various heat input source and heat transfer equations. Furthermore, a data-driven system was employed to train an ANN to predict the temperature and distortion in a multilayer DMD process based on critical parameters including laser power and scanning speed accurately. Multiple FE simulation iterations implement with different laser parameters as inputs for the data-driven system. This approach facilitated prediction of the correlation among manufacturing parameters, temperature, and distortion. The data-driven procedure proceeded until the difference between the predictions generated by the ANN and the following FE simulation results reached the desired threshold. The results showed the trained ANN accurately and promptly predicted the temperature and distortion in this process.

2 Thermal analysis

The Fourier heat conduction equation describes the changes in temperature through time and space in a medium. It is highly significant in the field of heat transfer because it helps to understand how heat is transferred over time between different materials. It also assists to quantify the relationship between changes in temperature, the properties of the material, and the distribution of thermal energy within the medium. Essentially, Equation (1) provides significant functions for the examination and prediction of heat distribution and propagation within various physical systems [27, 28].

$$\lambda\ \left(\ \frac{\partial^2T}{\partial {x}^2}+\frac{\partial^2T}{\partial {y}^2}+\frac{\partial^2T}{\partial {z}^2}\right)+Q=\rho \left(\textrm{T}\right)C(T)\ \frac{\partial T}{\partial t}$$
(1)

where λ is the isotropic thermal conductivity coefficient, T is the temperature, Q is the input heat, ρ(T) is the density, C(T) is the heat capacity coefficient. The DMD method incorporates conduction, convection, and radiation as the three heat transfer mechanisms in its thermal equilibrium equation [29].

$$\lambda\ \frac{\partial T}{\partial n}+h\ \left(T-{T}_0\right)+\sigma \varepsilon\ \left({T}^4-{T_0}^4\right)-Q=0$$
(2)

where ε is the thermal radiation coefficient, h is the convection heat transfer coefficient, T0 is the ambient temperature, and σ is the Stefan–Boltzmann constant (5.67 *10−8 W/m2 K4). Moreover, the laser beam is simulated by using a volume heat flux that is uniformly distributed. The authors [30] have suggested using an optical penetration depth (OPD)-controlled homogenous energy distribution for input heat energy:

$$Q=\frac{\alpha P}{\pi {R}^2\beta S}$$
(3)

where P is the laser power, R is the beam radius, β is the correction factor for the predicted optical power density, S is the OPD, and α is the material’s laser absorptivity. In this study, the OPD is set equal to layer thickness (0.5 mm), and the correction factor is determined at 0.7. To achieve an accurate thermal field solution, one must take into account the immense effect that the thermocapillary phenomenon’s Marangoni flow has on the temperature distribution [31]. In order to account for the Marangoni effect, artificial thermal conductivity was employed, following the methodology put forth by Lampa et al. [27]:

$${K}_m(T)=\left\{\begin{array}{l}k(T)\ T\le {T}_{liq}\\ {}2.5\ast k(T)\ T>{T}_{liq}\end{array}\right.$$
(4)

where Km(T) is the modified thermal conductivity and Tliq is the liquidus temperature.

3 Mechanical analysis

The total strain εij can be represented generally as:

$${\varepsilon}_{ij}={\varepsilon_{ij}}^E+{\varepsilon_{ij}}^P+{\varepsilon_{ij}}^T$$
(5)

where the plastic strain is represented by εijP, the elastic strain by εijE, and εijT is the thermal strain.

Isotropic Hooke’s law governs the elastic stress-strain relationship in the following methods:

$${\sigma}_{ij}={C_{ij kl}{\varepsilon}_{ij}}^E\ \left(i,j,k,l=1,2,3\right)$$
(6)

where Cijkl is the elastic stiffness tensor. For isotropic elastic solids, elastic strain εijE can be calculating by:

$${\varepsilon_{ij}}^E=\frac{1+\vartheta }{E}\ {\sigma}_{ij}-\frac{\vartheta }{E}{\sigma}_{ij}\ {\delta}_{ij}$$
(7)

The constitutive equation for thermal expansion can be utilized for calculating thermal strain εijT:

$${\varepsilon_{ij}}^T=\alpha \Delta T{\delta}_{ij}$$
(8)

where α is the thermal expansion coefficient, and ∆T is the temperature difference between two different material points. The Prandtl-Reuss equation [32] governs the plastic strain-stress relationship for isotropic material:

$$d{\varepsilon_{ij}}^P=\lambda {s}_{ij}$$
(9)

where λ is the plastic multiplier and sij is the deviatoric stress tensor defined by:

$${s}_{ij}={\sigma}_{ij}-\frac{1}{3}{\sigma}_{kk}\ {\delta}_{ij}$$
(10)

The overall strain rate can be defined as follows [33] by replacing Equations (6)–(10) in Equation (5) and taking the derivative with respect to time:

$${\dot{\varepsilon}}_{ij}=\frac{1+\vartheta }{E}\ {\dot{\sigma}}_{ij}-\frac{\vartheta }{E}{\dot{\sigma}}_{ij}\ {\delta}_{ij}+\alpha \dot{T}{\delta}_{ij}+\lambda \left({\sigma}_{ij}-\frac{1}{3}{\sigma}_{kk}\ {\delta}_{ij}\right)$$
(11)

4 Thermo-mechanical properties of SS 304

Previous studies have performed and validated the numerical simulation attempted to obtain near experimental results by considering the material’s thermo-elastoplastic behavior [7, 28]. These studies utilized some of the temperature-dependent properties specific to stainless steels 304. This study took into account critical parameters including liquidus temperature, solidus temperature, and latent heat fusion as shown in Table 1. The temperature-dependent values for Thermo-mechanical behavior are shown in Figs. 1, 2, 3.

Table 1 Latent heat of fusion for stainless steel 304 [34]
Fig. 1
figure 1

Temperature dependent thermal properties of SS 304 [28, 35, 36]

Fig. 2
figure 2

Temperature-dependent thermal expansion coefficient, Poisson’s ratio, Youngs modulus of SS 304 [35, 36]

Fig. 3
figure 3

Temperature-dependent plastic stress/strain variation of SS 304 [35, 36]

5 Finite element model (FEM)

Figure 4 illustrates the DMD process, where laser thermal energy is deposited into a control volume. This energy is absorbed by the material, leading to thermodynamic heat. It then conducts through solid and liquid boundaries and is convected and radiated through open surfaces. For FE simulation, a multi-layer DMD process has been developed using the commercial software ABAQUS [37]. An uncoupled thermal-mechanical simulation was performed to analyze the process which the results of the initial thermal study were utilized as inputs for the mechanical analysis and each pass middle node temperature was considered for investigation and simulation. The element birth and death technique [6] was used to represent the incremental deposition of powder layers during the additive manufacturing process. This procedure comprises deactivating all of the powder particles at first, then activating some parts of each layer only thereafter. Heat flux is applied to the chosen nodes, and additional calculations are made to determine the temperature and other material properties. The volumetric heat input source implemented by DFLUX user subroutine. The scanning zone measures 7.5 × 2.5 × 1.5 mm3, whereas the substrate is 12.7 × 50.8 × 3.175 mm3 in the model. Also, the temperature considered is that of the middle node of each pass, as extracted from the referenced study.

Fig. 4
figure 4

Schematic diagram of the DMD process

In mechanical analysis, the substrate’s one-sided fixation served as the only boundary condition used to limit rigid body motion. Furthermore, the thickness of each powder layer is 0.50 mm. The powder bed region was finely meshed into brick pieces to improve both accuracy and computational efficiency. On the other hand, the substrate was more coarsely meshed in the distance of the scanning zone and finer meshed close to it. For the whole domain for thermal analysis, first-order 3-D heat transfer elements (C3D8) were employed, taking into account stability as well as computing time and accuracy. Furthermore, in order to shorten computing times, first-order components were employed in other areas of mechanical analysis it also avoids shear and volumetric locking [37]. Consequently, the domain was represented by C3D8R elements. The main processing parameters that were used in the model’s creation are listed in Table 2.

Table 2 FE analysis parameters

6 Artificial neural network (ANN)

In machine learning, the Levenberg-Marquardt methodology is a commonly used method for training ANNs [38]. The output layer and the hidden layer constitute the ANN. In this research, the hyperbolic tangent activation functions are employed to stimulate the neurons in the hidden layers, whereas linear activation functions are used to activate the neurons in the output layer. The result of a specific neuron, r, can be defined as follows:

$$r={f}_r\left(\sum_{j=1}^n{w}_j{z}_j+b\right)$$
(12)

where fr the activation function applied to the weighted sum of inputs to produce the output, wj are weights, zj are inputs, and b is the bias.

To determine the best possible data distribution, the dataset is divided into three separate subsets: the test, validation, and training sets. The validation set is used to adjust the hyperparameters and reduce the possibility of overfitting, whereas the training set is used to train the ANN. Finally, the trained model’s final performance is evaluated using the test set. The distribution of data inside each set must precisely represent the distribution of data throughout the dataset. Typically, 70% of the samples are used for training, 15% are set aside for validation, and the remaining 15% are used for testing. Different optimization strategies are used to determine the best combination of hyperparameters and ANN design that yields the best performance on the test dataset. Using the provided dataset, the goal is to anticipate the multilayer temperatures and greatest distortion. The model is able to accurately and successfully anticipate the desired outcomes by adjusting the ANN’s design and hyperparameters.

The ANN was trained, and its performance was enhanced by using the MATLAB programming tools [39]. The two multilayer networks that were used in this work are shown in Fig. 5, where process parameters including laser power and scanning speed are the ANN’s input data. The temperatures in different layers and amount of distortion were chosen as the output variables of these two ANN. Noteworthy, the MATLAB algorithm created for this purpose systematically investigates network designs of between 8 and 12 neurons in 3 hidden layers. In order to guarantee different outcomes for every training iteration, the data for validation, testing and training were further divided at random. The code was rebuilt for training data to increase performance, which led to better outcomes. The trained ANN’s final configuration was chosen to predict the distinct layer temperature and distortion in the produced dataset.

Fig. 5
figure 5

Two designed five-layer ANNs

7 Data-driven system

The preliminary simulation outcomes were employed for the purpose of training an ANN and elucidating the relationships between input and output variables. In order to substantiate these findings, a set of random input data was utilized to the FE simulations and their results feed to ANN, and subsequently, the predictions of random parameters made by the trained ANN were compared to the results obtained from simulating these parameters. If the ANNs predictions were consistent with the simulation results, it indicated that the network had effectively identified the fundamental connections, leading the program to reach a conclusion. Nevertheless, in instances of discrepancies, the procedure was repeated until the intended outcomes were attained. The iterative nature of this approach guaranteed that the network consistently improved its comprehension, ultimately leading to accurate predictions of the complex associations between inputs and outcomes. To assess the accuracy of the layer’s temperature and distortion, a criterion was established, considering a tolerance of error lower than 1% difference for each parameter. The proposed method’s flowchart is presented in Fig. 6, demonstrating the iterative process aimed at refining the accuracy of the model.

Fig. 6
figure 6

Flowchart of proposed data-driven method

8 Results and discussion

In this study, the FEM model was employed to determine the melting pool temperature and distortion in DMD process of SS 304L. The results, represented in Fig. 7, showcase contour plots illustrating the temperature field in the middle of process and amount of distortion at the end of process. The examined process parameters encompassed scanning speed and laser power. The FE simulation employed the suggested volumetric heat input source technique and considering conduction, convection and radiation heat transfer equations, which provided superior results compared to the prior research [7, 28] that utilized a surface heat input source in FE simulation and combining convective and radiative heat transfer formula. The main reason contributing to the improved outcomes of the FE simulation by the volumetric heat input is that it considers all volume of powder projected from a feed nozzle exposed to laser beam and heat source (Table 3).

Fig. 7
figure 7

Thermal and mechanical investigation during DMD process

Table 3 Comparative analysis of deflection FE simulation and Experimental results by the prior research

After the validation of the FE simulation results, more simulations were conducted for different laser settings. These simulations were then utilized in a data-driven system to identify ANNs capable of properly predicting the temperature and distortion of multilayers. This study involved doing ten initial runs for ANN training, followed by seven further runs until the desired ANN, which met our objective, was obtained. The examination of the optimum results was conducted by utilizing significant statistics, such as the R-squared correlation (R2). The performance characteristics for the final output parameters, including changes in layer temperature and distortion, are illustrated in Figs. 8 and 9. The data demonstrates that the ANN accurately predicted the connections between input and output parameters, as indicated by the comparison between ANN outputs and FEM simulation outcomes. The regression analysis revealed R2 values more than 0.99 for both parameter sets, showing a precise relationship between the FEM results and the ANN model.

Fig. 8
figure 8

The R2 performance for prediction mechanical distortion during the DMD process

Fig. 9
figure 9

The R2 performance for prediction different layer temperature during the DMD process

To ensure the accuracy of the proposed method, the trained ANN and FEM results were compared for random input parameters. A desired threshold of 1% difference was set for each parameter, and errors were checked accordingly. An additional run was conducted to further validate the effectiveness of the trained ANN approach in predicting the temperature and distortion of distinct layers during the DMD process. This verification step significantly improves the reliability of the proposed approach. Table 4 presents the trained ANN and FEM results for two random input parameters, along with the percentage difference between the results. As shown in Table 4, errors were observed below 1% in each parameter and case. Furthermore, the results showed that while the FEM simulation requires approximately 36 h for each run, the trained ANNs employed in this study were able to predict the different layers temperature and distortion in less than a minute.

Table 4 Two FEM simulation for validation of trained ANN

9 Conclusion

This study represents a significant advancement in the modeling of DMD processes for SS 304. By integrating a FE model enriched with thermomechanical variables, highly accurate simulations were achieved, validated through comparison with previous studies. The development of a data-driven approach, training an ANN with FE simulation data, enabled precise predictions of temperature and distortion by analyzing critical manufacturing parameters. This innovative methodology not only improved prediction accuracy but also accelerated the process, showcasing the ANN’s adaptability to new data. The study successfully minimized the discrepancy between predicted and actual results to a minimal threshold, highlighting the potential of integrating machine learning with traditional simulation methods to optimize the DMD process. The developed model effectively captures the intricate relationships between input variables (such as laser power and scanning speed) and output variables (multi-layer temperature and distortion), as evidenced by the obtained R2 parameter exceeding 0.99, indicating high fitting accuracy. Additionally, the observed capability of the ANN model to accurately and rapidly predict multi-layer temperature and distortion according to process parameters is noteworthy. Ultimately, this research establishes a robust framework for predicting and controlling thermal behavior and distortion in multi-layer DMD, facilitating more efficient and reliable additive manufacturing processes.