modelSimpleRoom
Extends from Modelica.Icons.Example (Icon for runnable examples).
Information
This example demonstrates the implementation of a simple room model
that is implemented in the Python module Resources/Python-Sources/SimpleRoom.py.
The Python model computes a first-order response to the room model.
It returns the current room air temperature and the energy consumed during the simulation.
The Python module also passes an object from one call to the next. This object
contains the past room temperature, energy and time when the function was called,
stored as a Python dictionary.
This illustrates how Python data structures can be passed between function calls,
thereby enabling for example to call some (memory-intensive) machine learning program,
implemented in Python, from a Modelica block that may then pass the output of this program
to a controller.
Note that this example is for demonstration only. An implementation in Modelica would be much simpler and computationally more efficient.
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Buildings.Utilities.Time.ModelTime | modTim | Model time | |
| Python_3_8.Real_Real | pyt | Python interface | |
| Modelica.Blocks.Sources.Constant | T0 | Initial temperature | |
| Modelica.Blocks.Routing.Multiplex4 | mul | Multiplex | |
| Controls.OBC.CDL.Conversions.BooleanToReal | onOff | On off control | |
| Modelica.Blocks.Sources.Sine | TAmb | Ambient temperature | |
| Buildings.Controls.OBC.CDL.Reals.Subtract | sub1 | Inputs different | |
| Buildings.Controls.OBC.CDL.Reals.Hysteresis | onOffCon | On/off control |
Revisions
-
December 11, 2023, by Jianjun Hu:
Reimplemented on-off control to avoid using the obsoleteOnOffController. This is for #3595. -
August 27, 2021, by Michael Wetter:
Updated to Python 3.8. -
April 10, 2020, by Jianjun Hu and Michael Wetter:
Updated to Python 3.6. -
January 31, 2018, by Michael Wetter and Thierry Nouidui:
First implementation.