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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.15+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.15+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.8 macOS 11.0+ ARM64

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

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 af7eee7c7196b25cd97bcdd01260388e7e11ba42676157279bc688e0271de095
MD5 4327272f1445421c8d973c2c0bbfefe4
BLAKE2b-256 7544a4adb5623f74f08f11a5c7abcfa68c715539547e32dbeff5a9886747b226

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bbdd9947ae415113678a9dd834b9f29105aabcd4479a61538743020b95abe231
MD5 e96493d5311c602b1225ee5b35533d2e
BLAKE2b-256 df1c8b79f7d33e9b81d716eee4841a113659467d82d70573613b43b9843aeeac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 56d16e23b6d31d34675fba7abc86153b83486288dcc68133040d77d9af0e9d60
MD5 0797ef1c2ea4806550ef741d09bb7c6f
BLAKE2b-256 67d4de711b7d176a3730d44faaa62f0396e8ef0e472ed400ca02831251cd2b90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09df2c874789279521e0af8b40857106792d7b29521aefdae45164e243612834
MD5 e4711a257076f61f4872b3e93bcf4e76
BLAKE2b-256 d95e53686c9e8a35afed5522ffcc350a9984867cf759b3993ba3a8014d054031

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 95c9cc1d7be46021070642d3880f2262ceb7e5132ec35d8ef0cb16dabb424221
MD5 ef0464b1fff6140b16b6b6efddcb2455
BLAKE2b-256 f55eda64277e73c3d81253daf4828b08cb4f1ac912eba1f64e0daa37d1cdf0d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7726888a6b902ca4628aeac541f38df92b9779d74b96697c16ce557af6ea2e79
MD5 29ef8cacb1a410b0ec35affd8e2607a6
BLAKE2b-256 98a0ee4e4f7011b84dc6dd2baff9230c54db1b2c71ace5e4f444b88c0223d18c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 adfe9b8427595337fe5df2244cde5efc83d314a96ebc9fed2891500d325ef994
MD5 d50598deee7d391163a460267c42ac76
BLAKE2b-256 05104b9e676a89c43b795c95196d847949825f098b51c12546dadcd7c53df2fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c81666bf847980f51261df0670b0ce8f7acee221940dfcaf41fafe714bfcdb81
MD5 0af68db0cf1deb1aac8e090259196e16
BLAKE2b-256 d78d7de5acc41a345b371745036ad66bbe4fa49125707b11f2a7192a8374a925

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cabd1feee44a8f9c48f1c2ed474860b1b740a15ac11edf7636c0f5e87b5288a3
MD5 ae84ee7a691458795870b17788c83b34
BLAKE2b-256 49f8720f6e691e2a81141385d6c31114cb4f9011492ea6877937e69c38e6fb4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e8e036fb4876bb95e872321918ccef5fc96f42579d18298976b14e0169098508
MD5 bd0da375b9935403587c98b52170a581
BLAKE2b-256 f9248360ea09468bb0da9e2257eb5b66fc9c556592cad1cebf99797578e87690

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 00d438f48ff9bd3074cc0aca6a230e53bf67465d9f7bb7e9d206cd4e54976495
MD5 400957d4fe27a231f8ac4d91ef76e75c
BLAKE2b-256 5f6d6bde5df285d0cef42f9a69f3104236384a2cc449b0be4efd44a2dc0d40e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d6f904da8c4d3683d53e48fc3acd79453f22596465115d1fc1910ab3deeeab47
MD5 047b4b514906c803d15195de7cfe3aa1
BLAKE2b-256 de0b0639292a9d7dfc6f5a2a32094c195c0ad05d13cc3e300d39b34764b2a8ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 16170ea9fa650485e14f0d2e07b8e0d6115f156d27d568687e4ebbefc4c41387
MD5 5762041e5e07f821c12e498f56311691
BLAKE2b-256 afb0e4acb2b98ad2bd3f7c04d63989ef1da7267cf1bb6264462db9eab3212065

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cc9688c09eb5254e4f3fb69752b3f4f06721f8dda1aaeafac1a696ca368f795f
MD5 0d761f50c1c1f23ea6f955e995f8acb7
BLAKE2b-256 308948aef60cb303b66f73a729e1a55a7861b3d5334a4e03bdd9dbc0fb9fc323

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc956815915826-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 39f6534d8683af52f12adec1e103c291e3fee98b0355a3c6f6822dea38f809b6
MD5 f723dab16fec041b942a4cfc106bdd5a
BLAKE2b-256 73a5fe1748f5ed3350d089c0cee053fcea9518d42df6642714747f0c6b65a1a7

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