Skip to content

A python package for dynamic modeling and simulation of buildings. The framework builds upon the SAREF ontology and data-driven component models.

License

Notifications You must be signed in to change notification settings

JBjoernskov/Twin4Build

Repository files navigation

twin4build: A python package for Data-driven and Ontology-based modeling and simulation of buildings

twin4build is a python package which aims to provide a flexible and automated framework for dynamic modelling of indoor climate and energy consumption in buildings. It leverages the SAREF core ontology and its extensions SAREF4BLDG and SAREF4SYST.

Its core features include:

  • Automated generation of building energy models from semantic models (support for .rdf files is coming soon)
  • Automated calibration of building energy models using data-driven methods

This is a work-in-progress library and the functionality is therefore updated regularly. More information on the use of the package, code examples, and detailed documentation is planned for the fall 2024.

Examples and Tutorials

Below are some examples of how to use the package. More examples are coming soon.

Basics of Twin4Build

  • Open In Colab Part 1: Connecting components and simulating a model
  • Open In Colab Part 2: Modeling and control of indoor CO2 concentration

Automated Model Generation

To be added soon.

Model calibration

To be added soon.

Scenario testing

To be added soon.

Performance monitoring

To be added soon.

Documentation

The documentation can be found online. Below is a code snippet showing the basic functionality of the package.

import twin4build as tb
import twin4build.utils.plot.plot as plot

def fcn(self):
    ##############################################################
    ################## First, define components ##################
    ##############################################################

    #Define a schedule for the damper position
    position_schedule = tb.ScheduleSystem(
            weekDayRulesetDict = {
                "ruleset_default_value": 0,
                "ruleset_start_minute": [0,0,0,0,0,0,0],
                "ruleset_end_minute": [0,0,0,0,0,0,0],
                "ruleset_start_hour": [6,7,8,12,14,16,18],
                "ruleset_end_hour": [7,8,12,14,16,18,22],
                "ruleset_value": [0,0.1,1,0,0,0.5,0.7]}, #35
            add_noise=False,
            saveSimulationResult = self.saveSimulationResult,
            id="Position schedule")

    # Define damper component
    damper = tb.DamperSystem(
        nominalAirFlowRate = Measurement(hasValue=1.6),
        a=5,
        saveSimulationResult=self.saveSimulationResult,
        id="Damper")

    #################################################################
    ################## Add connections to the model #################
    #################################################################
    self.add_connection(position_schedule, damper, 
                        "scheduleValue", "damperPosition")


model = tb.Model(id="example_model", saveSimulationResult=True)
model.load(infer_connections=False, fcn=fcn)

# Create a simulator instance
simulator = tb.Simulator()

# Simulate the model
stepSize = 600 #Seconds
startTime = datetime.datetime(year=2021, month=1, day=10, hour=0, minute=0, second=0)
endTime = datetime.datetime(year=2021, month=1, day=12, hour=0, minute=0, second=0)
simulator.simulate(model,
                    stepSize=stepSize,
                    startTime=startTime,
                    endTime=endTime)

plot.plot_damper(model, simulator, "Damper", show=False) #Set show=True to plot

Installation

Python version Windows Ubuntu
3.8 windows-python3.8 ubuntu-python3.8
3.9 windows-python3.9 ubuntu-python3.9
3.10 windows-python3.10 ubuntu-python3.10
3.11 windows-python3.11 ubuntu-python3.11

The package can be installed with pip and git using one of the above python versions:

pip install git+https://github.com/JBjoernskov/Twin4Build

Graphviz

Graphviz must be installed separately:

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},
}

About

A python package for dynamic modeling and simulation of buildings. The framework builds upon the SAREF ontology and data-driven component models.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published