dq0 dynamics|software manual · dq0 dynamics|software manual yoash levron and ... this approach is...

45
DQ0 Dynamics—Software Manual Yoash Levron and Juri Belikov June 4, 2017 The software website can be found at: http://a-lab.ee/projects/dq0-dynamics 1

Upload: tranmien

Post on 02-Jul-2018

232 views

Category:

Documents


1 download

TRANSCRIPT

DQ0 Dynamics—Software Manual

Yoash Levron and Juri Belikov

June 4, 2017

The software website can be found at:http://a-lab.ee/projects/dq0-dynamics

1

Contents

1 The basics 3

What this tool does . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

When to use this tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Contact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 How to cite this work 5

3 How this software operates 6

4 License 8

5 Installing the software 9

6 Graphical user interface 10

6.1 Getting to know the environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

6.2 Library cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

6.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

6.3 Design Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

7 Tutorial 17

7.1 Designing the network using the Graphical-User-Interface . . . . . . . . . . . . . . . . . . . . 17

7.2 Processing the network data in Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

7.3 Time-domain simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

7.4 Small-signal model and Frequency-domain analysis . . . . . . . . . . . . . . . . . . . . . . . . 25

8 Overview of main functions 27

9 Examples 33

10 Mathematical background 35

10.1 The dq0 transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

10.2 Synchronous machine models and the unified reference frame . . . . . . . . . . . . . . . . . . 35

10.3 Modeling transmission networks in the frequency domain . . . . . . . . . . . . . . . . . . . . 38

10.4 Models of single passive components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

10.5 Modeling transmission networks in state-space . . . . . . . . . . . . . . . . . . . . . . . . . . 41

10.6 Small-signal models of units and feedback connection . . . . . . . . . . . . . . . . . . . . . . . 44

2

1 The basics

New users may wish to start with the tutorial on Section 7

Welcome!

Please take a minute to understand the basics.

What this tool does

This is a free software tool for analyzing the dynamics of power systems based on dq0 signals. It is designedto simulate and analyze power systems that include several generators and loads, and possibly a largetransmission network. The software provide tools for constructing dynamic models of the system components,and enables analysis in the frequency domain or the time domain. The manual and software provide simpleexplanations and examples that can help one get started, even if he has no prior knowledge on power systemdynamics, or the dq0 transformation.

When to use this tool

Several approaches exist for modeling the dynamic behavior of three-phase power systems. Transient sim-ulations that use the abc frame of reference describe the system by means of physical quantities, and thusoffer high accuracy and flexibility. This approach is often the most general, since it applies to nonsymmetricsystems, and is valid over a wide range of frequencies. Another popular approach is to model the power sys-tem using time-varying phasors, often by using the network power flow equations. This approach has manybenefits, one of them is that the transmission network is described by means of purely algebraic equations.However, time-varying phasors are only applicable at low frequencies, under the assumption that the systemis quasi-static.

A solution that complements these two well-known approaches is to model large power systems on the basisof dq0 quantities. This approach is not as general as abc-based models, and is advantageous mainly when thenetwork and units are symmetrically configured1. However, dq0 models combine two properties of interest:similar to transient models, dq0-based models are derived from physical models, and are therefore accurateat high frequencies, so the assumption of a quasi-static network is not required. In addition, similarly totime-varying phasors, dq0 models are time-invariant. This property allows to define an operating point, andenables small-signal analysis.

transient models(nonsymmetric)

physical,

accurate

quasi-static models

time-invariant,operating point

dq0 models(symmetrically configured)

This software exploits these properties, and uses dq0-based models for:

� Simulation of complete networks. The software allows to describe the dynamics of complete powersystems that include the transmission network, generators, and loads, based on dq0 quantities.

� Transient simulations of symmetrically configured power systems. The main advantages in this caseis that AC signals are mapped to constant signals at steady-state, so a large simulation step time maybe used.

1By definition, symmetrically configured networks produce symmetric three-phase currents, if fed by symmetric three-phasevoltages. For instance, a transmission network with identical circuit in each of the three-phases is symmetrically configured.

3

� Small-signal analysis. The dq0-based models are time-invariant, and therefore allow definition of anoperating point. Primary applications are stability analysis and controller design.

� Dynamic analysis of large-scale networks. The software uses state-space models that are minimalorder and sparse, and are therefore suitable for large systems.

Note that a primary limitation of this software is that the transmission network must be symmetricallyconfigured. For instance, transient analysis of an asymmetric fault is not supported.

Contact

Any questions? please contact us athttp://yoash-levron.eew.technion.ac.il/contactus/contact-2/

4

2 How to cite this work

We kindly request that publications derived from the use of this software acknowledge this fact by citingreferences from this list:

� J. Belikov and Y. Levron, “A sparse minimal-order dynamic model of power networks based on dq0signals,” IEEE Transactions on Power Systems, 2017, to be published.

� Y. Levron and J. Belikov, “Modeling power networks using dynamic phasors in the dq0 referenceframe,” Electric Power Systems Research, 144, pp. 233–242, Mar. 2017.

� Y. Levron and J. Belikov, “Open-source software for modeling and analysis of power networks in thedq0 reference frame,” in IEEE PES PowerTech Conference, to be published, Manchester, UK, Jun.2017.

� J. Belikov and Y. Levron, “Comparison of time-varying phasor and dq0 dynamic models for largetransmission networks,” International Journal of Electrical Power & Energy Systems, 93, pp. 65–74,Dec. 2017.

� Y. Levron and J. Belikov, “Reduction of power system dynamic models using sparse representations,”IEEE Transactions on Power Systems, 2017, to be published.

5

3 How this software operates

The software describes power systems by means of signal-flow diagrams, in which each component is modeledby dq0 quantities. An example is illustrated in Figs. 1 and 2.

G1

G2

Load

13

2

Figure 1: A single-line diagram of a 3-bus system.

G2 Vdq0,2

Idq0,2

G1 Vdq0,1

Idq0,1

3-bus

Transmission

Network

ξ = Aξξ +BξVdq0Idq0 = Cξξ +DξVdq0

LoadVdq0,3

Idq0,3

Figure 2: Signal-flow diagram of a 3-bus system.

In Fig. 2 the blocks on the left are dynamic models of the generators, the block in the middle is the dynamicmodel of the transmission network, and block on the right is a dynamic model of the load. These differentcomponents are modeled as follows:

� The transmission network. Transmission networks are represented by linear state-space models withvoltage inputs and current outputs. As an example, the dynamic model of a 3-bus network is given by

ξ = Aξξ +Bξu

y = Cξξ +Dξu,

where ξ is the state vector, and the input and output vectors are

u = [vd,1, vd,2, vd,3, vq,1, vq,2, vq,3, v0,1, v0,2, v0,3]T,

y = [id,1, id,2, id,3, iq,1, iq,2, iq,3, i0,1, i0,2, i0,3]T,

in which vd,n, vq,n, v0,n are the dq0 voltages of bus n, and id,n, iq,n, i0,n are the dq0 currents injected fromthe nth unit into bus n.

The software automatically constructs the matrices Aξ, Bξ, Cξ, Dξ based on the network data. This canbe done using the graphical user interface, or directly from the Matlab command line using the functionssNetw, ssNetwSym, or ssNetwMatPower. More details can be found at Sections 8 and 10.

The resulting state-space models are of minimal order, and use sparse system matrices, and are thereforesuitable for large power systems.

� Generators (power sources). We use the term generators to specify power sources in general. Thesemay include classic synchronous machines, or renewable sources such as photovoltaic inverters or windturbines. Generators are modeled based on dq0 models available in the literature. As an example, the dq0model of a synchronous machine is detailed in Section 10.

One problem that arises when considering the classic dq0 models is that they are typically based on localreference frames, and therefore linking different models to each other is not straightforward. For instance,in synchronous machine models the dq0 transformation is typically defined in respect to the rotor angle.However, since different machines may rotate at different frequencies, these models cannot be directly

6

linked to each other, since the dq0 signals describing each machine are defined in respect to the machine’slocal angle.

We approach this problem by modeling the network and its components using a dq0 transformation thatis based on a unified reference frame, which rotates with a fixed frequency2 of ωs = 2πfs. To this end,the dq0 signals associated with each generator are converted from the local reference frame to the unifiedreference frame. In addition, the state-space model describing the transmission network is also based onthis unified reference frame. Since all models are defined in respect to the same unified reference frame, amodel of the complete power system may be constructed. Further details may be found in Section 10.

� Loads. We use the term loads to specify power consumers in general. Loads are represented by twotypes of dynamic models. Simple loads are modeled by shunt impedances, which are typically embeddedinto the transmission network. More complex loads (for instance, synchronous motors) are described bydetailed dq0-based models, similarly to generators. In this case dq0 signals associated with each load areconverted from the load’s local reference frame to the unified reference frame.

Based on these models, the user may create a complete model of the power system in Simulink, and performtransient simulations. The software also provides several functions dedicated to small-signal and stabilityanalysis. The main functions are listed in Section 8, and several examples are provided in Section 9.

2The frequency ωs is chosen as follows: if there is an infinite bus in the system, ωs is selected as the frequency of the infinitebus. If no generator is large enough to be modeled as an infinite bus, then ωs is equal to the steady-state system frequency. Inthis case dq0 signals will be constant at steady-state, and the system will have well-defined equilibrium point. Other choices ofωs are possible, but the resulting dq0 models will be time varying, and therefore will not have an equilibrium point.

7

4 License

Essentially this is an open-source software. Anyone can use and distribute it (while citing it properly), butthe authors are not responsible for any damage.

The exact terms of the license are detailed as follows:

Copyright © 2016–2017, Dr. Yoash Levron and Dr. Juri Belikov, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted providedthat the following conditions are met:

� Redistributions of source code must retain the above copyright notice, this list of conditions and thefollowing disclaimer.

� Redistributions in binary form must reproduce the above copyright notice, this list of conditions andthe following disclaimer in the documentation and/or other materials provided with the distribution.

� Neither the name of the Technion nor the names of its contributors may be used to endorse or promoteproducts derived from this software without specific prior written permission.

This software is provided by the copyright holders and contributors “as is”, and any express or impliedwarranties, including, but not limited to, the implied warranties of merchantability and fitness for a particularpurpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect,incidental, special, exemplary, or consequential damages (including, but not limited to, procurement ofsubstitute goods or services; loss of use, data, or profits; or business Interruption) however caused and onany theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arisingin any way out of the use of this software, even if advised of the possibility of such damage.

