## 3 Mathematical Modeling Formulation  
### Modeling of Battery Swapping Station  
As previously noted, battery swapping stations function as convenient hubs for integrating electric vehicles into the distribution network, serving as both energy recipients from and contributors to the grid. Hence, the charging status of these vehicles significantly influences the metrics and parameters of the distribution network. This section introduces a robust model tailored for planning and siting analyses aimed at determining the charging status of these vehicles. In this proposed approach, each electric vehicle, whether charging or discharging, is depicted as a voltage source converter (VSC) in accordance with Figures 2 and 3. Consequently, the power received by an electric vehicle from the grid during charging is derived from Equation (1) [24]. This model not only aids in understanding the energy flow dynamics but also facilitates efficient resource allocation and infrastructure planning within the distribution network. \[P_{EV}^{ch/dis}(t)=P_{EV_{max}}(1-e^{-at/t_{max}})+P_{EV0} \tag{1}\]  
Figure 3: Equivalent representation of an electric vehicle’s circuitry when connected to the power grid (**a**) general configuration, (**b**) electrical equivalent circuit. Figure 2: Diagram illustrating the connection between a grid and an electric vehicle charging station. where in Equation (1) the following are used:  
\(P_{EV0}\) represents the initial charging power of the electric vehicle. \(\alpha\) denotes the charging battery time constant of the electric vehicle. \(t_{max}\) signifies the total time needed to charge the electric vehicle's battery from zero charge to maximum charge. \(P_{EV_{max}}\) stands for the maximum charging power of the electric vehicle. As illustrated in Figure 4, electric vehicles, whether charging or discharging at charging stations, are electrically interconnected to the grid in both series and parallel configurations. Consequently, the aggregate power consumption or generation by electric vehicle charging stations can be determined utilizing Equation (2) [24]. \[P_{EV}^{total}=\sum_{i=1}^{n}\sum_{j=1}^{m}P_{EV,ij} \tag{2}\]  
Given that the presence or absence of electric vehicles at charging stations hinges on the probabilistic tendencies of electric vehicle owners and the duration required for discharging or charging, the active power received from the grid by BSS is inherently subject to random and probabilistic behavior. This aspect necessitates careful consideration in the modeling of Equation (2). To address this, BSSs are classified into three categories based on charging speed: slow-charging, medium-charging (battery-switching), and fast-charging stations. In this study, the fast-charging method is employed to model the behavior of fast-charging stations using a probabilistic Markov model. The schematic of the probabilistic Markov model for a fast-charging electric vehicle station is depicted in Figure 5 [25]. Figure 4: Integration of electric vehicles with a charging station network. Figure 5: Markov probabilistic model representation for a fast-charging electric vehicle station. In the provided figure, \(\lambda\) denotes the success rate of a vehicle in accessing the charging converter, \(\mu\) represents the success rate of a vehicle in completing its battery charging, and \(\gamma\) signifies the rate at which a battery charging for an electric vehicle is completed and transitions to the ready-to-charge state.