Main Content

This example shows how you can obtain a Linear Parameter Varying (LPV) approximation of a Simscape™ Electrical™ model of a Boost Converter. The LPV representation allows quick analysis of average behavior at various operating conditions.

A Boost Converter circuit converts a DC voltage to another DC voltage by controlled chopping or switching of the source voltage. The request for a certain load voltage is translated into a corresponding requirement for the transistor duty cycle. The duty cycle modulation is typically several orders of magnitude slower than the switching frequency. The net effect is attainment of an average voltage with relatively small ripples. See Figure 1 for a zoomed-in view of this dynamics.

**Figure 1:** Converter output (load) voltage generation

In practice there are also disturbances in the source voltage and the resistive load affecting the actual load voltage .

Open the Simulink model.

```
mdl = 'BoostConverterExampleModel';
open_system(mdl);
```

**Figure 2:** Simscape Electrical based Boost Converter model

The circuit in the model is characterized by high frequency switching. The model uses a sample time of 25 ns. The "Boost Converter" block used in the model is a variant subsystem that implements 3 different versions of the converter dynamics. Double click on the block to view these variants and their implementations. The model takes the duty cycle value as its only input and produces three outputs - the inductor current, the load current and the load voltage.

The model simulates slowly (when looking for changes in say 0 - 10 ms) owing to the high frequency switching elements and small sample time.

In many applications, the average voltage delivered in response to a certain duty cycle profile is of interest. Such behavior is studied at time scales several decades larger than the fundamental sample time of the circuit. These "average models" for the circuit are derived by analytical considerations based on averaging of power dynamics over certain time periods. The model `BoostConverterExampleModel`

implements such an average model of the circuit as its first variant, called "AVG Voltage Model". This variant typically executes faster than the "Low Level Model" variant.

The average model is not a linear system. It shows nonlinear dependence on the duty cycle and the load variations. To aid faster simulation and voltage stabilizing controller design, we can linearize the model at various duty cycle and load values. The inputs and outputs of the linear system would be the same as those of the original model.

We use the snapshot time based trimming and linearization approach. The scheduling parameters are the duty cycle value (d) and the resistive load value (R). The model is trimmed at various values of the scheduling parameters resulting in a grid of linear models. For this example, we chose a span of 10%-60% for the duty cycle variation and of 4-15 Ohms for the load variation. 5 values in these ranges are picked for each scheduling variable and linearization obtained at all possible combinations of their values.

Scheduling parameters: d: duty cycle R: resistive load

nD = 5; nR = 5; dspace = linspace(0.1,0.6,nD); % nD values of "d" in 10%-60% range Rspace = linspace(4,15,nR); % nR values of "R" in 4-15 Ohms range [dgrid,Rgrid] = ndgrid(dspace,Rspace); % all possible combinations of "d" and "R" values

Create a parameter structure array.

params(1).Name = 'd'; params(1).Value = dgrid; params(2).Name = 'R'; params(2).Value = Rgrid;

A simulation of the model under various conditions shows that the model's outputs settle down to their steady state values before 0.01 s. Hence we use t = 0.01s as the snapshot time.

Declare number of model inputs, outputs and states.

ny = 3; nu = 1; nx = 2; ArraySize = size(dgrid);

Compute equilibrium operating points using `findop`

. The code takes several minutes to finish.

op = findop(mdl, 0.01, params);

Get linearization input-output specified in the model.

io = getlinio(mdl);

Linearize the model at the operating point array `op`

and store the offsets.

[linsys, ~, info] = linearize(mdl, op, io, params, ... linearizeOptions('StoreOffsets', true));

Extract offsets from the linearization results.

offsets = getOffsetsForLPV(info); yoff = offsets.y; xoff = offsets.x; uoff = offsets.u;

Plot the linear system array.

```
bodemag(linsys)
grid on
```

**Figure 3:** Bode plot of linear system array obtained over the scheduling parameter grid.

`linsys`

is an array of 25 linear state-space models, each containing 1 input, 3 outputs and 2 states. The models are discrete-time with sample time of 25 ns. The bode plot shows significant variation in dynamics over the grid of scheduling parameters. The linear system array and the accompanying offset data (`uoff`

, `yoff`

and `xoff`

) can be used to configure the LPV system block. The "LPV model" thus obtained serves as a linear system array approximation of the average dynamics. The LPV block configuration is available in the `BoostConverterLPVModel`

model.

```
lpvmdl = 'BoostConverterLPVModel';
open_system(lpvmdl);
```

**Figure 4:** LPV model configured using linsys.

For simulating the model, we use an input profile for duty cycle that roughly covers its scheduling range. We also vary the resistive load to simulate the case of load disturbances.

Generate simulation data.

t = linspace(0,.05,1e3)'; din = 0.25*sin(2*pi*t*100)+0.25; din(500:end) = din(500:end)+.1; % the duty cycle profile rin = linspace(4,12,length(t))'; rin(500:end) = rin(500:end)+3; rin(100:200) = 6.6; % the load profile yyaxis left plot(t,din) xlabel('Time (s)') ylabel('Duty Cycle') yyaxis right plot(t,rin) ylabel('Resistive Load (Ohm)') title('Scheduling Parameter Profiles for Simulation')

**Figure 5:** Scheduling parameter profiles chosen for simulation.

*Note: the code for generating the above signals has been added to the model's PreLoadFcn callback for independent loading and execution. If you want to override these settings and try your own, overwrite this data in base workspace.*

Simulate the LPV model.

sim(lpvmdl, 'StopTime', '0.004');

**Figure 6:** LPV simulation results.

The LPV model simulates significantly faster than the original model `BoostConverterExampleModel`

. But how do the results compare against those obtained from the original boost converter model? To check this, open model `BoostConverterResponseComparison`

. This model has Boost Converter block configured to use the high-fidelity "Low Level Model" variant. It also contains the LPV block whose outputs are superimposed over the outputs of the boost converter in the three scopes.

linsysd = c2d(linsys,Ts*1e4); mdl = 'BoostConverterResponseComparison'; open_system(mdl); %sim(mdl); % uncomment to run

**Figure 7:** Model used for comparing the response of high fidelity model with the LPV approximation of its average behavior.

The simulation command has been commented out; uncomment it to run. The results are shown in the scope snapshots inserted below.

**Figure 8:** Inductor current signals. Blue: original, Magenta: LPV system response

**Figure 9:** Load current signals. Blue: original, Magenta: LPV system response

**Figure 10:** Load voltage signal. Blue: original, Magenta: LPV system response

The simulation runs quite slowly due to the fast switching dynamics in the original boost converter circuit. The results show that the LPV model is able to capture the average behavior nicely.

By using the duty cycle input and the resistive load as scheduling parameters, we were able to obtain linear approximations of average model behavior in the form of a state-space model array.

The resulting model array together with operating point related offset data was used to create an LPV approximation of the nonlinear average behavior. Simulation studies show that the LPV model is able to emulate the average behavior of a high-fidelity Simscape Electrical model with good accuracy. The LPV model also consumes less memory and simulates significantly faster than the original system.