Main Content

Vary Parameter Values and Obtain Multiple Transfer Functions

This example shows how to use theslLinearizerinterface to batch linearize a Simulink® model. You vary model parameter values and obtain multiple open-loop and closed-loop transfer functions from the model.

You can perform the same analysis using thelinearizefunction. However, when you want to obtain multiple open-loop and closed-loop transfer functions, especially for models that are expensive to compile repeatedly,slLinearizercan be more efficient.

Since the parameter variations in this example do not affect the operating point of the model, you batch linearize the model at a single operating point. If your application uses parameter variations that affect the model operating point, first trim the model for each parameter value combination. For an example that uses thelinearizefunction, seeBatch Linearize Model at Multiple Operating Points Derived from Parameter Variations.

CreateslLinearizerInterface for Model

Thescdcascademodel used for this example contains a pair of cascaded feedback control loops. Each loop includes a PI controller. The plant models,G1(outer loop) andG2(inner loop), are LTI models.

Use theslLinearizerinterface to analyze the inner-loop and outer-loop dynamics.

Open the model.

mdl ='scdcascade'; open_system(mdl)

Use theslLinearizerfunction to create the interface.

sllin = slLinearizer(mdl)
slLinearizer linearization interface for "scdcascade": No analysis points. Use the addPoint command to add new points. No permanent openings. Use the addOpening command to add new permanent openings. Properties with dot notation get/set access: Parameters : [] OperatingPoints : [] (model initial condition will be used.) BlockSubstitutions : [] Options : [1x1 linearize.LinearizeOptions]

命令窗口显示显示信息theslLinearizerinterface. In this interface, no parameters to vary are yet specified, so theParamaetersproperty is empty.

Vary Inner-Loop Controller Gains

For inner-loop analysis, vary the gains of the inner-loop PI controller block, C2. Vary the proportional gain (Kp2) and integral gain (Ki2) in the 15% range.

Kp2_range = linspace(Kp2*0.85,Kp2*1.15,6); Ki2_range = linspace(Ki2*0.85,Ki2*1.15,4); [Kp2_grid, Ki2_grid] = ndgrid(Kp2_range,Ki2_range); params(1).Name ='Kp2'; params(1).Value = Kp2_grid; params(2).Name ='Ki2'; params(2).Value = Ki2_grid; sllin.Parameters = params;

Kp2_rangeandKi2_rangespecify the sample values forKp2andKi2. To obtain a transfer function for each combination ofKp2andKi2, usendgridand create a 6 x 4 parameter grid with grid arraysKp2_gridandKi2_grid. Configure theParametersproperty ofsllinwith the structureparams. This structure specifies the parameters to be varied and their grid arrays.

Analyze Closed-Loop Transfer Function for the Inner Loop

The overall closed-loop transfer function for the inner loop is equal to the transfer function fromu1toy2. To eliminate the effects of the outer loop, you can break the loop ate1,y1m, ory1. For this example, break the loop ate1.

Addu1andy2as analysis points, ande1as a permanent opening ofsllin.

addPoint(sllin,{'y2','u1'}); addOpening(sllin,'e1');

Obtain the transfer function fromu1toy2.

r2yi = getIOTransfer(sllin,'u1','y2');

r2yi, a 6 x 4 state-space model array, contains the transfer function for each specified parameter combination. The software uses the model initial conditions as the linearization operating point.

Becausee1is a permanent opening ofsllin,r2yidoes not include the effects of the outer loop.

Plot the step response forr2yi.

stepplot(r2yi);

所有模型的阶跃响应变化的10%range and the settling time is less than 1.5 seconds.

Analyze Inner-Loop Transfer Function at the Plant Output

Obtain the inner-loop transfer function aty2, with the outer loop open ate1.

Li = getLoopTransfer(sllin,'y2',-1);

Because the software assumes positive feedback by default andscdcascadeuses negative feedback, specify the feedback sign using the third input argument. Now,$L_{i} = -G_{2}C_{2}$. ThegetLoopTransfercommand returns an array of state-space (ss) models, one for each entry in the parameter grid. TheSamplingGridproperty ofLimatches the parameter values with the correspondingssmodel.

Plot the bode response for$L_{i}$.

bodeplot(Li)

The magnitude plot for all the models varies in the 3-dB range. The phase plot shows the most variation, approximately 20°, in the[1 10]rad/s interval.

Vary Outer-Loop Controller Gains

For outer-loop analysis, vary the gains of the outer-loop PI controller block, C1. Vary the proportional gain (Kp1) and integral gain (Ki1) in the 20% range.

Kp1_range = linspace(Kp1*0.8,Kp1*1.2,6); Ki1_range = linspace(Ki1*0.8,Ki1*1.2,4); [Kp1_grid, Ki1_grid] = ndgrid(Kp1_range,Ki1_range); params(1).Name ='Kp1'; params(1).Value = Kp1_grid; params(2).Name ='Ki1'; params(2).Value = Ki1_grid; sllin.Parameters = params;

Similar to the workflow for configuring the parameter grid for inner-loop analysis, create the structure,params, that specifies a 6 x 4 parameter grid. Reconfiguresllin.Parametersto use the new parameter grid.sllinnow uses the default values forKp2andKi2.

Analyze Closed-Loop Transfer Function from Reference to Plant Output

Removee1from the list of permanent openings forsllinbefore proceeding with outer-loop analysis.

removeOpening(sllin,'e1');

To obtain the closed-loop transfer function from the reference signal,r, to the plant output,y1m, addrandy1mas analysis points tosllin.

addPoint(sllin,{'r','y1m'});

Obtain the transfer function fromrtoy1m.

r2yo = getIOTransfer(sllin,'r','y1m');

Plot the step response forr2yo.

stepplot(r2yo)

The step response is underdamped for all the models.

Analyze Outer-Loop Sensitivity at Plant Output

To obtain the outer-loop sensitivity at the plant output, addy1as an analysis point tosllin.

addPoint(sllin,'y1');

Obtain the outer-loop sensitivity aty1.

So = getSensitivity(sllin,'y1');

Plot the step response ofSo.

stepplot(So)

The plot indicates that it takes approximately 15 seconds to reject a step disturbance at the plant output,y1.

Obtain Linearization Offsets

When batch linearizing for parameter variations, you can obtain the linearization offsets that correspond to the linearization operating points. To do so, set theStoreOffsetslinearization option in theslLinearizerinterface.

sllin.Options.StoreOffsets = true;

When you call a linearization function usingsllin, you can return linearization offsets in theinfostructure.

[r2yi,info] = getIOTransfer(sllin,'u1','y2');

You can then use the offsets to configure an LPV System block. To do so, you must first convert the offsets to the required format. For an example that uses thelinearizecommand, seeLPV Approximation of Boost Converter Model.

offsets = getOffsetsForLPV(info);

Close the model.

bdclose(mdl)

See Also

|||||||

Related Topics