Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions pypower/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
PyPOWER Flow Diagram
```mermaid
flowchart TD

subgraph pypower

option ---> runpf
option ---> runopf
option --> rundcopf

rundcopf --> runopf

runpf --> fdpf
runpf --> newtonpf
runpf --> gausspf

newtonpf -----> pplinsolve

runopf --> opf
opf --> opf_setup
opf --> opf_execute

opf_execute --> pipsopf_solver

pipsopf_solver --> pips

pips --> pplinsolve
end

fdpf ------> solve
pplinsolve --> factor_solve

subgraph scipy
solve
end

subgraph pyrlu
factor_solve
end
```
3 changes: 2 additions & 1 deletion pypower/opf_costfcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def opf_costfcn(x, om, return_hessian=False):

## polynomial cost of P and Q
df_dPgQg = zeros(2 * ng) ## w.r.t p.u. Pg and Qg
df_dPgQg[ipol] = baseMVA * polycost(gencost[ipol, :], xx[ipol], 1)
if len(ipol):
df_dPgQg[ipol] = baseMVA * polycost(gencost[ipol, :], xx[ipol], 1)
df = zeros(nxyz)
df[iPg] = df_dPgQg[:ng]
df[iQg] = df_dPgQg[ng:ng + ng]
Expand Down
5 changes: 3 additions & 2 deletions pypower/opf_hessfcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ def opf_hessfcn(x, lmbda, om, Ybus, Yf, Yt, ppopt, il=None, cost_mult=1.0):
d2f_dPg2 = zeros(ng)#sparse((ng, 1)) ## w.r.t. p.u. Pg
d2f_dQg2 = zeros(ng)#sparse((ng, 1)) ## w.r.t. p.u. Qg
ipolp = find(pcost[:, MODEL] == POLYNOMIAL)
d2f_dPg2[ipolp] = \
if len(ipolp):
d2f_dPg2[ipolp] = \
baseMVA**2 * polycost(pcost[ipolp, :], Pg[ipolp] * baseMVA, 2)
if any(qcost): ## Qg is not free
if qcost.any(): ## Qg is not free
ipolq = find(qcost[:, MODEL] == POLYNOMIAL)
d2f_dQg2[ipolq] = \
baseMVA**2 * polycost(qcost[ipolq, :], Qg[ipolq] * baseMVA, 2)
Expand Down
2 changes: 1 addition & 1 deletion pypower/qps_cplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def qps_cplex(H, c, A, l, u, xmin, xmax, x0, opt):

cplex = Cplex('null')
vstr = cplex.getVersion
s, e, tE, m, t = re.compile(vstr, '(\d+\.\d+)\.')
s, e, tE, m, t = re.compile(vstr, r'(\d+\.\d+)\.')
vnum = int(t[0][0])
vrb = max([0, verbose - 1])
cplex_opt['barrier']['display'] = vrb
Expand Down
2 changes: 1 addition & 1 deletion pypower/qps_mosek.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def qps_mosek(H, c=None, A=None, l=None, u=None, xmin=None, xmax=None,
# MOSEK Version 6.0.0.93 (Build date: 2010-10-26 13:03:27)
# MOSEK Version 6.0.0.106 (Build date: 2011-3-17 10:46:54)
# pat = 'Version (\.*\d)+.*Build date: (\d\d\d\d-\d\d-\d\d)';
pat = 'Version (\.*\d)+.*Build date: (\d+-\d+-\d+)'
pat = r'Version (\.*\d)+.*Build date: (\d+-\d+-\d+)'
s, e, tE, m, t = re.compile(eval('mosekopt'), pat)
if len(t) == 0:
vn = '<unknown>'
Expand Down
4 changes: 2 additions & 2 deletions pypower/scale_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from sys import stderr

from numpy import array, zeros, arange, in1d, ix_
from numpy import array, zeros, arange, isin, ix_
from numpy import flatnonzero as find

from scipy.sparse import csr_matrix as sparse
Expand Down Expand Up @@ -179,7 +179,7 @@ def scale_load(load, bus, gen=None, load_zone=None, opt=None):
for k in range(len(scale)):
idx = find(load_zone == k + 1)
gbus = gen[ld, GEN_BUS].astype(int)
i = find( in1d(e2i[gbus], idx) )
i = find( isin(e2i[gbus], idx) )
ig = ld[i]

gen[ix_(ig, [PG, PMIN])] = gen[ix_(ig, [PG, PMIN])] * scale[k]
Expand Down
4 changes: 2 additions & 2 deletions pypower/t/t_scale_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from os.path import dirname, join

from numpy import array, zeros, in1d, vstack, flatnonzero as find
from numpy import array, zeros, isin, vstack, flatnonzero as find

from pypower.loadcase import loadcase
from pypower.isload import isload
Expand Down Expand Up @@ -42,7 +42,7 @@ def t_scale_load(quiet=False):
lda = [None] * 3
for k in range(3):
a[k] = find(ppc['bus'][:, BUS_AREA] == k + 1) ## buses in area k
tmp = find( in1d(ppc['gen'][ld, GEN_BUS] - 1, a[k]) )
tmp = find( isin(ppc['gen'][ld, GEN_BUS] - 1, a[k]) )
lda[k] = ld[tmp] ## disp loads in area k

area = [None] * 3
Expand Down
4 changes: 2 additions & 2 deletions pypower/t/t_total_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from os.path import dirname, join

from numpy import array, zeros, r_, in1d, vstack, flatnonzero as find
from numpy import array, zeros, r_, isin, vstack, flatnonzero as find

from pypower.loadcase import loadcase
from pypower.isload import isload
Expand Down Expand Up @@ -41,7 +41,7 @@ def t_total_load(quiet=False):
lda = [None] * 3
for k in range(3):
a[k] = find(ppc['bus'][:, BUS_AREA] == k + 1) ## buses in area k
tmp = find( in1d(ppc['gen'][ld, GEN_BUS] - 1, a[k]) )
tmp = find( isin(ppc['gen'][ld, GEN_BUS] - 1, a[k]) )
lda[k] = ld[tmp] ## disp loads in area k

area = [None] * 3
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='PYPOWER',
version='5.1.20',
version='5.1.21',
author='Richard Lincoln',
author_email='r.w.lincoln@gmail.com',
description='Solves power flow and optimal power flow problems',
Expand Down