Skip to main content
TransitionZero Logo

TZ-OSeMOSYS - a modern long-run systems modelling framework

License Contributor Covenant Tests Coverage Python Status

OSeMOSYS is an open source modelling system for long-run systems analysis and planning. It has been employed to develop energy systems models from the scale of the globe, continents, countries, regions, and villages. OSeMOSYS is extremely flexible - it can be used for high-fidelity representations of power systems, rich with technological detail; medium-fidelity representations of all-energy systems including upstream energy supply, final energy demand, and climate policies; or low-fidelity nexus problems including commodities like materials, energy, and financing, and a range of environmental and social impacts.

OSeMOSYS is entirely open-source and can be used with a variety of programming languages and solvers.

OSeMOSYS with Scenario Builder

TransitionZero has rebuilt OSeMOSYS as a pip-installable Python package (tz-osemosys). This implementation of OSeMOSYS underlies our Scenario Builder, a no-code platform for energy system modelling. We have added the following features:

Documentation

TZ-OSeMOSYS

Examples

OSeMOSYS Docs

Installation

TZ-OSeMOSYS can be installed with a simple pip install tz-osemosys. To solve a model, however, you'll need a solver. Any solver compatible with Linopy will work: Coin-OR CBC, GLPK, HiGHS, Gurobi, CPLEX, and more. We recommend HiGHS, the leading open-source solver.

Solver Installation - HiGHS

HiGHS can be installed from source using cmake following the instructions here. You'll need to install a cmake distribution for your relevant operating system.

common issue: make sure you have write-privileges to default directory for cmake --install build, or either run this command with administrator privileges (sudo cmake --install build on mac and linux) or specify a different build directory

Docker installation

A docker container is provided that contains Python 3.11 and an installed version of HiGHS. You'll need to install a docker distribution relevant for your operating system.

The docker container is used in testing, but can also be used for local development work. The following docker command will run and enter the docker container, mount the current working directory at the /home directory, and change directory within the container to this directory.

docker run -v $(pwd):/home -it  ghcr.io/transition-zero/tz-highs/highs-python:latest /bin/bash -c 'cd /home && /bin/bash'

note! Any files changed within this mounted directory will persist, but any changes to environments, installed packages, etc. will not!

Quickstart

TZ-OSeMOSYS provides several entry-points to get started quickly, however your model is specified.

From Pydantic objects

Models can be specified directly with Pydantic objects. Pydantic gives useful tooling for class inheritance and field validation. The Model class and subclasses provide obvious semantic linking between the object types. The set of objects comprising the model is mutually exclusive - no information is repeated - and collectively exhaustive - no information needs to be extracted from csvs or other data sources.

from tz.osemosys import (
    Model,
    Technology,
    TimeDefinition,
    Commodity,
    Region,
    Impact,
    OperatingMode,
)

time_definition = TimeDefinition(id="years-only", years=range(2020, 2051))
regions = [Region(id="single-region")]
commodities = [Commodity(id="electricity", demand_annual=25 * 8760)]  # 25GW * 8760hr/yr
impacts = [Impact(id="CO2", penalty=60)]  # 60 $mn/Mtonne
technologies = [
    Technology(
        id="coal-gen",
        operating_life=40,  # years
        capex=800,  # mn$/GW
        # straight-line reduction to 2040
        residual_capacity={
            yr: 25 * max((1 - (yr - 2020) / (2040 - 2020), 0))
            for yr in range(2020, 2051)
        },
        operating_modes=[
            OperatingMode(
                id="generation",
                # $mn20/Mt.coal / 8.14 TWh/Mt coal * 8760 GWh/GW / 0.3 /1000 GWh/TWh (therm eff)
                opex_variable=20 / 8.14 * 8760 / 0.3 / 1000,  # $71/GW/yr
                output_activity_ratio={"electricity": 1.0 * 8760},  # GWh/yr/GW
                emission_activity_ratio={
                    "CO2": 0.354 * 8760 / 1000
                },  # Mtco2/TWh * 8760GWh/Gw/yr /1000 GWh/TWh
            )
        ],
    ),
    Technology(
        id="solar-pv",
        operating_life=25,
        capex=1200,
        capacity_factor=0.3,
        operating_modes=[
            OperatingMode(
                id="generation",
                opex_variable=0,
                output_activity_ratio={"electricity": 1.0 * 8760},  # GWh/yr/GW
            )
        ],
    ),
]

