A Digital Twinning Methodology for Vibration Prediction and Fatigue Life Prognosis of Vertical Oil Well Drillstrings

A detailed methodology to develop a digital twin has many useful applications in the era of technology 4.0. This study provides a framework to develop a digital twin for vibration prediction and fatigue life prognosis of a vertical oil well drillstring. The nature and the severity of the down-hole vibrations are identified and estimated based on the vibrational and operational parameter measurements made at the surface level. Because of the difficulty in accessing full-scale industrial drilling data, a reduced-scale drillstring was constructed that could exhibit bit bounce, stick-slip and whirl. A bond graph simulation model was tuned to match the apparatus, and then used to generate synthetic training data. The trained machine learning algorithm can classify the incoming surface monitoring data from the physical twin into different types and severities of vibration states which are not otherwise observable. Moreover, the classified vibration condition is used to re-configure the bond graph model with appropriate complexity to generate a loading history for fatigue life prognosis. The fatigue life estimation uses a novel combination of a low-complexity model of the entire drillstring and a high fidelity finite element model of components where stress concentrations are most severe. The digital twin detected the vibration type and its severity and estimated the remaining fatigue life of the physical system using only measurements of the motor current, rig floor axial vibration, and rotary speed.


I. INTRODUCTION
Downhole drillstring vibrations, especially high-frequency vibrations, are not observable from the ground level due to wave attenuation and bandwidth limitation of the currently used measuring techniques [1]. As mentioned in [2], a number of telemetry methods have been developed over the years to transfer measured data to the surface, including mud-pulse (MP), electromagnetic (EM), wired-drill-pipe, and acoustic telemetry. While the wired-drill-pipe telemetry can transport data up to 57 kbps, the MP and EM telemetry systems can only communicate data at rates of about up to 10 bps. In offshore applications, EM telemetry is ineffective, The associate editor coordinating the review of this manuscript and approving it for publication was Giovanni Merlino . and wired drill pipe telemetry is expensive and prone to malfunction when the wiring link between the transmitter and receiver is lost. Acoustic telemetry has the capacity to communicate at rates up to hundreds of bits per second. These transmission rates are insufficient for near real-time surface monitoring of high-frequency downhole vibrations. Therefore, both the detection and control of such vibrations are done at the bottom of the well [1], [3].
Nevertheless, the availability of rich vibrational data is essential for applications such as fatigue life prognosis of drill pipes. Timely detection of such conditions helps to make effective rectifications of the operations and hence to reduce the risk and to assure reliability. This allows the driller to take action to mitigate the vibration, for example, by reducing weight on bit (WOB) and/or increasing rotational speed to address stick-slip. The high cost for the downhole measurement of the drillstring vibrations consequently encourages machine learning approaches to downhole vibration prediction during drilling [4]. The limited availability of reliable training data for machine learning algorithms is also a challenge. A digital twin of a drillstring has the potential to generate synthetic data for different 'what-if' scenarios [5], which may be a solution for this problem. Therefore, the current study is focused on developing a digital twin which has the ability to generate its own data, by performing a series of simulations, to train its machine learning algorithms in order to make useful predictions such as downhole vibration state and fatigue life prognosis.
The overall outcome of the current study is a digital twin for a vibrating structure, in this case an oil well drillstring. The process starts with a physical system that is susceptible to vibration problems that a) can be classified (stick-slip, bit bounce, and whirl for drilling) and b) are not easily detected because direct measurement is not practical. A dynamic simulation model of the physical system is then created and parameterized, including virtual sensors to generate time series of practically available measurements. The virtual measurements corresponding to the selected types of vibration from the simulation model are used to train a machine learning algorithm. Measurements of actual physical system vibration can be input to the trained algorithm to identify vibration type and severity. Once vibration is detected and classified, the simulation model is configured to replicate it, and generate stress histories. The stress histories are exported to a finite element model for fatigue life prognosis.
Section II reviews literature on digital twinning, vibration measurement in drilling, drillstring modelling, and machine learning algorithms. Section III gives an overview of the process and introduces the techniques used at each stage. Sections IV to VII give detailed development of the case study system, simulation model, machine learning algorithm and training, and fatigue life prediction. Section VIII provides results, and discussion and conclusions are in Sections IX and X.

