#### Abstract

Photovoltaic- (PV-) based battery swapping stations (BSSs) utilize a typical integration of consumable renewable resources to supply power for electric vehicles (EVs). The charging strategy of PV-based BSSs directly influences the availability, cost, and carbon emissions of the swapping service. This paper proposes an optimal charging strategy to improve the self-consumption of PV-generated power and service availability while considering forecast errors. First, we introduce the typical structure and operation model of PV-based BSSs. Second, three indexes are presented to evaluate operational performance. Then, a particle swarm optimization (PSO) algorithm is developed to calculate the optimal charging power and to minimize the charging cost for each time slot. The proposed charging strategy helps decrease the impact of forecast uncertainties on the availability of the battery swapping service. Finally, a day-ahead operation schedule, a real-time decision-making strategy, and the proposed PSO charging strategy for PV-based BSSs are simulated in a case study. The simulation results show that the proposed strategy can effectively improve the self-consumption of PV-generated power and reduce charging cost.

#### 1. Introduction

Renewable energy and electric vehicles (EVs) have emerged as methods for ensuring energy security and for reducing emissions in many countries. However, for photovoltaics (PV) and other intermittent renewable energy sources with output volatility, large-scale renewable energy connected to the power grid still has many barriers to overcome. Moreover, it is difficult to maintain stable operation of the power grid and optimize scheduling for large populations of EVs with uncertain charging characteristics [1–3]. In addition, if the charging power is generated by coal-fired power plants, the emission advantage for EV is not obvious [4, 5]. The direct integration of PV with EV charging devices is an effective way to reduce EV emissions and the impact of EV charging on the power grid [6, 7].

There are three types of EV charging modes: conventional charging, fast charging, and battery swapping [8, 9]. The battery swapping mode replaces depleted batteries with fully charged batteries and charges the depleted batteries on a charging platform. The battery swapping mode is mainly applied in public transport, such as electric buses and electric taxis. As an important charging mode, the State Grid Corporation of China has invested in and constructed dozens of battery swapping stations (BSSs) in large cities in China [10, 11]. The centralized charging strategy in BSSs is constructive for the integration of renewable energy generation.

Most of the scholarships on EV charging and renewable energy generation have focused on design, operation, and optimal charging strategies [12–16]. A conceptual architecture and an assessment framework were proposed to explore integration scenarios of EVs and renewable energy generation in distribution networks [17]. The combination of PV energy and EVs in uncontrolled charging and smart charging strategies has been studied [18], as was a two-stage framework for the economic operation of an EV parking deck with renewable energy generation [19]. Heuristic optimization algorithms, such as particle swarm optimization (PSO) and genetic algorithm (GA), have been used to solve the multiobjective and nonlinear optimization problems associated with the management of EV charging involved in renewable energy generation. A PSO algorithm was utilized to allocate charging stations of plug-in electric vehicles [20] and to provide a coordinated charging/discharging scheme to increase revenues and incentives [21]. An optimization algorithm was developed based on the well-established PSO and interior point method for the optimal dispatch of EVs and wind power [22]. Two approaches based on the fuzzy genetic algorithm and fuzzy discrete PSO were proposed to minimize energy cost and grid losses by coordinating EV charging [23]. A PSO algorithm can randomly search to achieve satisfactory solutions by using a population of particles and is a practical algorithm for solving EV charging optimization problems involved in renewable energy generation.

The aforementioned charging strategies proposed for integrating PV and a charging station are not suitable for battery charging in a BSS. The charging strategy of a BSS is different from the general EV charging mode. In a BSS, a depleted EV battery system is replaced with a fully charged battery system in several minutes, and the depleted batteries are stored on a centralized charging platform. Recently, several studies have investigated charging strategies for BSSs without renewable energy generation. A novel centralized charging strategy for BSSs considered optimal charging priority and charging location [24]. A direct projection method was developed to compute an optimal charging schedule of the BSS efficiently [25]. However, these charging strategies have not properly considered the uncertain features of PV generation and battery swapping requirements.

A charging strategy for operating a PV-based BSS should take into account battery swapping demand, fluctuation of PV generation, charging cost, and forecast errors. The primary mission of a BSS is to ensure service availability for battery swapping. Battery charging of the BSS must be scheduled so that every EV that arrives will be provided with fully charged batteries. However, the battery charging schedule is compromised with forecasting errors for PV generation and battery swapping demand. In this paper, we propose a PSO charging algorithm to decrease the impact of forecast uncertainties on the availability of battery swapping services and to minimize the charging power cost.

