Repository navigation
Walkthrough PyPSA Quickstart 1
PyPSA's Quickstart 1 - Markets. Two zones, joined by one 400 MW line. Zone 1 has 500 MW of demand, zone 2 has 1,500 MW. Each zone has a 2,000 MW generator with a quadratic cost:
- zone 1: 10 g + 0.005 g²
- zone 2: 13 g + 0.01 g²
The question: the least-cost dispatch, the price in each zone, the flow on the line, and the congestion rent.
On Home, click New project. Name: Quickstart 1. Click Create project.


Click New network. Name: Two-zone market. Under Time axis, choose Define, start at 1 Jan 2026 00:00 for 1 hour, hourly, then click Create network.
The dialog has no framework choice; the network is a PyPSA network.

Open Components → Buses, then Add bus ▾ → Add in a panel…. Name: zone_1. Click Add another name, which suggests zone_2, then Add 2 buses to draft.



Open Loads and add load_1 and load_2 in a panel. Click Separate values beside Bus and beside Demand to give each load its own bus and demand.
| Name | bus | p_set (MW) |
|---|---|---|
| load_1 | zone_1 | 500 |
| load_2 | zone_2 | 1500 |

Open Generators and add gen_1 and gen_2 in a panel, each with p_nom 2000 MW. Give each its own bus, marginal cost and quadratic marginal cost.
| Name | bus | p_nom (MW) | marginal_cost | marginal_cost_quadratic |
|---|---|---|---|---|
| gen_1 | zone_1 | 2000 | 10 | 0.005 |
| gen_2 | zone_2 | 2000 | 13 | 0.01 |

Open Lines and add line_1 in a panel, from bus0 zone_1 to bus1 zone_2, with x 0.01 Ohm and s_nom 400 MVA.
| Name | bus0 | bus1 | x (Ohm) | s_nom (MVA) |
|---|---|---|---|---|
| line_1 | zone_1 | zone_2 | 0.01 | 400 |

The header shows a draft of 7 changes. Click Save version, give it the title Quickstart 1: two-zone market, and click Save v2.


Click Solve in the header, keep the defaults (Method: Optimize, Solver: HiGHS), and click Solve. The Solve page follows the run until it succeeds.



Click View results. Components opens with Results on, which adds the outputs as columns after the inputs. Read marginal_price on Buses, p on Generators, and p0 and p1 on Lines.
On Generators and Lines the output columns are past the right edge at 1440 px: click a row's name and press the right arrow key to scroll to them.




On Lines, open Columns and, under Statistics, tick Congestion rent. The column shows the line's congestion rent for the run.


Open Visualisation. The run summary at the top shows the objective and the peak line loading of 100 %, since the line is congested.

| Quantity | Value |
|---|---|
| Objective | 39,450 |
| gen_1 p (MW) | 900 |
| gen_2 p (MW) | 1,100 |
| zone_1 marginal_price | 19.00009 |
| zone_2 marginal_price | 35.00011 |
| line_1 p0 (MW) | 400 |
| line_1 p1 (MW) | -400 |
| Congestion rent (currency) | 6,400.008 |
| Peak line loading (%) | 100 |
💡 Key learnings
- A congested line splits one market into two prices. Zone 1's generator is cheaper, but the 400 MW line cannot carry all it could sell. Zone 2 must make its last 1,100 MW itself, so each zone's price is set by its own generator.
- With a quadratic cost, the price is the cost of the last MWh. Each MWh costs more than the one before: zone 1's price is 10 + 2 × 0.005 × 900 = 19, zone 2's is 13 + 2 × 0.01 × 1,100 = 35.
- Congestion rent is the value of the bottleneck. The line moves 400 MW from a price of 19 to a price of 35, worth 400 × 16 = 6,400 an hour. It is a first measure of what more transmission between the zones would be worth.
Using the app
Architecture
- Overview
- Python API
- Domain model
- Backend core
- Composition root and config
- Expression language internals
- Storage
- Execution
- Imports and exports
- Workflow engine
- HTTP API and contracts
- Frontend and desktop
- Build, CI and release
Contributing