1 Introduction

The proliferation of information and communication technologies (ICT) has led to the emergence of intelligent manufacturing paradigms [1]. Modern engineering uses model-based simulations and data analytics to ensure the manufacturing process’ accuracy, stability, and high efficiency. One simulation-based optimization concept which has demonstrated its value in many industrial fields is the digital twin (DT) [2]. The term was first introduced by Grieves in 2003, who generally defined the DT as “a digital representation of an actual physical product” [3]. In terms of manufacturing, as stated by Negri et al. [4], the DT consists of a virtual representation of a production system that can run on different simulation disciplines and is characterized by the synchronization between the virtual and physical systems, thanks to sensed data and connected smart devices, mathematical models, and real-time data elaboration. When referring to DTs, a fundamental concept is the level of data integration. Indeed, according to the definition mentioned above, the data flow between an existing physical object and a digital object (virtual representation) shall be fully integrated into both directions, which means that a change in the state of the physical object leads to a change of state in the digital object and vice versa [5]. More specifically, the virtual-to-physical connection, i.e., the information generated in the virtual environment is acted on the physical environment, separates the DT concept from more traditional multi-physics simulation and modeling approaches [6].

The DT of a physical sensor is often called a soft sensor. A soft sensor estimates process parameters in various applications when a hardware sensor is unavailable or unsuitable for direct measurements [7]. In polymer processing, for example, soft sensors can help assess melt quality during manufacturing, as it is challenging to monitor otherwise. Abeykoon et al. used a nonlinear polynomial model to predict the die melt temperature profile during extrusion from readily measurable parameters, i.e., the screw speed and the barrel set temperatures [8]. Using a similar approach, Kumar et al. developed a model-based approach for online estimating and controlling melt viscosity. Soft sensors can also be based on data-driven models [9]. Wang et al. measured the degree of polymer orientation during processing using a support vector machine algorithm [10], and Adawiah et al. predicted the molecular weight of biopolymers during the polymerization process through a neural network–based soft sensor [11].

Real-time monitoring is one of the most widely used applications of DTs in manufacturing, and its role is mainly to improve processing quality and reduce production costs in an efficient, dynamic, and intelligent manner [12]. Botkina et al. developed a DT of a cutting tool to improve the process continuously [13], while Tong et al. presented a DT to provide theoretical support for tool path generation and optimization in a machining process [14]. A digital twin for a multi-effect evaporation unit was developed and implemented in a real industrial plant to handle plant fluctuations [10]. Vachalek et al. presented a DT concept to support the production of pneumatic cylinders in the automotive industry [16]. Recently, a series of studies has been conducted discussing the development and implementation of DTs and data-driven algorithms in the polymer processing field. Liau and Ryu presented a paper discussing the technology required to build the DT for the injection molding industry [17], while Gim et al. employed transfer learning to increase the efficiency of process optimization for high surface quality when manufacturing plastic parts on different injection molding machines [18]. Bibow et al. proposed a modeling method to generate DTs of injection molding machines that automate the execution of a design of experiments (DoE) for process parameter optimization and react to system changes based on an event-driven behavior [19]. A framework to leverage the “case-based reasoning” technique over domain expertise into self-adaptive manufacturing is presented by Bolender et al. [20]. However, a systematic literature review reveals a research gap in the context of DTs specifically developed to increase the efficiency of manufacturing processes in their startup phase, i.e., when fine-tuning the manufacturing process settings. The time-consuming trial and error procedure performed by expert machine operators in this phase leads to excessive material waste and high labor costs, which implies lower process efficiency.

This problem is widespread in the extrusion of finished or semi-finished plastic products, such as films, plates, pipes, and profiles [21]. In the startup of an extrusion line for plastic tubes, the following product requirements must be satisfied by manually varying the extruder settings: (i) the tube weight per unit length, (ii) the inner, and (iii) the outer diameter. The startup phase is very complex since it involves modifying several interdependent processes and system variables [16]. Moreover, when manufacturing multilayer tubes, it is even more challenging to measure the weight of the substrate unless the production is stopped and the tube is cut open, and any deviation from the target is consequently fixed operating on the outer layer, which is often made of more expensive materials.

