In the context of achieving carbon neutrality, the integration of electric vehicles with renewable energy systems at an urban scale presents both opportunities and challenges. The spatial heterogeneity of EV charging demand, driven by diverse user behaviors and land-use patterns, necessitates a coordinated planning approach that can effectively match supply and demand while minimizing costs. This work proposes a novel method that combines community detection with a hierarchical optimization framework to co-plan EV charging infrastructure, wind power, photovoltaic generation, and energy storage system capacities across a city.
The proposed methodology follows a three-stage pipeline: user behavior modeling and spatial clustering, community detection based on charging load similarity, and community-differentiated capacity optimization for the energy storage system and renewable sources. First, we construct a Markov chain model for each EV user by encoding charging events with spatial displacement. Using relative entropy rate, we measure the dissimilarity between user behaviors and extract seven representative user classes via variational Bayesian Gaussian mixture clustering. This dimensionality reduction enables us to link user structure to land-use types through a multi-output nonlinear support vector machine, which predicts the distribution of EV user classes in every 5 km × 5 km grid cell of the city. Charging demand at each grid is then synthesized by simulating individual user charging sequences and aggregating them.
The second stage addresses the spatial heterogeneity of demand. We construct a graph where nodes are grid cells and edge weights are Pearson correlation coefficients between their normalized charging load curves. Applying the Louvain community detection algorithm, which maximizes modularity through iterative node relocation and aggregation, we partition the city into 16 communities. This division significantly improves the self-consumption ratio and self-sufficiency ratio of each community when matched with renewable generation, as shown in the following table comparing community-level and grid-level metrics.
| Metric | Before community detection (grid average) | After community detection (community average) | Improvement |
|---|---|---|---|
| PV Self-consumption ratio | 33% | 44.5% | +34.9% |
| PV Self-sufficiency ratio | 27% | 36% | +33.3% |
| Wind Self-consumption ratio | 42% | 51.5% | +22.6% |
| Wind Self-sufficiency ratio | 58% | 64.7% | +11.5% |
The third stage formulates a capacity planning model for each community. To manage the computational burden of large-scale EVs, we develop an aggregated EV model that replaces thousands of individual charging constraints with a compact set of linear constraints. Let \(H\) denote the number of optimization time slots. For a community with \(N\) EVs, we define the aggregated connection state \(A^{\text{agg}}\), energy state \(B^{\text{agg}}\), and cumulative energy demand \(D^{\text{agg}}\) as follows:
\[
A^{\text{agg}} = \sum_{i=1}^{N} A_i,\quad
B^{\text{agg}} = \sum_{i=1}^{N} B_i,\quad
D^{\text{agg}} = \sum_{i=1}^{N} D_i
\]
The aggregated charging power \(P^{\text{agg}}\) and energy \(E^{\text{agg}}\) are then constrained by:
\[
P^{\text{agg}} \leq P_{\text{pile,max}} \cdot A^{\text{agg}},\quad
E^{\text{agg}} = E_{\text{agg,a}} + U \cdot B^{\text{agg}} \cdot \Delta t \cdot P^{\text{agg}},\quad
E_{\text{min}} \cdot B^{\text{agg}} \leq E^{\text{agg}} \leq E_{\text{max}} \cdot B^{\text{agg}}
\]
The optimization problem for each community \(k\) minimizes the total annualized cost:
\[
\min_{x_{\text{int},k}} \left( C_{\text{PV},k} + C_{\text{wind},k} + C_{\text{BESS},k} + C_{\text{SG},k} \right)
\]
where the components are computed as:
\[
\begin{aligned}
C_{\text{PV},k} &= c_{\text{PV}} \cdot P_{\text{PV},k} \cdot \frac{r(1+r)^{y_{\text{PV}}}}{(1+r)^{y_{\text{PV}}}-1} \\
C_{\text{wind},k} &= c_{\text{wind}} \cdot P_{\text{wind},k} \cdot \frac{r(1+r)^{y_{\text{wind}}}}{(1+r)^{y_{\text{wind}}}-1} \\
C_{\text{BESS},k} &= \left( c_{\text{E\_BESS}} \cdot E_{\text{BESS},k} + c_{\text{P\_BESS}} \cdot P_{\text{BESS},k} \right) \cdot \frac{r(1+r)^{y_{\text{BESS}}}}{(1+r)^{y_{\text{BESS}}}-1} \\
C_{\text{SG},k} &= c_{\text{SG}} \cdot \sum_{t} \min\left( P_{\text{base},k}(t) – P_{\text{agg},k}(t),\, 0 \right) \Delta t
\end{aligned}
\]
The constraints include storage operation limits, wind/solar power curves, and the net-zero energy balance:
\[
P_{\text{prod},k}(t) = P_{\text{PV},k}(t) + P_{\text{wind},k}(t) + P_{\text{dis},k}(t),\quad
P_{\text{cons},k}(t) = P_{\text{ch},k}(t) + P_{\text{agg},k}(t),\quad
P_{\text{prod},k}(t) = P_{\text{cons},k}(t)
\]

