Code Monkey home page Code Monkey logo

pypower's Introduction

PYPOWER is a power flow and Optimal Power Flow (OPF) solver. It is a port of MATPOWER to the Python programming language. Current features include:

  • DC and AC (Newton's method & Fast Decoupled) power flow and
  • DC and AC optimal power flow (OPF)

Status

libraries_   pyversions_   license_   downloads_   travis_   pypi_version_

PYPOWER is no longer actively maintained. However, should improvements to PYPOWER be required then the original author may be available on contract. Please do not hesitate to get in contact directly.

Prerequisites

PYPOWER depends upon these prerequisites on the level of the operating system:

Virtual Environment

PYPOWER is recommended to be installed into a virtual environment:

$ python3.8 -m venv venv  # Or any supported Python version

Dependencies

PYPOWER depends upon SciPy, which can be installed as follows:

$ venv/bin/python -m pip install -r requirements.txt

Installation

The recommended way of installing PYPOWER is using pip:

$ venv/bin/python -m pip install PYPOWER

Alternatively, download and unpack the tarball and install:

$ tar zxf PYPOWER-5.x.y.tar.gz
$ venv/bin/python setup.py install

Testing

PYPOWER can be tested locally using the same tooling as on Travis CI:

$ venv/bin/python -m tox -e py27,py38  # Or any supported Python version

Using PYPOWER

Installing PYPOWER creates pf and opf commands. To list the command options:

$ venv/bin/pf -h

or:

$ venv/bin/opf -h

PYPOWER includes a selection of test cases. For example, to run a power flow on the IEEE 14 bus test case:

$ venv/bin/pf -c case14

Alternatively, the path to a PYPOWER case data file can be specified:

$ venv/bin/pf /path/to/case14.py

The opf command has the same calling syntax. For example, to solve an OPF for the IEEE Reliability Test System and write the solved case to file:

$ venv/bin/opf -c case24_ieee_rts --solvedcase=rtsout.py

For further information please refer to https://rwl.github.io/PYPOWER/ and the API documentation.

Support

Questions and comments regarding PYPOWER should be directed to the mailing list:

[email protected]

License & Copyright

Copyright (c) 1996-2015, Power System Engineering Research Center (PSERC) Copyright (c) 2010-2021 Richard Lincoln

The code in PYPOWER is distributed under the 3-clause BSD license below. The PYPOWER case files distributed with PYPOWER are not covered by the BSD license. In most cases, the data has either been included with permission or has been converted from data available from a public source.

While not required by the terms of the license, we do request that publications derived from the use of MATPOWER explicitly acknowledge that fact by citing:

R. D. Zimmerman, C. E. Murillo-Sanchez, and R. J. Thomas, "MATPOWER: Steady-State Operations, Planning and Analysis Tools for Power Systems Research and Education," Power Systems, IEEE Transactions on, vol. 26, no. 1, pp. 12–19, Feb. 2011.

Links

pypower's People

Contributors

bdw avatar behrouzsohrabi avatar bengt avatar chengts95 avatar dependabot[bot] avatar friederikemeier avatar heiner92 avatar jdedecca avatar kdheepak avatar nickpowersys avatar rwl avatar snperkin avatar sscherfke avatar susantoj avatar temcdrm avatar wyzdwdz avatar yasirroni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pypower's Issues

Ipopt test doesn't pass--too many arguments to nlp.solve.

I'm trying to use the Ipopt solver but am wondering if you made local changes to your pyipopt package. Specifically, solve only takes two arguments, x0 and userdata. What version of pyipopt and Ipopt are you using?

In ipopt_solver.m:

x, zl, zu, obj, status, zg = nlp.solve(x0, m, userdata)

Thank you for your great work on this port.

Bugs in makeYbus.py, lines 35-36 and lines 66-67

if any(bus[:, BUS_I] != list(range(nb))): stderr.write('buses must appear in order by bus number\n')
Should be:
if any(bus[:, BUS_I] != list(range(1, nb+1))): stderr.write('buses must appear in order by bus number\n')
Also:
f = branch[:, F_BUS] t = branch[:, T_BUS]
Should be:
f = branch[:, F_BUS] - ones(nl) t = branch[:, T_BUS] - ones(nl)

Value error when running case30pwl for OPF

As reported by Minjiang Chen on the mailing list:

But when I tried to run OPF for the ‘case30pwl’, I has an error which I will show details below. I also tried to run with PF for the ‘case30pwl’, it is fine.

And I also run other cases which are using the polynomial ‘gencost’, they are all working on opf mode.

Here are the code I run:

from pypower.api import runopf, loadcase

ppc = loadcase('case30pwl')
r = runopf(ppc)

Here are the error I got:

            PYPOWER Version 4.1.2, 27-Oct-2014 -- AC Optimal Power Flow

Traceback (most recent call last):

            File "D:\Minjiang\PhD\Research Progress\Programming\PyPower\Work1\Test5.py", line 13, in <module>
             r = runopf(ppc)
            File "C:\Python27\lib\site-packages\pypower-4.1.2-py2.7.egg\pypower\runopf.py", line 44, in runopf
             r = opf(casedata, ppopt)
            File "C:\Python27\lib\site-packages\pypower-4.1.2-py2.7.egg\pypower\opf.py", line 185, in opf
            results, success, raw = opf_execute(om, ppopt)
            File "C:\Python27\lib\site-packages\pypower-4.1.2-py2.7.egg\pypower\opf_execute.py", line 94, in opf_execute
            results, success, raw = pipsopf_solver(om, ppopt)
            File "C:\Python27\lib\site-packages\pypower-4.1.2-py2.7.egg\pypower\pipsopf_solver.py", line 147, in pipsopf_solver
            solution = pips(f_fcn, x0, A, l, u, xmin, xmax, gh_fcn, hess_fcn, opt)
            File "C:\Python27\lib\site-packages\pypower-4.1.2-py2.7.egg\pypower\pips.py", line 275, in pips
            f, df = f_fcn(x)                 # cost
         File "C:\Python27\lib\site-packages\pypower-4.1.2-py2.7.egg\pypower\pipsopf_solver.py", line 143, in <lambda>
            f_fcn = lambda x, return_hessian=False: opf_costfcn(x, om, return_hessian)
            File "C:\Python27\lib\site-packages\pypower-4.1.2-py2.7.egg\pypower\opf_costfcn.py", line 118, in opf_costfcn
            df_dPgQg[ipol] = baseMVA * polycost(gencost[ipol, :], xx[ipol], 1)
            File "C:\Python27\lib\site-packages\pypower-4.1.2-py2.7.egg\pypower\polycost.py", line 48, in polycost
            maxN = max( gencost[:, NCOST].astype(int) )

ValueError: max() arg is an empty sequence

I didn’t change anything in the ‘case30pwl’.

Use tox to verify that tests pass on all supported python versions.

You just need to pip install tox add a tox.ini in your main directory:

[tox]
envlist = py26,py27,py33,py34

[testenv]
deps = numpy scipy
commands = python pypower/t/test_pypower.py

Then run tox from within your main directory. It will create a virtualenv for each interpreter and execute the tests with that vm. See https://pypi.python.org/pypi/tox for details.

Note: This would work very well along with py.test. Your tox.ini would then look like:

[tox]
envlist = py26,py27,py33,py34

[testenv]
deps = pytest numpy scipy
commands = py.test

pylon case

import sys
import logging
import pylon
logging.basicConfig(stream=sys.stdout, level=logging.debug)
case=pylon.Case.load_Matpower("c:\data\case30pwl.m")

Traceback (most recent call last):
File "<pyshell#4>", line 1, in
case=pylon.Case.load_Matpower("c:\data\case30pwl.m")
AttributeError: type object 'Case' has no attribute 'load_Matpower'

PF and OPF results conflicting

Dear all,

I run an OPF and pass the solved case over to a PF solver. Then, the PF solver iterates. This should not be happening (I have established that after a discussion with Zimmerman), since the OPF solution is also a PF solution.

In older versions of MATPOWER this would happen because the OPF solver would not update the generator voltage setpoints. I did some checking and this does not seem to be the case in PYPOWER.

Minimal example:

from pypower.api import case14, runopf , runpf , ppoption
opt = ppoption(VERBOSE=2)
mpc = runpf(runopf(case14(), opt), opt)

LODF First Column Error

As reported by Xiang Lu on the mailing list:

from pypower.ext2int import ext2int1
from pypower.makePTDF import makePTDF
from pypower.makeLODF import makeLODF
from pypower.rundcpf import rundcpf
from pypower.idx_brch import BR_STATUS, PF
from pypower.loadcase import loadcase
from pypower.case9 import case9
ppc=loadcase(case9())
r=rundcpf(ppc)

baseMVA, bus, gen, branch = r[0]['baseMVA'], r[0]['bus'], r[0]['gen'], r[0]['branch']

_, bus, gen, branch = ext2int1(bus, gen, branch)

F0 = branch[:, PF]

H=makePTDF(baseMVA, bus, branch, 0)  ## H is correct

LODF = makeLODF(branch, H)

The resulted LODF is as follows:

array([[             nan,   1.64313008e-15,   8.89223335e-16,
                 nan,  -1.49968221e-15,   0.00000000e+00,
                 nan,  -1.40839721e-15,   8.89223335e-16],
   [             inf,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00],
   [             inf,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00],
   [             nan,   0.00000000e+00,   0.00000000e+00,
                 nan,   0.00000000e+00,   0.00000000e+00,
                 nan,   0.00000000e+00,   0.00000000e+00],
   [            -inf,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00],
   [             inf,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00],
   [             nan,   0.00000000e+00,   0.00000000e+00,
                 nan,   0.00000000e+00,   0.00000000e+00,
                 nan,   0.00000000e+00,   0.00000000e+00],
   [            -inf,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00],
   [             inf,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00,
                 nan,  -1.00000000e+00,  -1.00000000e+00]])

Getting ValueError: Shape mismatch Error when running OPF

I am receiving the following error when running an OPF
ValueError: shape mismatch: value array of shape (32,) could not be broadcast to indexing result of shape (16,2)

This is for a 15 bus system, the gencost array looks like this:

ppc["gencost"] = array([
[1, 0, 0, 2, 86., 1462., 430, 7310],
[1, 0, 0, 2, 86., 1204., 430, 6020],
[1, 0, 0, 2, 85., 1955., 425, 9775],
[1, 0, 0, 2, 85., 1445., 425, 7225],
[1, 0, 0, 2, 73., 1168., 365, 5840],
[1, 0, 0, 2, 73., 2920., 365, 14600],
[1, 0, 0, 2, 73., 1971., 365, 9855],
[1, 0, 0, 2, 79.8, 2872.8, 399, 14364],
[1, 0, 0, 2, 79.8, 1436.4, 399, 7182],
[1, 0, 0, 2, 79.8, 2633.4, 399, 13167],
[1, 0, 0, 2, 79.8, 2872.8, 399, 14364],
[1, 0, 0, 2, 79.8, 2234.4, 399, 11172],
[1, 0, 0, 2, 80., 1520., 400, 7600],
[1, 0, 0, 2, 80., 1440., 400, 7200],
[1, 0, 0, 2, 81.4, 1221., 407, 6105],
[1, 0, 0, 2, 81.4, 3093.2, 407, 15466]
])

Please help!

runpf

import pypower
from pypower.case24_ieee_rts import case24_ieee_rts
from pypower.runpf import runpf
c = case24_ieee_rts()
results, success = runpf(c)

Traceback (most recent call last):
File "<pyshell#5>", line 1, in
results, success = runpf(c)
File "build\bdist.win32\egg\pypower\runpf.py", line 96, in runpf
ppc = ext2int(ppc)
File "build\bdist.win32\egg\pypower\ext2int.py", line 150, in ext2int
o["areas"]["status"]["on"] = find( ar )
KeyError: 'areas'

ext2int function: bus numbering requires integer values instead of float numbers

I found a issue in the "ext2int" function related to false indexing of the consecutive bus numbering in row 152 (see following code). The dictonary data type requires integer indices instead of float numbers that are used currently.
The issue appears with the latest numpy version "1.12.0" (it doesn't ignore anymore false indexing with float numbers).

Current implementation (error appears in row 152):

## apply consecutive bus numbering
           o["bus"]["i2e"] = ppc["bus"][:, BUS_I].copy()
           o["bus"]["e2i"] = zeros(max(o["bus"]["i2e"]) + 1)

Manual fix by changing the code in row 151 (it's not pretty, I know, but it works):

## apply consecutive bus numbering
            o["bus"]["i2e"] = ppc["bus"][:, BUS_I].copy().astype(int)
            o["bus"]["e2i"] = zeros(max(o["bus"]["i2e"]) + 1)

IndexError due to 'ext2int.py' of 'runpf.py'

Dear Author, i am trying to run a repository that utilizes the PYPOWER's opf.py file to run power flow but when it calls the 'ext2int.py' to convert to continuous indexing starting from 0,it gives following error. IndexError: index 23 is out of bounds for axis 0 with size 23. if ou could help me resolve this issue, i would be thankful to you and it will assist to my phd research. Thanks for consideration.

pf not found

I installed PYPOWER along with numpy and scipy using pip install, and after that I tried running pf -h and I got the error
Traceback (most recent call last):
File "<pyshell#18>", line 1, in
pf -h
NameError: name 'pf' is not defined.

Even I tried to used runpf(ppe) by loading the case9 into ppe, and I got the error.
My code
from pypower.api import case9, ppoption,runpf,printpf
ppc = case9()
#ppopt = ppoption(PF_ALG=2)
r = runpf(ppc)
printpf(r)

error:
Traceback (most recent call last):
File "C:\Python27\test.py", line 4, in
r = runpf(ppc)
File "C:\Python27-64\lib\site-packages\pypower\runpf.py", line 95, in runpf
ppc = ext2int(ppc)
File "C:\Python27-64\lib\site-packages\pypower\ext2int.py", line 152, in ext2int
o["bus"]["e2i"] = zeros(max(o["bus"]["i2e"]) + 1)
TypeError: 'numpy.float64' object cannot be interpreted as an index.

Please help. Thanks in advance

Singular matrix error when solving simple 6 bus system

As reported by Dominik on the mailing list:

When including more than one generator in my grid, I get an error of creating a singular matrix:

[...]
  File "pypower\runpf.py", line 183, in runpf
    V, success, _ = newtonpf(Ybus, Sbus, V0, ref, pv, pq, ppopt)
  File "pypower\newtonpf.py", line 101, in newtonpf
    dx = -1 * spsolve(J, F)
  File "C:\WinPython-64bit-2.7.9.1\python-2.7.9.amd64\lib\site-packages\scipy\sparse\linalg\dsolve\linsolve.py", line 143, in spsolve
    b, flag, options=options)
RuntimeError: superlu failure (singular matrix?) at line 100 in file scipy\sparse\linalg\dsolve\SuperLU\SRC\dsnode_bmod.c

This does however not happen when solving the exact same case using MATPOWER after exporting it using 'savecase'.

def Testcase36():

    ## PYPOWER Case Format : Version 2
    ppc = {'version': '2'}

    ##-----  Power Flow Data  -----##
    ## system MVA base
    ppc['baseMVA'] = 10

    ## bus data
    # bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
    ppc['bus'] = array([
        [1, 3, 0, 0, 0, 0, 1, 1.02, 0, 20, 1, 1.06, 0.98],
        [2, 1, 0, 0, 0, 0, 1, 1, -150, 0.4, 1, 1.1, 0.9],
        [3, 1, 0.0006, 0, 0, 0, 1, 1, -150, 0.4, 1, 1.1, 0.9],
        [4, 1, 0, 0, 0, 0, 1, 1, -150, 0.4, 1, 1.1, 0.9],
        [5, 1, 0, 0, 0, 0, 1, 1, -150, 0.4, 1, 1.1, 0.9],
        [6, 1, 0, 0, 0, 0, 1, 1, -150, 0.4, 1, 1.1, 0.9],
    ])

    ## generator data
    # bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf
    ppc['gen'] = array([
        [1, 0, 0, 10, -10, 1.02, 10, 1, 10, -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [2, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [3, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [4, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [5, 0.00104344028, -0, -0, -0, 0, 10, 1, 0.00104344028, 0.00104344028, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [6, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    ])

    ## branch data
    # fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax
    ppc['branch'] = array([
        [1, 2, 2.52, 5.17949805, 0, 0.1, 0.1, 0.1, 1, 150, 1, -360, 360],
        [2, 3, 2.253125, 0.879645943, 0, 0.190525589, 0.190525589, 0.190525589, 0, 0, 1, -360, 360],
        [3, 4, 0.721125, 0.0954258769, 0, 0.0997661265, 0.0997661265, 0.0997661265, 0, 0, 1, -360, 360],
        [3, 5, 2.253125, 0.879645943, 0, 0.190525589, 0.190525589, 0.190525589, 0, 0, 1, -360, 360],
        [5, 6, 1.3220625, 0.174947441, 0, 0.0997661265, 0.0997661265, 0.0997661265, 0, 0, 1, -360, 360],
    ])

    return ppc

Traceback occurs when using printpf() function

Python files used when the traceback occurred are attached as .txt files.
params_banshee_f1.txt
run_banshee_f1.txt

Traceback (most recent call last):
File "C:/Users/[...]/POWER FLOW/run_banshee_f1.py", line 26, in
printpf(r)
File "C:\Python36\lib\site-packages\pypower\printpf.py", line 128, in printpf
i2e = bus[:, BUS_I].astype(int)
TypeError: 'NoneType' object is not subscriptable

Losses incorrectly calculated

As reported by Dominik on the mailing list:

When running a Powerflow in a very simple network of only 4 busses PYPOWER delivers the exact same result as when running the case in MATPOWER, however in its output it estimates an enormous power loss in the first branch, which is obviously false. (0.79MW compared to a value below 1kW).

def Testcase99():

    ## PYPOWER Case Format : Version 2
    ppc = {'version': '2'}

    ##-----  Power Flow Data  -----##
    ## system MVA base
    ppc['baseMVA'] = 10

    ## bus data
    # bus_i type Pd Qd Gs Bs area Vm Va baseKV zone Vmax Vmin
    ppc['bus'] = array([
        [1, 3, 0, 0, 0, 0, 1, 1.02, 0, 20, 1, 1.06, 0.98],
        [2, 1, 0, 0, 0, 0, 1, 1, -150, 0.4, 1, 1.1, 0.9],
        [3, 1, 0.000425005103, 0, 0, 0, 1, 1, -150, 0.4, 1, 1.1, 0.9],
        [4, 1, 0, 0, 0, 0, 1, 1, -150, 0.4, 1, 1.1, 0.9],
    ])

    ## generator data
    # bus Pg Qg Qmax Qmin Vg mBase status Pmax Pmin Pc1 Pc2 Qc1min Qc1max Qc2min Qc2max ramp_agc ramp_10 ramp_30 ramp_q apf
    ppc['gen'] = array([
        [1, 0, 0, 10, -10, 1.02, 10, 1, 10, -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [2, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [3, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [4, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    ])

    ## branch data
    # fbus tbus r x b rateA rateB rateC ratio angle status angmin angmax
    ppc['branch'] = array([
        [1, 2, 2.52, 5.17949805, 0, 0.1, 0.1, 0.1, 1, 150, 1, -360, 360],
        [2, 3, 2.253125, 0.879645943, 0, 0.190525589, 0.190525589, 0.190525589, 0, 0, 1, -360, 360],
        [3, 4, 0.721125, 0.0954258769, 0, 0.0997661265, 0.0997661265, 0.0997661265, 0, 0, 1, -360, 360],
    ])

    return ppc

Cannot printpf with a pf result

Hello,

When I tried the source code as in the tutorial http://www.pypower.org/usage.html, I got an error with printpf as follows
In [5]: printpf(r)

Traceback (most recent call last):
File "", line 1, in
File "/ufs/luong/.local/lib/python2.7/site-packages/PYPOWER-4.0.1-py2.7.egg/pypower/printpf.py", line 139, in printpf
i2e = bus[:, BUS_I].astype(int)
TypeError: 'NoneType' object has no attribute 'getitem'

Note that if r is a result returned from a runopf then there is no problem printing it. But if r is a result return from runpf then I got the above error message.

pypower.org is down

Following the API Documentation link http://www.pypower.org/api leads to a page that says "The domain pypower.org is for sale. To purchase, call ******. Click here for more details".

Unfortunately, this also means that the API documentation not available.

Improve test suite to use py.test (or something similar)

It would be nice if Pypower's test suite would support a test runner like pytest. This would make it a lot easier run only certain tests or skip certain tests.

In most cases, it should be sufficent to rename all files and methods from "t__" to "test__" and use simple assert statements.

IPOPT interface in Pypower

OPF is an important feature of Pypower. Pypower has kindly provided interface to IPOPT through pyIPOPT. However, in recent Python version, e.g., python 3.8, pyIPOPT is no longer supported. Is is possible to update the python-IPOPT interface? Thanks!

makeYbus uses one-indexing

makeYbus fails when using pypower test cases due to one-indexing issues. For instance, for:

import pypower.api as pp ppc = pp.case14() baseMVA, bus, branch = ppc['baseMVA'], ppc['bus'], ppc['branch'] pp.makeYbus(baseMVA, bus, branch)

The output is
buses must appear in order by bus number Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/priyadonti/anaconda2/envs/acopf/lib/python3.7/site-packages/pypower/makeYbus.py", line 71, in makeYbus Ct = csr_matrix((ones(nl), (range(nl), t)), (nl, nb)) File "/Users/priyadonti/anaconda2/envs/acopf/lib/python3.7/site-packages/scipy/sparse/compressed.py", line 51, in __init__ other = self.__class__(coo_matrix(arg1, shape=shape)) File "/Users/priyadonti/anaconda2/envs/acopf/lib/python3.7/site-packages/scipy/sparse/coo.py", line 192, in __init__ self._check() File "/Users/priyadonti/anaconda2/envs/acopf/lib/python3.7/site-packages/scipy/sparse/coo.py", line 274, in _check raise ValueError('column index exceeds matrix dimensions') ValueError: column index exceeds matrix dimensions

FIXES:

Line 66 should be
f = branch[:, F_BUS] - 1
and line 67 should be
t = branch[:, T_BUS] - 1

Additionally, the check in line 35 should be
if any(bus[:, BUS_I] != list(range(1, nb+1))):

TypeError: 'dict' object is not callable

from pypower.case24_ieee_rts import case24_ieee_rts
from pypower.runpf import runpf

c = case24_ieee_rts()
results, success = runpf(c)

Traceback (most recent call last):
File "<pyshell#13>", line 1, in
results, success = runpf(c)
File "build\bdist.win32\egg\pypower\runpf.py", line 79, in runpf
ppopt = ppoption() if ppopt is None else ppopt
TypeError: 'dict' object is not callable

Somebody could you help me?

savecase fails when solving OPF of IEEE RTS from command line

As reported by Prabakaran on the mailing list:

I recently installed PYPOWER in my Ubuntu 14.04, Python 2.7.6, scipy 0.13.3 and ran the sample commands given in GitHub project page's readme. When running the command,

$ opf -c case24_ieee_rts --solvedcase=rtsout.py

to solve an OPF for the IEEE Reliability Test System and write the solved case to file.

How to warm start an AC OPF solution?

Hi,

I'm trying to warm start a solution, but it doesn't seem to have any effect

warm_started_ppc = runopf(warm_ppc, ppopt=ppopt)

What I've done is set all the variables in the bus and gen table with a warm solution thinking that the solver will start from there.
However, when measuring the time to solve the ppc now, I get the same time no matter what I put in the warm_ppc, be it a sollved opf or zeros or anything else, it's like it has no effect.

What is the correct way to warm start a ppc for an AC OPF solution?

Thanks!

Tests fail under Python 2.7

Hi Richard,

when I run python pypower/t/test_pypower.py I get the following error:

----------  t_ext2int2ext  ----------
1..85
Traceback (most recent call last):
  File "pypower/t/test_pypower.py", line 135, in <module>
    test_pypower(verbose=True)
  File "pypower/t/test_pypower.py", line 78, in test_pypower
    t_run_tests(tests, verbose)
  File "/home/stefan/Code/PYPOWER/pypower/t/t_run_tests.py", line 67, in t_run_tests
    eval('mod.%s(not verbose)' % tname)
  File "<string>", line 1, in <module>
  File "/home/stefan/Code/PYPOWER/pypower/t/t_ext2int2ext.py", line 50, in t_ext2int2ext
    ppc = e2i_data(ppce)
TypeError: e2i_data() takes at least 3 arguments (1 given)

IEEE 30bus system

I find that the 30bus system in pypower is different from the ieee30 bus system. How could I get the case of IEEE30bus?

savecase is not compatible with python 3.4.3

Line 101 in savecase.py has to be changed from "fd = open(fname, "wb")" to "fd = open(fname, "w")" By using the first version I get the error massage: "'str' does not support the buffer interface"

Error in runopf()

https://groups.google.com/forum/#!topic/pypower/0WD2fz9PqRQ

>>> from pypower.api import runopf
>>> runopf(ppc)
PYPOWER Version 4.0.1, 14-Jul-2011 -- AC Optimal Power Flow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pypower\runopf.py", line 37, in runopf
    r = opf(casedata, ppopt)
  File "C:\Python27\lib\site-packages\pypower\opf.py", line 180, in opf
    results, success, raw = opf_execute(om, ppopt)
  File "C:\Python27\lib\site-packages\pypower\opf_execute.py", line 91, in opf_execute
    results, success, raw = pipsopf_solver(om, ppopt)
  File "C:\Python27\lib\site-packages\pypower\pipsopf_solver.py", line 142, in pipsopf_solver
    solution = pips(f_fcn, x0, A, l, u, xmin, xmax, gh_fcn, hess_fcn, opt)
  File "C:\Python27\lib\site-packages\pypower\pips.py", line 265, in pips
    be = uu[ieq, :]
IndexError: too many indice

Error regarding importing a new casefile

Hey,
Sorry if it is a trivial question (I am new to pypower).
I am running the following code:

from pypower.api import mygrid,ppoption, runpf, runopf, printpf
ppc = mygrid()

Where "mygrid" is my case file, which is in the same format as all other case files.
However, I receive the following error:

Traceback (most recent call last):
File "C:/Users/ayman/PycharmProjects/Project1/RandomTest.py", line 2, in
from pypower.api import mygrid,ppoption, runpf, runopf, printpf
ImportError: cannot import name mygrid

I tried renaming one of the already case files (ex: case14) to "mygrid" to make sure it is the correct format, but I also received the same error. It seems that I cannot call any case file other than the ones that come with the pypower.

Am I doing something wrong ? Is there a fix for that ?
I need to use my own grid with my own parameters.

Thanks.

DC power flow error with Scipy version 0.15

As reported by Puneet on the mailing list:

When I try to run DC power flow I get following error:

PYPOWER Version 4.1.2, 27-Oct-2014 -- DC Power Flow

Traceback (most recent call last):
File "<pyshell#15>", line 1, in
rundcpf(mpc)
File "C:\Python27\lib\site-packages\pypower\rundcpf.py", line 39, in rundcpf
return runpf(casedata, ppopt, fname, solvedcase)
File "C:\Python27\lib\site-packages\pypower\runpf.py", line 139, in runpf
Va = dcpf(B, Pbus, Va0, ref, pv, pq)
File "C:\Python27\lib\site-packages\pypower\dcpf.py", line 46, in dcpf
Va[pvpq] = spsolve(B[pvpq.T, pvpq], Pbus[pvpq] - B[pvpq.T, ref] * Va0[ref])
File "C:\Python27\lib\site-packages\scipy\sparse\linalg\dsolve\linsolve.py", line 108, in spsolve
% (A.shape, b.shape[0]))
ValueError: matrix - rhs dimension mismatch ((8, 8) - 1)

Based on this error it seems that latest Scipy version (0.15) is not compatible with PyPower.

IndexError in runpf.py, line 212

I meet an error when using runpf (enforce q limit):

Traceback (most recent call last):
File "/data2/wzr/opf/data/generate_data.py", line 31, in
results, success = runpf(ppc, opt)
File "/data2/wzr/anaconda3/envs/opf/lib/python3.7/site-packages/pypower/runpf.py", line 212, in runpf
(bus[gen[:, GEN_BUS], BUS_TYPE] == PV |
IndexError: arrays used as indices must be of integer (or boolean) type

Maybe the gen[:, GEN_BUS] is not integer type.

please help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.