Please note that the GUI part of the software is licensed differently: The GUI is based on the open-sourceproject TinyCAD, which is licensed under LGPLv2.1 or LGPLv3. Also note that the GUI uses Python,which uses the GPL license, and the Python software packages Decorator and NetworkX, both distributedwith the BSD license.

8

5 Installing the software

Installation and use of this software requires familiarity with the basic operation of Matlab, including settingup your Matlab path.

System requirements

� Matlab & Simulink must be installed.

� Several examples require the MatPower add-on, which is freely available on-line at:http://www.pserc.cornell.edu/matpower/This is not needed if you are only getting started.

Basic installation—without a graphical user interface

� Download the software files from Matlab central and copy them to a directory of your choice. The filesare available at

“Toolbox for Modeling and Analysis of Power Networks in the DQ0 Reference Frame”http://www.mathworks.com/matlabcentral/fileexchange/58702

� Setup the directory in your MATLAB path. In the MATLAB, go to File >Set Path... and click onAdd with Subfolders... Now, select the directory that contains the DQ0 dynamics folder.

Note: make sure that the library is added to the Matlab path with its subfolders.

Installation with a graphical user interface

Following the basic installation, the user may install the Graphical User Interface (GUI). Most examples inthis software package do not require the GUI. However, the GUI may help new users, and is necessary forthe tutorial (in Section 7).

The GUI can be downloaded from:

https://github.com/dq0Dynamics/dq0Dynamics

There are two versions to the software, a 32-bit and a 64-bit version. Choose to install whichever suits yourhardware. Python 2.7 is required for full functionality, and is therefore integrated as part of DQ0 Dynamicsinstallation. In case the user already has Python 2.7 installed on his computer, he may choose to not reinstallit. However, the recommended and default setting is to install it.

Note for Python 3 users: Python 2.7 is required for full functionally, so please check the Python2.7 box in the installation wizard.

9

6 Graphical user interface

6.1 Getting to know the environment

The initial layout can be seen in Fig. 3.

Figure 3: Initial layout.

First let us become more familiar with the top ribbon and explain the tools at our disposal. The top ribboncan be seen in Fig. 4.

Figure 4: Top ribbon.

The top ribbon is divided into 8 sections:

1. Red frame:

a. Create new project.

b. Open existing project.

c. Save current project.

10

d. Cut, copy, paste, print functions.

2. Green frame:

a. Process Network: This is the run command to process the electrical network and run all necessaryprocesses:

� Create PCB Netlist.

� Run python engine to create dq0 matrix inputs for Matlab simulation.

b. Set work-directory for network processing: After processing your network, new files will be createdthat represent your electrical network. As a default, these files are saved to your DQ0 installationdirectory. However, it is possible to change this directory by clicking this button. Once pressed, ablack command window will prompt you to insert the path of your new working directory. Oncea valid path is inserted the working directory will be changed and the outputs of dynamics dq0will be rerouted to this location.

3. Blue frame:

a. Add label to a wire.

b. Add wire to design.

c. Add junction.

d. Add power.

e. Add no connect to wire.

4. Yellow frame:

a. Horizontal and vertical rulers.

b. Add symbol pin (not in use).

c. Symbol picker (toggle cell library panel).

d. Toggle Zoom in/out of design.

e. Delete components in design.

f. Toggle edit design.

g. Rotate or flip components of design.

5. Orange frame: Add various extras to design:

a. Text, line polygons, ellipses, rectangles, arcs.

6. Black frame: Block manipulation:

a. Drag, move, duplicate, rotate.

7. Purple frame: Bus manipulation:

a. Name, join, place.

8. Gray frame: Mouse pointer coordinates.

The red frame in Fig. 5 contains the symbol library panel. The reduced symbol library can be found hereand will be used to drag and drop components into the design.

Further information about the symbols and their properties can be found in Section 6.2. The red framein Fig. 6 marks the work area. Opening a new project or starting a new project opens a new work area.Various work areas can be opened simultaneously. However, processing the network (green frame in Fig. 4)will run on the active work area that is in the foreground. Additionally, each work area may have varioussheets open. This is advantageous when building a design with hierarchical symbols which will be explainedshortly.

The tool options window seen in Figure 8 shows the data, parameters and properties for highlighted symbols.Once a symbol is chosen, the tool options window is the most efficient way to see its data and change thevalues of its parameters.

11

Figure 5: Symbol library panel.

Figure 6: Work area.

Figure 7: Tool options window.

12

Two drop down menus that deserve a mention are the Library and Special menus, seen in Figs. 8 and 9,respectively. The library menu allows you to add additional libraries and save newly created libraries in yourdesign. Although all necessary libraries are supplied, if the need should arise for new elements in the design,this is the sure way to add them. The Special menu allows for various operations:

1. The first two, Create PCB Netlist and Check Design Rules are automatically run by the ProcessNetwork button (green frame in Fig. 4) and therefore do not require the user to run these individ-ually. However the possibility remains for users to independently check the design rules during theimplementation stages of their electrical network if they deem the step necessary.

2. ‘Generate Symbol References’ is a useful tool that will be explained in detail in the following section.

3. ‘Create Parts List’ allows users to create a file (.txt or .csv) containing the parts that are used in theirdesign for future reference.

4. The following two features are supported by Dynamics DQ0 but not by the Python parser and thereforewill not be successfully translated into dq0 coordinates. We recommend not to use them:

a. ‘Insert Another Design as a Symbol’ allows users to insert another design as a black box to be usedin their current design. This is especially useful for hierarchical networks with large subsystems.

b. ‘Add Hierarchical Symbol’ opens a new special sheet that allows the users to treat it as a blackbox in their design. If the labels on the pins of the ‘Hierarchical Symbol Sheet’ match the labelson the pins of the main sheet for the design Dynamics DQ0 will automatically connect the twowhen processing the network.

Figure 8: Library drop down menu.

6.2 Library cells

6.2.1 Overview

There are three families of cells provided for the user in the built-in symbol library.

1. Consumers (CNS): these are the end nodes of your electrical grid. The three options are generator,loads and units, see Fig. 10. The user may add properties to this type of component in the tools optionwindow. For example:

a. Parameter: ‘name’, Value: ‘my generator’.

b. Parameter: ‘Power’, Value: ‘123.456’.

13

Figure 9: Special drop down menu.

Figure 10: Library consumers.

These parameters are stored in the ‘.mat’ file (dq0 inputs) under the object unit params and arerepresented in cell arrays. Each index in the array represents the CNS in the bus with the matchingnumber (to the index). For example, unit params(3).name will contain the value of the parametername of the CNS component of bus number 3. Note that numerical numbers are stored as numbersand alphanumerical names as strings. Another point to be noted is that users should not rely on thelength of unit params to determine the number of buses. For instance, if there are five buses but noCNS units in the design, the length of unit params will be zero.

2. Branches (TWS/WS): branches connect different consumers and have a built in resistance and induc-tance in series. There are two different types of branches, one with and one without a transformer, seeFig. 11.

Figure 11: Library branches.

3. Shunts (SLD/SNT): in order to create low resistance paths, the design supports the use for shunts, seeFig. 12.

Once a symbol has been placed in the work area, the tool options window will show all of the pertinent infor-mation about the symbol as shown in Fig. 13. In this case we picked a branch symbol with no transformer.In the tool options window the user can view/modify the symbol properties:

1. The symbol orientation: this can be toggled to an up, down, left or right position with mirroringcapabilities.

2. The symbol reference name. As a design rule, symbols must have a reference name. For the user’sconvenience, the ‘Generate Symbols Reference’ (see Fig. 9), will automatically create legal netlist names

14

Figure 12: Library shunts.

Figure 13: Tool options window.

for the symbols once the design is finished. If symbols do not get assigned a reference name, the builtin Design Rule Checker will prompt the user to do so. Each single reference name must be unique.Note: When initially placed, a symbol will have a reference name in the format ‘<symbol name>?’.This is an illegal symbol name according to the Dynamics dq0 design rules and should be changed asexplained.

3. The symbol’s parameters and values. In our example, the symbol has a resistor and an inductor, usersmay change the values of these parameters for the symbol here.

6.3 Design Rules

Bus LabelsBy convention, all buses (added by using the ‘add wire to design’ button in the blue frame in Fig. 4) musthave the same numbered name ‘busX’ with ascending order, starting from ‘1’. For example, the first wireshould be called ‘bus1’, the second ‘bus2’, etc. If this convention is not maintained, the Python Engine willprompt the user to fix the names of the required wires. Note that the name must be ‘bus’.

Bus ConnectivityA bus may contain:

1. No more than one CNS symbol.

2. No more than one SNT symbol.

3. No more than one SLD symbol.

In other words, a bus (meaning a blue wire from the blue frame in Fig. 4), may connect at most to one CNS,one SLD, and one SNT.

Branches ConnectivityBetween 2 adjacent buses, there is exactly 1 component of Branch type: WS/TWS. In other words, WS/TWSare not allowed to be connected in parallel (to each other). Note, however, that a bus is allowed to be linkedto many other buses, each connected with a single Branch (WS/TWS).

Symbol ReferencesAs previously mention, when a symbol is first created, it is not assigned a reference name. Reference namescan either be individually given to each symbol or given general names by running the ‘Generate SymbolReferences’ process under the ‘Special’ drop down menu. If this process is not executed, the built in DesignRule Checker prompts the user to do so.

15

Bus NumbersEvery wire should be assigned with a bus number. To do this, use the ‘Label’ button on the top ribbon (blueframe in Fig. 4). Once we click on the wire button, the tool options window should turn into the ‘Label ToolOptions’ window. Here we can type the names of our buses. Buses must be numbered as ‘bus1’, ‘bus2’, etc.

16

7 Tutorial

In this tutorial we will learn how to design and simulate a 9-bus power system.

Note: If you have not installed the software and the GUI, please do so now (Section 5).

The tutorial is divided to four parts:

� Designing the system using the GUI.

� Processing the network data, and creating an equivalent state-space model.

� Simulating the network dynamics in the time domain using Simulink.

� Creating a small-signal model and analyzing it in the frequency domain.

7.1 Designing the network using the Graphical-User-Interface

This section explains how to construct the 9-bus network, step-by-step. If you wish to skip this section, thefinal design may be loaded from Tutorial 1 9bus.dsn, which may be found in the folder Tutorial 1.

