Skip to main content

Python/C++ library for distribution power system analysis

Project description

PyPI version License: MIT Build and Test C++ and Python Check Code Quality REUSE Compliance Check

Quality Gate Status Coverage Maintainability Rating Reliability Rating Security Rating Vulnerabilities

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

Folder Structure

The repository folder structure is as follows. The examples, docs and scripts are self-explanatory.

  • The C++ calculation core is inside include/power-grid-model.
  • The python interface code is in src/power_grid_model
  • The code for validation of input data is in validation folder.
  • The tests folder is divided in the following way:
    • cpp_unit_tests contains the tests for the C++ calculation core.
    • benchmark_cpp contains a benchmark test case generator in C++.
    • unit folder contains tests for the python code.
    • data contains validation test cases designed for every component and algorithm. Some sample network types are also included. The validation is either against popular power system analysis software or hand calculation.

Examples

Please refer to Examples for more detailed examples for power flow and state estimation. Notebooks for validating the input data and exporting input/output data are also included.

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

power_grid_model-1.4.5-cp311-cp311-win_amd64.whl (475.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

power_grid_model-1.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.5 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.5-cp311-cp311-macosx_11_0_arm64.whl (478.9 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

power_grid_model-1.4.5-cp311-cp311-macosx_10_15_x86_64.whl (513.1 kB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

power_grid_model-1.4.5-cp310-cp310-win_amd64.whl (475.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

power_grid_model-1.4.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.5-cp310-cp310-macosx_11_0_arm64.whl (479.7 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

power_grid_model-1.4.5-cp310-cp310-macosx_10_15_x86_64.whl (514.3 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

power_grid_model-1.4.5-cp39-cp39-win_amd64.whl (475.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

power_grid_model-1.4.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (558.1 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.5-cp39-cp39-macosx_11_0_arm64.whl (478.6 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

power_grid_model-1.4.5-cp39-cp39-macosx_10_15_x86_64.whl (513.3 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

power_grid_model-1.4.5-cp38-cp38-win_amd64.whl (484.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

power_grid_model-1.4.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (586.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (558.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.5-cp38-cp38-macosx_11_0_arm64.whl (487.8 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

power_grid_model-1.4.5-cp38-cp38-macosx_10_15_x86_64.whl (522.1 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

Details for the file power_grid_model-1.4.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b690def5c0907b0f7b65930d234213ba78da5df8ede6ce7304a765c3b3a25958
MD5 f2d61bce5a48630209b4d7d94430b22d
BLAKE2b-256 76da818aeb30e72670e64ee5731582f6f836de1b3e545a3e6fafe609d1cef65b

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bf726d3547c5022e0673669222a6bfb46dfb1c7bcc5e01cd27edd08f22cc4145
MD5 6805604a1dff2c9abccd6f96692cb975
BLAKE2b-256 829fadd376258a243ec4f7e980028b80bd30a8dddef31b013e5f7a39496ac28f

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c04362605fc8184276c26162feebf1626020b38eb62234115fffa31bb050539f
MD5 28e94b60795c55134323eb3ec2e61710
BLAKE2b-256 a23b6e1567ffad0171bcf980692d5a7edbf7aa52cd0d8b5a895cc457b2621dd9

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a2e08dc1bb4865c2d050accb772bf6d87446dc74dd248ce95d0f56e94e85318
MD5 5b998fe27f305a80cb3f119a712aafd3
BLAKE2b-256 81c8f8046cbe163240085b1c4e93b9bcba1fcf97adf4a08503aaca4bcbef21cf

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a562ff56974bac85fa07cacff49a783ed6f45fd38859b3480877762e9f70de46
MD5 c58149930b799745782c23e3a6cb0d0a
BLAKE2b-256 3b163d51e0db591815ecf08ea0bc5387b46599032b05d7096ecd4168b6958f19

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3c211fe2c17a02da40f29b36ffea80e8bce66d3203624390bcc0eac2dfcbe29d
MD5 dc84bfe1aa03a48e8c814966a580ecbe
BLAKE2b-256 4bcb46b3dca6f5c829cb1157f361610159a0a8bbd571ef9e77db5f1fd1c7cd35

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1df9540b2694becb0d46c94e428de0c9078dcba586051ec48afd1e06f1266289
MD5 577817ace843530bbabb5546f5edb2ae
BLAKE2b-256 ee235d92aecb6e8957e55c41bbfd544dc3086ca235efce1079e3e4540433852b

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cfdfb922fddf261e9748c4e7ae221e348f982a2b80501309ac13a21221f5fc96
MD5 c91e197df71b70d2841334dce0831bf5
BLAKE2b-256 94027cf665bacf5e10b776e0e6be66f4f3deaa854d08f7d2c455e1b96b7f7df4

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9704a7f883a697953b5eea733786853c941c3fa88ad19869d2d13c14826e3a87
MD5 deecb51cb561c227a1723e34aafe5330
BLAKE2b-256 4c8a3bbbe665a7323b4f9f0b45678cddd73eb2e6f9d0269b8d3faf221aa8975b

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 24dfee48269d4948c1800ef850294a4e7116d87bce9612deb72f9ddab0ecb07f
MD5 13e7054ae65d7cd4f48a53c66d51e5fc
BLAKE2b-256 3e9d76afff33a5fcdbbe02a5160d75bb975192ad42f22cca40686942719ab39f

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 116e156edfdaf1911fdab2c4af2ecfe3809b66ed96ef1186258da2b0f926a1fd
MD5 6c76c6f6741508d040ecfa7bef3b2ae8
BLAKE2b-256 205fb77eb1e14bc201a9c1ae2803fd824a25473a84c7286b259bced182567002

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 69cd0a9a173b40a59a82e0d10f6edced98c2c173b5e82fecb9af4877afa537b4
MD5 ab0eca98e74d22eac1647546a3069917
BLAKE2b-256 722eb56e0220ddb1ce261660c8c365edab2715dd1fb599c64aee9d80a6709915

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d5cafcada6ccff34a10a07dfb54498e127e155e293a58893b35147fbc65d1c78
MD5 ccf86ade1d3800dacd4eb80f3d0986a8
BLAKE2b-256 fd595609efbc19b210180ace98766acc32711a444ba7433655419bdf9fde594a

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55554eefb730d4e9d9d26a769693ef28534705fb7cad691d7d15d77c159c8f08
MD5 0e9b1c27a173fe2e1ad8c6c8d312a207
BLAKE2b-256 4deb675219de662792de8d93dd92970c29709de4002f03e67b44679276937623

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ee13f900dfcdf16637c6c6e38157a59e7fe990a3de35822c42aeba318a67534c
MD5 33cb1d6c600053807a059a0a52be4632
BLAKE2b-256 2d751c247c7fd503c88514c8f3f5d331af97eb413bc70a83a1580e3f69141aaf

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d4848ef99dd0f97bd031279fae7c9966d91c2469fbdf6d4b6cbc9fe80db95f77
MD5 682ae095c3d5b1e517dd89f85420ca08
BLAKE2b-256 5075a14cc96028f269cd695217119a1ef7537cadd673d93caf51a00b198ede85

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7a9afcf86b54ed7f7fed541ae4a92ead689ea5c612b3c64a0dd26a63b74da54
MD5 3be5b34a38e57cb38bc7360e7399eaa9
BLAKE2b-256 3b8d2618a7e87061468db4828b11a7f8b810b92045cb0d995875b6708142b841

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7ef85abe9d6be016bdcac5db2b4e46b719787f95a6ed474f0302feb942401f9a
MD5 3d093cea0bd0862a4a57d8b780197d50
BLAKE2b-256 6a63b277db2a40ddb8690d557fcefe767bad682a79190308044ceb278bc575f8

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 43c5ef36e300d1eb60266e05db28ce2a5eba2acce4bf897da3b0c37e70de78a8
MD5 7a00cd19ff54cc48f1277b7b55004101
BLAKE2b-256 504fcf997b39ccf02010d9bcadce6d8ead650e5c4673aa1c16575c6f08ebd1af

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.5-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.5-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d696e2408bac9a719d71728491e32f5a010854df770cc41719125b540bf4e9a5
MD5 7919544d152104baf8f6bb9dd51e9346
BLAKE2b-256 b394ed03f428ac58f564711f9b0baa06854ae9ab29e3b015c846eeebdc3e44bc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page