Assembling systems


A collection of ssm arrays can be assembled into one ssm using the assemble function.

Managing inputs/outputs when assembling

The order of the systems does not modify the output of the assembly process. The assemble method works by matching inputs and outputs of the same name. Of course, they must have the same dimensionality and same time-step. However, the check for units is not implemented yet.

In terms of time-step it is important to assemble all continuously linked models together when the system is continuous, and discretize it later on. Time discrete models (typically digital systems, and the dynamical branch from the actuator input to the sensor output) should be assembled together when they are time-discrete. The discretization includes a zero hold which models correctly the A/D filter behavior.

Moreover, a system can be assembled in multiple steps. In this case there is a risk of “closing a loop” multiple times. To avoid this, the method assemble suppresses the inputs once they are assembled. May the user need the input for a simulation later on, he must duplicate it using the function inputDuplicate. Built-in models should also have built-in duplicated inputs to insert signals.

Example using an existing built-in models

sys = ssm(plist('built-in', 'SMD', 'PARAM NAMES', {'SMD_W'}, 'PARAM VALUES', 0.2*i));

The system can be made time discrete using the function ssm/modifyTimeStep. The input is then duplicated to be used for a controller feedback.

sys = ssm(plist('built-in', 'SMD', 'PARAM NAMES', {'SMD_W', 'SMD_C'}, 'PARAM VALUES', [-0.2 -0.5]));
sys.modifyTimeStep(0.01);
sys.duplicateInput('U', 'Negative Bias')
------ ssm/1 -------
      amats: {  [2x2]  }  [1x1]
      mmats: {  [2x2]  }  [1x1]
      bmats: {  [2x1]   [2x2]   [2x1]  }  [1x3]
      cmats: {  [1x2]  }  [1x1]
      dmats: {   []     [1x2]    []    }  [1x3]
   timestep: 0.01
     inputs:  [1x3 ssmblock]
         1 : U | Fu [kg m s^(-2)]
         2 : N | Fn [kg m s^(-2)], On [m]
         3 : Negative Bias | Fu [kg m s^(-2)]
     states:  [1x1 ssmblock]
         1 : standard test system | x [m], xdot [m s^(-1)]
    outputs:  [1x1 ssmblock]
         1 : Y | y [m]
     params: (empty-plist) [1x1 plist]
    version: $Id$-->$Id$
    Ninputs: 3
 inputsizes: [1 2 1]
   Noutputs: 1
outputsizes: 1
    Nstates: 1
 statesizes: 2
    Nparams: 0
isnumerical: true
       hist: ssm.hist [1x1 history]
   procinfo: (empty-plist) [1x1 plist]
   plotinfo: (empty-plist) [1x1 plist]
       name: standard_system_params
description: standard spring-mass-dashpot test system
    mdlfile: 
       UUID: 284b0ae3-947d-430a-802e-d9c3738ebb14
--------------------
M: running isStable
ans =
          2.05114794494015
warning, system named "standard_system_params" is not stable
ans =
     0

Then a controller can be created to make the system stable.

>> controller = ssm(plist( ...
   'amats',cell(0,0), 'bmats',cell(0,1), 'cmats',cell(1,0), 'dmats',{-1}, ...
   'timestep',0.01, 'name','controller', 'params',plist, ...
   'statenames',{}, 'inputnames',{'Y'}, 'outputnames',{'U'} ));
>> sysCL = assemble(sys, controller);
>> sysCL.isStable

------ ssm/1 -------
      amats: {  [2x2]  }  [1x1]
      mmats: {  [2x2]  }  [1x1]
      bmats: {  [2x2]   [2x1]  }  [1x2]
      cmats: {  [1x2]   
                [1x2]  }  [2x1]
      dmats: {  [1x2]    []     
                [1x2]    []    }  [2x2]
   timestep: 0.01
     inputs:  [1x2 ssmblock]
         1 : N | Fn [kg m s^(-2)], On [m]
         2 : Negative Bias | Fu [kg m s^(-2)]
     states:  [1x1 ssmblock]
         1 : standard test system | x [m], xdot [m s^(-1)]
    outputs:  [1x2 ssmblock]
         1 : Y | y [m]
         2 : U | U > 1 []
     params: (empty-plist) [1x1 plist]
    version: $Id$
    Ninputs: 2
 inputsizes: [2 1]
   Noutputs: 2
outputsizes: [1 1]
    Nstates: 1
 statesizes: 2
    Nparams: 0
isnumerical: true
       hist: ssm.hist [1x1 history]
   procinfo: (empty-plist) [1x1 plist]
   plotinfo: (empty-plist) [1x1 plist]
       name: assembled( standard_system_params + controller))
description: 
    mdlfile: 
       UUID: c6f7397e-add7-4f4c-8eb0-fd0a4841e3cf
--------------------
M: running isStable
System named "assembled( standard_system_params + controller))" is stable
ans =
     1

We can then use the system to produce a simulation.





©LTP Team