Open the GUI software (DQ0 dynamics). The initial screen should show an empty work area. This is wherewe will build our network.

We will start with some preliminary steps. First, set the page size. To do so, select ‘File’ from the menu,and then ‘Page Setup’. Now choose a page size as you like (this has no effect on the simulation).

Next, set the current working directory (folder). Press the Library symbol (Fig. 14). When asked whetherto change the working directory answer ‘yes’, ‘y’, or just press enter. Then, specify a library of your choice.

Figure 14: Changing the current working directory

Now, choose a file name for the current design. Select ‘File’ from the menu, and then ‘Save As’. Navigateto the library you chose in the previous step, and save the design. While working, save any time by clickingCtrl+S.

We will now start building the network. Remember that at any time you may open Tutorial 1 9bus.dsn,to see the final design. The first step will be to place the network branches (transmission lines), as seenin Fig. 16. This is done by choosing, from the component library on the left, the component named ‘WS- Branch RL’. This is a basic branch that includes a resistor and an inductor in series. Click it, then click’Place Symbol’, and put the component in the main design area. Components may be rotated by clickingCtrl-R. Notice that three branches contain transformers. These can be placed by selecting the component‘TWS - Branch RLT’.

Next, set the branch parameters. Left-click on any component, and edit its ‘R’, ‘L’, and ‘Ratio(X)’ fields.The specific values are shown in Fig. 16. The units for the resistance and inductance are not specified, butin this tutorial we will assume SI units, meaning that resistances are given in Ohm units, and inductancesare given in Henry units. The units will become important later, when the network data is processed inMatlab, but currently these are just numbers. The ‘Ratio(X)’ field controls the transformer ratio, as shownin Fig. 15. The design should now look as in Fig. 16.

17

bus i bus k

Lik Rikideal

transformer

X : 1

Figure 15: Branch with transformer, resistor and inductor.

Figure 16: The design after placing the network branches.

The next step is to connect the generators. Generators and other complex units are represented by two typesof components, either ‘CNS - Generator’ or ‘CNS - Unit’. These two components are identical, except fora different graphical symbol. Typically ‘CNS - Generator’ represents physical generators, and ‘CNS - Unit’represents other types of complex units. The 9-bus network contains three generators: Generator 1 is aninfinite bus, meaning an AC voltage source with a constant frequency and amplitude. In this tutorial thismodel describes a connection to a larger network, which can provide as much power as needed. Generators2,3 are synchronous machines.

Table 1: Generator data.Type Component Parameters

Gen. 1 infinite bus CNS - Unit V = 22

Gen. 2 synchronous machine CNS - Generator P = 163

V = 22

Gen. 3 synchronous machine CNS - Generator P = 85

V = 22

Place the generators in the design area, as shown in 17. Now click on the generators, to edit their parameters,according to Table 1. For instance, in Generator 2, define a parameter named ‘P’, and set its value to 163,then define the parameter ‘V’, and set its value to 22. In this tutorial these parameters mean that thegenerator’s single-phase output power in steady-state is 163 MW, and the no-load voltage is 22 kV (RMS).Generally, parameters can have any name and any value, and their meaning is freely chosen by the user.The GUI does not process these parameters, but only sends them ‘as is’ to the Matlab environment.

After adding the generators, the design should be similar to Fig. 17.

Next we will add loads to the network. One option to represent loads is to use the component ‘CNS - Load’.This component is exactly identical to ‘CNS - Generator’ or ‘CNS - Unit’, except for its different graphical

18

Figure 17: Adding generators to the network.

symbol, and different meaning to the user. When using ‘CNS - Load’ the GUI does not process the loadparameters, but only delivers them ‘as is’ to the Matlab environment for further processing.

Another option to represent loads is by using shunt elements (elements connected to ground). This type ofmodel is simpler, since the loads are then considered an integral part of the transmission network.

We therefore continue by adding loads using shunt elements. To do so, select the component ‘SLD - ShuntLoad’, and place it in the design area. Edit the load parameters as shown in Fig. 18. In general, the unitsof resistances and inductances are arbitrary, but in this tutorial we use Ohm and Henry units.

Figure 18: Adding loads to the network.

Now select the Wire tool from the menu (Fig. 19), and connect the components to each other. The finalresult is shown in Fig. 20

Few final steps are needed to finalize the design:

� Assign symbol references. This is necessary to avoid errors when processing the network. To doso, in the menu, click ‘Special’, and then ‘Generate Symbol References’, and then ’OK’. Notice thateach component now has a unique identifier, shown in its ‘Ref’ field.

� Assign bus numbers. From the menu select the Label tool (Fig. 21), enter a bus number, for instance

19

Figure 19: The wire tool.

Figure 20: After connecting the components using the wire tool.

’bus1’, and then click the desired wire. Assign a bus number to every node. Buses must be numbered‘bus1’, ‘bus2’, etc.

Following these steps, the design should appear as in Fig. 22.

Figure 21: The Label tool.

We are now ready to process the design, and to send the data to the Matlab environment. From themenu, click the ‘Process network’ tool (Fig. 23). When running this tool for the first time, it will open atemporary Matlab command window, and this may take a few seconds. The software now checks for designrule violations, as explained in Section 6.3. If no errors are found, a file named sdq0 inputs.mat will becreated in the current working directory. After the process is complete, you may close the Matlab commandwindow, and the GUI.

7.2 Processing the network data in Matlab

This section explains how to process the network data, using Matlab. The script Tutorial 1.m containsall the commands used in this section, and may be used as a reference. This script may be found in thefolder Tutorial 1.

Our objective in this section is twofold: first, we will create a state-space model representing the dynamic

20

Figure 22: The final design, after assigning symbol references and bus numbers.

Figure 23: The ’Process network’ tool

behavior of the transmission network and loads. Second, we will import the generator parameters, and usethem to prepare data for the Simulink model.

Open Matlab. The first step is to set the current folder. This may be done directly through the Matlabenvironment, or by using the cd command. The selected folder should contain the file sdq0 inputs.mat,that has been created in the previous section.

Start by loading the network data. To do so, type in the Matlab command window

load sdq0 inputs.mat;

Now type

whos

to see the variables. A short explanation about each of the variables that has been loaded is provided inTable 2.

As shown in Table 2, the variables may be divided to four groups. The 1st and 2nd groups describe thetransmission network, and the shunt loads. Currently you may skip the details, since these variables willbe automatically processed. Two variables of special interest are subset and unit params. The vectorsubset contains a list of buses that are connected to either a generator, load, or unit. Note that shuntloads are not included in this list. The structure unit params contain unit parameters. For instance,the generator connected to bus 2 contains two parameters: P = 163 and V = 22. (These parameters weredefined in the GUI). To see these parameters type

unit params{2}

Similarly, unit params{X} contains the parameters of the unit connected to Bus X.

21

Table 2: Variables in sdq0 inputs.mat

R bus

L bus

C bus

Rtil bus parameters of the transmission network.

Rb details may be found in the description of the function ssNetw() in Section 8

Lb

Tau

R bus SLD parameters of shunt L-R loads.

L bus SLD details may be found in the description of the function balLoadsRL() in Section 8

subset vector containing buses that are connected

to either a generator, load or unit

unit params structure containing the unit parameters

Next, type the following code:

ws = 2*pi*50;N = size(Lb,1);

The variable ws is the nominal system frequency (in rad/s), or the frequency of the infinite bus (in ourtutorial, this is bus no. 1). The variable N is the number of buses, in our case N=9.

Now type the following code, or select it in Tutorial 1.m and run it by clicking ‘F9’:

[A1,B1,C1,D1] = ssNetw(R bus,L bus,C bus,Rtil bus,Rb,Lb,Tau,ws);[A2,B2,C2,D2] = balLoadsRL(R bus SLD,L bus SLD,ws);[A3,B3,C3,D3] = mergeParlNetw(A1,B1,C1,D1,A2,B2,C2,D2);[A,B,C,D] = elimBus(A3,B3,C3,D3,subset);

Note: In case of an error, please check that the software library is added to the Matlab path with itssubfolders, as explained in Section 5.

This code creates a state-space model (matrices A,B,C,D) representing the network and shunt loads. Thecode is standard, and can be used as is with any design. We currently skip the details. If you are interested,a description of the functions may be found either in Section 8, or in the Matlab code.

The state-space model describes the dynamics of the network and shunt loads in terms of dq0 quantities. Itsinputs are the d, q, and 0 components of the bus voltages, and its outputs are the d, q, and 0 componentsof the bus currents. The input and output vectors include only these buses that are connected togenerators, loads, or units, that is, all the buses in the vector subset. In our tutorial, the network has9 buses, however, only three buses (1,2,3) are connected to generators. The resulting state-space model is

ξ = Aξξ +Bξu

y = Cξξ +Dξu,

where ξ is the state vector, and the input and output vectors are

u = [vd,1, vd,2, vd,3, vq,1, vq,2, vq,3, v0,1, v0,2, v0,3]T,

y = [id,1, id,2, id,3, iq,1, iq,2, iq,3, i0,1, i0,2, i0,3]T,

in which vd,n, vq,n, v0,n are the dq0 voltages of bus n, and id,n, iq,n, i0,n are the dq0 currents injected fromthe nth generator into bus n.

Observe now the structure of the matrices A,B,C,D. First, note that these matrices are represented assparse matrices, since they have many zero elements. Type

22

A

to obtain a list of the nonzero elements. Type

spy(A)

to see the location of these elements in the matrix. Now type

size(A)

The size of the state matrix is 18× 18, meaning that the state-space model has 18 states. Similarly, the sizeof B is 18× 9, since the model has 9 inputs, and the size of C is 9× 18, since the model has 9 outputs.

Next, we will use the parameters in unit params to prepare the necessary data for Simulink. Type thefollowing commands:

v1 d = (2ˆ0.5)*1e3*unit params{1}.V;v1 q = 0;v1 0 = 0;

These three lines define the dq0 voltages of bus 1, in Volts. Remember that unit params{1} contains theparameters of the unit connected to Bus 1. In our case this is the infinite bus, which has a single parameterunit params{1}.V. Notice that unit params{1}.V is given in kV-rms, and is thus multiplied by

√2·103.

Next, type the following commands:

Ert = 1e3*[unit params{2}.V , unit params{3}.V];Pg = 1e6*[unit params{2}.P , unit params{3}.P];

Ert contains the no-load output voltages of the synchronous machines in Vrms, and Pg contains the nominalsingle-phase output power of the machines in W.

Now type

poles = 2;J = 0.0125*Pg/ws;Kd = 20*J*ws;

This code defines several default parameters of the synchronous machines. poles is the number of poles ofthe synchronous machine, J is the rotor moment of inertia in kg·m2, and Kd is the machine’s damping factorin W·s. Notice that these values are normalized to the machine’s nominal power.

Next, type

Nu = length(subset);units to net = [1:3:3*Nu , 2:3:3*Nu , 3:3:3*Nu];[˜,net to units] = sort(units to net);

These commands create the routing vectors units to net and net to units, which define how modelsconnect to each other in Simulink. units to net defines the order of voltage signals connected fromthe generators to the network, and net to units defines the order of current signals connected from thenetwork back to the generators.

23

7.3 Time-domain simulations

We are now ready to simulate our 9-bus power system in the time domain, using Simulink.

For this step you will need the file Tutorial 1 sim.slx, which may be found in the folder Tutorial 1.This file should be copied to the Matlab current folder, if it is not already there.

Open the Simulink model by typing in the Matlab command line:

Tutorial 1 sim

Let’s start by observing the different parts of the model, in order to understand its structure.

On the right side of the model, you should find a relatively small block named ‘transmission network, DQ0state-space model’. This is the state-space model representing the transmission network and shunt loads.The inputs to the model are the dq0 voltages of buses 1,2,3, and the outputs of the model are the dq0currents of buses 1,2,3. Click the block twice to view its parameters. The matrices defining the model areA,B,C,D, generated in the previous section. The operator full(x) is needed since the ‘state-space’ blockdoes not accept sparse matrices, and requires the inputs to be full matrices.

On the left side, there are three blocks. The top one (smaller than the others) is named ‘Bus 1, infinitebus’. This block models the voltage source representing the infinite bus. This voltage source has a constantfrequency ωs, and a constant amplitude, and is therefore modeled by constant voltages in the dq0 referenceframe. Click on the block to open it. Inside you should find the three constants v1 d, v1 q, v1 0, whichhave been defined in the previous section.

Still on the left side of the model, find the block named ‘Bus 2, synchronous generator’. This block modelsthe synchronous machine, connected to bus 2. Observe the block inputs and outputs. The block has twoinputs. The bottom one is idq0, which is the dq0 currents injected from the generator to the transmissionnetwork. The upper input is the mechanical power applied to the rotor. Notice that the steady-state value ofthe mechanical power is three times Pg(1), that is, three times the nominal single-phase power, as definedin the previous section.

The block also has several outputs: vdq0 is the dq0 voltages on bus 2, and delta is the rotor angle inrespect to a reference frame rotating with ωst. Two additional outputs are the rotor electric frequency, andthe single-phase (electric) power produced by the generator.

Now click on the block to open it. Inside you will find the relatively simple model of the synchronousmachine, as developed in the mathematical background (see Section 10 and Fig. 26). Several blocks aremarked in blue. These contain the constants that have been defined in the previous section.

The last block on the left is named ‘Bus 3, synchronous generator’. This block is identical in structure tothe block just described.

Now move to the right again, and observe the two ‘Selector’ blocks, connected to the network state-spacemodel. These block reorder the signals, so that the generators dq0 signals match the state-space model inputsand outputs. Click on the ‘Selector’ blocks to see their parameters. Note that the order of signals is defined bythe two vectors units to net and net to units, defined in the previous section. units to net definesthe order of voltage signals connected from the generators to the network, and net to units defines theorder of current signals connected from the network back to the generators.

Observe now the ‘measurements’ block, above the network state-space model. This block accepts the networkdq0 voltages and currents, and computes several useful quantities: the vectors P and Q are the single-phaseactive and reactive powers injected to each of the buses. The powers are positive when injected from theunit into the bus. The vectors Vm RMS and Vph deg are the bus voltage magnitudes and voltage phases (inVrms and degrees). At steady-state, these four quantities constitute the network power-flow solution.

Lastly, observe the block ‘convert signals DQ0 to ABC’. As it name implies, this block converts signals inthe dq0 reference frame to signals in the abc reference frame. Since the simulation is based on dq0 quantities,this block is only used to display the abc signals.

Now let’s run the simulation...

24

Click the ‘run’ button, and observe the time changing in the display ‘sim time’. The simulation time isinfinite, so the simulation will run continuously until stopped.

First we shall examine the differences between dq0 and abc signals. Go to the block ‘convert signals DQ0to ABC’, and open the two scopes connected to its input and output. Now pause the simulation. Zoom-inon the abc signals, and watch their sinusoidal shape. Note that the dq0 signals are constant at steady-state.When you finish this test, run the simulation again.

Next, we will change the system operating point (power flow solution). On the left side, while the simulationis running, toggle the manual switch to change the mechanical power input of Generator 2. This will add 90MW of mechanical power. While toggling the switch, observe the changes in active power (in the networkmeasurements, on the right). When the switch is toggled, 30 MW are added to the active power of Bus 2,and at the same time, 30 MW are subtracted from the active power on Bus 1, which is the infinite bus. Thefactor of 3 (90 = 3 × 30) is because the mechanical power corresponds to a three-phase output, while themeasurements power is single-phase. When you finish this test, toggle the manual switch back to its initialposition.

Now we shall observe the system transient behavior.

Go to the block named ‘Bus 2 synchronous generator’, and open the scope connected to its delta output.This output measures the rotor angle, in respect to a reference frame rotating with ωst. Notice that insteady-state, the rotor angle is constant. Now, while the simulation is running, toggle the manual switch,and watch the resulting transients. You may have to scale the Y-axis of the scope to observe the full transient.

On the same block, open the scope connected to the ‘rotor electric frequency’ output. Toggle the manualswitch and watch the transients. Remember to scale the Y-axis. Notice that after the transient the frequencyalways converges back to 50 Hz, This is due to the effect of the infinite bus.

On the same block, open the scope connected to the ‘Active Power’ output. Toggle the manual switch andwatch the transients.

When you finish these last tests, toggle the manual switch back to its initial position.

7.4 Small-signal model and Frequency-domain analysis

A major advantage of dq0-based models is that they are time-invariant, so constant inputs produce constantoutputs. As a result, dq0-based models have a well-defined operating point, and may be linearized to obtaina small-signal model. This linear small-signal model may be then analyzed in the Laplace domain, or in thefrequency domain.

In this section we will demonstrate how to linearize our 9-bus power system around an operating point. Wewill generate Bode plots of the resulting small-signal model, and compute its poles and zeros. Type

Tutorial 1 sim

to open the Simulink model.

The first step is to define the small-signal model inputs and outputs. In this simulation these are alreadydefined, but nevertheless we will explain how to define them. Go to the block named ‘Bus 2 synchronousgenerator’, and left-click on its output ‘rotor electric frequency’. Now right-click on this signal, and afloating menu will appear. From this menu choose ‘Linear Analysis Points’, and observe that the ‘OutputMeasurement’ option is selected. This signal is an output of our small-signal model. Notice that the activepowers of Generators 2 and 3 are also defined as outputs.

Now left-click on the input ‘mechanical power’. Right-click, and choose ‘Linear Analysis Points’ again.Observe that the ‘Input Perturbation’ option is selected. This signal is the input signal of our small-signalmodel.

The next step is to linearize the model. To do so, type the following commands in the Matlab commandwindow:

25

io = getlinio(bdroot);linsys = linearize(bdroot,io,3);

This causes the simulation to run for 3 seconds, to obtain an operating point, and then the model is linearizedin the neighborhood of this operating point. You may now type

linsys

to observe the resulting small-signal model. To obtain the state-space matrices type

[Ap,Bp,Cp,Dp]=ssdata(linsys);

Check the dimensions of these matrices (for instance, by using size(Ap)). According to the dimensions,the small-signal model has 16 states, 1 input, and 3 outputs.

To view the Bode plot of the small-signal model type

figure; bode(linsys);

To view the poles of the small-signal model type

figure; pzmap(linsys);

26

8 Overview of main functions

Here is a list of several main functions. Detailed explanations can be found in the Matlab code. see Section 10for more details.

Root functions

bodeSparse()

1 function [Mag, Ph] = bodeSparse(A, B, C, D, u, w)2 % BODESPARSE Bode frequency response of a sparse state-space model.3 %4 % Usage:5 % [Mag, Ph] = bodeSparse(A, B, C, D, u, w)6 %7 % where8 % A, B, C, D - system matrices9 % u - input’s serial number. For single input input=1.

10 % For multi-input models select 1 <= input <= size(B,2)11 % w - frequency range [rad/s]12 %13 % Outputs:14 % Mag - magnitude [dB]15 % Ph - phase [deg]

This function computes the frequency response (bode plot) of a state-space model. The system matricesA,B,C,D can be large and sparse. This function performs the same task as Matlab’s function bode, butcan handle large dynamic systems with sparse system matrices. Run-time is primarily determined by thenumber of nonzero elements in the state matrix A.

� For systems with a single output Mag(k) is the magnitude at frequency W(k). For systems with multipleoutputs Mag(:,k) is the vector of magnitudes at frequency W(k), such that Mag(j,k) corresponds tothe jth output.

� For systems with a single output Ph(k) is the magnitude at frequency W(k). For systems with multipleoutputs Ph(:,k) is the vector of phases at frequency W(k), such that Ph(j,k) corresponds to the jthoutput.

closedLoop()

1 function [A, B, C, D] = closedLoop(Aksi, Bksi, Cksi, Dksi, unitData)2 % CLOSEDLOOP Constructs a linear state-space model of a complete power system:3 % transmission network, generators, and loads.4

5 % Usage:6 % [A, B, C, D] = closedLoop(Aksi, Bksi, Cksi, Dksi, unitData)7 %8 % where9 % Aksi, Bksi, Cksi, Dksi - system matrices of the network model

10 % unitData - a cell array (Nx1) that stores the system matrices of the11 % units. Each cell unitData{n} is a structure with the following fields:12 % unitData{n}.A = matrix An13 % unitData{n}.B = matrix Bn14 % unitData{n}.C = matrix Cn15 % unitData{n}.D = matrix Dn16 % unitData{n}.G = matrix Gn17 %18 % Outputs:19 % A, B, C, D - system matrices of the complete power system

