Skip to contents

energyRt energyRt hex logo

Lifecycle: maturing License: AGPL v3

energyRt (energy system modeling R-toolbox /ˈɛnərdʒi ɑrt/) is a macro-language for energy system modeling in R. You describe an energy system — its fuels, technologies, resources and demands — as R objects; energyRt compiles them into a full capacity-expansion & dispatch optimization model, solves it, and returns tidy results ready for dplyr/ggplot2 analysis. The technical layer (sets, equations, solver files, results parsing) is generated for you, so you concentrate on the system you are modeling, not on the code that optimizes it.

One model, four backends

The energyRt optimization model (~100 predefined equations, extendable with newConstraint()) is implemented in four mathematical-programming languages. The same model object solves on any of them, with consistent results:

Backend Language License
GLPK / MathProg (bundled with Rtools on Windows) open source
Julia / JuMP Julia + HiGHS open source
Python / Pyomo Python + CBC/HiGHS open source
GAMS GAMS commercial

Start on zero-setup GLPK; switch backends later without touching your model.

Quickstart

A complete model — one fuel, one power plant, one demand — built, solved and read in ~20 lines (GLPK, no external setup needed on Windows with Rtools):

library(energyRt)

GAS <- newCommodity("GAS", timeframe = "ANNUAL")
ELC <- newCommodity("ELC", timeframe = "ANNUAL")

SUP_GAS <- newSupply("SUP_GAS", commodity = "GAS",
                     availability = data.frame(cost = 6.0))   # fuel price, MEUR/PJ

EGAS <- newTechnology("EGAS",
  input   = list(comm = "GAS"), output = list(comm = "ELC"),
  ceff    = data.frame(comm = "GAS", cinp2use = 0.55),        # 55% efficient
  invcost = list(invcost = 900),                              # MEUR/GW
  fixom   = 25, cap2act = 31.536, olife = 25L)

DEM_ELC <- newDemand("DEM_ELC", commodity = "ELC",
                     dem = data.frame(dem = 50))               # 50 PJ a year

mod <- newModel("HELLO",
  data    = newRepository("parts", GAS, ELC, SUP_GAS, EGAS, DEM_ELC),
  region  = "R1", discount = 0.05,
  horizon = newHorizon(period = 2025:2040, intervals = c(1, 5, 10),
                       mid_is_end = TRUE))

scen <- solve_scenario(interpolate_model(mod, name = "BASE"),
                       solver = solver_options$glpk)

getData(scen, "vObjective", merge = TRUE)   # total discounted system cost
getData(scen, "vTechCap",   merge = TRUE)   # capacity the model built, GW

The Get started vignette walks through this example and the ideas behind it.

What’s in the box

  • Model bricks — commodities, technologies (with efficiencies, fuel blends & shares, auxiliary flows like emissions or cooling water), supply, demand, storage, weather, trade; draw() sketches any technology as a diagram. → Model bricks
  • UTOPIA teaching model — a complete multi-region electricity model built step by step, shipped as the utopia_modules data kit with ready scenario levers (CO₂ cap, carbon tax, renewable share, nuclear moratorium). → UTOPIA I: building the model · UTOPIA II: running scenarios
  • Levelized costlevcost() prices a technology a-priori (screening, textbook LCOE) or ex-post from a solved scenario, with autoplot() cost breakdowns.
  • Reportsreport() renders an HTML/PDF datasheet for a technology or a solved process, levcost included.
  • Scenario workflow — tidy result extraction with getData(), scenario editing & re-solving, Arrow-backed save_scenario()/load_scenario() for larger-than-memory results. → Workflow · Plotting

Learn more

  • Get started — the core idea in ten minutes.
  • Tutorials — installation, solver backends, model bricks, UTOPIA, workflow, plotting.
  • useR! workshop — a hands-on training course built on energyRt and the UTOPIA model (Quarto book, in preparation).
  • IDEEA — an open multi-region model of India’s power system, built with energyRt: a production-scale application.

Installation

pak::pkg_install("optimal2050/energyRt")
# or
remotes::install_github("optimal2050/energyRt")

To reproduce pre-2026 models, install the frozen legacy release instead: pak::pkg_install("optimal2050/energyRt@v0.50").

You will need at least one solver backend. On Windows, GLPK ships with Rtools — no extra setup. For Julia/JuMP, Python/Pyomo, or GAMS see the installation article and the solver backends article.

Development status

The current development line (v0.60.x) modernizes the interpolation pipeline, scenario storage, and analysis tools (levcost, report, autoplot) on the way to v1.0. The v0.50 release (“half-way-there”) is frozen and remains available for pre-2026 modeling projects; its model code, classes and methods will receive fixes only.

The package website: https://energyrt.org