
Cheat sheet: TOPIA, the example model
Source:vignettes/articles/cheatsheet-topia.Rmd
cheatsheet-topia.RmdA 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-05geoscales::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.
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.
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
)
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.
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) |
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 |
TOPIA <- build_topia(as = "model")
Existing plants retire on schedule; new vintages open in 2025, 2030, 2040 and 2050.
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().
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"
)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.
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)
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)
gg_map(CO2CAP, type = "generation", process = "EWIN", facet = "year")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.
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, ...
- The calendar is
d365_h24or a sample of it; an averaged one (s4_h24) is refused. - GLPK suits
preset = "tiny"only; everything else needs HiGHS or larger. -
EARLY_RETis infeasible without endogenous retirement (optimizeRetirement = TRUE, the model's default here). -
CO2_CAPis rescaled with the number of provinces kept; a lever that names a dropped process is dropped with it. -
R01has no line: alone it is an island system. - With the 2025 base year, zones
Z3andZ5are infeasible alone: they rely on their neighbours.Z4stands alone; a horizon without a base year relaxes it.