1 Introduction

Additive manufacturing (AM), known widely as 3D printing, is being used these days with diversified applications in several industrial sectors [1]. This tremendous use of AM processes has continued to increase the overall market for AM parts over the years to reach a market size of $8.4 billion [5]. Despite these progresses, AM technology still undergoes some issues related specifically to surface finish, geometric deformations, residual stresses, and dimensional/geometrical deviations [4]. Several researchers have dealt with this subject wherein dimensional deviation was caused mostly by printing head (nozzle/laser) displacement errors, material shrinkage, or tessellation errors. Building a predictive deviation model can be an essential way to understand the occurred deviation behavior and its control. Hence, two critical approaches are used to model shape deviation in AM parts [9]: (i) by improving the mesh of critical zones while creating the tessellation file, and (ii) by modifying the CAD file by compensation rates on the basis of the predictive models. Based on the error source, this category could be further subdivided into two more subcategories: machine error compensation and shrinkage compensation.

Deviation modeling considering machine as an error source was the subject of several researches. Tong et al. [6] proposed that building a model for the assessment of the accuracy based on a manufactured benchmarking part is highly depending on its geometry. Therefore, the authors concentrated on the machine accuracy description in order to evaluate parametric errors of the rapid prototyping (RP) machine. For this purpose, they established a mathematical model of a stereolithography (SLA) machine by transferring the sources of process errors to parametric error functions of the axis system. The case study involved was applied only on two-dimensional models which represented a major drawback of this algorithm since the objective of RP machines is to manufacture 3D objects and not 2D ones. In order to extend this approach, Tong et al. [7] developed, following the same approach in previous work, a parametric machine error model for the FDM machines. The authors established an approach to correct sliced files by compensation method and then tested that approach on two types of parts fabricated using the FDM and SLA machines. The purpose was to compare the machines’ models and the compensation method built in them. The findings revealed that the reduction of the average volumetric error by the application of the tessellation file compensation method was smaller in the FDM machine than that in the SLA machine. However, the remaining error values after the application of the compensation were almost the same for both machines.

Instead of modeling and compensating machine errors, which seems to be limited by the developed models and their dependence on the architecture of the used machine along with machine-specified deviation models, some researchers suggest making changes in the STL file to minimize deviation and ensure accuracy. This research path is interesting as it addresses the input file of AM machines and tries to improve the approximation it provides for the CAD file. A good example for this category is the work done by Zhu et al. [10] in which they focused on the modification of the STL file based on contour point displacement. The systematic deviations occurring in each slice were represented and modeled, in order to displace the contour points layer by layer to build a new triangular facet model. The case study showed the ability of the used algorithm to well predict the systematic and the unexpected deviations in the shape’s product. More works dealing with errors elimination and minimization of deviations through modifying the whole STL file, modification of each 2D section of the file, or by increasing the facet density locally were comprehensively reviewed by Zhu et al. [9].

In addition, shrinkage modeling and compensating was also considered a viable option to control dimensional deviation in AM parts. Xu et al. [8] investigated the deviation over the cylindrical and prismatic parts manufactured using SLA process. After assessing the different sources of deviation and representing them mathematically, the authors developed a deviation descriptive model and tried to apply it on both considered features. The results showed that while the model complied well with the cylindrical features at a 95% confidence bound, it showed some errors when applied to the square geometries. In fact, the model was a well fit at the edges’ centers and diverged at the corners resulting in round boundaries which in turn required some more investigations. Furthermore, Zhu et al. [11] proposed a new in-plane deviation model of the nominal shape based on the homogeneous transformation matrices viz. scaling, rotation, and translation. The authors built the model in the Cartesian coordinate system and tested it on a polygonal geometry part manufactured using the FDM process. A comparison between the results obtained by this model and the method of Fourier-series expansion (FSE) showed the capability of the developed model to predict the deviation even at the sharp corners, in contrary to the FSE method that did not approximate the sharp transitions even with a high order expansion. Moreover, Huang et al. [3] developed a method to investigate the compensation by which the CAD file could be modified to minimize the deviation. Working only on cylindrical shapes, the authors manufactured parts using SLA process and collected the measurements’ data. The model generated the amount of compensation to be applied at each established angle which was subsequently tested by manufacturing cylindrical parts on an SLA machine. The model showed promising results in terms of minimizing the shrinkage by 10%. However, it had to be improved to gain more accuracy. In another work, Huang et al. [2] proposed a unified model for cylindrical and polygon shapes. Based on the model the authors had earlier developed in 2012, few modifications were undertaken and applied on three polygonal shapes: square, regular pentagon, and dodecagon. The results of this study showed that the unified model predicted the cylindrical and the square shapes successfully. However, a relatively low approximation was observed for pentagon and dodecagon shapes.