II. BACKGROUND STUDY A. DIGITAL TWINS
This section introduces the digital twin concept and presents some recent developments along with their strengths and weaknesses.
'Digital twin' is a term that has been used in the recent past to describe a digital replica of a physical system. However, there is no consolidated view on what digital twins are [6]. The digital twin concept was first introduced by Michael Grieves at the University of Michigan in 2003 through Grieves' Executive Course on Product Lifecycle Management [7]. According to [5], the term 'digital twin' carries various definitions, and the term is often misinterpreted. As mentioned in their review, on some occasions, just a 3D visualization of a physical system is referred to as a digital twin. According to the broadest definition identified by [5], a digital twin is an ''integrated multi-physics, multi-scale, probabilistic simulation of an as-built system, enabled by digital thread, that uses the best available models, sensor information, and input data to mirror and predict activities or performance over the life of its corresponding physical twin'' [8].
Meanwhile, [9] defines three types of digital twins: Product, Process, and Performance. Product digital twins are used for the efficient design of new products, while Process digital twins are used in manufacturing and production planning. Performance digital twins are used to capture, analyze, and act on operational data. According to this classification [9], the outcome of the current study can be classified as a Performance digital twin.
A digital twin conceptual framework for a dynamic structural damage problem is presented by [6], in which a physics-based model coupled with Quadratic Discriminantbased classifier algorithm was introduced. The proposed conceptual framework could be adapted to implement a Product digital twin, which can prognose the fatigue failure of a vibrating structure.
A digital twin concept was proposed in [10] to estimate the structural life of aircraft components. It was envisioned that during the industry 4.0 technology level, the manufacturer could automatically populate the high-fidelity Product digital twin during manufacturing. While in operation, based on the sensor readings and other inputs, the digital twin would be capable of estimating structural life. However, as further mentioned in [10], the measured aircraft weight while in operation, which is a crucial input to the digital twin, still involves cumbersome ground equipment and input with assumptions given by the flight crew, and is hence not accurate at the moment.
In addition to damage or life predictions of systems, the digital twin approach can be used in process optimization. A novel hybrid framework introduced by [11] combines machine learning methods with API laboratory procedures, onsite measurement data, and fluid rheology to adequately describe the drilling fluids. This approach can leverage the drilling performance by optimizing cutting transport and hence get an efficient ROP. Further, as proposed by [12], digital twins can support planning, real-time analysis, realtime automated monitoring, forecasting simulation, and forward-looking simulations of problematic situations.
The use of digital twins in the fatigue life prognosis of drillstrings is not reported in the literature. Mathematical modelling, vibration simulations, fatigue analysis, and classification of surface monitoring measurements using machine learning algorithms are found as isolated studies in most cases and a holistic approach is not available in the literature. The current study addresses this by presenting a digital twin development procedure integrating dynamic modeling, vibration simulation, machine learning, and fatigue analysis. VOLUME 11, 2023

B. SURFACE MONITORING TECHNIQUES AND THEIR IMPORTANCE
Prior work has studied the feasibility of surface monitoring in estimating downhole vibration conditions. In order to learn more about bit-rock interaction, vibrations at the top of the drillstring were initially recorded and processed in the 1960's [13]. The contact between the bit and the rock during rotary or motor drilling generates forces and displacements in the drillstring. As further mentioned in [13], in the case of rotary drilling, additional stresses are produced between the drillstring and the wellbore wall. Another type of excitation comes from the fluid pulses produced by reciprocating mud pumps. Along the accessible mechanical and fluid routes, the forces from all these connected phenomena interact and transmit toward the surface. Measurements of stresses and accelerations made at the surface level can help to understand the downhole vibration conditions.
A study to understand the correlation between tri-cone bit wear conditions based on the different drilling signal measurements made at the surface level and drilling vibration analysis is presented in [14]. Several rigs were instrumented with data acquisition units including sensors to measure hoist motor current, rotary motor current, head encoder position, bailing air pressure, hoist voltage, rotary voltage, lower-mast vibration, and upper-mast vibration signals. The vibration was sensed using two accelerometers installed at approximately 2/3 of the drill mast height and the mast base. It was found that the rotary motor current signal statistical features are sensitive to bit wear which is related to the rotational speed [14]. Also, in their study on rock drilling operations, [15] concluded that vibration signals have significant potential for determining the degree of tool wear. Both the methods presented in [14] and [15] require downhole measurements to train the algorithms for the classification of vibration states.
A model using an artificial neural network (ANN) to anticipate the vibration of the drillstring when drilling a horizontal segment was presented by [16]. The three different forms of drillstring vibrations: axial, torsional, and lateral, were predicted by the ANN model using the surface drilling parameters as model inputs. Flow rate, mud pumping pressure, surface rotating speed, top drive torque, weight on bit, and rate of penetration (ROP) were the surface monitoring drilling parameters used. An equation for real-time estimation of the down-hole vibrations was proposed using the model developed. The approach of [16] required actual data to train the machine learning algorithm, which is not always a readily available factor in most situations.
Severe downhole stick-slip vibrations can be identified solely based on surface monitoring drilling data in the method proposed by [4]. It categorizes multi-channel drilling data acquired at the surface by employing a deep neural network model to identify downhole vibration events. This method requires both surface monitoring measurements and downhole measurements to train the deep neural network in order to perform this task.
Severe downhole stick-slip vibrations can be identified solely based on surface monitoring drilling data in the method proposed by [4], which categorized multi-channel drilling data acquired at the surface by employing a deep neural network model to identify downhole vibration events. This method required both surface monitoring measurements and downhole measurements to train the deep neural network in order to perform this task.
The patent presented in [17] also uses a surface monitoring technique to estimate the downhole lateral vibrations. The algorithm used is fine-tuned using the data taken from the downhole sensor. Once the algorithm is trained, it has the ability to detect lateral vibration. As per the observations, it was deduced that an increase in the moving average of drillstring torque or a decrease in the variation of drillstring torque is a sign of lateral vibration, which ultimately leads to a reduction of ROP. This method was limited to lateral vibration and whirling detection. Physical data was used in training the algorithm.
The above contributions emphasize the viability of surface-level monitoring of drill string vibrations. The training of a machine learning algorithm by employing a sophisticated drill string multi-physics simulation to identify various vibration categories and their intensities has not yet been investigated.

C. ALGORITHM TRAINING USING SYNTHETIC DATA
Any artificially generated information not originating from events or objects in the real world can be given the designation 'synthetic data'. Simulations have the potential to generate synthetic data which can mimic the actual scenario, and the generated data can be used to train a machine learning algorithm for a variety of uses. Synthetic data has a number of key advantages, including the ability to generate large training data sets without the need for manual labelling of data and the reduction of restrictions associated with the use of regulated or sensitive data. They can also be customized to match circumstances that real-world data does not permit at a low cost. Higher data quality, scalability, and ease of use are some advantages, to name a few [18], [19].
Synthetic data is used in software data-driven testing due to its flexibility, scalability, and realism [18]. In some cases, synthetic training data outperforms real-world data and is essential for creating superior Artificial Intelligence (AI) models. This is because rare incidents also can be simulated, and data can be generated, which facilitates better algorithm training covering the entire spectrum of events. Moreover, it helps to eliminate some practical issues in using realworld data, such as biases in data which lead to skewness and inaccuracy of the model. A variation on synthetic data is partially synthetic data that keeps some of the original data set and performs a gap-filling using the simulated data. Hybrid synthetic data combines the real-world and generated data, which creates an opportunity to acquire the benefits of both fully synthetic and partially synthetic data.
Further details on synthetic data usage in machine learning algorithm training and its practical limitations relevant to the current study are presented in Section IX.

1) AN OPEN-SOURCE HMM TOOLBOX
An open-source HMM toolbox is presented in [20], which provides improved flexibility in developing fault detection tools [21]. The operating concept is explained in Section III-B, which explains the suitability of using HMM for surface monitoring applications. When using this toolbox, the user does not need to evaluate the prior probabilities or transition probabilities of states which is a requirement of most of the commercial software tools. Instead, the algorithm can be trained using the training data set to generate them. A detailed description of the HMM open-source toolbox is available in [21] and [20] for further information.

D. DRILLSTRING SIMULATION
According to [22], the modelling of lateral vibrations of drillstrings has been explored since the mid-1960s. Analytical and finite element modelling approaches have been the most widely used. Although initial attempts relied on closed-form analytical solutions, the extreme complexity of vibrations and interactions with the well bore set limits to this approach. Therefore, the latter approach has become more common with the advancement of computer processing speeds but may be of limited use in design exercises because of excessive simulation times [23].
Physical system modelling can be more effective when using an approach that allows easy integration of components from different energy domains such as fluid, electrical, thermal, and mechanical. A typical drillstring simulation involves, but is not limited to, induction motors, fluid flows, structural vibrations, and heat transfer submodels. Sometimes it can be cumbersome to simulate each mechanism or phenomenon in their own domains and combine to get the overall output [24]. Although it is feasible for certain scales and complexity levels, the computational cost may be massive when the system becomes larger and more complicated.
It is beneficial to bring all the domains into one common platform to simplify the problem. Energy can be used to play the role of the 'common currency' in this kind of situation. The bond graph method [23], [24], [25] uses a small set of generalized elements to represent power storage, dissipation, boundary conditions, continuity, and compatibility constraints. The element symbols and connection rules are the same regardless of the energy domain, making multi-domain modelling straightforward. Further details on bond graphs can be found in [23], [24], and [25].
References [23], [26], and [27] present drillstring bond graph simulations using the Newton-Euler formulation and a body-fixed coordinate system. Rigid lumped segments were connected to each other with axial, shear, bending, and torsional springs such that the behaviour of the model approached that of a continuous system as the number of elements increases. Figure 1 illustrates the first three types, while the torsional spring can be considered as a similar spring to the one in Figure 1c but with a rotational degree of freedom. These springs are analogues to the structure's elasticity which are represented by capacitive (compliant) elements in the bond graph.
A flexible nonlinear drillstring model developed based on Lagrangian dynamics is also possible, as presented in [28]. The simulation included lateral bending, longitudinal motion, and torsional deformation dynamics. Because of the comparative ease of extracting constraint and internal forces, a Newton-Euler formulation with lumped segments is used in this paper.
The stress history at a specific location can be determined using the effort fluctuations of the compliances in the bond graph that represent the springs in Figure 1, as was done in [28] and in the lumped segment bond graph models previously published by the authors. That stress history can then be used in software such as SalomeMeca™ to perform fatigue estimation for multiaxial, non-proportional, and variable amplitude (MNV) loading scenarios. SalomeMeca™ is an open-source software that provides considerable flexibility in performing FEA simulations. A detailed description of the fatigue life estimation workflow is provided in [29].
In summary, this paper will leverage the bond graph approach, with lumped segments, to (1) represent a vertical drillstring physical apparatus, (2) generate training data for a machine learning algorithm to predict vibration, (3) predict stress history based on the physical system vibration that has been detected by the algorithm, and (4) use the stress history in SalomeMeca™ to give a fatigue prognosis.

