BlockImporter - BlockImporter Help

Home : Support : Online Help : Toolboxes : BlockImporter : Import Tools : BlockImporter/BuildDE

BlockImporter

 BuildDE
 creates differential equations from the model

 Calling Sequence BuildDE( sys, opts )

Parameters

 sys - record; system data opts - (optional) equation(s) of the form option = value; specify options for the BuildDE command

Options

 • makesets = truefalse
 Specifies whether the equations and initialeqs fields are assigned lists or sets. The default is false.

Description

 • The BuildDE command converts the equations in a BlockImporter data structure to a form that can be solved by dsolve.
 • The sys parameter is a Maple record. See BlockImporter[datastructure] for details.
 • The output is a record with fields equations, initialeqs, known, outputvars, parameters, and sourceeqs. With a small amount of further processing, the fields of this record can be passed to dsolve. See the Examples section, below.
 – equations = (list,set)(equation) -- contains the differential equations that describe the system. Differentials of state-variables in the input equations expressed in terms of D are converted to unevaluated functions of diff with t as the independent variable. For example, D(x) is converted to diff(x(t),t). If the keyword-option makesets is true, then the field is a set, otherwise it is a list.
 – initialeqs = (list,set)(function = anything) -- defines the initial values of the state variables of the system. If the keyword-option makesets is true, then the field is a set, otherwise it is a list.
 – known = set(name) -- the names of known functions that must be passed to dsolve/numeric using the known option.
 – outputvars = list(function) -- the names of the output of the system or subsystem. These are connected to the inputs of sink blocks and Outport blocks of subsystems. These are unevaluated functions of t.
 – parameters = list(indexed = anything) -- specifies the values of subsystem mask and MATLAB® global parameters used in equations. The left side of each equation consists of an indexed name K[num,str], where num is the block identifier of the subsystem in which parameter was defined (0 if the parameter is a MATLAB® global), and str is a string corresponding to the parameter name. The right side of the equation is the value of the name. It may be expressed in terms of other block parameters.
 – sourceeqs = list(function = algebraic) -- equations that define the time-behavior of sources. The left side is an unevaluated function of t. The right side is the definition of the source.

Examples

 > $\mathrm{with}\left(\mathrm{BlockImporter}\right):$

Create an example of an imported data structure.

 > $\mathrm{sys}≔\mathrm{BlockImporter}:-\mathrm{Example}\left(\right)$
 ${\mathrm{sys}}{:=}{\mathrm{record}}{}\left({\mathrm{equations}}{,}{\mathrm{initialeqs}}{,}{\mathrm{inputvars}}{,}{\mathrm{notes}}{,}{\mathrm{outputvars}}{,}{\mathrm{parameters}}{,}{\mathrm{procs}}{,}{\mathrm{sourceeqs}}{,}{\mathrm{statevars}}\right)$ (1)

Convert the imported data structure into a record with differential equations that are compatible with dsolve,numeric.

 > $\mathrm{deq}≔\mathrm{BuildDE}\left(\mathrm{sys},\mathrm{makesets}\right)$
 ${\mathrm{deq}}{:=}{\mathrm{record}}{}\left({\mathrm{equations}}{,}{\mathrm{initialeqs}}{,}{\mathrm{known}}{,}{\mathrm{outputvars}}{,}{\mathrm{parameters}}{,}{\mathrm{sourceeqs}}\right)$ (2)

Substitute the values of the source equations and parameters into the equations. Substitute the differential equations into the output variables.

 > $\mathbf{use}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{deq}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{deqs}≔\mathrm{subs}\left(\mathrm{sourceeqs},\mathrm{parameters},\mathrm{equations}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}∪\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{initialeqs};\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{outs}≔\mathrm{subs}\left(\mathrm{deqs},\mathrm{outputvars}\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{ins}≔\mathrm{map}\left(\mathrm{rhs},\mathrm{sourceeqs}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end use}:$

Solve the differential equations.

 > $\mathrm{dsol}≔\mathrm{dsolve}\left(\mathrm{deqs},'\mathrm{numeric}',\mathrm{interr}=\mathrm{false}\right)$
 ${\mathrm{dsol}}{:=}{\mathbf{proc}}\left({\mathrm{x_rkf45_dae}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (3)

Plot the results.

 > $\mathrm{plots}[\mathrm{odeplot}]\left(\mathrm{dsol},\left[\left[t,{\mathrm{outs}}_{1}\right],\left[t,{\mathrm{ins}}_{1}\right]\right],0..10,\mathrm{gridlines}=\mathrm{true}\right)$