The model generated by this function is a feedback connected model, describing the dynamics of the networktogether with the dynamics of the units connected to it (generators/loads). Since the units are linearizedin the neighborhood of the system’s operating point (power flow solution), the resulting model is linear,and inputs and outputs are small-signals that represent deviations from the system’s operating point. Thisfunction enables:

27

� Low-complexity modeling of the system dynamics. The resulting state-space model has a minimal numberof states and uses sparse system matrices, and therefore can be used to efficiently model the dynamics oflarge power systems in the neighborhood of an operating point.

� Stability analysis. Stability can be tested by examining eigenvalues of the state matrix A. The powersystem is stable at an operating point if all eigenvalues of the resulting state matrix A have negative realparts.

All the models are given in the state-space form, and use dq0 signals. Models of the network and variousunits can be created automatically by other functions from the package.

createQS()

1 function [Aqs, Bqs, Cqs, Dqs] = createQS(A, B, C, D)2 % CREATEQS creates a quasi-static model from a dynamic dq0 model.3 %4 % Usage:5 % [Aqs, Bqs, Cqs, Dqs] = create_quasi_static(A, B, C, D)6 %7 % where8 % A, B, C, D - system matrices of dq0 model, computed by functions9 % ’ssNetw’ or ’ssNetwSym’. These matrices can be full, sparse,

10 % numeric, or symbolic11 %12 % Outputs:13 % Aqs, Bqs, Cqs, Dqs - system matrices of the quasi-static model that14 % are numeric or symbolic, depending on the inputs

This function creates a quasi-static model from a dq0 model. The quasi-static model is a pure gain model,obtained by the approximation s → 0, i.e., using the so-called low frequency approximation. Under thisapproximation the system is usually modeled using time-varying phasors. Since the model represents astatic gain, all the constructed matrices except Dqs are empty.

createYbus()

1 function Ybus = createYbus(A, B, C, D)2 % CREATEYBUS Creates admittance matrix Ybus based on system matrices of3 % the full dq0 model.4 %5 % Usage:6 % Ybus = createYbus(A, B, C, D)7 %8 % where9 % A, B, C, D - system matrices of dq0 model

10 %11 % Outputs:12 % Ybus - the network Ybus matrix

This function creates the traditional admittance matrix Y bus based on the full dq0 state-space model asinput. The admittance matrix is evaluated using the quasi-static approximation (s → 0). Under thisapproximation Y bus may be extracted from the equality: [Id, Iq]

T = Y bus[Vd, Vq]T, where Id, Iq, Vd, Vq

are vectors from RN×1. This function is useful for validating the dq0 state-space model, since Y bus canbe computed directly from the network topology, and is provided by other software products (such asMatpower), it may be used as a checksum to validate the resulting system matrices A,B,C,D. TheY bus is measured in 1/Ohm, and can be converted to the standard per-unit representation as follows:Ybus per unit(i,j)=Ybus(i,j)*Vbase(i)*Vbase(j)/Pbase, where Vbase(i) is the voltage baseon bus i (in V), and Pbase is the power base (in W, common to all buses).

28

elimBus()

1 function [Ar, Br, Cr, Dr] = elimBus(A, B, C, D, subset)2 % ELIMBUS eliminates disconnected buses. It produces a new equivalent3 % dynamic model in which the currents in the buses being eliminated4 % are forced to zero.5 %6 % Usage:7 % [Ar, Br, Cr, Dr] = elimBus(A, B, C, D, subset)8 %9 % where

10 % A, B, C, D - matrices of the original model11 % subset - a vector of bus indices specifying the buses12 % to be included in the new model. Voltages and currents13 % of buses in this list are NOT eliminated, and will be14 % the inputs and outputs of the new model.15 %16 % Outputs:17 % Ar, Br, Cr, Dr - system matrices of the new dynamic model

The need to eliminate disconnected buses arises in several occasions:

� Sometimes certain buses are not connected to either a generator or a load. In this case the current injectedinto the bus is zero.

� Frequently loads are modeled as shunt elements and are integrated into the network model. In this caseload buses appear as disconnected buses with zero current.

� In many scenarios there is a need to analyze the dynamics or stability of a certain subset of units in thenetwork, typically only the generators. In such cases elimination of the disconnected buses results in asimpler dynamic model in which the inputs and outputs relate only to the required subset of buses. Thisis usually done after integrating the loads in the network model as shunt elements.

Bus elimination is achieved by controlling the inputs of the buses being eliminated, such that correspondingoutputs are zeroed. Assume for instance that the ith input and ith output are eliminated. This is doneusing the dynamic model output equation y = Cx+Du. Since the matrix D of the dq0 model is diagonal,the output y(i) can be zeroed by controlling the ith input such that u(i)=-(1/D(i,i))*Ci*x, whereCi is the ith row in matrix C. The input u(i) and the output y(i) are eliminated, and will not appear inthe new model.

Handling zero elements on the diagonal of D: D(i,i)=0. As described above, elimination is achieved byinverting elements on the main diagonal of matrix D. If several of these elements are zeros, the functiontransforms the state vector and computes a new dynamic model such that the corresponding rows in matrixC are also zero. In other words, if input/output i are being eliminated, and D(i,i)=0, then to zero theoutput the new state matrix C will have a zero row Ci=0, so that Ci*x+Di*ui=0, as required. This isdone by a LU decomposition of the relevant rows in matrix C. The process is numerically efficient and stablewith large sparse state matrices.

elimBusYbus()

1 function YbusR = elimBusYbus(Ybus, subset)2 % ELIMBUSYBUS eliminates disconnected buses in the system admittance matrix Ybus.3 %4 % Usage:5 % YbusR = elimBusYbus(Ybus, subset)6 %7 % where8 % Ybus - original admittance matrix9 % subset - a vector of bus indices specifying the buses

10 % to be included in the new model. Voltages and currents11 % of buses in this list are NOT eliminated, and will be12 % the inputs and outputs of the new model13 %14 % Outputs:15 % YbusR - the new admittance matrix

This function eliminates disconnected buses in the system admittance matrix Y bus. It produces an new

29

equivalent Y bus matrix for a network in which the currents of the eliminated buses are zeroed.

mergeParlNetw()

1 function [A, B, C, D] = mergeParlNetw(A1, B1, C1, D1, A2, B2, C2, D2)2 % MERGEPARLNETW Merges two networks connected in parallel.3 %4 % Usage:5 % [A, B, C, D] = MERGEPARLNETW(A1, B1, C1, D1, A2, B2, C2, D2)6 %7 % where8 % A1, B1, C1, D1 - system matrices of network 19 % A2, B2, C2, D2 - system matrices of network 2

10 %11 % Outputs:12 % A, B, C, D - system matrices of merged network

This function merges two networks connected in parallel. The networks are described by state-space models.The model inputs (voltages in dq0 coordinates) are the same for both networks. The model outputs (injectedcurrents in dq0 coordinates) are summed entry-wise.

ssNetw(), ssNetwSym(), ssNetwMatPower()

1 function [Aksi, Bksi, Cksi, Dksi] = ssNetw(R_bus, L_bus, C_bus, Rtil_bus, Rb, Lb, Tau, ws)2 % SSNETW Generates a dynamic model of a three-phase balanced or3 % symmetrically configured transmission network.4 %5 % Usage:6 % [Aksi, Bksi, Cksi, Dksi] = ssNetw(R_bus, L_bus, C_bus, Rtil_bus, Rb, Lb, Tau, ws)7

8 % where9 % R_bus - vector Nx1, shunt resistance on each bus in Ohm

10 % L_bus - vector Nx1, shunt inductance on each bus in H11 % C_bus - vector Nx1, shunt capacitance on each bus in F12 % Rtil_bus - vector Nx1, resistance in series with the shunt capacitance in Ohm13 % Rb - matrix NxN, the [i,k] element is the resistance on brach connecting14 % bus i and bus k15 % Lb - matrix NxN, the [i,k] element is the inductance (in H) on brach connecting16 % bus i and bus k17 % Tau - matrix NxN, indicates the branch transformer ratios18 % ws - nominal system frequency [rad/s]19 %20 % Outputs:21 % Aksi, Bksi, Cksi, Dksi - sparse system matrices22 %23 % See also: ssNetwSym, ssNetwMatPower

The above code represents abridged version taken from the function ssNetw, which does not supportsymbolic inputs. In order to use symbolic math, the function ssNetwSym can be used instead. In addition,the software contains a function ssNetwMatPower, which is implemented to construct state-space modelsof a power network represented by a MatPower database (mpc).

30

stepSparse()

1 function [y, t] = stepSparse(A, B, C, D, Tf, T, display)2 % STEPSPARSE Computes the step response of a state-space model.3 %4 % Usage:5 % stepSparse(A, B, C, D, Tf, T)6 % when invoked with no output arguments, this function plots the7 % step response on the screen8 % [y, t] = stepSparse(A, B, C, D, Tf, T)9 % returns outputs, assuming that a unit step is

10 % simultaneously applied to each of the inputs11 % [y, t] = stepSparse(A, B(:,m), C, D(:,m), Tf, T)12 % returns outputs, assuming that a unit step is13 % applied to the m’th input14 % [y, t] = stepSparse(A, B(:,m), C(p,:), D(p,m), Tf, T)15 % returns the p’th output, assuming that a unit step is16 % applied to the m’th input17 %18 % where19 % A, B, C, D - system matrices20 % Tf - simulation final time such that t\in[0,Tf]21 % T - numeric step size (sampling time)22 % display - computation progress is printed on screen (optional)23 %24 % Outputs:25 % t - time vector26 % y - the step response27 %28 % See also: ssNetw

This function performs the same task as Matlab’s function step, but is designed for large dynamic systemswith sparse system matrices. The function has been tested on multiple systems with up to 105 state variables,meaning size(A)=[100e3,100e3]. Run-time is primarily determined by the number of nonzero elementsin the state matrix A. The step response is computed using the Bilinear transformation (also called Tustin’sapproximation, or Trapezoidal rule), which is a stiff implicit solution method for ODEs:

x(k) = Q1x(k − 1) +Q2(u(k) + u(k − 1))/2

Q1 = (I − (T/2)A)−1(I + (T/2)A)

Q2 = (I − (T/2)A)−1BT.