III. METHODOLOGY
This section presents the methodology for developing the digital twin framework. Figure 2 is a flow chart showing the integration of the dynamic model, machine learning algorithm, physical system, and finite element post-processing into a digital twin capable of vibration prediction and fatigue failure prognosis. The bond graph simulations generated three types of vibrations: stick-slip, bit bounce, and whirling at three different levels of severity: high (H), medium (M), and low (L). Nine different parameter sets were used to generate the data sets. The synthetically generated data was used as the training data for the machine learning algorithm. Therefore, the trained algorithm is capable of classifying the incoming surface monitoring measurements originating from the physical model into one of the nine categories. Depending on the classification, the bond graph is reconfigured with the relevant parameter set and inputs to create that vibration scenario. The generated load fluctuation history from the bond graph is then used in the finite element model, which can prognose the fatigue life of the drillstring. The following sub-sections provide a detailed step-by-step description of the procedure.

A. THE BOND GRAPH MODEL AND ITS FUNCTION
The primary requirement of the bond graph is to simulate the potential drillstring dynamics for a given set of boundary conditions and operating parameters. Also, it should provide stress histories for fatigue life prognosis. Later damping, contact spring and friction force, and axial drag forces must be computed within the model. The number of elements can be decided based on the desired simulation speed and the modes of vibration considered. Once the simulation is set up, the bit bounce, stick-slip, and whirling scenarios can be created, and the corresponding surface-level responses can be recorded. These data are used to train the machine learning algorithms to classify unknown vibrations. These steps are described in detail in Section V. All the bond graph simulations and codes can be accessed through the author's online repository (https://github.com/mihiranpathmika).

B. THE USE OF HIDDEN MARKOV MODEL (HMM) IN SURFACE MONITORING APPLICATIONS
HMM is a statistical Markov model in which the system being modelled is assumed to be a Markov process [30] with 'hidden' states. Figure 3a illustrates the basic concept of the function of the HMM. According to that, the unobservable states can be indirectly studied by observing partially related incidents. P1 through P8 are the respective probabilities of changing one state to another indicated by the arrows. Knowing these prior probabilities, the user can deduce the likelihood of 'hidden' states by looking at the observable incident. In the current study, the same concept is proposed to be used to detect the hidden states of the drillstring. For example, as illustrated in Figure 3b, the hidden states may be 'Normal Operation' and 'Bit Bounce' while the observable incidents are two different vibration patterns that do not carry a direct meaning. If the user can determine the probabilities P1 through P8, the HMM can identify the most probable transition in states according to the changes in vibration patterns observable from the ground level. This is done using the Viterbi Algorithm. It is a dynamic programming algorithm for finding the most likely sequence of hidden states (Viterbi Path) that results in a sequence of observed events, especially in the context of Markov information sources and HMMs [31]. The concept illustrated in Figure 3  is used in the current study in classifying all three vibration conditions (bit bounce, stick-slip, and whirling) and their respective severity levels.
The user can train the HMM with different known vibration patterns for known actual states downhole. This training part will be facilitated by the validated bond graph model [21], [32], [33] as shown in Section VI.

C. FATIGUE LIFE ESTIMATION APPROACH
SalomeMeca™ [34] is used to estimate MNV loading fatigue damage. Geometry, Mesh, CodeAster, and ParaVis are the software that serve 3D modelling, meshing, solving, and post processing of finite element models. Geometry module facilitates the development of 3D models and defining geometrical entities that support the meshing process in the Mesh module. Mesh module provides enhanced flexibility in meshing by providing better control of the meshing parameters. The solver used is CodeAster™ which facilitates the definition of materials, load assignments, specifying boundary conditions, fatigue life estimation, and numerical solving. Finally, ParaVis™ [35] was used to post-process the results generated by CodeAster™.

