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

Folder Structure

The repository folder structure is as follows. The examples, docs and scripts are self-explanatory.

  • The C++ calculation core is inside include/power-grid-model.
  • The python interface code is in src/power_grid_model
  • The code for validation of input data is in validation folder.
  • The tests folder is divided in the following way:
    • cpp_unit_tests contains the tests for the C++ calculation core.
    • benchmark_cpp contains a benchmark test case generator in C++.
    • unit folder contains tests for the python code.
    • data contains validation test cases designed for every component and algorithm. Some sample network types are also included. The validation is either against popular power system analysis software or hand calculation.

Examples

Please refer to Examples for more detailed examples for power flow and state estimation. Notebooks for validating the input data and exporting input/output data are also included.

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

Uploaded CPython 3.11 Windows x86-64

power_grid_model-1.4.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.7-cp311-cp311-macosx_11_0_arm64.whl (479.1 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

power_grid_model-1.4.7-cp311-cp311-macosx_10_15_x86_64.whl (513.5 kB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

power_grid_model-1.4.7-cp310-cp310-win_amd64.whl (476.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

power_grid_model-1.4.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.8 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.7-cp310-cp310-macosx_11_0_arm64.whl (479.9 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

power_grid_model-1.4.7-cp310-cp310-macosx_10_15_x86_64.whl (514.8 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

power_grid_model-1.4.7-cp39-cp39-win_amd64.whl (475.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

power_grid_model-1.4.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (558.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.7-cp39-cp39-macosx_11_0_arm64.whl (478.8 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

power_grid_model-1.4.7-cp39-cp39-macosx_10_15_x86_64.whl (513.8 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

power_grid_model-1.4.7-cp38-cp38-win_amd64.whl (484.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

power_grid_model-1.4.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (586.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (558.5 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.7-cp38-cp38-macosx_11_0_arm64.whl (488.0 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

power_grid_model-1.4.7-cp38-cp38-macosx_10_15_x86_64.whl (522.5 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

Details for the file power_grid_model-1.4.7-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0a253ad69442444cc9a750ec88c818ea7959b9ef7c4d2641aa820f4cf6d312b2
MD5 96161b4ee0426a4c61a1314337ce6dc8
BLAKE2b-256 39a465066ebc8724970b9bf32c9805ad432ec1f792bcf946002d17fcbc2cbc10

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 75c0384c0a864d6aedc7cab7bf31b38471abdf51cf099edbe9aab2db6cfd372f
MD5 1816e97853f699e1be1bf8305e2898aa
BLAKE2b-256 0139aa4ee13a9b4964c20e716f87ae077fdb5afaac762ce3e0cfee67484c65c4

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6dc7fa12e10ee88bc1d42d4d6274e9f7862df10a579bd84a685e492136ff4d46
MD5 915f613fde0bb0b1f7de99e309f8ef41
BLAKE2b-256 60b4167012b90ba782326f8a9e09a3bc0c89dd55a1a24c82d1ae31030c12b5c5

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63ba5927cf8c7c68e06400777230630e2bc6960aaa0075a198858cc818bda15c
MD5 46dc4bd0ce7b8ecc348b711fb24c2973
BLAKE2b-256 fb7729d5a33c816880f37f2e0a93edc81ab6bde345fcbe4cb46efaa0b94025a0

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3cef9130f8f9b70a76801e4bf4ec28826c326d783659ab42f31c5a2cb5ad53f9
MD5 b476f5921198360b5e7a9964f4bcbfa4
BLAKE2b-256 25d6b1f00b0bffaea32d918712b9f240818cb199d037db49e22ddf2a77e2d81e

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 622d3a8b1f227fbd820a3ea87341423faa0cab42faeb778377df0ef7b6e9951e
MD5 d9be085882daf1c529f603d0b44d24c3
BLAKE2b-256 e99642d85f2f7417c32b0a661e86639e2fc0ed1d468e6018946f46ff69965f90

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d6d20b24d60be44ceae34973218a78f1bd8ab6cf141e36adff03cbed5c8723c6
MD5 9e69d0b8a36925b1250b731a94697860
BLAKE2b-256 fe6de9a8c25ec82211fb1a7584455e0e7ee45ede1b9116ee8e129d06321d91c2

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1b47f1ecc36b0678bab6df8e92b7384b61a9265655821159227594e9e4293a7b
MD5 8d5bf9099502a913d61461ec712eff4a
BLAKE2b-256 11acc026af3379cb55ac5c11ecc1ebe54c9836ca77781e56fc3912d41b74cacc

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a6fbf2d3abc302f5a573e2d82dc1f81c6bc293b63802f3d7a54be3005f6706bb
MD5 bf5f72e2a0e5cf53c6d9421cd645ab7f
BLAKE2b-256 f8bbad024ab52ff957df4429981ce309d32dfd65a9ad3b6c54b39b80be795919

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 943439eef1c8f5701111d736fd4a0031ebd667bae135adf82894a534986bc027
MD5 003b0dbe6b9f8625b97d867e2e8a85c5
BLAKE2b-256 736f911c47fd27fdfe18695cad15995997489b1d2606e5212f646307fe3514c7

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5bb350fe4a55c37deb451be30811432bf064a442776b5445318e0d5478f41515
MD5 3658a2e26d806532d17b3bd62a49d550
BLAKE2b-256 bd4dbe58aa68930256d4f9b38e55391da6f8f5dafade10c62400769e64f81904

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d46b5fe07c8329727290465227e5993072f0dc9ddf20618749cbac12fb75259f
MD5 cf381d864c82d976f3fa47e50ec5e8e7
BLAKE2b-256 fc34269952c8d817798925dacb215a4e822f265c0e80ff1ebed881c85da59499

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 aa40a5e55d328e7c2edef29850169424b9b4facb9e598456fd7dfbb654d6d09f
MD5 4534431287e2773815e79f4dd4159583
BLAKE2b-256 1976630b5d55ad93b7e20d17d46dddcce0aa4a8744d9d1a3f69407760d555bc0

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2b034086bc118855ba298840c9fffd381444c3e11356efdf98676c4a1508a117
MD5 d88922ba30b02ccd8eabdfda48dcccfb
BLAKE2b-256 661716168be9b513a32f2e0d1cefdfeeceb38414ba926813f982dbbeadbe3885

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 63b358398bc94a8ffe7314698a1bf61b5404160aee5cdbdaa6c01a86eba22ddb
MD5 7cb6c9a0785263a3bac8c3a07ab916ee
BLAKE2b-256 8b9011d90cd2cff7f1026d54e19c1b9ea9b215b41dbeb6fc73db69a980b254d1

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c9f166f396d77cdfc63d0bbce649e95f194af4f01d7f8ce495b8b0b1b08bb2f0
MD5 b65372dbb8d6ec8f98324eb035d5bb0d
BLAKE2b-256 068c3a7ae86c458834d54120a4485c35a030fc8d6e017cc9bf6350538da17403

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cf84e1b0cf02b6ea88f19410be4e6ccb5206ed0d8bff6254c286d4871d5da6b5
MD5 b43aae78e91d89a304bf99408522a884
BLAKE2b-256 05a8f8bb0b90101620b2c48c42b6ab98286c43410b8ad573822ad0dd49d95e70

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 10a4064e760c7bd84e89f0cff33411a0b695632d6dbdcccdcd0764e0cdf3cc1d
MD5 099d0cbae7fc43a5f6126fc6c7b05803
BLAKE2b-256 34fb8876d9c9c27412223d48b5c0f46e191221fdbc130664d57767a403fe82bb

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67106294562892d603c74a6e54752481c701af76741dc8c46c9da9ba31be6ef8
MD5 383300c86bf3b3f71a6c421e96356bc6
BLAKE2b-256 02c9fae01814597193ae16c1f64b013823054585f259ecc8c74db48dafd42d8b

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.7-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.7-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 26a2242f61640510ce2ceee92c96612ee6fbf31ba866531162351944b8678dc8
MD5 effa0c5510fd140462cbf99c1c8493ac
BLAKE2b-256 7bcbf030ae3b2ee764cd4a5e5af5ec8e9885621a0e278de7b57f64fab0db4aaa

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