Fault diagnosis method for gas ultrasonic flowmeter based on improved artificial vole algorithm
By improving the artificial lemming algorithm and generating sample sets from Markov transition fields, pre-training and training the convolutional neural network model, and adding a multi-head self-attention mechanism, the problem of accurate differentiation in fault diagnosis of gas ultrasonic flowmeters was solved, thereby improving the measurement reliability and industrial automation level of the flowmeter.
Patent Information
- Application Number
- CN202511449858.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-11
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2045-10-11
AI Technical Summary
The lack of accurate differentiation of specific faults in existing ultrasonic gas flow meters leads to decreased flow meter performance and measurement errors, which in turn affects the improvement of industrial automation levels.
An improved artificial lemming algorithm is adopted. By acquiring echo signal data and power quality disturbance data of gas ultrasonic flow meters, a migration model and source domain sample set are generated using Markov transition fields. The convolutional neural network model is pre-trained and trained, and a multi-head self-attention mechanism is added to achieve fault diagnosis.
It enables accurate differentiation of specific faults in gas ultrasonic flow meters, improves the measurement reliability and operational stability of flow meters, and enhances the level of industrial automation.
Smart Images

Figure CN120927106B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of flow detection, in particular to a gas ultrasonic flowmeter fault diagnosis method and device based on an improved artificial vole algorithm and a storage medium. BACKGROUND
[0002] The gas ultrasonic flowmeter has become a core device for gas metering due to its high precision, low maintenance cost and strong adaptability, and is widely used in long-distance pipeline and liquefied natural gas (LNG) industrial scenarios.
[0003] In the long-term uninterrupted operation process, the ultrasonic transducer in the flowmeter is prone to performance degradation due to aging or surface contamination, which further leads to metering deviation. Therefore, timely and accurate diagnosis of fault types not only helps engineers quickly locate problems and perform effective maintenance, but also provides a basis for flowmeter manufacturing enterprises to optimize product design and quality control. Moreover, fine fault diagnosis of ultrasonic flowmeters not only helps to improve their measurement reliability and operation stability, but also has important practical significance for promoting the improvement of industrial automation level.
[0004] Traditional fault diagnosis methods mainly rely on manual experience and monitoring of basic physical parameters. With the continuous improvement of the complexity and automation level of industrial equipment, the fault diagnosis technology of the gas ultrasonic flowmeter is transforming from single-parameter threshold method to multi-dimensional intelligent analysis. In order to quickly locate and repair faults, machine learning methods have been used to diagnose and predict the data of ultrasonic flowmeters. However, current research on fault diagnosis of gas ultrasonic flowmeters mainly focuses on performance monitoring of the flowmeter itself, and lacks accurate differentiation of specific faults.
[0005] In view of the problem that the related art lacks accurate differentiation of specific faults of the gas ultrasonic flowmeter, no effective solution has been proposed. SUMMARY
[0006] In this embodiment, a gas ultrasonic flowmeter fault diagnosis method, device and storage medium based on an improved artificial vole algorithm are provided to solve the problem of lack of accurate differentiation of specific faults of the gas ultrasonic flowmeter in the related art.
[0007] In a first aspect, a gas ultrasonic flowmeter fault diagnosis method based on an improved artificial vole algorithm is provided in this embodiment, and the method comprises:
[0008] Obtaining echo signal data and power quality disturbance data of a gas ultrasonic flowmeter;
[0009] Generating a transition model sample set according to the echo signal data and the Markov transition field;
[0010] generate a source domain sample set according to the power quality disturbance data and the Markov transition field;
[0011] pre-train a preset convolutional neural network model according to the source domain sample set, to obtain a migrated convolutional neural network model; in the pre-training process, an improved artificial vole algorithm is used to optimize and adjust parameters of the model; the improved artificial vole algorithm is an artificial vole algorithm that uses an iteration number as a degree-of-freedom parameter of a t-distribution variational operator to disturb individual positions of voles;
[0012] construct a first model according to the migrated convolutional neural network model;
[0013] train the first model according to the migration model sample set, to obtain a target model; in the model training process, the improved artificial vole algorithm is used to optimize and adjust parameters of the model;
[0014] perform fault diagnosis according to the target model and echo signal data to be diagnosed.
[0015] In some embodiments, generating a migration model sample set according to the echo signal data and the Markov transition field comprises: converting the echo signal data into a first two-dimensional feature map by using the Markov transition field, and constructing the migration model sample set according to the first two-dimensional feature map.
[0016] The method further comprises: generating a source domain sample set according to the power quality disturbance data and the Markov transition field, which comprises: converting the power quality disturbance data into a second two-dimensional feature map by using the Markov transition field, and constructing the source domain sample set according to the second two-dimensional feature map.
[0017] In some embodiments, constructing a first model according to the migrated convolutional neural network model comprises:
[0018] The output layer of the migrated convolutional neural network model is increased with a multi-head self-attention mechanism; the multi-head self-attention mechanism comprises a plurality of self-attention modules, and each module corresponds to a different representation subspace.
[0019] In some embodiments, performing fault diagnosis according to the target model and echo signal data to be diagnosed comprises:
[0020] converting the echo signal data to be diagnosed into a target two-dimensional feature map according to the Markov transition field;
[0021] inputting the target two-dimensional feature map into the target model, and outputting a fault category label by the target model; the fault category label corresponds to a fault type.
[0022] According to the fault category label, fault diagnosis is performed.
[0023] In some embodiments, in the pre-training process, the improved artificial vole algorithm is used to optimize and adjust the parameters of the model, including: randomly initializing search individuals and defining the parameters of the artificial vole search algorithm, calculating the fitness value of each search individual, and determining the position of the individual with the optimal fitness value after sorting.
[0024] In some embodiments, in the pre-training process, the improved artificial vole algorithm is used to optimize and adjust the parameters of the model, and further includes: using the improved artificial vole algorithm to optimize and adjust the learning rate, the number of neurons, and the linear transformation of the model.
[0025] In some embodiments, in the model training process, the improved artificial vole algorithm is used to optimize and adjust the parameters of the model, including: in the model training process, the improved artificial vole algorithm is used to optimize and adjust the number of attention heads of the model.
[0026] In some embodiments, the method further includes: adjusting the mutation amplitude according to the increase in the number of iterations in the training process.
[0027] In a second aspect, the embodiment provides a gas ultrasonic flowmeter fault diagnosis device based on an improved artificial vole algorithm, the device comprising:
[0028] An acquisition module is configured to acquire echo signal data and power quality disturbance data of a gas ultrasonic flowmeter.
[0029] A first generation module is configured to generate a migration model sample set according to the echo signal data and a Markov transition field.
[0030] A second generation module is configured to generate a source domain sample set according to the power quality disturbance data and the Markov transition field.
[0031] A pre-training module is configured to pre-train a preset convolutional neural network model according to the source domain sample set to obtain a migrated convolutional neural network model. In the pre-training process, an improved artificial vole algorithm is used to optimize and adjust the parameters of the model. The improved artificial vole algorithm is a t-distributed variational operator with the number of iterations as a degree of freedom parameter to disturb the position of a vole individual.
[0032] A construction module is configured to construct a first model according to the migrated convolutional neural network model.
[0033] The training module is configured to perform model training on the first model according to the migration model sample set, to obtain a target model; and in the model training process, the improved artificial vole algorithm is used to optimize and adjust parameters of the model.
[0034] The diagnosis module is configured to perform fault diagnosis according to the target model and echo signal data to be diagnosed.
[0035] In a third aspect, the embodiments provide a computer-readable storage medium having a computer program stored thereon, and the computer program, when executed by a processor, implements the steps of the gas ultrasonic flowmeter fault diagnosis method based on the improved artificial vole algorithm according to the first aspect.
[0036] Compared with the related art, the gas ultrasonic flowmeter fault diagnosis method, device and storage medium based on the improved artificial vole algorithm provided in the embodiments, by obtaining echo signal data and power quality disturbance data of a gas ultrasonic flowmeter, generating a migration model sample set according to the echo signal data and a Markov transition field, generating a source domain sample set according to the power quality disturbance data and the Markov transition field, pre-training a preset convolutional neural network model according to the source domain sample set to obtain a migrated convolutional neural network model, optimizing and adjusting parameters of the model by using the improved artificial vole algorithm in the pre-training process, the improved artificial vole algorithm being an artificial vole algorithm that uses an iteration number as a degree of freedom parameter to disturb the position of a vole individual, constructing a first model according to the migrated convolutional neural network model, performing model training on the first model according to the migration model sample set to obtain a target model, optimizing and adjusting parameters of the model by using the improved artificial vole algorithm in the model training process, and performing fault diagnosis according to the target model and echo signal data to be diagnosed, solves the problem that there is a lack of accurate differentiation of specific faults of a gas ultrasonic flowmeter in the prior art, and achieves accurate differentiation of specific faults of a gas ultrasonic flowmeter.
[0037] Details of one or more embodiments of the present application are presented in the following drawings and description to make other features, objects and advantages of the present application more apparent. BRIEF DESCRIPTION OF DRAWINGS
[0038] The accompanying drawings illustrated herein are used to provide further understanding of the present application, constitute a part of the present application, and the illustrative embodiments of the present application and their descriptions are used to explain the present application, and do not constitute improper limitations on the present application. In the drawings:
[0039] Figure 1 is a hardware structure block diagram of a terminal for a gas ultrasonic flowmeter fault diagnosis method based on an improved artificial vole algorithm provided by the embodiments of the present application;
[0040] Figure 2 is a flow chart of a gas ultrasonic flowmeter fault diagnosis method based on an improved artificial traveling wave algorithm provided by an embodiment of the present application;
[0041] Figure 3 is a flow chart of a fault diagnosis algorithm based on MTF and an improved Darknet19 provided by an embodiment of the present application;
[0042] Figure 4 is a Markov image generation process schematic diagram provided by an embodiment of the present application;
[0043] Figure 5 is a flow chart of a TALA algorithm provided by an embodiment of the present application;
[0044] Figure 6 is a fitness value curve diagram of different algorithms of an embodiment of the present application;
[0045] Figure 7 is a confusion matrix of an MTF-Darknet19-MSA model of an embodiment of the present application;
[0046] Figure 8 is a confusion matrix of an MTF-ALA-Darknet19 model of an embodiment of the present application;
[0047] Figure 9 is a confusion matrix of an MTF-TALA-Darknet19 model of an embodiment of the present application;
[0048] Figure 10 is a confusion matrix of an MTF-TALA-Darknet19-MSA model of an embodiment of the present application;
[0049] Figure 11 is a fault diagnosis performance comparison schematic diagram of different models of an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to more clearly understand the purpose, technical scheme and advantages of the present application, the present application is described and explained below in combination with the drawings and embodiments.
[0051] Unless otherwise defined, technical terms or scientific terms used in the present application shall have the same meaning as those commonly understood by a person of ordinary skill in the art to which the present application belongs. The terms "one", "a", "an", "the", "these", and similar terms in the present application do not mean "only one" or "exactly one", but can mean "one or more" or "at least one". The terms "include", "contain", "have", and any variant thereof in the present application are intended to cover the non-exclusive inclusion; for example, a process, method, and system, product or device containing a series of steps or modules (units) are not limited to the listed steps or modules (units), but can include steps or modules (units) not listed, or can include other steps or modules (units) inherent to the process, method, product or device. The terms "connect", "connect", "couple" and the like in the present application are not limited to physical or mechanical connection, but can include electrical connection, whether direct or indirect. The term "multiple" in the present application means two or more. The term "and / or" describes the association between the associated objects, which means that there can be three relationships, for example, "A and / or B" can mean that A exists alone, A and B exist together, and B exists alone. Generally, the character " / " represents the "or" relationship between the associated objects. The terms "first", "second", "third" and the like in the present application are only used to distinguish similar objects, and do not represent a specific order of the objects.
[0052] The method embodiments provided in the present embodiment can be executed in a terminal, a computer or a similar computing device. For example, the method embodiments are executed on a terminal, Figure 1 is a hardware structure block diagram of a terminal for a gas ultrasonic flowmeter fault diagnosis method based on an improved artificial vole algorithm provided by the present embodiment. As shown in Figure 1 , the terminal can include one or more (only one is shown in Figure 1 ) processor 102 and memory 104 for storing data, wherein the processor 102 can include but not limited to processing device such as microprocessor MCU or programmable logic device FPGA. The above terminal can also include transmission device 106 for communication function and input / output device 108. Those skilled in the art can understand that Figure 1 The structure shown is only schematic, which does not limit the structure of the above terminal. For example, the terminal can include more or less components than those shown in Figure 1 , or have a different configuration from that shown in Figure 1 .
[0053] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to a fault diagnosis method for a gas ultrasonic flow meter based on an improved artificial lemming algorithm in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0054] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0055] This embodiment provides a fault diagnosis method for gas ultrasonic flow meters based on an improved artificial lemming algorithm. Figure 2 This is a flowchart of a gas ultrasonic flow meter fault diagnosis method based on an improved artificial lemming algorithm provided in an embodiment of this application, as shown below. Figure 2 As shown, the process includes the following steps:
[0056] Step S201: Obtain echo signal data and power quality disturbance data from the gas ultrasonic flow meter.
[0057] In this step, a one-dimensional time series signal from the ultrasonic gas flow meter is acquired, namely the echo signal data and power quality disturbance data of the ultrasonic gas flow meter.
[0058] Step S202: Generate a migration model sample set based on the echo signal data and the Markov transition field.
[0059] In this step, the original data (i.e., echo signal data) is transformed using a Markov transition field (MTF) to convert one-dimensional echo signal data of a gas ultrasonic flowmeter into a two-dimensional feature map with corresponding labels, and multiple two-dimensional feature maps with corresponding labels are used as a migration model sample set. For example, the labels are used to identify fault categories, and the labels can be natural numbers, such as label 1 identifying the fault category as aging, label 2 identifying the fault category as contamination, label 3 identifying the fault category as aging and contamination, and label 4 identifying the fault category as normal, and so on.
[0060] In step S203, a source domain sample set is generated according to the power quality disturbance data and the Markov transition field.
[0061] In this step, the original data (i.e., power quality disturbance data) is transformed using a Markov transition field (MTF) to convert one-dimensional power quality disturbance data of a gas ultrasonic flowmeter into a two-dimensional feature map with corresponding labels, and multiple two-dimensional feature maps with corresponding labels are used as a source domain sample set. For example, the labels are used to identify fault categories, and the labels can be natural numbers, such as label 1 identifying the fault category as aging, label 2 identifying the fault category as contamination, label 3 identifying the fault category as aging and contamination, and label 4 identifying the fault category as normal, and so on.
[0062] In step S204, a pre-trained convolutional neural network model is obtained by pre-training a preset convolutional neural network model according to the source domain sample set; during the pre-training process, the parameters of the model are optimized and adjusted using an improved artificial lemming algorithm; the improved artificial lemming algorithm is an artificial lemming algorithm that uses a t-distribution variational operator with the number of iterations as a degree of freedom parameter to perturb the positions of lemming individuals.
[0063] In this step, the preset convolutional neural network model can be a lightweight and efficient convolutional neural network model, such as a Darknet19 model. The pre-training model inputs the source domain sample into the Darknet19 model for pre-training, and simultaneously optimizes and adjusts the parameters (learning rate, number of neurons, and linear transformation) of the model using the TALA algorithm. The TALA algorithm refers to an improved artificial lemming algorithm (ALA) that uses a t-distribution variational operator with the number of iterations as a degree of freedom parameter to perturb the positions of lemming individuals. The TALA algorithm is an improved version of the artificial lemming algorithm (Artificial Lemming Algorithm, ALA), and the core innovation lies in introducing a t-distribution variational operator to dynamically perturb the positions of lemming individuals with the number of iterations as a degree of freedom parameter, thereby enhancing the global search capability and convergence efficiency of the algorithm.
[0064] In step S205, a first model is constructed according to the migrated convolutional neural network model.
[0065] In this step, the trained model can provide effective feature representation for subsequent fault diagnosis tasks through the feature information learned by the source domain. Finally, a multi-head self-attention mechanism MSA is added to the output layer of the migrated Darknet19 model to construct a first model, which is denoted as a Darknet19-MSA model. MSA is composed of multiple self-attention modules, each module corresponds to a different representation subspace, so that the model can learn more rich information from multiple angles.
[0066] In step S206, the first model is trained according to the migration model sample set to obtain a target model; during the model training process, the improved artificial vole algorithm is used to optimize and adjust the parameters of the model.
[0067] In this step, the training set is input into the pre-trained Darknet19-MSA model for model training, and the TALA strategy is used to optimize the number of attention heads and other hyperparameters during the training process. The hyperparameters are adjusted according to the model training feedback, and the iteration optimization is performed until the performance on the training set reaches the optimal level.
[0068] In step S207, fault diagnosis is performed according to the target model and the echo signal data to be diagnosed.
[0069] In this step, the echo signal data to be diagnosed is converted into a target two-dimensional feature map according to the Markov transition field; the target two-dimensional feature map is input into the target model, and the target model outputs a fault category label; the fault category label corresponds to a fault type; and fault diagnosis is performed according to the fault category label.
[0070] Through the above steps, the echo signal data of the gas ultrasonic flowmeter and the power quality disturbance data are obtained; a migration model sample set is generated according to the echo signal data and the Markov transition field; a source domain sample set is generated according to the power quality disturbance data and the Markov transition field; a pre-trained convolutional neural network model is obtained by pre-training the preset convolutional neural network model according to the source domain sample set; during the pre-training process, the improved artificial vole algorithm is used to optimize and adjust the parameters of the model; the improved artificial vole algorithm is a t-distributed variational operator with iteration number as a degree of freedom parameter to disturb the position of the artificial vole individual; a first model is constructed according to the migrated convolutional neural network model; a target model is obtained by training the first model according to the migration model sample set; during the model training process, the improved artificial vole algorithm is used to optimize and adjust the parameters of the model; and fault diagnosis is performed according to the target model and the echo signal data to be diagnosed. The problem of lacking accurate differentiation of specific faults of the gas ultrasonic flowmeter in the prior art is solved, and accurate differentiation of specific faults of the gas ultrasonic flowmeter is achieved.
[0071] In some embodiments, the method further comprises: generating the transition model sample set according to the echo signal data and the Markov transition field, including: converting the echo signal data into a first two-dimensional feature map by using the Markov transition field, and constructing the transition model sample set according to the first two-dimensional feature map; and generating the source domain sample set according to the power quality disturbance data and the Markov transition field, including: converting the power quality disturbance data into a second two-dimensional feature map by using the Markov transition field, and constructing the source domain sample set according to the second two-dimensional feature map.
[0072] In some embodiments, the method further comprises: constructing the first model according to the transferred convolutional neural network model, including: adding a multi-head self-attention mechanism to an output layer of the transferred convolutional neural network model; and the multi-head self-attention mechanism including a plurality of self-attention modules, each module corresponding to a different representation subspace.
[0073] In some embodiments, the method further comprises: performing the fault diagnosis according to the target model and the echo signal data to be diagnosed, including: converting the echo signal data to be diagnosed into a target two-dimensional feature map according to the Markov transition field; inputting the target two-dimensional feature map into the target model, and outputting a fault category label by the target model; the fault category label corresponding to a fault type; and performing the fault diagnosis according to the fault category label.
[0074] In some embodiments, the method further comprises: optimizing and adjusting the parameters of the model by using the improved artificial marmot algorithm during the pre-training process, including: randomly initializing search individuals and defining parameters of the artificial marmot search algorithm, calculating fitness values of each search individual, and determining positions of the individuals with optimal fitness values after sorting.
[0075] In some embodiments, the method further comprises: optimizing and adjusting the learning rate, the number of neurons, and the linear transformation of the model by using the improved artificial marmot algorithm during the pre-training process.
[0076] In some embodiments, the method further comprises: optimizing and adjusting the number of attention heads of the model by using the improved artificial marmot algorithm during the model training process.
[0077] In some embodiments, the method further comprises: adjusting the mutation amplitude according to an increase in the number of iterations during the training process.
[0078] The embodiments will be described and illustrated below with specific examples.
[0079] The flowchart of the fault diagnosis algorithm based on the MTF and the improved Darknet19 is as shown in FIG. 3. Figure 3As shown, comprising the following steps: step S1, time series imaging. The original data is transformed by MTF to convert the one-dimensional gas ultrasonic flowmeter echo signal data and power quality disturbance data into a two-dimensional feature map with corresponding labels. MTF divides the time series into n intervals, each interval is assigned to the corresponding interval n and are natural numbers. To improve the efficiency of calculation, equal-width binning is selected here. Next, the transition probability from interval to interval at adjacent time steps , is calculated, where i, j is the transition probability, and W is a natural number, where the element of the transition matrix i is the conditional probability, indicating the probability of the interval at time i -1 moving to another interval at the next time, i.e., the time point of the , s, t are natural numbers, , to construct a W dimensional Markov state transition matrix , as shown in formula 1.
[0080] (1)
[0081] Due to the memoryless property of Markov chain, the transition matrix only depends on the previous time, ignoring the dependence of time step on the one-dimensional time domain sequence X . MTF generates a Markov transition field M based on formula 1, as shown in formula 2.
[0082] (2) where represents the transition probability from data point at time t to data point at time s , and the elements on the diagonal are the corresponding self-transition probability, i, j, s, t, n, are natural numbers. In this way, the Markov transition probability matrix W constructed according to the Markov chain can directly express the probability information on the Markov transition field M constructed according to the data length, which can not only avoid the loss of time sequence information of one-dimensional time domain signal, but also complete the preservation of data features, which is helpful for more accurate identification of fault features.
[0083] In the fault diagnosis method proposed in the present application, the time evolution of the collected gas ultrasonic flowmeter data is regarded as a Markov process, and a Markov transition field is constructed by the MTF method and image coding is realized. In the coding process, the amplitude information of each pixel point corresponds to the size of the transition probability w ij , and through visual conversion, the transition probability is presented as the change of color depth, and the color depth reflects the transition probability . The formation of the two-dimensional image is shown in Figure 4 . The image generated by MTF can be input into Darknet19, in which the power quality disturbance data is used as the source domain sample, and the echo signal data is used as the migration model sample.
[0084] Step S2, pre-training model. The source domain sample is input into the Darknet19 model for pre-training, and the TALA algorithm is used to optimize and adjust the parameters (learning rate, number of neurons and linear transformation) of the model. The TALA algorithm refers to an improved artificial lemming algorithm (ALA) that uses a t-distribution variational operator with the number of iterations as the degree of freedom parameter to perturb the position of the lemming individual. The TALA algorithm is an improved version based on the artificial lemming algorithm (Artificial Lemming Algorithm, ALA), and the core innovation point is to introduce a t-distribution variational operator with the number of iterations as the degree of freedom parameter to dynamically perturb the position of the lemming individual, thereby enhancing the global search ability and convergence efficiency of the algorithm. The TALA operation process is shown in Figure 5 .
[0085] First, randomly initialize the search individual and define the parameters of the artificial lemming search algorithm, calculate the fitness value of each search individual, and determine the position of the individual with the optimal fitness value after sorting. Subsequently, the energy adjustment coefficient E is calculated according to formula 3: wherein, T max is the maximum number of iterations, rand is a random value in the range of 0-1. When the energy is sufficient, i.e. , if , it represents that the search individual enters the long-distance migration state, and its position is updated using formula 4. Otherwise, the search individual enters the hole digging state, and its position is updated using formula 5. (5)
[0086] In formula 4, represents the position of the i th individual at the th iteration, represents the position of thei individuals in t the position of the current optimal solution. F is a flag to change the search direction, which helps to avoid local optimum, and its calculation formula is shown in equation 6. is a random number vector representing Brownian motion, which can search some potential areas in the space with dynamic and uniform step size. In this study, the standard normal function is used to calculate the step size of Brownian motion, as shown in equation 7. f BM is the probability density function of standard Brownian motion, from which the step size of Brownian motion is obtained. is a random number uniformly distributed in the interval generated by equation 8, with a dimension size of , Dim is a natural number, and this vector represents the movement of the current optimal individual and the random individual in the migration process, which is used to represent the interaction between individuals. In equation 5, is the current position of the i th individual, is the position of the randomly selected search individual a in the population, is the randomly selected search individual in the population, L is a random number that changes with the number of iterations, L and its calculation formula is shown in equation 9, where rand is a random number.
[0087] When the energy is insufficient, i.e. , if , the search individual enters the foraging state, which will update its position according to equation 10. Otherwise, the search individual will perform deceptive action to avoid predators, and its position will be updated using equation 11. In equation 10, represents the random search method during foraging, as shown in equation 12, radius represents the radius of the foraging range, which is calculated from the Euclidean distance between the current position and the optimal position, as shown in equation 13. In equation 11, G is the escape coefficient of the vole, which decreases with the increase of the number of iterations, and its calculation method is shown in equation 14. represents the maximum number of iterations. is a flying function used to simulate the deceptive action of the vole when escaping, and the function calculation is shown in equation 15. Equation 15 and is a random value, take 1.5.
[0088] Subsequently, the fitness value of the search individual is recalculated, and the position of the individual with the optimal fitness value is recorded. It is determined whether the position of the search individual has changed. If that is, the position has changed, the position of the search individual is disturbed according to Equation 16. wherein denotes a t-distribution with the number of iterations of the algorithm as a parameter of freedom. If the fitness value of the search individual after the mutation decreases, the position is updated, and if the fitness value decreases, the original position is maintained. If the maximum number of iterations has been reached, the position information of the search individual with the optimal fitness value is output; otherwise, the energy adjustment coefficient is calculated and the iteration is continued.
[0089] The feature information learned by the source domain after training can provide effective feature representation for subsequent fault diagnosis tasks. Finally, a multi-head self-attention mechanism MSA is added to the output layer of the migrated Darknet19 model, denoted as Darknet19-MSA model. MSA is composed of multiple self-attention modules, each module corresponds to a different representation subspace, so that the model can learn more rich information from multiple angles. Based on the traditional self-attention mechanism, MSA introduces a trainable linear transformation (matrix multiplication) to enhance the fitting ability of the model, so as to more accurately and meticulously achieve the required function. Specifically, the multi-head self-attention mechanism maps the input sequence to multiple different representation spaces and independently calculates the attention weights in each space. Such design enables the model to capture information in different subspaces.
[0090] Step S3, model training. Randomly divide the migration model samples into training set and test set in the ratio of 7:3. Then, input the training set into the pre-trained Darknet19-MSA model for model training, and optimize the hyperparameters such as the number of attention heads during the training process. Adjust the hyperparameters according to the training feedback of the model, and iterate and optimize until the performance on the training set reaches the optimal level, i.e. the accuracy does not improve after ten consecutive iterations, to ensure that the model structure is reasonable and efficient.
[0091] Step S4, fault diagnosis result output. Input the test set data into the network model in the optimal state to output the final fault diagnosis classification result. The final model input is the MTF image converted from the ultrasonic echo signal time series, and the output is the fault category label. The fault types corresponding to the labels are shown in Table 1.
[0092] In practical work, the common fault types in the design of gas ultrasonic flowmeter are designed and simulated experiments are carried out. The state of the flowmeter is divided into four categories: the first category is the fault caused by the aging of the transducer after long-term use of the flowmeter; the second category is the fault caused by the accumulation of pollutants in the transducer after long-term use of the flowmeter in the natural gas pipeline; the third category is the fault state of the superposition of the aging of the flowmeter and the pollutants (hereinafter referred to as the superposition state); and the last category is the normal state. According to the above experimental conditions and the verification regulation of the gas ultrasonic flowmeter , the verification regulation of the flowmeter stipulates that four flow points need to be verified, and the echo data at different flow points are collected to construct the fault data set of the gas ultrasonic flowmeter. The data set contains 800 samples, and each sample contains 400 sampling points. The basic information of the data set at four flow points (1 m³ / h, 16 m³ / h, 64 m³ / h, 160 m³ / h) is shown in Table 1.
[0093] In order to systematically evaluate the optimization performance of the improved algorithm, the ablation experiment is carried out under different flow rates. The experiment includes: MTF-Darknet19, which is used as the most basic control experiment and does not use any optimization algorithm; MTF-ALA-Darknet19, which uses the basic ALA; MTF-TALA-Darknet19, which uses the t-distribution strategy based on the number of iterations to optimize ALA; MTF-Darknet19-MSA, which introduces a multi-head self-attention mechanism in the output layer of Darknet19; MTF-TALA-Darknet19-MSA, which is the fault diagnosis model proposed in the present application, which combines the t-distribution strategy based on the number of iterations with ALA, and integrates MSA into the output layer of Darknet19. Four key indicators are used for experimental evaluation: precision Precision , recall Recall , accuracy Accuracy and F1 score harmonic mean. The calculation formula of the evaluation index is as follows:
[0094] Among them, TP represents true positive, FP represents false positive, TN represents true negative, FN represents false positive. The comparison results of the ablation experiment are shown in Table 2.
[0095] The experimental comparison results prove that the improved strategy proposed in the application has advantages in all evaluation indicators. Compared with other improved strategies, the accuracy of the model can reach 96.68%, the recall rate is 96.69%, the accuracy is 98.33%, and the F1 score is 97.38%.
[0096] To further illustrate the diagnostic ability of the proposed algorithm, Figure 6 The curve of the fitness value of the algorithm in the application with the number of iterations is shown, and a lower fitness value means a lower possibility of the algorithm falling into a local optimum. The horizontal axis represents the number of iterations, and the vertical axis represents the fitness. The experimental results show that the use of t-distribution variation based on the number of iterations and the introduction of the MSA layer can accelerate the convergence speed of the model and ultimately improve the accuracy.
[0097] In addition, we also use the confusion matrix as the standard for evaluating the accuracy of the fault diagnosis model. The confusion matrix measures the classification performance of the model by calculating the number of correct and incorrect classifications, and has high value in multi-classification tasks, which can present the comparison between the predicted value and the actual value of the model in detail. Figure 7 、 Figure 8 、 Figure 9 、 Figure 10 The confusion matrix of the test set prediction results of different improved strategies is shown, where the horizontal axis is the prediction result of the model, and the vertical axis is the true fault class. According to the confusion matrix results shown in Figure 7 、 Figure 8 、 Figure 9 、 Figure 10 When the basic model MTF-Darknet19 only introduces the MSA layer, the model performs well in the dirty class, but at the same time, it will misclassify other classes as the dirty class. When the basic model uses the ALA algorithm to optimize Darknet19, the improved model performs well in classifying dirty and aging, but encounters confusion in the superposition and normal classes, and the classification effect is not good. After introducing the t-distribution variation based on the number of iterations into the ALA algorithm, the classification performance of the model in the normal class is improved, but there is still some misclassification in aging and superposition. Compared with other improved strategies, the model proposed in the application has good recognition rate for various fault types in general, and misclassification rarely occurs, which further illustrates that the model has high diagnostic ability.
[0098] In order to simulate the noise interference received by the sensor in the real industrial environment and evaluate the anti-noise performance of the proposed method under different noise intensities, Gaussian noise is introduced to simulate the random noise commonly used in fault diagnosis. The Gaussian noise is added to the echo time series, and the Gaussian noise formula is 21. In order to quantify the influence of noise interference on the performance of the model, the performance degradation percentage (PDP) is used as an evaluation index. This index is used to measure the decline in model performance after adding noise. The probability density function of Gaussian noise is expressed as follows: Different noise intensities (5%, 10%, 15%) are selected for testing. The performance drop percentage (PDP) is calculated using formula 22: where BaseAccuracy is the fault diagnosis accuracy of the proposed method without noise, and NoiseAccuracy is the fault diagnosis accuracy of the proposed method after adding noise. As shown in Table 3, the proposed method can also exhibit good anti-noise performance under different noise intensities. Even under a noise intensity of 15%, the proposed method can have an accuracy of 93.96%, with a performance drop percentage of 4.44%, indicating that noise has a small impact on performance.
[0099] To verify the algorithm performance, the fault diagnosis method of the present application is compared with the fault diagnosis methods based on BILSTM, MTF-CNN and 1D-CNN respectively, and Proposed represents the fault diagnosis method of the present application, as shown in Table 4. Figure 11 As can be seen from the figure, the model constructed by the algorithm proposed in the present application has the best performance in the four evaluation indexes, with an average of about 96% for each index, which is significantly better than the other three methods, showing the outstanding ability and stable performance of the algorithm proposed in the present application in fault recognition. In comparison, 1D-CNN performs the worst, especially in recall rate and F1 score, which is significantly different from the algorithm proposed in the present application. Although BILSTM is better than 1D-CNN, it is still inferior to the method of the present application, and MTF-CNN performs relatively close, but still slightly inferior in each index.
[0100] The t-distribution in the embodiments of the present application is a probability distribution used to describe data with heavy-tailed characteristics. The t-distribution is a sampling distribution used in statistics to estimate the mean of a normal distribution when the sample size is small and the population variance is unknown. As shown in formula 23, the probability density function of the t-distribution is: f x (23) where, ν The degrees of freedom, control the degree of "heavy tail" of the distribution, and Γ is the gamma function. First, the application converts the one-dimensional echo signal in the gas ultrasonic flowmeter fault data set and the time sequence of power quality disturbance data into a two-dimensional feature map using the Markov transition field (MTF), so as to extract more discriminative feature information, which is convenient for subsequent fault classification through the Darknet19 model. Then, the Darknet19 model is pre-trained using the source domain samples, and at the same time, in order to enhance the feature extraction capability of the model, the TALA algorithm (the TALA algorithm refers to an improved artificial lemming algorithm (ALA) that uses a t-distribution variational operator with the number of iterations as the degree of freedom parameter to disturb the position of the lemming individual, and the TALA algorithm is an improved version based on the artificial lemming algorithm (Artificial Lemming Algorithm, ALA), and the core innovation point is to introduce a t-distribution variational operator, and the number of iterations is used as the degree of freedom parameter to dynamically disturb the position of the lemming individual, thereby enhancing the global search capability and convergence efficiency of the algorithm) is used to optimize the model parameters (such as learning rate, number of neurons and linear transformation, etc.), and a transfer model is obtained. After that, in order to further optimize the transfer model of Darknet19, a multi-head self-attention mechanism layer (MSA) is added after the output layer of the model, so that it can learn more valuable feature information from the data, and thus better adapt to the fault diagnosis task. Then, 70% of the transfer model samples are used for model training, and in this stage, the TALA algorithm is used to optimize the number of attention heads in the multi-head self-attention mechanism and other hyperparameters, so as to ensure that the model structure is reasonable and efficient. Finally, the remaining transfer model samples are input into the model with the best diagnosis performance, and the accurate identification of the flowmeter fault type is realized.
[0101] The beneficial effects of the application are:
[0102] 1. The application adopts a multi-head self-attention learning mechanism (MSA) to enhance the ability of the neural network to capture the relationship between inputs. The MSA is composed of multiple self-attention modules, each module corresponding to a different representation subspace, so that the model can learn more rich information from multiple angles. Based on the traditional self-attention mechanism, MSA introduces a trainable linear transformation (matrix multiplication) to enhance the fitting ability of the model, so as to more accurately and meticulously realize the required functions.
[0103] 2. The application uses an adaptive t-distribution variation operator to perturb the positions of the vole individuals. The adaptive t-distribution variation strategy gradually adjusts the variation amplitude as the number of iterations increases during the evolution process. The variation perturbation is the position of the artificial vole individual in the artificial vole algorithm, and the variation amplitude refers to the size of the change in the position of the vole individual. In the early stage of iteration, the degree of freedom is small, and the variation process produces a large disturbance. In the later stage, the degree of freedom increases, the t-distribution approaches normal, and the variance disturbance is small. This strategy fully utilizes the current population information, dynamically adjusts the characteristics of the variation operator according to the variation probability, can help the algorithm jump out of the local optimum at different stages, and finely adjusts to promote convergence to achieve the global optimum in the last stage, thereby improving the algorithm performance.
[0104] It should be noted that the steps shown in the above flow or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from here.
[0105] In this embodiment, an improved artificial vole algorithm-based gas ultrasonic flowmeter fault diagnosis device is also provided, which is used to implement the above embodiments and preferred embodiments, and will not be described again. The terms "module", "unit", "sub-unit" and the like used below can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware implementation is also possible and contemplated.
[0106] The device comprises:
[0107] The acquisition module is configured to acquire echo signal data and power quality disturbance data of the gas ultrasonic flowmeter.
[0108] The first generation module is configured to generate a migration model sample set according to the echo signal data and the Markov transition field.
[0109] The second generation module is configured to generate a source domain sample set according to the power quality disturbance data and the Markov transition field.
[0110] The pre-training module is configured to pre-train a preset convolutional neural network model according to the source domain sample set to obtain a migrated convolutional neural network model. During the pre-training process, the improved artificial vole algorithm is used to optimize and adjust the parameters of the model. The improved artificial vole algorithm is a t-distribution variation operator with the number of iterations as the degree of freedom parameter to perturb the position of the vole individual.
[0111] The construction module is configured to construct a first model according to the migrated convolutional neural network model.
[0112] a training module, configured to perform model training on the first model according to the migration model sample set, to obtain a target model; during the model training, the improved artificial vole algorithm is used to optimize and adjust parameters of the model;
[0113] a diagnosis module, configured to perform fault diagnosis according to the target model and echo signal data to be diagnosed.
[0114] It should be noted that each of the above modules can be a functional module or a program module, and can be implemented by software or hardware. For the modules implemented by hardware, each of the above modules can be located in the same processor; or each of the above modules can also be located in different processors in any combination.
[0115] In the embodiment, an electronic device is also provided, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0116] Optionally, the electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected with the processor, and the input / output device is connected with the processor.
[0117] Optionally, in the embodiment, the processor can be configured to perform the following steps by the computer program:
[0118] S1, obtaining echo signal data and power quality disturbance data of a gas ultrasonic flowmeter;
[0119] S2, generating a migration model sample set according to the echo signal data and a Markov transition field;
[0120] S3, generating a source domain sample set according to the power quality disturbance data and the Markov transition field;
[0121] S4, pre-training a preset convolutional neural network model according to the source domain sample set, to obtain a migrated convolutional neural network model; during the pre-training, the improved artificial vole algorithm is used to optimize and adjust parameters of the model; the improved artificial vole algorithm is a t-distributed variational operator with iteration number as a degree of freedom parameter to disturb the position of a vole individual;
[0122] S5, constructing a first model according to the migrated convolutional neural network model;
[0123] S6, performing model training on the first model according to the migration model sample set, to obtain a target model; during the model training, the improved artificial vole algorithm is used to optimize and adjust parameters of the model;
[0124] S7, according to the target model and the echo signal data to be diagnosed, performing fault diagnosis.
[0125] It should be noted that the specific examples in the embodiment can refer to the examples described in the above embodiments and optional implementation manners, and will not be described herein again.
[0126] In addition, in combination with the gas ultrasonic flowmeter fault diagnosis method based on the improved artificial vole algorithm provided in the above embodiments, a storage medium can also be provided in the embodiment to realize. The storage medium has a computer program stored thereon; the computer program is executed by a processor to realize any one of the gas ultrasonic flowmeter fault diagnosis methods based on the improved artificial vole algorithm in the above embodiments.
[0127] It should be understood that the specific embodiments described herein are only used to explain this application, but not to limit it. According to the embodiments provided in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of protection of the present application.
[0128] Obviously, the drawings are only some examples or embodiments of the present application, and those skilled in the art can also apply the present application to other similar situations without creative labor according to the drawings. In addition, it can be understood that although the work done in the development process may be complex and long, but for those skilled in the art, some design, manufacture or production changes according to the technical content disclosed in the present application are only routine technical means, and should not be regarded as insufficient disclosure of the present application.
[0129] The term "embodiment" in the present application means that the specific features, structures or characteristics described in combination with the embodiment can be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean independence or alternative to other embodiments. Those skilled in the art can clearly or implicitly understand that the embodiments described in the present application can be combined with other embodiments without conflict.
[0130] The above described embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it cannot be understood as a limitation on the scope of patent protection. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. A gas ultrasonic flowmeter fault diagnosis method based on an improved artificial vole algorithm, characterized in that, The method comprises: acquiring echo signal data and power quality disturbance data of a gas ultrasonic flowmeter; generating a migration model sample set according to the echo signal data and a Markov transition field; generating a source domain sample set according to the power quality disturbance data and the Markov transition field; pre-training a preset convolutional neural network model according to the source domain sample set to obtain a migrated convolutional neural network model; in the pre-training process, an improved artificial lemming algorithm is used to optimize and adjust parameters of the model; the improved artificial lemming algorithm is an artificial lemming algorithm that uses an iteration number as a degree of freedom parameter of a t-distribution variational operator to disturb individual positions of lemmings; constructing a first model according to the migrated convolutional neural network model; model training the first model according to the migration model sample set to obtain a target model; in the model training process, the improved artificial lemming algorithm is used to optimize and adjust parameters of the model; performing fault diagnosis according to the target model and to-be-diagnosed echo signal data.
2. The gas ultrasonic flowmeter fault diagnosis method based on the improved artificial vole algorithm according to claim 1, characterized in that, The generating of the migration model sample set according to the echo signal data and the Markov transition field comprises: converting the echo signal data into a first two-dimensional feature map by using the Markov transition field, and constructing the migration model sample set according to the first two-dimensional feature map; The generating of the source domain sample set according to the power quality disturbance data and the Markov transition field comprises: converting the power quality disturbance data into a second two-dimensional feature map by using the Markov transition field, and constructing the source domain sample set according to the second two-dimensional feature map.
3. The gas ultrasonic flowmeter fault diagnosis method based on the improved artificial vole algorithm according to claim 1, characterized in that, The constructing of the first model according to the migrated convolutional neural network model comprises: adding a multi-head self-attention mechanism to an output layer of the migrated convolutional neural network model; the multi-head self-attention mechanism comprises a plurality of self-attention modules, and each module corresponds to a different representation subspace.
4. The gas ultrasonic flowmeter fault diagnosis method based on the improved artificial vole algorithm according to claim 1, characterized in that, The performing of the fault diagnosis according to the target model and the to-be-diagnosed echo signal data comprises: converting the to-be-diagnosed echo signal data into a target two-dimensional feature map according to the Markov transition field; inputting the target two-dimensional feature map into the target model, and outputting a fault category label by the target model; the fault category label corresponds to a fault type; performing fault diagnosis according to the fault category label.
5. The gas ultrasonic flowmeter fault diagnosis method based on the improved artificial vole algorithm according to claim 1, characterized in that, The optimizing and adjusting of the parameters of the model in the pre-training process by using the improved artificial lemming algorithm comprises: randomly initializing search individuals and defining parameters of the artificial lemming search algorithm, calculating fitness values of each search individual, and determining a position of an individual with the optimal fitness value after sorting.
6. The gas ultrasonic flow meter fault diagnosis method based on the improved artificial vole algorithm according to claim 5, characterized in that, The optimizing and adjusting of the parameters of the model in the pre-training process by using the improved artificial lemming algorithm further comprises: optimizing and adjusting a learning rate, a number of neurons, and linear transformation of the model by using the improved artificial lemming algorithm.
7. The gas ultrasonic flow meter fault diagnosis method based on the improved artificial vole algorithm according to claim 1, characterized in that, The optimizing and adjusting of the parameters of the model in the model training process by using the improved artificial lemming algorithm comprises: optimizing and adjusting a number of attention heads of the model in the model training process by using the improved artificial lemming algorithm.
8. The gas ultrasonic flow meter fault diagnosis method based on the improved artificial vole algorithm according to claim 1, characterized in that, The method further comprises: adjusting a variation amplitude according to an increase in the iteration number in the training process.
9. A gas ultrasonic flowmeter fault diagnosis device based on an improved artificial vole algorithm, characterized in that, The device comprises: An acquisition module is configured to acquire echo signal data and power quality disturbance data of a gas ultrasonic flowmeter. A first generation module is configured to generate a migration model sample set according to the echo signal data and a Markov transition field. A second generation module is configured to generate a source domain sample set according to the power quality disturbance data and the Markov transition field. A pre-training module is configured to pre-train a preset convolutional neural network model according to the source domain sample set to obtain a migrated convolutional neural network model; in the pre-training process, an improved artificial vole algorithm is used to optimize and adjust parameters of the model; the improved artificial vole algorithm is an artificial vole algorithm that uses an iteration number as a degree-of-freedom parameter of a t-distribution variational operator to disturb individual positions of voles. A construction module is configured to construct a first model according to the migrated convolutional neural network model. A training module is configured to perform model training on the first model according to the migration model sample set to obtain a target model; in the model training process, the improved artificial vole algorithm is used to optimize and adjust parameters of the model. A diagnosis module is configured to perform fault diagnosis according to the target model and echo signal data to be diagnosed.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program, when executed by a processor, implements the steps of the gas ultrasonic flowmeter fault diagnosis method based on the improved artificial vole algorithm in any one of claims 1 to 8.
Citation Information
Patent Citations
Ultrasonic flowmeter fault early warning method and system, electronic equipment and medium
CN117288303A
Ultrasonic flowmeter fault diagnosis method based on improved sparrow search algorithm
CN117851903A