IV. PHYSICAL SYSTEM
This section applies the proposed methodology on a laboratory-scale apparatus as proof of concept. The main intention here is to showcase that training data for a machine learning algorithm, in this case for a slender vibrating structure, can be generated using a dynamic simulation model. This approach is useful when it is not feasible to generate reliable data from the physical structure in cases such as the down-hole vibration of a drillstring.

A. APPARATUS DESIGN
As the initial step, the apparatus was designed as illustrated in Figure 4. Further details of the design and CAD models can be accessed through the author's online repository. The drill bit consists of a flat bottom with a discontinuous cam profile that meshes with a similar profile on the base (hole bottom) as shown in Figure 5. Clockwise rotation of the bit will cause axial impacts resembling bit bounce vibration. When rotated in the opposite direction, this 'chatter mechanism' locks and the flexible coupling undergoes high torsional deformation and axial shortening, lifts the drill bit and suddenly releases it from the hole bottom. This motion resembles the stick-slip type of vibration. Further, the flexible coupling provides damping in the drillstring.
The platform, where the motor is mounted, can be moved vertically up or down using threaded rods and lock nuts. This facilitates axial thrust control, mimicking the weight on bit (WoB) of a drillstring. Therefore, the apparatus can also be operated without the chatter mechanism and the flexible coupling to get stick-slip. The flexible coupling approach was used to get a more distinct stick-slip motion. With the addition of the WoB, the flexible coupling tends to move away from the central axis, causing a mass imbalance. This promotes the forward whirling action of the rotating string. Further, rubber skins attached to the flexible coupling holder create an increased friction force between the wall and the drillstring, which leads to backward whirling. Figure 6a depicts the  fabricated apparatus ready for data acquisition, and Figure 6b illustrates the bond graph simulation's 3D visualization.

B. INSTRUMENTATION AND DATA ACQUISITION
The physical apparatus was instrumented to gather measurements that are typically available on the rig floor during drilling. The vibration of the platform, motor current fluctuation, and rotational speed fluctuation with lateral vibration of the rotating table are assumed to have a correlation with the downhole vibration conditions. These measurements must be acquired as time series to feed the machine learning algorithm as testing data.
The vibration of the platform was acquired using a Kistler™ K-Shear general-purpose accelerometer. The angular speed fluctuation of the Rotating Table was captured using an AccuRange 200™ Laser Measurement Sensor and an optical encoder. The accuracies and ranges of the sensors used  are presented in Table 1. The voltage across a resistor in series with the gear motor is directly proportional to the current demand fluctuation of the motor. Based on this assumption, the motor current fluctuation was measured as the third variable. National Instruments™ (NI) USB-6008 data logger, and LabVIEW™ software was used for data acquisition using these three channels. The LabVIEW™ program used is shown in Figure 7. The data acquired is presented in Section VIII.

V. DEVELOPMENT OF THE SIMULATION MODEL A. LUMPED SEGMENT SUBMODELS AND CONNECTIONS
The bond graph rigid body submodel used to simulate the actual drillstring is shown in Figure 8a. The corresponding points of A, B, and G indicated in Figure 8b are depicted in Figure 8a. with a total of nine elements was used, successfully capturing the first two natural frequencies of the various vibration types. In Figure 8a, One Junctions (1) represent velocity nodes where efforts (i.e. forces and torques) sum to zero and Zero Junctions (0) represent effort nodes that enforce velocity constraint equations. For example, the circled 0 junction, with the directed power bonds, enforces the relative velocity equation v a = v G + v A|G , in vector form, where the relative velocity term is generated by a cross product of the relative position vector and angular velocity. The 'R01' submodels are coordinate transforms. The developed bond graph can be reconfigured and customized to simulate a given structure by conveniently modifying the number of segments and (or) by including or suppressing certain degrees of freedom. The stiffness values can be determined following the procedure presented in [36].
The friction effects can be modelled by coding the friction model shown in Figure 8 with the constitutive law of the modeler's choice. In this paper, a model presented in [37] is used, which is illustrated in Figure 9. Sample models are available for potential users and can be accessed through the online repository. The Stribeck friction, denoted as F S , displays a negative slope when velocities are low. Meanwhile, the Coulomb friction, F C , produces a constant force at all velocities, and the viscous friction, F V , resists motion with a force that is directly proportional to the relative velocity. The sum of the Coulomb and Stribeck frictions in the vicinity of zero velocity is commonly known as breakaway friction, F brk . The friction can be estimated using equations 1 to 4.
where, F is friction force, F C is Coulomb friction, F brk is breakaway friction, v brk is breakaway friction velocity, v St is Stribeck velocity threshold, v Coul is Coulomb velocity threshold, v R and v C are absolute velocities of the two bodies in contact, v is relative velocity, and f is viscous friction coefficient.

