Coverage for teaser/examples/e3_export_ibpsa_models.py: 87%
15 statements
« prev ^ index » next coverage.py v7.4.4, created at 2025-04-29 16:01 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2025-04-29 16:01 +0000
1# # Example 3: Export Modelica models for IBPSA library using TEASER API
2# This module contains an example how to export buildings from a TEASER
3# project to ready-to-run simulation models for Modelica library IBPSA.
4# IBPSA focuses on free floating temperature without an ideal heater.
5# In contrast, AixLib focuses on ideal heat demand calculation, and
6# BESMod on the coupling to state-of-the-art energy systems.
7# These models should simulate in Dymola, OpenModelica and JModelica.
8# You can run this example using the [jupyter-notebook](https://mybinder.org/v2/gh/RWTH-EBC/TEASER/main?labpath=docs%2Fjupyter_notebooks)
10import teaser.examples.e1_generate_archetype as e1
11import teaser.logic.utilities as utilities
12import os
15def example_export_ibpsa():
16 """This function demonstrates the export to Modelica library IBPSA using
17 the API function of TEASER"""
19 # In e1_generate_archetype we created a Project with three archetype
20 # buildings to get this Project we rerun this example
22 prj = e1.example_generate_archetype()
24 # To make sure the export is using the desired parameters you should
25 # always set model settings in the Project.
26 # Project().used_library_calc specifies the used Modelica library
27 # Project().number_of_elements_calc sets the models order
28 # Project().merge_windows_calc specifies if thermal conduction through
29 # windows is lumped into outer walls or not.
30 # For more information on models we'd like to refer you to the docs. By
31 # default TEASER uses a weather file provided in
32 # teaser.data.input.inputdata.weatherdata. You can use your own weather
33 # file by setting Project().weather_file_path. However we will use default
34 # weather file.
36 prj.name = "ArchetypeExampleIBPSA"
37 prj.used_library_calc = 'IBPSA'
38 prj.number_of_elements_calc = 4
39 prj.merge_windows_calc = False
40 prj.weather_file_path = utilities.get_full_path(
41 os.path.join(
42 "data",
43 "input",
44 "inputdata",
45 "weatherdata",
46 "DEU_BW_Mannheim_107290_TRY2010_12_Jahr_BBSR.mos"))
48 # To make sure the parameters are calculated correctly we recommend to
49 # run calc_all_buildings() function
51 prj.calc_all_buildings()
53 # To export the ready-to-run models simply call Project.export_ibpsa().
54 # First specify the IBPSA related library you want to export the models
55 # for. The models are identical in each library, but IBPSA Modelica
56 # library is just a core set of models and should not be used
57 # standalone. Valid values are 'AixLib' (default), 'Buildings',
58 # 'BuildingSystems' and 'IDEAS'. We chose AixLib
59 # You can specify the path, where the model files should be saved.
60 # None means, that the default path in your home directory
61 # will be used. If you only want to export one specific building, you can
62 # pass over the internal_id of that building and only this model will be
63 # exported. In this case we want to export all buildings to our home
64 # directory, thus we are passing over None for both parameters.
66 prj.export_ibpsa(
67 library='AixLib',
68 internal_id=None,
69 path=None)
72if __name__ == '__main__':
74 example_export_ibpsa()
76 print("Example 3: That's it! :)")