ttinoco / pfnet Goto Github PK
View Code? Open in Web Editor NEWC library for modeling and analyzing electric power networks.
License: BSD 2-Clause "Simplified" License
C library for modeling and analyzing electric power networks.
License: BSD 2-Clause "Simplified" License
It is not possible to write on the active power P
of a generator object:
AttributeError: attribute 'P' of 'pfnet.cpfnet.Generator' objects is not writable
The following nosetest fails on my mac and on Nick's:
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.
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)
@awig I remember you found this some time ago.
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.
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
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) {
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")
To complete the pythonic transition from C integer masks, we need to convert the Bus Sensitivities and Bus Power Mismatches to strings.
See,
http://ttinoco.github.io/PFNET/python/reference.html#bus-sensitivities
http://ttinoco.github.io/PFNET/python/reference.html#bus-power-mismatches
If NET_COST also penalises the battery power (e.g. the injection from the storage), it cannot be beneficial to use the storage.
A function may need to represent itself as a combination of
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.
I am experiencing problems when setting the load variables as fixed. The number of fixed variables increases, however the A
matrix seems unchanged.
Looking at https://github.com/ttinoco/PFNET/blob/master/src/problem/constr/constr_FIX.c it seems like the FIX constraint is not implemented for loads. Is this the case or am I doing something wrong?
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.
The printf calls inside the C-part of the PFNET Library are going directly to stout and can therefore not be displayed in the Jupyter Notebook.
This is related to this issue:
http://stackoverflow.com/questions/35745541/how-to-get-printed-output-from-ctypes-c-functions-into-jupyter-ipython-notebook
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
It would be nice if the Graph renders the Bus IDs as node labels.
same for Acounter, Gcounter, Aconstr_index, Gconstr_index, etc
Other options are J_nnz_counter, J_row_counter, etc
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.
As discussed in the meeting, it would be nice to have a projection that returns the A
matrix of constraints in a certain area (one or multiple buses).
Testing with:
dev
merge into multi_period
dev
merge into multi_period
dev
dev
merge into multi_period
first I uninstall all above packages first from virtualenv
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')
.
load
in the documentation exampleAll 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.
@awig We can start with gen.reg_bus. Right now exception is raised by new_Bus when it gets NULL as argument. We need to catch this NULL and throw a generator exception ("GeneratorError") with a message like "generator does not regulate the voltage of any bus".
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.
The bus.show()
function is not passing it's output into python.
It would be nice to be able to specify the base power for .art
files.
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?
"pip install pfnet" should install C library and python wrapper.
Seems like solution might be customizing setuptools command using cmdclass and calling configure,make,etc with subprocess call.
Some good notes:
http://peterdowns.com/posts/first-time-with-pypi.html
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 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.