The extruder’s throughput must be continuously measured to determine the final weight and thickness of the tube. Measuring the mass flow rate and the tube’s inner diameter is not trivial. Expensive gravimetric dosing systems or X-ray-based measurement systems would be required to determine the weight and thickness of the tube, respectively. However, equipping a production plant with many extrusion lines with these devices may be unfeasible. To address these limitations, Garcìa et al. investigated novel methods to predict the inner and outer diameters of plastic extruded tubes, but they limited their research to the offline development of regression algorithms [23].

This work presents the development of a soft sensor–based DT of an extrusion line, where analytical and data-driven models are used. The extruder and the extrusion dies were modeled using machine learning regression techniques to predict the process throughput, while the continuity equation was deployed to estimate the tube’s final weight and inner diameter. The characterization of the considered material, whose properties were given as input to the digital models, was carried out according to a procedure based only on the data collected on the production line. The digital model was then fed with real-time data from the extrusion line PLC through an OPC UA client–server communication protocol to make instantaneous predictions. Finally, to evaluate the performances of the DT, several simulations of the startup of an industrial extrusion line were carried out.

In this context, the DT addresses the following tasks:

  1. (i)

    The DT represents a valuable tool to speed up the startup phase, providing the machine operator with useful suggestions while tuning the process settings.

  2. (ii)

    The DT makes feasible the real-time monitoring of the main quality indexes of the product, i.e., the weight and the inner and outer diameters of the tube, thus detecting any deviation from the targets.

The novelty of this work mainly lies in developing a soft sensor–based DT to reduce the startup time in the manufacturing of plastic tubes and enable the real-time monitoring of product quality. Real-time data are given as input to a digital model, and the results of the model simulations are acted on the physical system through the machine operator to adjust the process settings and meet the desired targets, thus closing the loop between the virtual and the physical environment. To the authors’ knowledge, this is the first time a DT has been employed to increase the startup efficiency in manufacturing plastic tubes.

2 Materials and methods

2.1 Materials characterization

Three flexible polyvinyl chloride (PVC) compounds, which will be further addressed as PVC A, PVC B, and PVC C, were selected among the most commonly used ones for manufacturing tubes. Table 1 summarizes their characteristics.

Table 1 Properties and composition of the different PVCs

2.1.1 Shear viscosity

The viscosity information for each material was extracted from real extrusion data previously collected as follows. Three different tube extrusion dies were used to extrude the material at different levels of the screw speed. The mass flow rate of the extrudate was recorded using a lab scale and a chronometer, as well as the pressure drop across the die ∆p and the melt temperature Tmelt. A section view of the tube extrusion die is shown in Fig. 1.

Fig. 1
figure 1

Tube extrusion die: section view

According to [24], the flow rate-pressure model of the die can be described by:

$${Q}_{v}={K}_{i}\frac{\Delta p}{\eta }$$
(1)

where \({Q}_{\mathrm{v}}\) is the volumetric flow rate, \({K}_{\mathrm{i}}\) the characteristic of the i-th die, and \(\eta\) the viscosity of the melt, expressed using a power law model [25]:

$$\eta =m(T){\dot{\gamma }}^{n-1}$$
(2)

where \(\dot{\gamma }\) is the shear rate in the die, n is the power law index, and m(T) is the flow consistency index, which accounts for the temperature dependence of the viscosity, according to the WLF model:

$$m\left(T\right)=Dexp\left[\frac{{A}_{1}\left(T-{T}^{*}\right)}{{A}_{2}+\left(T-{T}^{*}\right)}\right]$$
(3)

where \({T}^{*}\) is a reference temperature and D, A1, and A2 are model coefficients.

As \({K}_{\mathrm{i}}\) must be unique for a given extrusion die, the viscosity parameters (n, \({T}^{*}\), D, A1, and A2) for each material were retrieved by fitting Eq. 1 to the experimental flow rate data obtained with all the different dies simultaneously. The main advantage of this characterization method is the use of data already available from the production lines. Since material properties are given as input data to the digital model to predict the final characteristics of the tube, it would not be feasible to rely on offline laboratory tests conducted using rheometers. Instead, a systematic routine practice is proposed that allows the inline viscosity characterization of different materials.

