Honglin Li
  • Research
  • Projects
  • Publications
  • Software
  • Teaching
  • Learn
  • Notes
  • CV
  • Journeys

Microgrid Workbench

Island a fictional campus: set what must stay on, size solar, a battery and diesel, and test hypothetical outages on 2025 solar profiles within the feeder’s limits

Sandbox SB1 of Energy Systems, Step by Step: set Prairie Campus’s load priorities, equipment, feeder limits, tariff and owner; a small mixed-integer program runs hypothetical outages hour by hour or sizes the plan.
  1. Learn
  2. SB1
  • Analyst to Modeler · L2–L3
  • Sandbox
  • 30 min
  • After lesson 9
  • Completed
  1. 1Brief
  2. 2Bench
  3. 3Results
  4. 4Explain
  5. 5Sources

The brief

The site
Prairie Campus (fictional, from F7): a county hospital, a water and heating plant, dorms and labs, 1,200 kW in all, on one feeder.
You decide
What must stay on; solar (kW), battery (kWh), 200 kW generator sets and diesel (gallons); the feeder's limits, the tariff and the owner.
The engine works out
A normal year on the grid, then each hypothetical outage hour by hour as an island; or the cheapest sizes, with a small mixed-integer program.
It leaves out
Marginal electricity prices (the engine does not calculate them), the wiring inside the campus, part-load fuel use, battery wear, and outages you do not choose.

Open-ended: start from a preset, change one thing at a time, and copy the plan link to keep a plan.

The bench

Control Default plan Range
Solar panels 600 kW 0 to 4,000 kW, in steps of 25 kW
Battery 2,000 kWh 0 to 8,000 kWh, in steps of 50 kWh
Generator sets (200 kW each) 2 sets 0 to 4 whole sets
Diesel on site 675 gallons 0 to 6,000 gallons, in steps of 25 gallons
County hospital Must stay on one of: Must stay on, Keep if possible, Shed first
Water and heating plant Must stay on one of: Must stay on, Keep if possible, Shed first
Dorms Keep if possible one of: Must stay on, Keep if possible, Shed first
Classrooms and labs Shed first one of: Must stay on, Keep if possible, Shed first
Outages to plan for Winter storm, 3 days any of: Winter storm, 3 days, Winter evening, 1 day, Summer storm, 3 days
Feeder export limit 500 kW 0 to 2,000 kW, in steps of 50 kW
Feeder import limit 2,000 kW 800 to 2,000 kW, in steps of 50 kW
Tariff Time-of-use one of: Time-of-use, Flat
Owner Community-owned one of: Utility-owned, Co-op-owned, Community-owned
Size it may build solar, battery, generator sets any of: solar, battery, generator sets

