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

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

power_grid_model-1.4.0rc955916312336-cp310-cp310-win_amd64.whl (359.7 kB view details)

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.0rc955916312336-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (450.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc955916312336-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (436.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc955916312336-cp310-cp310-macosx_11_0_arm64.whl (361.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.0rc955916312336-cp310-cp310-macosx_10_15_x86_64.whl (396.0 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.0rc955916312336-cp39-cp39-win_amd64.whl (360.1 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.0rc955916312336-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (451.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc955916312336-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (436.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc955916312336-cp39-cp39-macosx_11_0_arm64.whl (361.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.0rc955916312336-cp39-cp39-macosx_10_15_x86_64.whl (395.4 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.0rc955916312336-cp38-cp38-win_amd64.whl (360.3 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.0rc955916312336-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (452.7 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc955916312336-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (437.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc955916312336-cp38-cp38-macosx_11_0_arm64.whl (361.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.0rc955916312336-cp38-cp38-macosx_10_15_x86_64.whl (395.5 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a6aca0c00263873eb3a250791f245e02027003a66e675a6f2e828b0a99b80664
MD5 17db50b64804d64f109feeee15694dbb
BLAKE2b-256 368622ebaf52dba4d7b3e333f50948a5def1434e38e67e9b0cba7267609ab170

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e916171ca718366db496b20baf294360cc440b326181e81c3b90937e5adc8c5
MD5 636615e70985e2669ce96dd387baeeb6
BLAKE2b-256 099db655aa8c829974fcc16d77c3be0b9c7189515005884aceba97ed372caac4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f2aa7a1fa7a4f8e787474954b893d3f8f4cca67522a9190a290f0021f05e96f4
MD5 a8fd898e7ecdcd1933fc7794fb3a38a0
BLAKE2b-256 760669a8637115286e0a6de7d900ebf165472894c35bc6f55262b14dd22c3d24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcb6d20def155211278271c4499dc21d1ac7e173772219fc65dc324fa0bc9053
MD5 acacc656ae7cf6a2b6ef3580ee5cd729
BLAKE2b-256 a30df832214c996383029bc17f1fd7081a547441265b09cade11dce9598b0bb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 db26f46fdf15becdf758cd8e84792000603d19554cc9a2e202a4a5bd372e76e5
MD5 9583dbd2f39bee84eb3c36becdb387b9
BLAKE2b-256 f68b24dc9486128fecd7f9c7f0657b8685ccc7a0725b372d90758292c22fc5c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9b4944f714feeb8a3fdd80f4cf231d7aa8db154258f6ecd911fe4420398574ce
MD5 aea09e6804b6e85ba1ed645c2bf3d13d
BLAKE2b-256 e0a1e91549f6ad4238ab181d2650edaf13479cb7cc01fa397f1f5cc7c70240f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 31188e1c64d70d7f69196d422f565b7b8a1c23bdf63b7a31156ae6f033624139
MD5 6302c4b0c4989cd80589785922e3047a
BLAKE2b-256 e86806f2b8d568dba39d728e5bdc1da5a94dc4e7bf1eb359a3aea8e9ae8ad526

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7094e1b60aaa5c6c792be867d6c1609ab6070fc425995dad99d829aedfbaec94
MD5 c7b11ae4acb358452084b8fce4ef59fa
BLAKE2b-256 edf8885222c3d60b5b129a1d1db99b8367982e4137f4f67febf5cbf7f5273737

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46348264fa2f868d3fc4d5f8a4926fa403190ccd3038a8a6a0e7c596341b2279
MD5 d6259b044651e3d9fafa44c1702364cf
BLAKE2b-256 78e5ccd8587c4bc4e58c2c715a9075514ea32f0a3f2975bf78e9d895c837da4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 25cdfbe0529daead3ae61d79260683f35dfb171ef3b9b2bccb8c0070ffaa3fd2
MD5 2416e93367e17a84558cfbb899a6b5a8
BLAKE2b-256 2f7fd7581cbc3f866e27f44b0fca951debe98751e0f27210494172fc688056e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 be8991bb96bf86784f2c6fc893dcedcf585920419a96305bce671cee87cc8cf2
MD5 048f84bf357d0157dfcf649145b3b351
BLAKE2b-256 c57bbc15aeba5b7d2bc89e5ff78c4289ad4d9ade27cb48307c0a40ae9b9cbdb0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8b26268a31117c3022470fed284aa85d2fa8ea97aed22b4b87b8c2500f8b2f3e
MD5 6b7c0728326e5550a6095a7ff147c626
BLAKE2b-256 c3283fd7f8da4e161d67a45de51f6f6d579fd62057684f1146d31a828be45d06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7266641d5a96c7446ea2710fead4ad254d5e66c7af409be8ca53877a942b2510
MD5 43ebc19b1757e8ed62e48fff6c79f2c6
BLAKE2b-256 dc3a3e9ed50955289bd3943f9b42824d374b9f914d6ccc0914a7a8e83f89cf81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eb7d948d03a24a7c8bf9ef5da130c0d6f7ac095a622a41112e95d4e548979510
MD5 23291a974609a0f5cd30189cef2a9601
BLAKE2b-256 8394349841aedb68e60b3126df54faa4ba62374f67b386b2764bd572f2e0ca36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc955916312336-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 0af11daa0c2095df4d33f50563793e5deaf34c04831d09bd349df132f86bd53a
MD5 0ba66f191b318ace3f822ad7487658a5
BLAKE2b-256 b66bc6a68d66f7e75c03373940abe482365c44460501a3950574158140e6a759

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