model = Model(
    id="simple-carbon-price",
    time_definition=time_definition,
    regions=regions,
    commodities=commodities,
    impacts=impacts,
    technologies=technologies,
)

model.solve()

From Yaml

YAML is a human-readable data serialisation language. We've build a custom YAML parser that allows the creation of model configurations that are exhaustive while also being expressive.

  • model fields can be cross-referenced in the yaml blob, e.g. my_field: ${commodities[0].COAL.demand}.
  • model fields can also be populated from environment variables: my_field: $ENV{MYVAR}.
  • simple Python expressions are automatically evaluated, including list comprehensions, dictionary comprehensions, min, max, sum, and range functions.
  • for data keyed by an osemosys set (e.g. YEARS, TIMESLICES, TECHNOLOGIES), wildcards "*" can be used in place of explicitly listing all set members.
  • data field set dimensions and membership are also automatically inferred - a single value can be given which will be broadcast to all set member combinations.
  • single or multiple .yaml files can be composed together, allowing you to separate, e.g. technologies.yaml, from the rest of your model.
  • with cloudpathlib and a cloud storage provider SDK installed the path to yaml files can be a cloud storage object URI. See https://cloudpathlib.drivendata.org/stable/ for more details.
  • pip install "tz-osemosys[cloudpath]" will install cloudpathlib and python client libraries for cloud storage provider SDKs.
from tz.osemosys import Model

my_model = Model.from_yaml("path/to/yaml/directory")

From Otoole outputs (legacy)

TZ-OSeMOSYS is provided with backwards compatibility with the otoole osemosys tooling. Any legacy models can be loaded from the directory of otoole-formatted csvs.

from tz.osemosys import Model

my_model = Model.from_otoole_csv("path/to/otoole/csv/directory")

Read more in the documentation

Example models

There are several example models in TZ-OSeMOSYS that serve as learning tools and starting points for users. We recommend exploring the two-region example model, which illustrates a simple system with two regions and includes primary, secondary, and final energy vectors. The model is built using yaml files and is fully documented within this repository.

Development and Contributing

We welcome contributions! To get started as a contributor or as a developer, please read our contributor guidelines.

Metadata

Release files for tz-osemosys 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tz-osemosys 0.4.0
File Size Uploaded
tz_osemosys-0.4.0.tar.gz 808.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tz-osemosys 0.4.0
File Interpreter ABI Platform
tz_osemosys-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 945.7 kB

Release files / tz_osemosys-0.4.0.tar.gz

Download URL tz_osemosys-0.4.0.tar.gz
Size 808.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3e6d3c462b9ca1f5430e9cd0a07c148e8730f24ff14f067484adc68d2910b0ad
BLAKE2b-256 checksum
How to use checksums
f08662d295406c6e0b57df496baf45a2e463b3143138252d5b4e7558aa14ea1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 28, 2026.

Transparency log

Release files / tz_osemosys-0.4.0-py3-none-any.whl

Download URL tz_osemosys-0.4.0-py3-none-any.whl
Size 137.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
775a3084ae78ac717bdf357af9b1fb9ef1de7b007c8aa9c7141f08de7c4601e2
BLAKE2b-256 checksum
How to use checksums
c81951e0af2ebde1d2fb3957f72545f13781b7abe176ba3be0955d2f3bd83667
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 28, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.1

2 release files

This release

0.4.0 This release

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.5

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page