A Particle-Swarm-Optimization-Based Approach for the Characterization of the Battery Pack of an Electric Vehicle When Driven Under Real Conditions

Recent developments in lithium-ion (Li-ion) storage technology have enabled a revolution in the automotive industry. Fully electric vehicles (EVs) operate under the most diverse combination of driving and environmental conditions affecting the autonomy range. In other words, an equal State-ofCharge (SOC) on two same model EV does not mean the same traveling distance since the conditions such as the Stateof-Health (SOH) of the battery, type of driver and even the type of route will influence the EV performance. Typically, SOC estimation algorithms are proposed and validated under controlled laboratory conditions. However, when real conditions are present, it is necessary to incorporate new tools capable of handling the diverse variability present in all the conditions. For instance, the elevation profile of the route influences the current that the battery pack delivers or regenerates, and the performance on the same route can be affected by the SOH. One of the main concerns for EV owners is that once a battery pack is installed, it becomes almost impossible to perform laboratory tests under controlled conditions.This paper proposes a novel Particle-Swarm-Optimization-based (PSO) method to characterize the battery pack of an EV when driven under real traffic conditions. The data was obtained by a real-driving experiment, which consists on driving the EV in a complete discharge cycle on a highway. During this experiment, the initial SOC was 100%, and the EV was Aramis Pérez et al. This is an open-access article distributed under the terms of the Creative Commons Attribution 3.0 United States License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited. driven through a highway where the driving conditions were almost uniform making it possible to characterize the SOC curve. The obtained model is then validated when the EV was driven in different types of routes. The obtained results show that the proposed approach can estimate the SOC satisfactorily. In this regard, this type of real-driving experiment can be performed by any driver, and by combining the particular results with the proposed approach, the users can personalize the SOC estimation model to their vehicles, and even more, create their own knowledge base of their EV performance through time. Therefore, the real-driving experiment can be replicated when needed to update the model parameters, thus allowing a better understanding of the actual SOH of the battery pack. Furthermore, by combining the obtained model with the elevation profile of a given route, the user can assess where to stop in case that a recharge is necessary.


INTRODUCTION
Due to climate change and the urge to reduce carbon emissions Electric Vehicles (EVs) are one of the most popular alternatives to reverse this situation. Literature reports that the global market sales for this type of vehicles has increased from 2.26 million units in 2019 to a total of 3.24 million during 2020 (Irle, 2020). Furthermore, when data from sales from 2010 to 2018 is used to define a logistic growth model, the prognosis results show that by year 2032 all passenger vehicles will represent near 30% of the fleet (Rietmann, Hügler, & Lieven, 2020). ogy have triggered a new revolution in the automotive industry, although electric vehicles (EVs) are affected by the most diverse combination of driving and environmental conditions affecting the autonomy range and the overall performance. Two of the most used indicators when using any type of battery are the State of Charge (SOC), and the State of Health (SOH). The SOC indicates the available energy stored in the battery, and typically is indicated as a percentage from the total energy that can be stored. For instance, a fully charged battery is represented as 100% SOC, and those fully discharged as 0% SOC. When a fully discharged battery is present, it can be stated that it reached its End-of-Discharge (EoD). The SOH is also represented as a percentage from the nominal capacity and the availability that the battery has to store energy. The SOH has a major influence on the range capacity of a vehicle, because a battery can always be charged up to 100% SOC although the autonomy will depend on the SOH. Different conditions of usage such as charging and discharging profiles, temperature, elevation profiles, and ways of driving will influence both the SOC as the SOH (Choi & Lim, 2002) . For example, two vehicles with the same SOC and different SOH will have very different autonomies.
One of the concerns that drivers have before purchasing an EV is the fear of getting stranded before arriving to charging location. This phenomena, called range anxiety, as well as not trusting EV technology have major influences on the rate at which this technology becomes more popular (Tantuau & Gavrilescu, 2019). When reading an EV dashboard it is more common that the driver trust more the remaining driving range than the actual SOC when making decisions on where to charge, although the autonomy is an estimated value dependent on the SOC (Pevec et al., 2019). Different approaches have been proposed to estimate the SOC on Li-ion cells (Xiong, Cao, Yu, He, & Sun, 2017). Typically the proposed methods are based on laboratory tests and controlled conditions during the discharge process. Although some other methods have been proposed for estimating the SOC of EV, they require special considerations that not necessarily can be obtained by a regular driver. This paper proposes a novel method to characterize the battery back of an EV through a Particle-Swarm-Optimization (PSO) scheme and a proposed driving profile. The proposed driving schedule was performed with a Nissan Leaf driven continuously in a major highway, and dealing with real traffic conditions. The obtained results were then validated by comparing the real SOC obtained from the EV computer, with a PF-based SOC estimation framework. This PF-based estimator was initially designed for Li-ion individual cells, and this paper extends this original methodology to an EV battery pack. The article is organized as follows: Section 2 mentions the situation of the electric vehicle market and the importance of battery health monitoring systems. In Section 3, the theo-retical concepts are presented. Section 4 states the characteristics of the case study developed, and Section 5 discusses the results obtained. Finally, Section 6 presents the conclusions of the work.

