Python/C++ library for distribution power system analysis
Project description
Power Grid Model
power-grid-model
is a Python library for steady-state distribution power system analysis.
The core of the library is written in C++.
Currently, it supports the following calculations:
- Symmetric and asymmetric power flow calculation with Newton-Raphson method and linear method
- Symmetric and asymmetric state estimation with iterative linear method
Installation
Install from PyPI
You can directly install the package from PyPI.
pip install power-grid-model
Build and install from Source
To install the library from source, refer to the Build Guide.
Quick Start
In this quick start a simple 10kV network as below is calculated. A line connects two nodes. One node has a source. One node has a symmetric load. The code in the quick start is in quick_example.py.
node_1 ---line_3--- node_2
| |
source_5 sym_load_4
The library uses a graph data model to represent the physical components and their attributes, see Graph Data Model.
Firstly, import the main model class as well as some helper functions for enumerations and meta data.
from power_grid_model import LoadGenType
from power_grid_model import PowerGridModel
from power_grid_model import initialize_array
Input Data
The library uses dictionary of numpy structured arrays as the main (input and output) data exchange format between Python and C++ core. The documentation Native Data Interface explains the detailed design of this interface.
The helper function initialize_array
can be used to
easily generate an array of the correct format.
# node
node = initialize_array('input', 'node', 2)
node['id'] = [1, 2]
node['u_rated'] = [10.5e3, 10.5e3]
The code above generates a node input array with two nodes, and assigns the attributes of the nodes to the array. Similarly, we can create input arrays for line, load, and generation.
# line
line = initialize_array('input', 'line', 1)
line['id'] = [3]
line['from_node'] = [1]
line['to_node'] = [2]
line['from_status'] = [1]
line['to_status'] = [1]
line['r1'] = [0.25]
line['x1'] = [0.2]
line['c1'] = [10e-6]
line['tan1'] = [0.0]
line['i_n'] = [1000]
# load
sym_load = initialize_array('input', 'sym_load', 1)
sym_load['id'] = [4]
sym_load['node'] = [2]
sym_load['status'] = [1]
sym_load['type'] = [LoadGenType.const_power]
sym_load['p_specified'] = [2e6]
sym_load['q_specified'] = [0.5e6]
# source
source = initialize_array('input', 'source', 1)
source['id'] = [5]
source['node'] = [1]
source['status'] = [1]
source['u_ref'] = [1.0]
# all
input_data = {
'node': node,
'line': line,
'sym_load': sym_load,
'source': source
}
Instantiate Model
We can instantiate the model by calling the constructor of PowerGridModel
model = PowerGridModel(input_data, system_frequency=50.0)
Power Flow Calculation
To calculate power flow, call the method calculate_power_flow
.
This method has many optional arguments, see Python API Reference
for a detailed explanation.
result = model.calculate_power_flow()
Both input and output data are dictionaries of structured numpy
arrays.
We can use pandas
to convert them to data frames and print them.
print('Node Input')
print(pd.DataFrame(input_data['node']))
print('Node Result')
print(pd.DataFrame(result['node']))
You can print the data in tables.
Node Input
id u_rated
0 1 10500.0
1 2 10500.0
Node Result
id energized u_pu u u_angle
0 1 1 0.999964 10499.619561 -0.000198
1 2 1 0.994801 10445.415523 -0.003096
Examples
Please refer to Examples for more detailed examples for power flow and state estimation.
License
This project is licensed under the Mozilla Public License, version 2.0 - see LICENSE for details.
Licenses third-party libraries
This project includes third-party libraries, which are licensed under their own respective Open-Source licenses. SPDX-License-Identifier headers are used to show which license is applicable. The concerning license files can be found in the LICENSES directory.
Contributing
Please read CODE_OF_CONDUCT and CONTRIBUTING for details on the process for submitting pull requests to us.
Contact
Please read SUPPORT for how to connect and get into contact with the Power Gird Model project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 451.9 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3b2be692ea7c159690943b965f669763aac7176500cc0393e1a674a9ba63272 |
|
MD5 | e5ca6b8f058b8bfb9fd456b362270ffb |
|
BLAKE2b-256 | ca83fc03f020363c6dd63ed0f55fdbbb9c78118436484ff0e6208798ac1c67fc |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 542.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c95bc075b676081d472f3bf34a9c2b63e9b38da1adb7e5d03415846515a3393 |
|
MD5 | 3329d164a5b3368017b03faa83fd4f16 |
|
BLAKE2b-256 | 83a62801ac85dd2ee5cb7ddcec38b412ef3e83702c37e94892d07d9e3de29c51 |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 528.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8aedf8f555814936cf66216836e0f600d5bdda79e82c7aa1def9231fddea5282 |
|
MD5 | ef0e0abbf5fdbd80e09cce9f5dc65c29 |
|
BLAKE2b-256 | 3ac1376b94ee473fa7107a984f3c29b30d4ed48876aef704afbf47908e1cf1b2 |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 453.7 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2888184da581d6b8036925eb00467482163f79ed8ef38d6e383e7d93997d5591 |
|
MD5 | ad4755e1c55fcdb42448e6bbb11da9ef |
|
BLAKE2b-256 | 63c490a125364bdd24d57c4c77deeff138ea3b75bab568abfa157b74b8b364a2 |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp310-cp310-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp310-cp310-macosx_10_15_x86_64.whl
- Upload date:
- Size: 488.4 kB
- Tags: CPython 3.10, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed5f501ca9017cfdc2ee0f6c9c842ba7e6dbd9c82ca6457eef8eaa4df5ed153a |
|
MD5 | 5c99f796a092320f8b88992dbc1db679 |
|
BLAKE2b-256 | b198103c1ad3afc7bdadfdda85fea306f26afeb3d539e53c5ca4fc8fc121d48b |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 451.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec86a59a05af798b9b7feb6622beed7b37d645bde2f7eb8dd31009263fc8b459 |
|
MD5 | cf16c7c7804328c9671b1614ed00ce80 |
|
BLAKE2b-256 | ab77d65ba22a10714638938fdbe540bd0c1996864abb7d0e59abbdbc2f6e199a |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 543.0 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 966f90d8a75fb5d9458cb5963225dd1e0f43136cce89dae5da2919704f98b9bf |
|
MD5 | 7528f4d8649ff8fee5a07c280c24136e |
|
BLAKE2b-256 | 30ef505899fb592aaa2685a45bb46af1ff210a05ac5566bb9632bb1713f1c86a |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 527.7 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27c16c2b57999720e9b779b28a20a8b04f5a4363b675861a64d5346fdc7b7f63 |
|
MD5 | 2ba9d0efd0f1d5b5e342b617135ffff8 |
|
BLAKE2b-256 | e9490a4f8c510515099d808efe35e271326355c4f52de2477616d0e071c4694e |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 452.5 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d95e780a75de63f8e04e9abd5da9e99fbff4ef74ac2425a0cc48fe6c67ce9f6 |
|
MD5 | 958bcd1a47f23ea7bc8dfc8980931b30 |
|
BLAKE2b-256 | 23845148a7934b6a123f5a4c8bdfc2d17e6385b7018f3060ac5d6c5f552feb80 |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp39-cp39-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp39-cp39-macosx_10_15_x86_64.whl
- Upload date:
- Size: 486.9 kB
- Tags: CPython 3.9, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 101d4656154646356614b3b9f3c1541608584d06e3a13fe574782ca85792ea5d |
|
MD5 | f220e3f35225262b378b53f38ba47b08 |
|
BLAKE2b-256 | 7942fe894eb3db7cc0ce07794ebe12344f57d70209be0ec4c77b73b0c03f754f |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 460.8 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fa8049dca06df11323ead6e4a6c3db586774dc93227dd11930a2b997bc315b3 |
|
MD5 | 8f5390a0a18745473311cfe84459b024 |
|
BLAKE2b-256 | 3b430c0c5f7b3dd5b783107e1fbd4f13b16e7fc1d277e42363ef13b3e607e006 |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 553.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ceff9d2fd75501da7eeae503a812fb4168695f168a993752876a665d7f8fb2c |
|
MD5 | dd81c4a07ac6e851dacdc3fa12016afe |
|
BLAKE2b-256 | 8ab1cfb568503d0981b566b3be2d7092c5489a134c7270f9b43db2910316cdb6 |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 528.3 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84502f709224e5a439a430b89202d884f48779d70eb195ee9a6b4402a76858f8 |
|
MD5 | 3ec9b294b319c678f070263b922acaf9 |
|
BLAKE2b-256 | 463a6ef02a6734c29a6c3806e0259382802157a0a538d5b24ebc263b59ba3342 |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 461.8 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0a977ca8f5a66650885807b7a60fc97ebfebee5f3428c599da8143189438bb8 |
|
MD5 | 86bf834e64b557ffe60f95835e4ccc50 |
|
BLAKE2b-256 | a5318b1715e9c7f2fbbde0edf7fdc42d63bc4401b1d2095a600c95eca25608d7 |
File details
Details for the file power_grid_model-1.4.0rc964404131143-cp38-cp38-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: power_grid_model-1.4.0rc964404131143-cp38-cp38-macosx_10_15_x86_64.whl
- Upload date:
- Size: 496.2 kB
- Tags: CPython 3.8, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c6ea31cb5693631158a2e488ab886fca823901a6e341b420e19984bfdfd95b1 |
|
MD5 | 0e796b6cae8ad8c57058b4d2bd2a82c5 |
|
BLAKE2b-256 | e8704fe316a4d9ba24963c2cc9ffd8fcdcc70ae343952f8af84e4208252832da |