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

Uploaded CPython 3.11 Windows x86-64

power_grid_model-1.4.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (558.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.9-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.9-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.9-cp310-cp310-win_amd64.whl (476.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

power_grid_model-1.4.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (577.0 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.9-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.9-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.9-cp310-cp310-macosx_10_15_x86_64.whl (514.7 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

power_grid_model-1.4.9-cp39-cp39-win_amd64.whl (475.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

power_grid_model-1.4.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.9-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.9-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.9-cp38-cp38-win_amd64.whl (484.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

power_grid_model-1.4.9-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.9-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.9-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.9-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.9-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 01f843f4a8712dfa25cb2dd799cf3ce99fb60ea59f8cc7bb09a2c60dff304446
MD5 4244cbdb6112af79a41f9a7e0c9fda40
BLAKE2b-256 3574061c64e8cd5d7bb6e655e26ea9c75e2d08c3949c876ea3a8ce66f2b5b59c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a66cc0dd85ddd4d3484147341955795e3b5eae008422101bbd2053b1f4c9a9ea
MD5 4102a3857da46b1fe8c21762ad458e97
BLAKE2b-256 c03b2d075f1900bed603d8d957957cdb181b7e512b58305522f35bf99d38bb53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 eb0d953b9032e04f9c5349c447560b6f3db362b9c05ec82c26d447d424deab8e
MD5 0bb70a17a53d08b8d0db1962fc6e064b
BLAKE2b-256 fc76762f8ea126315097b9e283d7422d622034e8943f339507806b58e1136938

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca05d15d6e98e9832a71564812774e3ec4665699170a61892c7829dbbad65dcf
MD5 78fa5c20b8d0242df6e8f2e443c83ac2
BLAKE2b-256 c3379c41011a96d5311409ca4a8f0395c6fac3526930b6c8a8816d729bdd5a4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 bc5e3f70bc9e64e107b58b476f5fdb90686bfb86f52fc48ba5746d365395a0e1
MD5 e06d8e6bf7dd3cb8e5726ce6a42eef20
BLAKE2b-256 b77fdd8b4d9331765ca1e20f7c93ddb6ec592c0ee32727bd905ca071e29d0a78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2c8adca0f9fca4b2dad2b7ecfbb3280275e0c0ab517bf3ddf386aadad8c3bd81
MD5 6fa381092874d9a0341f852fa164b4d9
BLAKE2b-256 e5e0cbceebac7b0efba7a648b136c970616b4fa1bc82bc542a91b692f3507147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 14690631f14a5539cb3c50024bbd2ab15492d755a08c9cfe16626e1f255edcba
MD5 a866614bf7412df164088613a3b22b1a
BLAKE2b-256 abdf4f02329565d6a5ce53de951530935b1cce93a9220fcfb3e7400d6ca7aee0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d6de5d14de3e2b872b548bccc9246e39c19712a2f31fdb4c66df1c6bf89b7e1d
MD5 6562e7e384b16fc77c43970843cef7bc
BLAKE2b-256 7f60a2f654e575bfa93c746d47171408586919c3e8842793208bd562ce35045e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ee2f6fa8db2602032fa108ff79f578404249b9288b6993c98bb7893c524951b
MD5 837d898f13086ab4b35fd19cd2a9bca9
BLAKE2b-256 ceb2f59bdc808886fd452b67ef4e8481479534f9306f776dc9956ccf9765db5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 030015282c6c03eea6277940156beda88401aa69597c9f3fb26e884155e9c2e8
MD5 aa9afef3b674b085cc072a5ffb99b04b
BLAKE2b-256 b87f2ffa820d000759aa121e17c07986612cd54b889f6a2f31184a46145f0677

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e777dcc78613d069591cfbed67022b585edd88a29753818d0b1328418fb9db3a
MD5 d1015476ef5b640b967f3f8bb950cf3f
BLAKE2b-256 112d5b0f242d1b0fa97cac370fecb6031f6cb33e2b552396f1533db986506ca5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ffae9df157a22b0fb6cc21cb5cec24287376c9e0ade20ea68a46e45b687fe8dc
MD5 4448038d463990ab08c7eddeaa48a798
BLAKE2b-256 a40aeaad89090669f7eb3d5d7ffe11de4d992770d944b6764d746cf631531705

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 65db17136fb39d2c4b425e99538aa91ae625651c4df56a930a83ffa005e65416
MD5 d6ca513fd6e623723651c5ed6fd81055
BLAKE2b-256 aba36213733f5fb4c013ba1e0f8fc31d778fd63b352b20bfe104c98267f93bd3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 548a9468a35f895a89585396b23a6d549bd7956e82c4b71a31aed42b7cffc50a
MD5 5dc4f49bdf3514653d50516bd0efdd48
BLAKE2b-256 d71397fcca1caceb18666c5aaa06939567eeee43de7562bc7ec602ef57b248fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 88b0e5907c9d8d6a51eaa2663681d9ee840464f0eeeb65633f5eb9f93c2c47e5
MD5 85bcb5432ef5020f28e459197fd61739
BLAKE2b-256 08f5009a68f733ea19b013cddf58328f597c5449cdccf7756db1caa1c1933a4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1eeadf23528a5f7d9948179c2219cc8104b3ee8d512516d6bfb7753711a05b0c
MD5 8a2927fdc598307af86a5157f7ecacc4
BLAKE2b-256 b080235ab498abe4759ba4526a31abba6e5bdf469726913ec78721dc607ef66b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c4537d2c7bc9bd29d4375239f24e4e6debb06a37bf4bcf4d2df15405bbb0d77
MD5 509b7b64107628d305a15dd2949a4ea6
BLAKE2b-256 332566053537912924ab81ba1b3fe40a48a917886f65e07584f91b5cedc16aab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9b9973b1311d748c5b5b550234b516a9429ce90f6eda3980f826ec958d7161f1
MD5 64e202ff7695b8001b97987a865bdc48
BLAKE2b-256 0118586fc13a27512c9caa1df20d5cb76bcf877d744b8ee035a39235bb1ae5de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6feec512d922b0960234e91db5e2e7e6425a5f40f554b9b3498a9edd32882802
MD5 0b093ffbfb196b2edcbc36b366798f2d
BLAKE2b-256 08b3a3d4a2a988c0985c8f260accab4c096065ca9e927603f2dec5f51639f327

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.9-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a187e22ddd5c2022023d03c0e7b367d8c97e75b65267a61d5d540574d918b638
MD5 9f24e5154de62f66dfe793bad9b1935e
BLAKE2b-256 c1eb4c0ecfb70ed00c82aad44c1ddaa545fbbac49fac186b121597a5eba66891

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