The major contributions of this paper are as follows: (1)A battery swapping service model and a battery charging model are introduced to improve the service availability of BSSs.(2)A PSO-based charging strategy is proposed to optimize the charging operation and to achieve self-consumption of PV energy for PV-based BSSs.(3)The effectiveness of the proposed PSO-based charging strategy is evaluated in a real-time swapping operation while minimizing the total charging cost.(4)The simulation results indicate that the proposed PSO-based charging strategy can achieve satisfactory effects under different battery demand forecast errors.

The content of this paper is organized as follows: Section 2 describes the system structure and operation model. Section 3 proposes three indexes used to evaluate the operation performance. Section 4 introduces the PSO-based charging strategy, including the basic PSO algorithm and its implementation in the battery charging operation. A case study and analysis are presented in Section 5, and conclusions are drawn in Section 6.

#### 2. System Structure and Operation Model

##### 2.1. System Structure and Components

A typical PV-based BSS structure is shown in Figure 1; the structure is mainly composed of a PV system, a battery charging system, a grid-connected system, and an energy management system.

The PV system consists of PV modules and DC/DC converters. The PV modules directly convert solar energy into electric energy and deliver power to the DC bus through the DC/DC converter. The actual output power of the PV system is mainly affected by solar irradiation and environmental temperature [26].

The battery charging system is comprised of DC chargers and batteries. An is driven by a battery system consisting of a fixed set of battery packs that is charged by a DC charger. In general, the battery is initially charged with a constant current until the state of charge (SOC) reaches a certain value, after which it is charged with a constant voltage. Recently, batteries have also been charged with a constant power [6].

The grid-connected system consists of a bidirectional AC/DC inverter and a distribution transformer. The grid-connected system balances power between the distribution grid and the DC bus and maintains a stable voltage in the DC bus.

The energy management system monitors and controls the operation of each component in the PV-based BSS. The optimal charging strategy will run on the energy management system to achieve the operational objectives of the BSS.

##### 2.2. Battery Swapping Service Model

The battery swapping service model is shown in Figure 2. The most important objective of the BSS is to maintain the availability of the battery swapping service. In the initial development period of the BSS, the quantity of batteries reserved in the BSS is limited to a relatively small swapping demand and the high cost of purchasing batteries. Therefore, studying the battery swapping service model is necessary to improve service availability and reduce charging cost.

To analyse the battery swapping service model, we divide one day into *I* periods, and each period has a length of *Δt*. The total number of power battery systems and chargers in the BSS is defined as *N*_{B} and *N*_{CH}, respectively. The number of EVs that the BSS can serve is defined as *N*_{S}.

For any time slot , the batteries in the BSS can be divided into the following states: (1) available status, in which the battery is fully charged and ready for the swapping service, defined as ; (2) charging status, in which the battery is in a charging status, defined as , and the battery will complete charging in time slot , defined as ; and (3) waiting for charging status, in which the battery is replaced in time slot , defined as .

The total number of EVs waiting to swap a battery in time slot is defined as . The number of EVs coming to the BSS to swap a battery in time slot is defined as . The number of EVs waiting to swap a battery that has not yet completed battery swapping in time slot due to limited battery swapping equipment or a lack of fully charged batteries is defined as . The number of EVs that have completed battery swapping in time slot is defined as . can be calculated as follows:

The number of batteries in different states varies dynamically with time. The number of fully charged available battery systems in time slot can be calculated as follows:

After the battery is fully charged, it should rest for a period of time to reach a steady state before discharge. Thus, the battery becomes available in the time slot after it has completed charging. Similarly, the replaced battery reaches the charging state in the following time slot.

The number of charging state battery systems in time slot can be calculated as follows:

Since the BSS configures a charger for every replaced battery system on the charging platform, the replaced battery systems can be charged in the next time slot.

##### 2.3. Battery Charging Model

The replaced batteries begin charging in the following time slot. The replaced batteries are charged in a constant power charging mode. In this mode, the charging time for a replaced battery is related to the initial SOC and the final SOC of the charging battery. where represents the battery charging time; and represent the initial SOC and finished SOC of a charging battery, respectively; represents the rated capacity of a battery; and represents the constant charging power.

To maintain the availability of the battery swapping service, there should be enough fully charged batteries to meet the EV swapping demand in each time slot.

In the next time slot , the new fully charged batteries transition to an available state, and new EVs come to the battery swapping service:

Based on (3) and (7), the following equation can be derived: where represents the number of battery systems that are fully charged in the time slot and and are the numbers of EVs coming to the BSS for battery swapping in the time slots and , respectively, which are the forecasted values. The other parameters in (8) are known in time slot , so can be determined.

However, the batteries may not be fully charged, as it may take several time slots to complete battery charging. The charging time for a battery can be calculated using (5). Thus, (8) needs to be applied to time slot .

The lower limit of the charging quantity of battery systems in time slot is decided by . Thus, the minimum charging power can be calculated as follows:

In the actual battery swapping service, the number of EVs coming to the BSS is a typical stochastic value. As a result, the forecast value always includes uncertainty errors. Having more fully charged batteries available in reserve should be considered to respond to forecast errors; however, keeping many fully charged batteries in reserve is not an economical solution. Therefore, an optimal charging strategy is needed to account for both forecast errors and charging economy.

#### 3. Evaluation Indexes for Operation Performance

Considering the purpose and characteristics of the battery swapping service, the evaluation indexes for the operation performance are given based on three points [27, 28]: (1) self-consumption of PV energy, (2) availability of the battery swapping service, and (3) economic cost of charging.

##### 3.1. The Self-Consumed PV in Total EV Charging Energy

There are two power sources for EV charging, namely, PV energy and distribution grid energy. This index evaluates the PV self-consumption rate in total EV charging energy, which is represented as the percentage of self-consumed PV energy in total EV charging energy (): where represents the charging energy of the battery charging platform in time slot and represents the energy supplied by the distribution grid in time slot .

##### 3.2. Waiting Time for Battery Swapping Service

EVs have to wait for battery swapping primarily due to a lack of fully charged batteries or limited swapping equipment. The battery swapping time for one EV is approximately 6–8 minutes and is not included in the waiting time. This index evaluates the availability of the battery swapping service, which is represented as the waiting time of the battery swapping service (): where represents the time that EVs spend waiting for battery swapping.

##### 3.3. The Price of Charging Energy

The charging energy price differs based on the energy sources. The energy from the distribution grid is more expensive than the energy from PV generation. The charging energy price is calculated as follows: where represents the average electricity price of the charging energy, represents the charging energy value from the distribution grid in time slot , represents the electricity price from PV energy, and represents the electricity price from the distribution grid.

#### 4. Charging Strategy

##### 4.1. PSO

The optimal charging strategy for PV-based BSSs is a stochastic program, as traditional linear optimization methods cannot handle the random calculations. The probabilistic transition rules used in a PSO make it an appropriate solution for the stochastic problem of the battery charging and swapping operations. A PSO simulates the group behaviours of flocking birds to find a particular optimal objective.

Initially, the PSO algorithm chooses candidate positions randomly within the search space. It then searches for the best positions by updating the generations. During each iteration of the algorithm, the objective function evaluates the fitness of each candidate position. The best fitness and positions are updated by comparing the newly evaluated fitness against the previous best fitness. Finally, the PSO algorithm maintains the best fitness and positions achieved among all particles in the swarm. The velocity and position of each particle are updated as follows [29]:
where represents the iteration number; is the inertia weight; and are the learning factors; and are two random numbers in the range [0, 1]; and , and are the *d*-dimensional vectors of velocity, position, best position, and global best position for the *i*th particle at the *k*th iteration, respectively.

##### 4.2. PSO-Based Strategy

Forecast data are provided in time slots, which includes PV generation and EV battery swapping demands. Then, the BSS operation plans are created for each time slot based on the battery swapping service model and the battery charging model. The BSS operation plans should guarantee the availability of battery swapping and maintain a low charging cost for each time slot.

However, the forecast values of PV generation and battery swapping demands always include uncertainty errors, and operational plans cannot be updated according to the real-time data, leading to suboptimal solutions. The PSO algorithm can search for the best charging solutions with the data from the previous time slot. A group of positions and velocities is randomly selected from the feasible solution space to initiate the PSO. The charging cost is the objective function with constraints on the charging power. Then, the positions and velocities are updated to search for the best solutions by evaluating the fitness. The best solutions of the PSO are used as the BSS operation plans for the next time slot. There are *I* time slots in one day, and the PSO algorithm is run to optimize the operation plans. The flowchart for the proposed PSO-based charging strategy is shown in Figure 3.

The charging cost is evaluated based on the electricity price of the charging energy, considering that the electricity quantities vary in the solutions. The charging power constraints are the minimum and maximum charging power. The minimum charging power is calculated using (10). The maximum charging power is decided by the quantity of chargers in the constant power charging mode.

