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

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.0rc962115664049-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (542.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc962115664049-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (528.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc962115664049-cp310-cp310-macosx_11_0_arm64.whl (453.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.0rc962115664049-cp310-cp310-macosx_10_15_x86_64.whl (488.4 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.0rc962115664049-cp39-cp39-win_amd64.whl (451.3 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.0rc962115664049-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (542.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc962115664049-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (527.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc962115664049-cp39-cp39-macosx_11_0_arm64.whl (452.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.0rc962115664049-cp39-cp39-macosx_10_15_x86_64.whl (486.8 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.0rc962115664049-cp38-cp38-win_amd64.whl (460.8 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.0rc962115664049-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (553.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc962115664049-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (528.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc962115664049-cp38-cp38-macosx_11_0_arm64.whl (461.7 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.0rc962115664049-cp38-cp38-macosx_10_15_x86_64.whl (496.2 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 36025b50abe601a0e9c00374662d1370c3b293b5009a9fcec65bfec185a3f32d
MD5 f060463869dfa601dfdb681fe81c0ee9
BLAKE2b-256 53809c48eebb44cec938d4c5d2ac027f3cfa2a6cbaca933829b4f289b1526e92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 755586d442dec48a4759427354cc10e87c932c23d8e8961de08fb102a9238f4b
MD5 636c41122be0470be3c2c7f4c8140f25
BLAKE2b-256 40b42e3ad93b3bbe741a7a1e4a3a2393c3da8caf2512aed74e123a00589515cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a23b07b8aa5b95aab1a6545d0def2839fc397b6fccb633275089bf14e10bbb3a
MD5 c2f924ddfaa3057ed7844a46910ab0b5
BLAKE2b-256 5773b4077341c314883027bf0aafe9073607ef7ed46fa11db8484eec8ad3bc3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f01ee2278b9b3db2e64fe669c8b606770608277a82c2b4e208822356247f1b72
MD5 6def8b6136cff37f76e68e465caf776f
BLAKE2b-256 2dff0cda2e4b38d9de62da81cad43f4d32e6bcfe5da7481f6a6519ecf8c993f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3cc8245c371a3b031f65e9d8dbd5915c6a2a4ecae89f6137c6edc6d95b22cc51
MD5 4bcc67da48fc525d23efa68c126d6921
BLAKE2b-256 8db61dcd643f5dbbbfefc5c6fc63ac83ad96b63ad07bee67fad32a04a34611d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e6ca346450a3908b3fd54d465f498b1e5d4a5ed12430102a5939adabc20952e0
MD5 e08580a70376de5e9ba26e57ba423e5d
BLAKE2b-256 ffc3842fae4030d4fae9b34cdf9867a7919e254110cb45c66f2dc898528241f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c0a73a832b9b2ac6e4092e8676457587de6d183b3a6983e29b21514ec94cd2ea
MD5 81fc3717f5267be06333f994c8dc0ecc
BLAKE2b-256 34243cc21d9c9e11c96808a5032c237fe2850c24a4b5783021cbc5faa4881202

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 101cbd6b25be945d8b1822f4596adf0a82d65e0624287cc12a923fc644ea45db
MD5 b6662ea00e506a7974a5003cb7513231
BLAKE2b-256 959672a62128d6195c5dd32a1fd65b4a30cb2ccec4151a69991b1d83360f49b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0b4fb69e9b9bd4bb14cf500f8392971af58fa19c9c018b8e1d1a2af45b837b9
MD5 97f7051d32a267963993d35b99f64b54
BLAKE2b-256 cc7d562f651a25a48ad93501789778d51286872e8557e738f6ada5a6d1580151

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7e16cf8017f6ad180172cc4fcb74fd8f412f0e0f154f12039d627706bd6e3b74
MD5 96a76817a4b95d0e4b94d0258dde0387
BLAKE2b-256 e83b3c4ce22125a35c3bd9720c2f82cc580d3b46968cf61b76862e4d92ec3497

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4af39406a90eb985951e5be3b7950471e7196b094a470a6c4f64bdab497d0a8f
MD5 b44ffb4a79d6a95c7c971475f417a03e
BLAKE2b-256 6f69f8c55e86e458715411719bf285665d8aa2fd21ac4f372c54bb451b2d52ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d788e2f9fa840b55cb5b77792583cfa055bb5f24388ed22807b012706bfa4efd
MD5 f49cc8f6523f91a4c82022fe9f703fc5
BLAKE2b-256 449f80799ef969776bbf4cc63a1b9c5e3e6e0e2c760f552ad87e7cd7cc17711c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d47b7f251fda9f17c3e6e7ec98b0514104d621b27bdf4b2d1c9bb66f8ab7ef18
MD5 d3d4c6a731c7d2be75909b3bdbf237d5
BLAKE2b-256 baaf38c08561050058b90c9e77a891540ba3cd552d08e8e21738b5fc8663e131

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31af35fdec783c968aef45e28b43466c37e14a4915198d12a5ed2758ef0e5629
MD5 f2dd74ae7a93270e8da97801b8e03c03
BLAKE2b-256 a2e36ed91731ac768780327c2e3b1e2dc4f3047d906b73b9be46d66691cbf2b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962115664049-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 319e36a0a6e805ef8be8d7746ee98e2e0c8e77e6f53baf6f13f6a78bdee1a3b9
MD5 0d9588de10294d2ab2cabe077777b3bb
BLAKE2b-256 33867770b1eb848a90ac096bab3d73f50ebef129ddc1eb6766d3f19442b2ce34

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