tensorpowerflow


Nametensorpowerflow JSON
Version 0.0.7 PyPI version JSON
download
home_pageNone
SummaryUltra fast power flow based in Laurent series expansion.
upload_time2024-04-17 15:28:11
maintainerNone
docs_urlNone
authorNone
requires_python>=3.0
licenseMIT
keywords power flow power systems time series loading
VCS
bugtrack_url
requirements numpy pandas matplotlib scipy tqdm numba networkx seaborn pandapower mkl psutil
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/MauricioSalazare/tensorpowerflow/master?urlpath=lab/tree/examples)
[![MIT License](https://img.shields.io/badge/License-MIT-yellow)](https://github.com/MauricioSalazare/tensorpowerflow/blob/master/LICENSE)
[![Python versions supported](https://img.shields.io/pypi/pyversions/tensorpowerflow.svg)](https://pypi.python.org/pypi/tensorpowerflow/)
[![Downloads per month](https://img.shields.io/pypi/dm/tensorpowerflow.svg)](https://pypi.python.org/pypi/tensorpowerflow/)
[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/MauricioSalazare/tensorpowerflow)](https://github.com/MauricioSalazare/tensorpowerflow)
[![PyPI - Version](https://img.shields.io/pypi/v/tensorpowerflow)](https://pypi.python.org/pypi/tensorpowerflow/)
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/MauricioSalazare/tensorpowerflow/python-package.yml)](https://github.com/MauricioSalazare/tensorpowerflow/actions)


# TensorPowerFlow

## What is TensorPowerFlow?
An ultra-fast power flow based on a fixed-point iteration algorithm. The power flow is intended for applications requiring massive
amounts of power flow computations. e.g., electrical load time series, metaheuristics, and electrical grid
environments for reinforcement learning.

## How to install

The package can be installed via pip using:

```shell
pip install tensorpowerflow
```

## Example:

Here we show four examples of what can be done with the packages:
1. *Example 1:* The package comes with a preloaded network case of 34 nodes that can be solved by default. 
2. *Example 2:* Solve 10.000 PF for the default network case. The active power for the nodes is generated by sampling a Normal 
    distribution.
3. *Example 3:* The GridTensor class can generate a random grid using the `GridTensor.generate_from_graph()` method.
    The parameters `nodes` and `child`, respectively, can control the number of nodes and branching per node.
4. *Example 4:* We test the grid with a tensor of 3 dimensions. The first dimension is the number of scenarios 
    (10 in the example). The second dimension is the number of time steps (8.760 to simulate a 30-minute resolution 
    consumption for one year). The third dimension is the number of PQ nodes in the grid (33 PQ nodes for the base 
    grid case).

```python
from tensorpowerflow import GridTensor
import numpy as np
from time import perf_counter

#%% Example 1: Solve base case (34 node bus)
network = GridTensor(gpu_mode=False)
solution = network.run_pf()
print(solution["v"])

#%% Example 2: Solve 10_000 power flows on the 34 node bus network case.
network_size = network.nb - 1 # Size of the network without the slack bus.
active_ns = np.random.normal(50, scale=1, size=(10_000, network_size)) # Power in kW
reactive_ns = active_ns * 0.1  # kVAr
solution_tensor = network.run_pf(active_power=active_ns, reactive_power=reactive_ns)
print(solution_tensor["v"])

#%% Example 3: Generate a random radial network of 100 nodes and a maximum of 1 to 3 branches per node.
network_rnd = GridTensor.generate_from_graph(nodes=100, child=3, plot_graph=True)
solution_rnd = network_rnd.run_pf()
print(solution_rnd["v"])

#%% Example 4: Solve a tensor power flow. For 10 scenarios, 8_760 time steps (one year - 1 hr res) for the 33 PQ nodes.
# Meaning that the dimensions of the tensor are (10, 8_760, 33)

network = GridTensor(numba=True)  # Loads the basic 34 bus node network.
active_ns = np.random.normal(50,  # Power in kW
                             scale=10,
                             size=(10, 8_760, 33)).round(3)  # Assume 1 slack variable
reactive_ns = (active_ns * .1).round(3)  # Constant PF of 0.1

start_tensor_dense = perf_counter()
solution = network.run_pf(active_power=active_ns, reactive_power=reactive_ns, algorithm="tensor")
t_tensor_dense = perf_counter() - start_tensor_dense
assert solution["convergence"], "Algorithm did not converge."
assert solution["v"].shape == active_ns.shape
print(f"Time tensor dense: {t_tensor_dense:.3f} sec.")


```

More examples can be found in the [examples folder](examples) (under development).
Also, you can try the package via Jupyter lab by clicking on the binder icon:

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/MauricioSalazare/tensorpowerflow/master?urlpath=lab/tree/examples)

## Reading and citations:

The mathematical formulation of the power flow can be found at:

> *"Tensor Power Flow Formulations for Multidimensional Analyses in Distribution Systems."* E.M. Salazar Duque,
Juan S. Giraldo, Pedro P. Vergara, Phuong H. Nguyen, and Han (J.G.) Slootweg. [arXiv:2403.04578 (2024)](https://arxiv.org/pdf/2403.04578).

## How to contact us

For any questions, suggestions or collaborations, contact Juan S. Giraldo at <jnse@ieee.org>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tensorpowerflow",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": null,
    "keywords": "power flow, power systems, time series loading",
    "author": null,
    "author_email": "Mauricio Salazar <e.m.salazar.duque@tue.nl>",
    "download_url": "https://files.pythonhosted.org/packages/7c/6d/b275bdbfe2ece3924bc35d863995ee54e550761ace83de0f2173dd21e087/tensorpowerflow-0.0.7.tar.gz",
    "platform": null,
    "description": "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/MauricioSalazare/tensorpowerflow/master?urlpath=lab/tree/examples)\n[![MIT License](https://img.shields.io/badge/License-MIT-yellow)](https://github.com/MauricioSalazare/tensorpowerflow/blob/master/LICENSE)\n[![Python versions supported](https://img.shields.io/pypi/pyversions/tensorpowerflow.svg)](https://pypi.python.org/pypi/tensorpowerflow/)\n[![Downloads per month](https://img.shields.io/pypi/dm/tensorpowerflow.svg)](https://pypi.python.org/pypi/tensorpowerflow/)\n[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/MauricioSalazare/tensorpowerflow)](https://github.com/MauricioSalazare/tensorpowerflow)\n[![PyPI - Version](https://img.shields.io/pypi/v/tensorpowerflow)](https://pypi.python.org/pypi/tensorpowerflow/)\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/MauricioSalazare/tensorpowerflow/python-package.yml)](https://github.com/MauricioSalazare/tensorpowerflow/actions)\n\n\n# TensorPowerFlow\n\n## What is TensorPowerFlow?\nAn ultra-fast power flow based on a fixed-point iteration algorithm. The power flow is intended for applications requiring massive\namounts of power flow computations. e.g., electrical load time series, metaheuristics, and electrical grid\nenvironments for reinforcement learning.\n\n## How to install\n\nThe package can be installed via pip using:\n\n```shell\npip install tensorpowerflow\n```\n\n## Example:\n\nHere we show four examples of what can be done with the packages:\n1. *Example 1:* The package comes with a preloaded network case of 34 nodes that can be solved by default. \n2. *Example 2:* Solve 10.000 PF for the default network case. The active power for the nodes is generated by sampling a Normal \n    distribution.\n3. *Example 3:* The GridTensor class can generate a random grid using the `GridTensor.generate_from_graph()` method.\n    The parameters `nodes` and `child`, respectively, can control the number of nodes and branching per node.\n4. *Example 4:* We test the grid with a tensor of 3 dimensions. The first dimension is the number of scenarios \n    (10 in the example). The second dimension is the number of time steps (8.760 to simulate a 30-minute resolution \n    consumption for one year). The third dimension is the number of PQ nodes in the grid (33 PQ nodes for the base \n    grid case).\n\n```python\nfrom tensorpowerflow import GridTensor\nimport numpy as np\nfrom time import perf_counter\n\n#%% Example 1: Solve base case (34 node bus)\nnetwork = GridTensor(gpu_mode=False)\nsolution = network.run_pf()\nprint(solution[\"v\"])\n\n#%% Example 2: Solve 10_000 power flows on the 34 node bus network case.\nnetwork_size = network.nb - 1 # Size of the network without the slack bus.\nactive_ns = np.random.normal(50, scale=1, size=(10_000, network_size)) # Power in kW\nreactive_ns = active_ns * 0.1  # kVAr\nsolution_tensor = network.run_pf(active_power=active_ns, reactive_power=reactive_ns)\nprint(solution_tensor[\"v\"])\n\n#%% Example 3: Generate a random radial network of 100 nodes and a maximum of 1 to 3 branches per node.\nnetwork_rnd = GridTensor.generate_from_graph(nodes=100, child=3, plot_graph=True)\nsolution_rnd = network_rnd.run_pf()\nprint(solution_rnd[\"v\"])\n\n#%% Example 4: Solve a tensor power flow. For 10 scenarios, 8_760 time steps (one year - 1 hr res) for the 33 PQ nodes.\n# Meaning that the dimensions of the tensor are (10, 8_760, 33)\n\nnetwork = GridTensor(numba=True)  # Loads the basic 34 bus node network.\nactive_ns = np.random.normal(50,  # Power in kW\n                             scale=10,\n                             size=(10, 8_760, 33)).round(3)  # Assume 1 slack variable\nreactive_ns = (active_ns * .1).round(3)  # Constant PF of 0.1\n\nstart_tensor_dense = perf_counter()\nsolution = network.run_pf(active_power=active_ns, reactive_power=reactive_ns, algorithm=\"tensor\")\nt_tensor_dense = perf_counter() - start_tensor_dense\nassert solution[\"convergence\"], \"Algorithm did not converge.\"\nassert solution[\"v\"].shape == active_ns.shape\nprint(f\"Time tensor dense: {t_tensor_dense:.3f} sec.\")\n\n\n```\n\nMore examples can be found in the [examples folder](examples) (under development).\nAlso, you can try the package via Jupyter lab by clicking on the binder icon:\n\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/MauricioSalazare/tensorpowerflow/master?urlpath=lab/tree/examples)\n\n## Reading and citations:\n\nThe mathematical formulation of the power flow can be found at:\n\n> *\"Tensor Power Flow Formulations for Multidimensional Analyses in Distribution Systems.\"* E.M. Salazar Duque,\nJuan S. Giraldo, Pedro P. Vergara, Phuong H. Nguyen, and Han (J.G.) Slootweg. [arXiv:2403.04578 (2024)](https://arxiv.org/pdf/2403.04578).\n\n## How to contact us\n\nFor any questions, suggestions or collaborations, contact Juan S. Giraldo at <jnse@ieee.org>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Ultra fast power flow based in Laurent series expansion.",
    "version": "0.0.7",
    "project_urls": {
        "repository": "https://github.com/MauricioSalazare/tensorpowerflow"
    },
    "split_keywords": [
        "power flow",
        " power systems",
        " time series loading"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "215957d08e8c3f1d077f164d678f9f785b445a3495d5417ec3e1774a1cdf9892",
                "md5": "acc3afb15aaac1c95fe75f8908159c8a",
                "sha256": "2ffb3f1871588ca7b9a3125e4aa2f5db6902b0267aa5d75f32c324cc5cceb94d"
            },
            "downloads": -1,
            "filename": "tensorpowerflow-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "acc3afb15aaac1c95fe75f8908159c8a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 31270,
            "upload_time": "2024-04-17T15:28:09",
            "upload_time_iso_8601": "2024-04-17T15:28:09.813083Z",
            "url": "https://files.pythonhosted.org/packages/21/59/57d08e8c3f1d077f164d678f9f785b445a3495d5417ec3e1774a1cdf9892/tensorpowerflow-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c6db275bdbfe2ece3924bc35d863995ee54e550761ace83de0f2173dd21e087",
                "md5": "c58697e68dc2c9cf8c89a381ded7da52",
                "sha256": "f6ec888a61cd50c025e5f8bbb99460ccd0628886e1242acb1ba9aa0b30804ddf"
            },
            "downloads": -1,
            "filename": "tensorpowerflow-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "c58697e68dc2c9cf8c89a381ded7da52",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 27763,
            "upload_time": "2024-04-17T15:28:11",
            "upload_time_iso_8601": "2024-04-17T15:28:11.648056Z",
            "url": "https://files.pythonhosted.org/packages/7c/6d/b275bdbfe2ece3924bc35d863995ee54e550761ace83de0f2173dd21e087/tensorpowerflow-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 15:28:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MauricioSalazare",
    "github_project": "tensorpowerflow",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.22.4"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    ">=",
                    "1.4.2"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    "<=",
                    "3.5.0"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.8.0"
                ]
            ]
        },
        {
            "name": "tqdm",
            "specs": [
                [
                    ">=",
                    "4.64.0"
                ]
            ]
        },
        {
            "name": "numba",
            "specs": []
        },
        {
            "name": "networkx",
            "specs": [
                [
                    ">=",
                    "2.7.1"
                ]
            ]
        },
        {
            "name": "seaborn",
            "specs": [
                [
                    ">=",
                    "0.11.2"
                ]
            ]
        },
        {
            "name": "pandapower",
            "specs": [
                [
                    ">=",
                    "2.8.0"
                ]
            ]
        },
        {
            "name": "mkl",
            "specs": []
        },
        {
            "name": "psutil",
            "specs": []
        }
    ],
    "tox": true,
    "lcname": "tensorpowerflow"
}
        
Elapsed time: 0.70976s