B. FLEXIBLE COUPLING MODELLING
The flexible coupling plays a major role in transferring the torque to the drill bit while allowing significant torsional deflection, creating a shortening effect that couples torsional and axial motion, and working as a vibration attenuator. Its nonlinear behaviour was characterized through a simple where θ is the angle of twist. Equation 5 was timedifferentiated and coded into a Modulated Source of Flow (MSf), and Equation 6 was coded into a modulated torsional bending stiffness C element as shown in Figure 11. Figure 11 depicts an interface model that connects adjacent rigid body segments by computing relative velocities of shear, axial, bending, and torsional springs. Interface elements other than the one at the flexible coupling are the same, except they do not have a modulated torsional stiffness or MSf with axial shortening effect. The interface models consist of four modulated transformers (MTF). Transformer, or TF, elements model a power conserving transformation wherein effort variables are related to each other by a parameter, and flow variables are related to each other by the same parameter. For example, meshing gears would be modelled as a TF, with input and output torque and angular velocities related by the same gear ratio. An MTF has a varying parameter that is provided by a modulating signal. The MTFs in the interface element multiply velocity vectors in the frame of one body by a rotation matrix, to transform the velocity to the inertial frame. The next MTF transforms the velocity from inertial to the frame of the adjacent body. This allows a calculation of velocity of point B on one body relative to point A on the adjacent body, by subtracting two vectors in the same frame. The C elements (with parallel damping elements R) integrate the relative velocity to get relative displacement components (translational or angular, as appropriate), which are multiplied by the spring stiffnesses to get internal efforts. These efforts maintain the shape of the rod, while creating stresses used in later fatigue analysis. The bond graph model can simulate bit bounce, stick-slip, and whirling vibrations.
The simulated data was stored as comma-separated values (CSV) files for later use as training data for the machine learning algorithm.

VI. VIBRATION CLASSIFICATION A. THE MACHINE LEARNING ALGORITHM
The HMM introduced in Section III-B is applied in the vibration status classification of the apparatus. As illustrated in Figure 2, the classification code developed based on the HMM algorithm can identify the type of vibration and its severity level. A brief description of the workflow of the code is presented in this section. The explanation is in line with the code presented in the author's online repository.
The HMM introduced in Section III-B is applied to the vibration status classification of the apparatus. As illustrated in Figure 2, the classification code developed based on the HMM algorithm will identify the type of vibration and its severity level. A brief description of the workflow of the code is presented in this section. The associated code is presented in the author's online repository.
This code is solely based on the open-source HMM toolbox presented in [20]. The entire code consists of ten sections. The first nine sections are to train the algorithm for the nine different vibration conditions illustrated in Figure 2. The tenth section of the code is responsible for classifying the incoming data strings to the relevant 'basket'.
The simulations were configured to generate training data for the nine vibration conditions. The experimental apparatus was then used to create the corresponding physical conditions for actual measurement and application of the machine learning algorithm. The testing data for bit bounce and stick-slip vibrations were taken for one amplitude level (medium) and then scaled to get the upper and lower extremes of vibration amplitudes. For whirling, the readings were taken for three different amplitude levels because the number of well-bore interactions is the characteristic behaviour of this type of vibration, and is different at different amplitude levels. The motor current or the angular speed does not show a considerable fluctuation for this type of vibration. It should be highlighted that the angular speed at the surface level was not giving a considerable fluctuation for different downhole vibrations of the apparatus used. This is because of the softness of the flexible coupling. Therefore only the axial vibration and the motor current fluctuation contributed significantly to the classification process, which was sufficient to distinguish the nine vibration conditions.
Both training and testing data were scaled prior to use in the algorithm. In this way, all the training and testing data can be brought in to a common scale, so pattern recognition is convenient to perform. The training process follows an iterative approach which is not computationally extensive. In the algorithm, the user can control the number of different layers in the 3D matrix. For example, it may represent different data sets from similar drillstrings. Also, the user can specify the number of Gaussian mixtures and the number of hidden states. The algorithm assumes prior and transition probabilities and optimizes them using the Expectation Maximization (EM) algorithm. When the calculated log-likelihood becomes consistent, the iteration stops, and it is considered a trained algorithm for the given data set. Figure 12 is the training curve for the algorithm, for the case of bit bounce vibration with a medium amplitude level. Once the algorithm is trained using training data, it generates some parameters unique to the data set that is used to train.
The classification is done based on the log-likelihood value estimated for an incoming test data string from the physical apparatus. This data string consists of the three readings taken simultaneously from the accelerometer, displacement sensor, and the motor current reading. The displacement sensor captures the response of angular velocity change using the optical encoder. The classifier takes all the data strings and computes the log-likelihood using the nine trained algorithms. In other words, it evaluates the similarity of the incoming test data strings to the respective states. The state which is corresponding to the maximum mean log-likelihood is presented as the vibration state of the drillstring during that time period. Once this is identified, the corresponding configuration of the bond graph can be selected to simulate and generate the relevant stress history for the fatigue life prognosis. These bond graph simulation stress histories can be made readily available as a database for a rapid fatigue prognosis.

