# Intelligent Stuck Pipe Type Recognition Using Digital Twins and Knowledge Graph Model
## Materials and Methods
### Identification of Sticking Degree Based on Physical Model and Particle Swarm Optimization Algorithm
#### 2.1.1 Physical Model of Hookload and Torque Based on 3D Borehole
The acceleration factors c1 and c2  
Figure 2: Distribution of calculated hookload and measured POOH value for well M.  
represent the acceleration weight of each particle moving towards the individual optimal position and the global optimal position, and their values influence the convergence and velocity of the particle. The appropriate control parameters can effectively enhance the particle optimization ability and convergence speed. (3) The initialization of particle space depends on the concrete problems, such as random initialization and linear initialization. Reasonable selection of particle initialization space can shorten the search time and improve the efficiency of the algorithm. The particle swarm optimization is used to solve the problem of distance between two curves to set one point on the curve as a particle. N particles on each curve are taken, and the given curve is set as: \(\mathrm{P}(\mathrm{u})=\sum_{i=0}^{m}d_{i}N_{i,u}(u)\), \(\overline{\mathrm{P}}(\overline{\mathrm{u}})=\sum_{i=0}^{n}\overline{d_{i}}N _{i,\overline{u}}(\overline{u})\). Take N particles on each curve. Each example is represented by geometric position x_i (I = 1, 2, \(\cdots\), N) and velocity vector of points v \(x_{i}(i=1,2,\cdots,N)\). The point is shifted along the velocity \(v_{i}(i=1,2,\cdots,N)\) direction to the collection position of the new point \(x_{i}^{*}=x_{i}+v_{i}(i=1,2,\cdots,N)\). The points on the two curves are matched with \(x_{i}\) and \(\overline{x_{i}}(i=1,2,\cdots,N)\). The distance between them is \(||x_{i}-\overline{x_{i}}||(i=1,2,\cdots,N)\). The shortest distance between the points N is \(\mathrm{min}\left\{||x_{i}-\overline{x_{i}}||\right\}(i=1,2,\cdots,N)\). In the subsequent iteration process, \(||x_{i}-\overline{x_{i}}||\) and \(\mathrm{min}\{||x_{i}-\overline{x_{i}}||\}(i=1,2,\cdots,N)\) constantly change. The shortest distance \(x_{i}\) and \(\overline{x_{i}}\) in the history is called as the individual optimal position of the ith pair, and \(||x_{i}-\overline{x_{i}}||\) the \(\mathrm{min}\{||x_{i}-\overline{x_{i}}||\}(i=1,2,\cdots,N)\) in the history is called as the population optimal position. The optimal position of the population is used as the shortest distance approximate value between curves. The distance between curves can be obtained by constantly updating the individual optimal position and the population optimal position by iteration. \[\mathrm{P}=1-((\mathrm{b}/\mathrm{b}_{\mathrm{n}})/(\mathrm{a}/\mathrm{a}_{ \mathrm{m}})) \tag{18}\]  
P is stuck pipe degree, b is distance between measured value and calculated value during the process of pipe sticking, a is distance between measured value and calculated value before stuck pipe, \(\mathrm{b}_{\mathrm{n}}\) is number of stuck point sequences, and \(\mathrm{a}_{\mathrm{m}}\) is number of point sequences before stuck pipe. Figure 3 shows the measured POOH hookload value during the process of drill pipe sticking. The orange scatter points in the figure indicate the measured POOH hookload of the well, which gradually deviates to the route with high friction coefficient, the approximate deviation degree of the sticking pipe can be obtained by Figures 4 and 5. Figure 3: Distribution of measured hookload for stuck pipe well. We combine Figures 4 and 5, PSO and Hookload model to obtain the degree of stuck pipe. The results are shown in Table 4.