Fuel cell life prediction method and device, electronic equipment and storage medium
By constructing a dual-model fusion prediction model using an improved Nernst equation and Transformer algorithm, and combining multi-scale physical constraints and cross-attention fusion, the accuracy and stability issues of fuel cell remaining lifetime prediction under complex operating conditions are solved, achieving accurate and stable fuel cell lifetime prediction and supporting online adaptive updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-22
- Publication Date
- 2026-04-07
AI Technical Summary
Existing methods for predicting the remaining life of fuel cells suffer from low accuracy under complex operating conditions, poor stability when data is missing, insufficient prediction stability due to fixed-weight fusion, and a disconnect between theory and practice, failing to meet the operation and maintenance needs of fuel cells.
An improved Nernst equation is used to construct a mechanistic sub-model and an improved Transformer algorithm to construct a data-driven sub-model. Combined with multi-scale physical constraints and cross-attention fusion prediction models, and through dynamic weight optimization and error correction mechanisms, accurate and stable prediction of the remaining life of fuel cells is achieved.
It improves the accuracy and stability of predictions under complex operating conditions, adapts to the feature representation and data adaptability of different operating conditions, supports online adaptive updates, and is suitable for real-time operation and maintenance of vehicle fuel cells.
Smart Images

Figure CN121812646A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of fuel cell monitoring and maintenance technology, and particularly relates to a fuel cell life prediction method, device, electronic equipment and storage medium. Background Technology
[0002] As a clean and efficient energy conversion device, fuel cells are increasingly widely used in new energy vehicles, distributed energy systems, and other fields. Accurate prediction of their remaining lifespan is crucial for ensuring stable equipment operation and reducing maintenance costs. Traditional fuel cell remaining lifespan prediction methods have many limitations and struggle to meet the actual needs under complex operating conditions: Early prediction technologies often relied on single-mechanism models or single-data-driven models. While single models based on electrochemical mechanisms (such as the traditional Nernst equation) have theoretical support, they do not fully consider the impact of complex operating conditions such as frequent start-stop cycles, low-temperature starts, and high-load fluctuations on the degradation rate, resulting in a deviation of over 20% between predicted and actual lifespans, making them unsuitable for the stringent maintenance requirements of automotive fuel cells. Data-driven models based on algorithms such as LSTM and the traditional Transformer rely on massive amounts of continuous historical data (typically over 1000 hours). In scenarios where data accumulation is insufficient in the early stages of new installations or sensor failures cause data interruptions, prediction accuracy drops sharply, and sometimes even fails to produce valid results. With technological advancements, some solutions employ a hybrid model combining "mechanism + data-driven" approaches. However, significant shortcomings remain: existing hybrid models often fuse the results of two models with fixed weights, failing to consider the accuracy differences between the two models under varying operating conditions. For instance, data-driven models exhibit superior nonlinear fitting capabilities under high-load conditions, while mechanistic models demonstrate stronger stability under low-load conditions. Fixed weights result in insufficient prediction stability across all operating conditions. Furthermore, data preprocessing often utilizes a single algorithm, exhibiting poor adaptability to non-normally distributed data and data with high missing rates, further impacting prediction accuracy. Additionally, issues such as low efficiency in hyperparameter optimization and a lack of targeted error correction, coupled with a disconnect between the prediction process and physical laws, limit the engineering applicability of current technologies. Therefore, a fuel cell remaining life prediction scheme that balances operating condition adaptability, data adaptability, and prediction accuracy, while deeply integrating theory and practice, is urgently needed to address core issues in existing technologies, including low accuracy under complex operating conditions, poor stability when data is missing, unadaptive weight allocation, and a disconnect between theory and practice. Summary of the Invention
[0003] Purpose of the invention: The technical problem to be solved by the present invention is to address the shortcomings of the prior art by providing a method, device, electronic device and storage medium for predicting the life of fuel cells. By optimizing the data preprocessing process, constructing an adaptive dual-model fusion architecture, introducing multi-scale physical constraints and cross-attention fusion prediction models, and improving the hyperparameter optimization and error correction mechanism, the invention achieves accurate and stable prediction of the remaining life of fuel cells under all operating conditions, providing a reliable decision-making basis for equipment operation and maintenance.
[0004] This invention firstly discloses a method for predicting the lifespan of a fuel cell, characterized by comprising the following steps:
[0005] Step 1: Deploy multiple measuring points and multivariable sensors in the fuel cell system to collect fuel cell operating data in real time. The fuel cell operating data includes voltage, current, stack temperature, humidity, and hydrogen partial pressure.
[0006] Step 2 involves preprocessing and standardizing the fuel cell operation data to construct a fuel cell health monitoring dataset, which is then divided into training, validation, and test sets. Data preprocessing employs a combination of the Laida criterion (3σ criterion) and an attention-based interpolation algorithm, while standardization utilizes the Z-score algorithm.
[0007] Step 3: Use the improved Nernst equation to construct a mechanistic sub-model to extract the theoretical feature matrix, and use the improved Transformer algorithm to construct a data-driven sub-model to extract the actual feature matrix. Then, merge the theoretical feature matrix and the actual feature matrix according to their weights into a new matrix that is easy to predict.
[0008] Step 4: Input the fused feature matrix into the multi-scale physical constraint and cross-attention fusion prediction model to calculate the predicted voltage, and at the same time use the inverse weight allocation algorithm to optimize the model weight parameters.
[0009] Step 5: Error correction of the model's prediction results is performed by interpolating through an attention mechanism and dynamically adjusting the operating condition attenuation coefficient.
[0010] Step 6: Calculate the remaining lifespan by comparing the preset failure threshold with the predicted voltage, and determine whether to issue an early warning based on the remaining lifespan.
[0011] In step 3, the step of using the improved Nernst equation to construct a mechanistic sub-model and extract the theoretical feature matrix includes:
[0012] Introducing an operating condition attenuation coefficient k (integrating both reactor temperature and current density factors), a voltage attenuation model is derived based on the improved Nernst equation:
[0013] ,
[0014] in, This represents the theoretical voltage value of the fuel cell at operating time t. It is the reversible potential (unit: V). Current density (unit: A / cm²). The impedance is in ohms (unit: Ω). To activate the overpotential, The gas constant is... Absolute temperature For electron transfer number, It is Faraday's constant. For exchange current density, This is concentration overpotential. For limiting current density, Runtime (in hours) Activation energy (unit: J / mol) is the universal gas constant. exp represents the natural exponential function.
[0015] The operating condition attenuation coefficient k is adjusted according to the coupling of reactor temperature and current density:
[0016] ,
[0017] in The stack temperature (unit: °C) is the temperature at which the stack temperature is reached. or When k is used, it is automatically corrected to 1.2 times the calculated value.
[0018] Substitute the training set data into the output to calculate the theoretical feature matrix corresponding to the theoretical voltage decay curve. The theoretical feature matrix It is an i-row matrix, where each row represents the theoretical characteristic representation of a variable.
[0019] In step 3, the step of using the improved Transformer algorithm to construct a data-driven sub-model to extract the actual feature matrix includes:
[0020] A condition-related attention head is added to the Transformer encoder layer, and a multi-head attention weight optimization formula is used to prioritize the extraction of stack temperature and current-related features:
[0021] ,
[0022] in, For the improved multi-head attention calculation function, These are the query matrix, key matrix, and value matrix, respectively, with Softmax being the normalization exponential function. The dimension of the key vector. For position encoding, For time steps, For dimensional indexing, For model dimensions, Encoding operating conditions (fusion reactor temperature) With current density (a nonlinear mapping), T represents transpose;
[0023] The standardized dataset was input into the improved Transformer model, with the encoder layer set to 6 layers, the attention heads to 8, and the hidden layer dimension to 512.
[0024] The data decay pattern is learned using the training set, and hyperparameters are adjusted using the validation set to output the actual feature matrix corresponding to the actual voltage decay curve. The actual feature matrix It is an i-row matrix, where each row represents the actual characteristic representation of a variable.
[0025] Step 3, which involves merging the theoretical feature matrix and the actual feature matrix according to their weights into a new matrix that is easier to predict, includes:
[0026] The dynamic weights are calculated based on the dual-model error rate and the operating condition fit, and the fusion formula is as follows:
[0027] ,
[0028] in, It is the fused feature matrix. , , These are weighting coefficients. , , , The error rate of the mechanism sub-model. To drive the sub-model error rate, For the working condition adaptation coefficient of the mechanism model, The operating condition adaptation coefficients for the data-driven model. This is a cross-attention fusion term used to capture the correlation information between two types of feature matrices.
[0029] In step 4, the multi-scale physical constraints and cross-attention fusion prediction model are implemented through the following steps:
[0030] Step 6.1, Model Architecture Composition: The multi-scale physical constraint and cross-attention fusion prediction model includes a multi-scale feature splitting module, a physical constraint embedding layer, a dynamic cross-attention weight optimization module, and a multi-objective joint optimization module. Each module works together to realize the prediction voltage calculation and weight parameter optimization.
[0031] Step 6.2: The multi-scale feature segmentation module performs multi-scale feature segmentation and directional fusion;
[0032] For the fused feature matrix Perform multi-scale splitting and targeted fusion:
[0033] Will Decomposed into long-cycle theoretical characteristics (Capturing decay trends over 100 hours) and short-cycle theoretical characteristics (Capturing 1-hour and 24-hour operating responses), based on the time-scale characteristics of voltage decay in the Nernst equation.
[0034] Will Decomposed into long-term actual characteristics (Transformer long sequence encoding output, input window size = 100h) and short-period actual features (Transformer short sequence encoding output, input window size = 24h).
[0035] The formula for targeted fusion is:
[0036] ,
[0037] in, intermediate parameters , , , The weight allocation formula is as follows: Through dynamic allocation of long / short period error rates in the dual-model approach, the weights are assigned as follows: , , , , in These are the weights of the long-period features of the mechanistic sub-model. It is the error rate of long-term prediction by the mechanistic sub-model. It is the error rate of long-term prediction by the data-driven sub-model. It is the operating condition adaptation coefficient of the long-period characteristics of the mechanism sub-model. It is the working condition adaptation coefficient of the long-cycle characteristics of the data-driven sub-model. These are the weights of the short-period features of the mechanistic sub-model. It is the error rate of short-period predictions by the mechanistic sub-model. It is the error rate of short-term prediction by the data-driven sub-model. It is the operating condition adaptation coefficient of the short-period characteristics of the mechanism sub-model. It is the operating condition adaptation coefficient of the short-cycle characteristics of the data-driven sub-model. It is the weight of long-term features in the data-driven sub-model. These are the weights of short-cycle features in the data-driven sub-model;
[0038] Step 6.3: The physical constraint embedding layer performs physical constraint embedded prediction;
[0039] The core physical laws of fuel cells are embedded in the prediction process, forcing the output to conform to the electrochemical mechanism, and the predicted voltage at time t is obtained. The formula is: , in, The output voltage of the mechanism sub-model. The output voltage of the data-driven sub-model is... This is a historical voltage smoothing compensation term. This represents the sliding window size, with a value ranging from 5 to 20. for The operating condition attenuation coefficient at time t, Physical constraint factor, Calculate the voltage for the pure Nernst equation. This is the constraint coefficient.
[0040] Step 6.4: The dynamic cross-attention weight optimization module executes the dynamic cross-attention weight optimization algorithm; The model weight parameters are optimized using a dynamic cross-attention weight optimization algorithm, and the implementation process is as follows: Define the objective function for the weighted prediction error rate: , in, The weighted prediction error rate, For the number of parameters ( (corresponding to voltage, current, stack temperature, humidity, and hydrogen partial pressure). For the first Measured values of each parameter For the first The importance weight of each parameter (voltage) , reactor temperature Current ,humidity partial pressure of hydrogen ); Calculate dynamic cross-attention score : , in, for No. Dimensional features, for No. dimensional features, where d is the feature dimension ( ), for The working condition adaptation coefficients corresponding to the dimensions (obtained through offline pre-training based on the training set data). Calculate the average attention score and : , , in, yes The number of feature dimensions, yes The number of feature dimensions; The weight update formula is: , , in, The error rate of the mechanism sub-model. To drive the sub-model error rate, For the operating condition adaptation coefficients of the mechanism sub-model, The operating condition adaptation coefficient (range 0.5~1.0) is used for the data-driven sub-model.
[0041] Set the stopping optimization conditions: the number of iterations is greater than or equal to the threshold of 50 rounds, and the error rate converges. or attention score convergence ( ) one of the three.
[0042] Step 6.5, the multi-objective joint optimization module performs multi-objective joint optimization: adopting a multi-objective joint optimization objective function. The model is trained while simultaneously constraining prediction accuracy, weight rationality, voltage smoothness, and physical consistency. The formula is as follows: , in, For the sample size, This is the measured voltage. This is a weighted regularization term to prevent overfitting. This is a voltage curve smoothing term, adapted to the continuous voltage decay characteristics of fuel cells. As a physical consistency constraint, it forces the predicted voltage to conform to the core logic of the Nernst equation. The regularization coefficient has a value range of 0.001 to 0.05 and is adaptively adjusted using the validation set.
[0043] Step 5 includes:
[0044] First, the error between the initial predicted voltage and the measured voltage of the multi-scale physical constraint and cross-attention fusion prediction model is calculated:
[0045] ,
[0046] in, It's an error. It is the measured voltage. It is the initial predicted voltage; The 3σ criterion was used to examine outlier error terms, and the mean μ and standard deviation of the voltage parameters were calculated. Remove Abnormal error samples; if the error is caused by missing data, use an attention mechanism for interpolation to complete it: , in, This is the completed data. It's missing data. It is the first One related parameter data, To score attention, For Gaussian kernel function, For kernel width, For missing data timestamps, For associated data timestamps; If the error is caused by changes in operating conditions, the operating condition attenuation coefficient can be dynamically adjusted. Correction: , in, This is the adjusted attenuation coefficient. It is the initial attenuation coefficient. This represents the change in reactor temperature (unit: °C). This represents the change in current density (unit: A / cm²). The threshold for changes in operating conditions (value range 5 and 10); The initial predicted voltage is added to the corrected error compensation value to obtain the final predicted voltage: , in, It is the final predicted voltage. This is the corrected error compensation value. For activation function, This is the error adjustment threshold (range 0.01~0.1).
[0047] Step 6 includes: Prediction Matrix This is an n x 1 matrix containing the predicted voltage values at each time point: , in, Representation matrix Each line, The predicted voltage value at time point n;
[0048] Set failure threshold Proton exchange membrane fuel cells for vehicles Adaptive adjustment based on temperature:
[0049] ,
[0050] The value range is 0.55V~0.65V).
[0051] The piecewise interpolation method is used to find the first occurrence of a given element in the prediction matrix. corresponding time :
[0052] ,
[0053] in, For the first At a certain point in time, For the first Predicted voltage at each time point Sampling interval (unit: h).
[0054] Calculate remaining lifetime:
[0055] ,
[0056] in, Remaining lifetime (unit: hours). Current running time (in hours). This is a compensation item for historical prediction bias. This represents the number of historical validation samples, with a value ≥ 100.
[0057] Set early warning threshold The remaining lifespan and operating time are dynamically adjusted as a percentage:
[0058] ,
[0059] in The baseline warning threshold is set at 100-500 hours. The design life of the fuel cell is ranged from 5000 to 10000 hours. The system will issue a warning at that time.
[0060] The present invention also provides an apparatus comprising a memory and a processor, wherein:
[0061] Memory is used to store computer programs that can run on a processor.
[0062] A processor is configured to execute the steps of the fuel cell remaining life prediction method while running the computer program.
[0063] The present invention also provides an electronic device, comprising: at least one processor; at least one memory for storing at least one program. When the at least one program is executed by the at least one processor, the at least one processor implements the aforementioned fuel cell remaining life prediction method. The processor is based on ARM Cortex and A76 architectures, the memory is DDR4 memory with a capacity of ≥8GB, and the communication interface supports the CAN bus protocol, adapting to automotive deployment scenarios.
[0064] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the aforementioned method for predicting the remaining life of a fuel cell. The storage medium includes removable or fixed storage carriers such as ROM, RAM, USB flash drive, and optical disc.
[0065] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention innovatively adopts a dual architecture of an improved Nernst equation mechanism sub-model and an improved Transformer data-driven sub-model, extracting theoretical and actual feature matrices respectively. Weights are dynamically allocated based on the error rate of the two models and their adaptability to operating conditions. Simultaneously, a cross-attention fusion term is introduced to capture the correlation information between the two types of features, forming a fused feature matrix that balances theoretical logic and data fit, greatly improving the comprehensiveness and adaptability of feature representation. Furthermore, a multi-scale physical constraint and cross-attention fusion prediction model is constructed. Through long-term and short-term feature decomposition and targeted fusion to adapt to different decay characteristics, the core laws of electrochemistry are embedded into the prediction process. Combined with a dynamic cross-attention weight optimization algorithm and multi-objective joint optimization, this avoids prediction results from violating physical laws and achieves adaptive weight adjustment, significantly improving the prediction stability and accuracy under complex operating conditions. Finally, anomaly errors are identified using the 3σ criterion. Attention-based interpolation for missing data and dynamic adjustment of the operating condition attenuation coefficient are employed to address data loss and operating condition changes, respectively. The sigmoid activation function is used to adjust the error compensation intensity, achieving precise correction of prediction errors. This effectively reduces prediction bias caused by data quality fluctuations and sudden changes in operating conditions, improving the reliability of the results. In summary, this invention comprehensively considers the multi-dimensional operating parameters and complex operating conditions of fuel cells, achieving accurate and stable prediction of remaining lifespan. It not only overcomes the limitations of traditional single-model or fixed-weight fusion but also supports online adaptive updates and on-board deployment, helping to promptly identify potential fault risks and providing reliable technical support for the full lifecycle operation and maintenance of fuel cells. This has significant practical implications and broad application prospects. Attached Figure Description
[0066] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments, and the advantages of the present invention in the above and / or other aspects will become clearer.
[0067] Figure 1 This is a flowchart of a method for predicting the remaining life of fuel cells based on big data.
[0068] Figure 2 This is an architecture diagram of the multi-scale physical constraints and cross-attention fusion prediction model in this invention.
[0069] Figure 3 This is a flowchart of the dynamic cross-attention weight optimization algorithm used in this invention.
[0070] Figure 4 This is a flowchart of the error correction process in this invention. Detailed Implementation
[0071] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0072] like Figure 1 As shown, this embodiment of the invention provides a fuel cell lifetime prediction method, including the following steps:
[0073] Step 1: Deploy multiple measuring points and multivariable sensors in the fuel cell system to collect fuel cell operating data in real time. The fuel cell operating data includes voltage, current, stack temperature, humidity, and hydrogen partial pressure.
[0074] Step 2 involves preprocessing and standardizing the fuel cell operation data to construct a fuel cell health monitoring dataset, which is then divided into training, validation, and test sets in a 7:2:1 ratio. Data preprocessing employs a combination of the Laida criterion (3σ criterion) and an attention-based interpolation algorithm, while standardization utilizes the Z-score algorithm.
[0075] Step 3: Use the improved Nernst equation to construct a mechanistic sub-model to extract the theoretical feature matrix, and use the improved Transformer algorithm to construct a data-driven sub-model to extract the actual feature matrix. Then, merge the theoretical feature matrix and the actual feature matrix according to their weights into a new matrix that is easy to predict.
[0076] Step 4: Input the fused feature matrix into the multi-scale physical constraint and cross-attention fusion prediction model to calculate the predicted voltage, and at the same time use the inverse weight allocation algorithm to optimize the model weight parameters.
[0077] Step 5: Error correction of the model's prediction results is performed by interpolating through an attention mechanism and dynamically adjusting the operating condition attenuation coefficient.
[0078] Step 6: Calculate the remaining lifespan by comparing the preset failure threshold with the predicted voltage, and determine whether to issue an early warning based on the remaining lifespan.
[0079] In step 3, the step of using the improved Nernst equation to construct a mechanistic sub-model and extract the theoretical feature matrix includes:
[0080] Introducing an operating condition attenuation coefficient k (integrating both reactor temperature and current density factors), a voltage attenuation model is derived based on the improved Nernst equation:
[0081] ,
[0082] in, This represents the theoretical voltage value of the fuel cell at operating time t. It is the reversible potential (unit: V). Current density (unit: A / cm²). The impedance is in ohms (unit: Ω). To activate the overpotential, The gas constant is... Absolute temperature For electron transfer number, It is Faraday's constant. For exchange current density, This is concentration overpotential. For limiting current density, Runtime (in hours) Activation energy (unit: J / mol) is the universal gas constant. exp represents the natural exponential function.
[0083] The operating condition attenuation coefficient k is adjusted according to the coupling of reactor temperature and current density:
[0084] ,
[0085] in The stack temperature (unit: °C) is the temperature at which the stack temperature is reached. or When k is used, it is automatically corrected to 1.2 times the calculated value.
[0086] Substitute the training set data into the output to calculate the theoretical feature matrix corresponding to the theoretical voltage decay curve. The theoretical feature matrix It is an i-row matrix, where each row represents the theoretical characteristic representation of a variable.
[0087] In step 3, the step of using the improved Transformer algorithm to construct a data-driven sub-model to extract the actual feature matrix includes:
[0088] A condition-related attention head is added to the Transformer encoder layer, and a multi-head attention weight optimization formula is used to prioritize the extraction of stack temperature and current-related features:
[0089] ,
[0090] in, For the improved multi-head attention calculation function, These are the query matrix, key matrix, and value matrix, respectively, with Softmax being the normalization exponential function. The dimension of the key vector. For position encoding, For time steps, For dimensional indexing, For model dimensions, Encoding operating conditions (fusion reactor temperature) With current density (a nonlinear mapping), T represents transpose;
[0091] The standardized dataset was input into the improved Transformer model, with the encoder layer set to 6 layers, the attention heads to 8, and the hidden layer dimension to 512.
[0092] The data decay pattern is learned using the training set, and hyperparameters are adjusted using the validation set to output the actual feature matrix corresponding to the actual voltage decay curve. The actual feature matrix It is an i-row matrix, where each row represents the actual characteristic representation of a variable.
[0093] Step 3, which involves merging the theoretical feature matrix and the actual feature matrix according to their weights into a new matrix that is easier to predict, includes:
[0094] The dynamic weights are calculated based on the dual-model error rate and the operating condition fit, and the fusion formula is as follows:
[0095] ,
[0096] in, It is the fused feature matrix. , , These are weighting coefficients. , , , The error rate of the mechanism sub-model. To drive the sub-model error rate, For the working condition adaptation coefficient of the mechanism model, The operating condition adaptation coefficients for the data-driven model. This is a cross-attention fusion term used to capture the correlation information between two types of feature matrices.
[0097] In step 4, the multi-scale physical constraints and cross-attention fusion prediction model are implemented through the following steps:
[0098] Step 6.1, Model Architecture Composition: The multi-scale physical constraint and cross-attention fusion prediction model includes a multi-scale feature splitting module, a physical constraint embedding layer, a dynamic cross-attention weight optimization module, and a multi-objective joint optimization module. Each module works together to realize the prediction voltage calculation and weight parameter optimization.
[0099] Step 6.2: The multi-scale feature segmentation module performs multi-scale feature segmentation and directional fusion;
[0100] For the fused feature matrix Perform multi-scale splitting and targeted fusion:
[0101] Will Decomposed into long-cycle theoretical characteristics (Capturing decay trends over 100 hours) and short-cycle theoretical characteristics (Capturing 1-hour and 24-hour operating responses), based on the time-scale characteristics of voltage decay in the Nernst equation.
[0102] Will Decomposed into long-term actual characteristics (Transformer long sequence encoding output, input window size = 100h) and short-period actual features (Transformer short sequence encoding output, input window size = 24h).
[0103] The formula for targeted fusion is: , in, intermediate parameters , , , The weight allocation formula is as follows: Through dynamic allocation of long / short period error rates in the dual-model approach, the weights are assigned as follows: , , , , in These are the weights of the long-period features of the mechanistic sub-model. It is the error rate of long-term prediction by the mechanistic sub-model. It is the error rate of long-term prediction by the data-driven sub-model. It is the operating condition adaptation coefficient of the long-period characteristics of the mechanism sub-model. It is the working condition adaptation coefficient of the long-cycle characteristics of the data-driven sub-model. These are the weights of the short-period features of the mechanistic sub-model. It is the error rate of short-period predictions by the mechanistic sub-model. It is the error rate of short-term prediction by the data-driven sub-model. It is the operating condition adaptation coefficient of the short-period characteristics of the mechanism sub-model. It is the operating condition adaptation coefficient of the short-cycle characteristics of the data-driven sub-model. It is the weight of long-term features in the data-driven sub-model. These are the weights of short-cycle features in the data-driven sub-model;
[0104] Step 6.3: The physical constraint embedding layer performs physical constraint embedded prediction;
[0105] The core physical laws of fuel cells are embedded in the prediction process, forcing the output to conform to the electrochemical mechanism, and the predicted voltage at time t is obtained. The formula is:
[0106] ,
[0107] in, The output voltage of the mechanism sub-model. The output voltage of the data-driven sub-model is... This is a historical voltage smoothing compensation term. This represents the sliding window size, with a value ranging from 5 to 20. for The operating condition attenuation coefficient at time t, Physical constraint factor, Calculate the voltage for the pure Nernst equation. This is the constraint coefficient.
[0108] Step 6.4: The dynamic cross-attention weight optimization module executes the dynamic cross-attention weight optimization algorithm;
[0109] The model weight parameters are optimized using a dynamic cross-attention weight optimization algorithm, and the implementation process is as follows:
[0110] Define the objective function for the weighted prediction error rate:
[0111] ,
[0112] in, The weighted prediction error rate, For the number of parameters ( (corresponding to voltage, current, stack temperature, humidity, and hydrogen partial pressure). For the first Measured values of each parameter For the first The importance weight of each parameter (voltage) , reactor temperature Current ,humidity partial pressure of hydrogen );
[0113] Calculate dynamic cross-attention score :
[0114] ,
[0115] in, for No. Dimensional features, for No. dimensional features, where d is the feature dimension ( ), for The working condition adaptation coefficients corresponding to the dimensions (obtained through offline pre-training based on the training set data).
[0116] Calculate the average attention score and :
[0117] ,
[0118] ,
[0119] in, yes The number of feature dimensions, yes The number of feature dimensions;
[0120] The weight update formula is:
[0121] ,
[0122] ,
[0123] in, The error rate of the mechanism sub-model. To drive the sub-model error rate, For the operating condition adaptation coefficients of the mechanism sub-model, The operating condition adaptation coefficient (range 0.5~1.0) is used for the data-driven sub-model.
[0124] Set the stopping optimization conditions: the number of iterations is greater than or equal to the threshold of 50 rounds, and the error rate converges. or attention score convergence ( ) one of the three.
[0125] Step 6.5, the multi-objective joint optimization module performs multi-objective joint optimization: adopting a multi-objective joint optimization objective function. The model is trained while simultaneously constraining prediction accuracy, weight rationality, voltage smoothness, and physical consistency. The formula is as follows:
[0126] ,
[0127] in, For the sample size, This is the measured voltage. This is a weighted regularization term to prevent overfitting. This is a voltage curve smoothing term, adapted to the continuous voltage decay characteristics of fuel cells. As a physical consistency constraint, it forces the predicted voltage to conform to the core logic of the Nernst equation. The regularization coefficient has a value range of 0.001 to 0.05 and is adaptively adjusted using the validation set.
[0128] Step 5 includes:
[0129] First, the error between the initial predicted voltage and the measured voltage of the multi-scale physical constraint and cross-attention fusion prediction model is calculated: , in, It's an error. It is the measured voltage. It is the initial predicted voltage; The 3σ criterion was used to examine outlier error terms, and the mean μ and standard deviation of the voltage parameters were calculated. Remove Abnormal error samples; if the error is caused by missing data, use an attention mechanism for interpolation to complete it: , in, This is the completed data. It's missing data. It is the first One related parameter data, To score attention, For Gaussian kernel function, For kernel width, For missing data timestamps, For associated data timestamps;
[0130] If the error is caused by changes in operating conditions, the operating condition attenuation coefficient can be dynamically adjusted. Correction: , in, This is the adjusted attenuation coefficient. It is the initial attenuation coefficient. This represents the change in reactor temperature (unit: °C). This represents the change in current density (unit: A / cm²). The threshold for changes in operating conditions (value range 5 and 10); The initial predicted voltage is added to the corrected error compensation value to obtain the final predicted voltage: , in, It is the final predicted voltage. This is the corrected error compensation value. For activation function, This is the error adjustment threshold (range 0.01~0.1).
[0131] Step 6 includes: Prediction Matrix This is an n x 1 matrix containing the predicted voltage values at each time point:
[0132] ,
[0133] in, Representation matrix Each line, The predicted voltage value at time point n;
[0134] Set failure threshold Proton exchange membrane fuel cells for vehicles Adaptive adjustment based on temperature:
[0135] ,
[0136] The value range is 0.55V~0.65V).
[0137] The piecewise interpolation method is used to find the first occurrence of a given element in the prediction matrix. corresponding time :
[0138] ,
[0139] in, For the first At a certain point in time, For the first Predicted voltage at each time point Sampling interval (unit: h).
[0140] Calculate remaining lifetime:
[0141] ,
[0142] in, Remaining lifetime (unit: hours). Current running time (in hours). This is a compensation item for historical prediction bias. This represents the number of historical validation samples, with a value ≥ 100.
[0143] Set early warning threshold The remaining lifespan and operating time are dynamically adjusted as a percentage:
[0144] ,
[0145] in The baseline warning threshold is set at 100-500 hours. The design life of the fuel cell is ranged from 5000 to 10000 hours. The system will issue a warning at that time.
[0146] In one specific embodiment of the present invention, the method includes:
[0147] 1. Data Collection
[0148] The experimental data comes from the open-source PEM fuel cell dataset (pem-dataset1), which contains complete data for Nafion 112 membrane standard testing and MEA activation testing, covering typical operating scenarios for automotive proton exchange membrane fuel cells. The data collection period was from March 2024 to March 2025, with a sampling frequency of 1Hz. Core parameters included voltage, current density, stack temperature, relative humidity, and hydrogen partial pressure, comprehensively recording the entire operating cycle of the fuel cell from activation to degradation. The data was divided into training, validation, and test sets at 70%:15%:15%, and after outlier removal, it was used for model training, hyperparameter tuning, and performance verification.
[0149] 2. Method parameter settings
[0150] 2.1 Data Preprocessing and Standardization Parameters
[0151] (1) The joint state vector of multi-source data has a dimension of 5 (voltage + current density + stack temperature + humidity + hydrogen partial pressure), which fully covers the key operating parameters of fuel cells;
[0152] (2) Outlier removal adopts the Raida criterion (3σ criterion), and the mean μ and standard deviation σ are calculated independently for a single parameter. The outlier threshold interval is set as [μ-3σ, μ+3σ].
[0153] (3) Missing value completion adopts an interpolation algorithm based on attention mechanism, with a kernel width σ1=3, which is suitable for application scenarios with a missing value rate ≤30%;
[0154] (4) Standardization adopts the Z-score algorithm to map all parameters to a standard normal distribution with mean = 0 and standard deviation = 1, thereby eliminating dimensional differences.
[0155] 2.2 Dual Model Core Parameters
[0156] 2.2.1 Improved parameters of the Nernst equation mechanism sub-model
[0157] (1) Basic electrochemical parameters: reversible potential E0 = 1.23 V, ohmic impedance R0 = 0.01 Ω, activation energy E a =80000 J / mol;
[0158] (2) Dynamic formula for the attenuation coefficient k under operating conditions:
[0159] ,
[0160] Where T2 is the stack temperature (°C) and i is the current density (A / cm²); when T2 < −10°C or i > 1.5 A / cm², k is corrected to 1.2 times the calculated value;
[0161] (3) The theoretical feature matrix M1 has a dimension of 5 rows × 128 columns, with each row corresponding to the theoretical decay feature of one parameter.
[0162] 2.2.2 Improve the parameters of the Transformer data-driven sub-model
[0163] (1) Model structure: 6 encoder layers, 8 attention heads (including 2 special attention heads for working conditions), and 512 hidden layer dimensions;
[0164] (2) Attention calculation parameters: Key vector dimension d k =64, the position encoding adopts sinusoidal function encoding, and the operating condition encoding integrates the nonlinear mapping of reactor temperature and current density;
[0165] (3) The actual feature matrix M2 has a dimension of 5 rows × 128 columns, which is consistent with the dimension of the theoretical feature matrix, making it easier for subsequent fusion calculation.
[0166] 2.3, such as Figure 2 As shown, the fusion matrix and prediction parameters
[0167] (1) Basic parameters for dynamic weight calculation: initial error rate of mechanism sub-model ε1=3.2%, initial error rate of data-driven sub-model ε2=2.8%; working condition adaptation coefficient of mechanism model α1=0.85, working condition adaptation coefficient of data-driven model α2=0.92;
[0168] (2) Multi-scale splitting parameters: long-period feature input window size = 100h, short-period feature input window size = 24h; long-period error rate ε 1l =2.9%, ε 2l =2.5%, short-cycle error rate ε 1s =3.5%, ε 2s =3.1%;
[0169] (3) Physical constraint parameters: constraint coefficient λ=0.05, sliding window size k=10, physical constraint factor Pconstraint is calculated based on the theoretical voltage of pure Nernst equation;
[0170] 2.4, such as Figure 3 As shown, the optimization parameters
[0171] (1) Optimizer parameters: Adam optimizer is used, learning rate = 0.001, number of iterations ≤ 50, error convergence threshold Δε = 1 × 10⁻ 4 ;
[0172] (2) Regularization coefficients for multi-objective joint optimization: λ1=0.01 (weight regularization term), λ2=0.02 (voltage curve smoothing term), λ3=0.03 (physical consistency constraint term).
[0173] 2.5, such as Figure 4 As shown, error correction and lifespan determination parameters
[0174] (1) Error correction parameters: abnormal error elimination threshold = 3σ (σ is the standard deviation of the initial prediction error), operating condition change threshold θ = 8, error adjustment threshold τ = 0.05;
[0175] (2) Failure threshold parameters: The temperature-adaptive failure voltage V0 ranges from 0.55V to 0.65V, and the baseline warning threshold T base =500h, fuel cell design life T total =8000h.
[0176] 3. Experimental Results and Analysis
[0177] 3.1 Evaluation Indicators
[0178] (1) Prediction accuracy indicators: The mean absolute error (MAE) and root mean square error (RMSE) are used, and the calculation formulas are as follows:
[0179] ,
[0180] ,
[0181] (2) Reliability index: Physical constraint compliance rate = (Number of predicted samples that meet the electrochemical theoretical laws / Total number of samples) × 100%;
[0182] (3) Engineering adaptability index: Single sample inference speed (unit: seconds), reflecting the feasibility of real-time deployment of the model.
[0183] 3.2 Comparative Experiment Design
[0184] Three sets of comparative models were set up and parallel validation was performed based on the same dataset:
[0185] (1) Traditional Model 1: Single LSTM data-driven model (no physical constraints);
[0186] (2) Traditional Model 2: Nernst Equation Mechanism Model + Single SVR Fusion Model (Fixed Weights);
[0187] (3) The model of this invention: multi-scale physical constraints plus cross-attention fusion network model (dynamic weights + dual model collaboration).
[0188] 3.3 Results Analysis
[0189] 3.3.1 Comparison of Prediction Accuracy and Reliability
[0190] Table 1 Performance Comparison of Different Models
[0191] Model MAE (V) RMSE (V) Physical constraint compliance rate (%) Single LSTM model 0.045 0.058 72 Mechanistic model + fixed weight SVR 0.031 0.042 85 This invention model 0.013 0.019 99.6
[0192] As shown in Table 1, the MAE of the model of this invention is only 0.013V and the RMSE is 0.019V, which reduces the error by 71.1% compared with the single LSTM model and by 58.1% compared with the fixed weight fusion model. The physical constraint compliance rate reaches 99.6%, which is significantly better than the traditional model and completely solves the core pain point of the traditional model that is "numerically reasonable but violates the electrochemical law".
[0193] 3.3.2 Generalization ability
[0194] Wide operating condition generalization capability: Under extreme operating conditions such as low temperature (-10℃~0℃) and high current density (1.2A / cm²~1.5A / cm²), the MAE fluctuation of the model of this invention is only 0.3%, while the fluctuation of the traditional model reaches 1.8%~2.5%, which makes it more stable to adapt to complex operating scenarios.
[0195] Data missing rate adaptability: When the data missing rate is 30%, the MAE of the model of this invention only rises to 1.7%, while the MAE of traditional models all exceed 5.0%, demonstrating excellent resistance to data missing rate.
[0196] In summary, this invention achieves a comprehensive breakthrough in prediction accuracy, physical reliability, inference efficiency, and generalization ability through the synergistic effects of multi-dimensional data fusion, dynamic collaboration of mechanism and data dual models, multi-scale physical constraint guidance, and precise error correction. It is fully adaptable to the online real-time remaining lifetime prediction needs of scenarios such as automotive proton exchange membrane fuel cells and distributed power generation fuel cells.
[0197] The present invention also provides a fuel cell remaining life prediction device, including a data acquisition module, a data preprocessing module, a dual model construction module, a prediction optimization module, an error correction module, and a life warning module. Each module is connected via a CAN bus. The data acquisition module adopts a multi-channel sensor module (sampling frequency 1Hz). The data preprocessing module and the prediction optimization module are integrated into an ARM Cortex and A76 processor. The memory adopts 8GB DDR4 memory and can be directly deployed in a vehicle fuel cell controller.
[0198] In addition, the present invention provides an electronic device including an ARM Cortex and A76 processor and 8GB DDR4 memory, which stores a fuel cell remaining life prediction program. When running, it executes all the steps of the above method, and the warning information is sent to the vehicle control system via the CAN bus.
[0199] This invention provides a method, apparatus, electronic device, and storage medium for predicting fuel cell lifespan. Many methods and approaches exist for implementing this technical solution; the above description is merely a preferred embodiment. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications should also be considered within the scope of protection of this invention. All components not explicitly stated in this embodiment can be implemented using existing technologies.
Claims
1. A method for predicting the lifespan of a fuel cell, characterized in that, Includes the following steps: Step 1: Deploy multiple measuring points and multivariable sensors in the fuel cell system to collect fuel cell operating data in real time; the fuel cell operating data includes voltage, current, stack temperature, humidity, and hydrogen partial pressure. Step 2: Preprocess and standardize the fuel cell operation data to construct a fuel cell health monitoring dataset, and divide it into training set, validation set and test set; wherein the data preprocessing adopts a combination of Laida criterion and attention-based interpolation algorithm, and the standardization adopts standard score Z-score algorithm; Step 3: Use the improved Nernst equation to construct a mechanism sub-model to extract the theoretical feature matrix, and use the improved Transformer algorithm to construct a data-driven sub-model to extract the actual feature matrix. Then, merge the theoretical feature matrix and the actual feature matrix into a new matrix that is easy to predict according to the weights. Step 4: Input the fused feature matrix into the multi-scale physical constraint and cross-attention fusion prediction model to calculate the predicted voltage, and at the same time use the inverse proportional weight allocation algorithm to optimize the model weight parameters. Step 5: Correct the model's prediction results by interpolating through an attention mechanism and dynamically adjusting the operating condition attenuation coefficient. Step 6: Calculate the remaining lifespan by comparing the preset failure threshold with the predicted voltage, and determine whether to issue an early warning based on the remaining lifespan.
2. The method according to claim 1, characterized in that, In step 3, the step of using the improved Nernst equation to construct a mechanistic sub-model and extract the theoretical feature matrix includes: Introducing the operating condition attenuation coefficient k, a voltage attenuation model is derived based on the improved Nernst equation: , in, This represents the theoretical voltage value of the fuel cell at operating time t. It is a reversible potential. For current density, For ohmic impedance, To activate the overpotential, The gas constant is Absolute temperature For electron transfer number, It is Faraday's constant. For exchange current density, This is concentration overpotential. For limiting current density, For runtime, For activation energy, Let be the universal gas constant, and exp denote the natural exponential function; The operating condition attenuation coefficient k is adjusted according to the coupling of reactor temperature and current density: , in For the pile temperature; Substitute the training set data into the output to calculate the theoretical feature matrix corresponding to the theoretical voltage decay curve. The theoretical feature matrix It is an i-row matrix, where each row represents the theoretical characteristic representation of a variable.
3. The method according to claim 2, characterized in that, In step 3, the step of using the improved Transformer algorithm to construct a data-driven sub-model to extract the actual feature matrix includes: A condition-related attention head is added to the Transformer encoder layer, and a multi-head attention weight optimization formula is used to prioritize the extraction of stack temperature and current-related features: , in, For the improved multi-head attention calculation function, These are the query matrix, key matrix, and value matrix, respectively, with Softmax being the normalization exponential function. The dimension of the key vector. For position encoding, For dimensional indexing, For model dimensions, This is the code for the operating conditions; T represents transpose. The standardized dataset was input into the improved Transformer model, with the encoder layer set to 6 layers, the attention head to 8, and the hidden layer dimension to 512. The data decay pattern is learned using the training set, and hyperparameters are adjusted using the validation set to output the actual feature matrix corresponding to the actual voltage decay curve. The actual feature matrix It is an i-row matrix, where each row represents the actual characteristic representation of a variable.
4. The method according to claim 3, characterized in that, Step 3, which involves merging the theoretical feature matrix and the actual feature matrix according to their weights into a new matrix that is easier to predict, includes: The dynamic weights are calculated based on the dual-model error rate and the operating condition fit, and the fusion formula is as follows: , in, It is the fused feature matrix. , , These are weighting coefficients. , , , The error rate of the mechanism sub-model. To drive the sub-model error rate, For the working condition adaptation coefficient of the mechanism model, For data-driven model operating condition adaptation coefficients; This is a cross-attention fusion term.
5. The method according to claim 4, characterized in that, In step 4, the multi-scale physical constraints and cross-attention fusion prediction model are implemented through the following steps: Step 6.1, Model Architecture Composition: The multi-scale physical constraint and cross-attention fusion prediction model includes a multi-scale feature splitting module, a physical constraint embedding layer, a dynamic cross-attention weight optimization module, and a multi-objective joint optimization module. Each module works together to realize the prediction voltage calculation and weight parameter optimization. Step 6.2: The multi-scale feature segmentation module performs multi-scale feature segmentation and directional fusion; For the fused feature matrix Perform multi-scale splitting and targeted fusion: Will Decomposed into long-cycle theoretical characteristics and short-cycle theoretical characteristics Based on the time-scale characteristics of voltage decay in the Nernst equation; Will Decomposed into long-term actual characteristics and short-cycle actual characteristics ; The formula for targeted fusion is: , in, The weighting formula is: , , , , in These are the weights of the long-period features of the mechanistic sub-model. It is the error rate of long-term prediction by the mechanistic sub-model. It is the error rate of long-term prediction by the data-driven sub-model. It is the operating condition adaptation coefficient of the long-period characteristics of the mechanism sub-model. It is the working condition adaptation coefficient of the long-cycle characteristics of the data-driven sub-model. These are the weights of the short-period features of the mechanistic sub-model. It is the error rate of short-period predictions by the mechanistic sub-model. It is the error rate of short-term prediction by the data-driven sub-model. It is the operating condition adaptation coefficient of the short-period characteristics of the mechanism sub-model. It is the operating condition adaptation coefficient of the short-cycle characteristics of the data-driven sub-model. It is the weight of long-term features in the data-driven sub-model. These are the weights of short-cycle features in the data-driven sub-model; Step 6.3: The physical constraint embedding layer performs physical constraint embedded prediction; The core physical laws of fuel cells are embedded in the prediction process, forcing the output to conform to the electrochemical mechanism, and the predicted voltage at time t is obtained. The formula is: , in, The output voltage of the mechanism sub-model. The output voltage of the data-driven sub-model is... This is a historical voltage smoothing compensation term. To adjust the sliding window size, for The operating condition attenuation coefficient at time t, Physical constraint factor, Calculate the voltage for the pure Nernst equation. These are constraint coefficients; Step 6.4: The dynamic cross-attention weight optimization module executes the dynamic cross-attention weight optimization algorithm; The model weight parameters are optimized using a dynamic cross-attention weight optimization algorithm, and the implementation process is as follows: Define the objective function for the weighted prediction error rate: , in, The weighted prediction error rate, For the number of parameters, For the first Measured values of each parameter For the first The importance weights of each parameter; Calculate dynamic cross-attention score : , in, for No. dimensional features, for No. d is a feature dimension. for The working condition adaptation coefficient corresponding to the dimension; Calculate the average attention score and : , , in, yes The number of feature dimensions, yes The number of feature dimensions; The weight update formula is: , , in, The error rate of the mechanism sub-model. To drive the sub-model error rate, For the operating condition adaptation coefficients of the mechanism sub-model, The operating condition adaptation coefficients for the data-driven sub-model; Set the conditions for stopping optimization; Step 6.5, the multi-objective joint optimization module performs multi-objective joint optimization: adopting a multi-objective joint optimization objective function. The model is trained while simultaneously constraining prediction accuracy, weight rationality, voltage smoothness, and physical consistency. The formula is as follows: , in, For the sample size, This is the measured voltage. For weight regularization terms, This is the voltage curve smoothing term. For physical consistency constraints, is the regularization coefficient.
6. The method according to claim 5, characterized in that, Step 5 includes: First, the error between the initial predicted voltage and the measured voltage of the multi-scale physical constraint and cross-attention fusion prediction model is calculated: , in, It's an error. It is the measured voltage. It is the initial predicted voltage; The 3σ criterion was used to examine outlier error terms, and the mean μ and standard deviation of the voltage parameters were calculated. Remove Abnormal error samples; if the error is caused by missing data, use an attention mechanism for interpolation to complete it: , in, This is the completed data. It's missing data. It is the first One related parameter data, To score attention, For Gaussian kernel function, For kernel width, For missing data timestamps, For associated data timestamps; If the error is caused by changes in operating conditions, the operating condition attenuation coefficient can be dynamically adjusted. Correction: , in, This is the adjusted attenuation coefficient. It is the initial attenuation coefficient. This represents the change in reactor temperature. The change in current density The threshold for changes in operating conditions; The initial predicted voltage is added to the corrected error compensation value to obtain the final predicted voltage: , in, It is the final predicted voltage. This is the corrected error compensation value. For activation function, This is the error adjustment threshold.
7. The method according to claim 6, characterized in that, Step 6 includes: Prediction Matrix This is an n x 1 matrix containing the predicted voltage values at each time point: , in, Representation matrix Each line, The predicted voltage value at time point n; Set failure threshold Proton exchange membrane fuel cells for vehicles Adaptive adjustment based on temperature: , The piecewise interpolation method is used to find the first occurrence of a given element in the prediction matrix. corresponding time : , in, For the first At a certain point in time, For the first Predicted voltage at each time point The sampling interval; Calculate remaining lifetime: , in, For remaining lifespan, This is the current running time. This is a compensation item for historical prediction bias. This represents the number of historical validation samples. Set early warning threshold The remaining lifespan and operating time are dynamically adjusted as a percentage: , in As the baseline warning threshold, For the design life of fuel cells, when The system will issue a warning at that time.
8. A device, characterized in that, Includes memory and processor, wherein: Memory is used to store computer programs that can run on a processor; A processor, configured to, while running the computer program, perform the steps of a fuel cell remaining life prediction method as described in any one of claims 1 to 7.
9. An electronic device, characterized in that, include: At least one processor and at least one memory are provided for storing at least one program, which, when executed by the processor, enables the processor to implement a fuel cell remaining life prediction method as described in any one of claims 1 to 7; the processor is based on ARM Cortex and A76 architecture, the memory is DDR4 memory with a capacity of ≥8GB, and the communication interface supports the CAN bus protocol to adapt to automotive deployment scenarios.
10. A computer-readable storage medium, characterized in that, The storage medium contains a computer program that, when executed by a processor, implements a method for predicting the remaining life of a fuel cell as described in any one of claims 1 to 7, wherein the storage medium includes removable or fixed storage media such as ROM, RAM, USB flash drive, and optical disc.