Skip to contents

A country of 12 provinces in 5 zones, shipped with the package: what is in it, and how to build, cut, solve and vary it

PDF, A4, 2 pages · energyRt 0.91.5.9019 (dev) · 2026-12-05
The country
The twelve provinces of TOPIA on the honeycomb layout, coloured by zone
geoscales::gg_geoscale(topia$geoscales$honeycomb, type = "map", labels = TRUE)
Z1 Caldera R01 Geysia, an island: no line
Z2 Capital R02 Metropia, R03 Solaria
Z3 Highlands R04 Nuclia, R05 Alpinia, R06 Coalia
Z4 Lowlands R07 Torrentia, R08 Lignia, R09 Silvania, R10 Industria
Z5 Coastlands R11 Windia, R12 Maritia

Nation TOPIA → 5 zones → 12 provinces; the model runs on provinces. Four maps of the same hierarchy: topia$geoscales.

The system
COA, GAS supply in price tiers, import, routes between zones → ECOA, EGAS
NUC supply → ENUC
BIO, WST supply → EBIO
HYD resource RES_HYD, inflow WHYD → EHYD
LANDS land RES_LANDS, sun WSOL → ESOL
LANDW land RES_LANDW, wind WWIN → EWIN
no fuel → EGEO
ELC 14 lines TBD_ELC_Rxx_Ryy, battery STG_ELC (4 h) → DEM_ELC
H2 from ELC by H2ELC; STG_H2 (200 h) → EXP_H2
CO2 emitted by the fuels burnt capped or taxed by a lever

Electricity only. 54 objects: 11 commodities, 8 supplies, 2 imports, 1 export, 3 weather series, 9 technologies, 2 storages, 17 trade objects, 1 demand. Wind sites come in grades HI, MD, LO, solar in FL, TH, as clusters of EWIN and ESOL. Base year 2025, milestones 2030, 2040, 2050; currency MUSD.

Build and solve
create_project("topia_project")

TOPIA_Z4 <- build_topia(
  regions = "Z4",
  calendar = "d365_h24_1dps",
  as = "model"
)
REF <- solve_model(
  object = TOPIA_Z4,
  name = "REF",
  solver = solver_options$mm_highs
)
A project first. Then the two decisions: regions = (one zone of four provinces) and calendar = (one real day per season, 96 hourly timeslices).
  • All defaults: the nation, every hour of the year (8760 timeslices), the horizon 2025--2050.
  • as = "model" is ready to solve; "kit" (default) is the list of parts; "repository" the bricks alone.
  • The Results, Visualization, Reports and Levelized cost sheets read zone Z3, solved on a horizon without the base year.
Regions and time
build_topia(regions, preset, layout, calendar, horizon, as, …)
regions province codes, zone codes, "TOPIA", or a count; a cut that splits a zone is refused
layout "honeycomb", "squares", "island", "continent": the map
calendar "d365_h24", or a sample of it: _1dps (96 timeslices), _1dpm, _3dpm, _1wps, _1wpm
horizon "BY2025_50_by10", "BY2025", or a horizon object
preset "full", "zone" (Z3), "island" (R01), "tiny" (R01, two plants: GLPK)
The kit
TOPIA_KIT <- build_topia()
names(TOPIA_KIT)
[1] "regions"   "groups"    "calendar" 
[4] "repo"      "geoscale"  "CO2_CAP"  
[7] "CT_CO2"    "EARLY_RET" "GREEN_H2" 
repo the repository: 54 objects
regions the provinces kept
calendar the calendar, by name
geoscale the hierarchy and its map
groups the objects by module
the other four policy levers, kept out of the repository
Stock and investment windows
TOPIA <- build_topia(as = "model")
Existing stock and the years each technology vintage can be built and operates

Existing plants retire on schedule; new vintages open in 2025, 2030, 2040 and 2050.

The network
Electricity lines between the provinces of TOPIA on the map
gg_trade_map(TOPIA_KIT$repo, map = TOPIA_KIT$geoscale)