2.1.2 Wall slip

When deriving the simple Newtonian throughput-pressure model in single-screw extrusion, a common assumption is the no-slip boundary condition, i.e., no slip at the walls [26]. However, materials like HDPE, elastomers, or PVC display wall slippage under certain circumstances [27], i.e., when the shear stress exceeds a critical value, causing the polymer melt to slip over the screw/barrel surface. Thus, the wall slip behavior of the material shall be considered when calculating the flow rate of the extruder to achieve high prediction accuracy. Moreover, the PVCs used in the experimental campaign are highly filled with calcium carbonate (Table 1), which leads to a phenomenon typical of polymer suspensions called “apparent slip” [28]. A practical approach is proposed to evaluate the slip behavior of the considered materials during extrusion. According to a typical analytical throughput-pressure model, such as the one proposed by Tadmor and Klein [15], the flow rate should increase proportionally with the screw speed. However, this is not verified when wall slip occurs, and a power law can be used instead to describe the relationship between the screw speed and the volumetric flow rate. The power law index can be interpreted as a deviation from linearity: the closer the power law index to one, the less the material slips on the walls of the screw/barrel of the extruder and vice versa.

2.2 Equipment

All the experiments were carried out on an industrial single-screw extruder with a barrier screw of 60-mm diameter. Two temperature–pressure transducers (ME series, Gefran, Italy) were installed on the extrusion die before and after the breaker plate, having an operating range of 0–2000 bar, 0–400 °C, respectively, and accuracy at the full-scale output of ± 0.25%. The polymer melt is shaped through the die and rapidly cooled in two water tanks while a mechanism at the end of the line pulls the tube at a constant speed. A dual-axis laser device (Zumbach, Switzerland) measures the outer diameter of the tube after the first cooling tank, where the material shrinkage is complete. The velocity of the tube is measured by a speed encoder mounted before the pulling mechanism. A schematic of the extrusion line is reported in Fig. 2.

Fig. 2
figure 2

Schematic of the tube extrusion line. Adapted from [29]

2.3 Experiments

An extensive experimental campaign was carried out according to a full factorial design of experiments (DoE) to determine the characteristic of both the extruder and the extrusion dies, including the following variables: the material, the die diameter, the screw speed, and the temperatures of the heating barrel and the die. Table 2 summarizes the factors and their respective levels set in the DoE. The geometrical dimensions of the mandrel were fixed for all the experiments, with a Dmandrel = 15 mm, while the temperature values refer to the temperature set from the hopper to the die (from left to right in Table 2).

Table 2 Full factorial DoE

Eventually, 216 experiment trials were performed. For each run, once the process reached the steady-state condition, a sample of material extruded in 2 min was collected and weighed with a digital scale. The temperature of the melt Tmelt and the pressure drop across the die ∆p were recorded. Finally, the repeatability of the collected data was addressed, as it could be affected mainly by the tested material. Strict acceptance protocols were applied concerning the incoming material, mainly regarding composition and chemical and mechanical properties. Moreover, different batches of the same material were mixed when stored to compensate for small property variations. Thus, it is reasonable to neglect the property fluctuations, as confirmed performing replicates of the experimental points after several weeks from the first data acquisition phase. The average percentage error is < 0.5% and < 5% for the measured mass flow rate and pressure drop, respectively.

3 Modeling and data analysis

3.1 Flow rate and tube quality characteristics

In a recent work by the authors [30], a detailed procedure for calculating the weight and thickness of the tube was presented.

Considering Fig. 3, the inner diameter of the tube at Section. (1), where it is assumed that the material shrinkage is complete and its temperature is equal to the room temperature, can be calculated as follows:

$$d\left(1\right)=\sqrt{{D(1)}^{2}-\frac{4\frac{{Q}_{\mathrm{m}}}{{v}_{1}{\rho }_{1}}}{\pi }}$$
(4)

