 DynamicSystems - Maple Programming Help

Home : Support : Online Help : Science and Engineering : Dynamic Systems : Simulation Tools : DynamicSystems/Simulate

DynamicSystems

 Simulate
 simulate a system

 Calling Sequence Simulate( sys, input, opts )

Parameters

 sys - System; system object input - algebraic, list(algebraic), Vector(realcons), list(Vector(realcons)), or Matrix(realcons); input signal opts - (optional) equation(s) of the form option = value; specify options for the Simulate command

Options

 • initialconditions = Vector( realcons ) or list( equation ):

Specifies the initial conditions of the system. For a state-space system the initial condition is specified as a Vector, while for the differential equation system, the initial conditions is a list of equations. The discrete difference equation is first converted to a transfer function representation and then to state-space representation, and as a result any initial conditions specified are ignored. The transfer function, coefficients, and zero-pole-gain systems ignore the initial conditions. If omitted, the zero initial conditions are used.

 • parameters = set(name = complexcons) or list(name = complexcons)
 Specifies numeric values for parameters in sys. These values override those specified by the parameters field of the system object, which in turn override the settings in in SystemOptions(parameters). The numeric value on the right-hand side of each equation is substituted for the name on the left-hand side in the expressions that define the model. No checking is done during the substitution to determine whether the substituted value is valid. For example, a complex value can be substituted for the coefficient of a polynomial. If the complex value had been originally assigned to the model at creation, a warning would be generated.

Continuous System Options

The following options apply to continuous systems.

 • output = solution, de, statevariable, outputvariable or a list of same

Specifies the content of the output. The following describes the output for each of the possible values. Multiple values can be selected by enclosing them in a list. Each element in the returned list/sequence (see returnlist, below) corresponds to the selected value.

 – solution: dsolve solution procedure; the default
 – de: system of diff-equations
 – outputvariable: list of the output-variables
 – statevariable: list of the state-variables
 – dsolveargs: additional arguments passed to dsolve; includes the value of the option dsolveargs (see below).
 • dsolveargs = list( equation )

Specifies additional parameters to be passed to dsolve. For typical values, see dsolve,numeric.

 • returnlist = truefalse
 True means return a list; false means return an expression sequence. The default is false.

Description

 • The Simulate command computes the transient response of sys, a linear system object, to input, a given input waveform. Both continuous and discrete systems can be simulated.

Continuous Systems

 • Continuous systems are simulated using dsolve[numeric]. The system is converted to a set of differential equations and initial conditions that are passed to dsolve.
 • Systems of type transfer function, coefficient, or zero-pole-gain are converted to a state-space representation that is then converted to a set of differential-equations.
 • If the variable names for the states are not given (transfer function, coefficient, and zero-pole-gain) then the value of statevariable from DynamicSystems[SystemOptions] is used with a numerical index appended.
 • A state-space system is converted to a set of differential equations.
 • A diff-equation system is used as is.
 • The input waveform, input, is given in terms of t, the time variable. For a single input system input is an algebraic expression, for a multiple-input system input is a list of algebraic expressions.  Heaviside functions in the input are converted to equivalent event-based steps.
 • By default the output is a dsolve procedure that takes the value of t as the input parameter.

Discrete Systems

 • A discrete system is simulated by converting it to a state-space representation and then iterating through the state-space equations.
 • If the variable names for the states are not given (transfer function, coefficient, and zero-pole-gain) then the value of statevariable from DynamicSystems[SystemOptions] is used with a numerical index appended.
 • The input waveform, input, consists of discrete values. For a single input system it is a Vector or a one-column Matrix. For a multiple input system it is a list of Vectors or a Matrix; the number of Vectors (columns of the Matrix) corresponds to the number of inputs of sys.
 • The output is a list of Vectors. Each Vector corresponds to an output of the system. The dimension of the Vectors match the dimension of the input Vector.
 • The calculation can be performed either as a hardware floating-point or software floating-point.  The environment variable UseHardwareFloats determines which floating-point representation is used.

Examples

 > $\mathrm{with}\left(\mathrm{DynamicSystems}\right):$
 > $\mathrm{ts}≔0.1$
 ${\mathrm{ts}}{≔}{0.1}$ (1)
 > $\mathrm{t_sim}≔10.0$
 ${\mathrm{t_sim}}{≔}{10.0}$ (2)
 > $\mathrm{in_t}≔\mathrm{Sine}\left(1,1,0,0\right)$
 ${\mathrm{in_t}}{≔}\left\{\begin{array}{cc}{0}& {t}{<}{0}\\ {\mathrm{sin}}{}\left({t}\right)& {\mathrm{otherwise}}\end{array}\right\$ (3)
 > $\mathrm{in_z}≔\mathrm{Sine}\left(1,1,0,0,\mathrm{samplecount}=\mathrm{round}\left(\frac{\mathrm{t_sim}}{\mathrm{ts}}\right),\mathrm{sampletime}=\mathrm{ts},\mathrm{discrete}\right)$
  (4)
 > $\mathrm{sys}≔\mathrm{DiffEquation}\left(\left[0.5\left(\frac{ⅆ}{ⅆt}i\left(t\right)\right)+i\left(t\right)=v\left(t\right)-0.01\left(\frac{ⅆ}{ⅆt}\mathrm{θ}\left(t\right)\right),0.01\left(\frac{ⅆ}{ⅆt}\left(\frac{ⅆ}{ⅆt}\mathrm{θ}\left(t\right)\right)\right)+0.1\left(\frac{ⅆ}{ⅆt}\mathrm{θ}\left(t\right)\right)=0.01i\left(t\right)\right],\mathrm{inputvariable}=\left[v\left(t\right)\right],\mathrm{outputvariable}=\left[\mathrm{θ}\left(t\right),i\left(t\right)\right]\right)$
 ${\mathrm{sys}}{≔}\left[\begin{array}{c}{\mathbf{Diff. Equation}}\\ {\mathrm{continuous}}\\ {\mathrm{2 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{v}{}\left({t}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{\theta }}{}\left({t}\right){,}{i}{}\left({t}\right)\right]\end{array}\right$ (5)
 > $\mathrm{sysz}≔\mathrm{ToDiscrete}\left(\mathrm{sys},\mathrm{ts}\right)$
 ${\mathrm{sysz}}{≔}\left[\begin{array}{c}{\mathbf{Diff. Equation}}\\ {\mathrm{discrete; sampletime = .1}}\\ {\mathrm{2 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{v}{}\left({q}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{\theta }}{}\left({q}\right){,}{i}{}\left({q}\right)\right]\end{array}\right$ (6)
 > $\mathrm{sol}≔\mathrm{Simulate}\left(\mathrm{sys},\left[\mathrm{in_t}\right]\right)$
 ${\mathrm{sol}}{:=}{\mathbf{proc}}\left({\mathrm{x_rkf45}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{...}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (7)
 > $\mathrm{p1}≔{\mathrm{plots}}_{\mathrm{odeplot}}\left(\mathrm{sol},\left[\left[t,\mathrm{θ}\left(t\right)\right]\right],t=0..\mathrm{t_sim},\mathrm{numpoints}=200,\mathrm{color}=\mathrm{red}\right):$
 > $\mathrm{ret}≔\mathrm{Simulate}\left(\mathrm{sysz},\left[\mathrm{in_z}\right]\right)$
  (8)
 > $\mathrm{out_z}≔{\mathrm{ret}}_{1}$
  (9)
 > $\mathrm{p2}≔\mathrm{DiscretePlot}\left(\mathrm{out_z},0,\mathrm{ts},\mathrm{style}=\mathrm{stair},\mathrm{color}=\mathrm{blue}\right):$
 > ${\mathrm{plots}}_{\mathrm{display}}\left(\mathrm{p1},\mathrm{p2}\right)$ > $\mathrm{sys2}≔\mathrm{TransferFunction}\left(\frac{1}{{s}^{2}+s+10}\right)$
 ${\mathrm{sys2}}{≔}\left[\begin{array}{c}{\mathbf{Transfer Function}}\\ {\mathrm{continuous}}\\ {\mathrm{1 output\left(s\right); 1 input\left(s\right)}}\\ {\mathrm{inputvariable}}{=}\left[{\mathrm{u1}}{}\left({s}\right)\right]\\ {\mathrm{outputvariable}}{=}\left[{\mathrm{y1}}{}\left({s}\right)\right]\end{array}\right$ (10)
 > $\mathrm{ret}≔\mathrm{Simulate}\left(\mathrm{sys2},\left[\mathrm{in_t}\right],'\mathrm{output}'=\left['\mathrm{solution}','\mathrm{de}','\mathrm{statevariable}','\mathrm{outputvariable}'\right]\right):$
 > $\mathrm{sol}≔{\mathrm{ret}}_{1}:$
 > $\mathrm{de_list}≔{\mathrm{ret}}_{2}:$
 > $\mathrm{state_v}≔{\mathrm{ret}}_{3}:$
 > $\mathrm{output_v}≔{\mathrm{ret}}_{4}:$
 > $\mathrm{sol}\left(0.1\right)$
 $\left[{t}{=}{0.1}{,}{\mathrm{x1}}{}\left({t}\right){=}{0.000161695975336734}{,}{\mathrm{x2}}{}\left({t}\right){=}{0.00479344012872838}{,}{\mathrm{y1}}{}\left({t}\right){=}{0.000161695975336734}\right]$ (11)
 > $\mathrm{de_list}$
 $\left[\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{x1}}{}\left({t}\right){=}{\mathrm{x2}}{}\left({t}\right){,}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{x2}}{}\left({t}\right){=}{-}{10.}{}{\mathrm{x1}}{}\left({t}\right){-}{1.}{}{\mathrm{x2}}{}\left({t}\right){+}\left(\left\{\begin{array}{cc}{0}& {t}{<}{0}\\ {\mathrm{sin}}{}\left({t}\right)& {\mathrm{otherwise}}\end{array}\right\\right){,}{\mathrm{y1}}{}\left({t}\right){=}{1.}{}{\mathrm{x1}}{}\left({t}\right){,}{\mathrm{x1}}{}\left({0}\right){=}{0}{,}{\mathrm{x2}}{}\left({0}\right){=}{0}\right]$ (12)
 > $\mathrm{state_v}$
 $\left[{\mathrm{x1}}{}\left({t}\right){,}{\mathrm{x2}}{}\left({t}\right)\right]$ (13)
 > $\mathrm{output_v}$
 $\left[{\mathrm{y1}}{}\left({t}\right)\right]$ (14)
 > ${\mathrm{plots}}_{\mathrm{odeplot}}\left(\mathrm{sol},\left[\mathrm{seq}\left(\left[t,i\right],i=\mathrm{state_v}\right)\right],t=0..10,\mathrm{title}="system states"\right)$ > ${\mathrm{plots}}_{\mathrm{odeplot}}\left(\mathrm{sol},\left[\mathrm{seq}\left(\left[t,i\right],i=\mathrm{output_v}\right)\right],t=0..10,\mathrm{title}="system output"\right)$ 