VII. FATIGUE LIFE PROGNOSIS
This section presents the extraction of the loading history from the bond graph, reconfigured after classification of physical system vibration, and the subsequent fatigue life prognosis procedure. The maximum stress concentration occurs at the joint between the drill bit and the drillstring due to the sharp transition of cross section. This focused area was selected for further analysis.
The load fluctuation can be captured using the bond graph. Bending and shearing loads, each on two orthogonal planes, with axial and torsional loads, are the six load fluctuations that can be fed into SalomeMeca™ as time-series data. The load fluctuations were extracted from the bond graph capacitive elements that represent the bending, torsional, shear, and axial compliances at the joint considered. The extracted load fluctuations for high amplitude whirling simulation are presented in Figure 16. Meshing was done using the Mesh Tool in SalomeMeca™ Netgen 1D-2D-3d, and the meshed geometry is shown in Figure 17a. For convenience in defining the aforementioned loadings, the 'loading horns' shown in Figure 17 were used. Figure 17 illustrates the fatigue prognosis result for high amplitude whirling vibration performed throughout 20 seconds while the angular speed of the drillstring is 100 rpm (10.4 rad/s). A complete MNV fatigue analysis workflow is available in [29] for further information.
As expected, the stresses acting on the steel moving parts of the apparatus in the laboratory are not severe, hence a substantial fatigue life remains. The fatigue life estimation methodology using SalomeMeca™ was verified by comparing it with the results of a simulation performed using a commercial code.

VIII. RESULTS
A. TRAINING AND TESTING DATA SETS Figure 13 illustrates the comparison of the measurements: motor current and axial acceleration for stick-slip and bit bounce vibration conditions. Simulated data is presented in the left column, while experimental data is presented in the right column. Figures 13a, b, e, and f represent the responses for stick-slip (SS) vibration with medium amplitude (M), while Figures 13c, d, g, and h represent the responses for bit  bounce (BB) vibration in the same amplitude level. Figure 14 depicts the responses for the whirling motion at low (L), medium (M), and high (H) amplitudes. Different patterns of axial accelerations at different amplitude levels are evident. The abbreviations TR and TST stand for 'training' and 'testing', respectively. In both Figures 13 and 14, all the simulation results are scaled for comparison purposes while preserving the characteristic features.

B. CLASSIFICATION
The code does the classification based on the average log-likelihood value computed for a given sample testing data set. This scoring method selects the best candidate among the trained algorithms. Figure 15 represents a sample  classification of low amplitude whirling vibration. The algorithm has shortlisted SS-M, WH-H, WH-M and WH-L. The average log-likelihood for the given test data set has been calculated with the trained algorithm as shown in Table 2. The numerical values indicate that the average log-likelihood values are close for the three types of whirling and medium stick-slip vibration conditions, while the maximum among them is assigned to low whirling vibration.

C. STRESS HISTORY EXTRACTION AND FATIGUE LIFE PROGNOSIS
Once the classification algorithm selects the most probable vibration condition, the bond graph simulation with the respective parameter set was run to extract the load fluctuations following the procedure mentioned in Section VII. The load history extracted from the element interface adjacent to the drill bit element is presented in Figure 16. The shear impulses give the highest fluctuation in response to the frictional impulses due to the collision with the wellbore. SalomeMeca™ can handle this complex combined loading situation to determine the remaining fatigue life. The uneven distribution of remaining fatigue life on the drillstring is evident in Figure 17, which is an indication of random loading and the superposition of the six different loading fluctuations. The remaining lifetime is near infinite due to the low stress fluctuations on the drill string. Nonetheless, it is clear that the digital twin framework is able to calculate the fatigue life incorporating complex geometric features and stress concentrations, using the simulation-based estimation of loads.

