]>
tutorial14
In this tutorial we introduce the external functions concept that can handle and execute
functions in external libraries. The daeScalarExternalFunction-derived external function
object is used to calculate the heat transferred and to interpolate a set of values
using the scipy.interpolate.interp1d object.
In this example we use the same model as in the tutorial 5 with few additional equations.
The simulation output should show the following messages at the end of simulation:
.. code-block:: none
...
scipy.interp1d statistics:
interp1d called 1703 times (cache value used 770 times)
The plot of the 'Heat_ext' variable:
.. image:: _static/tutorial14-results.png
:width: 500px
The plot of the 'Value_interp' variable:
.. image:: _static/tutorial14-results2.png
:width: 500px
$\mathit{tutorial14}$
Heat
$\mathit{Heat}$
$${ { Heat } - \left( { \left( { { m } \cdot { c_p } } \right) \cdot \left( { { \partial { { \left( { T } \right) } } } \over { \partial { t } } } \right) } \right) } = 0$$
$${ { tutorial14.Heat } - \left( { \left( { { tutorial14.m } \cdot { tutorial14.c_p } } \right) \cdot { { \partial { { tutorial14.T } } } \over { \partial { t } } } } \right) } = 0$$
False
Heat_ext
${\mathit{Heat}}_{\mathit{ext}}$
$${ { Heat_ext } - \left( { Heat \left( cp = { { c_p } } , dT = { { { \partial { { \left( { T } \right) } } } \over { \partial { t } } } } , m = { { m } } \right) } \right) } = 0$$
$${ { tutorial14.Heat_ext } - \left( { Heat \left( cp = { { tutorial14.c_p } } , dT = { { { \partial { { \left( { tutorial14.T } \right) } } } \over { \partial { t } } } } , m = { { tutorial14.m } } \right) } \right) } = 0$$
False
Value
$\mathit{Value}$
$${ { Value } - \left( { {2 {}} \cdot \left( { {\tau} } \right) } \right) } = 0$$
$${ { tutorial14.Value } - \left( { {2 {}} \cdot \left( { {\tau} } \right) } \right) } = 0$$
True
Value_interp
${\mathit{Value}}_{\mathit{interp}}$
$${ { Value_interp } - \left( { interp1d \left( t = { { {\tau} } } \right) } \right) } = 0$$
$${ { tutorial14.Value_interp } - \left( { interp1d \left( t = { { {\tau} } } \right) } \right) } = 0$$
False
Regulator
$\mathit{Regulator}$
eSTN
Heating
$\mathit{Heating}$
Q_in
The heater is on
${\mathit{Q}}_{\mathit{in}}$
$${ { Q_in } - {1500 {{W}}}} = 0$$
$${ { tutorial14.Q_in } - {1500 {{W}}}} = 0$$
True
OnConditionActions_0
${\mathit{OnConditionActions}}_{\mathit{0}}$
$\mathit{T}>340\mathit{K}$
actionChangeState_Cooling
${\mathit{actionChangeState}}_{\mathit{Cooling}}$
eChangeState
$\mathit{Regulator}$
Regulator
$\mathit{Regulator}.\mathit{Cooling}$
Regulator.Cooling
OnConditionActions_1
${\mathit{OnConditionActions}}_{\mathit{1}}$
$\mathit{\tau}>350\mathit{s}$
actionChangeState_HeaterOff
${\mathit{actionChangeState}}_{\mathit{HeaterOff}}$
eChangeState
$\mathit{Regulator}$
Regulator
$\mathit{Regulator}.\mathit{HeaterOff}$
Regulator.HeaterOff
$\mathit{Regulator}$
Regulator
Cooling
$\mathit{Cooling}$
Q_in
The heater is off
${\mathit{Q}}_{\mathit{in}}$
$${ Q_in } = 0$$
$${ tutorial14.Q_in } = 0$$
True
OnConditionActions_0
${\mathit{OnConditionActions}}_{\mathit{0}}$
$\mathit{T}<320\mathit{K}$
actionChangeState_Heating
${\mathit{actionChangeState}}_{\mathit{Heating}}$
eChangeState
$\mathit{Regulator}$
Regulator
$\mathit{Regulator}.\mathit{Heating}$
Regulator.Heating
OnConditionActions_1
${\mathit{OnConditionActions}}_{\mathit{1}}$
$\mathit{\tau}>350\mathit{s}$
actionChangeState_HeaterOff
${\mathit{actionChangeState}}_{\mathit{HeaterOff}}$
eChangeState
$\mathit{Regulator}$
Regulator
$\mathit{Regulator}.\mathit{HeaterOff}$
Regulator.HeaterOff
$\mathit{Regulator}$
Regulator
HeaterOff
$\mathit{HeaterOff}$
Q_in
The heater is off
${\mathit{Q}}_{\mathit{in}}$
$${ Q_in } = 0$$
$${ tutorial14.Q_in } = 0$$
True
$\mathit{Regulator}$
Regulator