One brick, as any other: getObject(TOPIA_KIT$repo, name = "EWIN"), then draw() or autoplot().

Reducing the model
build_topia(techs, modules, clusters, max_vintages, levers, …)
techs names to keep, or "-ENUC" to drop; "vre", "thermal"
modules commodities, supply, weather, generators, storage, hydrogen, transmission, fuel_trade, demand
clusters FALSE: one wind and one solar class, no grades
max_vintages 1: one vintage per technology
storage_duration a number, c(lo, up) or "free"; storage_inp2out alike
demand, weather "sample", or a user table
levers TRUE, FALSE, or lever names
TOPIA_SMALL <- build_topia(
  regions = "Z4",
  calendar = "d365_h24_1dps",
  max_vintages = 1,
  clusters = FALSE,
  as = "model"
)
Model size
preset = "tiny" one province, two plants, 96 timeslices: GLPK
a zone, _1dps about half a minute with HiGHS (mm_highs)
the nation, _1dps HiGHS
the nation, d365_h24 8760 timeslices: a large LP, see Backends & solvers

model_size() counts the rows and columns before anything is solved.

Base year, then the horizon
BY2025 <- interpolate_model(TOPIA_Z4,
  name = "BY2025",
  horizon_segment = "base_year")
BY2025 <- solve_scenario(BY2025)
REF <- interpolate_model(TOPIA_Z4,
  name = "REF",
  base_year_scenario = BY2025)
REF <- solve_scenario(REF)
2025 is given, so it is solved alone; its solution enters the projection as stock, and 2030, 2040, 2050 are solved.
Policy scenarios
CO2CAP CO2_CAP a national cap on CO2 in each year
CO2TAX CT_CO2 a CO2 price, 20 USD/t in 2025 to 80 in 2050
EARLY_RET EARLY_RET limits on coal and gas capacity in 2030, 2040, 2050
GREEN_H2 GREEN_H2 the electrolyser runs within renewable generation, per region and timeslice
CO2CAP <- interpolate_model(TOPIA_Z4,
  TOPIA_KIT$CO2_CAP,
  name = "CO2CAP",
  base_year_scenario = BY2025)
CO2CAP <- solve_scenario(CO2CAP)
A lever is a brick added at interpolation: the scenario is named after it, the model stays as it is.
Results on the map
Wind generation by province of zone Z3 in 2030, 2040 and 2050
gg_map(CO2CAP, type = "generation", process = "EWIN", facet = "year")
Hourly dispatch in R05 on a July day of 2050
autoplot(CO2CAP, "generation", region = "R05", year = 2050, timeslice = "^d196_")

Zone Z3 under the CO2 cap. The sampled days are d015, d105, d196, d288. More on Visualization and Results.

The underlying data
geoscales the four maps, with geometry
weather hourly wind, solar and hydro profiles
demand hourly load
stock the existing fleet
links the lines
grades wind and solar site grades
modules the model itself, its calendars and horizons

All in the dataset topia: topia$weather, ...

topia_profiles(regions, calendar, …)
Weather, demand and stock tables for a set of regions.
topia_simulate(regions, calendar, …)
Synthetic weather and demand of a chosen shape.
topia_profile(shape, levels, calendar, …)
One simple profile: step, sine, cosine, hex.
Pitfalls
  • The calendar is d365_h24 or a sample of it; an averaged one (s4_h24) is refused.
  • GLPK suits preset = "tiny" only; everything else needs HiGHS or larger.
  • EARLY_RET is infeasible without endogenous retirement (optimizeRetirement = TRUE, the model's default here).
  • CO2_CAP is rescaled with the number of provinces kept; a lever that names a dropped process is dropped with it.
  • R01 has no line: alone it is an island system.
  • With the 2025 base year, zones Z3 and Z5 are infeasible alone: they rely on their neighbours. Z4 stands alone; a horizon without a base year relaxes it.