Skip to contents

Where commodities enter and leave the model: domestic sources, resources, price steps and exogenous demand

PDF, A4, one page · energyRt 0.91.5.9015 (dev) · 2026-11-29
Build them
SUP_COA <- newSupply("SUP_COA", desc = "Domestic coal",
  commodity = "COA", unit = "PJ",
  supply = data.frame(region = c("R1", "R2"),
    ava.up = c(400, 150),     # PJ per slice
    cost = c(2.5, 3.0)),      # per PJ
  reserve = data.frame(region = c("R1", "R2"),
    res.up = c(8000, 2000)))  # over the horizon
SUP_GAS <- newSupply("SUP_GAS", commodity = "GAS",
  supply = data.frame(ava.up = 600))
SUP_GAS <- asSupplyCurve(SUP_GAS, range = c(4, 12),
  nsteps = 4)                 # 4 price steps
DEM_ELC <- newDemand("DEM_ELC", desc = "Power demand",
  commodity = "ELC", unit = "GWh",
  demand = data.frame(
    year = c(2025, 2050),       # interpolated
    demand = c(100, 180)))      # per slice
Drawn

A supply is open on the left (nothing flows in), a demand on the right. Each price step of a curve is a cluster with its own ava and cost.

How they enter the model
sup ≤ ava.up × Π(wava.up·weather) -- per slice, an absolute amount, not a share of capacity
Σ sup ≤ res.up -- cumulative over the horizon, per region
cost = Σ cost·weight·sup -- into the objective
dem = Σ demand -- fixed: the balance must deliver it

Supply and demand enter the commodity balance as out and inp; sup, dem = vSupOut, vDemInp. Imports and exports to the rest of the world are on the Trade sheet.

Supply
newSupply(name, desc, commodity, unit, weather, reserve, supply, cluster, geoframe, region, units, misc, ...)
A domestic source: one commodity, an availability, a cost, an optional reserve.
supply df cryt availability and cost
ava.lo/up/fx bounds on the flow, per slice 0/∞/– comm/year
cost cost per unit 0 cur/comm
reserve df cr cumulative resource
res.lo/up/fx bounds on the total over the horizon 0/∞/– comm
weather df c scales availability by a weather series
weather name of the weather object
unit unit expected from the series
transform derived series from weather@misc$transform
wava.lo/up/fx multiplier on ava.* 1/1/– factor
cluster df r price steps or tiers (see Clusters & vintages)
cluster step label
desc description
act.share.lo/up/fx bounds on the step's share of the flow –/–/–
order display order –
units df units, for reference and reports
comm unit of the commodity
activity unit of activity
currency currency of cost
Demand
newDemand(name, desc, commodity, unit, units, demand, cluster, geoframe, region, misc, ...)
Exogenous: the model has to deliver it.
demand df cryt the amount, per region, year, slice
demand amount per slice 0 comm
cluster df r sub-regional shares of one total
cluster share label
desc description
dem.share.fx fixed share of the total; shares sum to 1 –
order display order –
units df units, for reference and reports
comm unit of the commodity
currency currency
Identity & scope
name chr set name (supply)
name chr set name (demand)
desc chr description
desc chr description
commodity chr the one commodity supplied
commodity chr the one commodity demanded
region chr regions where it exists; empty = all
region chr regions where it applies; empty = all
geoframe chr geoscale level its regions are given at
geoframe chr geoscale level its regions are given at
Overrides & extras
defVal df per-object default, e.g. defVal$cost <- 1
defVal df per-object default
interpolation df per-object rule, e.g. interpolation$cost <- "inter"
interpolation df per-object interpolation rule
misc list free list for user data
misc list free list for user data
Price curves
asSupplyCurve(object, range, nsteps, shares, price, …)
A single-price supply, import or export → parallel price steps (clusters).
SUP_GAS <- newSupply("SUP_GAS", commodity = "GAS",
  supply = data.frame(ava.up = 600))
SUP_GAS <- asSupplyCurve(SUP_GAS,
  shares = c(0.5, 0.3, 0.2),
  price = c(4, 7, 12))
SUP_GAS@cluster

Each step gets its share of ava.up and its own cost; the model takes the cheapest first.

Recipes
# a resource running out: a cumulative cap
SUP_COA <- update(SUP_COA, reserve = data.frame(
  res.up = 5000))
# availability that changes over time
SUP_GAS <- newSupply("SUP_GAS", commodity = "GAS",
  supply = data.frame(year = c(2025, 2050),
    ava.up = c(600, 200), cost = 4))
# a must-take: at least 100 per slice
SUP_BIO <- newSupply("SUP_BIO", commodity = "BIO",
  supply = data.frame(ava.lo = 100,
    ava.up = 300, cost = 1))
# one national total split into areas
DEM_ELC <- newDemand("DEM_ELC",
  commodity = "ELC",
  cluster = data.frame(
    cluster = c("N", "S"),
    dem.share.fx = c(0.6, 0.4)),
  demand = data.frame(demand = 100))
Demand clusters are fixed shares of one total.
In the solution
vSupCost Supply costs (weighted) ry
vSupOut Output of supply cryt
vSupReserve Cumulative supply (weighted) cr
vDemInp Input to demand cryt
vSupOutTot Total commodity supply (weighted) cryt
getData(scen, name = "vSupOut",
        comm = "COA", merge = TRUE)
levcost(object, comm, name, ...)
With autocomplete = TRUE, a supply missing for an input is filled in for a levelized cost.