Twin4Build
Dynamic simulation of buildings with differentiable data-driven models and integration with semantic models for developing Digital Twins for buildings.
https://github.com/jbjoernskov/twin4build
Category: Energy Systems
Sub Category: Building Energy Monitoring
Keywords
building-energy-model building-simulation data-driven digital-twin ontology
Last synced: about 20 hours ago
JSON representation
Repository metadata
Dynamic simulation of buildings with differentiable data-driven models and integration with semantic models.
- Host: GitHub
- URL: https://github.com/jbjoernskov/twin4build
- Owner: JBjoernskov
- License: mit
- Created: 2022-04-09T20:56:01.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-02-23T10:50:59.000Z (about 1 month ago)
- Last Synced: 2026-03-26T17:32:09.809Z (12 days ago)
- Topics: building-energy-model, building-simulation, data-driven, digital-twin, ontology
- Language: Python
- Homepage: https://twin4build.readthedocs.io/
- Size: 728 MB
- Stars: 24
- Watchers: 1
- Forks: 9
- Open Issues: 5
- Releases: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
README.md
twin4build: A python package for Data-driven and Ontology-based modeling and simulation of buildings
Dynamic modeling and simulation of buildings, featuring fully differentiable models for parameter estimation and optimal control. Supports integration of semantic models for automatic model generation and fast implementation.
Core Classes and Functionality
Twin4Build provides several top-level classes for building, simulating, translating, calibrating, and optimizing building energy models:
-
Model:
The main container for your building system, components, and their connections. Use this class to assemble your digital twin from reusable components. -
Simulator:
Runs time-based simulations of your Model, producing time series outputs for all components. Handles the simulation loop and time stepping. -
Translator:
Automatically generates a Model from a semantic model (ontology-based building description) and maintains a link between these. Enables ontology-driven, automated model creation. -
Estimator:
Performs parameter estimation (calibration) for your Model using measured data. Supports both least-squares and PyTorch-based optimization. -
Optimizer:
Optimizes building operation by adjusting setpoints or control variables to minimize objectives or satisfy constraints, using gradient-based methods.
All classes are accessible via the main package import:
import twin4build as tb
A typical workflow would look like this:
Examples and Tutorials
Below are some examples of how to use the package.
More examples are coming soon.
Basics of Twin4Build
Translator
Estimator
Optimizer
Documentation
The documentation can be found online.
Below is a code snippet showing the basic functionality of the package.
import twin4build as tb
# Create a model
model = tb.Model(id="example_model")
# Define components
damper = tb.DamperTorchSystem(id="damper")
space = tb.BuildingSpaceTorchSystem(id="space")
# Add connections to the model
model.add_connection(damper, space,
"airFlowRate", "supplyAirFlowRate")
# Load the model
model.load()
# Create a simulator instance
simulator = tb.Simulator(model)
# Simulate the model
step_size = 600 #Seconds
start_time = datetime.datetime(year=2025, month=1, day=10, hour=0, minute=0, second=0) # Optionally set the timezone
end_time = datetime.datetime(year=2025, month=1, day=12, hour=0, minute=0, second=0) # Optionally set the timezone
simulator.simulate(step_size=step_size,
start_time=start_time,
end_time=end_time)
# Plot the results
plot.plot_component(simulator,
components_1axis=[("Damper", "airFlowRate")],
components_2axis=[("Damper", "damperPosition")],
ylabel_1axis="Air flow rate", #Optional
ylabel_2axis="Damper position", #Optional
show=True,
nticks=11)
Installation
The package is installed with pip:
pip install twin4build
The following python versions are supported:
| Python version | Windows | Ubuntu |
|---|---|---|
| 3.9 | ||
| 3.10 | ||
| 3.11 | ||
| 3.12 |
Graphviz (recomended)
To utilize the graph-drawing capabilities of twin4build, the drawing engine Graphviz must be installed.
It can be installed by downloading the install-file from the official website or by using your favorite package manager:
Ubuntu
sudo add-apt-repository universe
sudo apt update
sudo apt install graphviz
Windows
On windows, the winget or choco package managers can be used:
winget install graphviz
choco install graphviz
MacOS
brew install graphviz
Publications
Cite as
@article{OntologyBasedBuildingModelingFramework,
title = {An ontology-based innovative energy modeling framework for scalable and adaptable building digital twins},
journal = {Energy and Buildings},
volume = {292},
pages = {113146},
year = {2023},
issn = {0378-7788},
doi = {https://doi.org/10.1016/j.enbuild.2023.113146},
url = {https://www.sciencedirect.com/science/article/pii/S0378778823003766},
author = {Jakob Bjørnskov and Muhyiddine Jradi},
keywords = {Digital twin, Data-driven, Building energy model, Building simulation, Ontology, SAREF},
}
Owner metadata
- Name: Jakob Bjørnskov
- Login: JBjoernskov
- Email:
- Kind: user
- Description:
- Website:
- Location:
- Twitter:
- Company: Center for Energy Informatics, University of Southern Denmark
- Icon url: https://avatars.githubusercontent.com/u/74002963?v=4
- Repositories: 1
- Last ynced at: 2023-03-05T16:34:59.078Z
- Profile URL: https://github.com/JBjoernskov
GitHub Events
Total
- Release event: 2
- Delete event: 5
- Pull request event: 6
- Fork event: 1
- Issues event: 22
- Watch event: 7
- Issue comment event: 8
- Push event: 148
- Create event: 5
Last Year
- Release event: 2
- Delete event: 3
- Pull request event: 2
- Issues event: 21
- Watch event: 3
- Issue comment event: 7
- Push event: 74
- Create event: 2
Committers metadata
Last synced: 4 days ago
Total Commits: 1,162
Total Committers: 7
Avg Commits per committer: 166.0
Development Distribution Score (DDS): 0.158
Commits in past year: 104
Committers in past year: 2
Avg Commits per committer in past year: 52.0
Development Distribution Score (DDS) in past year: 0.01
| Name | Commits | |
|---|---|---|
| Jakob Bjørnskov | j****v@m****m | 978 |
| SebsCubs | a****c@u****o | 83 |
| Avneet | a****t@i****m | 77 |
| AugustMST | a****0@s****k | 9 |
| Wiszniewski.Grzegorz GPI | G****I@k****k | 6 |
| anshumannec | a****i@i****m | 5 |
| Avneet | 3****d | 4 |
Committer domains:
- india.nec.com: 2
- kmd.dk: 1
- student.sdu.dk: 1
- unal.edu.co: 1
- me.com: 1
Issue and Pull Request metadata
Last synced: 12 days ago
Total issues: 13
Total pull requests: 92
Average time to close issues: 5 months
Average time to close pull requests: 3 days
Total issue authors: 2
Total pull request authors: 5
Average comments per issue: 0.92
Average comments per pull request: 0.2
Merged pull request: 73
Bot issues: 0
Bot pull requests: 0
Past year issues: 4
Past year pull requests: 1
Past year average time to close issues: 2 months
Past year average time to close pull requests: 24 days
Past year issue authors: 2
Past year pull request authors: 1
Past year average comments per issue: 1.0
Past year average comments per pull request: 0.0
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- JBjoernskov (10)
- SebsCubs (3)
Top Pull Request Authors
- avneet006 (45)
- SebsCubs (33)
- AugustMST (11)
- gpikmddk (2)
- JBjoernskov (1)
Top Issue Labels
- enhancement (10)
- documentation (1)
- bug (1)
Top Pull Request Labels
- enhancement (22)
- bug (11)
- documentation (3)
- duplicate (1)
Package metadata
- Total packages: 1
-
Total downloads:
- pypi: 22 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 4
- Total maintainers: 1
pypi.org: twin4build
Dynamic simulation of buildings and integration with semantic modeling.
- Homepage:
- Documentation: https://twin4build.readthedocs.io/
- Licenses: MIT
- Latest release: 1.1.2 (published 5 months ago)
- Last Synced: 2026-04-03T20:01:26.214Z (4 days ago)
- Versions: 4
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 22 Last month
-
Rankings:
- Dependent packages count: 8.725%
- Average: 28.947%
- Dependent repos count: 49.168%
- Maintainers (1)
Dependencies
- FMPy ==0.3.16 development
- OMPython ==3.4.0 development
- Requests ==2.31.0 development
- SQLAlchemy ==2.0.21 development
- arviz ==0.12.1 development
- bayesian_optimization ==1.4.3 development
- corner ==2.2.2 development
- emcee ==3.1.4 development
- fastapi ==0.103.1 development
- ipython ==8.15.0 development
- keycloak ==3.1.3 development
- matplotlib ==3.7.2 development
- memory_profiler ==0.61.0 development
- networkx ==3.1 development
- numpy ==1.22.4 development
- onnxruntime ==1.15.1 development
- pandas ==2.0.3 development
- ptemcee ==1.0.0 development
- pwlf ==2.2.1 development
- pydot ==1.4.2 development
- pymc ==5.7.2 development
- pymcmcstat ==1.9.1 development
- pytensor ==2.14.2 development
- pytz ==2023.3 development
- scipy ==1.7.3 development
- seaborn ==0.12.2 development
- setuptools ==68.0.0 development
- tqdm ==4.66.1 development
- uvicorn ==0.23.2 development
- fastapi *
- fmpy *
- matplotlib *
- networkx *
- onnx *
- onnxruntime *
- openpyxl *
- pandas *
- pwlf *
- pydot *
- pymc *
- pytensor *
- requests *
- scipy *
- seaborn *
- torch *
- tqdm *
Score: 8.448700194970938