This method was selected since it maps stable poles in the s-domain to stable poles in the z-domain, andthus preserves the system stability. The original model is stable if and only if the approximated step responseconverges to a finite value.

The solver implemented in this file attempts to balance speed and memory requirements depending onthe system size. For small systems, the inverse invAT=inv(speyeNN-(T/2)*A) is computed explicitly,to obtain fast computation speed. For large systems, speyeNN-(T/2)*A is decomposed using the LUdecomposition, and the inverse is never computed explicitly. This typically enhances the accuracy andcomputation speed for very large systems, and also requires less memory.

31

Models

balLoadsRL()

1 function [A, B, C, D] = balLoadsRL(R_bus, L_bus, ws)2 % BALLOADSRL Generates a dynamic model of balanced three-phase series RL loads.3 %4 % Usage:5 % [A, B, C, D] = BALLOADSRL(R_bus, L_bus, ws)6 %7 % where8 % R_bus - vector Nx1, resistance on each bus in Ohm9 % L_bus - vector Nx1, inductance on each bus in H

10 % ws - the nominal system frequency [rad/s]11 %12 % Outputs:13 % A, B, C, D - sparse system matrices

This function generates simple dynamic model of a linear balanced three-phase load modeled by RL com-ponents connected in series.

longLine()

1 function [A, B, C, D] = longLine(Rx, Lx, Cx, len, N, ws)2 % LONGLINE Implements an approximate (lumped) dynamic model of a long power line.3 %4 % Usage:5 % [A, B, C, D] = LONGLINE(Rx, Lx, Cx, len, N, ws)6 %7 % where8 % Rx - resistance per unit length [Ohm/m]9 % Lx - inductance per unit length [H/m]

10 % Cx - capacitance per unit length [F/m]11 % len - transmission line length [m]12 % N - number of T sections13 % ws - nominal system frequency [rad/s]14 %15 % Outputs:16 % A, B, C, D - system matrices

This function constructs an approximate (lumped parameters based) model in the dq0 reference frame suchthat the model can be directly embedded into the main grid.

32

9 Examples

Here is a list of several examples. For each .m file there is a respective .slx file with assembled simulationscheme. Detailed explanations can be found in the Matlab code.

ex get started here.m

This script demonstrates the use of several basic functions: ssNetw, ssNetwSym, createYbus, createQS,elimBus, elimBusesYbus, longLine.

ex2busStability.m

This script illustrates stability analysis of a 2-bus power system. This file demonstrates:

– How to use the function closedLoop to construct a state-space model of a complete power system(transmission network + generators/loads).

– How to test stability theoretically by examining eigenvalues of the state matrix A.

ex7busLongLine.m

This script simulates the dynamics of a 7-bus system with long transmission lines, synchronous generators,and photovoltaic generators. The simulation demonstrates the use of dq0 signals to model all the systemcomponents, and shows the effects of the long power line (especially delays) on the dynamics and stabilityof the system.

ex9busSG.m

This script simulates the dynamics of a 9-bus power system in the time domain. The system in this exampleincludes three major blocks: the transmission network, the loads, and the generators. The system convergesto a steady-state that matches its power flow solution. The user may trigger a dynamic response by definingan input step in mechanical power.

ex14busSGandPV.m

This script shows dynamic simulation of a 14-bus test case network, with physical synchronous machinemodels and photovoltaic inverters (renewable sources). The user may choose between transient simulationor small signal analysis.

exDroopA.m, exDroopB.m

These scripts illustrate how to use simple droop control and analyze dynamics and stability of large powersystems with physical synchronous machines.

exLargeSysStability.m

This script presents the small-signal modeling and stability analysis of large power systems. This file demon-strates:

– How to model the small-signal dynamics of large power systems using dq0 signals.– How to evaluate the system stability based on eigenvalues.– How to compute step responses of the complete system.

Power systems ranging in size from 4 to 2383 buses are considered.

33

exMatPower.m

This script constructs dynamic models of power systems from the MatPower package in the dq0 referenceframe.

syncMachVsSwing.m

This script provides comparison between the transient response of the physical and approximate (swingequation) synchronous machine models. Both models are tested when connected to an infinite bus.

The physical (accurate) model is based on the book “Electric Machinery” by Fitzgerald. The presentedmodel is based on dq0 quantities, and is identical to the model presented in the book, except that the inputvoltages and output currents are represented in a references frame rotating with angle ωst, (instead of θ -the rotor electrical angle), where ωs is the frequency of the infinite bus. This change of coordinates allowsdirect connection of the model to the infinite bus, or to any other model (network/load/generator) that isrepresented in the same reference frame.

The approximated model is based on the (classical) swing equation, and includes the effects of a seriessynchronous inductance and armature resistance. Similar to the physical model, the input voltages andoutput currents are represented in a references frame rotating with angle ωst.

34

10 Mathematical background

10.1 The dq0 transformation

Assume a general three-phase unit (generator or load), as presented in Fig. 24.

unit

va(t) ia(t)

vb(t) ib(t)

vc(t) ic(t)

network

Figure 24: A unit in the network, showing signals in the abc reference frame.

A dynamic model of such a unit may be derived from the differential equations describing its physicalbehavior. To this end, a natural choice of variables are the three voltages va(t), vb(t), vc(t) and the threecurrents ia(t), ib(t), ic(t). A dynamic model based on these variables is called a transient model. Transientmodels based on abc quantities are very general and have many advantages. However, one drawback is thatthey are not time-invariant, since they involve sinusoidal components that are functions of time. As a result,there is no direct way to define an operating point for these models, or to perform a small-signal analysis.To address this problem, the dq0 transformation maps sinusoidal signals in the abc reference frame to newsignals in the dq0 reference frame. A primary advantage of this transformation is that symmetric AC signalsare mapped to constants. As a result, if the power system is symmetrically configured, dq0-based models aretime-invariant. For this reason, the dq0 transformation provides a compact dynamic model of symmetricallyconfigured units or systems, and is useful for small-signal analysis, stability analysis, and controller design.

Let ζ represent the quantity to be transformed (current or voltage), then the dq0 transformation (matrixTθ) is defined as ζdζq

ζ0

= Tθ

ζaζbζc

=2

3

cos (θ) cos(θ − 2π

3

)cos(θ + 2π

3

)− sin (θ) − sin

(θ − 2π

3

)− sin

(θ + 2π

3

)12

12

12

ζaζbζc

, (1)

and the inverse transformation (matrix T−1θ ) isζaζbζc

= T−1θ

ζdζqζ0

=

cos (θ) − sin (θ) 1cos(θ − 2π

3

)− sin

(θ − 2π

3

)1

cos(θ + 2π

3

)− sin

(θ + 2π

3

)1

ζdζqζ0

. (2)

The angle θ(t) appearing in these equations is the reference angle of the dq0 transformation. For instance,in synchronous machines, θ(t) is typically selected to be the rotor electrical angle (measured in respect tothe stator), which means that dq0 quantities are viewed in a reference frame rotating with the rotor. Theinstantaneous three-phase power flowing from the unit into the network is given by

P3φ(t) = vaia + vbib + vcic =3

2

(vdid + vq iq + 2v0i0

). (3)

The power is constant regardless of the choice of θ(t).

10.2 Synchronous machine models and the unified reference frame

To demonstrate the dq0 transformation and its properties, we show in this section two dq0-based models ofthe synchronous machine. We start by developing the model of a simple synchronous machine connected toan infinite bus. While such a model is popular in many textbooks, we show here how to develop it usingdq0 quantities directly, and without using phasor concepts. We also use this simple model to explain theconcept of a unified reference frame.

35

Assume a simplified synchronous machine represented as an ideal voltage source behind a synchronousinductance Ld. The machine is connected to an infinite bus, as shown in Fig. 25.

Ld

synchronousinductance

SGvd = 0

vq = Ve

v0 = 0

synchronous machine

∞vd = Vg

vq = 0

v0 = 0

infinitebus

Figure 25: Simple synchronous machine connected to an infinite bus, single phase diagram.

Both the infinite bus (on the right) and the internal synchronous machine (on the left) are represented asvoltage sources. The synchronous machine voltage is vd = 0, vq = Ve, v0 = 0, with a reference angle of θ.In this example θ is the electric angle of the rotor in respect to the stator. The infinite bus has a constantfrequency of ωs, so its voltage is given by vd = Vg, vq = 0, v0 = 0, with a reference angle of ωst.

We now wish to construct a dynamic model of the complete system based on dq0 signals. However, apotential problem is that the two voltage sources in this system are defined with respect to two differentreference frames (θ and ωst). To solve this, we choose ωst as a unified reference frame for both the infinite busand synchronous machine, and construct a model of the synchronous machine using signals in this referenceframe. The dq0 transformation with the reference angle ωst is given byζdζq

ζ0

= Tωs

ζaζbζc

=2

3

cos (ωst) cos(ωst− 2π

3

)cos(ωst+ 2π

3

)− sin (ωst) − sin

(ωst− 2π

3

)− sin

(ωst+ 2π

3

)12

12

12

ζaζbζc

, (4)

and a formula that allows to convert signals from any reference frame to the unified frame isζdζqζ0

= Tθ,ωst

ζdζqζ0

=

sin (δ) cos (δ) 0− cos (δ) sin (δ) 0

0 0 1

ζdζqζ0

, (5)

where δ(t) = θ(t)−ωst+π/2. The variables ζd, ζq are defined with respect to ωst, and ζd, ζq are defined withrespect to θ. This formula may be proven using equations (2) and (4). The synchronous machine voltage isnow obtained by substituting vd = 0, vq = Ve, v0 = 0 in (5), which leads tovdvq

v0

=

Ve cos (δ)Ve sin (δ)

0

,δ = θ − ωst+ π/2.

(6)

In addition, the dynamic behavior of the angle δ is described by

δ =poles

2Jωs

(Pm −Kdδ − P3φ

). (7)

This is the classic swing equation. The term J is the rotor constant of inertia, poles is the number ofmachine poles (must be even), Pm is the mechanical power, and Kd is the damping constant. As before, thethree-phase power is given by

P3φ =3

2(vdid + vqiq + 2v0i0) . (8)

By combining the equations above, and taking δ = φ1, a state-space model of the simple synchronousmachine results in

φ1 = φ2,

φ2 =poles

2Jωs

(Pm −

3

2Ve(cos(φ1)id + sin(φ1)iq

)−Kdφ2

),

