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

Uploaded CPython 3.11Windows x86-64

power_grid_model-1.4.0rc974214509214-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc974214509214-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc974214509214-cp311-cp311-macosx_11_0_arm64.whl (476.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

power_grid_model-1.4.0rc974214509214-cp311-cp311-macosx_10_15_x86_64.whl (510.3 kB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

power_grid_model-1.4.0rc974214509214-cp310-cp310-win_amd64.whl (473.1 kB view details)

Uploaded CPython 3.10Windows x86-64

power_grid_model-1.4.0rc974214509214-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (575.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc974214509214-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc974214509214-cp310-cp310-macosx_11_0_arm64.whl (477.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

power_grid_model-1.4.0rc974214509214-cp310-cp310-macosx_10_15_x86_64.whl (511.6 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

power_grid_model-1.4.0rc974214509214-cp39-cp39-win_amd64.whl (472.5 kB view details)

Uploaded CPython 3.9Windows x86-64

power_grid_model-1.4.0rc974214509214-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (574.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc974214509214-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc974214509214-cp39-cp39-macosx_11_0_arm64.whl (476.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

power_grid_model-1.4.0rc974214509214-cp39-cp39-macosx_10_15_x86_64.whl (510.2 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

power_grid_model-1.4.0rc974214509214-cp38-cp38-win_amd64.whl (481.8 kB view details)

Uploaded CPython 3.8Windows x86-64

power_grid_model-1.4.0rc974214509214-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (584.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

power_grid_model-1.4.0rc974214509214-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (554.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

power_grid_model-1.4.0rc974214509214-cp38-cp38-macosx_11_0_arm64.whl (485.3 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

power_grid_model-1.4.0rc974214509214-cp38-cp38-macosx_10_15_x86_64.whl (519.5 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0352da356e47e57bba40f9fee9ec14a06b367b997be0f7150ed587d9ee5f8e49
MD5 e26831e35f2523f75e2ee309abfe36b8
BLAKE2b-256 80fca5ec2f4d5bf97211c40d4e86a8ec97126eef5faad230443ba299390f1e33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c4630410e706f872ae53e3038f0c52d983a1f3b1e7301f76872e1787894a2c1
MD5 5f887b7112f4ed960aed73d23af91612
BLAKE2b-256 e0fa67fd385caf0e74e3f5e609f27b8a4c3f28045bc582fe73b439265a8b4860

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 82ae1f380cbaba3e5af75e78d9d1a540159e518f5e96d988fc843d498702ef7a
MD5 31d411ecd9a26c3055fbc1cbdbce28c2
BLAKE2b-256 412f8835104650346ffc8476e189118821a1f3b293157a2d1912e3a6f6dd7d76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e5b4d18e5879bea4fe49a29006ff88d03f41a2997fcb5694fd565c0541b1dde
MD5 1bdea0a59ed669a0c82cac56b374900e
BLAKE2b-256 8ca6e96f6e7a192f80ff8943c4cc2e8a8e86336cbe4bcb1b1536f4d5e5a92233

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 29af372712da38bc9e165afed04d145f1343b677581f16435ba6df73ae39f718
MD5 773703a490855b1ada909a57ba31f4e8
BLAKE2b-256 c54970effd40bc4a2b0edd6fa431879287851793ec466cb05a263d21feee9ec5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bff9657be56ee3cdcf40806d2172c6bf9f3d7c89924eff8a7e86e365bf4d3838
MD5 f6d64d92c3c61dd5434c4bf238607648
BLAKE2b-256 57e6c694f1ec87f13e6faffc5ff0ae191664e58bfe95229c347c2cbe0faaf617

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d865191a4587dc7011d925924e60a9514406caa34eb72c413c09a38034878616
MD5 d753ddeb0092e8fddde152c6fea8ee0b
BLAKE2b-256 c5feb5941e823c624dbebbfb3040b43d865af7146882c81669f03ec8ffa1fdbe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 63d1e9172371c100c6865cdf377ed688b8838d3322fb77a3203c9b71bf8c4ba6
MD5 3dd8624e0640313f6329f9bafcd92185
BLAKE2b-256 cc38ef6290914f528f4738eb1c148df52acd417fcaa6267c1785e9da9e9ced15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70e278d17c910d9f07bd2846ee2536cdefb53ca54a4f189171097acd35a1ad3b
MD5 2c11e10c2b99322d8626acde2747db9f
BLAKE2b-256 9d11ac33187160ba7a4467530c867b0bbaeb43c1d0ac332cab244f60211db32b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6fac33ea59b92f942a63f1241822532bcfa70f3494a4ae01a7ca6479b2c0503d
MD5 62f1cec950dff162789882f36dbe6273
BLAKE2b-256 e4abc16c16b6ee02583be3bfef6b51bcf4df9bf3a0c56fc2304a0fe202c53832

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5f6eb1eda7e055df3a82fe285feaf8e9487ff0dc7fd0a7d31f0fb73ba14f7c0e
MD5 32035e46153bb7868b91b1c3c24037eb
BLAKE2b-256 00c237ed63bdd0151597491a933a8ce0f685d4208b6d2c8c2ddc3724aaa3afaf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45bf04850206d04492273dc876f5a85599106f699ff19676b80c15f8503ff822
MD5 e30f5f28942c138481e4f9ae3210ab16
BLAKE2b-256 9ab8211479ee2140e62082612f5b5ab911fb89dee2855b49cc83208c97af499b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 69246b659800cfcceb518e5b7ac8c9b29ce375f3d74dd88b3c6fbe2a67c0e30a
MD5 964fe8f7a842d5ac3268b95ab554c19b
BLAKE2b-256 0d4a8861e4b3b27db6c58cdd7eda5b23542425a1d23ea92e41d828a2b1977fcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e85c73c1f9974c90e986efdfb7f0c3c28cd9b9235f009e0fe283c599a019e04
MD5 ffde28ce6ebb50b0f92eab9e4f5860f8
BLAKE2b-256 85ddb200a6bae6f6781732a4b6f323243bc5c71172a329e52e5d632983684ba9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 20b12c902fca3cb1d44e0ec907eb36267238931c9b5054629892c68de3c61804
MD5 87bfa76e806c4f72083efd521081276f
BLAKE2b-256 75efa32ae12012e6d3c747468d820d4c53de2dc8a1749af0c2a942d90090dbb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 22658ccda94325593d95b9b63c5c46f897a7ba501caf74618ad6d169549dbd99
MD5 6a7efaef2b8881b3c276776d146bf7ae
BLAKE2b-256 62413cf31e35165ec97f6deb813616a671e5e3234e083a8ca5a832eee2420ee1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9261289bb85166112b820b432f5e339b059dd481de020b8634d9290f9bb4d0c
MD5 1fac6e8f300ee3a03fe19d32dce13e37
BLAKE2b-256 c7f109996f406a69cede7073a04d5534eba24416e14b716f580409c1b166c517

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 57ef1c97ce86dd5167ad9e056deb55cb58effd5de96a2fffd0f12d4dfa4a9cf6
MD5 c23861e6d7ad0ea7319b5e23bc408330
BLAKE2b-256 c0279e5b9be8b74c1b04f03b167d99b2880ce342ea981d6f346c7fd22080339d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b1ca872870570887db74bcf7c8952e80d578ec64c261506db71827b3e136f3f
MD5 c70d48370ccff651352c56465a766efa
BLAKE2b-256 f14d140caa521fcf171ae5e67495b51fab98a8113dfc517f92155035d9fa2792

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for power_grid_model-1.4.0rc974214509214-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a456ae42def80378cac082707377486cc51a79d8a9961dc48f08359f31e8da94
MD5 73335a7ed9945ce9eb9c436c0be34151
BLAKE2b-256 52c2dba1d1d0acbbda32c7c78747e4bd389d92d096cc7a4b852d0123db4cdd2f

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