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

If you're not sure about the file name format, learn more about wheel file names.

power_grid_model-1.4.4-cp311-cp311-win_amd64.whl (475.6 kB view details)

Uploaded CPython 3.11Windows x86-64

power_grid_model-1.4.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.4-cp311-cp311-macosx_11_0_arm64.whl (478.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

power_grid_model-1.4.4-cp311-cp311-macosx_10_15_x86_64.whl (513.1 kB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

power_grid_model-1.4.4-cp310-cp310-win_amd64.whl (475.6 kB view details)

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (557.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.4-cp310-cp310-macosx_11_0_arm64.whl (479.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.4-cp310-cp310-macosx_10_15_x86_64.whl (514.3 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.4-cp39-cp39-win_amd64.whl (475.1 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (576.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (558.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.4-cp39-cp39-macosx_11_0_arm64.whl (478.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.4-cp39-cp39-macosx_10_15_x86_64.whl (513.3 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.4-cp38-cp38-win_amd64.whl (484.4 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (586.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (558.4 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.4-cp38-cp38-macosx_11_0_arm64.whl (487.8 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.4-cp38-cp38-macosx_10_15_x86_64.whl (522.1 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d85867dccd1445fd3bb040ef0e077ea0c09dbad1fe1ea37715044063fe60da54
MD5 c5e6eee69bdf47b20309c4e3127124ff
BLAKE2b-256 7c9bbc35a1592175333c8e1d8d54daff3a6819e8e88f2eccba40e5029b2100d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bf96bc160f29bdd9c8a061e2554b5e49d8915b0f8b778dc7a76e6612a2672e72
MD5 1c898d6e0be3d456caff11b80cc7f5b1
BLAKE2b-256 83229d35926fb9b6c6a4ab337fe3532a455728cce78b779e50943999f3570c1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a03163656bfa8094db07a7e69fd69ecb26626a9be98b22be9e75a4dea073d47d
MD5 484ed99ea72beab2dcdfe05e5a256e9d
BLAKE2b-256 384b24b97cf8eafbcf2b58ad25821e30a6b27a2b5f2df2bfb360417e88d94761

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c0d88797d4c3f7031781e177fb2a54fe109e89f5141e435ed746f5727f560e8
MD5 7627531299ee0ac70fa870707f699582
BLAKE2b-256 828efa8a2030861a15411ef98326fed6515504821bfb9c091e26d20e70e53ac9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a7724b31648f8b88b669d2235a89aba96293feb42a9950059ec064b9bfb34106
MD5 f68b7f49a232597496858a21533fc95a
BLAKE2b-256 0b72e985ca9bb13bcb5bab56d78675f2a8d41efd04ed9ababb9252f7d1f944f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fb0b5937dff56eaebb32cc5274df494b377ac04d4a15fab19f674eb496d9db50
MD5 aa3a46dae4bd736537cc9dd9c7a600ee
BLAKE2b-256 e1442f8e6286ab5c0e5e5fa4d1311993ea7bab6ab541b76a57011187450a49dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 74dbaeb78c840f0fb3ac8f2b87929fd0de8647967a1d8541be3068b6afb5f87b
MD5 35778972337a77942a822bf30beb90aa
BLAKE2b-256 b322dcefdb8b373abb6dca57f45788f2d4bb2ec91841ab334ea7fe65ddf713fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5b0163d783422f156a243a8d8281fe6ea1a1e1df4c680b12b89ce4ddc8cb7d36
MD5 a9714837489afb8427074f085519a472
BLAKE2b-256 bf040d439e2f2a6c1e9b2a6813765ee2530e79b12a0291f0eb3e97147bd9b3d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29d70f97ba15c64a543413c66fb4ef527fa3620c2f8eefc97bbb9416fce3a8ab
MD5 3b3bd003366d269f37b4e37932421a55
BLAKE2b-256 8779a3a9e2754177b02dd6ec2746a50fb19d436f239d8458c0dc8758ca3011b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ca7980b083a2dfa748400f11ce8e9d5ef8f766950774db5d37cbf897a35355d1
MD5 2e698f936048533106e7d2c5bb5f20ef
BLAKE2b-256 fb54257041d271de5ee862533b35efdb1b1601255c2580b0852b69ae7834d5ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a7800b327e83016822c8b723b9358a29b9b864b19f47b3805127e19e5997c1ad
MD5 cd2f89e9d22740822355a4815a4c3ee0
BLAKE2b-256 1b232eb26c45a157c4b03b066b8851d3c91b6400d8a95753c401979e7642a34d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 77b91664d1c496bc5dca1bd60aff99456219839193f5b065e64ba7341b53d0a7
MD5 cb6df58feb095f860b06e13636e58972
BLAKE2b-256 ae527e30894131c0aeafee77165bf2ae5d889d7cec885a93399d20da80871d9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cef2dce499ef3ccda96cbd96e790020691617c26899bef6abdcc2fc1c578fa4b
MD5 7b0b208438bedcc83f4fba01ee2005d0
BLAKE2b-256 e6812df0fbcd72200930c2ed00b3148f1ec94a6f42bc7f4612655bd53cd3d470

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c895efcbb829230435ec5ca54c10ccc64eeb207b2412b6ef5b015825783b169
MD5 f9e5f8d877d6eba1ba02f83c45d2d104
BLAKE2b-256 68664344f600533079859520b6aef40aa6a217d0a02c75790200c2265c0e7938

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 b9ed0ef1f5f6461dc1c54611e066b086a5c9789d519019bf0cc71972fbae567c
MD5 9538acded246db03d2f2d3ef3227b356
BLAKE2b-256 4639033a94da69552ab9df4693d111581990b34a20cf159b3719877c04aaa01f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1e3f073f30e3566a61da479a22ac3570b454dece4c6f97f4749073094b23792a
MD5 f0cadff295153eed0ab0717125dbe929
BLAKE2b-256 bfdaedda145c96a7978daf39cac0f2a3be6efbd14c186a2e25b8946eecb8273a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 933cb5f7922a66271d2c92c344d339168da37f05ae021c7c6a3996775a879ced
MD5 2524412ea7540ea8954a4431328b6d6c
BLAKE2b-256 6f8264cc430b1f5a29d1db7202a4685a80ec1a21dde248ac5d3fba359a8b53f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6f850b73285a653896d68ea5c9ac82a7d6090d256ef15954fa79d22385e6f364
MD5 4cdff6534b431cf1d6e383b534f9d222
BLAKE2b-256 edd75b4580ace0a95b647f79e4984be22597c7cf3d24ea3d219ab1837da0d447

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ddffc9ce991309109023b4eef032760c26caf04f4542dd6040df3c1a39cb9b40
MD5 4ab41d6a980a55a617f3672526dfb65c
BLAKE2b-256 c5984d2a92d378f4a97a941780849c3c096526d8caed9d2a6cceab0a82b45657

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.4-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 dcdb2d2c64ba60b13340d94de875ea96ae53e80822b9f1a0c6822c819e2459e0
MD5 5820bc2a721c80e822a7ae6938ccd132
BLAKE2b-256 515fb79e740950375eedb9f40919a3411b226b5e4e1cbb407d895b90bfc9faa7

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