Skip to main content

Python/C++ library for distribution power system analysis

Project description

PyPI version License: MIT Build and Test C++ and Python Format Code 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

power_grid_model-1.4.0rc963308087965-cp310-cp310-win_amd64.whl (451.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

power_grid_model-1.4.0rc963308087965-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (542.5 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc963308087965-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (528.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc963308087965-cp310-cp310-macosx_11_0_arm64.whl (453.7 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

power_grid_model-1.4.0rc963308087965-cp310-cp310-macosx_10_15_x86_64.whl (488.4 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

power_grid_model-1.4.0rc963308087965-cp39-cp39-win_amd64.whl (451.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

power_grid_model-1.4.0rc963308087965-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (542.9 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc963308087965-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (527.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc963308087965-cp39-cp39-macosx_11_0_arm64.whl (452.5 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

power_grid_model-1.4.0rc963308087965-cp39-cp39-macosx_10_15_x86_64.whl (486.9 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

power_grid_model-1.4.0rc963308087965-cp38-cp38-win_amd64.whl (460.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

power_grid_model-1.4.0rc963308087965-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (553.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc963308087965-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (528.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc963308087965-cp38-cp38-macosx_11_0_arm64.whl (461.7 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

power_grid_model-1.4.0rc963308087965-cp38-cp38-macosx_10_15_x86_64.whl (496.2 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 df8873172b8a4c5150de0c8c2b8893760e87ffdd23a07e78026a0761c8aea683
MD5 f735d3741a0df2c1cd855d959d488b86
BLAKE2b-256 6a32a0a5a7808d04fae6b94fb0ea33ee2901d4ccf30136948efbcd7b60d9c357

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a4619031c9e4a3847b1e6e6fe7555f35169117d47265a90706b19734dc7e26c6
MD5 6b5762cfaf9efe55ee1df0483e1ce766
BLAKE2b-256 10fa3e7bd19631a385a2dd0eea16fc51d936c180e1e340176f8ee7c130e56c20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4d5a5a14f3e352abb72cb025d6fb639424973e6ba9f4f17193aaef0e9315fcec
MD5 78e675d15147413d3fcb42e94fd0fe21
BLAKE2b-256 50b645a911471e31e40f598fcf22028628231cff873f5ab24eb9629f81f48c34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80a582d51fa8804250ab458d27562d9f2e57a25070e1fb7da3b457dec52f02d6
MD5 d1d8ab0c236dab2ec0dea61c768eea82
BLAKE2b-256 6d868873cd66f6b1e192998982d8de740a5fc4a275f31ad8fa7702aab7c08254

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 470c8972c2900ad75a0b78937295c03a8424a5ac5b0607b90606770d9eeb25c0
MD5 06b5968b1b46ed592720cfb111c9f1e3
BLAKE2b-256 c377ffc8ae8fd2f1e5cf998fc6e12a32a628ce38686703607c4a6f06c6190a9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8ce6ad4e947a436fb7340afe0f4d8393839d216095a92cb74a25a44fe74b3838
MD5 91724025778188143e48f4b788c59dee
BLAKE2b-256 a1c2ce0b810e7570c0e4ab8dad7ab19ac0953524bd161c984c685e204bae7270

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2257cc30006418d8cb88b2d020b8311e12f08d73795d2e2cd1ca0069a495ed6c
MD5 f648cd9d62d771520dcc9bd751679f56
BLAKE2b-256 c2cb5db4a4b7ad04a44adb7fb208d47bd5a02ee433a90e0309a73eb719739c0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0e46a08709d72cab5b4a91056fb8417c80135a543208b782f350bd41aed43bd8
MD5 ba8bc9268bfb9d0d13a850a8aecfa33a
BLAKE2b-256 87b04535f5b2ca70ed08adc1e89dbd8f72487de437e1129720a6affda8263883

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 25c4332d372848668304e11ee43f54ab1c5c930901e0bf9aae25e48b335eaed3
MD5 3e952b4be0647f0e06554b9dcfca7667
BLAKE2b-256 d09f428a4311b303d080e42c57da3b857cd0da6da0d18210b36bdcd43e63fe8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6fb19d1090c8950f3692c36be82b872860f7cc98522d1c419c603adfa2f46953
MD5 a93eabcbafd1e573f93e2078066a4567
BLAKE2b-256 87839ead0d5c8b48660699c5e924c09ad8e4016530b60a9a62e80f8b5d8f35bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 76bc7614d501b617ec3d328c0be1d1271ebcb6812e9dcb8f71d7c7b774b6eaed
MD5 0a4e7c6b36749dfb5fcb377fa92a97d7
BLAKE2b-256 58b178e1bd35644e630c25def778ae3b61ae130085e8ed50db6fd86583ece799

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8229ed171bf7c49114f3443775900e199f397657e55a599b9b2f1a5cb09bfdca
MD5 d1040f67f5f8abc4400f41f88852f98d
BLAKE2b-256 0cb8d0169763b45482bace6cdfd11383c10009f25644ad377b1701aae996e1de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6869511a25fe5abf91c33baad8b5a5e411b7590be627da7fc6bd667278ee0713
MD5 d728747fcb6890e7b9d5bab0ae0a1756
BLAKE2b-256 b16cbf2081960687d00454d2cf301f10ec0efda81235872d38c3f76fb538e25e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 373eb042bfd49b8640e67bf99df59785365f5029bb0784a32cc5154dad61864f
MD5 fffcd575746cd3b2715db0db3e9fc2c7
BLAKE2b-256 aa3050a4ffd0518fcf7d459f041c0a58fc2276c5f79bd00c4d4aba04b9bd2204

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc963308087965-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8b4e212f2e1b5356bda35e4fe65ebb28739ad24509547e9fffb0815cf9bb9374
MD5 38f496e57471b1c8f463fcc8c497e936
BLAKE2b-256 95e8028b974480149eee74661c06546ccc91c53c3c5ca3fd9eaa4711f4297166

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