This codebase implements the DistFlow Equations in both single and multiphase with a loss parameterization.
The main function is distflow_lossy
which takes a MATPOWER case and possible options structure as input.
To run the lossless DistFlow simply use:
[v, pf, qf] = distflow_lossy(mpc);
Paramerization options are available via the opt
function.
For example,
opt = struct('alpha_method', 7, 'alpha', [0.483, 0.499]);
[v, pf, qf] = distflow_lossy(mpc, opt);
The main function is distflow_multi
, which takes structure arrays bus
and branch
as arguments as well as a possible opt
structure.
Description of the data format is available in the functions.
To run DistFlow using the lossless approximation simply use:
[rbus, rbranch] = distflow_multi(bus, branch);
Parametrization options are available via the opt
structure.
For example,
opt = struct('alpha_method', 11, 'alpha', [0.492, 0.501]);
[rbus, rbranch] = distflow_multi(bus, branch, opt);
Some example data structures are available:
IEEE_13.mat
IEEE_34.mat
IEEE_37.mat
IEEE_123.mat
It is also possible to export the system matrices from the disflow_lossy
function.
With the help of the getsigma
function, multiple loadflows for various loading scenarios can be calculated with less redundancy.
To do this, the mats_gen
field of the options structure needs to be set to 1 (opt.mats_gen=1
), and 6 output arguments specified.
As an example:
opt = struct('alpha_method', 12, 'alpha', [0.498, 0.5], 'mats_gen', 1);
[Beta, K, zeta, eta, v0, conn] = distflow_multi(bus, branch,opt);
The constant power load vector can be generated as:
sigma = getsigma(bus);
And the voltage solution is:
nu = (Beta*conn.M - K)\(Beta*conn.M*v0 + zeta*sigma + eta*conj(sigma));
v = sqrt(real(conn.U*nu));
- The matrix
Beta*conn.M - K
can be factored in advance, in which case for newsigma
vectors, this becomes a simple matrix multiplication. As an example:
[L,U] = lu(Beta*conn.M - K);
Linv = inv(L); %alternatively Linv = L\speye(size(L,1));
Uinv = inv(U); %alternatively Uinv = U\speye(size(U,1));
nu = Uinv*Linv*(Beta*conn.M*v0 + zeta*sigma + eta*conj(sigma));
Depending on the size of the matrices and sparsity patterns this version may be faster, or the original one with the backslash operator.
- This method should generally be used with
opt.alpha_method=12
oropt.alpha_method=1
as in both cases load is not included in the other matrices. Otherwise, much of the benefit is lost. - If any constant impedance loads change, the
K
matrix is impacted. If this happens very frequenly, again some of the benefits may be lost. For occasional changes however, theupdateKmat
function is available, which profides the new matrix by callingK = updateKmat(bus, branch, conn)
- If for whatever reason the reference voltage changes, the
v0
vector can be recreated using the functionv0 = v0update(bus, branch)