ELECTRIC VEHICLES BACKGROUND
In recent years the use of EVs has increased significantly due to the effort of various government policies to minimize carbon dioxide emissions. For example one of the actions is the introduction of laws and regulations for the use of EVs by that provide a variety of benefits to the users such as tax discounts, and preferred public parking (Gómez-Gélvez, Mojica, Kaul, & Isla, 2016). As a result, the electric vehicle market has increased the compound annual growth rate by 26.8% between the years 2021 to 2030 (Markets & Markets, 2021). The guidelines established by various countries evidence this situation; such is the case of Chile and Costa Rica, where it is expected that by 2050, all public transportation will be zero emissions (Gómez-Gélvez et al., 2016).
EVs can be classified into three categories depending of the nature of the energy source. The main types are: Battery Electric Vehicles (BEVs), Hybrid Electric Vehicles (HEVs), and Plug-in Hybrid Electric Vehicles (PHEVs) (Gómez-Gélvez et al., 2016).
• BEVs: The motor is powered only from an electric battery. • HEVs: These type of cars have an electric battery and a combustion engine. The battery is charged by the combustion engine and regenerative breaking. • PHEVs: Similar to the HEV, but in this case the battery can be charged when plugged to a charger.
The introduction of electric vehicles has been notorious in the last five years in Latin America. For example, in Costa Rica, the total EV fleet grew almost 100% during 2020 and the first semester of 2021, for an estimated total of 2000 units. Between 2018 and 2019, Chile had a 68% increase in the number of EVs, and currently, there is an approximate fleet of 900 units. Other countries, such as Panama, have had a slower process, but even so, the presence of EVs can be evidenced (ONU Environment Programme, 2019) (Ochoa, 2020).
Regarding public transportation, Chile has the largest fleet outside of China with more than 500 electric buses servicing the country. Panama implemented a plan between 2018 and 2019, obtaining promising results (Gómez-Gélvez et al., 2016). This plan lead to the purchase of 35 units to be incorporated into public transport. On the other hand, Costa Rica initiated in 2021 an experimental phase of EV in public transport.
Although their increasing popularity, the cost of EVs is still a major constraint for most users. A very important percentage of the total cost of the EV is the battery pack, literature defines this value somewhere between 30% to 50% of the total cost of the EV . For this reason, and in order to avoid a premature damage to the battery pack, EVs require a Battery Management System (BMS) and a Thermal Management System (TMS). The BMS is in charge of controlling that way in which energy flows in the battery, either in charging mode as well as in discharge mode. Also it monitors all the other important indicators, such as SOC, SOH, temperature, current, and speed to mention some. Estimating the SOC and SOH has received significant attention since the information they provide on the percentage of available energy and the degradation rate contribute significantly to decision-making in the operation and use of the EVs. Currently diverse are the studies that have been presented to the student the different techniques for the estimation of both indicators considering the evaluation of individual cells or the battery pack (Xiong et al., 2017) (Rahimi-Eichi, Ojha, Baronti, & Chow, 2013. Different techniques can be used in BMS to estimate the SOC. For example, it is possible to classify the techniques into four large groups: Conventional method, Adaptive filter algorithm, Learning algorithm, and Non-linear observer (Hannan, Lipu, Hussain, & Mohamed, 2017). Basically, the selection of the method will depend on its precision and accuracy in the estimation process. Moreover, they also establish the challenges that arise in estimating SOC, including cell unbalancing, model characterization, and the sensitivity of the equipment that performs the measurements of the variables (voltage, current, temperature). In other efforts, the authors estimate the SOC using the Unscented Kalman Filter considering the Autocovariance Least Squares technique (El Din, Hussein, & Abdel-Hafez, 2018). Also in this work, the authors propose using a battery cell model that uses Artificial Neural Network to determine the parameters dynamically. Finally, in (Li, Guo, Qi, Guo, & Li, 2020), the authors compare the SOC estimation using the Adaptive Filter algorithm and a battery model that allows the online selection of parameters. Through these works, it is evidenced that the SOC estimation is a critical parameter in BMS since the accuracy of its measurements affects decision-making in EVs.

Particle Swarm Optimization
Particle Swarm Optimization (PSO) is an optimization method inspired by collective behaviors observed in nature, such as bird flocking or fish schooling searching for food (Sun & Liu, 2013). Proposed initially by , PSO is a stochastic population-based algorithm used for solving nonlinear-nonconvex optimization problems (Bansal, 2019).
The PSO algorithm uses a set of individuals, called particles, to explore the space of an objective function aiming to find the optimal solution, called global best (gbest). At each iteration step, the PSO algorithm "moves" the particle swarm through the search space by adjusting each particle's position and velocity, thus allowing the particles to be attracted to the position of the gbest.
The typical PSO algorithm is initialized with a set of random candidate solutions (the particles), where a position and a velocity vector characterizes each particle. Then, at each iteration step the particles move through the search space of dimension d to find the global minimum solution adapting their positions and velocities. The best solution of each particle (pbest i ) and the current global best solution of all particles (gbest) are also stored at each iteration. Two stopping criteria are used to stop the search process: i) when the iteration steps reach a maximum value and ii) when the global best solution reaches a predefined tolerance. Finally, the result of the optimization problem corresponds to the gbest value computed by the PSO algorithm (Martínez-Ledesma & Jaramillo Montoya, 2020).
As previously stated, each particle is characterized by a position and a velocity vector, updated at each iteration step.
Considering v id (t) the velocity and x id (t) the position of the particle i in the d−dimension search space at the iteration step t, the equations that update these two vectors are defined in Eq.
(2), respectively (Shi & Eberhart, 1998): where ω is the so-called inertia weight, which allows balancing the exploration and exploitation of the search space, c 1 and c 2 are the so-called cognitive and social components, respectively. These two coefficients control the degree of influence that gbest and pbest should have on the velocity and position of the particles. Moreover, φ 1 and φ 2 are two random vectors sampled from a d−dimensional uniform distribution on the [0, 1] interval, which contribute to keeping the diversity in the particle swarm at adequate levels (Freitas, Lopes, & Morgado-Dias, 2020; Martínez-Ledesma & Jaramillo Montoya, 2020).
The main steps of the PSO algorithm are arranged in the pseudo-code illustrated in Algorithm 1 (Sun & Liu, 2013;Yang, 2021).