where D(1) is the outer diameter of the tube at Section. (1), \({Q}_{\mathrm{m}}\) is the mass flow rate, \({v}_{1}\) is the velocity of the tube, and \({\rho }_{1}\) is the material density at room temperature. Since D(1) and \({v}_{1}\) are continuously measured by the laser device and the speed encoder, respectively, and the density is known, only \({Q}_{\mathrm{m}}\) needs to be determined. According to the continuity equation, the mass flow rate is constant, thus:

$${Q}_{\mathrm{m}}={Q}_{\mathrm{v}0}{\rho }_{0}$$
(5)

where \({Q}_{\mathrm{v}0}\) is the volumetric flow rate at Section. (0), i.e., at the exit of the die, and \({\rho }_{0}\) is the density of the polymer melt. Since the weight per unit length of the tube can be calculated as

$${m}_{\mathrm{tube}}=\frac{{Q}_{\mathrm{m}}}{{v}_{1}}$$
(6)

the volumetric flow rate of the extruder needs to be estimated to predict the main quality characteristics of the tube. However, previous results by the authors showed that when extruding materials like PVC, the analytical throughput-pressure model, such as the one proposed by Tadmor and Klein (Agassant et al. 2017), fails to predict the flow rate because of the wall slip phenomenon. Therefore, data-driven models of both the extruder and the extrusion dies were developed to estimate the volumetric flow rate more accurately.

Fig. 3
figure 3

Schematic of tube extrusion

3.2 ML algorithms

Different machine learning algorithms were trained, evaluated, and tested using the open-source Python distribution platform Anaconda to build both the models of the extruder and the extrusion dies. First, the input and output variables of the extruder model were defined:

$$\begin{array}{c}{x}_{\mathrm{i}}=\left(N, \Delta p,\eta ,slip \right)\\ {y}_{\mathrm{i}}={Q}_{\mathrm{v}}\end{array}$$
(7)

where N is the screw speed, ∆p is the pressured drop across the die, \(\eta\) is the viscosity of the melt, and slip is a variable that accounts for wall slip phenomena, and it is defined as the deviation from the proportionality between the screw speed and the flow rate, i.e., the exponent of the power law equation. A feature selection phase was conducted by choosing the regressors based on the physics of the process. All the described predictors are thus known to be informative, according to the analysis of the extruder throughput-pressure models from the literature. Raw data were standardized to obtain values on a uniform scale, and preprocessed data were randomly shuffled and divided into training and testing sets according to a proportion of 85% and 15% of the original dataset, respectively. Three different models were considered to predict the extruder flow rate: polynomial regression (PR), support vector regression (SVR), and multilayer perceptron neural network (MLP). Model optimization was performed for each regression algorithm using k-fold cross-validation: Keras wrapper and randomized search from the Keras API (by TensorFlow) and the validation curve tool from the scikit-learn library were deployed for the hyperparameter tuning of the MLP and the PR and SVR, respectively. The optimized models were then evaluated and compared on the testing set, calculating an unbiased estimation of the out-of-sample error. Both model optimization and selection were based on the root mean squared error as the performance metric:

$$RMSE=\sqrt{\frac{1}{N}\sum_{i=1}^{N}{\left({y}_{\mathrm{i}}-{\widehat{y}}_{\mathrm{i}}\right)}^{2}}$$
(8)

Residual scatter plots and learning curves were also employed as diagnosing tools to analyze the bias and the variance of the considered models. The procedure mentioned above was also used to develop the extrusion die models. Given the annular geometry of the tube extrusion dies, the flow of the polymer melt can be considered a pressure-driven flow through a slit:

$${Q}_{\mathrm{v}}= \frac{W{t}^{3}}{12\eta }\frac{\Delta p}{L}$$
(9)

where W and L are the width and the length of the slit, respectively. Thus, the input and output variables of the data-driven model were defined as follows:

$$\begin{array}{c}{x}_{\mathrm{i}}=\left( \Delta p,\eta ,{t}^{3}\right)\\ {y}_{\mathrm{i}}={Q}_{\mathrm{v}}\end{array}$$
(10)

where t is the thickness of the tube die.

3.3 Startup optimization algorithm

In this work, the manufacturing of the first layer of flexible PVC tubes was considered, and the reduction of the startup time of an industrial extruder was addressed. Before the large-scale production of each tube, a startup phase is carried out to find the optimal process settings. Once the inner and outer diameters of the tube are defined, the weight per unit length is determined for a given material (i.e., for a given density) as follows:

$${m}_{\mathrm{tube}}=\frac{\pi }{4}\left({D}^{2}{-d}^{2}\right)\rho$$
(11)

The temperatures of both the barrel and the die are then chosen based on the extruded material. The tube is then connected to the pulling mechanism, and the velocity of the line, which depends on the desired production rate, and the tube’s outer diameter are set. A dual-axis laser device continuously measures the outer diameter of the tube. Its value is kept constant by a feedback controller, which acts on the opening-closing mechanism of the valve of the compressed air passing through the mandrel (Fig. 3). As the pulling mechanism imposes the velocity of the line, the volumetric flow rate that allows obtaining the desired weight per unit length can be calculated combining Eq. (5) and Eq. (6):

$${Q}_{\mathrm{v}0}^{*}=\frac{{m}_{\mathrm{tube}}{v}_{1}}{{\rho }_{0}}$$
(12)

where \({Q}_{\mathrm{v}0}^{*}\) represents the target flow rate and \({\rho }_{0}(T)\) is calculated with the temperature measured at the exit of the die. To achieve the target flow rate, thus the inner diameter and weight of the tube, it is necessary to vary the screw speed of the extruder. At present, the tuning of the screw speed is conducted by the machine operator as follows. The first attempt is carried out based on a heuristic curve where the flow rate is plotted as a function of the screw speed. This curve was previously obtained by the machine operator, who collected and weighed the extruded samples of several reference materials at different screw speeds. The machine operator then cuts a 1-m-long tube, weighs it, and measures its inner and outer diameters. These values are then entered into the SCADA system of the line. Based on the difference between the measured and target values, the screw speed is automatically adjusted by shifting the reference curve. However, due to the poor reliability of the reference curve, several attempts may be needed before meeting the tube requirements, ending up being a time-consuming procedure. The reference curve was obtained by testing only a few materials, and the volumetric flow rate was calculated with the material density at room temperature. Secondly, the wall slip phenomenon during extrusion was neglected, and a linear relationship was assumed between the flow rate and the extruder screw speed. A novel method for speeding up the startup of the machine is thus proposed. A schematic of the algorithm is shown in Fig. 4.

Fig. 4
figure 4

Workflow of the startup optimization algorithms

Once the quality indexes of the tube are known from the datasheet, the target volumetric flow rate \({{Q}_{\mathrm{v}}}^{\mathrm{target}}\) can be calculated according to Eq. 6 and Eq. 5. Then, for a given material and geometry of the die, the corresponding pressure drop can be obtained by inverting the model of the extrusion die, which will be further referred to as the “pressure drop model”:

Pressure drop model (inverted extrusion die model)

$$\Delta \mathrm{p}=f\left({Q}_{\mathrm{v}},\eta ,\frac{1}{{t}^{3}}\right)$$
(13)

For machine learning regression models, this can be easily done by replacing an input variable with the output variable, and vice versa, and training the model again. Then, the predicted value is given as input value to the inverted extruder model (further referred to as “screw speed model”), which was trained by swapping the screw speed and the flow rate as input and output, respectively, and the screw speed required to extrude the target flow rate is computed:

Screw speed model (inverted extruder model)

$$N=f\left({Q}_{\mathrm{v}},\Delta p,\eta ,slip\right)$$
(14)

