Dynamic Systems Examples - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Science and Engineering : Dynamic Systems : examples/DynamicSystems

Dynamic Systems Examples

The DynamicSystems package is a collection of procedures for creating, manipulating, simulating, and plotting linear systems models.

Getting Started

While any command in the package can be referred to using the long form, for example, DynamicSystems, it is often easier to load the package and then use the short form command names.

restart;

with(DynamicSystems):

System Object Creation

Assign a differential system with derivatives in the input.

deq := 3*(diff(y(t), t, t))-2*y(t) = u(t)+diff(u(t), t):

sys1 := DiffEquation(deq, u, y):

Using the MagnitudePlot command, the magnitude of the response vs. frequency can be plotted, adding circles at selected frequencies. This is done by generating and combining two plots.

plots[display](MagnitudePlot(sys1), MagnitudePlot(sys1, frequencies = [.1, 1, 10], style = point, symbolsize = 20, symbol = circle));

Options

Parameters Option

All system constructors, such as TransferFunction and DiffEquation, accept a parameters option that consists of a list of equations specifying the parameter names and corresponding values. These parameters are used by procedures that require numeric values, for example, the plot routines. Most procedures that require numeric systems also provide a parameters option that can override the parameters assigned to the system.

sys2 := TransferFunction( A/(s+omega), parameters = [A=1, omega=2]):

MagnitudePlot(sys2);

Here, the parameters option of the plot procedure overrides the parameter A in the object:

MagnitudePlot(sys2, parameters=[A=100]);

StateSpace Options

The StateSpace constructor accepts options, such as randomtest and genbound, which are useful for generating random stable state-space systems.

ss1 := StateSpace('randomtest','numstates'=3,'numinputs'=2,'numoutputs'=1, 'genbound'=5.):

PrintSystem(ss1);

State Spacecontinuous1 output(s); 2 input(s); 3 state(s)inputvariable=u1t,u2toutputvariable=y1tstatevariable=x1t,x2t,x3ta=4.4249316456570244.0245959500059053.73013183706493920.468815192049838467.6764075377459054.0579193707561922.2150178113295164.1337585613901935.85276313606821b=3.002804688888002004.70592781760615608−0.146243512771587980−3.423869183224517174.571669482429456374.64888535199276554c=4.15735525189067090−0.782387173737250308−3.58113661372784664d=4.594924263929030422.92207329559554374

(1)

The StateSpace constructor also accepts the usesymbols keyword option, which can be used to construct state matrices with symbolic elements.

ss2 := StateSpace('numstates'=3,'numinputs'=2,'numoutputs'=1,'usesymbols'):

PrintSystem(ss2);

State Spacecontinuous1 output(s); 2 input(s); 3 state(s)inputvariable=u1t,u2toutputvariable=y1tstatevariable=x1t,x2t,x3ta=a1,1a1,2a1,3a2,1a2,2a2,3a3,1a3,2a3,3b=b1,1b1,2b2,1b2,2b3,1b3,2c=c1,1c1,2c1,3d=d1,1d1,2

(2)

System Conversion

The ToContinuous command converts discrete systems to continuous systems using a specified conversion method.

sysd := TransferFunction(1/(z+a),discrete,parameters=[a=3]):

sysc1 := ToContinuous(sysd, method=forward):

PrintSystem(sysc1);

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=1s+1+a

(3)

sysc2 := ToContinuous(sysd, method=prewarp):

PrintSystem(sysc2);

Transfer Functioncontinuous1 output(s); 1 input(s)inputvariable=u1soutputvariable=y1stf1,1=s2.ass2.a2.

(4)

The Resample command resamples a discrete system with a new sampling time.

sysd2 := Resample(sysd, 2, method=prewarp):

PrintSystem(sysd2);

Transfer Functiondiscrete; sampletime = 21 output(s); 1 input(s)inputvariable=u1zoutputvariable=y1ztf1,1=z+3az+3z+3a+1

(5)

Plotting

A Nichols plot is useful for quickly estimating the closed-loop response of system with unity-feedback, given its open-loop transfer function. For example, let the open-loop transfer function be:

G := 1/(s*(s+1)*((1/2)*s+1)):

By default a Nichols plot includes constant-phase and constant-magnitude contour plots of a closed-loop system.  From the graph below, the peak closed-loop response is about 5 dB, at 0.8 rad/s, because that is the highest constant-magnitude contour that it touches (estimating).

NicholsPlot(TransferFunction(G), gainrange = -20 .. 20, frequencies = [.8]);

Here we plot the actual closed-loop response and confirm that the maximum gain is approximately 5 dB, at 0.8 rad/s.

CL := TransferFunction(G/(1+G)):

MagnitudePlot(CL, range = .1 .. 10);

System Analysis

The NormH2 and NormHinf commands compute each respective norm of a system.

sys3 := TransferFunction(1/(s+1)^2):

NormH2(sys3);

0.500000000000000

(6)

NormHinf(sys3);

1.000001000

(7)

The Covariance command computes the output covariance Matrix with the inputs driven by white Gaussian noise.

Covariance(sys3,<<1>>);

0.250000000000000

(8)

System Manipulation

sys4 := StateSpace(usesymbols, numstates=2, numinputs=1, numoutputs=1, symbols=[A1,B1,C1,D1]):

PrintSystem(sys4);

State Spacecontinuous1 output(s); 1 input(s); 2 state(s)inputvariable&equals;u1toutputvariable&equals;y1tstatevariable&equals;x1t&comma;x2ta&equals;A11,1A11,2A12,1A12,2b&equals;B11,1B12,1c&equals;C11,1C11,2d&equals;D11,1

(9)

sys5 := StateSpace(usesymbols, numstates=2, numinputs=1, numoutputs=1, symbols=[A2,B2,C2,D2]):

PrintSystem(sys5);

State Spacecontinuous1 output(s); 1 input(s); 2 state(s)inputvariable&equals;u1toutputvariable&equals;y1tstatevariable&equals;x1t&comma;x2ta&equals;A21,1A21,2A22,1A22,2b&equals;B21,1B22,1c&equals;C21,1C21,2d&equals;D21,1

(10)

The SeriesConnect command creates the equivalent system representation of two or more system objects connected in series.

sys_series := SeriesConnect([sys4,sys5]):

PrintSystem(sys_series);

State Spacecontinuous1 output(s); 1 input(s); 4 state(s)inputvariable&equals;u1toutputvariable&equals;y1tstatevariable&equals;x1t&comma;x2t&comma;x3t&comma;x4ta&equals;A11,1A11,200A12,1A12,200B21,1C11,1B21,1C11,2A21,1A21,2B22,1C11,1B22,1C11,2A22,1A22,2b&equals;B11,1B12,1B21,1D11,1B22,1D11,1c&equals;D21,1C11,1D21,1C11,2C21,1C21,2d&equals;D21,1D11,1

(11)

The ParallelConnect command creates the equivalent system representation of two or more system objects connected in parallel.

sys_parallel := ParallelConnect([sys4,sys5]):

PrintSystem(sys_parallel);

State Spacecontinuous1 output(s); 1 input(s); 4 state(s)inputvariable&equals;u1toutputvariable&equals;y1tstatevariable&equals;x1t&comma;x2t&comma;x3t&comma;x4ta&equals;A11,1A11,200A12,1A12,20000A21,1A21,200A22,1A22,2b&equals;B11,1B12,1B21,1B22,1c&equals;C11,1C11,2C21,1C21,2d&equals;D11,1+D21,1

(12)

See Also

DynamicSystems


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam