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.0rc969410922786-cp311-cp311-win_amd64.whl (454.1 kB view details)

Uploaded CPython 3.11Windows x86-64

power_grid_model-1.4.0rc969410922786-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (544.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc969410922786-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (530.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc969410922786-cp311-cp311-macosx_11_0_arm64.whl (455.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

power_grid_model-1.4.0rc969410922786-cp311-cp311-macosx_10_15_x86_64.whl (489.0 kB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

power_grid_model-1.4.0rc969410922786-cp310-cp310-win_amd64.whl (454.2 kB view details)

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.0rc969410922786-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (544.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc969410922786-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (530.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc969410922786-cp310-cp310-macosx_11_0_arm64.whl (456.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.0rc969410922786-cp310-cp310-macosx_10_15_x86_64.whl (490.6 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.0rc969410922786-cp39-cp39-win_amd64.whl (453.6 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.0rc969410922786-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (545.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc969410922786-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (529.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc969410922786-cp39-cp39-macosx_11_0_arm64.whl (454.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.0rc969410922786-cp39-cp39-macosx_10_15_x86_64.whl (489.1 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.0rc969410922786-cp38-cp38-win_amd64.whl (463.1 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.0rc969410922786-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (555.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc969410922786-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (530.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc969410922786-cp38-cp38-macosx_11_0_arm64.whl (464.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.0rc969410922786-cp38-cp38-macosx_10_15_x86_64.whl (498.5 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b60f925c5b387d1ba16d1603ede7710a678fc4296ec6b099296334ae8a4e378a
MD5 3188e63420d012e0f52bd9150aee027e
BLAKE2b-256 2a81a6c7bbcd93ae9ebc7a1ba45fdaa70883a2aac4e86e6e0e9ede79c991fcbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f498761836abd1c7e350b066b54d18aa116191288ce02470bbd4ac36ad050e83
MD5 69974b3eb7bb6946624039b023dc63aa
BLAKE2b-256 9ad72895a4b0a87f6abe6cc6def43a1e9d7e61c399d37f5c89deedcbaac54223

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4521c9b18075548e31e3c21dcfcd1410b5e35777e62683ea87dd9a263e27d905
MD5 8ab26ef0aafc9d13d2aa1d6fe064fe7a
BLAKE2b-256 5a87150efc7ddab41a545bfe065c8a5f5d89eab1fa63b419fbcd77d695c144a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b558f2ff81d29c3fd763d8b6db423e4f4cb98e49c4e4c977490b6bd9f9b3552
MD5 e3fd57e41a90c0b1cab96937e9b267df
BLAKE2b-256 b4fb3219ca8a0a91f037a70f31a4da6b71ca896f6a84745c99179643d605b021

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e3b1962482d998b67553ca5a1badf2ac7a5d86e0dad20e030155778e30dfa429
MD5 fa796fa1ace8217516a11a1d8ece6b70
BLAKE2b-256 153122677b0e1f90e78cdddd4df0116297583ca0f9f92c264a5be90c552249f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3517c299d15de6864bc4670e8ebc223a4489da11e2b49655ccf247f15ab0e8a2
MD5 bab288f437d17e4c46ef4356baba2d09
BLAKE2b-256 ef73d327cbfef219bf70fd5e116437ee34b9ceca41b75900f6204edc1675ea61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 129194e7fa30932ede05115624dc3a5a0d9ee0faa79c204bd4c10c2a2ba9f89d
MD5 5003fd7888f4a36a67ec2418c10a6e85
BLAKE2b-256 a8d170afc2ed16446d36e6598b1337abcfa91b067b34e0844b8e7841f00db054

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dc5d228be52d8408066e6bb7b19bcb9948f708d336ecf8907f4173c2110eb189
MD5 6e866b5b2cbf750103cfa0f8b716f002
BLAKE2b-256 a15325e7ff39af4288b27a2c2b527bf78759a9a336eb4d12c538c4b179c56fd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 970363a651a29df84b54197e79cb49f3b4610478e24b89bd2a839d90d7aac8e7
MD5 c9a9c772e8fbf25657058238ddf86569
BLAKE2b-256 b8fdd741e8176cb5b8952bb2c19962a5804f5554ae4a0ea360c24032e05f436a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a210741181bf4a33dd571bacf1270e8899912036c59f0b81478dceec0d299060
MD5 71e450c881e3f602f7f177fcdd557714
BLAKE2b-256 ec37ce7877ce0931bf4dd001e7ecab07f31eacbde39176aaab6732395d0234aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ded2b65c74c579d95ecd7c5793cd4e5a1349d80bcea492e4c0943964ab57f26f
MD5 9bda3021a2304ae0956add7355b5019f
BLAKE2b-256 f671c1db405eed60837e3731ca55bd12b8079acdedb536a9063d7a673e31c5e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2610c4dee80be7840557666bd6c5f0dae35bc6b0c81ec864a9ed8099541dc79b
MD5 c675d4fa69318e53ead2d178ce158c32
BLAKE2b-256 cf99718e0549e06e504937a4521aee7e257bd9cdf225ac0d044201bd7a8549bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 99b87bf9400499f8b08823bd3575633c676294f2ed51b3ce07a3394bf2e4200c
MD5 50aa95cd1fa80d42e52b054523ec049f
BLAKE2b-256 7e22ad094f8a838980c583505d0d2a507f6baba9c0ad5d1480d73d3652882b71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e1eaee6749105611299138c552d5af36ea6404a7bb9c70545076691c93c1cb2
MD5 1fe3b0229723b5f038285da3a74491be
BLAKE2b-256 9b642a2a3fbf52df0d6fee6254e68efc2f54cd3945027c182f42826289c609ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e80e31b92aa3b84da16d451e0c866fe29759280f2366ceed76fefcd7fad0c715
MD5 ed933f208dbc21a233b4ecf67ba78084
BLAKE2b-256 b8118fc926fcdccf9db673a51edd685ce1ad9eff4daf797a28d86a2599e7ae88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 782751f6b9a183be303436cd22c0b1c0e04c61cc300e1d3c1a4e179cd354071c
MD5 65274b06c28f4acaaba36f867ea6aeb4
BLAKE2b-256 af7b1065f2a5dea4c8fde637909c24b8b749be8d218bb94a13f6589f25d9537a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 343a4d21978923a287a70172933ce85fd4620443199174348ed36214ec4f250f
MD5 704e37e03e81f67fb9032d227f7bed8c
BLAKE2b-256 d5ed364075d78b79fd2dde17f0b91ebdb3595f3d98ec797c583a03f93835e04a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9dac9f6ef3a4624be357b6afc660ec5437937e086efa2a3d2fdb961e8eff3c3d
MD5 5a3032410652c396e6b6ba7114b0f774
BLAKE2b-256 f8079d4df8c0dd3a4536291042be7a52e163228932912e5cb551136b9d125d53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 564219033d00ff7b12bcb1e216351158304d5207be071ac903cd9c8d14658ba7
MD5 44407fe4060df6e1423fed06da2d6e91
BLAKE2b-256 da8b1e8d6d91c501ea5b14da6f1b7a670aff51d814c60a2ded1dec80e501f226

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc969410922786-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 bda9d94e9396f2d9cbc12b7cc1c5f61d5702ceefaf09aa7c482edd44db15096e
MD5 6b81948cef9c6474f64a986117b3117f
BLAKE2b-256 3643a9475bd3782643b0201a982e588cef0ee13636cb7fbbd32b32a331fad9a4

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