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

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.15+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.15+ x86-64

power_grid_model-1.4.0rc967016405994-cp38-cp38-win_amd64.whl (463.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.8 macOS 11.0+ ARM64

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

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 628ccb17e01051ba5003e236fa5e37af90b35ffc569e11b202ce204c28d0f7f3
MD5 7cccc69cfcc3f5f5b06b07f24dfbc933
BLAKE2b-256 41164b34f819df66ef8332c677991fa8667412cd69fd46f455dd319718ee4044

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ddf815caa92b004a642d1ffa117a78ddfba4e6610baa5cff72078a31f2150170
MD5 9e092cfe9e720689d272f3757b20a2bb
BLAKE2b-256 886db04ea13c5d955f28513e1a057142518855572add1862e149e080909445fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 08737f624a917b0c250b0b74009309a417e0f3f1c9146cc2ad112e9bb3bc018d
MD5 4302ab5a52da9446f9ea2280c426fd26
BLAKE2b-256 11fa61e9afc97995611a431087ffeda7ed99b97d180d59f49874044fa546b632

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6e72ecb06d040dd17fb3e0fecc1948af6c31416174dd5f84e758d675f7c5b63
MD5 0e2c745662a271b77b816b5fccf347e1
BLAKE2b-256 5512abbcc39417c6212d62cdec836708c9ba39919f6e624e67dfa0029c7472f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 de7be6178f2a02e718b7fc61c8452593a762748e99294e3446f0ad6f3c407ee7
MD5 4cdfaaa5c5b60c29ecf9799af3796d7e
BLAKE2b-256 418e7e23d07536959198e94855bcbdbbce4e9d1ca9c0dca3ce336007b68adfcd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 075bac2aa797ae6cc73410d92a32850c19efd4312ab355bacbe584dc9342ce33
MD5 617810d21fc9b5619f500de685632750
BLAKE2b-256 bd5fcff59ac4c596ce51cb67084fb850aabda918b202fb850c2053d7f316cd71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e761050f940dd58581c064befe7968947d35ceddbfb7809c283df1edea24495f
MD5 9f49d02a305bbc7cc30b2e74f3db5226
BLAKE2b-256 8303ac72de82cf9f0b886aba53696eade70635a4310dc82f8dd00011d7e22c43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 831d9ca210a12744a0d03bca887c81440351f0040d58d1fb76c915655362ac86
MD5 cad2812880fdb46ac5287abedf417e37
BLAKE2b-256 6699c5faaae6e6f966059935d6089500fb4585075a39e9d6976cc89b09493573

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6f8c911c60e01941d2ed1422b1ecd58cbac93fa82b674d5f2d63ab00fefb3b3
MD5 7a93f5f8c6780ee645cf6bcddf032059
BLAKE2b-256 29222e196debf5200fc83a853811d1e7ecab57bd422c8cad0c8ac0d528b28470

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d176da43566bc39a87aa9e475cbebb46a87e3081ba23803dc3905d503973c9ee
MD5 0ff0d9a6bd44c9ff5e34b690db572664
BLAKE2b-256 8370c26d316d5f860f9a99c4853a7b7d0643b212f2b0f0ba81a7df605fd234a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b3fc4706a88e54ea002fdde173d64c3010035786841b02ca9a98ff18c2205c9a
MD5 4eef4757f79c6c991a944f8edc03326f
BLAKE2b-256 22171d83ff6832d5b6eda29af7b7b7f13e8a30912a8b2e78e8abac6a1c75bbba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 98ebb845ce4703a05a82f225386dc9b3ed7ee166458a09c3d3ecde2782f2caa1
MD5 da8c17eb2e87f8fbe601740abc413406
BLAKE2b-256 8db94f87957d5c5f2989db5a5cdc1705ee55eda3daa30e07819896720d308245

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 818363eb72751463c246b48424241568f5c903a93991f6e3c0a63c90fee498c0
MD5 ea5fac866e4a5a748818c58042657865
BLAKE2b-256 9348b0c8be2d8e09d9da54c4e0c4f6b2a20a62cb47a470e56a4a61d3deaa9dbe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cec330489adbf7c0c83571141480e660e98cb16d2afe517cf568f46c2a2ed317
MD5 39891a83b29f8994142a6c53b5a415df
BLAKE2b-256 ad45651c0c4846d1636f49e082b129b4d6e9888bbfe08833f508c23bbe595238

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc967016405994-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8376d20c8a9e18d34619f417ebd1ad3edb62137402599ff38b3cb54170e12b55
MD5 7c918258db4d0a12c3a1aefdb591f4d9
BLAKE2b-256 78d8cb7d748d27c9a890753d7b7b375150a8ed643e819cafb55d09143d0328b2

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