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.0rc956500675456-cp310-cp310-win_amd64.whl (449.2 kB view details)

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.0rc956500675456-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (539.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc956500675456-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (525.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc956500675456-cp310-cp310-macosx_11_0_arm64.whl (451.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.0rc956500675456-cp310-cp310-macosx_10_15_x86_64.whl (485.6 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.0rc956500675456-cp39-cp39-win_amd64.whl (448.6 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.0rc956500675456-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (540.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc956500675456-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (525.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc956500675456-cp39-cp39-macosx_11_0_arm64.whl (449.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.0rc956500675456-cp39-cp39-macosx_10_15_x86_64.whl (484.1 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.0rc956500675456-cp38-cp38-win_amd64.whl (458.0 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.0rc956500675456-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (550.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc956500675456-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (525.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc956500675456-cp38-cp38-macosx_11_0_arm64.whl (459.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.0rc956500675456-cp38-cp38-macosx_10_15_x86_64.whl (493.5 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 36ea0512eb790e5c054df1b38adb22ebff4d53e73fac36ca39ec40c980367022
MD5 efaab01549061aae911bd93a6bea31bc
BLAKE2b-256 aabc2bf7b10cbf06c0ea3fe0ba5d39b1a6eeb7defcdb1cf2c95315f8c29612ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1086a652c1c243d925341c54c6f1a58ae2ab976d2a6012068a3cd3147fe614c
MD5 43e325706b2fbc7958790a49d1762cf6
BLAKE2b-256 13fe1b5861674d6cf2f469359bc4be7641613635fb9daecae155770008a4570d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b71d420e96b12fa4b106d3997bc7242c540d7da618b107aa226f7a7f271d8f4a
MD5 f3625d7a4cf6064584869be900ae35c5
BLAKE2b-256 0b52298c3928078ef88f22587adc2e74c5549b7ad264b2c064a14f7fed2cb069

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8be6d8cd3bd85ca5171677cb1e9f5beb3b212cad1cda0cb75e34705a6e3cff2a
MD5 5ce688658f54130513dd59f5b140707d
BLAKE2b-256 77787493c927befa43e8ea7a27c87a593569ca8d8987a1485e00c12a65f426e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d963be5d3ff9a943af70e3e17cb656d5771c79eb8131e699f087a3c0b587a0b4
MD5 7e6d5cbf13360ae7e89bc04723dd5c36
BLAKE2b-256 5d3899161b5896ed5065a9eaa0fc4cc6147ece87a6ad433cc32d8c1c9adaae9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ad2991fffea5b2622536d37a6622d1c9c629f08e874d0e7fe47c6edaabdd4baf
MD5 793f10623820c36dabbf29507ede9d7d
BLAKE2b-256 e8d81efea4d40053fb17892211df1783f403ddd04d19e55ecdef5e76417c3e21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88c347529747e866c241c4f45ebd26f6b93b02e47f300698809b468500fdbce3
MD5 f7f1ea1fa7bebd7f460ff1707950177c
BLAKE2b-256 b8e83eea440dd7c40c4e5d69529a5ee600a8330f80c1b096b3b6dd9ac549d972

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c55d517144ace3457b34e0d5c602f7cfc7bdc6ee4e33c203378795e10fe8e850
MD5 43c28b746d0027702fcc5cdaade03472
BLAKE2b-256 40e1e443403be32dcf4a01e43cf4f127b578ac0fc0f25d2cb71319e588482fe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f07852a88b8f78c60b1637fb022746d45a550d854a4c689c459d1f709e611b11
MD5 75ef8b66b71b16be865c50de8c90cf0a
BLAKE2b-256 4d2196a3607c2717c3fec17d9a7b9231cf0c45f9ef3954038ef7f0e918b10ba9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 393efcd4f7bac6f3197dc1cc64a6e8d8c91da56b1bd5e1b9a8521f6e1c81652d
MD5 6d37b7da541ecf5d12b599b22a928ed7
BLAKE2b-256 fec133c37f81a3ae0465c0558fe3ff8c57cdd1786f3ee7b982775f550ddb92eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1bf68237a7a5084a5576b4ca13f29a646e61bb7098fcecfbef055e0fbb3eab82
MD5 a91fe59a98cb60cc09619db8dc96bca3
BLAKE2b-256 87586741aba84a1281dd0230f53a2a5278ac332462f088535715aafe73e4e761

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb714c84cde06a3baeaf0332b88ad517c95361abd30b7a9f803f4fa7d47484ed
MD5 78a23973c2ce9d5fc69626ef076573e7
BLAKE2b-256 95e496c0a2ca51f45eaad59a464328516568407cd858d7e24f98b4c5260ac39c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dbf27fe95028ba6ead0bc5fcf5c01f83276becd6f72db58885e1e4fdaab57ae5
MD5 1460139e0eb3877763512c350d782aff
BLAKE2b-256 c97848b9001e9c10718c0395623983330e2cafb7866aac1064167ee76cbfd92c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d62f7e2701cd8049a3210ec3a1af474903a9ac3712598387d205f87a52a7d02
MD5 bf6a173538406565a9f06064523461ad
BLAKE2b-256 a1d4db31390cde7682e61b146d91194f6df3fc73c5360e2ddc892594061242b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956500675456-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 33b5484a85dfe3321e478d4d3eb53a8a2e986038bd3dd9fb5a8a7d71fac02707
MD5 af65d14a2d09fd24ba86e9b9721d55a3
BLAKE2b-256 7afeaaaa59d335c5d5cefd217906cf940fc4a93b6784eeeafdeef6f075fca765

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