Buildings.Utilities.IO.Python36
Package to call Python functions
Information
This package contains blocks and functions that embed Python 3.6 in Modelica. Data can be sent to Python functions and received from Python functions. This allows for example data analysis in Python as part of a Modelica model, or data exchange as part of a hardware-in-the-loop simulation in which Python is used to communicate with hardware.
See Buildings.Utilities.IO.Python36.UsersGuide for instruction.
Extends from Modelica.Icons.VariantsPackage (Icon for package containing variants).
Package Content
Name | Description |
---|---|
UsersGuide | User's Guide |
Real_Real | Block that exchanges a vector of real values with a Python function |
Functions | Package with functions that call Python |
Examples | Collection of models that illustrate model use and test models |
Buildings.Utilities.IO.Python36.Real_Real
Block that exchanges a vector of real values with a Python function
Information
Block that exchanges data with a Python function that does not need to pass an object from one call to the next.
For each element in the input vector uR[nDblWri]
,
the value of the flag flaDblWri[nDblWri]
determines whether
the current value, the average over the sampling interval or the integral
over the sampling interval is sent to Python. The following three options are allowed:
flaDblWri[i] | Value sent to Python |
0 | Current value of uR[i] |
1 | Average value of uR[i] over the sampling interval |
2 | Integral of uR[i] over the sampling interval |
If the function needs to pass an object from one invocation to the
next, set passPythonObject = true
.
Otherwise, leave it at its default value passPythonObject = false
.
Extends from Modelica.Blocks.Interfaces.DiscreteBlock (Base class of discrete control blocks).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Time | samplePeriod | Sample period of component [s] | |
Time | startTime | 0 | First sample time instant [s] |
String | moduleName | Name of the python module that contains the function | |
String | functionName | moduleName | Name of the python function |
Integer | nDblWri | Number of double values to write to Python | |
Integer | nDblRea | Number of double values to be read from the Python | |
Integer | flag | 0 | Flag for double values (0: use current value, 1: use average over interval, 2: use integral over interval) |
Boolean | passPythonObject | false | Set to true if the Python function returns and receives an object, see User's Guide |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | uR[nDblWri] | Real inputs to be sent to Python |
output RealOutput | yR[nDblRea] | Real outputs received from Python |