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

Uploaded CPython 3.10 Windows x86-64

power_grid_model-1.4.0rc960013026076-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (542.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc960013026076-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (528.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc960013026076-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.0rc960013026076-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.0rc960013026076-cp39-cp39-win_amd64.whl (451.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

power_grid_model-1.4.0rc960013026076-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.0rc960013026076-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (527.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc960013026076-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.0rc960013026076-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.0rc960013026076-cp38-cp38-win_amd64.whl (460.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

power_grid_model-1.4.0rc960013026076-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.0rc960013026076-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (528.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc960013026076-cp38-cp38-macosx_11_0_arm64.whl (461.6 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

power_grid_model-1.4.0rc960013026076-cp38-cp38-macosx_10_15_x86_64.whl (496.1 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b413928de3d1a12b4e83e8e0a624ddeadd51e2ce0c559f6bd80c4cee7442aebd
MD5 9983d16047fd034a18977d7b3113ae86
BLAKE2b-256 d5c23a1c690c380346842097b2d5670994ca3a1b29e5dd888a55ef8977975564

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2d5fe02a7a6598d70a952ac2f356c2a029ecb09b99a742e4babaade777e345c9
MD5 77b7ae8f6564547414de29a5447f2b0e
BLAKE2b-256 fe8c08c819a90a499546334c85860a97f45e4905dfb224abbfe97c9638fd9e3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 17a68ba6e82343c34aa39c7fc696953fe1c626d207a110c9105507b98df05c64
MD5 0f74e182e3da7f8a05dcd74e0432e45b
BLAKE2b-256 102f3acaadc6e1035c8e98dfdb75c644b473940f23325c9184d2c2e54522198e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 931632bcb05316859b50957f4aaaceb21883e463fb3d98d4898e046ef7cdc507
MD5 29767f08b9bc295675f9d32a221f3756
BLAKE2b-256 2003a0b0ab34b7610ff77abf001f3859abba972bdf58296968f00ba9ec9d595e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 2e2f9d60a9f36487ea82efa2519123a26db4954af893a1e705a744113246ee22
MD5 3a11e82d69f34e132e5ce89761ca65e9
BLAKE2b-256 7bf573088b2d32ca72eebd87443189d383e0b01b471d5229921a7be053c62178

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 badc1504a609a605e52569cf54bcba126408bb9e1f64894aa269b949a7f17e47
MD5 4a46bf803f6e54864773b85110ee3445
BLAKE2b-256 5e6179a2ea24624c2b97656cd092374ec7b5b031a3099147901cad5f4ca1c03f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7cadbc8d7d863e4b233cae0c0b43f29044674d4f434cf94e71ead931979228bb
MD5 f98ca8a4ae61a7563e084574597dfab2
BLAKE2b-256 0900d6b0718c671e4978014ae0f9b1c33adf8f1638a138fee7f6802bfc2faf1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 097a6c08d5ac84d6ca5ba232938e7a0d31c1eb0e3c327e35585f463ef4b55495
MD5 2126c42215736787f7b5e9dbe6e9b1d6
BLAKE2b-256 fa3c407dece35e6e21977bbb15f7f1bce9fece11bfe488188f2b7950e6e02958

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2b54b5e0e3cec530e48cfdd21f023fff97e3b101879b941e9daeb75f87757153
MD5 dce7d46b151fbadf022f9301c5e42482
BLAKE2b-256 6f8e7efa803120c1349f46b6ec330057892972514166177a669a52b33e3a22e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d4bf161593c7b6cbbaf9040814aa6e43911b19ad51c43dfbc100adab3c27fba8
MD5 2ca42c4617fbf825848dcf15a535896c
BLAKE2b-256 7136016b15ac877d5b6cd30c9e32ad15026f771aba5dc18bd95822e469ac682b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 9c721720690fc7a4d9b509df726881dfe9d811aea22da2439d618d61d119ea4b
MD5 18c7f0787bd0ff356845a865f7f966d0
BLAKE2b-256 7fd134ce2857f91c2c6bd802f711cb451306b2fa94763670b0ab91a20593d48b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9c69e810d922b9a67ffd2e8d47d76efda0121d9fa5b6ec71b9244c7adfe4bbad
MD5 1f8210dd75f11cf658ea6b2ae428e57c
BLAKE2b-256 a2569e681b9d51c977ce5b1476be901155d44e9b3f523357a5b0cfe2c34f706a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 48be706e0caf573d9b55f926aef449dff9f058c678157a2ad32a4825c5c10d61
MD5 12a55328104abcdb833c5ef105fe4aa8
BLAKE2b-256 17dde1e18302e5edd1f1519eb9ae2361969fdfaa1625181e6c80c512b7fc7e9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66561134f71db3c5e43f9d92824b05ada69cfa0fa0a33a645a9e179ceb581651
MD5 6333aee6f8938c947910fbc17953b34b
BLAKE2b-256 7f63cb5c81febae8c4b6441fdcea085d9a0f46b2c1a042f55c59b6878bdcb648

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc960013026076-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 0db96eb68574f49ef708f038b9d393f43a2d1afb8f34825c9f555855d3ac7395
MD5 b282a55bcb5b4ce56b415f954660b61c
BLAKE2b-256 c360692f762c37bfd3d0a4b322935667026afb0575a443423daba2da333c2879

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