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

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.0rc971314394601-cp311-cp311-win_amd64.whl (454.1 kB view details)

Uploaded CPython 3.11Windows x86-64

power_grid_model-1.4.0rc971314394601-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (544.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc971314394601-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (530.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc971314394601-cp311-cp311-macosx_11_0_arm64.whl (455.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

power_grid_model-1.4.0rc971314394601-cp311-cp311-macosx_10_15_x86_64.whl (489.0 kB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

power_grid_model-1.4.0rc971314394601-cp310-cp310-win_amd64.whl (454.2 kB view details)

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.0rc971314394601-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (544.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc971314394601-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (530.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc971314394601-cp310-cp310-macosx_11_0_arm64.whl (456.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.0rc971314394601-cp310-cp310-macosx_10_15_x86_64.whl (490.6 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.0rc971314394601-cp39-cp39-win_amd64.whl (453.6 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.0rc971314394601-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (545.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc971314394601-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (529.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc971314394601-cp39-cp39-macosx_11_0_arm64.whl (454.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.0rc971314394601-cp39-cp39-macosx_10_15_x86_64.whl (489.1 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.0rc971314394601-cp38-cp38-win_amd64.whl (463.1 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.0rc971314394601-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (555.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc971314394601-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (530.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc971314394601-cp38-cp38-macosx_11_0_arm64.whl (464.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.0rc971314394601-cp38-cp38-macosx_10_15_x86_64.whl (498.5 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

Details for the file power_grid_model-1.4.0rc971314394601-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 66619c0c972d43fc844b0bf88192831632d5303cbf7a0ddf02d00aa426c060af
MD5 6a6e610dde77ae2c3ac6004a0a9946fe
BLAKE2b-256 f3a4d4851147f2fbc5892d347a5ee90e50a064a45f0d7572370eb7ff8551c98e

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc971314394601-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a36407d4ac33ea263b5bfed851d9f9fb6cf96f15df4805b7bb50eaba4ac03a31
MD5 240a680d246fecfa07c45a54e9c3ef59
BLAKE2b-256 ea186a844e13e5b4e17242ee4cadb1a97a402729b19eea736d0b04cb0833a412

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc971314394601-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 794c845a3f1d6c7f947dccd8c8bfef4c896affce46b227f58314bc1f56bf0094
MD5 bdffcb2335915dcf3b1be1b6387f386b
BLAKE2b-256 c5a1d8ac7b65ed3868a8be47c29826a08b36ff8302bff4fbc66231d358a03189

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc971314394601-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e538850ff7b85d64ba91040bea150ca3591281dc6d56bdc496e17e58dde5d166
MD5 491574a0da1e9876516ad8e05ebb1542
BLAKE2b-256 b0e8c848b094981d3f36e63e56e90a02229427b89cc23cc978dac7b1f96c26a0

See more details on using hashes here.

File details

Details for the file power_grid_model-1.4.0rc971314394601-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c8ec7ceb0fa1084dc82bf8fb44cb996ad07cc57978a59605c55d77e6c4ebf36c
MD5 d16d4f7b82082c40e6607b020dbe7c7e
BLAKE2b-256 52297ffa88d2c05b4b4549b47cc30d00ab85c4b0ab4a42dffbfa0f7782a83b91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 470ff8d8efe161155d58cfe5fb0d7681204eb974734093293f98405eec53d6aa
MD5 da43bd96b2e915781dc57093c1140c33
BLAKE2b-256 2040d1fd2296c928dcb0b8cd1b15257e444df07fd213c58d9884ae7682a97952

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6733b3a8380541552752d2e9ffeb2f4461c43871d11ef81f2944a338ccf12eaf
MD5 371ccdfcca9644bde5bbef21e0f9baf4
BLAKE2b-256 c5af237bf362f3c38f049d34d01e84652a67b9f319cb0fb7f8eae9452627d775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bd68734b4e331e9f8bc1cc778d01e6bd5fa8d66043d6f1823855a7e0d90f1d78
MD5 1c4c1df31216f1d93790f78b45117734
BLAKE2b-256 34039c8dab2d33d7b1136c5e60e8ff1f44153642285d71c296dc9694e90e574c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26691408d39162afe8ed5b25c4b667277c8c1d6f8cd940469fb27f68ee07e8ce
MD5 3092dbc9e363541f87094ab40e6631b2
BLAKE2b-256 c9f3a9a24d05af58b0d6c1a1c861651e11abe4eea3c3c03b0415929d75b4d88d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 207eec52f7bcd7eda15f0b618276132312eac3c0c85121a4be1fd647198cefa4
MD5 672ee8e744440a2ea1724c0996f559cd
BLAKE2b-256 e8940a51e4941ac95865bf6bb4cdbba1ea4a5d5c043d9f56ceb61b237fda7422

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 22f6aa2586375a041f1dd1ad89d9fa922d3531d6cb5cfb07e800f95b3e8294d7
MD5 d6b7315676d7fece11a83becf0fccbe1
BLAKE2b-256 160f4c74ae1b199d2ea40a28f511905c60b6d9431090c67ec1e9c88b26d43cb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c65577912064c9614a9ad4c872946eb2b19d39a20c11bbe959c80af126d1da7
MD5 0aa05a179d1a502d7ac973586740f53a
BLAKE2b-256 a9d4699f888b4f1716e0e4ff09a50e84d34401e7d5c10df27e59e43f1cd6bc1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bb90d0e381dd9d7c9510ad9f8a50807ef48be96e1eba1b60c57959f0f367595c
MD5 78106092f195735b50e39b089a2771bf
BLAKE2b-256 fc29f8eded9b7df6f3fb121894924b5f527f6e89b76b403ece0d270f969afb94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b5da707c88ae16882fe36ecafc2bc41df38f0946909dc87e287da572c2180b3
MD5 0e8b07189b96a93f76a6fd8bb47d7ab1
BLAKE2b-256 c0fab3d48aad43d3a72bb2b479fb74d42b82f6c28822829b45275e705508115b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 16efbd2d90665cd157171a9c330f83f403d583ce326ce14ea957dfba2d283127
MD5 fa514f642a5c64a74c18fa3b845d7ec9
BLAKE2b-256 062ca60e3dfe591656d45d7d964d21cc09d2c525e66aa790eea4b06514c30872

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c0793ced291e10cce4fbb2a97c4b407559db573a976ac64fcefa610403413cd0
MD5 6e091d8f406946f8ba1a60df4824d325
BLAKE2b-256 888213f80b238c3eaadee2a812412bad88fdaf011b7802dc3c7a962a6c0727f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 186ecb87037d569e70a8e2552955260d75c1ab4d6d39c9de2553d87b9ad08550
MD5 4a41a440219ee6e8b6b1bc55925b7512
BLAKE2b-256 7284bf1e3b4eabd3429fc4d2bad7aece02aa4fadda7345b4308dc82b9a345fd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 530ba748cbe4e75251ce7f93743256632b058f67d3b4d237d8c91e3c7fc7c368
MD5 0e075acbf1237d36963adc22a2a29be6
BLAKE2b-256 5d22af35867333bc5e98ec05c2a8c538a36c57ddf1499f45f7835fdf66be14e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea4d15789a1722112e2392d5aa6d4b3f47851bd1cfebb47a144a74545ec73491
MD5 18d9770cd468c49016a370d04556edb6
BLAKE2b-256 b59ce04eca8c3bedf204c19b813c1de9ad3a7ca4274a9a6cb6cdae702a205444

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc971314394601-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 62b1ebc41209f66efe7844507d074c722bfc1b21b2e92cde733221fd5e4ff20c
MD5 760738ce5dae42d3710b6c673a82a959
BLAKE2b-256 819fb20a271c85c81792280d79037e722616406e5b277b771fe738a8e8c1f43f

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