In light of the comprehensive review of the state-of the-art, it can be deduced that modeling, predicting, and controlling the deviation in additively manufactured parts were the concerns of the researches and various methods were applied and tested. However, some of these methods have shown few drawbacks and points of weaknesses related specifically to the type of file to modify and the deviation source to model. In fact, modifying the STL file through improving the mesh and displacing points to form a new triangular tessellation is a laborious task, especially when the addressed part is quite big. Further, modifying the CAD file, even seeming to be quite easy, may lead to some more deviation when transforming it to STL format. Regarding the deviation source to consider for modeling either machine displacement error or processing errors such as shrinkage, considering them both at the same time is not only challenging but also the model will include numerous parameters, and achieving its resolution will become difficult. Deviation induced by machine displacement has the drawback of not being a transferable approach as the developed model will depend on the machine architecture. On the other hand, modeling of shape deviation produced by processing errors can be the easiest type to consider. Following this path, it is intended in this article to mathematically model the in-plane deviation of circular and square shapes using a specified model for each of them by guaranteeing more precise deviation prediction. The deviation along the z-axis will not be treated in this paper as it will add more parameters thereby increasing the complexity of the models. In addition, studying the deviation along the z-axis will impose the need to study its interaction with the in-plane deviation, which is not the objective of this paper.

The proposed approach is given in Fig. 1. Using the polar coordinate system (PCS), the deviation between the nominal and the predictive values at each angle is modeled (“In-plane deviation modeling” section). The aim, therefore, is to extract the compensation rates (“Compensation modeling” section) to be applied at each angle while modifying the initial CAD file. As a verification test, a new part was manufactured (“Experimental study” section) based on the compensated CAD file to compare its deviation with the initial part to not only validate the developed mathematical models but also test their capability to well predict the deviation. The results were then discussed in the “Discussion” section along with the conclusions drawn in “Conclusion” section.

Fig. 1
figure 1

The overall used approach

2 In-plane deviation modeling

2.1 In-plane deviation in FDM process

For the subject study, FDM process is considered as it is the available one at the moment of realization of the study. In FDM process, a polymer filament is heated, fused, and deposited by a nozzle on a substrate in a layer-by-layer manner to create solid 3D-objects. Shape deviations that may occur while manufacturing parts with FDM process are essentially due to the fusion-solidification process which is the operating principle of the FDM process as well. The in-plane shape deviation in FDM process can be decomposed into two steps which are explained in subsequent paragraphs.

During fusion stage, a temperature higher than necessary to fuse the filament can lead to the expansion of the product size. Likewise, less heat than required can result in its reduction. (x, y) are the deviations along x- and y-axis, and (x0, y0) are the coordinates of a point “P” from the boundary of a nominal geometrical form. The location of point “P” after deviation (x, y) is modeled as shown in Eq. 1:

$$ \left\{\begin{array}{c}x={x}_0+{\Delta }_x\\ {}y={y}_0+{\Delta }_y\end{array}\right. $$
(1)

After fusion and deposition of melted filament onto the substrate, the material undergoes a phase change which leads to a shrinkage deviation that can be represented as Eq. 2:

$$ \left\{\begin{array}{c}{x}_1={p}_x\times x\\ {}{y}_1={p}_y\times y\end{array}\right. $$
(2)

where (px, py) are expansion (or shrinkage) factors relative to the phase change process of the material used and (x1, y1) are the new coordinates of the point “P.” Thus, the final coordinates of point “P” from the boundary of the geometrical shape in question, after the whole shape deviation process, is given in Eq. 3:

$$ \left\{\begin{array}{c}{x}_2={p}_x\left({x}_0+{\Delta }_x\right)\\ {}{y}_2={p}_y\left({y}_0+{\Delta }_y\right)\end{array}\right. $$
(3)

Another variable, ζ, is added and denoted as ζ = {px, py, x, y}. This is actually the set of parameters to be used in the development of the models proposed in this paper.

Deciding which coordinate system to use for modeling is the first step in any development approach for a model. To wisely make a decision, the deviation of point “P” from the contour of a geometric feature in both Cartesian (CCS) and PCS is represented in Fig.  2. From this figure, it is obvious that expressing the deviation of point “P” in CCS necessitates two parameters, x and y, representing respectively the deviation along x- and y-axis. However, in PCS, the deviation of point “P” can be described only by r that represents the deviation along the radius of the geometric shape. Subsequently, PCS is used in this paper to represent the mathematical model of the in-plane deviation.

Fig. 2
figure 2

Deviation modeling of a point “P” considering a Cartesians coordinates systems and b polar coordinates system

2.2 Proposed mathematical models

In this study, a model is specified for each studied feature, i.e., a mathematical model for in-plane deviation modeling in circular shapes and another one for the squared shapes. Manufacturing a circular shape using FDM process will probably lead, through the fusion-solidification process as explained above, to an elliptical shape. Therefore, it is viable to equate r(θ, r0(θ)) with the polar radius of an ellipse. Hence, the equation of the predicted radius rp(θ) is as shown in Eq. 4:

$$ {r}_p\left(\theta \right)=\frac{p_x\left({r}_0+{\Delta }_x\right)\ {p}_y\left({r}_0+{\Delta }_y\right)}{\sqrt{p_x^2{\left({r}_0+{\Delta }_x\right)}^2{\mathit{\sin}}^2\left(\uptheta \right)+{p}_y^2{\left({r}_0+{\Delta }_y\right)}^2{\mathit{\cos}}^2\left(\uptheta \right)}} $$
(4)

where px(r0 + x) and py(r0 + y) are respectively the semi-major axis and the semi-minor axis of the resulting elliptical shape (Fig. 3), and r0 is the nominal diameter.

Fig. 3
figure 3

Schematic example of deviations occurred in circular shape while fusion-solidification process of FDM

On the other hand, squared shapes also undergo deviation while manufactured by FDM process and are found on the transformation of the sharp corners of the square to rounded corners. The predicted radius of the square is equated to the polar radius of a square and, hence, modeled as given by Eq. 5:

$$ {r}_p\left(\theta \right)=\frac{p_x\times \left({\Delta }_x+{r}_0\right)}{2}\sqrt{\frac{1-\sqrt{\cos^2\left(2\theta \right)}}{\cos^2\left(\theta \right){\sin}^2\left(\theta \right)}} $$
(5)

where px × (x + r0) is the radius of the resulting square after deviation, \( {r}_0=a/\sqrt{2} \), where a is the nominal length of the square side (Fig. 4). Here, it is noted that the notation is kept as px and x even if PCS is referred to in order to avoid any confusion with r which is used in the upcoming section to denote the shrinkage.

Fig. 4
figure 4

Schematic example of deviations occurred in square shape while fusion-solidification process of FDM

Equation 5 is then simplified, and the resulting form is used as a notation for the parameters of the square deviation model \( {p}_x^{\prime } \) and\( {\Delta }_x^{\prime } \). Modified Eq. 5 is as shown in Eq. 6:

$$ {r}_p\left(\theta \right)={p}_x^{\prime}\times \left({\Delta }_x^{\prime }+{r}_0\right)\sqrt{\frac{1-\sqrt{\cos^2\left(2\theta \right)}}{\cos^2\left(\theta \right){\sin}^2\left(\theta \right)}} $$
(6)

The next step is the determination of the set of parameters of each model, i.e., ζ = {px, py, x, y} and\( \zeta^{\prime }=\left\{{p}_x^{\prime },{\Delta }_x^{\prime}\right\} \), so that the predicted deviations can fit with the observed ones. For this purpose, estimation from measurements’ data based on a given manufactured part is obtained through a fitting curve that perfectly adjusts the recorded points of the shape contour. In this paper, the function “fminsearch” from the “fitting curve” toolbox of MATLAB is chosen. This function finds the minimum of a scalar function of several variables, starting with a random initial value. Given that (θi, rm(θi)) are the measurements’ data taken from the manufactured part and ζ and ζare the set of parameters of models to estimate, the function that needs to be minimized is the sum of squared deviations as given by Eq. 7:

$$ \hat{P}={\mathrm{argmin}}_{\zeta}\sum \limits_i^N{\left|{r}_p\left({\theta}_i\right)-{r}_m\left({\theta}_i\right)\right|}^2 $$
(7)

where \( \hat{P} \) is the set of parameters to estimate ζ = {px, py, x, y} for circular shape deviation model and \( {\zeta}^{\prime }=\left\{{p}_x^{\prime },{\Delta }_x^{\prime}\right\} \) for squared shape model; rp is the predicted radius given by Eq. 4 and Eq. 6, and rm is the measured radius at each angle θi. Details about measurements’ data extraction are given while presenting the carried experimental study in the “Experimental study” section.

3 Compensation modeling

In this section, the CAD file is acted upon directly by adding compensation rates extracted from the predictive models developed in the “In-plane deviation modeling” section. A noted compensation,x(θ), applied at the angle θ, is only an added value to the radius, r(θ, r0(θ)), recorded at that angle. To model this compensation, it is assumed that the manufacturing conditions as well as the shrinkage process dynamics are the same with or without applying the compensation. So, firstly a differentiation is set between (i) shrinkage modeling, ∆r, which represents the deviation between the nominal and the current/measured radius, and (ii) shrinkage process modeling, f, which represents the process of deviation/compensation, such that, given a nominal radius,r0, the resulting radius, r1,after applying the compensation, x(θ), will also undergo a deviation (r1 < r0).

The deviation is denoted as ∆r(θ, r0(θ)), the nominal radius as r0(θ), and the actual (manufactured) radius as r(θ, r0(θ)). Therefore, in the PCS, the deviation between the nominal and the actual shape is written as given in Eq. 8:

$$ \Delta r\left(\theta, {r}_0\left(\theta \right)\right)=r\left(\theta, {r}_0\left(\theta \right)\right)-{r}_0\left(\theta \right) $$
(8)

After applying a compensation,x(θ), the actual radius is denoted as r(θ, r0(θ), x(θ)), and the nominal radius is given as r0(θ) + x(θ). The function “f” determining the shrinkage process is defined as shown in Eq. 9:

$$ f\left(\theta, {r}_0\left(\theta \right)+x\left(\theta \right)\right)=r\left(\theta, {r}_0\left(\theta \right),x\left(\theta \right)\right)-\left({r}_0\left(\theta \right)+x\left(\theta \right)\right) $$
(9)

It is imperative to note here that Eq. 8 is a special case of Eq. 9 where x(θ) = 0 and ∆r(θ, r0(θ)) = f(θ, r0(θ)).

Next, the occurred deviation after applying the compensation, x(θ), can be written as given in Eq. 10:

$$ {\displaystyle \begin{array}{l}\Delta r\left(\theta, {r}_0\left(\theta \right),x\left(\theta \right)\right)=r\Big(\theta, {r}_0\left(\theta \right),x\left(\theta \Big)\right)-{r}_0\left(\theta \right)\\ {}\Delta r\left(\theta, {r}_0\left(\theta \right),x\left(\theta \right)\right)=f\left(\theta, {r}_0\left(\theta \right)+x\left(\theta \right)\right)+x\left(\theta \right)\end{array}} $$
(10)

To explore the shrinkage, ∆r(θ, r0(θ), x(θ)), the second-order Taylor’s expansion formula is used as given in Eq. 11:

$$ {\displaystyle \begin{array}{l}E\left(\Delta r\left(\theta, {r}_0\left(\theta \right),x\left(\theta \right)\right)\left|\theta \right)=E\left(f\left(\theta, {r}_0\left(\theta \right)+x\left(\theta \right)\right)\right|\theta \right)+x\left(\theta \right)\\ {}=f\left(\theta, {r}_0\left(\theta \right)\right)+{f}^{\prime}\left(\theta, {r}_0\left(\theta \right)\right)x\left(\theta \right)+x\left(\theta \right)\end{array}} $$
(11)

Ideally, the applied compensation must give rise to the nominal radius, deducing that the approximation in Eq. 11 will be equal to zero. Hence, the optimal value of the compensation x(θ) is found as shown in Eq. 12

$$ {x}^{\ast}\left(\theta \right)=-\frac{f\left(\theta, {r}_0\left(\theta \right)\right)}{f^{\prime}\left(\theta, {r}_0\left(\theta \right)\right)+1} $$
(12)

This is the mathematical model of the compensation, where f(θ, r0(θ)) = r(θ, r0(θ)) − r0(θ), and r(θ, r0(θ)) is the predicted radius that is modeled in Eq. 4 and Eq. 6.

4 Experimental study

The part shown in Fig. 5a was considered for the experimental study. It is composed of 3 cylinders (each of radius 5, 10, and 15 mm) and three squares (each of side lengths 10, 20, and 30 mm) (Fig. 5b). All the features had a height of 10 mm. This part was modeled in CATIA V5 and then converted to STL format using meshing parameters of 0.01 mm for size and 1 mm for sag value. The part was then manufactured under Replicator 2X FDM printer using polylactic acid (PLA) material. The manufacturing parameters set are shown in Table. 1. The part was then scanned by Atos Core 3D scanner, which offers a measurement precision of 20 μm, and treated using GOM inspect software. The points constituting the contour of each geometric feature were extracted at a height of 0.5 mm from the top of features (Fig. 6) to avoid the edges that can be rounded which may result in inaccurate measurements, thereafter. The extracted points were then represented by their (x, y, z) coordinates in CCS. As the interest was only in in-plane deviation, only x and y coordinates were retained. These coordinates must be classified from the smallest to the largest (according to x or y optionally) to allow a good conversion to polar coordinates (θi, rm(θi)).

Fig. 5
figure 5

a Considered part for the experiment. b Part’s engineering drawing

Table 1 Manufacturing parameters values
Fig. 6
figure 6

a Extraction of middle square contour points at a distance of 0.5 mm from the top. b Points extracted

A MATLAB code to sink our models to the measured data obtained from the manufactured part, i.e., the extracted points from features’ contours, was also developed. In this code, Eq. 7 was implemented using the aforementioned “fminsearch” function, and expressions of deviation models for circles and squares were given respectively by Eq. 4 and Eq. 6. The purpose was to find out the estimated parameters’ values, i.e., ζ = {px, py, x, y} and\( {\zeta}^{\prime }=\left\{{p}_x^{\prime },{\Delta }_x^{\prime}\right\} \). The sets of estimated parameters’ values for cylinders’ and squares’ models are reported respectively in Tables 2 and 3. These parameters are then substituted in Eq. 4 and Eq. 6 which allows the construction of a compensation equation for each feature by means of Eq. 12, thereby producing 6 compensation equations, which have not been added in the scope of this work due being too complicated.

Table 2 Estimated parameters for cylinders’ model
Table 3 Estimated parameters for squares’ model

Modifying the initial CAD by adding the compensation rates to the points constituting the contour of each feature is the subsequent step. It consists of modifying the radii of different geometrical shapes by adding compensation rates relative to each angle θ. Given that nominal radius was r0(θ), the new radius is r0(θ) + x(θ). The new contours’ points are then transferred to CATIA v5 to redraw the features and construct the new part. The compensated part is further manufactured and scanned to compare the in-plane deviation and ensure the predictability of proposed models.

5 Discussion

The compensated and uncompensated parts are shown in Fig. 7. The in-plane deviations recorded for features of both parts are shown in Figs. 8 and 9. The blue line represents the deviation before compensation (i.e., uncompensated features), and the red line shows the deviation after compensation (i.e., compensated features). From a preliminary perspective, it turns out that there are some improvements as follows:

  1. i.

    For the middle and the big squares, the shrinkage has significantly reduced over all the edges. In the big square, the deviation has improved for all the edges except the bottom edge where it remains negative (not exceeding − 0.1 mm). For the middle square, the deviation has improved especially on the left and bottom edges of the square. Slight improvements are visible on the other edges as well. Concerning the small square, it shows variances for the four sides. In fact, the upper side shows betterment in the shrinkage recorded, with a deviation value of − 0.02 mm after applying the compensation. A reduction of shrinkage is noticed especially in the right side although it has become positive. For the deviation in the corners of the squares, sharp corners are represented in the figure of deviations in the ideal case by a strictly vertical line separating the curves depicting the deviation in each side of the square. In this sense, the small square shows rounded deformed corners while the deviation in the corners is less obvious in the middle and in the big square.

  2. ii.

    For the big cylinder, the average of shrinkage values measured all around the contour’s points has decreased by 81% from its original value. The deviation reduced generally all over the contour except for the portion (π, 3π/2) where the value of the deviation remained almost the same but with a positive index. The middle cylinder also showed betterment in shrinkage values, as it decreased by 69% after applying the compensation. For the small cylinder, the shape of the deviation slightly changed, but an improvement in the values of the deviation is noticed with a 29% of reduction in the average shrinkage in compensated cylinder.

Fig. 7
figure 7

a Uncompensated part. b Compensated part

Fig. 8
figure 8

Deviation recorded for squares before (blue continuous line) and after (red dash-dot line) compensation

Fig. 9
figure 9

Deviation recorded for cylinders before (blue continuous line) and after (red dash-dot line) compensation

To put it all together, it can be stated that the proposed models predict the shrinkage well and help to decrease it. The same has been demonstrated by the manufactured compensated part throughout the contour of the considered shapes. However, there remain some problems to be resolved related to the deformation taking place in the corners of the squares as well as the shrinkage of the small features. In fact, the more the feature to manufacture is small, the more inaccurate it will be. That is caused by several reasons such as the difficulty of realizing small precise displacements of the printing head and the bed in FDM machines. Also, small printed features undergo faster cooling resulting in more deformation especially in the corners of prismatic shapes. More work can be done in order to control the deviation well and ensure a regular deviation profile.

6 Conclusion

In this paper, the deviation in circular and prismatic shape was discussed. Two models, each for a specific geometric feature, were developed to model the in-plane deviation. The experimental study was conducted using a part containing features with different sizes and manufactured with a FDM machine. In general, the models showed a good fit to the experimental data despite some roundness in the squares’ corners. In the subsequent step, compensation rates were extracted via a compensation model to reform the CAD file and correct the occurring shrinkage. The comparison between the in-plane deviation before and after compensation showed the effectiveness of the developed models to fit the data and improve the recorded shrinkage values. However, more work can be done to address some persistent problems such as the roundness of corners and irregularity of deviation profile. With this idea, and besides these issues, the deviation along the z-axis by extending the two models to predict and model the in-plane and out-of-plane deviations will be the subject of future work.