We validated the framework using multi-source data from Wuhan, including over 2.6 million charging records, LandScan population density, EULUC-China land-use classification, and meteorological data. The grid cells covered the entire municipal area at a 5 km resolution. The Louvain algorithm automatically identified 16 communities with a modularity of 0.714, indicating a high-quality partition. Compared to a grid-by-grid planning approach, the proposed community-scale planning reduces total annual cost by 9.21% when vehicle-to-grid (V2G) is enabled, and by 9.97% without V2G. The following table summarizes the capacity allocation results under different scenarios.
| Scenario | PV capacity (MW) | Wind capacity (MW) | Storage capacity (MWh) / Power (MW) | Investment cost (106 CNY) | Operation cost (106 CNY) | Total cost (106 CNY) |
|---|---|---|---|---|---|---|
| 1: Community-based (no V2G) | 40.8 | 76.2 | 345.0 / 39.6 | 53.54 | 39.19 | 92.73 |
| 2: Grid-based (no V2G) | 38.9 | 79.4 | 347.2 / 52.0 | 54.46 | 45.65 | 100.11 |
| 3: City-wide (no V2G) | 41.7 | 74.5 | 348.8 / 39.3 | 53.49 | 51.37 | 104.86 |
| 4: Community-based (V2G) | 40.9 | 66.6 | 315.7 / 32.4 | 48.86 | 42.04 | 90.89 |
Further analysis reveals that the optimal capacity configuration varies significantly across communities. Using the ratio of wind capacity to PV capacity and the ratio of storage capacity to total renewable capacity as features, hierarchical clustering identifies three community types: photovoltaic-dependent communities (wind/PV < 1.85), wind-dependent communities (wind/PV > 3), and hybrid communities. For example, communities 11 and 12 are wind-dependent, while communities 2, 4, 6, 10, 14 require higher storage ratios exceeding 3.
Sensitivity analysis on PV unit cost shows that if the PV capital cost drops to 60% of its current value, many communities would switch to PV-dominated configurations. Additionally, as EV penetration increases from 13% to 50%, the required wind capacity grows 53.6% faster than PV capacity per percentage point of penetration, due to the better temporal alignment between wind generation and evening charging peaks.
The aggregated EV model demonstrates excellent computational efficiency: simulation times remain around 0.5 s regardless of fleet size, while the error compared to the individual model is within 3%. This allows the community-level optimization to be solved rapidly for all 16 communities.
In conclusion, the proposed community-detection-based planning method effectively exploits the spatial complementarity of EV charging loads to enhance the integration of renewable sources and energy storage systems. The results for Wuhan indicate that the approach reduces total system cost by over 9% compared to a naive grid-by-grid scheme, while also lowering investment in stationary energy storage system capacity by enabling V2G services. The framework provides a scalable solution for urban energy planners to achieve cost-efficient, net-zero energy districts powered by electric vehicles and renewable generation.
