TZ-OSeMOSYS
A TransitionZero implementation of the OSeMOSYS systems model.
https://github.com/transition-zero/tz-osemosys
Category: Energy Systems
Sub Category: Energy System Modeling Frameworks
Keywords from Contributors
energy-model
Last synced: about 23 hours ago
JSON representation
Repository metadata
TZ-OSeMOSYS - a TransitionZero implementation of the OSeMOSYS systems model
- Host: GitHub
- URL: https://github.com/transition-zero/tz-osemosys
- Owner: transition-zero
- License: agpl-3.0
- Created: 2023-10-26T09:07:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-11-13T10:26:58.000Z (about 1 month ago)
- Last Synced: 2025-11-30T15:09:17.280Z (26 days ago)
- Language: Python
- Homepage:
- Size: 1.36 MB
- Stars: 35
- Watchers: 4
- Forks: 6
- Open Issues: 9
- Releases: 35
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE-OF-CONDUCT.md
README.md
TZ-OSeMOSYS - a modern long-run systems modelling framework
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:
- Pydantic-based model construction and validation
- Linopy-based numerical optimsation and solving
- Reverse-compatability with OSeMOSYS-otoole
Documentation
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, andrangefunctions. - 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
setdimensions and membership are also automatically inferred - a single value can be given which will be broadcast to all set member combinations. - single or multiple
.yamlfiles can be composed together, allowing you to separate, e.g.technologies.yaml, from the rest of your model. - with
cloudpathliband 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 installcloudpathliband 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.
Owner metadata
- Name: Transition Zero
- Login: transition-zero
- Email:
- Kind: organization
- Description:
- Website:
- Location: United Kingdom
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/73114765?v=4
- Repositories: 1
- Last ynced at: 2023-03-01T18:22:29.152Z
- Profile URL: https://github.com/transition-zero
GitHub Events
Total
- Create event: 38
- Issues event: 1
- Release event: 13
- Watch event: 15
- Delete event: 19
- Issue comment event: 27
- Push event: 100
- Pull request review comment event: 27
- Pull request review event: 41
- Pull request event: 40
- Fork event: 3
Last Year
- Release event: 12
- Watch event: 15
- Delete event: 16
- Issue comment event: 20
- Push event: 71
- Pull request review event: 32
- Pull request review comment event: 22
- Pull request event: 31
- Fork event: 2
- Create event: 31
Committers metadata
Last synced: 3 months ago
Total Commits: 171
Total Committers: 16
Avg Commits per committer: 10.688
Development Distribution Score (DDS): 0.673
Commits in past year: 26
Committers in past year: 6
Avg Commits per committer in past year: 4.333
Development Distribution Score (DDS) in past year: 0.538
| Name | Commits | |
|---|---|---|
| Lucas Kruitwagen | l****n@g****m | 56 |
| edwardxtg | 7****g@u****m | 36 |
| Thomas Kouroughli | t****u@i****m | 20 |
| ollie-bell | 5****l@u****m | 20 |
| Aman Majid | 3****d@u****m | 14 |
| Abhishek Shivakumar | a****r@M****x | 7 |
| Abhishek Shivakumar | a****r@M****l | 4 |
| Anca Chereches | a****c@t****g | 3 |
| Calvin Nesbitt | c****4@g****m | 3 |
| djwels | 1****s@u****m | 2 |
| Ali Cass | 5****s@u****m | 1 |
| DanWelsby | d****w@t****g | 1 |
| Joe O'Connor | 6****a@u****m | 1 |
| Noon van der Silk | n****b@g****m | 1 |
| abhishek0208 | a****8@g****m | 1 |
| edwardxtg | e****g@g****m | 1 |
Committer domains:
Issue and Pull Request metadata
Last synced: about 1 month ago
Total issues: 14
Total pull requests: 92
Average time to close issues: about 1 month
Average time to close pull requests: 5 days
Total issue authors: 8
Total pull request authors: 13
Average comments per issue: 0.29
Average comments per pull request: 0.54
Merged pull request: 59
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 23
Past year average time to close issues: N/A
Past year average time to close pull requests: 3 days
Past year issue authors: 0
Past year pull request authors: 5
Past year average comments per issue: 0
Past year average comments per pull request: 0.35
Past year merged pull request: 14
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- amanmajid (4)
- Drowsle (2)
- abhishek0208 (2)
- Lkruitwagen (2)
- joconnor-ecaa (1)
- irfanm-tz (1)
- ollie-bell (1)
- djwels (1)
Top Pull Request Authors
- edwardxtg (31)
- ollie-bell (18)
- Lkruitwagen (16)
- Tomkourou (7)
- amanmajid (4)
- djwels (4)
- abhishek0208 (3)
- ancache (2)
- Handriyanti (2)
- CalvinNesbitt (2)
- joconnor-ecaa (1)
- silky (1)
- a-cass (1)
Top Issue Labels
- bug (3)
- documentation (2)
Top Pull Request Labels
- bug (1)
- help wanted (1)
- enhancement (1)
Package metadata
- Total packages: 1
-
Total downloads:
- pypi: 481 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 29
- Total maintainers: 1
pypi.org: tz-osemosys
An OSeMOSYS implementation for the Future Energy Outlook by TransitionZero
- Homepage: https://github.com/transition-zero/tz-osemosys
- Documentation: https://tz-osemosys.readthedocs.io/
- Licenses: GNU Affero General Public License v3
- Latest release: 0.3.5 (published about 2 months ago)
- Last Synced: 2025-12-23T17:32:03.989Z (3 days ago)
- Versions: 29
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 481 Last month
-
Rankings:
- Dependent packages count: 9.707%
- Average: 36.876%
- Dependent repos count: 64.044%
- Maintainers (1)
-
Funding:
- https://transitionzero.org
Dependencies
- actions/checkout v3 composite
- actions/setup-python v3 composite
- dcarbone/install-jq-action v2.1.0 composite
- schneegans/dynamic-badges-action v1.7.0 composite
- actions/checkout v4 composite
- actions/download-artifact v3 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- pypa/gh-action-pypi-publish release/v1 composite
- sigstore/gh-action-sigstore-python v2.1.0 composite
- release-drafter/release-drafter v5 composite
- actions/checkout v4 composite
- actions/download-artifact v3 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- pypa/gh-action-pypi-publish release/v1 composite
- highspy *
- linopy *
- orjson *
- pydantic >2
- pydantic-settings *
- xarray *
Score: 12.734722470208641