Bayesian filtering and Particle filters
Bayesian filtering (BF) is a probabilistic method to recursively estimate the posterior probability density function (PDF) of the state vector x k at each time step k given a set of measurements z 1:k (Särkkä, 2013). Specifically, the BF prob-Algorithm 1 Particle swarm optimization 1: Definition of the objective function f (x) 2: Parameters initialization (swarm size n, ω, c 1 , y c 2 ) 3: Random initialization of the position (x id ) and the velocities (v id ) of the particle swarm 4: Find gbest from min{f (x 1d ), ..., f (x nd )} 5: while (stopping criteria are not met) do 6: for (all n particles) do 7: Update the velocity vector (v id (t + 1)) 8: Compute new position vector (x id (t + 1)) 9: Find the current pbest 10: end for 11: Find the current gbest 12: 13: end while lem aims to compute the posterior PDF p(x k |z 1:k ) in real time. In realistic scenarios, the dynamics of the state vector x k are usually non-linear, time-variant and disturbed by non-Gaussian uncertainties, which entails that there is no optimal closed-form solution for the BF problem (Ristic, Arulampalam, & Gordon, 2003).
For these scenarios, Particle Filters (PFs) are a type of algorithms used to compute a sub-optimal solution for the BF problem. PF algorithms are based on Monte Carlo simulation, and seek to represent the posterior PDF p(x k |z 1:k ), at each time step k, by a set of N p random samples with associated weights. These samples are called particles and are represented by Eq. (3): To compute the optimal solution, PF sequentially acquires the set of particles from an alternative q(·) distribution, called importance PDF. Therefore, the posterior PDF p(x k |z 1:k ) is represented by (Arulampalam, Maskell, Gordon, & Clapp, 2002): where the weights w (i) k are updated according to: The selection of the q(·) PDF is directly related to the PF performance, thus it should be considered in the filter design and implementation (Orchard & Vachtsevanos, 2009). For exam-ple, the basic PF implementation, the Sequential Importance Sampling (Arulampalam et al., 2002), selects the q(·) PDF equal to the prior state PDF, such that: Thereby, the weights w (i) k are computed using the likelihood of the new measurements.

