
Cheat sheet: Levelized cost
Source:vignettes/articles/cheatsheet-levcost.Rmd
cheatsheet-levcost.RmdThe cost of a unit of output: before solving, from an object and the prices around it; after solving, from what the model built and ran
PDF, A4, one page · energyRt 0.91.5.9015 (dev) · 2026-11-29The discounted cost of a process over its years, divided by its discounted output:
LCOE = Σ_y df_y (EAC_y + FOM_y + VOM_y + Fuel_y)
-----------------------------------------
Σ_y df_y · Output_y
EAC annualised investment, FOM/VOM fixed and variable O&M, Fuel inputs at their price, df the discount factor. A storage adds its charging cost; a trade divides by what arrives.
| ex-ante |
technology, storage, trade
|
a mini-model around the object: unit demand, the prices you give |
model, repository
|
the same, with the container's supplies, calendar, region, horizon and discount | |
| ex-post | solved scenario
|
what the process cost and produced in the solution |
lc <- levcost(mod, name = "ECOA")
lc$levcost_npv
ECOA 0.05263046
Calendar, region, years, discount rate and the supplies of its inputs come from the model.
lv <- levcost(mod, name = "EWIN",
by_variant = TRUE)
levcost(lv, by_variant = "npv") or "components" returns the table without solving again.
levcost(object, comm, name, ...)comm: the output to divide by (default: all of the output group); name: the process in a container.lg <- levcost(EGAS, fuel_costs = c(GAS = 8),
discount = 0.07)
lg$levcost_npv
EGAS 0.06078848
fuel_costs.fuel_costs |
prices of inputs (and aux inputs) with no supply |
repo |
supplies, commodities, weather to build with |
autocomplete |
supply missing inputs instead of returning NULL
|
weather |
required when the process has a @weather slot |
discount, base_year, horizon
|
0.05; years from olife if none |
timeframe |
"ANNUAL": one slice, the weather as an annual factor; "native": the calendar's slices |
by_region |
one price per region, as a list |
method |
"analytic" closed form, "solve" a mini-model; "auto" picks |
frontier |
extra solves mapping a grouped output's share corners |
backstop |
a costly slack so the mini-model always solves; not in the cost |
sapply(c("ENUC", "EBIO", "EHYD"),
function(p) unname(levcost(CO2CAP,
name = p)$levcost_npv))
ENUC EBIO EHYD 0.02366629 0.04450633 0.02834199
ls <- levcost(CO2CAP, name = "STG_ELC")
sapply(ls, \(x) unname(x$levcost_npv))
STG_ELC_VIN2025 STG_ELC_VIN2035
0.04619618 0.02962019
…
Ex-post: idle capacity raises it, a high load factor lowers it; ex-ante assumes the plant runs as its availability allows.
$levcost |
by year |
$levcost_npv |
one number: the discounted average |
$cost_breakdown |
eac, fixom, varom, input, import, export by year |
$cost_breakdown_npv |
the same, discounted |
$cost_yearly |
undiscounted costs, output, inputs |
$frontier |
the share corners (frontier = TRUE) |
$scenario |
the solved mini-model (solver path) |
$units |
the cost and activity units |
autoplot(lc): by year; autoplot(lc, type = "npv"): one bar. A list of results plots side by side.
ECHP <- newTechnology("ECHP",
input = data.frame(comm = c("COA", "BIO"),
group = "fuel"),
output = data.frame(comm = "ELC"),
group = data.frame(group = "fuel"),
ceff = data.frame(comm = c("COA", "BIO"),
cinp2use = c(0.40, 0.35),
grp.share.up = c(1, 0.3)))
gg_share_frontier(tech_share_frontier(ECHP))[[1]]
report(ECOA, levcost = lc)
- Ex-ante and ex-post answer different questions: what a plant would cost if run as assumed, and what it did cost in this system.
- Capacity bounds are stripped from the mini-model: it sizes the plant to the unit demand.
- A weather-driven plant needs its weather, or its availability is whatever
afsays. - A multi-region process is priced in its first region unless
by_region = TRUE. - The units are the model's: cost unit per activity unit (
$units).