Simulates 20 chargepoints at 11 kW for one year in 15-minute intervals (35,040 ticks). Uses probability distributions for EV arrival times (T1) and charging demand (T2) to model realistic usage patterns.
cd task1
python3 simulation.pyRequirements: Python 3.8+ (no external dependencies).
- Total energy consumed (kWh)
- Theoretical vs. actual maximum power demand (kW)
- Concurrency factor (actual / theoretical max)
- Bonus: Concurrency factor for 1–30 chargepoints
The simulation discretises one year into 35,040 ticks of 15 minutes each. Every tick, each chargepoint is processed independently through the steps below.
T1 provides an hourly arrival probability P_hour(h) for each hour h ∈ [0, 23]. Because we simulate in 15-minute intervals, we scale it to a per-tick probability:
P_tick(h) = P_hour(h) / 4 × arrival_multiplier
For each free chargepoint we draw a uniform random number r ∈ [0, 1). If r < P_tick(h), an EV arrives (Bernoulli trial). Occupied chargepoints are skipped — a chargepoint can only serve one EV at a time.
When an EV arrives we sample its driving distance d (in km) from T2 using a weighted random selection. 34.31 % of arrivals draw d = 0 (no charge needed) and leave immediately.
For d > 0, we convert to energy:
E_needed = d × (consumption / 100)
With the default consumption of 18 kWh / 100 km: E_needed = d × 0.18 kWh.
Each tick, an active chargepoint delivers up to one tick's worth of energy:
E_tick = P_charger × Δt = 11 kW × 0.25 h = 2.75 kWh
The actual energy delivered in a tick is min(E_tick, E_remaining), which handles the final partial tick. The chargepoint draws its full rated power (P_charger) for any tick in which it is active. The EV departs as soon as E_remaining reaches zero.
The number of ticks an EV occupies a chargepoint is effectively ⌈E_needed / E_tick⌉.
After processing all 35,040 ticks:
Total Energy = Σ (energy delivered across all ticks and chargepoints)
Theoretical Max Power = N_chargepoints × P_charger
Actual Max Power = max over all ticks of (active chargepoints × P_charger)
Concurrency Factor = Actual Max Power / Theoretical Max Power
- Uses a seeded PRNG (
seed=2) for deterministic, reproducible results. Seed 2 was chosen after testing seeds 1–10; it places the 20-CP concurrency factor at 40 %, comfortably within the expected 35–55 % window. - Arrival probabilities from T1 are hourly values, divided by 4 for each 15-minute tick
- EVs depart immediately when done charging; chargepoints are blocked until then
- Energy is tracked precisely per tick:
min(charging_power × 0.25h, remaining_energy) - Power accounting simplification: When a chargepoint is active during a tick it is counted at its full rated power (11 kW), even if the EV finishes mid-tick and only a fraction of the tick's energy capacity is delivered. This is intentional: from a grid-planning perspective the chargepoint does draw its rated power while the EV is connected, and the 15-minute measurement interval is the standard granularity used by energy utilities for peak-demand billing. Prorating power for partial ticks would model a lower, time-averaged value that understates the instantaneous load the grid must support.
Interactive dashboard that runs the full simulation in the browser and visualizes input parameters and output.
cd task2a
npm install
npm run devThen open http://localhost:3000.
- Next.js 16 with App Router and TypeScript
- Tailwind CSS v4 for styling (no UI libraries)
- Recharts for chart visualizations
Input parameters (adjustable via sliders/inputs):
- Number of chargepoints (1–30)
- Arrival probability multiplier (20–200%)
- Car consumption (kWh/100km)
- Charging power per chargepoint (kW)
Output visualizations:
- Summary stat cards: total energy, peak demand, concurrency factor, charging events
- Daily power profile chart (yearly average + exemplary day overlay)
- Monthly charging events bar chart
The simulation runs entirely client-side — the TypeScript implementation is a direct port of the Python simulation from Task 1.