Microgrid Dispatch

PYTHON CONTROL SYSTEMS PROJECT

Off-grid microgrid
dispatch

A 24-hour simulation of how solar, battery storage, and a diesel generator share the load at a remote site.

Unmet load0 kWh
Diesel generation701 kWh
Minimum battery SOC20%

24-HOUR SIMULATION

Dispatch timeline

Solar to loadBattery dischargeDiesel Battery chargeLoad

Charging is shown below zero. The lower plot tracks battery state of charge (SOC).

SUPERVISORY CONTROL

Control logic

  1. Serve the load with solar. Send surplus energy to the battery, within its charging limit.
  2. Use stored energy for deficits. Respect the battery's discharge limit and 20% SOC reserve.
  3. Dispatch diesel for the remainder. Record unmet demand if all available sources are at their limits.

ACCEPTANCE TESTS

Validation

  • Solar surplus charges the battery
  • Battery alone covers a small deficit
  • Diesel covers the deficit at the SOC floor
  • Insufficient capacity records unmet load
  • Hourly supply and demand reconcile

Python source

The controller receives demand, available solar, and equipment limits for one hour. It returns battery and diesel energy commands.

VS Code screenshot of dispatch.py, which prioritizes solar, applies battery limits, and uses diesel to cover remaining demand.