Giter Site home page Giter Site logo

ttinoco / pfnet Goto Github PK

View Code? Open in Web Editor NEW
12.0 4.0 4.0 67.25 MB

C library for modeling and analyzing electric power networks.

License: BSD 2-Clause "Simplified" License

Makefile 0.57% C 97.07% C++ 1.14% MATLAB 0.23% CMake 0.46% Shell 0.04% M4 0.11% Batchfile 0.03% Objective-C 0.36%
modeling electric

pfnet's People

Contributors

awig avatar dmitry-shchetinin avatar martinzellner avatar mbaltzinger avatar mushfeqr avatar ttinoco avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

pfnet's Issues

Cannot modify power for generator

It is not possible to write on the active power Pof a generator object:

AttributeError: attribute 'P' of 'pfnet.cpfnet.Generator' objects is not writable

test_func_LOAD_UTIL nosetest fails

@ttinoco

The following nosetest fails on my mac and on Nick's:

FAIL: test_func_LOAD_UTIL (tests.test_functions.TestFunctions)

Traceback (most recent call last):
File "/Users/ajwigington/projects/Power/PFNET/python/tests/test_functions.py", line 1252, in test_func_LOAD_UTIL
self.assertLessEqual(error,EPS)
AssertionError: 2.914487117911174 not less than or equal to 2.0


Ran 63 tests in 19.018s

I think the is a matter of just making this assertion a little less stringent. Not sure what is the source of the difference though.

Support Qmax=Qmin=0 of a regulating generator

I found this problem while merging the romcon additions with the multiperiod and pythonic improvements from ttinoco. Note this data should be considered bad but exists for some test cases like the ieee14 raw file and could potentially occur in real cases as well.

adam:

I found the error occurs because the slack generator has Qvar max of 0 and Qvar min of 0. In the .mat the Qvar max is 10.0. I tried just changing this to a very small value it it still runs fine. I have implemented a temporary solution to set the default Qvar max to a small, epsilon like value in the meantime.

tomas:

Some constraints in pfnet add some epsilons to prevent dividing by zero when Qmin = Qmax.

If it is related to Q we can start looking into the voltage regulation constraints by generators and in the PV-PQ switching heuristics (all in pfnet). Actually, we can start looking into the generator reactive power participation constraints. I think the error should come from there. in line 118 of nr.pf, where the maximum is throwing an error, you can check whether the error comes from norminf(fdata.f) or norminf(fdata.r). If it comes from fdata.r, then it comes from the linear constraints and hence it likely comes from Q participation constraints (fdata.f is related to nonlinear constraints, e.g. voltage regulaation)

Branch flows and clarification on naming

I will be adding branch flows to the branch struct and will perform the calculation of the branch flows within the struct as well. These flows will then be used by the update_properties in net.c. This will NOT change constr_PF.c.

I will also change the naming conventions to clarify what elements of the branch and from what bus the flows are being calculated.

Import fails on multi_period branch

The import of PFNET currently fails on the multi_period branch:

ImportError: dlopen(/usr/local/lib/python3.5/site-packages/pfnet/cpfnet.cpython-35m-darwin.so, 2): Symbol not found: _BAT_get_E_final
  Referenced from: /usr/local/lib/python3.5/site-packages/pfnet/cpfnet.cpython-35m-darwin.so
  Expected in: /Users/murphy/git/PFNET/lib/libpfnet.so
 in /usr/local/lib/python3.5/site-packages/pfnet/cpfnet.cpython-35m-darwin.so

active distribution grid mutliperiod ACOPF

variables

  • generator powers (P,Q)
  • bus voltage magnitude and angles
  • load powers (P,Q)
  • renewable powers (P,Q) and curtailment support
  • battery charging powers and energy levels
  • transformer tap ratios

objectives

  • generation cost
  • renewable curtailment cost
  • smooth gen Q profiles

constraints

  • generator ramping
  • renewable PQ capability (square for now)
  • battery dynamics (check handling of efficiencies)
  • battery boundary conditions
  • AC PF and net properties (with battery, variable generator, and load support)
  • AC branch flow limits
  • voltage magnitude limits, device limits (gens,loads, renewables, batteries, transformers)
  • load constant power factor

misc

  • handling of renewable powers curtailment
  • user-friendly addition of batteries and renewable energy sources to network

Build on dev branch fails without RAW parser

For

  make NO_RAW_PARSER=1 NO_GRAPHVIZ=1

I see the following output:

src/parser/parser_RAW.c:37:21: error: unknown type name ‘ART_Parser’
 void RAW_PARSER_set(ART_Parser* parser, char* key, REAL value) {

separate parser and network?

  • make parsers, functions, and constraints behave as objects in obj_oriented branch
    ** each type provides a "new" method to create a base struct with methods set to type-specific methods.
    ** in python, custom parsers, functions and constraints are subclasses of CustomParser,CustomFunction, and CustomConstraint (type-specific methods are set automatically)
  • this setup is nicer and "double build" is not needed for detecting python-based parsers
  • parsers will behave as follows (@awig) What do you think about the options below?
parser = ParserMat()
net = parser.parse("filename")
parser.write("outfile",net)

or

net = Network()
parser = ParserMat()
parser.read("filename",net)
parser.write("outfile",net)

or

net = Network()
parser = ParserMat()
parser.read("filename")
parser.load(net)
parser.write("outfile",net)

I like the first one since one can just do net = ParserMAT().parse("filename")

graph regresentation for objective functions (e.g. piecewise linear)?

A function may need to represent itself as a combination of

  • function
  • constraint
  • old + new variables

New variables may be assumed to be in vector x after some "offset".
Who sets this offset? The problem?
What if function is constructed/used outside problem? Then offset remains "invalid" and function ignores extra variables? Or one should explicitly ask the function to return a suitable graph representation of itself? This routine for getting a graph representation should demand the "offset" for the new variables.

Provide net consumption of bus as variable

It would be nice to be able to define a net_cost variable (say z) for each bus. With an index_z it would be convenient to refer to that variable of the optimization problem.

set_flag arguments clarity

I propose we change the pfnet.set_flag and pfnet.set_component_flag argument types to the following to add clarity to what they represent:
props -> properties
q -> quantities
obj -> object
obj_type -> object_type

unit commitment support

  • gen commitment variables
  • startup, shutdown cost, no load cost functions
  • minimum up and down time constraints
  • gen active power limits affected by commitment variables
  • commitment variable limits (in LBOUND constraint)

`num_vars` for bus

It would be nice to have the num_vars property on a bus level to get the number of variables associated with a specific bus.

Testing: Multi-period

Multi-period Testing

Testing with:

  • PFNET dev merge into multi_period
  • raw-parser dev merge into multi_period
  • OPTALG dev
  • GRIDOPT dev merge into multi_period

Installation

first I uninstall all above packages first from virtualenv

Mac OSX

PFNET and RAW_PARSER
  • delete all files in PFNET/lib folder

  • cd to raw-parser

  • set $PFNET

  • make clean && make for raw-parser completes and places librawparser.so into PFNET/lib

  • cd to PFNET

  • make clean && make NO_GRAPHVIZ=1 NO_RAW_PARSER=1

  • make clean && make

  • cd to PFNET/python

  • python setup.py clean && python setup.py install --no_raw_parser --no_graphviz

  • python setup.py clean && python setup.py install

  • note: still have to do python setup.py build_ext --inplace and add the PFNET/lib to $DYLD_LIBRARY_PATH to get nosetests to run

  • nosetests -v

  • import works fine.

  • Example pfnet.Network(5) works fine

  • Example should show loading network net.load('ieee14.mat').

    • I recommend including a load in the documentation example
  • All the examples in the documentation work as expected.

  • what PF file is the example using when it shows output?

  • if you could add external (e.g., vargen). what happens if you define different number time-periods for different elements?

  • in the documentation (not sure if it belongs here or in the solver) but that the problem is solved for all time periods at once?

I will add more as I continue testing. @ttinoco Please label this issue as you see fit.

portability problem: windows line endings in .mat files

We have been working on a windows distribution for PFNET. It turned out that git was automatically translating unix line endings (LF) to windows line endings (CRLF) in checkout. (Windows git will automatically translate back upon a commit)

This causes the C-based tests to fail on the .mat files included with PFNET source code when checked out from git.

It might be good to check data files for windows line endings and error out on load/parse if they are present.

@awig

nonlinear inequality constraints?

expand standard form or allow slack variables?

For slack variables: constraint needs num_vars and offset to find extra vars in vector x.
Who sets the offset? The problem? What if offset is not set?

New constraint (that supports extra variables)
Ax + Abar y = b
f(x) + Jbar y = 0
df/dx = J
df/dy = Jbar
l <= Gx + Gbar y <= u

Constraint needs to know the size of y to construct Jbar, Abar, and Gbar. How does it find out about this? An idea is to have
"num_local_extra_vars"
"num_extra_vars"
"local_extra_vars_offset"
The offset is used to find the local extra vars in the vector y of all the extra vars. A problem asks the constraints to "count", which determines num_local_extra_vars. Then the problem with this information defines the vector y and sets "num_extra_vars" (size of y) and "local_extra_vars_offset" for each constraint.

constr.eval needs to take values of x as well as values of y. Values of y should be optional?

pythonic interface

I really dislike having to use in Python constants like pfnet.BUS_PROP_SLACK, or pfnet.BUS_VAR_VMAG, etc. This is not a nice interface at all for a high level language like Python. We should not let the Python wrapper inherent this from the C code.

What if we use strings in Python? For example, a code like

bus.has_flags(pfnet.FLAG_VARS,pfnet.BUS_VAR_VMAG)

would instead be

bus.has_flags('variable','voltage magnitude')

Another example: A code like

 net.set_flags(pfnet.OBJ_BUS,
               pfnet.FLAG_VARS,
               pfnet.BUS_PROP_NOT_SLACK,
               pfnet.BUS_VAR_VMAG|pfnet.BUS_VAR_VANG)

would instead be

 net.set_flags('bus',
               'variable',
               ['not slack'],
               ['voltage magnitude,'voltage angle'])

What do you think @awig @martinzellner ?

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.