SimPowerSystems    
circ2ss

Compute the state space model of a linear electrical circuit

Synopsis

You must call circ2ss with a minimum of seven input arguments.

You can also specify additional arguments. To use options, the number of input arguments must be 12, 13, 14 or 16.

Description

The circ2ss command computes the state space model of a linear electrical circuit expressed as

where x is the vector of state space variables (inductor currents and capacitor voltages), u is the vector of voltage and current inputs, and y is the vector of voltage and current outputs.

When you build a circuit from Power System Blockset blocks of the powerlib library, circ2ss is automatically called by power2sys. circ2ss is also available as a stand-alone function for expert users. This allows you to generate state space models without using Power System Blockset graphical user interface and to access options that are not available through powerlib. For example, you can specify transformers and mutual inductances with more than three windings.

The linear circuit can contain any combination of voltage and current sources, RLC branches, multiwinding transformers, mutually coupled inductances, and switches. The state variables are inductor currents and capacitor voltages.

The state space representation (matrices A,B,C,D, and vector x0) computed by circ2ss can then be used in a Simulink system, via a State-Space block, to perform simulation of the electrical circuit (see Example section below). Nonlinear elements (mechanical or power electronic switches, transformer saturation, machines, distributed parameter lines, etc.) can be connected to the linear circuit.

These Simulink models are interfaced with the linear circuit through voltage outputs and current inputs of the state space model. You can find the models of the nonlinear elements provided with the Power System Blockset in the powerlib_models library (see the Advanced Topics chapter).

Input Arguments

The number of input arguments must be 7, 12, 13, 14, or 16. Arguments 8 to 16 are optional. The first seven arguments that must be specified are

The last nine arguments are optional. The first three are used to pass arguments from the power2sys function. Hereafter, only the arguments to be specified when circ2ss is used as a stand-alone function are described:

Output Arguments

The last lines of the states matrix, which are followed by an asterisk, indicate inductor currents and capacitor voltages that are not considered as state variables. This situation arises when inductor currents or capacitor voltages are not independent (inductors forming a cut set or capacitors forming a loop). The currents and voltages followed by asterisks can be expressed as a linear combination of the other state variables:

Format of the RLC Input Matrix

Two formats are allowed:

Each line of the RLC matrix must be specified according to the following format.

[node1, node2, type, R, L, C, Nobr] for RLC branch or line branch

[node1, node2, type, R, L, C, Nobr] for transformer magnetizing branch

[node1, node2, type, R, L, U, Nobr] for Transformer winding

[node1, node2, type, R, L, U, Nobr] for mutual inductances

