Skip to content

How do I share a site's power limit between chargers?

A depot with a grid limit cannot give every car its full power at once. CHARGE shares a site limit between the cars charging. The script runs the same cars on a 100 kW and on a 60 kW site.

from nagasim import build as nb


def mean_charge_minutes(site_limit):
    m = nb.Model(time_limit=3000, time_unit="minutes")
    cars = m.create(distribution=nb.Exponential(rate=1 / 25), max_arrivals=100)
    # 20 kWh a car at up to 50 kW a car takes 24 minutes alone; the site limit caps the total power.
    bay = m.charge(energy="20", max_power="50", site_limit=site_limit)
    cars >> bay >> m.record(stat_name="charge_minutes", kind="tally", expr="entity.charge_time") >> m.dispose()
    results = m.run(seed=1)
    return float(results["user_summary"].set_index("Statistic").loc["charge_minutes", "Value"])


# Cars arrive about every 25 minutes, so two sometimes overlap. A 100 kW site feeds both at full power.
# A 60 kW site shares its power between them, which stretches those charges.
print(f"100 kW site limit: {mean_charge_minutes(100):.1f} minutes a charge")
print(f" 60 kW site limit: {mean_charge_minutes(60):.1f} minutes a charge")

Save it as recipe-site-power.py and run it with python. The script seeds itself, so the numbers below are the same on your machine.

100 kW site limit: 29.1 minutes a charge
 60 kW site limit: 70.8 minutes a charge

How it works

  1. m.charge(energy, max_power, site_limit) charges each car with up to max_power while the total stays under site_limit.
  2. A car alone needs 24 minutes for 20 kWh at 50 kW; overlaps stretch that, and a 60 kW limit stretches it much more.
  3. The charge_time of each entity is recorded, so you can read the delay the limit causes.

Elements used

Back to all recipes.