vd = Ve cos(φ1), vq = Ve sin(φ1), v0 = 0.

(9)

36

This model has two state variables φ1, φ2, three inputs id, iq, i0, and three outputs vd, vq, v0. Note that themodel represents only the machine’s voltage source, and does not include the synchronous inductance, whichwill be shown in equation (27) below. A complete model of the power system is shown in Fig. 26.

× id,2

× iq,2

+

+3/2

Kd

−−+

Pmpoles2Jωs

∫dτ

∫dτ

Ve cos(δ)

δ

vd,2

Ve sin(δ)vq,2

inductor

dq0

model

vd,1

vq,1

Vg

0

infinitebus

Figure 26: Dynamic model of a simple synchronous machine connected to an infinite bus.

Instead of the simple model discussed so far, consider now a more sophisticated model of the synchronousmachine3. This model captures the interaction of the direct-axis magnetic field with the quadrature-axismmf, and the quadrature-axis magnetic field with the direct-axis mmf, as well as the effects of resistances,transformer voltages, field winding dynamics, and salient poles. The parameters are explained in Table 3.

Table 3: Nomenclature: Synchronous machine.

λd, λq, λ0 flux linkages

λf field winding flux linkage

vd, vq, v0 stator voltages

vf field winding voltage

id, iq, i0 stator currents

if field windings current

Ld, Lq, L0 synchronous inductances

Laf mutual inductance between the field winding and phase a

Lff self-inductance of the field winding

Ra, Rf armature and field winding resistance

J rotor moment of inertia

Te, Tm electromagnetic and mechanical torque

Omitting the algebraic details, the resulting nonlinear state-space model of the machine with respect to the

3A. E. Fitzgerald, C. Kingsley, S. D. Umans, Electric Machinery, 6th Edition, McGraw-Hill, New York, 2003.

37

reference angle θ is

φ1 = −2RaLffL2β

φ1 + φ2φ5 +2RaLafL2β

φ4 + vd,

φ2 = −RaLqφ2 − φ1φ5 + vq,

φ3 = −RaL0

φ3 + v0,

φ4 =3RfLafL2β

φ1 −2RfLdL2β

φ4 + vf ,

φ5 =poles

2J

(Tm +

3L2β − 6LffLq

2L2βLq

φ1φ2 +3LafL2β

φ2φ4

),

id = −2LffL2β

φ1 +2LafL2β

φ4,

iq = − 1

Lqφ2,

i0 = − 1

L0φ3, if = −3Laf

L2β

φ1 +2LdL2β

φ4, ω = φ5,

(10)

where L2β = 2LdLff − 3L2

af . In this model, the state variables are φ1 = λd, φ2 = λq, φ3 = λ0, φ4 = λf ,

φ5 = ω, the inputs are vd, vq, v0, vf , Tm, and the outputs are id, iq, i0, if , ω.

Using (5), this model can be translated to the unified reference frame (with respect to ωst). Note that themodel has an additional state variable δ = φ6. The new inputs are vd, vq, v0, vf , Tm, and the new outputsare id, iq, i0, if , ω

φ1 = −2RaLffL2β

φ1 + φ2φ5 +2RaLafL2β

φ4 + sin(φ6)vd − cos(φ6)vq,

φ2 = −RaLqφ2 − φ1φ5 + cos(φ6)vd + sin(φ6)vq,

φ3 = −RaL0

φ3 + v0,

φ4 =3RfLafL2β

φ1 −2RfLdL2β

φ4 + vf ,

φ5 =poles

2J

(Tm +

3L2β − 6LffLq

2L2βLq

φ1φ2 +3LafL2β

φ2φ4

),

φ6 = φ5 − ωs,

id = −2LffL2β

sin(φ6)φ1 −1

Lqcos(φ6)φ2 +

2LafL2β

sin(φ6)φ4,

iq =2LffL2β

cos(φ6)φ1 −1

Lqsin(φ6)φ2 −

2LafL2β

cos(φ6)φ4,

i0 = − 1

L0φ3, if = −3Laf

L2β

φ1 +2LdL2β

φ4, ω = φ5, δ = φ6.

(11)

Unlike the simple model, this model of the synchronous machine includes the inductance terms Ld, Lq, L0.Since this model uses the unified reference frame (ωst), it can be connected to an infinite bus directly bysubstituting vd = Vg, vq = 0, v0 = 0.

10.3 Modeling transmission networks in the frequency domain

This section presents a dq0-based model of transmission networks in the frequency domain. We start byreminding the reader of time-varying phasors, and their relations to the power flow equations. We thenextend the time-varying phasor model to obtain a more accurate model of the network in terms of dq0quantities.

38

We begin by developing the relationship between dq0 signals and time-varying phasors. Assume a unit withbalanced three-phase AC voltages given by

va(t) = A(t) cos (ωst+ ϕ(t)) ,

vb(t) = A(t) cos

(ωst+ ϕ(t)− 2π

3

),

vc(t) = A(t) cos

(ωst+ ϕ(t) +

3

).

(12)

Assuming that variations in the magnitude A(t) and phase ϕ(t) are slow in comparison to the frequency ωs,

then these voltages may be represented by a time-varying phasor V (t) = A(t)√2ejϕ(t). In addition, as discussed

in the previous section, equivalent dq0 voltages with respect to the unified reference ωst are

vd(t) = A(t) cos(ϕ(t)),

vq(t) = A(t) sin(ϕ(t)),

v0(t) = 0.

(13)

It immediately follows that a time-varying phasor relates to dq0 quantities in the unified reference frame by

V (t) =A(t)√

2ejϕ(t) =

1√2

(vd(t) + jvq(t)), (14)

or alternatively,

vd(t) =√

2 Re{V (t)},

vq(t) =√

2 Im{V (t)},(15)

and the same relationships hold for currents or for every other quantity. Let us now examine the relationshipsfor active and reactive powers. Assuming a voltage phasor V (t) and a current phasor I(t), the powers aregiven by

P (t) = Re{V (t)I(t)∗} =1

2(vd(t)id(t) + vq(t)iq(t)) =

1

3P3φ(t),

Q(t) = Im{V (t)I(t)∗} =1

2(vq(t)id(t)− vd(t)iq(t)) .

(16)

This equation shows the dual meaning of the active power P (t). In the specific case of a static or quasi-staticsystem, in which transients are slow in comparison to ωs, the active power P (t) of each phase is the averagepower over a line cycle. In addition, the instantaneous sum of powers for the three-phases is P3φ(t) = 3P (t).Note that if the system is not quasi-static (for instance, during a fast transient) the average powers P andQ are not well-defined. However, the expression for P3φ(t) still holds.

We now turn our attention to modeling the transmission network. Using time-varying phasors, the networkis usually described by the admittance matrix Y bus. Assume a network with N buses, and denote thebus voltages by VN×1(t), and the bus injected currents by IN×1(t). All quantities in these vectors aretime-varying phasors. The network is then described by the relation

IN×1(t) = Y busVN×1(t). (17)

This is a quasi-static model of the transmission network. It is quasi-static since it is based on the assumptionthat phasors change slowly in comparison to ωs, so the frequency throughout the network is approximatelyconstant. As a result, the matrix Y bus is composed of constant admittances, which are computed at thefixed frequency ωs. We highlight this fact by denoting Y bus = Y bus(jωs). Equation (17) can also be writtenin terms of its real and imaginary parts. The result is

Re{IN×1(t)} = Re{Y bus}Re{VN×1(t)} − Im{Y bus} Im{VN×1(t)},Im{IN×1(t)} = Im{Y bus}Re{VN×1(t)}+ Re{Y bus} Im{VN×1(t)}.

(18)

Equivalently, the quasi-static model in (17) can be expressed by the power-flow equations, given by

Pn(t) = |Vn(t)|N∑k=1

|ynk||Vk(t)| cos (∠ynk + δk − δn) ,

Qn(t) = −|Vn(t)|N∑k=1

|ynk||Vk(t)| sin (∠ynk + δk − δn) ,

(19)

39

where, for the nth unit, Pn(t), Qn(t) are the powers injected from the unit into the network, |Vn(t)| is thevoltage amplitude, and δn is the voltage phase. In addition, the constants ynk are elements of the admittancematrix Y bus.

Due to the assumption of quasi-static phasors, equations (17), (18), and (19) are only valid at frequencies thatare much lower than ωs. We now provide a theorem4 that extends this model to high frequencies using dq0quantities. Define the dq0 signals vd,n, vq,n, v0,n to be the voltages on bus n, id,n, iq,n, i0,n to be the injectedcurrents to bus n. In addition define the vectors Vd(t) = [vd,1(t), . . . , vd,N (t)]T, Id(t) = [id,1(t), . . . , id,N (t)]T,etc. The dynamic model of a general symmetrically configured network in the Laplace domain isId(s)Iq(s)

I0(s)

=

N1(s) jN2(s) 0−jN2(s) N1(s) 0

0 0 Y bus(s)

Vd(s)Vq(s)V0(s)

, (20)

where Y bus(s) is the frequency dependent nodal admittance matrix and

N1(s) :=1

2

(Y bus(s+ jωs) + Y bus(s− jωs)

),

N2(s) :=1

2

(Y bus(s+ jωs)− Y bus(s− jωs)

).

(21)

These equations describe the accurate dynamics of the network in the Laplace domain, based on dq0 quan-tities. The following corollary relates the proposed dq0 model to the standard quasi-static model.

Corollary 1 When Y bus(s+ jωs) = Y bus and Y bus(s− jωs) = (Y bus)∗, equation (20) reduces to the quasi-static expressions in (18).

This corollary states that if the general Y bus(s+jωs) can be approximated by a constant matrix when s→ 0,then the dynamic model is quasi-static.

10.4 Models of single passive components

Assume a balanced three-phase inductor, as shown in Fig. 27.

unit

Lva(t) ia(t)

Lvb(t) ib(t)

Lvc(t) ic(t)

Figure 27: A balanced three-phase inductor.

We will use this simple network to demonstrate the quasi-static and dq0-based dynamic models, and tocompare them to each other. The admittance matrix describing the network is Y bus(s) = 1

sL , or at a fixedfrequency ωs, Y

bus = Y bus(jωs) = 1jωsL

. Using time-varying phasors, and according to (17), (18), thequasi-static model is given by

I(t) =1

jωsLV (t). (22)

