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

Uploaded CPython 3.11Windows x86-64

power_grid_model-1.4.0rc976316120145-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc976316120145-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc976316120145-cp311-cp311-macosx_11_0_arm64.whl (475.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

power_grid_model-1.4.0rc976316120145-cp311-cp311-macosx_10_15_x86_64.whl (509.7 kB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

power_grid_model-1.4.0rc976316120145-cp310-cp310-win_amd64.whl (472.5 kB view details)

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.0rc976316120145-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc976316120145-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc976316120145-cp310-cp310-macosx_11_0_arm64.whl (476.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.0rc976316120145-cp310-cp310-macosx_10_15_x86_64.whl (511.0 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.0rc976316120145-cp39-cp39-win_amd64.whl (471.9 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.0rc976316120145-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (573.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc976316120145-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (553.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc976316120145-cp39-cp39-macosx_11_0_arm64.whl (475.4 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.0rc976316120145-cp39-cp39-macosx_10_15_x86_64.whl (509.6 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.0rc976316120145-cp38-cp38-win_amd64.whl (481.3 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.0rc976316120145-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (584.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc976316120145-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc976316120145-cp38-cp38-macosx_11_0_arm64.whl (484.7 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.0rc976316120145-cp38-cp38-macosx_10_15_x86_64.whl (518.9 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 deacae17e8ad859ad2aba4126fb7aae2c451e74117f45e452225776d7250d790
MD5 b96d0d7360c7e5f1c0e04f6be7f61425
BLAKE2b-256 a473af64b44b86addde1910d534fc64aadfd88b0baf5b1f59055c541ab0c8ab1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f2e54235a822ceb88144684470c40fcc9307e1ac899ae0dee0436c4da5abe5b
MD5 d900b3a2503591662e11b4613e92c557
BLAKE2b-256 6eeaab0df7f09e5c08294799aefe70491140275f3ab783e5da4952ca40492704

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7013262444e2bc9e463ea66ce55ebe8b8d6a0d20aeb9ecb62783371de2bd49d3
MD5 35c7a47a0c1a01368a16b8866c733ac7
BLAKE2b-256 f45e9d10248422e2ed4e98e368f284d103737ab7b2534bfb09c813f44859394e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d5136002c7288c61fc721e61c35230557c0a77d7d80d97e0dbe2d4f1db9e4885
MD5 6c342ebbaac207541198e5f65013e174
BLAKE2b-256 b170b9387b56f9e7a45a4e0fdb929d84750258170e14ae6e53ece5e9e30080a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e4348af827d58e76f5674a55a164173dacbf81ba839d4d5b2b0354a9102a6fba
MD5 d55059a6f8ee6d4f0072c44fbb055151
BLAKE2b-256 672e463e7c2ceab33b02196f5e08aaba40db9e4dab658a1814f943e8894b4b41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d15d1a4611d7114d5c07049898beafcbfac85c6a7b88b078d3958711ba72a938
MD5 aa202ca23709c2e15a9a0fd4c95159bc
BLAKE2b-256 088942981c3728747fed49c2423cceebabc2a37da93d770296202194a6d85517

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f30bdfc2cf52a7f329e7cbe202e8f759205f30fddce4d8d5e1340af3b953ae96
MD5 fbc1d3d2e0cbd2eeea9f3ff40b651019
BLAKE2b-256 b054ccc7de2d69c9b427841672398f84807c94a57cb55664e7e1b6485473e5a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 db6a87aa064060801402cc3ed0888f9c661a373fd8eadc6c77397643e45ae258
MD5 b233746ecf9262eec79fee09e31f93cb
BLAKE2b-256 1fdf689cf805d8053b2ddc5e21dc2e33b93855c35b3e70156e35166cee38ff48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d18977a5fef55485b41d384748a8ef303d5a7dde1441e3c2c10956bbaf60133
MD5 1a3139ec25f0dd9b1528bfaf963a0253
BLAKE2b-256 0722a2f421e725ad3f2b51623d790f27c7359e279e114cd8c9d786af31455517

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 2823fa8ddafb173948b86ab263c4d81c17340da8553f2dc696e7e176f2b988f6
MD5 727d185ae64e315eda54934cae384f0d
BLAKE2b-256 205244075dc923034a4ba1d8435130118988a6119f7ce9308e8cc520d7d24a99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8b31870b098611b915cb52ed580d5b777fda0340adfc4953baa5b3d38ddbfb6c
MD5 ec24f0a70956fc30aca233a7eb86f799
BLAKE2b-256 2594b0bb0706869a9f71fca012bc8778c4967be531c81e9f8cbd9313c55b86e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec4129aefa26f5160e1e2cdcd7fbb7f22a4c7842ccb7a71dfc5beefc2d912a9f
MD5 5b9ffe26225e9821d7a086db8e5ee3ce
BLAKE2b-256 227c6e1c935203e9173d7175f75a2b261533e617d825ffca2163ba6c0e78ded9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6ccbf1b19226e7f2f2c8ebda09296ec0083e334d1431da3007a1c6cb50a0ce61
MD5 674a0ed21c0e284918ffbe025f8bb0f2
BLAKE2b-256 3fbc3668408e82c33611011eb7a1b715771a656e3670bbb6af6ffae27700567f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c4f5421f57359efc53f9934c6b6cf7453bad8a1a13e0fdec053dda9d33e4484b
MD5 e21768d5ce5389cacb599a235acd4596
BLAKE2b-256 375ff37a9d5223108edf23c78636e15b323d8644ee550449a563370cf9073e1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ae8b91e7431db37d9788951f470a34e0eb1e9986d6842981e07682ba407a1a81
MD5 78f7b95df5e1bbc5e30be02403328474
BLAKE2b-256 6633d82eb878bc4128313b0a26b36b86d13189ed68f4f7e7e796c33790859175

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b4c64eed50df0cc0e88d84167915b1577dd8e103934ab6deb1f8d562d7b6162c
MD5 699b912234af00f8b9a82934c9d96ae1
BLAKE2b-256 73583016294ec9a238560cb8e943b7afe2a249e90ccdb3f4cc39124a35aab9bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2564f984060ecc03a9f0a407dd73a694e0d1f65393e91dffa8c88407206383a1
MD5 2edf189c3193abe1a1b61c955f42d2c0
BLAKE2b-256 950508ba2590cacb5bdf01900598990c9554bdcbacdf19bed54943303f5f0809

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f46732ef258dcc3373df809a19550b4bbb79cebee2c89a007f9332e589d62617
MD5 a7e1ce3f4c8141467c8e765512a34857
BLAKE2b-256 dca4abd5bfbb21dc5c90f7c4faf516192d69fa402a0b2d569a13bae27feda6fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9df2ea7efa744fd6578554e6dc53dbb6fe9eb736ded03012df12895c020b923
MD5 3a0190acd4acd313648b1e82bd7699dd
BLAKE2b-256 ed823f2c0d7b8e45ebd184b7fe61d01fcb21af6ad0e819c50494098dfe505ab8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc976316120145-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 b9a6f4dcafafe36f16c5c99e06c4efe24ef43048d3eff7212628a0ec1dbb7e81
MD5 65dc6dfeeb0e31596a5259b9cae43d35
BLAKE2b-256 8f96b5ac17ef598277f764e23fbcf4d3b7823cb1aaec41d32b835cdf0e230091

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