The machine operator is thus provided with a suggested screw speed value to achieve the desired tube weight and inner diameter. Once the screw speed adjustment is operated on the extruder according to the results of Eq. 14, the machine operator waits for the process to stabilize, and a new iteration starts. The real-time values of the input variables, such as the melt temperature and the pressure drop across the die, are retrieved from the extruder PLC deploying an OPC UA client–server communication protocol. Given the nature of the extrusion process, even though the publishing interval of the monitored process variables in the server is 1 s, a data acquisition thread updates the digital model every 15 s, thus letting the process reach the steady-state condition after every modification of the operating parameters. At the same time, the (direct) extruder model computes the volumetric flow rate:

Direct extruder model

$${Q}_{\mathrm{v}}=f\left(N,\Delta p,\eta ,slip\right)$$
(15)

and by receiving as input variables the outer diameter value and the tube velocity from the OPC UA server, the tube’s final weight and inner diameter are estimated through the continuity equation (Eq. 4 and Eq. 6). The underlying mechanism of the iterative algorithm could be further explained observing Fig. 5. In this schematic, the curves of the extruder model (at different screw speeds) and the extrusion die model (at different melt temperatures) are reported with dotted and continuous lines, respectively. At the beginning of the first iteration, let us assume that the operating point is P0: the melt temperature is Tmelt = T0, and the extruder is running at a screw speed N = N0. The viscosity of the melt is calculated with Eq. 2, and this value is given as input to the pressure drop model, through which the estimated pressure drop ∆p = ∆p0 is computed. The screw speed model then allows calculating the screw speed of the extruder at the target operating point P1, i.e., to achieve the target flow rate \({Q}_{\mathrm{v}0}^{*}\). The screw speed is consequently increased from N0 to N1. However, when the screw speed increases, the temperature of the melt increases too, as well as the shear rate in the extruder, leading to a new operating point P2 where Tmelt = T1. Then, the second iteration starts, and a new value of the suggested screw speed is computed to achieve the target: N = N2. The screw speed is thus decreased from N1 to N2, and the melt temperature decreases too, so the new operating point is P3. The algorithm then computes the screw speed N3 to achieve the target point P4. The algorithm converges when the difference between the computed and the target flow rate is lower than a given threshold value, which depends on the required quality standards of the product.

Fig. 5
figure 5

Detailed schematic of the iterative algorithm

4 Results

4.1 Materials characterization: shear viscosity and wall slip

The shear viscosity curves obtained from the rheological characterization of the materials used in the experimental tests are shown in Fig. 6.

Fig. 6
figure 6

Viscosity vs. shear rate for the three different PVCs used

In Fig. 7, the experimental flow rate is plotted as a function of the screw speed for the three different PVCs, one extrusion die, and one temperature setting to characterize the wall slip behavior of the used materials.

Fig. 7
figure 7

Slip behavior of three different PVCs for one extrusion die (tube thickness = 1.5 mm) and one temperature set (T = 150 °C)

As it is evident from Fig. 7, the material exhibiting the highest deviation from linearity is PVC B, which is also the material with the highest filler content, while the effects of the wall slip are less evident for PVC C, which has the lowest content of calcium carbonate instead. The power law index for each material will be referred to as the slip coefficient, and it can be given as input value to the ML model of the extruder to predict the flow rate. As for the viscosity, when several data are collected from production lines, this procedure represents a practical method to characterize the slip behavior of the extruded materials in a time-saving manner.

4.2 Experimental results

The data collected during the experimental tests are shown in Fig. 8 in the typical throughput-pressure plot.

Fig. 8
figure 8

Experimental data for one temperature set (high) and different geometries of the die, screw speed values, and materials: a PVC A, b PVC B, and c PVC C

