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

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

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

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

power_grid_model-1.4.0rc973505921013-cp311-cp311-win_amd64.whl (472.5 kB view details)

Uploaded CPython 3.11Windows x86-64

power_grid_model-1.4.0rc973505921013-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc973505921013-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc973505921013-cp311-cp311-macosx_11_0_arm64.whl (475.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

power_grid_model-1.4.0rc973505921013-cp311-cp311-macosx_10_15_x86_64.whl (509.9 kB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

power_grid_model-1.4.0rc973505921013-cp310-cp310-win_amd64.whl (472.7 kB view details)

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.0rc973505921013-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc973505921013-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc973505921013-cp310-cp310-macosx_11_0_arm64.whl (476.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.0rc973505921013-cp310-cp310-macosx_10_15_x86_64.whl (511.2 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.0rc973505921013-cp39-cp39-win_amd64.whl (472.1 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.0rc973505921013-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc973505921013-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc973505921013-cp39-cp39-macosx_11_0_arm64.whl (475.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.0rc973505921013-cp39-cp39-macosx_10_15_x86_64.whl (509.8 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.0rc973505921013-cp38-cp38-win_amd64.whl (481.5 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.0rc973505921013-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (584.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc973505921013-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc973505921013-cp38-cp38-macosx_11_0_arm64.whl (484.9 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.0rc973505921013-cp38-cp38-macosx_10_15_x86_64.whl (519.1 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e58629c6cda387732f1a4323b27763d8b1852167568a164e72deab16e43364bf
MD5 d6f2aa39f05192d1caeb06604942ea0d
BLAKE2b-256 b20fc6d162d6ef38a55cd3ad6deaa7271193f94f1df9d414795bf8e494d4e05e

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 25d5ef8611eda47b562d245cffc4d8026d2519c3960ec61cf75778b3c1d54000
MD5 d150fe85590d356d5734434ed3f3c6eb
BLAKE2b-256 a021d62e7da184121257610e7b5f511cf36cd59aecc2fb1b1f6572b510efc826

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2bfa79ad7f753d5dded2a2823b3fd8a95f3f5e6b4e2dbe33b5b515ae9768caf3
MD5 26328ac0cad71d5114c95a4240eb0f23
BLAKE2b-256 b689c2bab4520234d3c987354d019cc3e0b753ffcc6037af602e2dde8fe62c52

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 83b345aab2cccaadbc537ffcc0425a56dd1f2493f0ee50fbee2c27314cd7f4eb
MD5 375c7582846abd8b248fa60a7b4fbbec
BLAKE2b-256 33063c53fcec9e875990486f99a769dddaccfb944e56802d24b74e3fc28d72ae

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7f616111a8e224e907cd91b96960002399363431684b406780e9b82c26ade5e2
MD5 160a5c77a107062ef43a35029f390001
BLAKE2b-256 5b051bca5696344b590a1caf1c2c3fea07b51e564e1e71550422dc04140685b2

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fa976ab173b47f2007c7c989a9476cdef7df81103aa0ca0e479fd2c593e17828
MD5 43a98147fcb1df18e2512583266651e0
BLAKE2b-256 f01b5a1fb3121d19f3c9ff3a0fb2905b2cb06aaf155b519f438f9e65a9dfbf98

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18b5ebf02a37e7a4e79aca1c3d34a232c2d0d3cc83e79a53d4e3ae40d3d13187
MD5 4062ea6147276c51f3430c1f12c01b83
BLAKE2b-256 c797b3f61a6d71479aa7285659af31e149557393830a42bf21d7260571a284e6

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8314d24889e4ea31a91b72e6150431c779328078a3507980aac0b7f19fd26579
MD5 9d75a841080631f444dc0bc57917ec08
BLAKE2b-256 ff573066f9953d95a9eec4e0bd1d30f3c2aad56ffc2ddaa7dc4ba149544ae68b

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d4e24dbff33aa5b105f2fd9d9bd27cfce05132adf1117b7d85e9cf92f5caf13
MD5 e1a3933197a02d878a79ec740b142c15
BLAKE2b-256 8c3e6c5ef3f74f23cac0e4124ce0208f4821b2e8c898f113599ebf0a1c7a2d5c

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 714e34c1eafa07ac27978d044b3cdc587a1fd01dad407dc225db379d3b9306b8
MD5 154d4758089e92abb04bff1daf9bad53
BLAKE2b-256 8a69f13ba60a6191abc59415e58b702953472c3e49a0fbdb43019475d99ac5f8

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c3faeec1396f5d9316981e8cbaf7d9cb2a8165b6b5ac66d0128b275b033249ea
MD5 7b46fdab13900a6b4a988663486120bf
BLAKE2b-256 682e5bc79717f23d4d44f04b3b62d05491e0461b6ffe4da8173423f6bb8d4438

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1bf3c7aa65970e196d195841f26af659a6531b35bbe770b3b82ca1c387aec21
MD5 409dc376ef755e14e0675c011e7b35ae
BLAKE2b-256 45741277355fe2ac02ca06e0b698aad33a26e12f398a23ad120a31674f7cb52c

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f95e6e0ebbb2dbd520096d4ec782afc4d569e2336e28140fc88f134ba377b566
MD5 db966cb6ffb98feaade5a00c305e8cd1
BLAKE2b-256 579723ef852f533cfd54a2a49cc54e5b7ae015c0145393c698b904be3e469aee

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ab0739682b546c012c9fe2d2a5e4b09cdb11edbe776c4807e6fdf3b2fed84e8
MD5 08cb52391f05e302396e8ce8015148db
BLAKE2b-256 9d4f59bb0aaf6a5e43156d19830b1929f6eef5d4c60726d1a0aa56d493e5122e

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f84d39c1a0e37ccf0f7da8f59fd00a290cdef555a57540125548e613b3f38236
MD5 02d3711740a3b0eaa4b89d69ba458472
BLAKE2b-256 298a942dcb4be2d7e723d2f3fd51976851077e6d6f5f5df868c9f4e1afdbf16a

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 43504bd46a2cc586b629ab3ad16d72a0e4d24be0a38ac742de334c2de9762c6f
MD5 3cf20724f9e3cf39910f7cfca54c6448
BLAKE2b-256 7cc3e1c3693a2af5edba234a7e41c045097d1b3934dd73e703600d85beb70bd2

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63efcb7ad32d5693f21756f0cf470ec023ee0c03c7e5e272be50bf8d47db78b4
MD5 6f6f528b6b805aeb6648ada61fe2933e
BLAKE2b-256 a0d55dbcac101fea7350f5589c47ab2ddefb98a2f205e707dfec76a91a37ac93

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2e9aedd8aef39fb34b8f82722fad96b929e812a6a1bfaf6dd9e2a2e1fee85eff
MD5 652f1559d9f5cb06040c709a11c94c3a
BLAKE2b-256 3c5f02ce8c20142b70c972c16f53509ba3ae979e3e215dd1b65071dec36a9268

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8500f84d9d8b1b178aa1713b8e2306fadbee9b923db748339cc3200d69abb0c4
MD5 bf35f1c39fdf4ed06ded62290b3d5349
BLAKE2b-256 c31d1d0cddd5975888b6da210750423802526fb14dc17875582a3cbc4caa56b3

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc973505921013-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc973505921013-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8d9f7572c0a6cde668d90dae8809627275bc541d4312dc7e75ec43f515146ff9
MD5 200e3cec87faf181ef381df67559ca45
BLAKE2b-256 c95062f12460e44465a140760081a199669f2ea60cb97ebd2a68de8c612cdaee

See more details on using hashes here.

Supported by

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