State-of-Charge model
Previous works (Espinoza, Pérez, Orchard, Navarrete, & Pola, 2017;Pola et al., 2015) have proposed an empirical state-space model for the SOC characterization of Li-ion batteries in discrete time. The process model allows assuming the battery pack operation by an equivalent circuit made up of only two states: x 1 represents the internal battery impedance |Z int | [Ω], whereas x 2 corresponds to the SOC. Equations (7) and (8) detail the state-space process model: Regarding the state-space measurement model (i.e., the system output), this is related to the voltage signal v(k) [V ], detailed in Eq. (9): where i(k) (discharge current in Amperes [A]) and ∆t (the sample time in seconds [s]) are the input variables. V 0 , V L , α, β, γ, and ζ are the parameters that capture the non-linear behavior of the voltage signal in open-circuit conditions. These parameters are estimated offline. E crit represents the total energy that the battery pack can deliver, and ω 1 and ω 2 are the process noises, while ν represents the measurement noise.

PSO-based parameter estimation
The offline estimation of the measurement model parameters defined previously considers a slightly modified version of the model detailed in Eq. (9). This modified version is shown in Eq. (10): where the SOC and the current I are data vectors. The parameters vector θ corresponds to the parameters set to be estimated. It is worth noting that the SOC data vector can be computed based on the voltage (V ) and the current (I) data vectors acquired from a real-driving test experiment.
Considering then the data vectors V , I, and SOC of length M obtained from a real-driving test experiment, the parameter estimation is formulated as the optimization problem defined by Eq. (11), solved through the PSO algorithm.

PROPOSED METHODOLOGY
The procedure presented in this article can be divided into three different steps. The first step consisted in performing a driving test with practically no stops in a major highway in order to capture the discharge dynamics of the EV battery pack. Since most methods proposed in the existing literature are oriented to laboratory tests that characterize the discharge process of regular Li-ion cells, characterizing an EV battery pack without the assistance of laboratory equipment becomes a challenging process since it becomes almost impossible to replicate these types of tests. For this reason, in this article it is proposed an extensive drive oriented to capture most of the discharge dynamics of an EV battery pack in a continuous manner. The second step consisted in applying an evolutionary algorithm, PSO specifically, to estimate the SOC model parameters as described in Section 3.4. Finally, the third step is oriented to the validation of the obtained model. For this, two different routes with distinct driving conditions are selected. The first route consists on driving the EV through one of the country's most challenging uphill mountain roads, whilst the other is a prolonged descent from one of the country's highest mountain peaks and driving back to the city, specifically to the University Campus. It is important to understand that this extensive drive test is proposed as an alternative in which a particular user can characterize any EV battery pack. With the collected information in these two routes, the SOC is estimated with the PF-based scheme, as explained in Section 3.2 and then compared to the ground truth given by the EV computer. The Mean Absolute Error (MAE) and the Mean Squared Error (MSE) were used as metrics to evaluate the performance of the proposed algorithm.