In Fig. 8, four subgroups can be distinguished for each plot, which refers to the flow rate recorded for different dimensions of the extrusion die (the labels in Fig. 8a also apply to Fig. 8b and Fig. 8c). As expected, the volumetric flow rate increases with the screw speed for all the materials and the dies, while for a given flow rate, the pressure drop across the die increases with the inverse of the die diameter. From further analysis of the experimental data, it was also observed that, for a specific die, the flow rate does not increase proportionally with the screw speed, as assumed by the Tadmor and Klein analytical model. For example, observing Fig. 8a and Fig. 8c (Ddie = 22 mm, T = 160 °C), the difference between the values of the flow rate at low screw speeds is relatively small \(\left(Q_{\mathrm v}^{\mathrm{PVCA}}=234\mathrm{cm}^3,Q_{\mathrm v}^{\mathrm{PVCC}}=241\mathrm{cm}^3atN=10\mathrm{rpm}\right)\); their difference increases at high screw speeds \(\left(Q_{\mathrm v}^{\mathrm{PVCA}}=1050\;\mathrm{cm}^3,Q_v^{\mathrm{PVCC}}=1165\;\mathrm{cm}^3at\;N=55\mathrm{rpm}\right)\) because it depends on the wall slip behavior of the considered material. Moreover, the analytical model cannot describe the pressure-sensitive behavior of the extruder, which can be deduced by the less-than-linear decrease of the flow rate with the pressure drop across the die for a given screw speed. Data-driven methods were thus employed to accurately predict the extruder’s flow rate in this complex scenario.

4.3 Machine learning models

The experimental data were used to develop the flow rate, pressure drop, and screw speed models. Model training, hyperparameter tuning, and model testing were conducted for each model according to the procedure described in Section. 3.2, and the results are summarized in Table 3.

Table 3 Cross-validation, in-sample and out-of-sample error for different ML regression models

Only one ML algorithm was chosen for each model, i.e., the one marked with “*” in Table 3, based on the best performance, which was evaluated and compared using the RMSE. The SVR algorithm exhibited the lowest RMSE when deployed to predict the extrusion flow rate and the screw speed, with the corresponding hyperparameters being tuned using cross-validation, while for what concerns the pressure model, the PR was chosen over the MLP. Moreover, the residual scatter plot and the learning curves were evaluated to diagnose the behavior of each model in terms of bias and variance. As an example, the residual scatter plot and the learning curves of the flow rate model are reported in Fig. 9.

Fig. 9
figure 9

a Flow rate predictive model: residual plot and b learning curves

As shown in Fig. 9a, the residuals are randomly scattered around 0, which means that the committed error is mainly due to stochastic effects and that the model can correctly predict the extruder flow rate. Figure 9b shows that the loss of the model decreases with the training set size and that the gap between the training and the testing loss curves becomes smaller as the training set size increases, thus proving good model fitting. The same analysis was also conducted for the screw speed and pressure models.

Finally, each model was retrained on the entire dataset, and the mean absolute percentage error (MAPE) was calculated. The SVR error is MAPE = 1.04% and MAPE = 1.07% when predicting the extruder flow rate and the screw speed, respectively, while the PR error is MAPE = 4.07% in the case of the pressure model. Since the errors are small enough to be compatible with the production standards, the regression models mentioned above are suitable for being deployed in the digital model of the DT. Moreover, the error of the ML regression models was also evaluated for each material used during the experimental trials, thus detecting possible overfitting behaviors that could arise, for example, from a specific train-test split of the original dataset.

4.4 Real-time estimation of the tube quality indexes

The DT digital model of the extrusion line, based on both the ML algorithms of the extruder and the extruder die, and the continuity equation was then employed to start the production of a new tube. Five experimental trials were conducted varying the geometry of the tube (i.e., different inner and outer diameters) for one material (PVC B). From the analysis of the results of the ML models, it was confirmed that the prediction loss was not significantly affected by the material used during the experimental campaign, i.e., the choice of the material is not relevant to assess the performance of the startup optimization algorithm in this phase. Before each run, the target weight per unit length of the tube and its outer diameter was chosen based on practical considerations, such as the adopted material and the size of the extrusion die. Once the velocity of the pulling mechanism was set, the inner diameter of the tube was uniquely determined, knowing the density of the material. The extruder was initially operated at low screw speed, and the DT algorithm was started. At each iteration, the DT (i) computed the suggested screw speed to achieve the target output (target weight per unit length and inner diameter) and (ii) provided the machine operator with the current values of the estimated weight and inner diameter of the tube. The results of the experiments are summarized in Table 4.

