Fault Recognition of Indicator Diagrams Based on the Dynamic Time Warping Distance of Differential Curves

Oil recovery with pumping units is widely used in oilﬁeld development at present. The management level of pumping units is related to the overall economic beneﬁt of oilﬁeld. In order to eﬀectively control the production management of pumping wells, it is necessary to take all the production data to formulate a reasonable working system and make continuous analyses about the daily management level of pumping wells. The analysis and interpretation of the indicator diagram is a direct understanding way about the situation of deep well pumps in petroleum engineering. However, the complicated practical oilﬁeld conditions often lead to the distortion of regular indicator diagrams, resulting in the low eﬃciency of fault-type diagnosis and wrong recognition. A new method of identifying the fault type of indicator diagrams is proposed by using the dynamic time warping (DTW) distance, through which a two-dimensional indicator diagram is transformed into a one-dimensional diﬀerential curve. The experimental results of real indicator diagrams show that the method is eﬀective for the type diagnosis of indicator diagrams with high accuracy and fast speed.


Introduction
Rod pumping is the commonly used method for mechanical oil extraction. In order to understand the real underground working situation of the deep pumping wells, the indicator diagram records the real-time changes of curves related to the changes of states of light bars. A closed curve called an indicator diagram is drawn by a complete up-and-down stroke, which contains the rich information of the pump and the rod and their corresponding working situations. Indicator diagrams are viewed as one of the important basic sources in the fault diagnosis of pumping wells and the evaluation of oil production [1][2][3]. erefore, the intelligent identification and analyses of indicator diagrams are quite significant for petroleum engineering and production management [4,5]. e actual indicator diagrams of pumping wells are the real reflection of the complex process of the deep pumping wells and the sucker rods. e curves in the indicator diagrams possibly fluctuate and change frequently, making the diagnosis result easily influenced by the subjective and objective factors such as the experiences and technical levels of the interpreter, so the efficiency and accuracy of the pumping system may be restricted to some extent [6,7]. Meanwhile, with the rapid development of computer sciences, many indicator diagrams and their corresponding types have been digitalized and defined in the database [8], which can be easily applied to the fault diagnosis in the real oilfields through the database. e existing digital resources are helpful to automatically identify the shape and characteristics of indicator diagrams, which have become a hot spot in the research of oil development [9,10]. Currently, some methods, e.g., the back-propagation (BP) neural networks [11,12], the radial basis function (RBF) [13], the extreme learning machine [14], and the convolution neural networks (CNNs) [15], have been applied to the fault diagnosis of pumping units and are gradually replacing the traditional artificial analysis.
However, due to the internal mechanism of these methods, they possibly suffer from the following disadvantages: (1) when extracting features, the input of numerous displacement-load data of indicator diagrams may seriously affect the complex internal mapping structure of neural networks so that the diagnostic accuracy of the model is lowered; (2) some models, e.g., CNNs, are computationally intensive and have a large number of parameters to set, requiring large storage space and memory, which is contradictory to the low-level hardware conditions in the real field; (3) fault diagnoses are based on the detection of contour features of indicator diagrams, but some models sometimes cannot effectively extract these features.
To address the abovementioned issues, the key solution in the fault diagnosis of pumping units can be summarized as extracting and recognizing contour features of indicator diagrams effectively. In this paper, based on the dynamic time warping (DTW) distance of time series [16], a new method for improving the identification of indicator diagrams is proposed. is method first uses the differential curves to convert the two-dimensional closed curves of the indicator diagrams into the one-dimensional curves and then identify the type of indicator diagrams through the DTW distance [17,18]. e experimental results show that our method can effectively distinguish similar curves of indicator diagrams, and the fault recognition for the unknown indicator diagrams is accurate and fast. , (x 2 , y 2 ), . . ., (x n , y n )}, where (x i , y i ) (i � 1,2, . . ., n) stands for the coordinates of each point on the sides of ABCD. Note that these points (x i , y i ) do not necessarily represent the four vertexes A, B, C, or D, but may be any points on the side of the quadrangle. e definition of Q is as follows:

The Main Idea of the Proposed Method
where x max and y max are, respectively, the maximum values in the horizontal and vertical directions in ABCD. Since an indicator diagram with no fault is actually a parallelogram, a fault-free indicator diagram is illustrated using a parallelogram ABCD in Figure 1, and the turning point Q just happens to be C. e up stroke is ABC and the down stroke is CDA. e horizontal axis stands for the displacement of the light rod and the vertical axis is the load of the light rod.