CASE STUDY
For this case study a 2018 Nissan Leaf was considered. The battery capacity has a nominal value of 30 kWh, the obtained SOH retrieved from the cars computer is approximately 80% and the odometer displays 6500 km of use.
The discharge dynamics of the battery are obtained using a proposed extensive drive test. This test consists on driving the Nissan Leaf starting at 100% SOC and driving it in highway conditions (to avoid any additional power consumption that are present when driving in city conditions), until the battery is almost completely discharged (any value below 10% SOC). This driving test was done on a regular business day to capture all the possible existing traffic conditions. Furthermore, while performing this drive test, the driver tried to keep the speed as constant as possible so the required current from the battery is as uniforms as possible. In other words, since laboratory discharge conditions for a Li-ion cell require a constant discharge current, this extensive drive test tries to emulate a similar discharge process. During the test, the ambient temperature at the departure site was nearly 20 • C at 8:00 a.m, and at the arriving location approximately 35 • C at noon. Also, the retrieved battery pack temperature information had similar values during the test, and it followed a linear trend, starting at 22 • C and finishing at 34 • C.
The performed driving test started at the Faculty of Engineering of the University of Costa Rica in San Jose, and the destination at the beginning was not certain since is was dependent on the available range. Although, it was known that the discharge location was going to be along one major highway due to the availability of charging stations. At the beginning of the test the dashboard indicated an autonomy of 170 km and it was completely charged. Due to the geographic conditions of the country and the location of the starting point (the city has an elevation of 1222 meters above sea level), the first part of the test consisted of a descent until reaching practically the sea level (near the Pacific coast), and once this point was reached the rest of the test was performed in a practically plain highway. For practical reasons even though the route has small slopes it is virtual impossible to find a complete plain highway unless the car is driven in a race track, or along a specifically designed road, or even just if the discharge is performed hovering on a chassis dynamometer with no slopes programmed. In this case, the stored energy was enough to arrive to the city of Liberia in the Northern Pacific of the country. At this point, the SOC was nearly 5%, and the total traveling distance was approximately 220 kilometers, more than the initial autonomy displayed in the dashboard at the beginning of the test. This difference is a consequence of a combination of the kinetic energy recovery system and efficient driving. The main characteristics of the route followed in the proposed extensive drive test are shown in Table 1. Figure 1 illustrates the elevation profile of San Pedro-Liberia route.   Figure 2 illustrates the obtained discharge curve. Although it is not the typical discharge curve obtained under controlled conditions, the obtained data is enough for characterizing the dynamics of the battery. Remember that this paper used two different routes to validate the proposed model.
The first route, has a length of approximately 30 kilometers, see Table 2. As mentioned before, this route in the way it is driven is one of the most challengers due to the steep slopes present. For many years this was one of the most used routes when returning from the Pacific Coast to the Central Valley. Due to the mountain conditions on this road, it is not possible to reach highway speeds but the demanded current when ascending limits the regenerative capacity of the vehicle making it one of the most energy expensive portions of the country s road network, see Figure 3.
The next route used for validation is a prolonged descent. The initial point was the main entrance of the Irazú Volcano National Park and the final destination was the University of Costa Rica main campus. In this case the route has a length of approximately 45 km, and the the altitude at the staring point is nearly 3255 meters above sea level. Table 3 shows the main characteristics of this route. As shown in Figure 4 the condition of this road is that it can be characterized as a   very long descent with practically a constant slope along the route. This particular condition makes it interesting to assess the capability of the model to capture the dynamics of the discharge curve when there is a notable regenerative effect.