With JavaScript on, you change these on a one-line diagram, run each outage in your browser, ask the solver for the cheapest sizes, and copy a link to your plan.

  • Illustrative: Prairie Campus and its loads (F7's), equipment costs, fuel use, the export credit and the owners' costs of capital, in 2025 dollars.
  • Solar: a teaching profile per kW of panels, SPP's observed 2025 hourly shape scaled to EIA's monthly capacity factors, as in F7; not measured campus output.
  • EIA: the tariff's level, the diesel price and both CO₂ factors (sources below).

Results

Result for the default plan (F7's campus) Value
Plan 600 kW of solar · 2,000 kWh battery · 2 sets of 200 kW · 675 gallons
Annual cost: equipment and upkeep plus the normal-year grid bill on 12 average days (2025 dollars, illustrative; outage diesel not included) $1,341,327
The year's bill with nothing built $1,405,586
CO₂ from grid electricity in a normal year 3,425 t
Must-stay-on load unserved: winter storm, 3 days 10,070 kWh (675 gal of diesel, $2,470)

Precomputed with HiGHS on 3 November 2026 for the default plan above; with JavaScript on, the bench runs your own plan.

How the engine works, as diagrams

Run the outages
A linear program runs a normal year on 12 average days; then a mixed-integer program runs each outage as an island, with whole 200 kW sets that run at 30% or more.
Size it for me
One mixed-integer program picks the cheapest solar, battery and whole sets that keep every must-stay-on load on in every chosen outage; rounded up to the bench's steps, the run then checks them.
It holds when
The chosen outages are the ones that matter, loads are flat, 12 average days stand in for the year, and the coming sun is known.
It leaves out
Marginal prices, the campus's wiring, part-load fuel use, battery wear, fuel deliveries, outage diesel in the annual cost, and how often outages happen.
Go deeper · ModelerThe model behind the bench

M5 writes the engine down, proves the sizing with branch and bound, and runs the storm on forecasts. Its notebook rebuilds the models in Python and checks the sizing and outage numbers.

Go deeperHow the outages are chosen

Every outage is hypothetical: the grid is assumed down while the 2025 sun of that stretch shines.

Named outage Grid assumed down
Winter storm, 3 days 72 hours from 00:00 on 20 January 2025
Winter evening, 1 day 24 hours from 16:00 on 20 January 2025
Summer storm, 3 days 72 hours from 00:00 on 28 July 2025

The ten drawn outages:

  • Seed 7: the same ten on every visit.
  • Start: any whole hour from 1 January to 25 February 2025, each equally likely.
  • Length: 6 to 72 hours, each equally likely.
  • A teaching sample, not outage statistics: riding through all ten is ten tests passed, nothing more.
Go deeperHow close 12 average days come to a full year

The normal year is 12 average days, one per month; each day's battery ends where it began. The test runs four plans over all 8,760 hours of 2025 as well:

Plan Grid bill, 12 average days Grid bill, 8,760 hours Difference
F7's campus (the default plan) · 600 kW, 2,000 kWh $1,117,962 $1,117,960 the same
Size it for me, from the default plan · 2,625 kW, 3,650 kWh $548,218 $571,684 +4.3%
Sized with the dorms also must stay on (C1) · 3,225 kW, 5,050 kWh $403,456 $430,228 +6.6%
M5's plan: exports capped at 0 kW · 2,575 kW, 3,600 kWh $562,709 $595,596 +5.8%

Average days smooth out runs of cloudy and sunny days, so a large solar-and-battery plan's bill comes out low. Read the annual cost as an estimate.

Numbers, sources and what’s next

Inputs the engine uses

Input Value Source
Campus loads (flat, every hour) 300 · 100 · 250 · 550 kW F7's Prairie Campus: hospital, water and heating plant, dorms, labs (illustrative)
Solar output per kW of panels 24.0% a year A teaching profile, not measured campus output: SPP's observed 2025 hourly shape, EIA-930 · accessed 2 Nov 2026; scaled to EIA, Electric Power Monthly, Table 6.07.B, month by month · issue of 23 Oct 2026
Tariff level 13.37¢/kWh EIA, Electric Power Annual, Table 2.4: U.S. commercial average, 2025 · accessed 3 Nov 2026. Time-of-use: 28.31¢ from 16:00 to 21:00, 9.44¢ otherwise (illustrative split)
Diesel $3.66/gallon Prices each outage's diesel, shown on its own (not in the annual cost). EIA, U.S. No 2 diesel retail price, 2025 average · released 3 Nov 2026
CO₂ from diesel 10.19 kg/gallon EIA, Carbon Dioxide Emissions Coefficients · released 18 Sep 2024
CO₂ from grid electricity 0.367 kg/kWh EIA FAQ: about 0.81 pounds per kWh, U.S. utility-scale generation, 2023 · updated 11 Dec 2024. An average, operating-only factor
Equipment, a year's upkeep, life $1,800/kW · $450/kWh · $600/kW · $5/gal Illustrative, 2025 dollars: solar ($20/kW, 25 years), battery (2.5%, 15 years, 90% of a charge back), generator sets ($15/kW, 20 years), diesel tank (20 years)
Generator fuel use 0.07 gal/kWh Illustrative, at any output; a set that is on runs at 30% of its 200 kW or more
Export credit 4¢/kWh Illustrative: Prairie Town's combined-cycle running cost, $40/MWh (lesson 0)
Owners' real cost of capital 6% · 4% · 5% Illustrative: utility, co-op, community

Keep going

Back to the course map

Built on

  • F7 (the campus and its island) and A14 (what a microgrid is worth); lesson 9 (storage) and lesson 3 (outages and balance); M2 for whole numbers in a model.
  • Formalised in M5; applied in the capstone C1.
  • Open tools for larger microgrid models: PyPSA, Pyomo and JuMP.

Sources and further reading

  • EIA. Hourly Electric Grid Monitor (Form EIA-930): the Southwest Power Pool solar behind the sun.
  • EIA. Electric Power Annual, Table 2.4: average price of electricity to ultimate customers, 2025.
  • EIA. Carbon Dioxide Emissions Coefficients, and How much carbon dioxide is produced per kilowatthour of U.S. electricity generation?
  • HiGHS. Documentation of the open-source solver that runs the bench in your browser.

Spotted an error, or stuck? Write to hlli@ksu.edu. Corrections are made in place and dated here.

Text licensed CC BY 4.0, code MIT: teachers and students may reuse and adapt it, with credit to Honglin Li.

© 2026 Honglin Li · Kansas State University · hlli@ksu.edu

 

Last updated: November 2026 · Built with Quarto