Skip to content

Walkthrough PyPSA Quickstart 1

James Dunkerley edited this page Dec 3, 2026 · 10 revisions

Quickstart 1: a two-zone market with a congested line

All walkthroughs

What it models

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.

Steps

1. Create the project

On Home, click New project. Name: Quickstart 1. Click Create project.

Home

New project

2. Create the network with one timestep

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.

New network with one hourly timestep

3. Add the buses

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.

Add bus menu

Add in a panel

Two bus names in the panel

4. Add the loads

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

Add loads with separate values

5. Add the generators

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

Quadratic marginal cost per generator

6. Add the line

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

Add line

7. Save the draft

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

Draft of seven changes

Save a new version

8. Solve

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

Solve button

Solve dialog

Run succeeded

9. Read the prices, dispatch and flow

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.

View results

Bus marginal prices

Generator dispatch

Line p0 and p1

10. Show the congestion rent

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

Columns, Statistics

Congestion rent

11. Check the run summary

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

Run summary

Results

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.

Bugs

  • #2747 The run summary counts unused capacity of non-variable generators as curtailment (open)
  • #2748 The solver log shows the server's temporary file paths (open)

Hard to do

  • #2741 With Results on, output columns come after every input, with no Outputs only view, so p, p0 and p1 are off screen (open)
  • #2746 The network's Overview ignores the open draft: "No buses yet" and 0 of each type (open)

Clone this wiki locally