搜档网
当前位置:搜档网 › digsilent学习资料

digsilent学习资料

MATLAB interface

The example “Matlab Example” described below shows how a Matlab Simulink model can be interfaced to DIgSILENT Power Factory.

1. Installation

The complete example contains three files.

1.Matlab Example.dz is a PowerFactory file.

Start PowerFactory, import this file and activate the project.

2.VCOtype16.m is a Matlab M-file.

This file is an interface between Matlab and PowerFactory. Ensure that it is saved in directory included in the Matlab path.

3.vcotype16mod.mdl is a Simulink model and contains the Simulink implementation of VCO

type 16. Ensure that it is saved in directory included in the Matlab path.

After activating the project you will find the VCO_16_Matlab inside of the PowerFactory Library folder. The only thing the user has to change is the definition of the path to the Matlab M-File VCOtype16.m.

Matlab and Simulink have to be installed.

After that the example is ready to start the demonstration.

2. Matlab Example

The grid contains two generators, one load and one line. A simulation event is defined for the load (increasing the reactive power after 0.5 second). The example has two study cases:

1.Built-in

2.Matlab

In the base study case (Built-in), both composite models use the IEEE-frame and the built-in AVR. The generators have different VCO parameters set.

The built-in VCO type 16 in PowerFactory is an excitation control system with simplified exciter.

The plots resulting from the simulation show busbar voltages and excitation voltage for both generators. The results are stored in result files located under the “Results” folder of the relevant study case.

In the second study case (Matlab), which is a modification of the base case, VCO type 16 is modeled in Simulink. A Matlab console is started automatically when running the simulation. The results are plotted on top of the results obtained with the built-in model; it is clear that the two alternative models give the same results.

In the second case the composite model uses a Matlab AVR frame

The parameters for each of the generators are defined inside of the DSL element. Time constants and other data are the same as for the built-in VCO models.

VCO type 16 modeled inside Simulink:

3. M-file

The m-file VCOtype16.m is an interface configuration for the Simulink model (vcotype16mod.mdl).

Used functions and variables:

function [t, x, y] = VCOtype16

global u Tvm usetp upss Vska Tisp Ur1mx Ur1mn Vsex Efdmx Efdmn x1 x2

options = simget('VCOtype16_model');

options = simset('InitialState', [x1,x2]);

[t, x, y] = sim('VCOtype16_model', [], options);

PowerFactory inserts into Matlab workspace the global variables listed above. Those variables are necessary to successfully run the Simulink model. There are three input signals (u, usetp, upss), one output signal (uerrs) and two state variables (x1, x2). In each step of the PowerFactory simulation (0.01 second) the Simulink model is completely evaluated. State variables (‘InitialState’) are assigned to Simulink model in each step of the simulation. For PowerFactory it is a simple function call: [t, x, y] = VCOtype16.

PowerFactory uses only one Simulink model for both generators. To avoid limitation of Simulink which allows only one instance of the model running at the same time, PowerFactory must send all parameters in the each step of the simulation.

To find appropriate equations for the initial conditions you need to understand the construction of the transfer function blocks in Simulink. To obtain this understanding you can replace the variables with actual numbers in the Matlab Simulink model, set the initial conditions, run it for a few seconds and monitor the outputs of all transfer functions to see whether the model initialized correctly.

The Matlab Simulink model (.mdl) and the interface file (.m) file may not have the same name.

The order of the state variables in the interface file’s statement “options = simset('InitialState', [x1, x2, …….])” is important; the order of the elements in the vector [x1, x2, …] must be the same as in the state variable vector constructed internally by Matlab. To determine the order of the Matlab state variable vector the user may use the command “[sizes,x0,xstring]= ModelName” in the Matlab workspace, where ModelName is the name of the Simulink model (without the .mdl extension and without inverted commas). The output of the string variable xstring contains the names of the dynamic blocks in the Simulink model in the desired order. In the case of the above example the first state variable is in the measurement block and the second state variable is in the integrator:

xstring =

'VCOtype16_model/Measure/State Space'

'VCOtype16_model/Integrator'

The names of the variables in the ‘Initial conditions’ fields in the masks of the Simulink model dynamic blocks is irrelevant.

The initial conditions are set within Power Factory. Also, for the purpose of Power Factory’s model checking mechanisms, the state derivatives equal to zero

The Simulink solver parameters are set to integrate over one small time step, e.g. start time = 0, end time = 0.01, and step size = 0.01.

相关主题