SimPowerSystems    

Customizing Your Nonlinear Model

Up to now, you have used a nonlinear model with fixed parameters. If you plan to use this block in other circuits with different parameters (for example, an inductance with a different voltage rating or a saturation characteristic defined with more than two segments), you will find it more convenient to enter the block parameters in a dialog box, rather than modifying individual blocks of your subsystem.

In the following section, you learn how to use the Simulink masking facility to create a dialog box, an icon, and documentation for your model. For more details, refer to the Using Simulink guide.

Block Initialization

Select the Nonlinear Inductance subsystem and in the Edit menu, select Mask subsystem. The Mask Editor window appears.

Select the Initialization tab. In the Mask type field, enter

The parameters that you have to specify are the nominal voltage, the inductance in the linear region, and the flux-current characteristic (flux and current vectors in p.u.).

Click Add. In the Prompt field, enter

In the Variable field, enter the variable name associated with that field.

Repeat the preceding steps to define the dialog boxes and associated variables listed below.

In the Initialization commands section, enter the following MATLAB commands. This code prepares the two vectors Current_vect and Flux_vect to be used in the Look-Up Table block of the model.

As the saturation characteristic is specified only in the first quadrant, three lines of code are added to complete the negative part of the saturation characteristic. Notice also how the validity of the first segment of the saturation characteristic is verified. This segment must be defined by two points [0 0; 1 1] specifying a 1 p.u. inductance (nominal value) for the first segment.

Click the OK button to close the Mask Editor window. Double-click the icon of your masked block. Its dialog opens with all fields empty. Enter the values as shown here.

Before you can use the masked block, you must apply the two internal variables defined in the initialization section of the Look-Up Table block. Select your block and, in the Edit menu, select Look under mask.

The Nonlinear Inductance subsystem opens. Open the Look-Up Table block dialog box and enter the following variable names in the two fields:

Close the Nonlinear Inductance subsystem and start the simulation. You should get the same waveforms as shown in Figure 1-26.

Block Icon

In this section you learn how to customize your block's icon and make it more attractive.

Select your block and, in the Edit menu, select Edit mask. The Mask Editor window opens. Select the Icon tab.

In the Drawing commands section, you can specify any drawing that will appear in your block icon by using the plot function. You can, for example, plot the flux-current characteristic of your inductance.

Remember that the currents and fluxes of the nonlinear characteristic are stored respectively in the Current_vect and Flux_vect internal variables of the masked block. Enter the following command in the Drawing commands section.

Click Apply and notice that the saturation characteristic is displayed on the icon. Notice also that the input and output names have disappeared.

To make them visible, in the Icon transparency pop-up menu, select Transparent. Click OK to close the Mask Editor window.

Block Documentation

In this section, you add documentation to your block dialog box. Select your block and, in the Edit menu, select Edit Mask. The Mask Editor window opens.

Select the Documentation tab and enter in the Block description the text shown in the dialog box of the next figure. Then, click OK to close the Mask Editor window. The next time you double-click your block, this description appears on the dialog box of the block.


  Modeling a Nonlinear Inductance Modeling a Nonlinear Resistance