#### Lithium-ion power battery system cycle life fitting

Using the data obtained from the lithium-ion power battery pack cycle life test, combined with the Matlab genetic algorithm toolbox, the functional relationship between the battery system capacity retention rate η and the number of charge-discharge cycles n was fitted. Referring to the research methods of general engineering problems, combined with the observation of the relationship between the capacity retention rate and the number of cycles in Figure 1, a 3rd degree polynomial can be used to fit the relationship between the two, namely:
η=a0+a1n+a2n²+a3n3——(1)

According to a certain test result, we can know the test data [ηi, ni ] of the capacity retention rate η and the number of charge-discharge cycles n. In order to prevent the magnitude of the undetermined coefficients a0, a1, a2, and a3 from being too small, the number of cycles of charge and discharge is converted to 1000 times as a unit. The data of ηi,ni are shown in Table 1.

1 Steps for fitting based on Matlab genetic algorithm toolbox
The following describes the process of using the Matlab Genetic Algorithm Toolbox to determine the undetermined coefficients a0, a1, a2, a3 in the polynomial (1):

① Determine the fitness function. The fitness function designed in Matlab Genetic Algorithm can only obtain its minimum value. If the maximum value is to be solved, appropriate changes must be made. Let η’²i be the capacity decay rate corresponding to the number of cycles ni calculated by the fitting function formula (3-26), then the sum of squares of the total errors of ηi and η’i is

Generally, it can be considered that the smaller the error squared sum e, the better the fitting effect, even if the values ​​of the undetermined coefficients a0, a1, a2, and a3 with the smallest e are the optimal results.

② Write the m file of the fitness function and save it to the Matlab working path with the function name “bat_cyclelife3”. The function written in this article is as follows:
function y=bat_cyclelife3(a)
C=[103.53035498.45161596.41157494.62567793.27196492.11820590.86393389.384969]; Ne=[0.001, 0.36, 0.72, 1.08, 1.44, 1.80, 2.16, 2.52];
[r, s] = size(c);
y=0
For i=1: s
y=y+(C(i)-(a(1)+a(2)Ne(i)+a(3)(Ne(i)^2)+a(4)*(Ne(i)^ 3)))^2
% Error sum of squared minimization principle
end

③ Open the Matlab Genetic Algorithm Toolbox to make relevant settings, run and obtain the test results. Enter the handle of the fitness function “@bat_cyclelife3” in the Fitness function, enter “4” for the number of variables, check Best fitness and Best individual in the running display (Plots), and set the Selection function in the selection parameter (Selection) to roulette For Roulette, in Stopping Criteria, Generations is set to 100, Fitness limit is set to 0, Stall generations is set to 100, and Stall time limit is set to Inf. The parameters such as crossover and mutation are default values, which are set in the default toolbox. After completing the settings, click the “Start” button, and the genetic algorithm starts to operate.

2 Algorithm calculation process and results
When the maximum number of iterations (Generations) of the stopping condition is set to 100, the display of the best fitness and the current best individual during the calculation process is shown in Figure 2. It can be seen from this that the optimal fitness (that is, the sum of squares of errors) gradually decreases as the number of iterations progresses, and the optimal fitness of each generation is gradually approaching the average fitness, indicating that the algorithm is constantly being optimized. The best fitness after 100 iterations is 21542.86, and the values ​​of a0, a1, a2, and a3 are shown in Table 2.

It can be seen from Figure 2 that the optimal fitness continues to decrease in the process of 100 iterations, indicating that the optimization can be continued by increasing the number of iterations. Set the “Selection” to Stochastic uniform, the Generations in the Stopping Criteria to “Inf”, the Time limit to “Inf”, the Stall Generations to “Inf”, and then click “Start” restarts the operation. Through the display of the best fitness in Plots, we can see the change between the fitness and the best individual. When the desired effect is achieved, click “Stop” in the toolbox to stop the operation, and record the optimization results of the algorithm as shown in Table 2.

After 2191 iterations, the best approximations of the coefficients a0, a1, a2, and a3 are 102.5959, -10.7985, 3.99807, and -0.7087, respectively, which is the difference between the capacity retention rate η of the lithium-ion power battery pack and the number of charge-discharge cycles n. The functional relationship between them is shown in formula (2). The maximum value of the error between the calculated value of the fitting equation (2) and the actual capacity retention rate obtained by the experiment is 0.9, and the sum of squares of the total error is only 1.5282, indicating that the equation (2) has a good degree of fit. Using the Matlab function to program and draw, the data points obtained from the experiment and the curve of the fitting function are shown in Figure 3. According to the capacity retention rate lower than 80% as the end of life, the total cycle life of the lithium-ion power battery pack is calculated to be 3836 times according to formula (2).
η=102.5959-10.7985n+3.99807n²-0.7087n3——(3)