Table 4 Startup optimization for different tube geometries using the DT: experimental results

For each of the five trials, the values of the suggested screw speed and the predicted weight of the tube were stored every 15 s in a list with the corresponding timestamp to estimate the time required to achieve the target output. For example, the data acquired during the second trial are plotted in Fig. 10.

Fig. 10
figure 10

Screw speed correction algorithm. The dash-dot curve (∙-∙) represents the target weight of the tube, the continuous curve (–) represents the estimated weight of the tube, and the broken line curve (–) represents the suggested screw speed

In Fig. 10, the dash-dot curve represents the target value of the weight of the tube (m = 125 g/m), while the continuous curve represents the weight of the tube estimated by the DT. After the first iteration, during which the algorithm computes the screw speed to achieve the targets based on the current value of the process variables retrieved from the OPC UA server, the machine operator sets the suggested screw speed N  30 rpm and waits for the process to stabilize. As can be noticed, after three iterations, the algorithm has converged as the difference between the target weight and the estimated one (mest = 124.2 g) is less than 0.7%, and the suggested screw speed remains almost constant, apart from small adjustments (which cause the small oscillation of the estimated mass value). Thus, in less than 200 s, the algorithm allows tuning the machine settings to obtain a tube with the desired specifications, which is a significant time-saving considering that the standard procedure can take up to 20 min when carried out by an expert operator. The error between the target and estimated values is − 0.64%, while the error between the estimated and the measured weight is 2.89%. From a qualitative point of view, the same results are obtained for the other four trials, as shown in Fig. 11a.

Fig. 11
figure 11

Tube extrusion process monitoring with the DT. x: estimated a tube weight and b tube inner diameter; y: residuals between the estimated and measured a tube weight and b inner diameter

While the MAPE between the target value and the estimated weight value is less than 1%, the estimated tube weight value is always larger than the measured one (mean percentage error =  + 1.66%), meaning a systematic error occurs. This is likely due to a slight underestimation of the velocity of the tube, which is measured by the speed encoder. Thus, the thickness of the tube is overestimated. At the same time, the inner diameter is underestimated (mean percentage error =  − 1.78%), as shown in Fig. 11b. Even though the prediction of the algorithm is affected by the abovementioned systematic error, the DT allows the estimation of the tube quality indexes with an accuracy that is compatible with the required production standard since the inner diameter tolerance is ± 0.3 mm and the weight per unit length tolerance is ± 5 g/m. However, even if the model’s prediction performance can be improved by installing more accurate hardware sensors, the implementation of the DT proved to be effective in significantly reducing the time required to achieve the target quality indexes concerning the previous trial and error startup procedure.

5 Conclusions

The digital twin of an industrial tube extrusion line was developed and implemented to reduce the startup time of the extruder and to enable the inline monitoring of the most important quality indexes of the tube, i.e., the weight per unit length and the inner and outer diameters. ML regression models of the extruder and the extrusion die, trained and tested on experimental data, were combined with the continuity equation to develop the digital model of the twin. Since both the rheological and slip behaviors of the polymer melt need to be considered to achieve high model performance, a practical approach based on the analysis of the data collected directly from the extrusion lines was proposed to estimate these properties. The proposed method is suitable for efficiently characterizing different materials since it does not rely on offline laboratory tests. Once fed with real-time data from the physical entity through OPC UA, the DT provided the machine operator with the suggested settings (the screw speed of the extruder) to achieve the target specifications. Experimental simulations of the startup of the line for tubes of different weights and geometry demonstrated that the optimization algorithms allowed for a significant reduction of the startup time, thus increasing the overall efficiency of the process.

Moreover, the digital model calculated the instantaneous flow rate and the weight and inner diameter of the tube, achieving an accuracy of 98.3% and 98.2%, respectively, which proved the developed DT suitable for being deployed in production according to the required quality standards. However, a systematic error was noticed when predicting the weight per unit length and the inner diameter of the tube, which was probably due to a slight underestimation of the measured tube velocity. The tube velocity measurement needs to be improved to achieve an overall high DT accuracy.