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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

power_grid_model-1.4.0rc962714210300-cp310-cp310-macosx_10_15_x86_64.whl (488.3 kB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc962714210300-cp39-cp39-macosx_11_0_arm64.whl (452.4 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.15+ x86-64

power_grid_model-1.4.0rc962714210300-cp38-cp38-win_amd64.whl (460.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.8 macOS 11.0+ ARM64

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

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 71875914e1753427281b207417701020b5d391bc05dc72de811e6266c53b6d2c
MD5 8c5983530b9d7811bcdf633abaff0913
BLAKE2b-256 47da81bb98f0b9dabf79c7c02bf7ca5cbc802e5583ed2413f4db1d1555fc4e57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1f1addb7f8686b8ec8666bfe5385bef5ab246db3cd5082fcf6595a94605c0f74
MD5 6217fe0f7d6ca36f04abed34aae70c86
BLAKE2b-256 143111efc413a252af8b5159df0a135fd6af27e07375d9a0518dc61f9c8cc9d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3509fc4e07bc6cfb0b1873afd48803b3d2363d9d0c34fa7c69369c8f8df26798
MD5 27c22c6f7850bf3e08836a981f076f48
BLAKE2b-256 41c5578cb839b83efebac682b84dfd7342f1de633891cd6144cb8a3af9f4cc6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66ce35ccbc42ddce59ed99aa8612b06db5d7e959afa909cad604ebd24bb4030e
MD5 dbfdf8d722ac98dd050c683688cff1b4
BLAKE2b-256 ff3ee28d37cce1857f19811dadff208298957d9377f191c706b55dbeee62152b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 cb8272f5e318db2ebcc883f673b68fc851cfae2fb066c3e4290b398107749315
MD5 d94664a69ddb407c77b82894e2935f7a
BLAKE2b-256 7bf0c088d942de8dfd9ec2bed8c3d14ddb49f76614409551af7a5750eb4802c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6e2a0feaf35f72d8cfad571c7fc0681c85408b5c77439a067b2fa6b8e5b5ccbd
MD5 15730ab5766cfd4477e0d2fbfef68ee6
BLAKE2b-256 5427fa5f6dc8560d1a8a7727cdfa6fa21fdcf66ef4477bd99e31bb077ffccd7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c72bec1425a4f319dccffd43142131936e20d4c9e0c47b698d7bd595803736d0
MD5 5183856a6540f1f54995d15355eef0bd
BLAKE2b-256 93f8f4836e59b27a8aac1deeb4d1e680f8cee9ce29f5660ed814eb57e44d8672

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3d05fa03cd7830c4ffa77e0f878c383177ed1179698abf84703f93929bc10d59
MD5 98b8c6252060f989317ab395a3dbb98c
BLAKE2b-256 5cf0c7267fd93942e5e5519f4f842eb1b470ea37bbd13ff4b299809d1ff27f17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ceae3b4dc8b55fd4357f54387bb212a4769838ec58f3016961fc6026d5bbc6a0
MD5 887b438abdcb0621c771352e98a84afc
BLAKE2b-256 e9311b8a47292bca7eae509966d47260cf82fea582da33d4be5f5a6895c75393

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 275faecd0d8d700c487c327635f7b1fe9d6917db3b537378db44025581cc6151
MD5 a081dc5d2a1846d4bf496ff1980b0761
BLAKE2b-256 4a96f6841c69d53b8a270c89bc3b16525344654114874645d3d415b96a2724b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c9227268db8741bdab3ade493b5a7d3e5da193a21448990501a065cb08e17836
MD5 85746dfd6abf340077e1c6ec64df893b
BLAKE2b-256 252635403d78ddbeb0570f5fd409ddabba65336802673c79467dbc6ee13858d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a89484f26312179b9f62ba752a96072f1de9e0f61690f1881c141401ebad24c1
MD5 dfc88ff82982ff437c748bb44363e061
BLAKE2b-256 6dd1d825b5c59cd10ef220150f923d5b2ded80ae9c0b2b34209696e1ec9d23aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e7159e499eeb2a40928be946eb343a8e9d51a4afdc43d73adaa2875e1707e24f
MD5 f789b34f20eb7b8a4759393466b1e6e5
BLAKE2b-256 dae67ce4d9c20ccce10ac79fa8e561d5be3bba158c44d8e6a85f6201090b1095

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e3de70dee8c95448052cfe845ca2adb9a0d0af81675095151bfd80a823fc614d
MD5 6e87bb5590cee19189d80722a197933e
BLAKE2b-256 9e5a6ac3fe4023c2482699c1948aca6c2a394ddaf5117aafbe2f6073111abac2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc962714210300-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 439d2d50be9eb8d567b4c1ee1ccf3057e94c29a1af98ab35a7e10e4bacf96ee4
MD5 a176621fa01d1ac2f69e4e50cf363547
BLAKE2b-256 e78812498c4274d9207f300af2728bf7613a0a6bb6f3b8c6b29748b53eee5c8f

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