The number of batteries being charged is the decision variable for the optimization. The PSO stops when it reaches the number of iterations that ensures convergence to the global best position.

#### 5. Case Study

##### 5.1. Simulation Environment

A simulation was conducted based on the PV-based BSS located in Nanjing, China; the configuration parameters are shown in Table 1. The BSS in the case study provides a battery swapping service for twenty EV buses running along three bus lines. The capacity of the battery system is 160 kWh, with five big battery packs and four small battery packs for each EV bus. The charging mode is constant power charging at a rate of 1/3 C.

According to the actual operation of the BSS, the working time of the battery swapping service runs from 6:00 to 23:00. A robot automatically swaps the batteries, and the battery swapping time of one EV bus is set to 7 minutes. The battery swapping times and the SOC of the replaced battery are acquired from the BSS operation database. The parameters of the PSO in the simulation are set as follows: the number of particles *N* is 20, the learning factors and are both 2, the inertia weight *w* is 0.8, and the iteration number *k* is 50.

In the simulation, the duration of a single time slot is set to 30 minutes, and there are 34 time slots for the battery swapping service in one day. The simulation analyses and compares a day-ahead operation schedule [30, 31], a real-time decision-making (RTDM) strategy [28], and the PSO charging strategy in a typical day.

##### 5.2. Simulation Results and Analysis

The day-ahead operation schedule provides the BSS operators with a set of plans for the entire day’s operations according to the forecast data. Uncertain forecast errors may affect the availability of battery swapping service and the cost of charging. The RTDM strategy updates the forecast parameters in real time as more operational data become available and repeatedly adjusts the schedule to reduce the impact of forecast errors. We compare the BSS using the day-ahead operation schedule and the PSO charging strategy and analyse the evaluation indexes of these three strategies under different forecast errors.

The same PV production and battery swapping demand data are used to simulate the real-time operations of the BSS. We perform these two approaches to battery charging for 34 time slots in one day. The forecast and actual PV production are shown in Figure 4, and the forecast and actual values of the battery swapping demand are shown in Figure 5. The simulation results show the BSS operation under two charging approaches, as depicted in Figures 6–8.

Figure 6 shows the number of batteries charged by the day-ahead operation schedule and the PSO charging strategy. The day-ahead operation schedule charges batteries 158 times in total, and the PSO strategy charges 156 times. During the real-time operation, the PSO charging strategy takes advantage of PV production to charge more batteries, while the operation schedule uses less PV energy due to the battery demand forecast errors. Figures 7 and 8 show the numbers of EVs swapping batteries and the number of EVs waiting for battery swapping using these two approaches in all 34 time slots. In the schedule operation, eight EVs must wait for battery swapping mainly due to the battery demand forecast errors.

The power distribution results from the two charging approaches can be obtained from the simulation, as shown in Figure 9. Both charging approaches achieve a good PV power consumption performance; only a little of the PV energy is supplied to the grid at noon. Charging the batteries in the BSS mitigates the fluctuation of PV generation, and the charging load of the BSS on the distribution grid decreases. In addition, the PSO strategy performs better than the schedule operation in terms of the self-consumption of PV energy, particularly at noon.

To analyse the performance of the proposed charging strategy in real-time operations, the evaluation results of the indexes proposed in Section 3 are listed in Table 2. The results show that the performances of all the charging strategies are influenced by the battery demand forecast errors.

The evaluation index is influenced by both the PV production and battery demand forecast errors. When PV output power is greater than the battery charging demand, PV self-consumption is related to the charging strategy. The charging strategies of the day-ahead operation schedule and RTDM track PV generation power, and the charging strategy of PSO is to minimize the charging cost. The global search ability of PSO enables the charging strategy to perform a little better than the other two strategies in the boundary between PV production and battery charging demand under the influence of forecast errors, as shown in Figure 9. The results of the evaluation index show that all the strategies achieve a good performance on the self-consumption of PV energy. The of the PSO strategy is greater than that of the other strategies by 3-4 points on average. The battery demand forecast errors have little impact on PV energy self-consumption.

For charging decisions that are made based on battery swapping demand, the availability of the swapping service is seriously influenced by battery demand forecast errors, as indicated on the evaluation index . The of the schedule strategy increases from 1.3 min to 3.8 min, with battery demand forecast errors growing from 10% to 40%. The increased forecast errors have relatively less impact on the other charging strategies. The RTDM and PSO strategies update the operation data in real time and adjust charging plans to reduce the impact of the accumulated forecast errors. The PSO strategy achieves satisfactory results under 30% forecast errors. When the forecast errors increase to 40%, the of the PSO strategy reaches 1.2 min, which is not as good as the RTDM strategy. However, the forecast errors cannot be eliminated. The availability of the battery swapping service can be improved by reserving more fully charged batteries, though this strategy increases charging cost, and purchasing batteries is expensive.