By taking the real and imaginary parts of this equation, and using the relations between dq0 signals andphasors provided in (15), equivalent expressions for the quasi-static model are

vd(t) = −ωsLiq(t),vq(t) = ωsLid(t).

(23)

4This theorem is presented at Y. Levron and J. Belikov, “Modeling power networks using dynamic phasors in the dq0reference frame,” Electric Power Systems Research, 144, pp. 233–242, Mar. 2017.

40

We will now compute the more accurate dq0 dynamic model. According to (20), (21),Id(s)Iq(s)I0(s)

=

sL(s2+ω2

s)ωs

L(s2+ω2s)

0−ωs

L(s2+ω2s)

sL(s2+ω2

s)0

0 0 1sL

Vd(s)Vq(s)V0(s)

, (24)

and following several algebraic manipulations,

Vd(s) = −ωsLIq(s) + sLId(s),

Vq(s) = ωsLId(s) + sLIq(s),

V0(s) = sLI0(s).

(25)

Transformation from the Laplace domain to the time domain provides

vd(t) = −ωsLiq(t) + Ldid(t)

dt,

vq(t) = ωsLid(t) + Ldiq(t)

dt,

v0(t) = Ldi0(t)

dt.

(26)

Direct comparison of the quasi-static model in (23) and the dq0 model in (26) shows that the two models aresimilar, except for the additional time derivatives, which describe high-frequency effects. At low frequencies,where the time derivatives are negligible, the two models are equivalent.

We will now use these results to develop state-space models for the inductor, capacitor, and resistor. Assumea three-phase inductor with currents id, iq, i0, voltages on one side vd,1, vq,1, v0,1, and voltages on the otherside vd,2, vq,2, v0,2. Following (26), the dynamic model of the inductor may be written as

d

dt

idiqi0

=

0 ωs 0−ωs 0 0

0 0 0

idiqi0

+1

L

vd,1 − vd,2vq,1 − vq,2v0,1 − v0,2

. (27)

Similarly, the model of a capacitor C is

d

dt

vd,1 − vd,2vq,1 − vq,2v0,1 − v0,2

=

0 ωs 0−ωs 0 0

0 0 0

vd,1 − vd,2vq,1 − vq,2v0,1 − v0,2

+1

C

idiqi0

, (28)

and for a resistor R the model is vd,1 − vd,2vq,1 − vq,2v0,1 − v0,2

=

R 0 00 R 00 0 R

idiqi0

. (29)

10.5 Modeling transmission networks in state-space

The software represents symmetrically configured transmission networks by linear state-space models, whichare constructed using the Gilbert’s realization procedure. The state-space models are of minimal order,and use sparse system matrices, and are therefore suitable for large power systems. The final results aresummarized in this section. It is not necessary to understand the algebric details below in order to use therelated functions.

The state-space model representing the transmission network is given by

ξ = Aξξ +Bξu

y = Cξξ +Dξu,

where ξ is the state vector, the input u = [Vd, Vq, V0]T is the dq0 transformations of the three-phase voltages,and the output y = [Id, Iq, I0]T is the dq0 transformations of the three-phase injected currents.

41

The software automatically constructs the matrices Aξ, Bξ, Cξ, Dξ based on the network data. This canbe done using the graphical user interface, or directly from the Matlab command line using the functionssNetw, ssNetwSym, or ssNetwMatPower.

Assume a network with the standard branch shown in Fig. 28.

yishunt

elementbus i

(from)bus k(to)

ykshunt

element

Lik Rikideal

transformer

τik : 1

Figure 28: Standard branch connecting buses i and k.

Consider next the special case assuming that the network is fully connected, and all transformers have a1 : 1 ratio. The admittance matrix Y bus(s) is then given by

Yik(s) =

Yi(s) +

N∑i 6=k

1

L`1`2s+R`1`2if i = k,

− 1

L`1`2s+R`1`2if i 6= k.

(30)

The indices are defined as `1 = i, `2 = k if i < k, `1 = k, `2 = i if i > k, or alternatively as

`1 = N − 1−⌊

1

2

(√(2N − 1)2 − 8`− 1

)⌋,

`2 = N − N(N − 1)

2+ `+

1

2

⌊1

2

(√(2N − 1)2 − 8`− 1

)⌋(⌊1

2

(√(2N − 1)2 − 8`− 1

)⌋+ 1

),

(31)

where ` = 1, . . . , N(N − 1)/2. In addition, i = 1, . . . , N and k = 1, . . . , N . Shunt elements are given as

Yi(s) = Cis/(CiRis + 1) + 1/Lis + 1/Ri. For this admittance matrix, a minimal state-space realization ofthe Laplace domain model in (20) can be represented as

ξ = Aξξ +Bξu

y = Cξξ +Dξu,(32)

where u = [Vd, Vq, V0]T, y = [Id, Iq, I0]T, and the matrices are defined as

Aξ =

[Adq 00 A0

], Bξ =

[Bdq 0

0 B0

],

Cξ =

[Cdq 00 C0

], Dξ =

[Ddq 0

0 D0

].

(33)

The system matrices can be schematically represented as follows.

42

dq components

State matrix Adq is represented as an N(N + 3)×N(N + 3)-dimensional block diagonal matrix

Adq =

− 1

CiRiωs 0 0 0 0

−ωs − 1

CiRi0 0 0 0

0 0 0 ωs 0 0

0 0 −ωs 0 0 0

0 0 0 0 −R`1`2

L`1`2ωs

0 0 0 0 −ωs −R`1`2

L`1`2

, (34)

where the first and the second blocks both have lengths i, and the third block is of the length `.

Input matrix Bdq is an N(N + 3)× 2N -dimensional matrix composed of three blocks

Bdq =[BTL BT

M BTR

]T(35)

such that

BL =

i i+N

i− 1

2Li0

0 − 12Li

, BM =

i i+N

i− 1

2CiR2i

0

0 − 1

2CiR2i

,

BR =

`1 `2 `1+N `2+N

`

12L`1`2

− 12L`1`2

0 0

0 0 12L`1`2

− 12L`1`2

.(36)

Output matrix Cdq is a 2N ×N(N + 3)-dimensional matrix composed of three blocks

Cdq =[CTL CT

M CTR

](37)

such that

CL =

i i+N

i2 0

0 2

, CM =

i i+N

i2 0

0 2

, CR =

`1 `2 `1+N `2+N

`2 −2 0 0

0 0 2 −2

. (38)

Feedthrough matrix Ddq is represented by a 2N × 2N diagonal matrix of the form

D0 = diag

(1

R1+

1

R1

, . . . ,1

RN+

1

RN,

1

R1+

1

R1

, . . . ,1

RN+

1

RN

). (39)

Zero component

State matrix A0 is represented as an N(N + 3)/2×N(N + 3)/2-dimensional block diagonal matrix

A0 =

− 1

CiRi0 0

0 0 0

0 0 −R`1`2

L`1`2

, (40)

43

where the first and the second blocks both have lengths i, and the third block is of the length `.

Input matrix B0 has N(N + 3)/2×N dimensions such that

B0 =[BTL BT

M BTR

]T, (41)

where

BL = −diag

(1

C1R21

, . . . ,1

CN R2N

), BM = diag

(1

L1, . . . ,

1

LN

), BR =

[ `1 `2

`1

L`1`2− 1L`1`2

]. (42)

Output matrix C0 has N ×N(N + 3)/2 dimensions such that

C0 =[CL CM CT

R

], (43)

where

CL = IN , CM = IN , CR =[ `1 `2

` 1 −1]. (44)

Feedthrough matrix D0 is represented by N ×N diagonal matrix of the form

D0 = diag

(1

R1+

1

R1

, . . . ,1

RN+

1

RN

). (45)

10.6 Small-signal models of units and feedback connection

The general scheme of the feedback connection is schematically depicted in Fig. 29.

unit

networku y

w

Figure 29: Feedback connection of the network and attached units.

Define a general small-signal model of a unit connected to the nth bus as

ϕn = Anϕn +Bnyn +Gnwn

un = Cnϕn +Dnyn,(46)

where inputs and outputs are5 yn = [id,n, iq,n, i0,n]T, un = [vd,n, vq,n, v0,n]T, and wn is a vector of externalsignals (such as the mechanical power input of a synchronous machine). A composite model that includesall the units in the network is given as

ϕ = Aϕϕ+Bϕy +Gϕw

u = Cϕϕ+Dϕy,(47)

where w = [w1, . . . , wN ]T is a vector of external signals, and system matrices are defined as

Aϕ = IN ⊗An, Bϕ = IN ⊗BnR,Cϕ = R−1IN ⊗ Cn, Dϕ = R−1IN ⊗DnR,Gϕ = IN ⊗Gn

(48)

5The general small-signal model is defined with current inputs and voltage outputs to be compatible with the transmissionnetwork model presented above. If the unit model uses voltages as inputs and currents as outputs, then these signals can beexchanged by integrating the line shunt capacitance into the unit’s model.

44

with ⊗ being the Kronecker product. The matrix R3N×3N is a routing matrix. It is required since thenetwork inputs are ordered as {Vd, Vq, V0}; however, the outputs of units are ordered as {Vdq0,1, . . . , Vdq0,N}.Therefore, it is necessary to route signals appropriately. The routing matrix R is constructed such that onesare placed on positions (i+ 3k, (i− 1)N + k + 1) for i = 1, 2, 3, k = 0, . . . , N − 1 and zeros elsewhere.

A state-space model describing the feedback between the transmission network and the units connected toit is obtained as follows. Elimination of u from (32) and (47) results in

ξ = Aξξ +BξCϕϕ+BξDϕy,

ϕ = Aϕϕ+Bϕy +Gϕw,

y = D (Cξξ +DξCϕϕ) ,

(49)

where D = (I −DξDϕ)−1. Next, the output variable y is eliminated from (49), yielding

ξ = (Aξ +BξDϕDCξ) ξ + (BξCϕ +BξDϕDDξCϕ)ϕ,

ϕ = BϕDCξξ + (Aϕ +BϕDDξCϕ)ϕ+Gϕw.(50)

The state-space model of the feedback-connected system is then given as

x = Ax+Bw, (51)

where x = [ξ, ϕ]T, and matrices A,B are defined as

A =

[Aξ +BξDϕDCξ BξCϕ +BξDϕDDξCϕ

BϕDCξ Aϕ +BϕDDξCϕ

](52)

and

B =

[0Gϕ

]. (53)

45