A Multicore Implementation Method for Nonlinear MPC Controller of a Fuel Cell Hydrogen System
By combining the computing characteristics of CPU and NPU in the fuel cell hydrogen system, scalar and matrix calculations in MPC optimization problems and optimize data transmission, the problem of low control efficiency of multi-core processors is solved, and higher system performance and stability are achieved.
Patent Information
- Application Number
- CN202510360458.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-03-26
AI Technical Summary
The existing fuel cell hydrogen systems have low control efficiency on multi-core processors, resulting in excessive processing load and limited overall system performance improvement.
By combining the computing characteristics of CPU and NPU, scalar calculations and large-scale parallel matrix calculations in MPC optimization problems are handled separately, data transmission is optimized, and the overall coordination and stability of the system are improved.
It significantly shortens the total computing time, improves the utilization efficiency of multi-core resources, improves the overall coordination efficiency and stability of the system, and is suitable for dynamically changing computing requirements and complex logic tasks.
Smart Images

Figure CN119882573B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of fuel cell hydrogen systems, and specifically to a method for multi-core implementation of a non-linear MPC controller for a fuel cell hydrogen system. Background Art
[0002] Although certain resource optimization and task parallelism have been achieved in the application of multi-core processors in the prior art, there are still significant deficiencies in technical implementation. For example, for most existing method computing platforms, they are mostly multi-core homogeneous, and multiple CPUs are similar in internal structure. Therefore, the algorithm is restricted by the multi-core homogeneous structure during the controller deployment process. Moreover, for the traffic scheduling method of multi-core processors, it mainly focuses on the static segmentation of flow information and task distribution, but the task allocation and data interaction efficiency between the control plane and the data plane are not high. The task allocation mainly focuses on the main core, which may lead to an excessive processing load on the control plane, thus restricting the further improvement of the overall system performance. In addition, the optimization processing of multi-dimensional data characteristics is not deep enough, which is likely to cause scheduling bottlenecks and data conflict problems. Although the multi-core clock control method improves the resource utilization efficiency by dynamically adjusting the clock frequency, it overly relies on the independent module configuration of a single core, increasing the hardware overhead and system complexity. At the same time, the cooperation between multi-cores and task communication are not fully optimized, resulting in limited improvement in overall performance. These drawbacks are particularly obvious when facing high-complexity calculations and dynamic task requirements. Summary of the Invention
[0003] The present invention aims to provide a method for multi-core implementation of a non-linear MPC controller for a fuel cell hydrogen system, and proposes a solution with higher flexibility and resource utilization efficiency. By combining the computing characteristics of the CPU and NPU cores, scalar calculations and large-scale parallel matrix calculations in the MPC optimization problem are processed respectively, significantly shortening the total calculation time and optimizing the occupancy of multi-core resources. In addition, the present invention optimizes the data transmission during the calculation process by core, minimizing the data interaction load between the CPU and NPU, and improving the overall coordination and stability of the system. This method not only adapts to dynamically changing computing requirements, but also shows higher performance and flexibility when dealing with complex logic tasks, breaking through the limitations of the prior art.
[0004] To achieve the above object, the present invention provides the following technical solutions:
[0005] Term Explanation: MPC: Model Predictive Control (MPC) is an optimization control method based on a mathematical model, which uses predicting future system states and solving optimization problems to generate optimal control inputs, and is widely used in fields such as chemical engineering, energy, and autonomous driving, and is suitable for dealing with multi-variable coupling and constraint problems.
[0006] Vector calculation core: A hardware unit specifically designed for parallel processing of vector data, capable of performing single-instruction multiple-data-stream (SIMD) operations, which can significantly improve the computational efficiency of tasks such as matrix operations, graphics rendering, and neural network inference, and is an important part of high-performance computing.
[0007] IPC synchronous communication: A technology for sharing data or coordinating work between processes, including methods such as shared memory, message queues, semaphores, and pipes, which can be used to improve the concurrency of the system and is widely applied in distributed systems and multi-threaded programming.
[0008] Crossbar bus: A high-performance interconnection architecture that enables parallel communication between multiple input and output devices through a matrix cross-connection, providing high bandwidth, low latency, and dynamic path allocation capabilities. It is widely used in multi-processor systems and internal chip interconnections and is suitable for scenarios with high performance requirements.
[0009] A multi-core implementation method for a non-linear MPC controller of a fuel cell hydrogen system, the method comprising:
[0010] S1: Perform Taylor expansion on the fuel cell hydrogen system and linearize each system state equation at the set equilibrium point.
[0011] S2: After linearization, combine all state equations into a continuous-time state space equation, and then perform discretization through the forward Euler method;
[0012] S3: After obtaining the discrete state equation, define the prediction step and the control step , default both to be p and equal, and perform model recursion according to the length of the step;
[0013] S4: Through the definition of the system state and control sequence, integrate the recursion of the discrete state equation into matrix form;
[0014] S5: Determine the reference sequence to achieve system tracking;
[0015] S6: Transform the defined objective function into a quadratic objective function;
[0016] S7: Since the quadratic objective function contains two unknowns and is relatively complex to solve, replace the recursive discrete state equation:
[0017] S8: After transforming the objective function into the standard form of quadratic programming, use the gradient descent method to solve it. After obtaining the optimal control sequence through the gradient descent method, apply the first control quantity in the control sequence to the system to obtain the system state at the next moment , and then through continuous rolling optimization until the system realizes the tracking of the reference value, achieving the purpose of effectively controlling the hydrogen system.
[0018] As a further technical solution of the present invention, the method further includes: The control principle of model predictive control is to utilize the state and constraint conditions of the system at the current moment to predict the state and input variables within a certain period of time in the future, solve for the optimal control sequence, and finally select the first control quantity in the control sequence and apply it to the system;
[0019] Denote the predicted system state within the next p control periods at time k as:
[0020] ;
[0021] In addition, when predicting the future state of the dynamic system, the control quantities within the prediction time domain also need to be known :
[0022] .
[0023] As a further technical solution of the present invention, in S8, according to the solution process of the gradient descent method, the operations of each solution step are respectively assigned to the NPU and the CPU for processing, and the content includes:
[0024] Step 1: Calculation of the Hessian matrix: The Hessian matrix is obtained by taking the second derivative of the objective function;
[0025] ;
[0026] Among them, the Q matrix is the state weight matrix, defined according to the objective function, and is used to measure the influence of the deviation between the system state and the reference value on the optimization objective; the W matrix is the control weight matrix, defined according to the objective function, and is used to constrain and optimize the magnitude of the control input to prevent problems such as instability or excessive power consumption caused by too large a control input;
[0027] The solution of the Hessian matrix mainly involves matrix multiplication operations. Assign to the NPU for processing, and the calculation result of the NPU is integrated with 2W by the CPU through IPC high-speed communication to obtain the H matrix;
[0028] Step 2: Gradient calculation: Obtained by taking the first derivative of the objective function:
[0029] ;
[0030] Among them, , , , , and The matrix is the coefficient matrix obtained by discretizing the state equation through the forward Euler method;
[0031] The calculation of the gradient of the objective function mainly involves matrix multiplication operations, including the f matrix and The above calculations are mainly implemented by the NPU and, after the solution is completed, are sent to the CPU through the IPC high-speed communication method for and The addition integration calculation is finally performed to obtain the gradient of the objective function;
[0032] Step 3: Solve the linear equation to control the change amount : Perform a Taylor expansion of the objective function near the current control sequence :
[0033] ;
[0034] Step 4: Convergence judgment: After obtaining the descent direction , define an appropriate step size to ensure that the objective function monotonically decreases in the direction of the optimal value. The iterative update formula is:
[0035] ;
[0036] Step 5: State prediction: After passing the convergence judgment, update the state variables and the state equation:
[0037] ;
[0038] ;
[0039] where and The matrix is the coefficient matrix obtained by discretizing the state equation through the forward Euler method; , ;
[0040] Step 5.1: For the update of the state variables and the state equation, the NPU is responsible for matrix-vector multiplication and, after the calculation, sends the result to the CPU through the IPC high-speed communication method for addition integration calculation. In addition, the system state also needs to send the reference sequence and the f matrix Update is performed. After all the solution processes and state equations are updated, the solution calculation for the next moment is entered, and continuous rolling optimization is carried out until the output of the system tracks the reference quantity and ends.
[0041] As a further technical solution of the present invention, both the NPU and the CPU use shared memory for data storage. For task interaction, the calculation data of the two cores will be transmitted through a high-bandwidth and low-latency Crossbar bus. The communication mechanism of the IPC adopts a synchronous mode to ensure the real-time performance between data transmission and calculation tasks, and avoid problems such as data inconsistency or calculation delay during the transmission process.
[0042] As a further technical solution of the present invention, step 3 includes:
[0043] Step 3.1: To minimize the objective function, we hope that the first-order term (gradient term) of the Taylor expansion is zero and the second-order term (curvature term) is negative, so as to find a suitable descent direction. To obtain this direction, calculate the first derivative of the objective function with respect to and set it to zero, that is:
[0044] ;
[0045] Furthermore, the optimal descent direction is obtained as:
[0046] ;
[0047] Step 3.2: When solving the equation, considering that the order of the H matrix is relatively large and the calculation complexity is high, it is therefore chosen to change the solution of the ordinary linear equation to the solution of two simple triangular matrix equations through Cholesky decomposition, so as to reduce the calculation complexity. Specifically:
[0048] Step 3.2.1: Perform Cholesky decomposition on the H matrix: , and the original equation is simplified to:
[0049] ;
[0050] Step 3.2.2: Parameter substitution for solution: Let , and solve ;
[0051] Step 3.2.3: Direction solution: After obtaining y, calculate , and finally obtain ;
[0052] For the allocation of the solution task, since the calculation of Cholesky decomposition requires ensuring that the matrix is a positive definite matrix, the CPU is first tasked with checking whether the H matrix satisfies positive definiteness. If it does, the CPU communicates with the NPU via IPC high-speed communication to perform Cholesky decomposition and matrix inversion on the H matrix and matrix multiplication and other operations.
[0053] As a further technical solution of the present invention, step 4 includes:
[0054] Step 4.1: Define the judgment basis value for convergence , and after each iterative update, is substituted into the gradient of the objective function and the two-norm is calculated. If is satisfied, it is considered that the optimal control sequence is obtained at the current moment; otherwise, continuous iterative updates are performed until the condition is met;
[0055] Step 4.2: For the task allocation of convergence judgment, the NPU is mainly responsible for the update of the control sequence and the calculation of the two-norm . After the calculation, the calculation result of the two-norm is sent to the CPU via IPC high-speed communication for condition judgment whether it is less than . If not, the NPU is communicated to continue iterative calculation.
[0056] Compared with the prior art, the beneficial effects of the present invention are:
[0057] The present invention combines the respective calculation advantages of the CPU and the NPU, allocates the scalar calculation tasks in the MPC optimization problem to the CPU for processing, while the large-scale parallel vector and matrix calculations are responsible for the NPU, thus significantly shortening the total calculation time and improving the utilization efficiency of multi-core resources. At the same time, by optimizing the data transmission between the NPU and the CPU, the data interaction load between the two cores is effectively reduced, further improving the overall coordination efficiency and stability of the system, and is an effective method applicable to solving the MPC solution that requires more time and resource occupancy. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 is the main flowchart for solving using model predictive control (MPC) in the embodiments of the present invention.
[0059] Figure 2 is the processing diagram of the operations involved in the MPC solving process by the gradient descent method in the embodiments of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0060] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0061] The background of the present invention is to address the existing problems in the fuel cell hydrogen system and propose to use model predictive control (MPC) to solve them. The main goal is to accurately track the ideal inlet hydrogen mass flow rate and internal pressure of the fuel cell stack to avoid power degradation caused by purging and the risk of proton exchange membrane rupture due to excessive pressure difference. Aiming at the complexity in the MPC solution process and the deficiencies of existing methods, the present invention proposes a multi-core implementation method for a non-linear MPC controller of a fuel cell hydrogen system. The main idea is as follows: According to the objective function, during the process of solving the optimal control variables, the scalar operations and matrix operations involved in the gradient descent method are respectively assigned to the CPU and NPU for processing. The main calculation processes include: the calculation of the Hessian matrix (H matrix), the calculation of the gradient of the objective function ( ), the solution of the linear equation (the change in the control sequence ), the judgment of convergence, and the update of the system state. In the above calculations, the CPU is mainly involved in operations such as integrating the output results and conditional judgment, while the NPU mainly processes large-scale matrix operations and decomposition tasks. When the calculation tasks of the two cores are completed, the calculation results are transmitted through the high-speed inter-core communication bus (hereinafter referred to as the Crossbar bus), and IPC synchronous communication is used to ensure the real-time nature of data transmission and avoid delays, ultimately achieving the goal of minimizing the total calculation time and resource occupancy.
[0062] The specific steps for determining the system state, control variables, and output variables of the fuel cell hydrogen system are as follows:
[0063] Since the proportional valve and the circulation pump have a greater impact on the mass flow rate and internal pressure at the inlet of the fuel cell stack, the opening degree of the proportional valve ( ), and the control voltage of the circulation pump ( ) are selected as the control variables;
[0064] The state variables of the system are selected as the hydrogen supply manifold pressure ( ), the return manifold pressure ( ), and the angular velocity of the circulation pump ( );
[0065] Since the main focus is on the hydrogen mass flow rate and the fuel cell stack pressure at the inlet, the output variables are set as and .
[0066] Generally speaking, the control model of the system is:
[0067]
[0068] wherein: x in it is the state variable of the system; u is the control variable of the system; the state variable x mainly includes: (the pressure of the hydrogen supply manifold), (the pressure of the return manifold) and (the angular velocity of the circulation pump); the control variable u mainly includes: (the opening of the proportional valve) and (the control voltage of the circulation pump); the output y of the system mainly includes: (the hydrogen mass flow rate at the anode inlet) and (the anode pressure).
[0069] Step 2: The objective function mainly considers tracking the ideal value and minimizing the control variation to ensure the stability of the system. Therefore, the formula of the objective function is:
[0070] ;
[0071] wherein: p is the length of the prediction horizon; m is the length of the control horizon; is the weight coefficient of the output error, used to adjust the contribution of the output error in the objective function; is the predicted future steps of the system output at time k; is the reference trajectory, that is, the target value that the system expects to reach; is the weight coefficient of the control increment, used to adjust the contribution of the control input change in the objective function; is the control increment, representing the change amount of the control input.
[0072] Step 3: The constraints of the system mainly consider the constraints on the opening of the proportional valve, the control voltage and angular velocity of the circulation pump, as well as the pressure constraints of the manifolds and the pressure difference between the anode and cathode:
[0073]
[0074] wherein: is the maximum value of the opening of the proportional valve; is the maximum value of the control voltage of the circulation pump; is the maximum value of the angular velocity of the circulation pump; respectively represent the minimum and maximum values of the pressure; represents the pressure difference between the anode and cathode.
[0075] The above are the control model, objective function and constraint conditions of the fuel cell hydrogen system. The main process of solving using model predictive control (MPC) is asFigure 1 As shown in:
[0076] An embodiment of the present invention provides a multi-core implementation method for a non-linear MPC controller of a fuel cell hydrogen system. The method includes:
[0077] S1: Since the fuel cell hydrogen system is a non-linear system, compared with a linear system, the computational complexity of its solution is higher and it takes longer. To save computing time and resources and reduce computational complexity, the fuel cell hydrogen system is usually subjected to Taylor expansion. The specific operation is to linearize each system state equation at the set equilibrium point. The following is the calculation formula for Taylor expansion:
[0078]
[0079] S2: After linearization, all state equations are combined into a continuous-time state space equation, and then discretized by the forward Euler method. The discrete state equation is:
[0080]
[0081] Where: The matrix is the coefficient matrix obtained by discretizing the state equation by the forward Euler method;
[0082] S3: After obtaining the discrete state equation, define the prediction step and the control step , and by default, both are equal to p, and model recursion is performed according to the length of the step:
[0083]
[0084] S4: The control principle of model predictive control (MPC) is to use the state and constraints of the system at the current moment to predict the state and input variables in the future for a period of time, and solve the optimal control sequence. Finally, the first control quantity in the control sequence is selected and applied to the system; Therefore, compared with other control methods such as PID, etc., the unique feature of MPC is that it needs to predict the future system state;
[0085] S4.1: Denote at time k, the predicted system state within the next p control cycles as:
[0086]
[0087] S4.2: In addition, when predicting the future state of the dynamic system, the control quantity within the prediction time domain is also required:
[0088]
[0089] S5: Through the definition of the system state and control sequence, the recurrence of the discrete state equation is integrated into matrix form:
[0090]
[0091] Where: ;
[0092] S6: Determine the reference sequence , to achieve system tracking;
[0093]
[0094] The determination of the reference sequence needs to be determined according to the system conditions and will not be introduced in detail here;
[0095] S7: Transform the defined objective function into its quadratic form objective function as:
[0096]
[0097] Where the Q matrix is the state weight matrix, defined according to the objective function, and is used to measure the impact of the deviation between the system state and the reference value on the optimization objective; the W matrix is the control weight matrix, defined according to the objective function, and is used to constrain and optimize the magnitude of the control input to prevent problems such as instability or excessive power consumption caused by too large a control input;
[0098] S8: Since the quadratic form objective function contains two unknowns and is relatively complex to solve, the recursive discrete state equation is replaced and transformed into:
[0099]
[0100] Where: ;
[0101] S8.1: Simplify the above objective function to:
[0102] ;
[0103] Where: .
[0104] S9: After transforming the objective function into the standard form of quadratic programming, the gradient descent method is used for solution. The kernel operations involved in the solution process will be described in detail below. After obtaining the optimal control sequence through the gradient descent method, the first control quantity in the control sequence is applied to the system to obtain the system state at the next moment , and then through continuous rolling optimization until the system achieves tracking of the reference value, achieving the purpose of effectively controlling the hydrogen system.
[0105] The operations involved in the solution process of MPC by the gradient descent method are processed by dividing the cores, and the detailed process is as Figure 2 shown:
[0106] According to the solution process of the gradient descent method, the content of distributing the operations of each solution step to the NPU and CPU for processing includes:
[0107] Step 1: Calculation of the Hessian matrix: The Hessian matrix is obtained by taking the second derivative of the objective function;
[0108]
[0109] Among them, the Q matrix is the state weight matrix, which is defined according to the objective function and is used to measure the impact of the deviation between the system state and the reference value on the optimization objective; the W matrix is the control weight matrix, which is defined according to the objective function and is used to constrain and optimize the magnitude of the control input to prevent problems such as instability or excessive power consumption caused by too large a control input;
[0110] The solution of the Hessian matrix mainly involves matrix multiplication operations. The is assigned to the NPU for processing, and the calculation result of the NPU is integrated with 2W by the CPU through the IPC high-speed communication method to obtain the H matrix;
[0111] Step 2: Gradient calculation: Obtained by taking the first derivative of the objective function:
[0112]
[0113] Among them, , , , , and The matrix is the coefficient matrix obtained by discretizing the state equation through the forward Euler method;
[0114] The calculation of the gradient of the objective function mainly involves matrix multiplication operations, including the calculation of the f matrix ( ) and the calculation of . The above calculations are mainly implemented by the NPU and, after the solution is completed, are handed over to the CPU through the IPC high-speed communication method for and addition integration calculation to finally obtain the gradient of the objective function;
[0115] Step 3: Solve the linear equation to control the change amount : For the objective function Perform a Taylor expansion near the current control sequence as follows:
[0116]
[0117] Step 3.1: To minimize the objective function, we hope that the first-order term (gradient term) of the Taylor expansion is zero and the second-order term (curvature term) is negative, so as to find a suitable descent direction. To obtain this direction, calculate the first derivative of the objective function with respect to and set it to zero, i.e.:
[0118]
[0119] Thus, the optimal descent direction is obtained as:
[0120]
[0121] Step 3.2: When solving this equation, considering that the order of the H matrix is relatively large and the computational complexity is high, we choose to convert the solution of the ordinary linear equation into the solution of two simple triangular matrix equations through Cholesky decomposition, so as to reduce the computational complexity. Specifically:
[0122] Step 3.2.1: Perform Cholesky decomposition on the H matrix: , and the original equation is simplified to:
[0123]
[0124] Step 3.2.2: Parameter substitution for solution: Let , and solve ;
[0125] Step 3.2.3: Direction solution: After obtaining y, calculate , and finally obtain ;
[0126] For the distribution of the solution task, since the calculation of Cholesky decomposition requires ensuring that the matrix is a positive definite matrix, the CPU is first used to check whether the H matrix satisfies positive definiteness. If it is satisfied, the CPU communicates with the NPU through the IPC high-speed communication method to perform Cholesky decomposition and matrix inversion ( ), matrix multiplication and other operations.
[0127] Step 4: Convergence judgment: After obtaining the descent direction , define a suitable descent step size to ensure that the objective function can monotonically decrease in the direction of the optimal value. The iterative update formula is:
[0128]
[0129] Step 4.1: Define the judgment basis value for convergence , and after each iterative update, is brought into the gradient of the objective function , and the two-norm is calculated. If is satisfied, it is considered that the optimal control sequence is obtained at the current moment; otherwise, is continuously iteratively updated until the condition is satisfied;
[0130] Step 4.2: For the task assignment of convergence judgment, the NPU is mainly responsible for the update of the control sequence and the calculation of the two-norm . After the calculation, the calculation result of the two-norm is sent to the CPU through the IPC high-speed communication method for condition judgment whether it is less than . If it does not meet the condition, the NPU is communicated to continue the iterative calculation.
[0131] Step 5: State prediction: After the convergence judgment is passed, the state quantity and the state equation are updated:
[0132]
[0133] Among them, and matrices are the coefficient matrices obtained by discretizing the state equation through the forward Euler method; , ;
[0134] Step 5.1: For the update of the state quantity and the state equation, the NPU is responsible for the matrix-vector multiplication operation ( ) and sends the result to the CPU through the IPC high-speed communication method for addition integration calculation after the calculation. In addition, the system state also needs to update the reference sequence and the f matrix ( ) after the update is completed. When all the solution processes and the state equation updates are completed, the solution calculation at the next moment is entered, and continuous rolling optimization is performed until the output of the system tracks the reference quantity and ends.
[0135] Both the NPU and the CPU use shared memory for data storage. For task interaction, the calculation data of the two cores will be transmitted through the high-bandwidth and low-latency Crossbar bus. The IPC communication mechanism uses a synchronous mode to ensure the real-time performance between data transmission and calculation tasks, and avoid problems such as data inconsistency or calculation delay during the transmission process.
[0136] It should be noted that, in this text, the term "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements but also other elements not expressly listed, or elements that are inherent to such process, method, article, or device. Without further limitation, an element defined by the phrase "including an..." does not exclude the presence of additional identical elements in the process, method, article, or device that includes such element.
[0137] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be similarly included in the patent protection scope of the present invention.
Claims
1. A multi-core implementation method of a nonlinear MPC controller for a fuel cell hydrogen system, characterized in that: The method comprises: S1: Perform Taylor expansion on the fuel cell hydrogen system to linearize the state equations of each system at the set equilibrium point; S2: After linearization, the state equations are combined into continuous time-state space equations and discretized using the forward Euler method; S3: Define the prediction step size and control step length , by default, both are equal to p, and the model is recursively deduced according to the length of the step; S4: The recursion of the discrete state equations is integrated into a matrix form by defining the state and control sequence of the system; S5: Determine the reference sequence to achieve systematic tracking; S6: transform the defined objective function into a quadratic objective function; S7: Since the quadratic objective function contains two unknowns, the solution is relatively complicated, so the recursive discrete state equation is replaced; S8: After converting the objective function into the standard form of quadratic programming, the gradient descent method is used to solve it. After the optimal control sequence is obtained by the gradient descent method, the first control variable in the control sequence is applied to the system to obtain the system state at the next moment. , and then through continuous rolling optimization, until the system achieves tracking of the reference value, the purpose of effectively controlling the hydrogen system is achieved.
2. The multi-core implementation method of a nonlinear MPC controller for a fuel cell hydrogen system according to claim 1, characterized in that: The method also includes: the control principle of the model predictive control is to use the state and constraints of the system at the current moment to predict the state and input variables in the future period, and solve the optimal control sequence, and finally select the first control quantity in the control sequence to apply to the system; Note that at time k, the system state predicted within the next p control cycles is for: ; In addition, when predicting the future state of a dynamic system, it is also necessary to know the control quantity within the prediction time domain. : 。 3. The multi-core implementation method of a nonlinear MPC controller for a fuel cell hydrogen system according to claim 1, characterized in that: In S8, according to the solution process of the gradient descent method, the operations of each solution step are respectively assigned to the NPU and the CPU for processing, including: Step 1: Calculation of the Hessian matrix: The Hessian matrix is obtained by taking the second derivative of the objective function; ; Among them, the Q matrix is the state weight matrix, which is defined according to the objective function and is used to measure the impact of the deviation between the system state and the reference value on the optimization target; the W matrix is the control weight matrix, which is defined according to the objective function and is used to constrain and optimize the size of the control input to prevent instability or excessive power consumption caused by excessive control input; Solving the Hessian matrix mainly involves matrix multiplication. Assign it to the NPU for processing and send the calculation results of the NPU to the Through IPC high-speed communication, the CPU and 2W perform addition integration to obtain the H matrix; Step 2: Gradient calculation: By taking the first-order derivative of the objective function, we get: ; in, , , , , and The matrix is the coefficient matrix obtained by discretizing the state equation by the forward Euler method; The calculation of the objective function gradient mainly involves matrix multiplication, including the f matrix and The calculation is realized by NPU, and after the solution is completed, it is handed over to CPU through IPC high-speed communication. and The addition and integration calculation finally obtains the gradient of the objective function; Step 3: Solve the linear equation to control the change :For the objective function In the current control sequence Taylor expansion nearby: ; Step 4: Convergence judgment: Find the descending direction Then, define the appropriate descending step size , ensuring that the objective function decreases monotonically towards the optimal value, the iterative update formula is: ; Step 5: State prediction: After the convergence is judged, the state quantity and state equation are updated: ; ; in, and The matrix is the coefficient matrix obtained by discretizing the state equation by the forward Euler method; , ; Step 5.1: For the update of state quantity and state equation, NPU is responsible for matrix-vector multiplication and sends the result to CPU for addition and integration calculation through IPC high-speed communication. After the update is completed, the reference sequence And the f matrix is updated. When all the solution processes and state equation updates are completed, the solution calculation at the next moment is entered, and the rolling optimization is continuously carried out until the output of the system tracks the reference value.
4. The multi-core implementation method of a nonlinear MPC controller for a fuel cell hydrogen system according to claim 3, characterized in that: Both NPU and CPU use shared memory to store data. For task interaction, the computing data of the two cores are transmitted through the high-bandwidth, low-latency Crossbar bus, while the IPC communication mechanism uses a synchronous mode.
5. The multi-core implementation method of a nonlinear MPC controller for a fuel cell hydrogen system according to claim 3, characterized in that: Step 3 includes: Step 3.1: Calculate the objective function with respect to The first-order derivative of and set it to zero, that is: ; Then the optimal descent direction is obtained: ; Step 3.2: When solving the equation, considering that the order of the H matrix is relatively large and the computational complexity is high, we choose to use Cholesky decomposition to change the solution of the ordinary linear equation to two simple triangular matrix equations to reduce the computational complexity: Step 3.2.1: Perform Cholesky decomposition on the H matrix: , the original equation is simplified to: ; Step 3.2.2: Parameter substitution solution: Let , solve ; Step 3.2.3: Direction solution: After solving for y, calculate , and finally get ; Regarding the allocation of solution tasks, since the calculation of Cholesky decomposition requires that the matrix is a positive definite matrix, the CPU is first asked to check whether the H matrix satisfies the positive definiteness. If so, the CPU communicates with the NPU through IPC high-speed communication to perform Cholesky decomposition, matrix inversion, and matrix multiplication on the H matrix.
6. The multi-core implementation method of a nonlinear MPC controller for a fuel cell hydrogen system according to claim 3, characterized in that: Step 4 includes: Step 4.1: Define the convergence criteria , after each iteration update Substitute the gradient of the objective function into And calculate the two norms, if it satisfies It is considered that the optimal control sequence is obtained at the current moment, otherwise it is continuously updated , until the conditions are met; Step 4.2: For the task allocation of convergence judgment, NPU is mainly responsible for controlling the sequence Update of the two-norm After the calculation, the result of the two-norm calculation is sent to the CPU through the IPC high-speed communication method to determine whether it is less than If it does not meet the requirements, the communication NPU continues to perform iterative calculations.
Citation Information
Patent Citations
Cement decomposing furnace control method and system based on combined model predicting control technology
CN104765350A
Method for real time optimization and parallel computing of model prediction control based on computing chart
US20220327388A1