The charging cost evaluation index is related to the charging energy source. The electricity price of PV generation is lower than that of the distribution grid. As forecast errors increase, PV self-consumption reduces, and the charging cost increases. is negatively correlated with PV self-consumption. The PSO strategy achieves higher PV self-consumption than the other two charging strategies, so is lower in the same forecast errors. The of the PSO strategy is lower than that of the other two strategies in all cases. Even when forecast errors expand to 40%, still reaches $0.0799/kWh.

The results clearly show that the evaluation indexes of the proposed PSO charging strategy are better than those of the day-ahead operation schedule and RTDM strategy. The proposed strategy is sufficiently sophisticated to handle the forecast errors during real-time operations. The proposed PSO charging strategy can provide a charging reference to optimize the manual operation in the BSS at present, and it may be applied in automatic charging operation in the future.

#### 6. Conclusions

This paper proposes an optimal charging strategy that considers the impact of forecast errors to improve service availability and reduces the operating cost of PV-based BSSs. A battery swapping service model is used to describe the regular battery swapping operation of a BSS, and a battery charging model is developed to determine the charging time and quantity. Then, a PSO-based strategy is proposed to optimize the charging time and the charging number of batteries based on PV production and battery demand forecast errors. The simulation results show that the PSO charging strategy can effectively improve the self-consumption of PV energy and the availability of the swapping service. In addition, the charging cost of the PSO strategy is lower than that of the day-ahead operation schedule and the RTDM strategy. The PSO charging strategy updates the charging plans in each time slot according to the actual data to avoid the influence of cumulative errors. Therefore, the proposed PSO charging strategy can perform well for the real-time operation of PV-based BSSs.

It is difficult to improve the service availability and PV self-consumption of PV-based BSSs without increasing the charging cost. A common practice to improve service availability is to reserve more fully charged batteries, but this increases the charging cost. Deploying energy storage systems with battery second use may be a good solution to the problem. The authors will continue the optimal charging strategy of PV-based BSS considering battery second use in the future work.

#### Nomenclature

c_{1}, c_{2}: | Learning factors |

E_{EV}(i): | Charging energy of the BSS in time slot i |

E_{grid}(i): | Charging energy supplied by the distribution grid in time slot i |

I: | Total number of time slots in a day |

k: | Iteration number |

N_{B}: | Number of battery systems in the BSS |

N_{CH}: | Number of chargers in the BSS |

N_{S}: | Number of EVs that the BSS serves |

N_{A}(i): | Number of battery systems available for swapping in time slot i |

N_{C}(i): | Number of battery systems charging in time slot i |

N_{NA}(i): | Number of battery systems that complete charging in time slot i |

N_{WB}(i): | Number of battery systems waiting for charging status in time slot i |

N_{EV}(i): | Number of EVs waiting to swap a battery in time slot i |

N_{NEV}(i): | Number of EVs that arrive to swap a battery in time slot i |

N_{SEV}(i): | Number of EVs that complete battery swapping in time slot i |

N_{WEV}(i): | Number of EVs that have not yet completed battery swapping in time slot i |

: | d-dimensional vectors of best position |

: | d-dimensional vectors of global best position |

P_{Cha}: | Constant charging power of a battery system |

P_{Cha_min}(i): | Minimum charging power of the BSS in time slot i |

PR_{EV}: | Average electricity price of the charging energy |

PR_{grid}: | Electricity price of the distribution grid |

PR_{PV}: | Electricity price of PV energy |

r_{1}, r_{2}: | Random numbers in the range [0, 1] |

SOC_{init}: | Initial SOC of a battery system when charging begins |

SOC_{end}: | Final SOC of a battery system when charging ends |

Δt: | Length of every time slot |

T_{B_Cha}: | Charging time of a battery system when charging ends |

: | d-dimensional vectors of velocity |

w: | Inertia weight |

W_{B}: | Rated capacity of a battery system |

WT(i, j): | The time that EVs wait for battery swapping |

: | d-dimensional vectors of position. |

#### Conflicts of Interest

The authors declare no conflicts of interest.

#### Acknowledgments

This work was supported by the Fundamental Research Funds for the Central Universities of China (Grant no. 2242016K41064).