IX. DISCUSSION
The novel approach introduced in this study is capable of developing and customizing a digital twin. Successful implementation of the proposed framework has the potential to reduce reliance on measurement while drilling (MWD) for vibration problem detection. When the process is implemented for a full-scale drillstring, the data downloaded after tripping operations can be utilized to validate the overall digital twin. Improved real-time fatigue prognosis can increase the reliability of the drillstring, which will reduce the risk involved in the entire project. Drillstring failures have a major impact on the overall project cost, and more careful monitoring and proactive, corrective, and preventive actions will increase the drillstring's useful lifetime. Moreover, as mentioned in [38], rig downtime due to MWD tool failure carries enormous risks, especially in challenging environments. A digital twin can be implemented as a secondary safety layer.
If a particular vibration is taking place in the lower part of the drillstring, the observations made at the surface level will depend on numerous factors such as the well depth, fluid flow speed, fluid rheology, speed of rotation, WoB, pipe geometry, drillstring orientation, type of drill bit, and the nature of the formation being drilled, to name a few. If these observations are only classified based on expert judgment and intuition, an inherent risk will be introduced due to potential human error. This motivates the implementation of a digital twin, using the framework of this paper, which has the capability to learn both through experience as well as running 'what-if' scenarios.
As with any measurement-based diagnostic approach, robustness of the machine learning algorithm training and predictions can be improved with a greater number of more accurate sensor inputs. A balance must be struck between accuracy of the prediction, and cost associated with increased sensing capability. In the current study, lateral acceleration of the rotary table could be added as an additional channel, incorporated into the real-time measurement data string. The use of a lower-powered motor may increase the torque fluctuations during stick-slip, thereby reducing classification uncertainty.
As described in [26] and [39], the bond graph of the digital twin could be expanded to include the effects of the drilling fluid. More experimentation could give a more nonlinear contact model for 'bit-rock' interaction and wellbore collisions.
When the digital twin is implemented for a particular drillstring, the data logged during tripping operations can be utilized to validate the overall digital twin as real-world data can be acquired with less complexity compared with deep wells. Finer adjustments to the digital twin can be made during this period which will be beneficial in the long run. In this way, confidence in the bond graph simulation can be improved as the machine learning algorithm solely depends on the data generated by the bond graph at higher depths.
There may be some practical limitations to using purely synthetic data as the data is generated in a near-perfect environment. Real-world data acquired through instrumentation will carry numerous noise effects. This is somewhat indicated in the results presented in Figure 13. As mentioned previously, some sensor noise can be artificially introduced into the virtual measurements, without seriously compromising the prediction ability. Therefore, more work is required to quantify the confidence of the classification algorithm in the face of varying amounts of noise or sensor error.
Open questions remain about the potential for model updating when operating conditions or the state of the system change. If for example sensor data showed a sudden change in amplitude or frequency content, this could be due to a previously-learned vibration condition, or to non-problematic changes such as a new rock formation. It could also be an artefact of sensor failure. In future, training will be expanded to include not only anticipated vibration patterns but also things like sensor faults and changes in the environment with which the system interacts.

X. CONCLUSION
The current study proposes a bond graph, finite element modelling, and machine learning-based digital twin development framework for oilwell drillstring fatigue life prognosis where direct stress measurements are almost impractical. To detect vibration problems in a physical system, a dynamic simulation model with virtual sensors was created and used to train a machine learning algorithm. The algorithm analyzed vibration measurements from the physical system and identified the type and intensity of vibration. The simulation model was then adjusted to reproduce the vibration and generate stress histories for fatigue life analysis in a finite element model. The concept was verified to be feasible in classifying the physical system's downstream vibrations based on the type and severity level through surface-level response monitoring. Finally, the study identifies and recommends potential improvements to make the framework applicable in real-world applications.
MIHIRAN GALAGEDARAGE DON (Member, IEEE) received the B.Sc. degree (Hons.) in materials engineering and the master's degree in sustainable process engineering from the University of Moratuwa, Sri Lanka, in 2009 and 2016, respectively, and the master's degree in process engineering form the Memorial University of Newfoundland, St. John's, Canada, in 2018, where he is currently pursuing the Ph.D. degree in mechanical engineering. He started as a materials engineer, in 2009, and joined academia, in 2011. Since then, he has been a lecturer, a teaching assistant, and a per-course instructor, and served universities in Sri Lanka, Australia, U.K., and Canada. His research interests include multidisciplinary/interdisciplinary research, integrating domains, such as materials engineering, mechanical engineering, process engineering, safety engineering, and machine learning. His teaching areas include engineering materials, solid mechanics, fluid flow modeling, and similitude and experimental data analysis. He received the Outstanding Teaching Assistant Award, in May 2022, from the Faculty of Engineering, Memorial University of Newfoundland.
GEOFF RIDEOUT received the B.Eng. degree in mechanical from the Memorial University of Newfoundland, in 1993, the M.A.Sc. degree in mechanical engineering from Queen's University, Kingston, ON, Canada, and the Ph.D. degree in mechanical engineering from the University of Michigan.
Before his M.A.Sc. degree, he worked in telecommunications equipment manufacturing and building systems consulting. He has lectured with the University of Michigan and the Humber Institute for Advanced Technology and Applied Learning, Toronto. He is currently a Professor with the Memorial University of Newfoundland, teaching mechanics, modeling, and design. His research interests include automated modeling, vibrationassisted drilling, vehicle dynamics and control, and modal testing for nondestructive evaluation.