A liquid substance composition detection method, system and storage medium
Patent Information
- Application Number
- CN202610876503.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-17
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2046-06-17
AI Technical Summary
因此,亟需一种液体物质成分检测方法,从液固摩擦电信号中有效放大并自动提取出与液体物质成分密切相关的深层特征,克服传统时域分析方法对微弱差异不敏感的缺陷
本申请提供一种液体物质成分检测方法、系统和存储介质,方法中将原始电信号末端补零至预设阈值后,采用重叠分帧策略将非平稳信号切分为多个近似平稳的短时片段,再经离散傅里叶变换和幅值平方运算获得频谱图信号。该处理既保留了液滴滑落过程中电荷转移的时序动态信息,又将微弱的物质成分差异转化为频域能量分布的显著变化,解决了单纯依赖电压或电流峰值难以区分无机溶质成分的技术难题。
Smart Images

Figure CN122409484B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of liquid detection and analysis technology, and in particular relates to a method, system and storage medium for detecting the composition of liquid substances. Background Technology
[0002] Rapid and accurate detection of liquid components has significant research and application value in fields such as environmental monitoring, industrial production, food safety, and medical diagnosis. For example, in water environment management, on-site and real-time monitoring of components such as inorganic salt ions and organic pollutants in water bodies is crucial to ensuring water ecological security and the health of residents' drinking water. However, with the acceleration of industrialization and the growth of distributed detection needs, traditional laboratory detection methods relying on large instruments, such as ion chromatography and mass spectrometry, while highly accurate, suffer from problems such as expensive equipment, complex operation, and long detection cycles, making it difficult to meet the needs of decentralized and real-time on-site detection.
[0003] Triboelectric nanogenerators (TENGs) at the liquid-solid interface offer a novel approach to liquid detection. The basic principle is that when a test liquid droplet falls and comes into contact with and separates from a solid friction layer, charge transfer occurs due to the difference in electron affinity between the two, resulting in an electrical signal related to the liquid's physicochemical properties. Existing detection methods typically directly acquire and analyze the time-domain characteristics of this electrical signal, such as peak voltage or current values and waveform integral area, attempting to establish a correlation between these simple statistics and liquid composition (e.g., salt solutions of different concentrations).
[0004] However, for distinguishing the components of many liquid substances, especially inorganic solutes (such as different types of metal ions or extremely low concentrations of organic matter) that have negligible impact on the mechanical properties of the solution (such as viscosity and surface tension), the waveform differences of the original electrical signals generated by liquid-solid friction are extremely weak. These differences are often submerged in system noise and random fluctuations, making it difficult to extract stable and reliable quantitative indicators by relying solely on manual observation or traditional time-domain peak statistical methods, thus hindering the establishment of effective discrimination models. Capturing such subtle differences typically requires massive amounts of data, resulting in extremely low accuracy and robustness. Therefore, there is an urgent need for a liquid component detection method that can effectively amplify and automatically extract deep features closely related to the liquid component from the liquid-solid friction electrical signals, overcoming the insensitivity of traditional time-domain analysis methods to subtle differences. Summary of the Invention
[0005] This application provides a method, system, and storage medium for detecting the composition of liquid substances. It effectively amplifies and extracts deep features closely related to the composition of liquid substances from liquid-solid triboelectric signals, overcomes the shortcomings of traditional time-domain analysis methods that are insensitive to slight differences, and improves the accuracy and robustness of liquid substance composition identification.
[0006] In a first aspect, this application provides a method for detecting the composition of a liquid substance, comprising: Acquire the original electrical signal generated by the droplets of the target liquid after friction; Converting the original electrical signal into a spectrogram signal includes: Fill the end of the original electrical signal with 0 until the number of sampling points of the original electrical signal reaches a preset threshold to obtain the first electrical signal; The first electrical signal is divided into frames, and an index matrix is constructed based on the number of sampling points in each frame and the distance between the starting positions of sampling points in two adjacent frames in the first electrical signal. The index values are obtained from the first electrical signal by indexing the index matrix to obtain the framed electrical signal matrix. The complex spectrum matrix is obtained by processing the electrical signal matrix using the discrete Fourier transform. The complex spectrum matrix F is converted into a spectrum signal P according to the following formula: ; Where |·| represents the absolute value; N fft The number of data points used when performing a discrete Fourier transform on each frame of electrical signal; The spectral signals of droplets with known liquid composition were used as the training set to train a neural network, and the trained neural network was used as a liquid composition detection model. The spectral signal of the droplets of the liquid to be tested is input into the liquid composition detection model to output the composition of the liquid to be tested.
[0007] Optionally, the step of dividing the first electrical signal into frames to construct an index matrix based on the number of sampling points in each frame and the distance between the starting positions of sampling points in two adjacent frames within the first electrical signal includes: The expression for constructing index matrix I: ; Where, N step is the distance between the starting positions of the sampling points of two adjacent frames of electrical signals in the first electrical signal; m is the first matrix; T denotes the transpose of a matrix; For 1 row N frame A second matrix consisting of columns, all of which are 1s; N frame The number of sampling points in each frame of electrical signal; 1 M The third matrix is M rows and 1 column, with all elements equal to 1; M is the number of electrical signals after framing; r is the fourth matrix; L represents the total number of sampling points for the original electrical signal. This indicates rounding up to the nearest integer.
[0008] Optionally, the step of obtaining the framed electrical signal matrix by indexing the first electrical signal according to the index matrix includes: The expression for constructing the framed electrical signal matrix: ; Among them, X frame X is an electrical signal matrix composed of the electrical signal vectors of each frame; frame [q,e'] represents X frame The element in the q-th row and e'-th column; x pad [I q,e' [x] is the first electrical signal pad Middle I q,e' One element; I q,e' It is the element in the q-th row and e'-th column of the index matrix I.
[0009] Optionally, the step of processing the framed electrical signal matrix using discrete Fourier transform to obtain a complex spectrum matrix includes: Construct the expression for the complex spectrum matrix F: ; Where F[a,k] is the element in the a-th row and k-th column of the complex spectrum matrix F; N frame X represents the number of sampling points in each frame of the electrical signal; frame [a,b] represents X frame The element in the a-th row and b-th column; w[b] is the b-th element in the window function matrix; e is the natural constant; j is the imaginary unit; π is pi; k=1,2,...,N fft -1.
[0010] Optionally, the step of training a neural network using the spectral signals of multiple droplets with known liquid compositions as a training set, and using the trained neural network as a liquid composition detection model, includes: The two-dimensional tensor representing the droplet spectrogram signal is input into the neural network to be trained, so as to output the first vector corresponding to each droplet spectrogram signal; Perform softmax calculation on each first vector to obtain the category probability distribution vector corresponding to each droplet; The cross-entropy loss of the spectrum signal of each droplet is determined based on the category probability distribution vector corresponding to each droplet; The batch loss of all spectrogram signals in the current batch of droplets is determined based on the cross-entropy loss; The partial derivatives of the batch loss with respect to all trainable parameters of the neural network to be trained are used as the gradient of the batch loss. The batch loss gradient is used to update all trainable parameters multiple times until the batch loss stops decreasing, resulting in a trained neural network that can be used as a liquid substance composition detection model. The trained neural network parameters are all trainable parameters obtained from the last update.
[0011] Optionally, the step of inputting the two-dimensional tensor representing the droplet spectrogram signal into the neural network to be trained, so as to output a first vector corresponding to each droplet spectrogram signal, includes: The first vector h corresponding to the spectrum signal of each droplet is calculated according to the following formula: ; in, Let W be the activation function of the fully connected layer of the neural network to be trained; W is the weight matrix of the fully connected layer. It is a flattening function; is the activation function of the convolutional layer of the neural network to be trained; K is the convolutional kernel parameter; P is a two-dimensional tensor representing the droplet spectrum signal; is the spatial convolution operator, representing the convolution operation; c is the bias vector of the convolutional layer; d is the bias vector of the fully connected layer.
[0012] Optionally, the step of updating all trainable parameters multiple times based on the batch loss gradient until the batch loss stops decreasing, to obtain a trained neural network as a liquid substance composition detection model, includes: All trainable parameters are updated multiple times according to the following formula: ; Among them, y (t) β1 is the first moment estimate of the gradient when updating all trainable parameters for the t-th time; β1 is the exponential decay rate of the first moment; y (t-1) g is the first moment estimate of the gradient when updating all trainable parameters for the (t-1)th time; (t) v is the gradient when updating all trainable parameters for the t-th time; (t) β2 is the second moment estimate of the squared gradient when updating all trainable parameters for the t-th time; β2 is the exponential decay rate of the second moment; v (t-1) The second moment estimate of the squared gradient when updating all trainable parameters for the (t-1)th time; The gradient first moment estimate after bias correction when updating all trainable parameters for the t-th time; The gradient squared second moment estimate after bias correction when updating all trainable parameters for the (t-1)th time; Let be the set of all trainable parameters at the t-th update; Let be the set of all trainable parameters at the (t-1)th update; α is the preset learning rate; ε is a constant.
[0013] Secondly, this application provides a liquid substance composition detection system, comprising: The acquisition module is used to acquire the original electrical signal generated by the droplets of the target liquid after friction; The conversion module, used to convert the original electrical signal into a spectrogram signal, includes: Fill the end of the original electrical signal with 0 until the number of sampling points of the original electrical signal reaches a preset threshold to obtain the first electrical signal; The first electrical signal is divided into frames, and an index matrix is constructed based on the number of sampling points in each frame and the distance between the starting positions of sampling points in two adjacent frames in the first electrical signal. The index values are obtained from the first electrical signal by indexing the index matrix to obtain the framed electrical signal matrix. The complex spectrum matrix is obtained by processing the electrical signal matrix using the discrete Fourier transform. The complex spectrum matrix F is converted into a spectrum signal P according to the following formula: ; Where |·| represents the absolute value; N fft The number of data points used when performing a discrete Fourier transform on each frame of electrical signal; The training module is used to train a neural network using the spectral signals of droplets with known liquid composition as the training set, and to use the trained neural network as a liquid composition detection model. The detection module is used to input the spectral signal of the droplets of the liquid to be tested into the liquid composition detection model, so as to output the composition of the liquid to be tested.
[0014] Thirdly, this application provides a computer-readable storage medium, characterized in that it is used to store a computer program; when the computer program is executed by a processor, it implements the steps of the liquid substance composition detection method described in the first aspect.
[0015] Beneficial effects: This application provides a method, system, and storage medium for detecting the composition of liquid substances. The method involves padding the original electrical signal with zeros to a preset threshold, then using an overlapping framing strategy to divide the non-stationary signal into multiple approximately stationary short-time segments. The resulting spectrum signal is then obtained through discrete Fourier transform and amplitude squared operation. This processing preserves the temporal dynamic information of charge transfer during droplet sliding and transforms subtle differences in substance composition into significant changes in frequency domain energy distribution, solving the technical problem of distinguishing inorganic solute components by simply relying on voltage or current peak values.
[0016] The spectral signal is input into a neural network as a two-dimensional tensor. Convolutional layers scan and extract local features in the time-frequency domain, and fully connected layers construct a nonlinear mapping from spectral features to substance composition categories. The neural network can autonomously learn the subtle response patterns of different liquid components at specific frequency bands and times, exhibiting high recognition capabilities for similar substances such as electrolytes / non-electrolytes and different metal ions. Attached Figure Description
[0017] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A schematic flowchart of a liquid substance composition detection method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of a liquid substance composition detection device provided in an embodiment of this application; Figure 3 A diagram of triboelectric signals generated by ultrapure water provided in an embodiment of this application; Figure 4 A diagram of the triboelectric signal generated by the copper sulfate solution provided in the embodiments of this application; Figure 5 A diagram of a single triboelectric pulse signal generated by ultrapure water provided in an embodiment of this application; Figure 6 A diagram of a single triboelectric pulse signal generated by a copper sulfate solution provided in an embodiment of this application; Figure 7 The spectrum obtained by processing the ultrapure aqueous solution provided in the embodiments of this application using the method of this application; Figure 8 The spectrum obtained by processing the copper sulfate solution provided in the embodiments of this application using the method of this application; Figure 9 This is a schematic flowchart of a liquid substance composition detection system provided in an embodiment of this application. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0020] Example 1 This embodiment provides a method for detecting the composition of a liquid substance, which is applied to a liquid substance composition detection device, such as... Figure 2 As shown, the liquid composition detection device includes a microfluidic drive module 1 for generating and dropping liquid droplets; and a triboelectric power generation module 2, located in the path of the dropping liquid droplets, for generating electrical signals by rubbing against the dropping liquid droplets.
[0021] like Figure 1 As shown, the methods for detecting the composition of liquid substances include: Step 101: Obtain the original electrical signal generated by the droplets of the target liquid after friction.
[0022] For example, the pulse current output interface of the triboelectric generator module 2 is connected to a DSCope U3P100 oscilloscope, and the oscilloscope is controlled by LabVIEW software to acquire and record the triboelectric signal induced by the droplet in real time.
[0023] Step 102: Convert the original electrical signal into a spectrogram signal.
[0024] This step requires framing the original electrical signal. To ensure that each frame of the electrical signal has the same number of sample points, the original electrical signal needs to be padded (terminated with zeros). That is, zeros are added to the end of the original electrical signal until the number of sample points of the original electrical signal reaches a preset threshold. The zero-padded original electrical signal is then used as the first electrical signal x. pad .
[0025] The first electrical signal is non-stationary (its characteristics change over time). Directly performing a Fourier transform on the entire long signal would lose time information, making it impossible to see when the signal characteristics change. By segmenting the signal into frames, we can assume that the signal within each frame is approximately stationary, and then perform a Fourier transform on each frame separately, thereby obtaining the joint time-frequency distribution.
[0026] An electrical signal (a sequence of voltage or current changes over time) acquired continuously over a long period of time is divided into multiple short segments that overlap or do not overlap, according to a fixed time length (or number of sampling points). Each segment is called a frame.
[0027] The first electrical signal is divided into frames, based on the number of sampling points (length per frame) N in each frame. frame And the distance (frame shift) N between the starting positions of the sampling points of two adjacent frames of electrical signals in the first electrical signal. step Construct an index matrix; where N frame and N step These are all customizable parameters. For example, each frame of electrical signal contains 2000 sampling points, and the interval between the start positions of two adjacent frames, for example, 1000 sampling points, indicates that there is 50% overlap between frames.
[0028] For example, the expression for constructing the index matrix I is: .
[0029] Where m is the first matrix; T denotes the transpose of a matrix; For 1 row N frame A second matrix consisting of columns, all of which are 1; 1 M The third matrix is M rows and 1 column, with all elements equal to 1; M is the number of electrical signals after framing (i.e., the total number of frames); r is the fourth matrix; L represents the total number of sampling points for the original electrical signal. This indicates rounding up to the nearest integer.
[0030] The index values are obtained by indexing the first electrical signal using the index matrix to obtain the framed electrical signal matrix.
[0031] For example, the expression for constructing the framed electrical signal matrix is as follows: .
[0032] Among them, X frame X is an electrical signal matrix composed of the electrical signal vectors of each frame; frame [q,e'] represents X frame The element in the q-th row and e'-th column; x pad [I q,e' ] is the Ith signal in the first electrical signal q,e' One element; I q,e' This is the element in the q-th row and e'-th column of index matrix I.
[0033] .
[0034] X frame Each row in the middle corresponds to a frame point signal (i.e., a short time segment).
[0035] The complex spectrum matrix is obtained by processing the framed electrical signal matrix using the discrete Fourier transform.
[0036] For example, the expression for the complex spectrum matrix F is constructed as follows: .
[0037] Where a is the row number of the element currently being calculated in matrix F, k is the column number of the element currently being calculated in matrix F, and b is the position of the element in matrix X. frame The column index; F[a,k] is the element in the a-th row and k-th column of the complex spectrum matrix F; X frame [a,b] represents X frameThe element in the a-th row and b-th column; w is the window function matrix; n' is the fifth matrix. cos(·) is the cosine function; w[b] is the b-th element in the window function matrix; e is the natural constant; j is the imaginary unit; π is pi; N fft The number of data points used when performing a Discrete Fourier Transform on each frame of the electrical signal is a pre-set parameter; 0 < N fft ≤N frame k=1,2,...,N fft -1.
[0038] Convert the complex spectrum matrix into a spectrum signal.
[0039] For example, a complex spectral matrix is converted into a spectrogram signal P according to the following formula: .
[0040] Where |·| represents absolute value.
[0041] Step 103: Use the spectral signals of droplets with known liquid composition as a training set to train the neural network, and use the trained neural network as a liquid composition detection model.
[0042] Spectrum signal , is a two-dimensional tensor, where H' is the height of the spectrogram, W' is the width of the spectrogram, and R represents the set of real numbers.
[0043] A two-dimensional tensor representing the droplet spectrogram signal is input into the neural network to be trained, so as to output the first vector corresponding to each droplet spectrogram signal.
[0044] For example, the first vector h corresponding to each droplet spectrum signal is calculated according to the following formula: .
[0045] in, Let W be the activation function of the fully connected layer of the neural network to be trained; W is the weight matrix of the fully connected layer. It is a flattening function; is the activation function of the convolutional layer of the neural network to be trained; K is the convolutional kernel parameter; P is a two-dimensional tensor representing the droplet spectrum signal; is the spatial convolution operator, representing the convolution operation; c is the bias vector of the convolutional layer; d is the bias vector of the fully connected layer.
[0046] Perform softmax calculation on each first vector to obtain the class probability distribution vector corresponding to each droplet.
[0047] For example, the category probability distribution vector corresponding to each droplet is calculated according to the following formula: .
[0048] in, Let be the k'th element of the class probability distribution vector p; h[s] is the k'th element of the first vector h; h[s] is the sth element of the first vector h; S is the length of the first vector h, that is, the total number of elements of the first vector h.
[0049] The cross-entropy loss of the spectrogram signal for each droplet is determined based on the probability distribution vector of the corresponding class.
[0050] For example, the cross-entropy loss Loss for each droplet spectrum signal is calculated according to the following formula: .
[0051] Where K' is the total number of elements in the first vector; o represents the tag vector obtained by one-hot encoding of the sample types corresponding to the droplet spectrum signal, and the total number of elements is the same as that in the first vector; Let be the k'th element of vector o; p is the class probability distribution vector, with the same total number of elements as the first vector.
[0052] The batch loss of all spectrogram signals in the current batch of droplets is determined based on the cross-entropy loss.
[0053] For example, the batch loss of all spectrogram signals in the current batch of droplets is calculated according to the following formula. : .
[0054] Where B is the total number of spectrogram signals in the current batch; Loss z This represents the cross-entropy loss of the z-th spectrogram signal in the current batch.
[0055] The partial derivatives of the batch loss with respect to all trainable parameters of the neural network to be trained are used as the gradient of the batch loss.
[0056] For example, partial derivatives are taken for all trainable parameters of the neural network to be trained according to the following formula: .
[0057] Where g is the gradient of the batch loss; θ is the set of all trainable parameters. .
[0058] The batch loss gradient is used to update all trainable parameters multiple times until the batch loss stops decreasing, resulting in a trained neural network that can be used as a liquid substance composition detection model. The trained neural network parameters are all trainable parameters obtained from the last update.
[0059] For example, all trainable parameters are updated multiple times according to the following formula: .
[0060] Where t is the time step, indicating the number of times the parameter has been updated, starting from 1 and incrementing after each batch of data is processed; y (t) β1 is the first moment estimate of the gradient when updating all trainable parameters for the t-th time, i.e., the exponential moving average of the gradient; β1 is the exponential decay rate of the first moment; y (t-1) g is the first moment estimate of the gradient when updating all trainable parameters for the (t-1)th time; (t) v is the gradient when updating all trainable parameters for the t-th time; (t) β2 is the second moment estimate of the squared gradient when updating all trainable parameters for the t-th time, i.e., the exponentially moving average of the element-wise squared gradient; β2 is the exponential decay rate of the second moment; v (t-1) The second moment estimate of the squared gradient when updating all trainable parameters for the (t-1)th time; The gradient first moment estimate after bias correction when updating all trainable parameters for the t-th time; The gradient squared second moment estimate after bias correction when updating all trainable parameters for the (t-1)th time; Let be the set of all trainable parameters at the t-th update; Let be the set of all trainable parameters at the (t-1)th update; α is the preset learning rate, a hyperparameter that controls the step size of each parameter update; ε is a constant to prevent the denominator from being zero.
[0061] Repeat the above update process for all spectrogram signals in each batch until the batch loss no longer decreases, thus obtaining the trained network parameters. .
[0062] Step 104: Input the spectral signal of the droplets of the liquid to be tested into the liquid composition detection model to output the composition of the liquid to be tested.
[0063] The spectral signal P' of the liquid droplet to be tested is input into the trained neural network, and the output vector is... This allows us to determine the material composition corresponding to h'.
[0064] like Figure 3 and Figure 4The figures show the triboelectric signals obtained by the method of this application for ultrapure aqueous solution and 0.05M CuSO4 (copper sulfate) solution, respectively.
[0065] like Figure 5 and Figure 6 The images shown are magnified views of a single pulse signal, respectively displaying the single friction pulse signal of ultrapure aqueous solution and 0.5 mol / L CuSO4.
[0066] like Figure 7 and Figure 8 The figures shown are the spectrum diagrams of electrical signals from an ultrapure aqueous solution and a 0.05 mol / L CuSO4 (copper sulfate) solution, obtained by processing them using the method provided in this application. The original electrical signal has a length of 4800, and each frame after framing contains 200 electrical signal sampling points. The distance between the starting positions of two adjacent frames in the original signal is 50.
[0067] The following are specific embodiments of the method disclosed in this application, using several different solutions to classify solutes according to the method of this application and obtaining the classification accuracy: According to the method of this embodiment, 756 spectrogram signals from electrolyte solutions and 1214 spectrogram signals from non-electrolyte solutions were used as training sample sets to train the neural network model. Another 252 spectrogram signals from electrolyte solutions and 404 spectrogram signals from non-electrolyte solutions were used as validation sample sets. The trained neural network was used to determine the solution components. Finally, the classification accuracy of the validation set was 100%, the classification index AUO_ROC was 100%, the precision was 100%, and the recall was 100%.
[0068] According to the method of this embodiment, 283 spectrogram signals from lithium chloride solution and 332 spectrogram signals from ultrapure water were used as training sample sets to train the neural network model. Another 94 spectrogram signals from lithium chloride solution and 111 spectrogram signals from ultrapure water were used as validation sample sets. The trained neural network was used to determine the composition of the solution. Finally, the classification accuracy of the validation set was 98.44%, the classification index AUO_ROC was 99.81%, the precision was 98.48%, and the recall was 98.37%.
[0069] According to the method of this embodiment, 179 spectrogram signals from fulvic acid solution and 167 spectrogram signals from sodium chloride solution were used as training sample sets to train the neural network model. Another 59 spectrogram signals from fulvic acid solution and 55 spectrogram signals from sodium chloride solution were used as validation sample sets. The trained neural network was used to determine the components of the solution. Finally, the classification accuracy of the validation set was 100%, the classification index AUO_ROC was 100%, the precision was 100%, and the recall was 100%.
[0070] According to the method of this embodiment, 167 spectrogram signals from sodium chloride solution and 283 spectrogram signals from lithium chloride solution were used as training sample sets to train the neural network model. Another 55 spectrogram signals from sodium chloride solution and 94 spectrogram signals from lithium chloride solution were used as validation sample sets. The trained neural network was used to determine the solution components. Finally, the classification accuracy of the validation set was 86.81%, the classification index AUO_ROC was 92.65%, the precision was 86.05%, and the recall was 85.08%.
[0071] According to the method of this embodiment, 167 spectrogram signals from sodium chloride solution and 304 spectrogram signals from magnesium chloride solution were used as training sample sets to train the neural network model. Another 55 spectrogram signals from sodium chloride solution and 101 spectrogram signals from magnesium chloride solution were used as validation sample sets. The trained neural network was used to determine the composition of the solution. Finally, the classification accuracy of the validation set was 81.25%, the classification index AUO_ROC was 85.20%, the precision was 79.96%, and the recall was 77.68%.
[0072] According to the method of this embodiment, 283 spectrogram signals from lithium chloride solution and 304 spectrogram signals from magnesium chloride solution were used as training sample sets to train the neural network model. Another 55 spectrogram signals from sodium chloride solution and 94 spectrogram signals from magnesium chloride solution were used as validation sample sets. The trained neural network was used to determine the solution components. Finally, the classification accuracy of the validation set was 90.69%, the classification index AUO_ROC was 94.61%, the precision was 90.61%, and the recall was 90.65%.
[0073] According to the method of this embodiment, 179 spectrogram signals from fulvic acid solution and 332 spectrogram signals from ultrapure water were used as training sample sets to train the neural network model. Another 59 spectrogram signals from fulvic acid solution and 111 spectrogram signals from ultrapure water were used as validation sample sets. The trained neural network was used to determine the composition of the solution. Finally, the classification accuracy of the validation set was 84.38%, the classification index AUO_ROC was 91.90%, the precision was 82.54%, and the recall was 83.33%.
[0074] In summary, the liquid composition detection method provided in this embodiment pads the original electrical signal with zeros to a preset length to ensure consistent data length for each frame during subsequent framing. Then, an overlapping framing strategy is employed to divide the non-stationary long signal into multiple approximately stationary short segments. Frame extraction is rapidly completed by constructing an index matrix, avoiding the inefficiency of loop traversal. Overlapping framing preserves the temporal dynamic information of charge transfer during droplet sliding, allowing transient changes in the signal to be fully captured in subsequent frequency domain analysis.
[0075] After applying a window function to each frame of the signal, a discrete Fourier transform is performed to obtain a complex spectrum matrix. The square of the amplitude is then calculated to obtain the spectrum signal. This transform amplifies the extremely weak differences in material composition in the original time domain (such as electrical signal fluctuations caused by different metal ions or low concentrations of organic matter) into significant changes in the energy distribution in the frequency domain, solving the technical problem that statistical correlation cannot be established by simply relying on voltage or current peak values.
[0076] The spectral signals of a large number of droplets with known components are used as two-dimensional tensors input to a convolutional neural network. Automatic extraction time of the convolutional layers. Local deep features in the frequency domain are flattened and mapped to the component category space through a fully connected layer. A Softmax classifier and cross-entropy loss are combined, and the Adam optimization algorithm iteratively updates the network parameters until the loss converges. The neural network can autonomously learn the subtle response patterns of different liquid components at specific frequency bands and times, significantly improving recognition accuracy and robustness compared to manually designed features or simple statistical methods. Experimental verification shows that the classification accuracy for similar components such as electrolytes and non-electrolytes, different metal ions (e.g., lithium chloride and magnesium chloride), and organic matter (e.g., humic acid) can reach over 80% or even 100%.
[0077] By inputting the spectral signal of the droplet to be tested into the trained model, the composition category of the substance can be output. The entire process realizes end-to-end detection from signal acquisition to intelligent discrimination, without the need for expensive instruments or professional operation, providing an efficient and low-cost technical means for scenarios such as decentralized water quality monitoring and industrial liquid analysis.
[0078] Example 2 Based on the same inventive concept as Embodiment 1, this embodiment provides a liquid substance composition detection system. Since the principle of this system in solving the problem is similar to that of the aforementioned liquid substance composition detection method, the implementation of this system can refer to the implementation of the liquid substance composition detection method.
[0079] like Figure 9 As shown, the liquid substance composition detection system includes: The acquisition module 10 is used to acquire the original electrical signal generated by the droplets of the target liquid after friction.
[0080] Conversion module 20, used to convert the original electrical signal into a spectrogram signal, includes: The original electrical signal is filled with zeros at the end until the number of sampling points of the original electrical signal reaches a preset threshold to obtain the first electrical signal.
[0081] The first electrical signal is divided into frames, and an index matrix is constructed based on the number of sampling points in each frame and the distance between the starting positions of sampling points in two adjacent frames in the first electrical signal.
[0082] The index values are obtained by indexing the first electrical signal using the index matrix to obtain the framed electrical signal matrix.
[0083] The electrical signal matrix is processed by discrete Fourier transform to obtain a complex spectrum matrix.
[0084] The complex spectrum matrix F is converted into a spectrum signal P according to the following formula: .
[0085] Where |·| represents the absolute value; N fft The number of data points used when performing a discrete Fourier transform on each frame of electrical signal.
[0086] Training module 30 is used to train a neural network using the spectral signals of droplets with known liquid composition as a training set, and to use the trained neural network as a liquid composition detection model.
[0087] The detection module 40 is used to input the spectrum signal of the droplets of the liquid to be tested into the liquid composition detection model, so as to output the composition of the liquid to be tested.
[0088] For more detailed information on the working process of each of the above modules, please refer to the relevant content disclosed in Example 1, which will not be repeated here.
[0089] Example 3 This embodiment provides a computer device, including a processor and a memory; wherein, when the processor executes the computer program stored in the memory, it implements the steps of the liquid substance composition detection method described in Embodiment 1.
[0090] For a more detailed explanation of the above method, please refer to the relevant content disclosed in Example 1, which will not be repeated here.
[0091] Example 4 This embodiment provides a computer-readable storage medium for storing a computer program; when the computer program is executed by a processor, it implements the steps of the liquid substance composition detection method described in Embodiment 1.
[0092] For a more detailed explanation of the above method, please refer to the relevant content disclosed in Example 1, which will not be repeated here.
[0093] Example 5 This embodiment provides a computer program product, including computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, they implement the steps of the liquid substance composition detection method described in Embodiment 1.
[0094] For a more detailed explanation of the above method, please refer to the relevant content disclosed in Example 1, which will not be repeated here.
[0095] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems, devices, storage media, and computer program products disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section.
[0096] Those skilled in the art will clearly understand that the techniques in the embodiments of this application can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application or some parts of the embodiments.
[0097] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.
[0098] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).
[0099] As an example, computer-executable instructions can be deployed to execute on a single electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed across multiple locations and interconnected via a communication network.
[0100] The present application has been described in detail above with reference to specific embodiments and exemplary examples; however, these descriptions should not be construed as limiting the present application. Those skilled in the art will understand that various equivalent substitutions, modifications, or improvements can be made to the technical solutions and implementation methods of the present application without departing from the spirit and scope of the present application, and all such modifications and improvements fall within the scope of the present application. The scope of protection of the present application is determined by the appended claims.
Claims
1. A method for detecting the composition of a liquid substance, characterized in that, include: Acquire the original electrical signal generated by the droplets of the target liquid after friction; Converting the original electrical signal into a spectrogram signal includes: Fill the end of the original electrical signal with 0 until the number of sampling points of the original electrical signal reaches a preset threshold to obtain the first electrical signal; The first electrical signal is divided into frames, and an index matrix is constructed based on the number of sampling points in each frame and the distance between the starting positions of sampling points in two adjacent frames within the first electrical signal, including: The expression for constructing index matrix I: ; Where, N step is the distance between the starting positions of the sampling points of two adjacent frames of electrical signals in the first electrical signal; m is the first matrix; T denotes the transpose of a matrix; For 1 row N frame A second matrix consisting of columns, all of which are 1s; N frame The number of sampling points in each frame of electrical signal; 1 M The third matrix is M rows and 1 column, with all elements equal to 1; M is the number of electrical signals after framing; r is the fourth matrix; L represents the total number of sampling points for the original electrical signal. Indicates rounding up; By indexing the first electrical signal using the index matrix, the framed electrical signal matrix is obtained, including: The expression for constructing the framed electrical signal matrix: ; Among them, X frame X is an electrical signal matrix composed of the electrical signal vectors of each frame; frame [q,e'] represents X frame The element in the q-th row and e'-th column; x pad [I q,e' [x] is the first electrical signal pad Middle I q,e' One element; I q,e' This refers to the element in the q-th row and e'-th column of index matrix I; The electrical signal matrix is processed using the Discrete Fourier Transform to obtain the complex spectrum matrix, including: Construct the expression for the complex spectrum matrix F: ; Where F[a,k] is the element in the a-th row and k-th column of the complex spectrum matrix F; X frame [a,b] represents X frame The element in the a-th row and b-th column; w[b] is the b-th element in the window function matrix; e is the natural constant; j is the imaginary unit; π is pi; k=1,2,...,N fft -1; The complex spectrum matrix F is converted into a spectrum signal P according to the following formula: ; Where |·| represents the absolute value; N fft The number of data points used when performing a discrete Fourier transform on each frame of electrical signal; The spectral signals of droplets with known liquid composition were used as the training set to train a neural network, and the trained neural network was used as a liquid composition detection model. The spectral signal of the droplets of the liquid to be tested is input into the liquid composition detection model to output the composition of the liquid to be tested.
2. The method for detecting the composition of liquid substances according to claim 1, characterized in that, The step of training a neural network using the spectral signals of droplets with known liquid compositions as a training set, and then using the trained neural network as a liquid composition detection model, includes: The two-dimensional tensor representing the droplet spectrogram signal is input into the neural network to be trained, so as to output the first vector corresponding to each droplet spectrogram signal; Perform softmax calculation on each first vector to obtain the category probability distribution vector corresponding to each droplet; The cross-entropy loss of the spectrum signal of each droplet is determined based on the category probability distribution vector corresponding to each droplet; The batch loss of all spectrogram signals in the current batch of droplets is determined based on the cross-entropy loss; The partial derivatives of the batch loss with respect to all trainable parameters of the neural network to be trained are used as the gradient of the batch loss. The batch loss gradient is used to update all trainable parameters multiple times until the batch loss stops decreasing, resulting in a trained neural network that can be used as a liquid substance composition detection model. The trained neural network parameters are all trainable parameters obtained from the last update.
3. The method for detecting the composition of liquid substances according to claim 2, characterized in that, The step of inputting the two-dimensional tensor representing the droplet spectrum signal into the neural network to be trained, so as to output a first vector corresponding to each droplet spectrum signal, includes: The first vector h corresponding to the spectrum signal of each droplet is calculated according to the following formula: ; in, Let W be the activation function of the fully connected layer of the neural network to be trained; W is the weight matrix of the fully connected layer. It is a flattening function; is the activation function of the convolutional layer of the neural network to be trained; K is the convolutional kernel parameter; P is a two-dimensional tensor representing the droplet spectrum signal; is the spatial convolution operator, representing the convolution operation; c is the bias vector of the convolutional layer; d is the bias vector of the fully connected layer.
4. The method for detecting the composition of liquid substances according to claim 3, characterized in that, The process of updating all trainable parameters multiple times based on the batch loss gradient until the batch loss stops decreasing, to obtain a trained neural network, which serves as a liquid substance composition detection model, includes: All trainable parameters are updated multiple times according to the following formula: ; Among them, y (t) β1 is the first moment estimate of the gradient when updating all trainable parameters for the t-th time; β1 is the exponential decay rate of the first moment; y (t-1) g is the first moment estimate of the gradient when updating all trainable parameters for the (t-1)th time; (t) v is the gradient when updating all trainable parameters for the t-th time; (t) β2 is the second moment estimate of the squared gradient when updating all trainable parameters for the t-th time; β2 is the exponential decay rate of the second moment; v (t-1) The second moment estimate of the squared gradient when updating all trainable parameters for the (t-1)th time; The gradient first moment estimate after bias correction when updating all trainable parameters for the t-th time; The gradient squared second moment estimate after bias correction when updating all trainable parameters for the (t-1)th time; Let be the set of all trainable parameters at the t-th update; Let be the set of all trainable parameters at the (t-1)th update; α is the preset learning rate; ε is a constant.
5. A liquid substance composition detection system, characterized in that, include: The acquisition module is used to acquire the original electrical signal generated by the droplets of the target liquid after friction; The conversion module, used to convert the original electrical signal into a spectrogram signal, includes: Fill the end of the original electrical signal with 0 until the number of sampling points of the original electrical signal reaches a preset threshold to obtain the first electrical signal; The first electrical signal is divided into frames, and an index matrix is constructed based on the number of sampling points in each frame and the distance between the starting positions of sampling points in two adjacent frames within the first electrical signal, including: The expression for constructing index matrix I: ; Where, N step is the distance between the starting positions of the sampling points of two adjacent frames of electrical signals in the first electrical signal; m is the first matrix; T denotes the transpose of a matrix; For 1 row N frame A second matrix consisting of columns, all of which are 1s; N frame The number of sampling points in each frame of electrical signal; 1 M The third matrix is M rows and 1 column, with all elements equal to 1; M is the number of electrical signals after framing; r is the fourth matrix; L represents the total number of sampling points for the original electrical signal. Indicates rounding up; By indexing the first electrical signal using the index matrix, the framed electrical signal matrix is obtained, including: The expression for constructing the framed electrical signal matrix: ; Among them, X frame X is an electrical signal matrix composed of the electrical signal vectors of each frame; frame [q,e'] represents X frame The element in the q-th row and e'-th column; x pad [I q,e' [x] is the first electrical signal pad Middle I q,e' One element; I q,e' This refers to the element in the q-th row and e'-th column of index matrix I; The electrical signal matrix is processed using the Discrete Fourier Transform to obtain the complex spectrum matrix, including: Construct the expression for the complex spectrum matrix F: ; Where F[a,k] is the element in the a-th row and k-th column of the complex spectrum matrix F; X frame [a,b] represents X frame The element in the a-th row and b-th column; w[b] is the b-th element in the window function matrix; e is the natural constant; j is the imaginary unit; π is pi; k=1,2,...,N fft -1; The complex spectrum matrix F is converted into a spectrum signal P according to the following formula: ; Where |·| represents the absolute value; N fft The number of data points used when performing a discrete Fourier transform on each frame of electrical signal; The training module is used to train a neural network using the spectral signals of droplets with known liquid composition as the training set, and to use the trained neural network as a liquid composition detection model. The detection module is used to input the spectral signal of the droplets of the liquid to be tested into the liquid composition detection model, so as to output the composition of the liquid to be tested.
6. A computer-readable storage medium, characterized in that, Used to store computer programs; when executed by a processor, the computer programs implement the steps of the liquid substance composition detection method according to any one of claims 1-4.
Citation Information
Patent Citations
Friction pair lubrication state automatic identification method based on friction electric signals
CN116067816A
Experimental method and device for quantifying liquid friction static sequence
CN118393233A