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

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 10.15+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.15+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.15+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.2-cp38-cp38-macosx_11_0_arm64.whl (487.7 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

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

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9df6a1e9885c53afbaf9a8ffeb9865ec5de1457c42dee60d18bec28e9218ba6f
MD5 b09a5f6a9b8ecc4727db1dffff89342e
BLAKE2b-256 a06c7698b7754e0c01552f4fa78f5ccf8cb0630ac1ea55eb61550c1de2951232

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba6fe4036f4384a3fba87b2788ad83a6644ce1df95a17d9e9ee3419ff65a43e9
MD5 a90f8cbad536ae960b2841fbddc17075
BLAKE2b-256 9944ce2eaed0f17fc31d56ecfc8225d9d4ee88f224828b8b7c6133a716586ee7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 94a4c53ad52598fbd970d92ef3f979c274a1c4811bffafde1cc21d1901b8e856
MD5 3a394bf7c173b529ea063b61aa347e79
BLAKE2b-256 9fd4c7a4ceb7e5d8b0481ffa520ba376bfd7158eae530b5b1ae550bc03ab5e6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bb95c17b7bfaf9ca66f784edaa43669a5b60067e20457be03ca2c1c06801918
MD5 0b46b89942df179fd5594d30ba07d4db
BLAKE2b-256 2d4c3e797be32b734edad1c8bc3761dbd45925aeb50452a84da364cb98b3b7fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5374ca436f7c5893edd7e5131fcc7f22d4cd0c0cc47b0f104eb837f8a616db6c
MD5 f55e9f928ae43bb645d8e0f574526a2b
BLAKE2b-256 75cac2fce5e7460e0700615f4039a72629a43481bdf3a6921de93191909a8f93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 35fe50b32edfab00a042728a43924e07bd3ff2d710477d476bc02b21143b2dc3
MD5 a876679029e7df37f7b03bcca23cebc4
BLAKE2b-256 192a13e5444c591b46fc308ff778dce95c67d7c0f71b0c2ffdcbf761994a9ef5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 01477d1cee10c1a980dfe580fae5da643cbb6fd955bac730052536bcc13059ab
MD5 bddd49fd4cec73b60c72fbec49df31b4
BLAKE2b-256 9c2db8dd56ebb823ce1057689072bdee0ad77182b24afb5c32bae372a7e1cd79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f91ceccfd836a15214513a352c4e4d12804fbeb66d17134262039eb0b4c017dc
MD5 7094da84cf21813ce985a1ba57853984
BLAKE2b-256 3bab6f342fc5c928b7e02ceae203d366c0facba09a81ed0e569481dab193a254

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e70bf7a5e04700b693bc743a2c28b17d57eaca13a331e0f468e7c6fdd4033a2e
MD5 b5c04d66cedf589f2162ee915bbcd65e
BLAKE2b-256 174b1f0130a6d92cf159dae5727a9ae0f815d39bc695c14edb5912657b82580e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 82cd8be902cfd234797faf048674b81f88c830a48d39530dc1f0af87ff012909
MD5 dd7a29b6916a11de40a321e410e185aa
BLAKE2b-256 c9d82f43e4defcaa0b507ec8f5dafb50516241efe3da13fa205e0fef7129d448

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d99a9add561384634b1da4acf4c139e17d4a16648facded7839102b3174aa43e
MD5 dc0c7f45d9f4e4aaaf25c875c8300b9b
BLAKE2b-256 e1f4a6049d5e2735c40ece713638ec6f90f82f7b0f3caddd9f957a760dc4c08f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 69719b4731bf21391fb6daaf60a55cbec64e22d29a6b68152fcfe16ec2d4696a
MD5 33281350833283557969e73f374cc806
BLAKE2b-256 49ada9bdb22cf313dbe675ab1433f20fb1d64a1b7668f97ce5c98aae335f5f8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0df327f9497c2dc3a9e9ed262e94a6f7513b7864b1e902fbcfe21c03ab3a1f38
MD5 d6e5ed82bc3a5b9de3191e7a9cf2e19c
BLAKE2b-256 458c76386cfcde5f277a2cf27065f8db6d16640853f26f5268416c8cb1604b95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01b1e1f7167c4780d3379c09f7c146061d501cc8095c1a3be737b835fc41c144
MD5 8086aa358473f3da47f9bef48adf7ff7
BLAKE2b-256 7daae7a8854a7f59d3decec3976904b0258edcb23bc987d328ac8791a0bd3851

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 2435eeff04e9d78d2d94b3703b795e67079b81441e112530eb48ff0997448e7a
MD5 c110bc52fd7ae18ab1e6ef296f6bfeaf
BLAKE2b-256 3fb11646d72c8c158c8080f747351664047d8fb8998068b863f74196901da9d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 253ed8550b7c025997e1df19b0130fc153eb3821b237d8a1b9f8ba30bb68f380
MD5 060fd97956bd3ba0b06625538ca7f443
BLAKE2b-256 4e600b4067ead1c02251c8460d2e02218e1dba870296dd08c6571bf83b3cd0ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ae759757f0d4f87a7a988b72e634021ffb7f3d1c57488559642e45dfefb8873
MD5 267820533b1c0ab6ef44a8581e6fbf06
BLAKE2b-256 0058bb3d5e74b97d8b445bebc616371fcd93b42fa03740ba319dd7f85faa38f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bce06b362737a51469c14f597480177314e3bdafc08124cf80454c88593abe26
MD5 f29fdc5d02e682715c81269450b45dfc
BLAKE2b-256 752a389b07f5b40df04f0e4cd1214d835125d70e7a31e5baf38741c26f5558f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b0696c3a544dffdde362b2f6679bf484063f92593e443293fe863dd0de94ced1
MD5 4bb02e22e7a4d6b186baf45329f9778c
BLAKE2b-256 aae66971d43b5ffd131b4b3dcd305d6cf917d43ea5d004363a9fb19cdf254883

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3e0d2110c78993aa6fe2667521b37d1eb6d97bd09ea6ca028938369af907f916
MD5 7140e2acf2f08fdc431ff754e6f046cf
BLAKE2b-256 64f509dbc16b00cb3e034693b843075f700faa7c06ffd0a9e1d5ba520d66aa5e

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