For a mutual inductor or a transformer having N windings, N+1 consecutive lines must be specified in RLC matrix:

  1. N lines with type = 2 or type = 3; (one line per winding). Each line specifies R/L/U or R/Xl/Xc where [R/L, R/Xl = winding resistance and leakage reactance for a transformers or winding resistance and self reactance for mutually coupled windings. U is the nominal voltage of transformer winding (specify 0 if type = 3).
  2. One extra line with type = 1 for the magnetizing branch of a transformer (parallel Rm/Lm or Rm/Xm) or one line with type = 0 for a mutual impedance (series Rm/Lm or Rm/Xm).

For a transformer magnetizing branch or a mutual impedance, the first node number is an internal node located behind the leakage reactance of the first winding. The second node number must be the same as the second node number of the first winding.

To model a saturable transformer, you must use a nonlinear inductance instead of the linear inductance simulating the reactive losses. Set the Lm/Xm value to 0 (no linear inductance) and use the Transfosat block, set with proper flux-current characteristics.

This block can be found in the powerlib_models library. It must be connected to the linear part of the system (State-Space block or S-function) between a voltage output (voltage across the magnetizing branch) and a current input (current source injected into the transformer internal node). See the Example at the end of the circ2ss documentation.

If type is negative, its absolute value specifies the length (km) of a transmission line simulated by a PI section. For a transmission line, the R/L/C or R/Xl/Xc values must be specified in /km or , mH, or µF per km.

Parameter 
Description 
R
Branch resistance ()
Xl
Branch inductive reactance ( at freq_sys) or transformer winding leakage reactance ( at freq_sys)
L
Branch inductance (mH)
Xc
Branch capacitive reactance ( at freq_sys). The negative sign of Xc is optional.
C
Capacitance (µF)
U
Nominal voltage of transformer winding. Same units Volts or kV must be used for each winding. For a mutual inductance (type=3), this value must be set to zero.
  • Zero value for R, L or Xl, C or Xc in a series or parallel branch indicates that the corresponding element does not exist.

The following restrictions apply for transformer winding R-L values. Null values are not allowed for secondary impedances if some transformer secondaries form loops (as in a three-phase delta connection). Specify a very low value for R or L or both (e.g., 1e-6 p.u. based on rated voltage and power) to simulate a quasi-ideal transformer. The resistive and inductive parts of the magnetizing branch can be set to infinite (no losses; specify Xm = Rm = inf).

Format of the Source Input Matrix

Three formats are allowed:

Each line of the source matrix must be specified according to the following format:

Order in Which Sources Must Be Specified

The functions that compute the state space representation of a system expect the sources in a certain order. This order must be respected in order to obtain correct results. You must be particularly careful if the system contains any switches. The following list gives the proper ordering of sources:

  1. The currents form all switches that have a null inductance (Lon = 0), if any
  2. The currents from all nonlinear models that have a finite inductance (switches with Lon > 0, the magnetizing inductance in saturable transformers, etc.), if any
  3. All other voltage and current sources in any order, if any

Refer to the Example section below for an example illustrating proper ordering of sources for a system containing nonlinear elements.

Format of the Switches Input Matrix

Switches are nonlinear elements simulating mechanical or electronic devices such as circuit breakers, diodes, or thyristors. Like other nonlinear elements, they are simulated by current sources driven by the voltage appearing across their terminals. Therefore, they cannot have a null impedance. They are simulated as ideal switches in series with a series R-L circuit. Various models of switches (circuit breaker, ideal switch, and power electronic devices) are available in the powerlib_models library. They must be interconnected to the linear part of the system through appropriate voltage outputs and current inputs.

The switch parameters must be specified in a line of the switches matrix in seven different columns, according to the following format.

The next two fields specify the current input number and the voltage output number to be used for interconnecting the switch model to the state space block. The output number corresponding to the voltage across a particular switch must be the same as the input number corresponding to the current from the same switch (see Example section below):

Format of the Line_Dist Matrix

The distributed parameter line model contains two parts:

  1. A linear part containing current sources and resistances that are connected at the line sending and receiving buses together with the linear circuit.
  2. A nonlinear part available in the Dist_line block of the powerlib_models library. This block performs the phase-to-mode transformations of voltage and currents and simulates the transmission delays for each mode. The Dist_line block must be connected to appropriate voltage outputs and current inputs of the linear part of the system. The line parameters have to be specified in the line_dist matrix and also in the Dist_line block.

Each row of the line_dist matrix is used to specify a distributed parameter transmission line. The number of columns of line_dist depends on the number of phases of the transmission line.

For an nphase line, the first (4 + 3 * nphase + nphase^2) columns are used. For example, for a three-phase line, 22 columns are used.

Format of the Yout Matrix

The desired outputs are specified by a string matrix yout. Each line of the yout matrix must be an algebraic expression containing a linear combination of states and state derivatives, specified according to the following format:

Parameter 
Description 
Uc_bn
Capacitor voltage of branch n
Il_bn
Inductor current of branch n
dUc_bn
Derivative of Uc_bn or Il_bn
Un, In
Source voltage or current specified by line n of the source matrix
U_nx1_x2
Voltage between nodes x1 and x2
I_bn
Current in branch n. For a parallel RLC branch, I_bn corresponds to the total current IR + IL + IC
I_bn_nx
Current flowing into node x of a PI transmission line specified by line n of the RLC matrix. This current includes the series inductive branch current and the capacitive shunt current.

Each output expression is built from voltage and current variable names defined above, their derivatives, constants, other variable names, parentheses and operators (+-*/^), in order to form a valid MATLAB expression. For example:

If variable names are used (R1 and L2 in the above example), their names and values must be specified by the two input arguments vary_name and vary_val.

Sign Conventions for Voltages and Currents

Parameter 
Sign Convention 
I_bn, Il_bn, In
Branch current, inductor current of branch n, or current of source #n is oriented from node1 to node2.
I_bn_nx

Current at one end (node x) of a PI transmission line. If x = node1, the current is entering the line. If x = node2, the current is leaving the line.

Uc_bn, Un

Voltage across capacitor or source voltage (Unode1 - Unode2).

U_nx1_x2

Voltage between nodes x1 and x2 = Ux1 - Ux2. Voltage of node x1 with respect to node x2.

Order in Which Outputs Must Be Specified

The functions that compute the state space representation of a system expect the outputs to be in a certain order. This order must be respected in order to obtain correct results. You must be particularly careful if the system contains any switches. The following list gives the proper ordering of outputs:

  1. The voltages across all switches that have a null inductance (Lon = 0), if any
  2. The currents of all switches that have a null inductance (Lon = 0), if any, in the same order as the voltages above
  3. The voltages across all nonlinear models that have a finite inductance (switches with Lon > 0, the magnetizing inductance in saturable transformers, etc.)
  4. All other voltage and current measurements that you request, in any order

Refer to the Example section below for an example illustrating proper ordering of outputs for a system containing nonlinear elements.

Example

The following circuit consists of two sources (one voltage source and one current source), two series RLC branches (R1-L1 and C6), two parallel RLC branches (R5-C5 and L7-C7), one saturable transformer, and two switches (Sw1 and Sw2). Sw1 is initially closed whereas Sw2 is initially open. Three measurement outputs are specified (I1, V2, and V3). This circuit has seven nodes numbered 0, 1, 2, 2.1, 10, 11, and 12. Node 0 is used for the ground. Node 2.1 is the internal node of the transformer where the magnetization branch is connected.

Linear state space.   You can use the circ2ss function to find the state space model of the linear part of the circuit. The nonlinear elements Sw1, Sw2, and Lsat must be modeled separately by means of current sources driven by the voltage appearing across their terminals. Therefore you must provide three additional currents sources and three additional voltage outputs for interfacing the nonlinear elements to the linear circuit.

You can find the state space model of the circuit by entering the following commands in a MATLAB script file. The example is available in the psbcirc2ss.m file. Notice that an output text file containing information on the system is requested in the call to circ2ss.

Command line messages.   While circ2ss is executing the following messages are displayed.

State space output.   The names of the state variables are returned in the states string matrix.

Although this circuit contains a total of six inductors and capacitors, there are only four state variables. The names of the state variables are given by the first four lines of the states matrix. The last two lines are followed by an asterisk indicating that these two variables are a linear combination of the state variables. The dependencies can be viewed in the output file psbcirc2ss.net.

The A,B,C,D matrices contain the state space model of the circuit without nonlinear elements (all switches open). The x0 vector contains the initial state values considering the switch Sw1 closed. The Asw, Bsw, Csw, and Dsw matrices contain the state space model of the circuit considering the closed switch Sw1. The x0sw vector contains the initial current in the closed switch.

The system source frequencies are returned in the freq vector.

The corresponding steady state complex outputs are returned in the (6-by-3) y matrix where each column corresponds to a different source frequency.

For example, you can obtain the magnitude of the six voltage and current outputs at 60 Hz as follows:

The initial values of the four state variables are returned in the x0 vector. You must use this vector in the State-Space block to start the simulation in steady state.

The initial values of switch currents are returned in x0sw. To start the simulation in steady state you must use these values as initial currents for the nonlinear model simulating the switches.

The Simulink model of the circuit shown in the following figure is available in the psbcirc2ss_slk.mdl file. The linear part of the circuit is simulated by the sfun_psbcontc S-function. Appropriate inputs and outputs are used to connect the switch and saturable reactance models to the linear system. Notice that the status of each switch is fed back from the breaker block to the S-function, after the inputs mentioned earlier. You can find the Breaker and Transfosat blocks in the powerlib_models, library containing all the nonlinear models used by the blockset. As the breaker model is vectorized, a single block is used to simulate the two switches Sw1 and Sw2.

If you use the powerlib library to build your circuit, the same Simulink system is generated automatically by the power2sys function. The powerlib version of this system is also available in the psbcirc2ss_psb.mdl file and is shown below.

Figure 5-1: psbcirc2ss_slk.mdl Example Diagram

Figure 5-2: psbcirc2ss_psb.mdl Example Diagram

See Also

power2sys


  Power System Command Reference power2sys