RESULTS
The first step to validate our case study was to implement the methodology for parameter tuning using PSO. First, the route San Pedro-Liberia was used to obtain the resulting parameters shown in Table 4. Subsequently, the discharge voltage and the voltage vs SOC fitting curve were obtained with the parameters found, see Figure 5. The parameter |Z p | is used only as an initial condition for the estimation of the state x 1 . For this data set, the MAE was 0.901, and the MSE was 1.318.
The second step was to obtain the voltage, internal impedance, and SOC estimate considering the discharge current for the two routes proposed in the case study. In both cases, the SOC estimation follows the same trend in the long term as the ground truth. Furthermore, both the estimated SOC and the SOC given by the EV on-board computer are bounded within the confidence intervals. Figure 6 illustrates the current consumption, voltage, internal impedance and SOC corresponding to the El Roble-San Mateo route (Figure 3). The current consumption graphic shows that the difference in altitude in the route implies a higher current consumption, and the steepest portions of the route might induce to large errors in the SOC estimation. In general, the SOC estimation has a good performance when compared to the SOC computed by the on-board computer.
The results for the Irazú-San Pedro route are shown in Figure   7. The current consumption for this route varies among different negative values for most of the trip. This situation is explained by the elevation profile of the route (Figure 4), mainly in downhill. Also, this causes the estimation of the SOC to be overestimated due to the energy recovered through the regenerative breaking. On the other hand, in the uphill parts of the route where the current profile is positive, the estimation of the SOC is inaccurate. This situation can be attributed to the discrepancies over the computed SOC by the on-board computer. Nevertheless, the SOC estimation follows the same trend as the information given by the EV.   As mentioned before, the MAE and MSE are the selected metrics to evaluate the performance of the algorithms. The results obtained for both routes are shown in Table 5. The metrics reflect that the algorithms have a better performance for the El Roble-San Mateo route since the Irazú-San Pedro route has a steep downhill slope, which shows the regenerative braking effect. However, the model presented in this work does not incorporate this variant, which opens the door to carry out studies on how to incorporate these characteristics into existing models.
In the results found, it can be observed that the proposed algorithms are capable of adjusting to the characteristics presented by the different routes. This situation is still evident in the Irazú-San Pedro route. Thus, despite overestimating the SOC, the algorithm can follow the trajectory according to the ground truth. The results also highlight that for other profiles with a high discharge component such as the El Roble-San Mateo route, the model has excellent precision and confidence. The main reason for this is that existing models have adequately characterized the battery discharge processes, thus allowing an adequate estimation of the SOC.
However, it is necessary to explore alternatives that will enable the regenerative effect to be included to guarantee the proper SOC estimation regardless of the route trip.

CONCLUSIONS
This paper proposed calculating the parameters of a previously reported SOC model through a PSO framework for online SOC estimation in EVs based on particle filters, with the particularity that a real driving test was designed for this purpose. The test consisted in completely discharging a Nissan Leaf battery pack while driving non-stop between two cities on a mostly plain highway to maintain a constant speed during most part of the trip.
Afterwards, two routes with different elevation profiles were used to validate the behavior of the SOC estimation using the tuned model. The results showed high accuracy in the SOC estimation when the route did not present regenerative breaking effects due to brakes. Nevertheless, in the route where the regenerative effect was considerable, the SOC estimation was not as accurate, which marks the way for future works that propose an improved SOC model capable of including the regenerative breaking effects.
In the light of the results, the proposed approach can be applied any time when a real-driving experiment can be performed. Therefore, the model parameters can be updated when needed by the users to obtain a tuned SOC model, according to the current SOH of the battery pack. . He has authored and co-authored more than 100 papers on diverse topics, including the design and implementation of failure prognostic algorithms, statistical process monitoring and system identification. His research work at the Georgia Institute of Technology was the foundation of novel real-time failure prognosis approaches based on particle filtering algorithms. His current research interests include the study of theoretical aspects related to the implementation of real-time failure prognosis algorithms, with applications to battery management systems, electromobility, mining industry, and finance. Dr. Orchard is a Fellow of the Prognostic and Health Management Society.