e Reverse-Translational Curve of the Down-Stroke
Curve.
e fault of pumping units leads to the failure of making the indicator diagram a parallelogram, meaning the up stroke and the down stroke cannot form a parallelogram. Under the circumstances, the specific fault should be recognized using indicator diagrams. To identify the fault type, one of the possible ways is to calculate the difference between the down stroke and the up stroke and then determine the fault type based on the difference, which makes obtaining the reverse-translational curve of the down-stroke curve a precondition. A reverse curve is defined as a curve like the letter "S," formed by two curves bending in opposite directions or produced by the joining of two curves that turn in opposite directions. For a down-stroke curve CDA that is composed of the line segments of CD and DA, its reverse curve symmetrically about A, called AD''C'', should be calculated by a symmetrical transformation of CDA. For convenience, suppose A coincides with the origin O, i.e., A is in the same position as the origin O. If the coordinate of D is (x D , y D ), then its corresponding transformed coordinate of (2) e symmetric transformation from CDA to its reverse curve AD''C'' is shown in Figure 2.
en, each point on AD''C'' should be translated by, respectively, moving a distance of x max in the positive horizontal direction and a distance of y max in the positive vertical direction to obtain a new translational curve

Substitute equation (2) into equation (3), and then the coordinate of points on
Finally, the reverse-translational curve (i.e., C'D'A') of the original down-stroke curve is shown in Figure 3. Since the theoretical ABCD in Figure 1 is a parallelogram, now B coincides with D', O coincides with C', and so does C and A', meaning the two curves OBC and C'D'A' are actually same. However, in the real situation, the indicator diagram is not always a parallelogram due to the fault of pumping units, so these two curves will not always coincide under the real circumstances.

Introduction to the Differential Curve.
e difference function is widely used in mathematics, physics, and informatics and is a tool for studying discrete mathematics, reflecting a change between discrete quantities. e differential curve is used to characterize the difference function. e shapes of theoretical indicator diagrams drawn from the fault-free pumping units are parallelograms. Since the probability of two or more equipment's failure leading to the same symmetrical changes in the up stroke and down stroke of the indicator diagrams is quite small, the different shapes of differential curves can be used to describe the states or the fault types of pumping units.
For a two-dimensional diagram ABCD with a specific kind of fault information from pumping units, it is difficult to directly measure the difference between the up stroke and the down stroke, causing a challenge to recognize the fault type. However, it can be inferred that if the difference between the up-stroke curve and the reverse-translational curve of the down stroke is transformed to a one-dimensional curve, which can be easily plotted through a differential curve, it will be much easier for interpreters to judge the fault type since the two-dimensional shapes of indicator diagrams have been expressed by one-dimensional differential curves. e differential curve is computed by the reverse-translational curve of the down stroke minus the up-stroke curve of the indicator diagram, through which the recognition of the fault type for pumping units is highly simplified.
Suppose the up-stroke curve is defined as f rev−tran (·), respectively, are the functions defining the relations between the horizontal axis x i and the vertical axis (U i and RT i ), meaning each coordinate of the up-stroke curve is (x i , U i ) and that of the reverse-translational curve of the down stroke is (x i , RT i ). RT i can be obtained by equation (4) and U i is directly obtained from the original data. en, the differential curve is formulated as For example, Figure 4 shows the realization of the differential curve abcd using the indicator diagram corresponding to the fault of missing fixed valves, i.e., the quadrangle ABCD in Figure 4 is used as the typical fault of missing fixed valves in indicator diagrams, where ABC represents the up stroke, CDA stands for the down stroke, and AD' is parallel to CD. As mentioned previously, the quadrangle ABCD should be a parallelogram when the pumping units have no any faults. However, since AD' rather than AB is parallel to CD, the quadrangle ABCD fails to be a parallelogram, and then the differential curve abcd is obtained by equation (5).
ree theoretical differential curves corresponding to three types of indicator diagrams and their fault types are shown in Figure 5. It is easily inferred that if the differential curve abcd in Figure 4 is in a fault-free state of pumping units, point b should coincide with point c, shown as the differential curve of "Working properly" in Figure 5. It is seen that the theoretical differential curves of different faults of pumping units are obviously different. However, due to the actual complex underground situation, the actual differential curves are quite unstable and changeable, possibly quite different from those theoretical fault types of Mathematical Problems in Engineering differential curves, making it difficult for the type recognition of differential curves.

DTW Distance.
To address the abovementioned issue, the DTW distance, originally used in speech recognition for similarity research of time series, is introduced to recognize the differential curves in complicated conditions [19]. By DTW, the distance between two time series with different lengths can be calculated accurately. In order to realize the time-axis scaling in a time series, the similarity waveforms of time series should be aligned on the time axis. According to the minimum cost of the time warping path, the DTW distance is used to measure the similarity of two time series with different lengths, in which the points are not required a one-to-one mapping. For two time series X and Y, some parameters are introduced first. Suppose |X| and |Y| are the lengths of these two time series; X[1: i] (1 ≤ i ≤ |X|) is the subseries varying from the first element in the X series to the i-th element; where D min writes For example, as shown in Figure 6, take the two time series (X � (3, 6, 5, 3, 4) and Y � (3, 4, 5, 6, 2, 3)) to illustrate the calculation of the DTW distance. In Figure 6, X is the row vector and Y is the column vector, so i ranges from 1 to 5 and j ranges from 1 to 6. For a one-dimensional time series, erefore, according to equations (6) and (7), Row 1 (1 ≤ i ≤ 5, j � 1) of Figure 6 is calculated:  different lengths. Suppose there are two differential curves of indicator diagrams, one of which has been recognized as a known fault type of pumping units; the other is unknown. If the DTW distances between the two differential curves are close enough, they can be considered as the same fault type; if not, the unknown curve should be calculated with other differential curves with a known fault type to obtain the DTW distance for similarity evaluation.
us, the DTW distance can be applied to evaluate the fault type between two differential curves of indicator diagrams.

e Procedure of the Proposed Method.
e procedure of the proposed method is described as follows: Step 1: input the original indicator diagram and determine the turning point, the up stroke, and the down stroke, respectively.
Step 2: perform the reverse-translational transformation upon the down stroke and then obtain the differential curve, called diff, of the indicator diagram according to equation (5).
Step 3: using some differential curves with alreadyknown fault types as the control group, the DTW distance between diff and the control group is calculated according to equation (6).
Step 4: if the DTW distance between diff and the curve in the control group is small enough or smaller than a threshold, they are considered as the same type. If not, try another curve in the control group until the fault type of diff can be determined.

Experimental Results and Analyses
In order to test the efficiency of the proposed method, the experiments were performed using the actual indicator diagram dataset, which contains 150 actual indicator diagrams and has altogether 5 types: gas influence (sample size � 45), insufficient supply of fluids (sample size � 39), not-filled pump (sample size � 22), oil well paraffinication (sample size � 19) and working properly (sample size � 25), in which the first four are fault types and the last one means the pumping units have no any faults. e experimental environment is Intel Core i5-2450M CPU, 4G memory, and Windows 10. Twelve randomly selected actual indicator diagrams as well as their types are shown in Figure 7, and their corresponding differential curves are plotted according to equation (5), also as shown in Figure 7. Each indicator diagram is named from #1 to #12 successively. en, based on the abovementioned differential curves, the DTW distances are obtained using our method, as shown in Table 1. e values in the grid are the DTW distances between the different differential curves, in which the smallest distances are highlighted with a bold font. e two curves with the smallest distance can be considered as the same type of indicator diagrams. It is seen that most indicator diagrams with smallest distances are proven to be the same type by comparing the types already shown in Figure 7. For example, the closest curve for #4 is #9, whose type is "working properly." e closest curve for #2 is #12, and for #12, the closest curve is #10. e curve types of #2, #10, and #12 are all "gas influence." ere is only one mistake, which is that the closest curve for #11 (insufficient supply of fluids) is #5 (gas influence), according to Table 1. e reason is the curves of "insufficient supply of fluids" and those of "gas influence" sometimes are quite similar in some conditions. erefore, the accuracy of fault recognition for these 12 samples is 91.7%. en, our method was compared to some other typical methods for fault recognition of indicator diagrams including BP networks [12], extreme learning machine [14], and RBF [20] in order to further verify its effectiveness. e tests were performed using all the 150 samples in the actual dataset of indicator diagrams. Table 2 shows the training time and fault diagnosis accuracy of different methods. As can be seen from Table 2, our method performs best in the accuracy and the second best in the speed, only slightly slower than the extreme learning machine.

Conclusion
Based on the characteristics of the indicator diagrams, this paper establishes a method of recognizing the fault type of pumping units using the DTW distance of differential curves that is obtained through the difference between the up-stroke curve and the reverse-translational curve of the down-stroke curve. e experimental results show that the proposed method is accurate and fast, suitable for the complex real situations of oilfields.

Data Availability
e data used to support this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that they have no conflicts of interest. Mathematical Problems in Engineering 7